From 9bd4e5a415520cf0218bf880c15f9aa0485c6864 Mon Sep 17 00:00:00 2001 From: calic Date: Fri, 29 May 2026 01:27:49 +0200 Subject: [PATCH] =?UTF-8?q?fix(maps):=20v0.5.3=20=E2=80=94=20refresh=20atl?= =?UTF-8?q?as=5Fby=5Falias=20after=20load=5Ftextures?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit build_map_v3 caches an alias->atlas dict (atlas_by_alias) at map-load time, pointing at the resolved stubs from load_tilemap. load_textures later REPLACES m.atlases[i] in-place with the populated record (diffuse_texture_handle + per-tile UVs from the lib-asset's tiles.atlas.json) but never updated atlas_by_alias. Effect: the v3 vertex/material render path resolves m.atlas_by_alias[layer.material] to the PRE-load stub, finds no diffuse handle, and short-circuits to the MISSING_ASSET_COLOR fallback — every material-bound cell renders solid yellow regardless of the bitmask/slot computation. Fix: after each m.atlases[atlas_idx] = ... write in load_textures, also overwrite m.atlas_by_alias[atlas_alias] with the new record. Guarded on `if m.atlas_by_alias` so v2 maps (no autotile path) are unaffected. Found by the editor's freshly-bound work map after 0.2.0b.1 — vagrant was unaffected by the bug because its hand-authored map was loaded fine on the very first frame, masking the issue. --- init.lua | 7 +++++++ manifest.lib | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/init.lua b/init.lua index 09e2279..5cd0baf 100644 --- a/init.lua +++ b/init.lua @@ -1680,6 +1680,13 @@ function M.load_textures(asset_aliases) diffuse_texture_handle = ok_d and diffuse_h or nil, height_texture_handle = ok_h and height_h or nil, } + -- v0.5.3: keep atlas_by_alias in sync with the replaced atlas + -- record. Built at load time off the pre-load stub; without this + -- refresh the v3 vertex/material render path resolves through + -- atlas_by_alias to the stub and falls back to MISSING_ASSET_COLOR. + if m.atlas_by_alias then + m.atlas_by_alias[atlas_alias] = m.atlases[atlas_idx] + end end -- Update m.tile_size from first atlas only when the atlas declares a uniform diff --git a/manifest.lib b/manifest.lib index 9c70cef..6f71f74 100644 --- a/manifest.lib +++ b/manifest.lib @@ -1 +1 @@ -{"id":"lib-core.maps","version":"0.5.2","api_min":"0.1"} +{"id":"lib-core.maps","version":"0.5.3","api_min":"0.1"}