@@ -7,7 +7,6 @@ local schemas = require("tecs.internal.mcpschemas")
77local entityworld = require("tecs.internal.world")
88local cameraselection = require("tecs.internal.cameraselection")
99local rendercomponents = require("tecs.internal.rendercomponents")
10- local snapshotvalue = require("tecs.internal.snapshotvalue")
1110local ecs = require("tecs.ecs")
1211local materials = require("tecs.gpu.materials")
1312local layers = require("tecs.gfx.layers")
@@ -16,9 +15,9 @@ local audio = require("tecs.audio")
1615local paths = require("tecs.files")
1716local files = require("nupp.io.files")
1817local path = require("nupp.io.path")
19- local binary = require("nupp.data.binary")
2018local json = require("nupp.data.json")
2119local profile = require("nupp.profile")
20+ local buffer = require("string.buffer")
2221
2322local function register(
2423 name: string,
@@ -346,12 +345,13 @@ end
346345
347346register(
348347 "snapshot_save",
349- "Write the committed world as a versioned binary snapshot.",
348+ "Write the committed world as a native binary snapshot.",
350349 function(args: {[string]: any}): {[string]: any}
351350 local destination = artifact(args.name or "snapshot.bin")
352351 local world = bindings.requireWorld()
353- local snapshot = world:saveSnapshot()
354- local bytes = "TECS-SNAPSHOT\1" .. binary.encode(snapshotvalue.clone(snapshot))
352+ local output = buffer.new()
353+ world:saveSnapshot({format = "binary", buffer = output})
354+ local bytes = output:tostring()
355355 local ok, reason = files.writeAtomic(destination, bytes)
356356 assert(ok, reason)
357357
@@ -361,7 +361,7 @@ register(
361361)
362362register(
363363 "snapshot_load",
364- "Replace the world from a TECS NVB snapshot; legacy Teal files require conversion .",
364+ "Replace the world from a native binary snapshot.",
365365 function(args: {[string]: any}): {[string]: any}
366366 assert(path.newPath(args.path):isAbsolute(), "snapshot path must be absolute")
367367 local bytes: string
@@ -370,19 +370,14 @@ register(
370370 assert(input ~= nil, reason)
371371 local size, sizeReason = input:size()
372372 assert(size ~= nil, sizeReason)
373- assert(size <= 67108878, "snapshot exceeds the binary codec byte limit")
374373 local reader = input:newReader()
375374 local chunk, failure = reader:read(size + 1)
376375 assert(chunk ~= nil, failure)
377376 assert(#chunk == size, "snapshot changed during the read")
378377 bytes = chunk
379378 end
380- local magic = "TECS-SNAPSHOT\1"
381- assert(bytes:sub(1, #magic) == magic, "unsupported snapshot framing; legacy Teal snapshots require conversion")
382- local snapshot = binary.decode(bytes:sub(#magic + 1))
383- assert(type(snapshot) == "table", "snapshot must contain a world record")
384379 local world = bindings.requireWorld()
385- local prelude = world:loadSnapshot(snapshot as ecs.Snapshot )
380+ local prelude = world:loadSnapshot(bytes )
386381
387382 return {
388383 path = args.path,
0 commit comments