Fix crash when using tile atlas merge with recreated alt tile

(cherry picked from commit 88d2ed433d)
This commit is contained in:
Rakka Rage 2023-06-29 16:03:22 +02:00 committed by Yuri Sizov
parent a3951382cd
commit 980d95a3ad
1 changed files with 3 additions and 2 deletions

View File

@ -106,10 +106,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.
@ -117,7 +118,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;