Skip to content

Commit e4a93f0

Browse files
author
Portponky
committed
Fix decoration placement and tile set scene source behavior
1 parent b8531e9 commit e4a93f0

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/BetterTerrainPP.cpp

+5-6
Original file line numberDiff line numberDiff line change
@@ -299,10 +299,7 @@ int BetterTerrainPP::get_cell(int layer, godot::Vector2i coord) const
299299
return TerrainType::EMPTY;
300300

301301
godot::TileData* td = m_tilemap->get_cell_tile_data(layer, coord);
302-
if (!td)
303-
return TerrainType::EMPTY;
304-
305-
if (!td->has_meta(meta_name))
302+
if (!td || !td->has_meta(meta_name))
306303
return TerrainType::NON_TERRAIN;
307304

308305
godot::Dictionary td_meta = td->get_meta(meta_name);
@@ -482,9 +479,11 @@ void BetterTerrainPP::update_tile_immediate(int layer, godot::Vector2i coord, co
482479
if (type < TerrainType::EMPTY || type >= static_cast<int>(m_terrain_types.size()))
483480
return;
484481

482+
// Don't access m_terrain_types if type is Empty (-1)
483+
const bool terrain_is_decoration = type == TerrainType::EMPTY;
485484
const Placement* placement {nullptr};
486-
if (m_terrain_types[type] == TerrainType::MATCH_TILES || m_terrain_types[type] == TerrainType::DECORATION)
487-
placement = update_tile_tiles(coord, types, m_terrain_types[type] == TerrainType::DECORATION);
485+
if (terrain_is_decoration || m_terrain_types[type] == TerrainType::MATCH_TILES)
486+
placement = update_tile_tiles(coord, types, terrain_is_decoration);
488487
else if (m_terrain_types[type] == TerrainType::MATCH_VERTICES)
489488
placement = update_tile_vertices(coord, types);
490489

0 commit comments

Comments
 (0)