mirror of
https://github.com/1dot13/source.git
synced 2026-09-16 14:47:17 +02:00
Fix indentation
This commit is contained in:
+107
-111
@@ -432,7 +432,7 @@ INT8 RandomPointPatrolAI(SOLDIERTYPE *pSoldier)
|
|||||||
INT32 InternalGoAsFarAsPossibleTowards(SOLDIERTYPE *pSoldier, INT32 sDesGrid, INT16 bReserveAPs, INT8 bAction, INT8 fFlags )
|
INT32 InternalGoAsFarAsPossibleTowards(SOLDIERTYPE *pSoldier, INT32 sDesGrid, INT16 bReserveAPs, INT8 bAction, INT8 fFlags )
|
||||||
{
|
{
|
||||||
#ifdef DEBUGDECISIONS
|
#ifdef DEBUGDECISIONS
|
||||||
STR16 tempstr;
|
STR16 tempstr;
|
||||||
#endif
|
#endif
|
||||||
INT32 sLoop,sAPCost;
|
INT32 sLoop,sAPCost;
|
||||||
INT32 sTempDest,sGoToGrid;
|
INT32 sTempDest,sGoToGrid;
|
||||||
@@ -583,156 +583,152 @@ INT32 InternalGoAsFarAsPossibleTowards(SOLDIERTYPE *pSoldier, INT32 sDesGrid, IN
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// HAVE FOUND AN OK destination AND PLOTTED A VALID BEST PATH TO IT
|
// HAVE FOUND AN OK destination AND PLOTTED A VALID BEST PATH TO IT
|
||||||
|
|
||||||
|
|
||||||
#ifdef DEBUGDECISIONS
|
#ifdef DEBUGDECISIONS
|
||||||
AINumMessage("Chosen legal destination is gridno ",sDesGrid);
|
AINumMessage("Chosen legal destination is gridno ",sDesGrid);
|
||||||
AINumMessage("Tracing along path, pathRouteToGo = ",pSoldier->pathing.usPathIndex);
|
AINumMessage("Tracing along path, pathRouteToGo = ",pSoldier->pathing.usPathIndex);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
sGoToGrid = pSoldier->sGridNo; // start back where soldier is standing now
|
sGoToGrid = pSoldier->sGridNo; // start back where soldier is standing now
|
||||||
sAPCost = 0; // initialize path cost counter
|
sAPCost = 0; // initialize path cost counter
|
||||||
|
|
||||||
// 0verhaul: If the destination is within the patrol route, allow it. This is necessary to allow an errant soldier
|
// 0verhaul: If the destination is within the patrol route, allow it. This is necessary to allow an errant soldier
|
||||||
// to return to his patrol route if flanking or other actions have pulled him beyond his allowed range from origin.
|
// to return to his patrol route if flanking or other actions have pulled him beyond his allowed range from origin.
|
||||||
if (SpacesAway(sOrigin,sDesGrid) <= usMaxDist)
|
if (SpacesAway(sOrigin,sDesGrid) <= usMaxDist)
|
||||||
{
|
{
|
||||||
fAllowDest = TRUE;
|
fAllowDest = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// we'll only go as far along the plotted route as is within our
|
// we'll only go as far along the plotted route as is within our
|
||||||
// permitted roaming range, and we'll stop as soon as we're down to <= 5 APs
|
// permitted roaming range, and we'll stop as soon as we're down to <= 5 APs
|
||||||
|
|
||||||
sTempDest = pSoldier->sGridNo;
|
sTempDest = pSoldier->sGridNo;
|
||||||
|
|
||||||
for (sLoop = 0; sLoop < (pSoldier->pathing.usPathDataSize - pSoldier->pathing.usPathIndex); sLoop++)
|
for (sLoop = 0; sLoop < (pSoldier->pathing.usPathDataSize - pSoldier->pathing.usPathIndex); sLoop++)
|
||||||
{
|
{
|
||||||
// what is the next gridno in the path?
|
// what is the next gridno in the path?
|
||||||
|
|
||||||
//sTempDest = NewGridNo( sGoToGrid,DirectionInc( (INT16) (pSoldier->pathing.usPathingData[sLoop] + 1) ) );
|
//sTempDest = NewGridNo( sGoToGrid,DirectionInc( (INT16) (pSoldier->pathing.usPathingData[sLoop] + 1) ) );
|
||||||
//sTempDest = NewGridNo( sGoToGrid,DirectionInc( (UINT8) (pSoldier->pathing.usPathingData[sLoop]) ) );
|
//sTempDest = NewGridNo( sGoToGrid,DirectionInc( (UINT8) (pSoldier->pathing.usPathingData[sLoop]) ) );
|
||||||
sTempDest = NewGridNo( sTempDest,DirectionInc( (UINT8) (pSoldier->pathing.usPathingData[sLoop]) ) );
|
sTempDest = NewGridNo( sTempDest,DirectionInc( (UINT8) (pSoldier->pathing.usPathingData[sLoop]) ) );
|
||||||
|
|
||||||
// this should NEVER be out of bounds
|
// this should NEVER be out of bounds
|
||||||
if (sTempDest == sGoToGrid)
|
if (sTempDest == sGoToGrid)
|
||||||
{
|
{
|
||||||
#ifdef BETAVERSION
|
#ifdef BETAVERSION
|
||||||
sprintf(tempstr,"GoAsFarAsPossibleTowards: ERROR - gridno along valid route is invalid! guynum %d, sTempDest = %d",pSoldier->ubID,sTempDest);
|
sprintf(tempstr,"GoAsFarAsPossibleTowards: ERROR - gridno along valid route is invalid! guynum %d, sTempDest = %d",pSoldier->ubID,sTempDest);
|
||||||
|
|
||||||
#ifdef RECORDNET
|
#ifdef RECORDNET
|
||||||
fprintf(NetDebugFile,"\n\t%s\n",tempstr);
|
fprintf(NetDebugFile,"\n\t%s\n",tempstr);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
PopMessage(tempstr);
|
PopMessage(tempstr);
|
||||||
SaveGame(ERROR_SAVE);
|
SaveGame(ERROR_SAVE);
|
||||||
#endif
|
#endif
|
||||||
|
break; // quit here, sGoToGrid is where we are going
|
||||||
break; // quit here, sGoToGrid is where we are going
|
|
||||||
}
|
|
||||||
|
|
||||||
// if this takes us beyond our permitted "roaming range"
|
|
||||||
// but if it brings us closer, then allow it!
|
|
||||||
if (SpacesAway(sOrigin,sTempDest) > usMaxDist && !fAllowDest)
|
|
||||||
break; // quit here, sGoToGrid is where we are going
|
|
||||||
|
|
||||||
|
|
||||||
if ( usRoomRequired )
|
|
||||||
{
|
|
||||||
if ( !( InARoom( sTempDest, &usTempRoom ) && usTempRoom == usRoomRequired ) )
|
|
||||||
{
|
|
||||||
// quit here, limited by room!
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if ( (fFlags & FLAG_STOPSHORT) && SpacesAway( sDesGrid, sTempDest ) <= STOPSHORTDIST )
|
// if this takes us beyond our permitted "roaming range"
|
||||||
{
|
// but if it brings us closer, then allow it!
|
||||||
break; // quit here, sGoToGrid is where we are going
|
if (SpacesAway(sOrigin,sTempDest) > usMaxDist && !fAllowDest)
|
||||||
}
|
break; // quit here, sGoToGrid is where we are going
|
||||||
|
|
||||||
// CAN'T CALL PathCost() HERE! IT CALLS findBestPath() and overwrites
|
|
||||||
// pathRouteToGo !!! Gotta calculate the cost ourselves - Ian
|
|
||||||
//
|
|
||||||
//ubAPsLeft = pSoldier->bActionPoints - PathCost(pSoldier,sTempDest,FALSE,FALSE,FALSE,FALSE,FALSE);
|
|
||||||
|
|
||||||
if (gfTurnBasedAI)
|
if ( usRoomRequired )
|
||||||
{
|
|
||||||
// if we're just starting the "costing" process (first gridno)
|
|
||||||
if (sLoop == 0)
|
|
||||||
{
|
|
||||||
if (pSoldier->usUIMovementMode == RUNNING)
|
|
||||||
{
|
|
||||||
sAPCost += GetAPsStartRun( pSoldier ); // changed by SANDRO
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ATE: Direction here?
|
|
||||||
sAPCost += EstimateActionPointCost( pSoldier, sTempDest, (INT8) pSoldier->pathing.usPathingData[sLoop], pSoldier->usUIMovementMode, (INT8) sLoop, (INT8) pSoldier->pathing.usPathDataSize );
|
|
||||||
|
|
||||||
bAPsLeft = pSoldier->bActionPoints - sAPCost;
|
|
||||||
}
|
|
||||||
|
|
||||||
// if this gridno is NOT a legal NPC destination
|
|
||||||
// DONT'T test path again - that would replace the traced path! - Ian
|
|
||||||
// NOTE: It's OK to go *THROUGH* water to try and get to the destination!
|
|
||||||
// sevenfm: jump over fence code - if current gridno is not legal destination, check next gridno
|
|
||||||
if (!LegalNPCDestination(pSoldier,sTempDest,IGNORE_PATH,WATEROK,0))
|
|
||||||
{
|
|
||||||
// break;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// if after this, we have <= 5 APs remaining, that's far enough, break out
|
|
||||||
// (the idea is to preserve APs so we can crouch or react if
|
|
||||||
// necessary, and benefit from the carry-over next turn if not needed)
|
|
||||||
// This routine is NOT used by any GREEN AI, so such caution is warranted!
|
|
||||||
|
|
||||||
if ( gfTurnBasedAI && (bAPsLeft < bReserveAPs) )
|
|
||||||
break;
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
sGoToGrid = sTempDest; // we're OK up to here
|
if ( !( InARoom( sTempDest, &usTempRoom ) && usTempRoom == usRoomRequired ) )
|
||||||
|
{
|
||||||
|
// quit here, limited by room!
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// if exactly 5 APs left, don't bother checking any further
|
if ( (fFlags & FLAG_STOPSHORT) && SpacesAway( sDesGrid, sTempDest ) <= STOPSHORTDIST )
|
||||||
if ( gfTurnBasedAI && (bAPsLeft == bReserveAPs) )
|
{
|
||||||
|
break; // quit here, sGoToGrid is where we are going
|
||||||
|
}
|
||||||
|
|
||||||
|
// CAN'T CALL PathCost() HERE! IT CALLS findBestPath() and overwrites
|
||||||
|
// pathRouteToGo !!! Gotta calculate the cost ourselves - Ian
|
||||||
|
//
|
||||||
|
//ubAPsLeft = pSoldier->bActionPoints - PathCost(pSoldier,sTempDest,FALSE,FALSE,FALSE,FALSE,FALSE);
|
||||||
|
|
||||||
|
if (gfTurnBasedAI)
|
||||||
|
{
|
||||||
|
// if we're just starting the "costing" process (first gridno)
|
||||||
|
if (sLoop == 0)
|
||||||
|
{
|
||||||
|
if (pSoldier->usUIMovementMode == RUNNING)
|
||||||
|
{
|
||||||
|
sAPCost += GetAPsStartRun( pSoldier ); // changed by SANDRO
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ATE: Direction here?
|
||||||
|
sAPCost += EstimateActionPointCost( pSoldier, sTempDest, (INT8) pSoldier->pathing.usPathingData[sLoop], pSoldier->usUIMovementMode, (INT8) sLoop, (INT8) pSoldier->pathing.usPathDataSize );
|
||||||
|
bAPsLeft = pSoldier->bActionPoints - sAPCost;
|
||||||
|
}
|
||||||
|
|
||||||
|
// if this gridno is NOT a legal NPC destination
|
||||||
|
// DONT'T test path again - that would replace the traced path! - Ian
|
||||||
|
// NOTE: It's OK to go *THROUGH* water to try and get to the destination!
|
||||||
|
// sevenfm: jump over fence code - if current gridno is not legal destination, check next gridno
|
||||||
|
if (!LegalNPCDestination(pSoldier,sTempDest,IGNORE_PATH,WATEROK,0))
|
||||||
|
{
|
||||||
|
// break;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// if after this, we have <= 5 APs remaining, that's far enough, break out
|
||||||
|
// (the idea is to preserve APs so we can crouch or react if
|
||||||
|
// necessary, and benefit from the carry-over next turn if not needed)
|
||||||
|
// This routine is NOT used by any GREEN AI, so such caution is warranted!
|
||||||
|
|
||||||
|
if ( gfTurnBasedAI && (bAPsLeft < bReserveAPs) )
|
||||||
break;
|
break;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sGoToGrid = sTempDest; // we're OK up to here
|
||||||
|
|
||||||
|
// if exactly 5 APs left, don't bother checking any further
|
||||||
|
if ( gfTurnBasedAI && (bAPsLeft == bReserveAPs) )
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// if it turned out we couldn't go even 1 tile towards the desired gridno
|
// if it turned out we couldn't go even 1 tile towards the desired gridno
|
||||||
if (sGoToGrid == pSoldier->sGridNo)
|
if (sGoToGrid == pSoldier->sGridNo)
|
||||||
{
|
{
|
||||||
#ifdef DEBUGDECISIONS
|
#ifdef DEBUGDECISIONS
|
||||||
sprintf(tempstr,"%s will go NOWHERE, path doesn't meet criteria",pSoldier->name);
|
sprintf(tempstr,"%s will go NOWHERE, path doesn't meet criteria",pSoldier->name);
|
||||||
AIPopMessage(tempstr);
|
AIPopMessage(tempstr);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
pSoldier->pathing.usPathIndex = pSoldier->pathing.usPathDataSize = 0;
|
pSoldier->pathing.usPathIndex = pSoldier->pathing.usPathDataSize = 0;
|
||||||
return(NOWHERE); // then go nowhere
|
return(NOWHERE); // then go nowhere
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
// possible optimization - stored path IS good if we're going all the way
|
|
||||||
if (sGoToGrid == sDesGrid)
|
|
||||||
{
|
{
|
||||||
pSoldier->pathing.bPathStored = TRUE;
|
// possible optimization - stored path IS good if we're going all the way
|
||||||
pSoldier->pathing.sFinalDestination = sGoToGrid;
|
if (sGoToGrid == sDesGrid)
|
||||||
}
|
{
|
||||||
else if ( pSoldier->pathing.usPathIndex == 0 )
|
pSoldier->pathing.bPathStored = TRUE;
|
||||||
{
|
pSoldier->pathing.sFinalDestination = sGoToGrid;
|
||||||
// we can hack this surely! -- CJC
|
}
|
||||||
pSoldier->pathing.bPathStored = TRUE;
|
else if ( pSoldier->pathing.usPathIndex == 0 )
|
||||||
pSoldier->pathing.sFinalDestination = sGoToGrid;
|
{
|
||||||
pSoldier->pathing.usPathDataSize = sLoop + 1;
|
// we can hack this surely! -- CJC
|
||||||
}
|
pSoldier->pathing.bPathStored = TRUE;
|
||||||
|
pSoldier->pathing.sFinalDestination = sGoToGrid;
|
||||||
|
pSoldier->pathing.usPathDataSize = sLoop + 1;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef DEBUGDECISIONS
|
#ifdef DEBUGDECISIONS
|
||||||
ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_BETAVERSION, L"%d to %d with %d APs left", pSoldier->ubID, sGoToGrid, pSoldier->bActionPoints );
|
ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_BETAVERSION, L"%d to %d with %d APs left", pSoldier->ubID, sGoToGrid, pSoldier->bActionPoints );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
return( sGoToGrid );
|
return( sGoToGrid );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user