Skip to content

Commit

Permalink
Fix inaccurate Jail removal (ihhub#8184)
Browse files Browse the repository at this point in the history
  • Loading branch information
ihhub authored Dec 26, 2023
1 parent c155678 commit c9949d4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/fheroes2/maps/maps_tiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1443,6 +1443,7 @@ void Maps::Tiles::fixTileObjectType( Tiles & tile )

void Maps::Tiles::Remove( uint32_t uniqID )
{
// TODO: this method must update the type of the main object
_addonBottomLayer.remove_if( [uniqID]( const Maps::TilesAddon & v ) { return v._uid == uniqID; } );
_addonTopLayer.remove_if( [uniqID]( const Maps::TilesAddon & v ) { return v._uid == uniqID; } );

Expand Down
8 changes: 6 additions & 2 deletions src/fheroes2/maps/maps_tiles_helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,9 @@ namespace
Maps::Tiles & topTile = world.GetTiles( top );
topTile.Remove( tile.GetObjectUID() );

if ( topTile.GetObject() == MP2::OBJ_JAIL ) {
if ( topTile.GetObject() == MP2::OBJ_JAIL && topTile.GetObjectUID() == 0 ) {
// Since the main object was removed from the tile is it safe to mark it as empty, even if other non-main objects exist.
// This is not ideal but it doesn't break things.
topTile.setAsEmpty();
topTile.FixObject();
}
Expand All @@ -224,7 +226,9 @@ namespace
Maps::Tiles & leftTile = world.GetTiles( Maps::GetDirectionIndex( top, Direction::LEFT ) );
leftTile.Remove( tile.GetObjectUID() );

if ( leftTile.GetObject() == MP2::OBJ_JAIL ) {
if ( leftTile.GetObject() == MP2::OBJ_JAIL && leftTile.GetObjectUID() == 0 ) {
// Since the main object was removed from the tile is it safe to mark it as empty, even if other non-main objects exist.
// This is not ideal but it doesn't break things.
leftTile.setAsEmpty();
leftTile.FixObject();
}
Expand Down

0 comments on commit c9949d4

Please sign in to comment.