summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRémi Verschelde <remi@verschelde.fr>2023-05-26 11:23:03 +0200
committerGitHub <noreply@github.com>2023-05-26 11:23:03 +0200
commit95d745f8dc76a76592ecc391282ccf490de75078 (patch)
tree781f6d23b0d25843b6b3860d9df32d2b5b228aae
parent15b7a8e7f1c645a7fc868a0053379d1ae196c3b6 (diff)
parent88d2ed433d7f5a90f09b75dab8bd9574ffa8d4ae (diff)
downloadredot-engine-95d745f8dc76a76592ecc391282ccf490de75078.tar.gz
Merge pull request #77382 from rakkarage/tileset_merge_crash
Fix crash when using tile atlas merge with recreated alt tile
-rw-r--r--editor/plugins/tiles/atlas_merging_dialog.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/editor/plugins/tiles/atlas_merging_dialog.cpp b/editor/plugins/tiles/atlas_merging_dialog.cpp
index f958e83b4d..a91ee9fa6c 100644
--- a/editor/plugins/tiles/atlas_merging_dialog.cpp
+++ b/editor/plugins/tiles/atlas_merging_dialog.cpp
@@ -105,10 +105,11 @@ void AtlasMergingDialog::_generate_merged(Vector<Ref<TileSetAtlasSource>> p_atla
// Create tiles and alternatives, then copy their properties.
for (int alternative_index = 0; alternative_index < atlas_source->get_alternative_tiles_count(tile_mapping.key); alternative_index++) {
int alternative_id = atlas_source->get_alternative_tile_id(tile_mapping.key, alternative_index);
+ int changed_id = -1;
if (alternative_id == 0) {
merged->create_tile(tile_mapping.value, atlas_source->get_tile_size_in_atlas(tile_mapping.key));
} else {
- merged->create_alternative_tile(tile_mapping.value, alternative_index);
+ changed_id = merged->create_alternative_tile(tile_mapping.value, alternative_index);
}
// Copy the properties.
@@ -116,7 +117,7 @@ void AtlasMergingDialog::_generate_merged(Vector<Ref<TileSetAtlasSource>> p_atla
List<PropertyInfo> properties;
src_tile_data->get_property_list(&properties);
- TileData *dst_tile_data = merged->get_tile_data(tile_mapping.value, alternative_id);
+ TileData *dst_tile_data = merged->get_tile_data(tile_mapping.value, changed_id == -1 ? alternative_id : changed_id);
for (PropertyInfo property : properties) {
if (!(property.usage & PROPERTY_USAGE_STORAGE)) {
continue;