From caf5828153d5d7fa22360e7270ba2832fc601ced Mon Sep 17 00:00:00 2001 From: Asdow <20314541+Asdow@users.noreply.github.com> Date: Sun, 4 Feb 2024 12:38:10 +0200 Subject: [PATCH] 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 --- TacticalAI/AIMain.cpp | 28 ---------------------------- 1 file changed, 28 deletions(-) diff --git a/TacticalAI/AIMain.cpp b/TacticalAI/AIMain.cpp index 5a03b1bf..c07e84e8 100644 --- a/TacticalAI/AIMain.cpp +++ b/TacticalAI/AIMain.cpp @@ -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