summaryrefslogtreecommitdiff
path: root/scene/2d
diff options
context:
space:
mode:
authorHaoyu Qiu <timothyqiu32@gmail.com>2021-12-18 15:53:21 +0800
committerHaoyu Qiu <timothyqiu32@gmail.com>2021-12-18 15:53:21 +0800
commit1078c389f993e9f2107af148eeb6c8a0311d3183 (patch)
tree052f55579f15133801bd1065a2d754004db0d35a /scene/2d
parentb0e93711b36bae3d2bb3a7e9a4a88faf055499fb (diff)
Fix crash when executing `TileMap.map_pattern`
Validates the input reference.
Diffstat (limited to 'scene/2d')
-rw-r--r--scene/2d/tile_map.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp
index 084a5a520d..2ad6476812 100644
--- a/scene/2d/tile_map.cpp
+++ b/scene/2d/tile_map.cpp
@@ -2104,6 +2104,7 @@ Ref<TileMapPattern> TileMap::get_pattern(int p_layer, TypedArray<Vector2i> p_coo
}
Vector2i TileMap::map_pattern(Vector2i p_position_in_tilemap, Vector2i p_coords_in_pattern, Ref<TileMapPattern> p_pattern) {
+ ERR_FAIL_COND_V(p_pattern.is_null(), Vector2i());
ERR_FAIL_COND_V(!p_pattern->has_cell(p_coords_in_pattern), Vector2i());
Vector2i output = p_position_in_tilemap + p_coords_in_pattern;