1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-04-13 11:40:38 +02:00

Better comments, remove dead code

This commit is contained in:
Ivan Savenko 2024-05-28 13:37:42 +00:00
parent f7989f6dcb
commit 3847e3e2b4
2 changed files with 15 additions and 25 deletions

View File

@ -37,7 +37,7 @@ enum class EPathAccessibility : ui8
NOT_SET,
ACCESSIBLE, //tile can be entered and passed
VISITABLE, //tile can be entered as the last tile in path
GUARDED, //visitable, but in zone of control of nearby monster
GUARDED, //tile can be entered, but is in zone of control of nearby monster (may also contain visitable object, if any)
BLOCKVIS, //visitable from neighboring tile but not passable
FLYABLE, //can only be accessed in air layer
BLOCKED //tile can be neither entered nor visited

View File

@ -267,10 +267,11 @@ PathfinderBlockingRule::BlockingReason MovementAfterDestinationRule::getBlocking
return BlockingReason::DESTINATION_BLOCKED;
case EPathNodeAction::BATTLE:
// H3 rule: do not allow direct attack on wandering monsters if hero lands on visitable object
if (config->options.originalFlyRules && destination.nodeObject && source.node->layer == EPathfindingLayer::AIR)
return BlockingReason::DESTINATION_BLOCKED;
/// Movement after BATTLE action only possible from guarded tile to guardian tile
// Movement after BATTLE action only possible from guarded tile to guardian tile
if(destination.guarded)
{
if (pathfinderHelper->options.ignoreGuards)
@ -303,7 +304,7 @@ PathfinderBlockingRule::BlockingReason MovementToDestinationRule::getBlockingRea
if(source.guarded)
{
if(source.node->layer != EPathfindingLayer::AIR
if(source.node->layer != EPathfindingLayer::AIR // zone of control is ignored when flying
&& !pathfinderConfig->options.ignoreGuards
&& (!destination.isGuardianTile || pathfinderHelper->getGuardiansCount(source.coord) > 1)) // Can step into tile of guard
{
@ -378,44 +379,33 @@ void LayerTransitionRule::process(
break;
case EPathfindingLayer::SAIL:
//tile must be accessible -> exception: unblocked blockvis tiles -> clear but guarded by nearby monster coast
if((destination.node->accessible != EPathAccessibility::ACCESSIBLE && destination.node->accessible != EPathAccessibility::GUARDED)
|| destination.tile->visitable) //TODO: passableness problem -> town says it's passable (thus accessible) but we obviously can't disembark onto town gate
{
// have to disembark first before visiting objects on land
if (destination.tile->visitable)
destination.blocked = true;
//can disembark only on accessible tiles or tiles guarded by nearby monster
if((destination.node->accessible != EPathAccessibility::ACCESSIBLE && destination.node->accessible != EPathAccessibility::GUARDED))
destination.blocked = true;
}
break;
case EPathfindingLayer::AIR:
if(pathfinderConfig->options.originalFlyRules)
{
if(source.node->accessible != EPathAccessibility::ACCESSIBLE &&
source.node->accessible != EPathAccessibility::VISITABLE &&
destination.node->accessible != EPathAccessibility::VISITABLE &&
destination.node->accessible != EPathAccessibility::ACCESSIBLE)
if(source.node->accessible != EPathAccessibility::ACCESSIBLE && source.node->accessible != EPathAccessibility::VISITABLE)
{
if (destination.node->accessible == EPathAccessibility::BLOCKVIS)
{
// Can't visit 'blockvisit' objects on coast if hero will end up on water terrain
if (source.tile->blocked || !destination.tile->entrableTerrain(source.tile))
destination.blocked = true;
}
if (destination.node->accessible == EPathAccessibility::FLYABLE)
destination.blocked = true;
}
if(destination.node->accessible == EPathAccessibility::VISITABLE)
{
if (destination.node->accessible != EPathAccessibility::VISITABLE)
destination.blocked = true;
}
}
else if(destination.node->accessible != EPathAccessibility::ACCESSIBLE)
else
{
/// Hero that fly can only land on accessible tiles
if(destination.nodeObject)
// Hero that fly can only land on accessible tiles
if(destination.node->accessible != EPathAccessibility::ACCESSIBLE && destination.nodeObject)
destination.blocked = true;
}