mirror of
https://github.com/1dot13/source.git
synced 2026-09-16 14:47:17 +02:00
Fix: use system time instead of game time for breaking AI deadlock as game time is affected by fast timer mode, as a result breaking AI decision before it can execute normally.
Allow to break AI deadlock manually by pressing ESC key after 10 seconds, auto break AI after DEAD_LOCK_DELAY seconds. git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@9383 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
@@ -65,6 +65,9 @@ extern INT8 STRAIGHT;
|
|||||||
//extern UINT8 gubSpeedUpAnimationFactor;
|
//extern UINT8 gubSpeedUpAnimationFactor;
|
||||||
void SetSoldierAniSpeed( SOLDIERTYPE *pSoldier );
|
void SetSoldierAniSpeed( SOLDIERTYPE *pSoldier );
|
||||||
|
|
||||||
|
// sevenfm
|
||||||
|
time_t gtTimeSinceMercAIStart;
|
||||||
|
|
||||||
void RecalculateSoldiersAniSpeed()
|
void RecalculateSoldiersAniSpeed()
|
||||||
{
|
{
|
||||||
UINT32 uiLoop;
|
UINT32 uiLoop;
|
||||||
@@ -764,6 +767,7 @@ void DisplayHiddenTurnbased( SOLDIERTYPE * pActingSoldier )
|
|||||||
DebugAI( String( "Giving AI control to %d", pActingSoldier->ubID ) );
|
DebugAI( String( "Giving AI control to %d", pActingSoldier->ubID ) );
|
||||||
pActingSoldier->flags.fTurnInProgress = TRUE;
|
pActingSoldier->flags.fTurnInProgress = TRUE;
|
||||||
gTacticalStatus.uiTimeSinceMercAIStart = GetJA2Clock();
|
gTacticalStatus.uiTimeSinceMercAIStart = GetJA2Clock();
|
||||||
|
gtTimeSinceMercAIStart = time(0); // sevenfm: also remember system time
|
||||||
|
|
||||||
if ( gTacticalStatus.ubTopMessageType != COMPUTER_TURN_MESSAGE)
|
if ( gTacticalStatus.ubTopMessageType != COMPUTER_TURN_MESSAGE)
|
||||||
{
|
{
|
||||||
|
|||||||
+12
-3
@@ -53,6 +53,7 @@
|
|||||||
#include "points.h"
|
#include "points.h"
|
||||||
#include "Soldier Functions.h" // added by SANDRO
|
#include "Soldier Functions.h" // added by SANDRO
|
||||||
#include "Text.h" // sevenfm
|
#include "Text.h" // sevenfm
|
||||||
|
#include "english.h" // sevenfm: for ESC key
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "connect.h"
|
#include "connect.h"
|
||||||
@@ -114,8 +115,8 @@ INT8 gbDiff[MAX_DIFF_PARMS][5] =
|
|||||||
{ 4, 6, 8, 10, 13 } // DIFF_MAX_COVER_RANGE
|
{ 4, 6, 8, 10, 13 } // DIFF_MAX_COVER_RANGE
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// sevenfm
|
||||||
|
extern time_t gtTimeSinceMercAIStart;
|
||||||
|
|
||||||
void EndAIGuysTurn( SOLDIERTYPE *pSoldier );
|
void EndAIGuysTurn( SOLDIERTYPE *pSoldier );
|
||||||
|
|
||||||
@@ -696,7 +697,14 @@ void HandleSoldierAI( SOLDIERTYPE *pSoldier ) // FIXME - this function is named
|
|||||||
|
|
||||||
if (gfTurnBasedAI)
|
if (gfTurnBasedAI)
|
||||||
{
|
{
|
||||||
if ( ( GetJA2Clock() - gTacticalStatus.uiTimeSinceMercAIStart ) > ( (UINT32)gGameExternalOptions.gubDeadLockDelay * 1000 ) && !gfUIInDeadlock )
|
time_t tCurrentTime = time(0);
|
||||||
|
UINT32 uiShortDelay = 10;
|
||||||
|
UINT32 uiDelay = (UINT32)gGameExternalOptions.gubDeadLockDelay;
|
||||||
|
UINT32 uiTime = (UINT32)(tCurrentTime - gtTimeSinceMercAIStart);
|
||||||
|
BOOLEAN fKeyPressed = _KeyDown(ESC);
|
||||||
|
|
||||||
|
if ((uiTime > uiDelay || uiTime > uiShortDelay && fKeyPressed) && !gfUIInDeadlock)
|
||||||
|
//if ( ( GetJA2Clock() - gTacticalStatus.uiTimeSinceMercAIStart ) > ( (UINT32)gGameExternalOptions.gubDeadLockDelay * 1000 ) && !gfUIInDeadlock )
|
||||||
{
|
{
|
||||||
// ATE: Display message that deadlock occured...
|
// ATE: Display message that deadlock occured...
|
||||||
LiveMessage( "Breaking Deadlock" );
|
LiveMessage( "Breaking Deadlock" );
|
||||||
@@ -1042,6 +1050,7 @@ void StartNPCAI(SOLDIERTYPE *pSoldier)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
gTacticalStatus.uiTimeSinceMercAIStart = GetJA2Clock();
|
gTacticalStatus.uiTimeSinceMercAIStart = GetJA2Clock();
|
||||||
|
gtTimeSinceMercAIStart = time(0);
|
||||||
|
|
||||||
DebugMsg( TOPIC_JA2AI, DBG_LEVEL_3 , "Clock set" );
|
DebugMsg( TOPIC_JA2AI, DBG_LEVEL_3 , "Clock set" );
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user