generate the region maps as the game does
Every map in all 118 stored regions matches the save to the pixel, so the port is checked against ground truth rather than eyeballed. Getting there meant reproducing .NET quirks the output depends on: LCGRandom reseeding from its previous seed, Dictionary slot order in NaturalShape, and C#'s left-to-right evaluation of RNG draws. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
32
src/vsmv.sex
32
src/vsmv.sex
@@ -2,17 +2,25 @@
|
||||
;;; against a saved world and dumps what either side produced.
|
||||
|
||||
(include stdio.h string.h)
|
||||
;; An import brings in a module's own public forms but not the types
|
||||
;; they mention, so dependencies come first.
|
||||
(import cs)
|
||||
(import json)
|
||||
(import maps)
|
||||
(import lcg)
|
||||
(import noise)
|
||||
(import shape)
|
||||
(import save)
|
||||
(import dump)
|
||||
(import worldgen)
|
||||
(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"
|
||||
(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))
|
||||
|
||||
@@ -65,6 +73,26 @@
|
||||
(cJSON-Delete j))
|
||||
(return bad))
|
||||
|
||||
;;; 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 s (* save) (save/open save-path))
|
||||
(if (! s)
|
||||
(return 1))
|
||||
(var settings world-settings (world-settings/defaults))
|
||||
(= (. settings seed) (. s seed))
|
||||
(= (. settings size-x) (. s size-x))
|
||||
(= (. settings size-y) (. s size-y))
|
||||
(= (. settings size-z) (. s size-z))
|
||||
(for (var i int 0) (< i (. s config-count)) (++ i)
|
||||
(.set (& settings) [(. s config-keys) i] [(. s config-values) i]))
|
||||
(var g (* worldgen) (worldgen/make settings assets-dir))
|
||||
(if (! g)
|
||||
(return 1))
|
||||
(var failed int (+ (verify-stories s g) (verify-regions s g out)))
|
||||
(save/close s)
|
||||
(return failed))
|
||||
|
||||
(pub fn main ((argc int) (argv [* char])) int
|
||||
(if (< argc 2)
|
||||
(return (usage)))
|
||||
@@ -86,4 +114,6 @@
|
||||
(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)))
|
||||
|
||||
Reference in New Issue
Block a user