diff options
author | Yuri Sizov <yuris@humnom.net> | 2023-07-24 19:33:55 +0200 |
---|---|---|
committer | Yuri Sizov <yuris@humnom.net> | 2023-07-24 19:33:55 +0200 |
commit | f6187014ec1d7a47b7201f64f3a8376a5da2f42d (patch) | |
tree | f4096267edcbc82b7f3cbbaaf0735b897c6ee801 | |
parent | 21524e26e00b23ebbb76bce148e2993c85c2f035 (diff) | |
parent | a7ab7e469b2469acbda8026b054ddf226d53da2d (diff) | |
download | redot-engine-f6187014ec1d7a47b7201f64f3a8376a5da2f42d.tar.gz |
Merge pull request #79851 from timothyqiu/null-tileset
Fix crash when executing `TileMap.fix_invalid_tiles`
-rw-r--r-- | scene/2d/tile_map.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp index 2aa3edb03b..3c37fc7775 100644 --- a/scene/2d/tile_map.cpp +++ b/scene/2d/tile_map.cpp @@ -2273,9 +2273,12 @@ void TileMapLayer::force_update() { } void TileMapLayer::fix_invalid_tiles() { + Ref<TileSet> tileset = tile_map_node->get_tileset(); + ERR_FAIL_COND_MSG(tileset.is_null(), "Cannot call fix_invalid_tiles() on a TileMap without a valid TileSet."); + RBSet<Vector2i> coords; for (const KeyValue<Vector2i, TileMapCell> &E : tile_map) { - TileSetSource *source = *(tile_map_node->get_tileset())->get_source(E.value.source_id); + TileSetSource *source = *tileset->get_source(E.value.source_id); if (!source || !source->has_tile(E.value.get_atlas_coords()) || !source->has_alternative_tile(E.value.get_atlas_coords(), E.value.alternative_tile)) { coords.insert(E.key); } |