mirror of
https://github.com/1dot13/source.git
synced 2026-09-09 14:46:05 +02:00
Refactor merc backpack checking in FindBestPath (#162)
* remove unused fNonFenceJumper from AstarPathfinder::GetPath * Extract backpack check into function and flip logic Avoiding double negatives is nice
This commit is contained in:
@@ -76,7 +76,6 @@ private:
|
|||||||
|
|
||||||
SOLDIERTYPE* pSoldier;
|
SOLDIERTYPE* pSoldier;
|
||||||
INT8 onRooftop;//aka ubLevel, not sure if this bool is logically reversed yet
|
INT8 onRooftop;//aka ubLevel, not sure if this bool is logically reversed yet
|
||||||
bool fNonFenceJumper;
|
|
||||||
bool fNonSwimmer;
|
bool fNonSwimmer;
|
||||||
bool fPathingForPlayer;
|
bool fPathingForPlayer;
|
||||||
bool fPathAroundPeople;
|
bool fPathAroundPeople;
|
||||||
|
|||||||
+6
-4
@@ -454,6 +454,11 @@ UINT32 guiFailedPathChecks = 0;
|
|||||||
UINT32 guiUnsuccessfulPathChecks = 0;
|
UINT32 guiUnsuccessfulPathChecks = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
static auto canJumpFences(SOLDIERTYPE* pSoldier) -> bool {
|
||||||
|
return IS_MERC_BODY_TYPE(pSoldier) && pSoldier->CanClimbWithCurrentBackpack();
|
||||||
|
}
|
||||||
|
|
||||||
//ADB the extra cover feature is supposed to pick a path of the same distance as one calculated with the feature off,
|
//ADB the extra cover feature is supposed to pick a path of the same distance as one calculated with the feature off,
|
||||||
//but a safer path, usually farther away from an enemy or following behind some cover.
|
//but a safer path, usually farther away from an enemy or following behind some cover.
|
||||||
//however it has not been tested and it may need some work, I haven't touched it in a while
|
//however it has not been tested and it may need some work, I haven't touched it in a while
|
||||||
@@ -638,7 +643,6 @@ int AStarPathfinder::GetPath(SOLDIERTYPE *s ,
|
|||||||
|
|
||||||
fTurnBased = ( (gTacticalStatus.uiFlags & TURNBASED) && (gTacticalStatus.uiFlags & INCOMBAT) );
|
fTurnBased = ( (gTacticalStatus.uiFlags & TURNBASED) && (gTacticalStatus.uiFlags & INCOMBAT) );
|
||||||
fPathingForPlayer = ( (pSoldier->bTeam == gbPlayerNum) && (!gTacticalStatus.fAutoBandageMode) && !(pSoldier->flags.uiStatusFlags & SOLDIER_PCUNDERAICONTROL) );
|
fPathingForPlayer = ( (pSoldier->bTeam == gbPlayerNum) && (!gTacticalStatus.fAutoBandageMode) && !(pSoldier->flags.uiStatusFlags & SOLDIER_PCUNDERAICONTROL) );
|
||||||
fNonFenceJumper = !( IS_MERC_BODY_TYPE( pSoldier ) );
|
|
||||||
fNonSwimmer = !( IS_MERC_BODY_TYPE( pSoldier ) );
|
fNonSwimmer = !( IS_MERC_BODY_TYPE( pSoldier ) );
|
||||||
fPathAroundPeople = ( (fFlags & PATH_THROUGH_PEOPLE) == 0 );
|
fPathAroundPeople = ( (fFlags & PATH_THROUGH_PEOPLE) == 0 );
|
||||||
fCloseGoodEnough = ( (fFlags & PATH_CLOSE_GOOD_ENOUGH) != 0);
|
fCloseGoodEnough = ( (fFlags & PATH_CLOSE_GOOD_ENOUGH) != 0);
|
||||||
@@ -2244,7 +2248,6 @@ INT32 FindBestPath(SOLDIERTYPE *s , INT32 sDestination, INT8 bLevel, INT16 usMov
|
|||||||
DOOR * pDoor;
|
DOOR * pDoor;
|
||||||
STRUCTURE * pDoorStructure;
|
STRUCTURE * pDoorStructure;
|
||||||
BOOLEAN fDoorIsOpen = FALSE;
|
BOOLEAN fDoorIsOpen = FALSE;
|
||||||
BOOLEAN fNonFenceJumper;
|
|
||||||
BOOLEAN fNonSwimmer;
|
BOOLEAN fNonSwimmer;
|
||||||
BOOLEAN fPathAroundPeople;
|
BOOLEAN fPathAroundPeople;
|
||||||
BOOLEAN fConsiderPersonAtDestAsObstacle;
|
BOOLEAN fConsiderPersonAtDestAsObstacle;
|
||||||
@@ -2316,7 +2319,6 @@ if(!GridNoOnVisibleWorldTile(iDestination))
|
|||||||
fTurnBased = ( (gTacticalStatus.uiFlags & TURNBASED) && (gTacticalStatus.uiFlags & INCOMBAT) );
|
fTurnBased = ( (gTacticalStatus.uiFlags & TURNBASED) && (gTacticalStatus.uiFlags & INCOMBAT) );
|
||||||
|
|
||||||
fPathingForPlayer = ( (s->bTeam == gbPlayerNum) && (!gTacticalStatus.fAutoBandageMode) && !(s->flags.uiStatusFlags & SOLDIER_PCUNDERAICONTROL) );
|
fPathingForPlayer = ( (s->bTeam == gbPlayerNum) && (!gTacticalStatus.fAutoBandageMode) && !(s->flags.uiStatusFlags & SOLDIER_PCUNDERAICONTROL) );
|
||||||
fNonFenceJumper = !( IS_MERC_BODY_TYPE( s ) ) || (!s->CanClimbWithCurrentBackpack());//Moa: added backpack check
|
|
||||||
|
|
||||||
// Flugente: nonswimmers are those who are not mercs and not boats
|
// Flugente: nonswimmers are those who are not mercs and not boats
|
||||||
fNonSwimmer = !(IS_MERC_BODY_TYPE( s ) );
|
fNonSwimmer = !(IS_MERC_BODY_TYPE( s ) );
|
||||||
@@ -2930,7 +2932,7 @@ if(!GridNoOnVisibleWorldTile(iDestination))
|
|||||||
nextCost = gTileTypeMovementCost[ gpWorldLevelData[ newLoc ].ubTerrainID ];
|
nextCost = gTileTypeMovementCost[ gpWorldLevelData[ newLoc ].ubTerrainID ];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( nextCost == TRAVELCOST_FENCE && fNonFenceJumper )
|
else if ( nextCost == TRAVELCOST_FENCE && !canJumpFences(s))
|
||||||
{
|
{
|
||||||
goto NEXTDIR;
|
goto NEXTDIR;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user