summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2019-11-10 10:10:29 +0100
committerGitHub <noreply@github.com>2019-11-10 10:10:29 +0100
commite711534c46dc6904704580505bc154840352c1e0 (patch)
treea6bce5a10ac91e64f2d6640bc9ccfe48016d5643 /scene
parentd65719fb13c4b824340dda10d9b0394a631b27eb (diff)
parent26b933dc21b8b7aecf6f0c908424e7738e5dc4f4 (diff)
Merge pull request #33452 from Chaosus/fix_tilemap
Fix incorrect offset for old-format tilemaps
Diffstat (limited to 'scene')
-rw-r--r--scene/resources/tile_set.cpp45
1 files changed, 35 insertions, 10 deletions
diff --git a/scene/resources/tile_set.cpp b/scene/resources/tile_set.cpp
index 24122a8d99..16a95e65a8 100644
--- a/scene/resources/tile_set.cpp
+++ b/scene/resources/tile_set.cpp
@@ -148,20 +148,45 @@ bool TileSet::_set(const StringName &p_name, const Variant &p_value) {
}
}
} else if (what == "shape")
- for (int i = 0; i < tile_get_shape_count(id); i++)
- tile_set_shape(id, i, p_value);
+ if (tile_get_shape_count(id) > 0) {
+ for (int i = 0; i < tile_get_shape_count(id); i++) {
+ tile_set_shape(id, i, p_value);
+ }
+ } else {
+ tile_set_shape(id, 0, p_value);
+ }
else if (what == "shape_offset")
- for (int i = 0; i < tile_get_shape_count(id); i++)
- tile_set_shape_offset(id, i, p_value);
+ if (tile_get_shape_count(id) > 0) {
+ for (int i = 0; i < tile_get_shape_count(id); i++) {
+ tile_set_shape_offset(id, i, p_value);
+ }
+ } else {
+ tile_set_shape_offset(id, 0, p_value);
+ }
else if (what == "shape_transform")
- for (int i = 0; i < tile_get_shape_count(id); i++)
- tile_set_shape_transform(id, i, p_value);
+ if (tile_get_shape_count(id) > 0) {
+ for (int i = 0; i < tile_get_shape_count(id); i++) {
+ tile_set_shape_transform(id, i, p_value);
+ }
+ } else {
+ tile_set_shape_transform(id, 0, p_value);
+ }
else if (what == "shape_one_way")
- for (int i = 0; i < tile_get_shape_count(id); i++)
- tile_set_shape_one_way(id, i, p_value);
+ if (tile_get_shape_count(id) > 0) {
+ for (int i = 0; i < tile_get_shape_count(id); i++) {
+ tile_set_shape_one_way(id, i, p_value);
+ }
+ } else {
+ tile_set_shape_one_way(id, 0, p_value);
+ }
else if (what == "shape_one_way_margin")
- for (int i = 0; i < tile_get_shape_count(id); i++)
- tile_set_shape_one_way_margin(id, i, p_value);
+ if (tile_get_shape_count(id) > 0) {
+ for (int i = 0; i < tile_get_shape_count(id); i++) {
+ tile_set_shape_one_way_margin(id, i, p_value);
+ }
+ } else {
+ tile_set_shape_one_way_margin(id, 0, p_value);
+ }
else if (what == "shapes")
_tile_set_shapes(id, p_value);
else if (what == "occluder")