summaryrefslogtreecommitdiff
path: root/src/LivingVillage.Kernel
diff options
context:
space:
mode:
Diffstat (limited to 'src/LivingVillage.Kernel')
-rw-r--r--src/LivingVillage.Kernel/Sim.fs13
-rw-r--r--src/LivingVillage.Kernel/WorldSave.fs12
2 files changed, 20 insertions, 5 deletions
diff --git a/src/LivingVillage.Kernel/Sim.fs b/src/LivingVillage.Kernel/Sim.fs
index 0845abd..9da7c46 100644
--- a/src/LivingVillage.Kernel/Sim.fs
+++ b/src/LivingVillage.Kernel/Sim.fs
@@ -235,8 +235,17 @@ module Sim =
let dtSeconds = 1.0 / float ticksPerSecond
let dtSecondsF = 1.0f / float32 ticksPerSecond
- let mapWidthTiles = 64
- let mapHeightTiles = 48
+ /// World dimensions are parameterized so a large procedural map (e.g. 512x384)
+ /// can reuse every movement/wander/clamp rule. Defaults stay the legacy 64x48 to
+ /// keep all existing deterministic tests and baselines untouched.
+ let mutable mapWidthTiles = 64
+ let mutable mapHeightTiles = 48
+
+ /// Configure the world size. Note: the caller must not step worlds during a
+ /// reconfiguration; bounds are read per step from these values.
+ let configureBounds (widthTiles: int) (heightTiles: int) : unit =
+ mapWidthTiles <- widthTiles
+ mapHeightTiles <- heightTiles
let tilePixels = 32
let avatarSpeed = 160.0f
diff --git a/src/LivingVillage.Kernel/WorldSave.fs b/src/LivingVillage.Kernel/WorldSave.fs
index 8a47c7d..e68a45f 100644
--- a/src/LivingVillage.Kernel/WorldSave.fs
+++ b/src/LivingVillage.Kernel/WorldSave.fs
@@ -469,7 +469,9 @@ module WorldSave =
let save (world: World) : string =
let tokens = ResizeArray<string>()
- add tokens formatVersion
+ add tokens "LV_WORLD_SAVE_V2"
+ addInt tokens mapWidthTiles
+ addInt tokens mapHeightTiles
addInt64 tokens world.Tick
addFloat tokens world.Time
addUInt64 tokens world.Rng.State
@@ -492,8 +494,12 @@ module WorldSave =
try
let tokens = text.Split([| '|' |], StringSplitOptions.None)
let reader = TokenReader(tokens)
- if reader.Take("format") <> formatVersion then
- invalid "unsupported save format"
+ match reader.Take("format") with
+ | "LV_WORLD_SAVE_V2" ->
+ configureBounds (readInt reader "bounds.w") (readInt reader "bounds.h")
+ | v1 when v1 = formatVersion ->
+ configureBounds 64 48
+ | _ -> invalid "unsupported save format"
let tick = readInt64 reader "tick"
let time = readFloat reader "time"
let rng = { State = readUInt64 reader "rng" }