summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2019-07-03 21:25:43 +0200
committerGitHub <noreply@github.com>2019-07-03 21:25:43 +0200
commit2832c5aa94009c757ca9ba94489e158886205f5b (patch)
treea8201c2971a3d49d4716bd6320fc287ae2e00d79
parente81ddf1242aa5b8e4f1736952ac7461d1d76459d (diff)
parent1b8b36c771fcecb3a40c058547f6a95d8027d9d8 (diff)
Merge pull request #30290 from qarmin/tile_set_again
Fix crash with TileSet(again)
-rw-r--r--scene/resources/tile_set.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/scene/resources/tile_set.cpp b/scene/resources/tile_set.cpp
index 899abfc9f9..bd5ce91e77 100644
--- a/scene/resources/tile_set.cpp
+++ b/scene/resources/tile_set.cpp
@@ -731,6 +731,8 @@ void TileSet::tile_set_shape(int p_id, int p_shape_id, const Ref<Shape2D> &p_sha
Ref<Shape2D> TileSet::tile_get_shape(int p_id, int p_shape_id) const {
ERR_FAIL_COND_V(!tile_map.has(p_id), Ref<Shape2D>());
+ ERR_FAIL_COND_V(p_shape_id < 0, Ref<Shape2D>());
+
if (p_shape_id < tile_map[p_id].shapes_data.size())
return tile_map[p_id].shapes_data[p_shape_id].shape;
@@ -740,6 +742,7 @@ Ref<Shape2D> TileSet::tile_get_shape(int p_id, int p_shape_id) const {
void TileSet::tile_set_shape_transform(int p_id, int p_shape_id, const Transform2D &p_offset) {
ERR_FAIL_COND(!tile_map.has(p_id));
+ ERR_FAIL_COND(p_shape_id < 0);
if (p_shape_id >= tile_map[p_id].shapes_data.size())
tile_map[p_id].shapes_data.resize(p_shape_id + 1);
@@ -750,6 +753,8 @@ void TileSet::tile_set_shape_transform(int p_id, int p_shape_id, const Transform
Transform2D TileSet::tile_get_shape_transform(int p_id, int p_shape_id) const {
ERR_FAIL_COND_V(!tile_map.has(p_id), Transform2D());
+ ERR_FAIL_COND_V(p_shape_id < 0, Transform2D());
+
if (p_shape_id < tile_map[p_id].shapes_data.size())
return tile_map[p_id].shapes_data[p_shape_id].shape_transform;
@@ -780,6 +785,8 @@ void TileSet::tile_set_shape_one_way(int p_id, int p_shape_id, const bool p_one_
bool TileSet::tile_get_shape_one_way(int p_id, int p_shape_id) const {
ERR_FAIL_COND_V(!tile_map.has(p_id), false);
+ ERR_FAIL_COND_V(p_shape_id < 0, false);
+
if (p_shape_id < tile_map[p_id].shapes_data.size())
return tile_map[p_id].shapes_data[p_shape_id].one_way_collision;
@@ -800,6 +807,8 @@ void TileSet::tile_set_shape_one_way_margin(int p_id, int p_shape_id, float p_ma
float TileSet::tile_get_shape_one_way_margin(int p_id, int p_shape_id) const {
ERR_FAIL_COND_V(!tile_map.has(p_id), 0);
+ ERR_FAIL_COND_V(p_shape_id < 0, 0);
+
if (p_shape_id < tile_map[p_id].shapes_data.size())
return tile_map[p_id].shapes_data[p_shape_id].one_way_collision_margin;