Merge pull request #52459 from groud/fix_terrain_editor_reset

Fix TileSet terrain painting reset to no terrain
This commit is contained in:
Gilles Roudière 2021-09-08 09:19:39 +02:00 committed by GitHub
commit b0fd7ae642
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1465,12 +1465,13 @@ void TileDataTerrainsEditor::_tile_set_changed() {
ERR_FAIL_COND(!tile_set.is_valid()); ERR_FAIL_COND(!tile_set.is_valid());
// Fix if wrong values are selected. // Fix if wrong values are selected.
if (int(dummy_object->get("terrain_set")) > tile_set->get_terrain_sets_count()) { int terrain_set = int(dummy_object->get("terrain_set"));
if (terrain_set >= tile_set->get_terrain_sets_count()) {
terrain_set = -1;
dummy_object->set("terrain_set", -1); dummy_object->set("terrain_set", -1);
} }
int terrain_set = int(dummy_object->get("terrain"));
if (terrain_set >= 0) { if (terrain_set >= 0) {
if (int(dummy_object->get("terrain")) > tile_set->get_terrains_count(terrain_set)) { if (int(dummy_object->get("terrain")) >= tile_set->get_terrains_count(terrain_set)) {
dummy_object->set("terrain", -1); dummy_object->set("terrain", -1);
} }
} }