mirror of
https://github.com/1dot13/source.git
synced 2026-07-22 13:40:22 +02:00
Remove deadlock breaking from TurnBasedHandleNPCAI
It's already handled before a call to this function, and TurnBasedHandleNPCAI() is only called when pSoldier's action is AI_ACTION_NONE
This commit is contained in:
@@ -1677,33 +1677,6 @@ INT16 ActionInProgress(SOLDIERTYPE *pSoldier)
|
||||
|
||||
void TurnBasedHandleNPCAI(SOLDIERTYPE *pSoldier)
|
||||
{
|
||||
// added by Flugente: static pointers, used to break out of an endless circles (currently only used for zombie AI)
|
||||
static SOLDIERTYPE* pLastDecisionSoldier = NULL;
|
||||
static INT16 lastdecisioncount = 0;
|
||||
|
||||
// simple solution to prevent an endless clock: remember the last soldier that decided an action. If its the same one, increase the counter.
|
||||
// if counter is high enough, end this guy's turn
|
||||
if ( pSoldier == pLastDecisionSoldier )
|
||||
{
|
||||
// we will only end our turn this way if this function was called over 100 times with same soldier without ending a turn.
|
||||
// so many actions in a single turn smell of an endless clock.
|
||||
// If we end a turn normally, the counter will be set back to 0, so this wont be a problem if you have a single soldier left for multiple turns
|
||||
if ( lastdecisioncount >= 100 )
|
||||
{
|
||||
// zombie is done doing harm...
|
||||
EndAIGuysTurn( pSoldier);
|
||||
lastdecisioncount = 0;
|
||||
return ;
|
||||
}
|
||||
else
|
||||
++lastdecisioncount;
|
||||
}
|
||||
else
|
||||
{
|
||||
pLastDecisionSoldier = pSoldier;
|
||||
lastdecisioncount = 0;
|
||||
}
|
||||
|
||||
// yikes, this shouldn't occur! we should be trying to finish our move!
|
||||
// pSoldier->flags.fNoAPToFinishMove = FALSE;
|
||||
|
||||
@@ -1886,7 +1859,6 @@ void TurnBasedHandleNPCAI(SOLDIERTYPE *pSoldier)
|
||||
{
|
||||
// turn based... abort this guy's turn
|
||||
EndAIGuysTurn( pSoldier );
|
||||
lastdecisioncount = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user