Skip to content

Commit 9b57339

Browse files
committed
Remove additional passability marks on the bottom part of tiles
1 parent b83008d commit 9b57339

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

src/fheroes2/maps/maps_tiles.cpp

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -790,24 +790,30 @@ void Maps::Tile::updatePassability()
790790
const MP2::MapObjectType correctedObjectType = MP2::getBaseActionObjectType( bottomTileObjectType );
791791

792792
if ( MP2::isOffGameActionObject( bottomTileObjectType ) || MP2::isOffGameActionObject( correctedObjectType ) ) {
793-
if ( ( bottomTile.getTileIndependentPassability() & Direction::TOP ) == 0 ) {
794-
if ( isShortObject( bottomTileObjectType ) || isShortObject( correctedObjectType ) ) {
795-
_tilePassabilityDirections &= ~Direction::BOTTOM;
796-
}
797-
else {
798-
_tilePassabilityDirections = 0;
799-
return;
800-
}
793+
if ( ( bottomTile.getTileIndependentPassability() & Direction::TOP ) != 0 ) {
794+
// This is an action object with unrestricted access from top.
795+
796+
// Only main action object parts can have unrestricted access.
797+
assert( MP2::isOffGameActionObject( bottomTileObjectType ) );
798+
return;
799+
}
800+
801+
if ( !isShortObject( bottomTileObjectType ) && !isShortObject( correctedObjectType ) ) {
802+
// Since the object on the tile below is considered as tall we must mark this tile as impassable.
803+
_tilePassabilityDirections = 0;
801804
}
805+
806+
return;
802807
}
803-
else if ( isShortObject( bottomTileObjectType )
808+
809+
if ( isShortObject( bottomTileObjectType )
804810
|| ( !bottomTile.containsAnyObjectIcnType( getValidObjectIcnTypes() )
805811
&& ( isCombinedObject( objectType ) || isCombinedObject( bottomTileObjectType ) ) ) ) {
806-
_tilePassabilityDirections &= ~Direction::BOTTOM;
812+
// If this assertion blows up then the above checks are invalid!
813+
assert( ( bottomTile.getTileIndependentPassability() & Direction::TOP ) == 0 );
807814
}
808815
else {
809816
_tilePassabilityDirections = 0;
810-
return;
811817
}
812818
}
813819
}

0 commit comments

Comments
 (0)