1
0
mirror of https://github.com/godotengine/godot.git synced 2026-01-06 19:41:11 +00:00

Merge pull request #44839 from qarmin/fix_crash_tile_map

Do not iterate over map when removing its values
This commit is contained in:
Rémi Verschelde
2021-01-01 23:06:35 +01:00
committed by GitHub

View File

@@ -1024,7 +1024,9 @@ void TileMap::update_dirty_bitmask() {
void TileMap::fix_invalid_tiles() {
ERR_FAIL_COND_MSG(tile_set.is_null(), "Cannot fix invalid tiles if Tileset is not open.");
for (Map<PosKey, Cell>::Element *E = tile_map.front(); E; E = E->next()) {
Map<PosKey, Cell> temp_tile_map = tile_map;
for (Map<PosKey, Cell>::Element *E = temp_tile_map.front(); E; E = E->next()) {
if (!tile_set->has_tile(get_cell(E->key().x, E->key().y))) {
set_cell(E->key().x, E->key().y, INVALID_CELL);
}