Skip to content

Commit

Permalink
Fix most of left cases with passabilities
Browse files Browse the repository at this point in the history
close #4348
close #4491
close #4389
close #4339
relates to #4495
  • Loading branch information
ihhub committed Jan 19, 2022
1 parent 99fa793 commit 010b4cd
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/fheroes2/maps/maps_tiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -977,9 +977,22 @@ void Maps::Tiles::updatePassability()
return;
}

// Count how many objects are there excluding shadows, roads and river streams.
const std::ptrdiff_t validLevel1ObjectCount = std::count_if( addons_level1.begin(), addons_level1.end(),
[]( const TilesAddon & addon ) {
if ( TilesAddon::isShadow( addon ) ) {
return false;
}

const int icnType = MP2::GetICNObject( addon.object );
return icnType != ICN::ROAD && icnType != ICN::STREAM;
} );

const bool singleObjectTile = validLevel1ObjectCount == 0 && addons_level2.empty() && ( bottomTile.objectTileset >> 2 ) != ( objectTileset >> 2 );
const bool isBottomTileObject = ( ( bottomTile._level >> 1 ) & 1 ) == 0;

if ( !isDetachedObject() && isBottomTileObject && bottomTile.objectTileset > 0 && bottomTile.objectIndex < 255 ) {
// TODO: we might need to simplify the logic below as singleObjectTile might cover most of it.
if ( !singleObjectTile && !isDetachedObject() && isBottomTileObject && bottomTile.objectTileset > 0 && bottomTile.objectIndex < 255 ) {
const MP2::MapObjectType bottomTileObjectType = bottomTile.GetObject( false );
const bool isBottomTileActionObject = MP2::isActionObject( bottomTileObjectType );
const MP2::MapObjectType correctedObjectType = MP2::getBaseActionObjectType( bottomTileObjectType );
Expand Down

0 comments on commit 010b4cd

Please sign in to comment.