Fix crash making a tileset bigger and pressing Remap (fix #4144)

This happens only if the tilemap already has tile references outside
the valid range of the tileset (and even bigger than the new tileset
size).
This commit is contained in:
David Capello 2023-11-15 20:58:00 -03:00
parent a6d9dce339
commit 340ed3f68f

View File

@ -965,9 +965,11 @@ void ColorBar::onRemapTilesButtonClick()
if (n > 0) {
for (const ImageRef& tilemap : tilemaps) {
for (const doc::tile_t t : LockImageBits<TilemapTraits>(tilemap.get()))
if (t != doc::notile)
usedTiles[doc::tile_geti(t)] = true;
for (const doc::tile_t t : LockImageBits<TilemapTraits>(tilemap.get())) {
const doc::tile_index ti = doc::tile_geti(t);
if (ti > 0 && ti < n)
usedTiles[ti] = true;
}
}
}