diff options
author | Rafał Mikrut <mikrutrafal@protonmail.com> | 2020-12-31 15:47:37 +0100 |
---|---|---|
committer | Rafał Mikrut <mikrutrafal@protonmail.com> | 2020-12-31 15:47:37 +0100 |
commit | 29b288238108ca34b25a58a9376f418d61e55420 (patch) | |
tree | ed35156a5f156d919e2214416df3c61f13c6eca0 | |
parent | 41e9028868e49669de83c82ba20fd9dcef0d1b8b (diff) | |
download | redot-engine-29b288238108ca34b25a58a9376f418d61e55420.tar.gz |
Do not iterate over map when removing its values
-rw-r--r-- | scene/2d/tile_map.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp index 928a839cc1..cf8f395821 100644 --- a/scene/2d/tile_map.cpp +++ b/scene/2d/tile_map.cpp @@ -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); } |