A chunk's solid blocks are a palette of block ids, raw or zstd, and a zstd frame of bit planes; a layer of a lone 0 is all air. With them, vsmv verify compares the rock of every stored block below the surface with the strata laid against our own heights, which predate the dry seabed raise: 99.91% of 1.38 billion blocks match. Lava basalt near the bottom, the granite of cave walls and structures, and columns whose height differs explain all but 0.0011%, nearly all of that in one area at the explored edge whose layer boundaries are not explained yet. What the save has instead of stratum rock is tallied too, as the ground truth the deposits phase can be checked against. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
121 lines
4.8 KiB
Scheme
121 lines
4.8 KiB
Scheme
;;; vsmv: the command-line side of the viewer. It checks the generator
|
|
;;; against a saved world and dumps what either side produced.
|
|
|
|
(include stdio.h string.h)
|
|
(import cs)
|
|
(import json)
|
|
(import save)
|
|
(import dump)
|
|
(import worldgen)
|
|
(import rivers)
|
|
(import strata)
|
|
(import settings)
|
|
(import ores)
|
|
(import verify)
|
|
|
|
(var worldgen-assets [(* const char) 6]
|
|
#("landforms" "geologicprovinces" "rockstrata" "storystructures"
|
|
"blocklayers" "deposits"))
|
|
|
|
(fn usage () int
|
|
(fputs "usage: vsmv info SAVE.vcdbs\n vsmv seed TEXT...\n vsmv assets ASSETS-DIR\n vsmv dump SAVE.vcdbs OUT-DIR\n vsmv verify SAVE.vcdbs ASSETS-DIR OUT-DIR\n"
|
|
stderr)
|
|
(return 2))
|
|
|
|
(fn info ((path (* const char))) int
|
|
(var s (* save) (save/open path))
|
|
(if (! s)
|
|
(return 1))
|
|
(printf "seed %d\n" (. s seed))
|
|
(printf "size %d x %d x %d\n" (. s size-x) (. s size-y) (. s size-z))
|
|
(printf "block ids %d\n" (. s block-count))
|
|
(printf "world config, %d values:\n" (. s config-count))
|
|
(for (var i int 0) (< i (. s config-count)) (++ i)
|
|
(printf " %-28s %s\n" [(. s config-keys) i] [(. s config-values) i]))
|
|
(printf "story locations:\n")
|
|
(for (var i int 0) (< i (. s story-count)) (++ i)
|
|
(var l (* story-location) (& [(. s stories) i]))
|
|
(printf " %-24s %8d %4d %6d\n" (. l code) (. l x) (. l y) (. l z)))
|
|
(var regions extent (save/extent s "mapregion"))
|
|
(var chunks extent (save/extent s "mapchunk"))
|
|
(printf "map regions %lld, x %d..%d z %d..%d\n" (. regions count)
|
|
(. regions x0) (. regions x1) (. regions z0) (. regions z1))
|
|
(printf "map chunks %lld, x %d..%d z %d..%d\n" (. chunks count)
|
|
(. chunks x0) (. chunks x1) (. chunks z0) (. chunks z1))
|
|
(save/close s)
|
|
(return 0))
|
|
|
|
;;; vsmv assets assets -> each worldgen file's top-level arrays and
|
|
;;; the rock strata in generation order, which the result depends on.
|
|
(fn assets ((dir (* const char))) int
|
|
(var bad int 0)
|
|
(for (var i int 0) (< i 6) (++ i)
|
|
(var path [char 1024])
|
|
(snprintf path (sizeof path) "%s/survival/worldgen/%s.json" dir [worldgen-assets i])
|
|
(var j (* cJSON) (json-load path))
|
|
(if (! j)
|
|
(do (++ bad) (continue)))
|
|
(printf "%s:" [worldgen-assets i])
|
|
(for (var item (* cJSON) (. j child)) item (= item (. item next))
|
|
(if (cJSON-IsArray item)
|
|
(printf " %s[%d]" (. item string) (cJSON-GetArraySize item))))
|
|
(printf "\n")
|
|
(if (== (strcmp [worldgen-assets i] "rockstrata") 0)
|
|
(do
|
|
(var variants (* cJSON) (cJSON-GetObjectItemCaseSensitive j "variants"))
|
|
(for (var v (* cJSON) (. variants child)) v (= v (. v next))
|
|
(printf " %-20s %-12s %s\n"
|
|
(cJSON-GetStringValue (cJSON-GetObjectItemCaseSensitive v "blockcode"))
|
|
(cJSON-GetStringValue (cJSON-GetObjectItemCaseSensitive v "rockGroup"))
|
|
(cJSON-GetStringValue (cJSON-GetObjectItemCaseSensitive v "genDir"))))))
|
|
(cJSON-Delete j))
|
|
(return bad))
|
|
|
|
;;; Generates every region the save stored, with the save's own world
|
|
;;; settings, and diffs the maps.
|
|
;;; Generates every region the save stored, with the save's own world
|
|
;;; settings, and diffs the maps.
|
|
(fn verify ((save-path (* const char)) (assets-dir (* const char)) (out (* const char))) int
|
|
(var source world-source)
|
|
(if (! (world-source/load save-path (& source)))
|
|
(return 1))
|
|
(var g (* worldgen) (worldgen/make (. source settings) assets-dir))
|
|
(if (! g)
|
|
(return 1))
|
|
(var s (* save) (save/open save-path))
|
|
(var rocks (* strata) (strata/make g assets-dir))
|
|
(var minerals (* ores) (ores/make (. source settings) assets-dir rocks))
|
|
(var failed int (+ (verify-stories s g) (verify-regions s g out)
|
|
(verify-ores s minerals out)
|
|
(verify-readings s g (river-config/defaults) rocks minerals)
|
|
(verify-strata s g (river-config/defaults) rocks out)
|
|
(verify-rivers s g (river-config/defaults) out)
|
|
(verify-heights s g (river-config/defaults) rocks out)))
|
|
(save/close s)
|
|
(return failed))
|
|
|
|
(pub fn main ((argc int) (argv [* char])) int
|
|
(if (< argc 2)
|
|
(return (usage)))
|
|
(var cmd (* const char) [argv 1])
|
|
(if (&& (== (strcmp cmd "info") 0) (== argc 3))
|
|
(return (info [argv 2])))
|
|
(if (&& (== (strcmp cmd "seed") 0) (>= argc 3))
|
|
(do
|
|
(for (var i int 2) (< i argc) (++ i)
|
|
(printf "%d\t%s\n" (world-seed [argv i]) [argv i]))
|
|
(return 0)))
|
|
(if (&& (== (strcmp cmd "assets") 0) (== argc 3))
|
|
(return (assets [argv 2])))
|
|
(if (&& (== (strcmp cmd "dump") 0) (== argc 4))
|
|
(do
|
|
(var s (* save) (save/open [argv 2]))
|
|
(if (! s)
|
|
(return 1))
|
|
(dump s [argv 3])
|
|
(save/close s)
|
|
(return 0)))
|
|
(if (&& (== (strcmp cmd "verify") 0) (== argc 5))
|
|
(return (verify [argv 2] [argv 3] [argv 4])))
|
|
(return (usage)))
|