feat(maps): save_to_disk emits cells_material conditionally
cells_material is added to the per-layer JSON only when at least one entry is non-zero, so v0.5.6-vintage maps with no cell-tile content write byte-identical output through the 0.5.7 serializer. Maps with cell-tile content round-trip the array through save and reload. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
15
init.lua
15
init.lua
@@ -1761,6 +1761,21 @@ local function serialize_map_v3(map)
|
|||||||
if layer.material ~= nil then layer_out.material = layer.material end
|
if layer.material ~= nil then layer_out.material = layer.material end
|
||||||
if layer.vertices ~= nil then layer_out.vertices = layer.vertices end
|
if layer.vertices ~= nil then layer_out.vertices = layer.vertices end
|
||||||
if layer.overrides ~= nil then layer_out.overrides = layer.overrides end
|
if layer.overrides ~= nil then layer_out.overrides = layer.overrides end
|
||||||
|
-- 0.5.7: emit cells_material only when at least one entry is
|
||||||
|
-- non-zero. This preserves byte-identical save output for
|
||||||
|
-- pre-0.5.7-content maps.
|
||||||
|
if layer.cells_material then
|
||||||
|
local any_set = false
|
||||||
|
for i = 1, #layer.cells_material do
|
||||||
|
if layer.cells_material[i] and layer.cells_material[i] ~= 0 then
|
||||||
|
any_set = true
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if any_set then
|
||||||
|
layer_out.cells_material = layer.cells_material
|
||||||
|
end
|
||||||
|
end
|
||||||
out.layers[layer_name] = layer_out
|
out.layers[layer_name] = layer_out
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user