feat(stdlib): Tiled P6 — infinite/chunked maps, .world stitching, base64+zstd (#74)
- Infinite/chunked maps: <chunk x y width height> (TMX) and JSON chunks[] (default 16x16) decode and flatten into the dense layer array, sized to the chunk union; the map's 0/0 header dimensions fall back to the flattened bounds. - .world stitching: Tiled.world / Tiled.world_count / Tiled.world_map read a .world (JSON, reusing Json.parse) and list its member maps at their offsets. - base64+zstd: a self-contained pure-Ludic Zstandard decompressor (runtime/native/zstd.ludic, RFC 8878) — the design's "largest single item, explicitly last". Frame header + raw/RLE/compressed blocks; raw/RLE and direct-weight Huffman literals; the full FSE sequence path (predefined, transcribed exactly from zstd's hardcoded tables since they're not rebuildable from the default distributions; RLE; FSE-described) with repeat offsets and execution. Decodes the low-entropy GID streams a tilemap produces; a high- entropy FSE-compressed-Huffman-weights block fails cleanly with -1 rather than emitting wrong bytes (documented scope). Proven by library/tiled_p6.ludic (12 assertions): TMX + TMJ chunk flattening, .world offsets, and a real zstd-compressed tile layer decoding byte-exactly to its CSV baseline. x test: 97 passed. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
78a5719fae
commit
764a0296ce
16 changed files with 18356 additions and 17205 deletions
1
assets/tiled-fixtures/demo.world
Normal file
1
assets/tiled-fixtures/demo.world
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"maps": [{"fileName": "zstd_map.tmx", "x": 0, "y": 0, "width": 384, "height": 256}, {"fileName": "grid_maze.tmx", "x": 384, "y": 0, "width": 128, "height": 80}], "onlyShowAdjacentMaps": false, "type": "world"}
|
||||
1
assets/tiled-fixtures/infinite_map.tmj
Normal file
1
assets/tiled-fixtures/infinite_map.tmj
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"type": "map", "version": "1.10", "orientation": "orthogonal", "renderorder": "right-down", "width": 0, "height": 0, "tilewidth": 16, "tileheight": 16, "infinite": true, "tilesets": [{"firstgid": 1, "source": "collision.tsx"}], "layers": [{"type": "tilelayer", "id": 1, "name": "ground", "width": 0, "height": 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, 3, 3, 3, 3, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]}]}]}
|
||||
15
assets/tiled-fixtures/infinite_map.tmx
Normal file
15
assets/tiled-fixtures/infinite_map.tmx
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Hand-authored P6 infinite/chunked fixture (issue #74). CC0. -->
|
||||
<map version="1.10" tiledversion="1.10.2" orientation="orthogonal" renderorder="right-down" width="0" height="0" tilewidth="16" tileheight="16" infinite="1" nextlayerid="2" nextobjectid="1">
|
||||
<tileset firstgid="1" source="collision.tsx"/>
|
||||
<layer id="1" name="ground" width="0" height="0">
|
||||
<data encoding="csv">
|
||||
<chunk x="0" y="0" width="16" height="16">
|
||||
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1,3,3,3,3,3,3,3,3,3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||||
15
assets/tiled-fixtures/zstd_map.tmx
Normal file
15
assets/tiled-fixtures/zstd_map.tmx
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Hand-authored P6 zstd fixture (issue #74). CC0. -->
|
||||
<map version="1.10" tiledversion="1.10.2" orientation="orthogonal" renderorder="right-down" width="24" height="16" tilewidth="16" tileheight="16" infinite="0" nextlayerid="3" nextobjectid="1">
|
||||
<tileset firstgid="1" source="collision.tsx"/>
|
||||
<layer id="1" name="csv" width="24" height="16">
|
||||
<data encoding="csv">
|
||||
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1,1,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1,1,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1,1,3,3,3,3,3,2,3,3,3,3,3,2,3,3,3,3,3,2,3,3,3,3,1,1,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1,1,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1,1,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1,1,3,3,3,3,3,2,3,3,3,3,3,2,3,3,3,3,3,2,3,3,3,3,1,1,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1,1,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1,1,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1,1,3,3,3,3,3,2,3,3,3,3,3,2,3,3,3,3,3,2,3,3,3,3,1,1,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1,1,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
|
||||
</data>
|
||||
</layer>
|
||||
<layer id="2" name="zstd" width="24" height="16">
|
||||
<data encoding="base64" compression="zstd">
|
||||
KLUv/WAABe0AADgBAAAAAwIBBgC4mgT54KqgO9JxR0xFgOm26RIB
|
||||
</data>
|
||||
</layer>
|
||||
</map>
|
||||
Loading…
Add table
Add a link
Reference in a new issue