Encapsulate PBI Category-1 transition flags as file-statics

gfEnteringMapScreenToEnterPreBattleInterface, gfAutomaticallyStartAutoResolve
and gfDelayAutoResolveStart are now file-static in PreBattle Interface.cpp
(the latter's definition moved here from Strategic Movement.cpp). External
access goes through accessors declared in the header; PBI.cpp touches the
statics directly.

Accessors exist only where an external caller needs one:
AutomaticallyStartAutoResolve() getter (read in Town Militia,
gamescreen, Player Command); SetAutomaticallyStartAutoResolve (set in
Creature Spreading, strategicmap); SetDelayAutoResolveStart (set in
Strategic Movement);
SetEnteringMapScreenToEnterPreBattleInterface (set in strategicmap).
gfEnteringMapScreen stays a raw cross-read into mapscreen state, not
PBI-owned.  No behavior change: getter returns BOOLEAN.

Verify: grep the three flag names across the tree hits only PreBattle
Interface.cpp (three static defs, four accessor bodies, and in-file
Handle/reader access). No header externs, no external raw refs. Build: JA2.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Marco Antonio J. Costa
2026-08-02 14:58:24 -03:00
committed by majcosta
co-authored by Claude Opus 4.8
parent f1d5431660
commit 380fedca10
8 changed files with 22 additions and 17 deletions
+1 -1
View File
@@ -353,7 +353,7 @@ void InternalLeaveTacticalScreen( UINT32 uiNewScreen )
gpCustomizableTimerCallback = NULL;
// unload the sector they teleported out of
if ( !gfAutomaticallyStartAutoResolve )
if ( !AutomaticallyStartAutoResolve() )
{
CheckAndHandleUnloadingOfCurrentWorld();
}
+2 -2
View File
@@ -1210,7 +1210,7 @@ void CreatureAttackTown( UINT8 ubSectorID, BOOLEAN fOverrideTest )
InitPreBattleInterface( NULL, TRUE );
break;
case CREATURE_BATTLE_CODE_AUTORESOLVE:
gfAutomaticallyStartAutoResolve = TRUE;
SetAutomaticallyStartAutoResolve( TRUE );
InitPreBattleInterface( NULL, TRUE );
break;
case CREATURE_BATTLE_CODE_TACTICALLYADD:
@@ -1413,7 +1413,7 @@ void CreatureAttackTown_OtherCreatures( UINT8 ubSectorID, UINT8 ubType )
InitPreBattleInterface( NULL, TRUE );
break;
case CREATURE_BATTLE_CODE_AUTORESOLVE:
gfAutomaticallyStartAutoResolve = TRUE;
SetAutomaticallyStartAutoResolve( TRUE );
InitPreBattleInterface( NULL, TRUE );
break;
case CREATURE_BATTLE_CODE_TACTICALLYADD:
+1 -1
View File
@@ -455,7 +455,7 @@ BOOLEAN SetThisSectorAsEnemyControlled( INT16 sMapX, INT16 sMapY, INT8 bMapZ, BO
//KM : August 6, 1999 Patch fix
// This check was added because this function gets called when player mercs retreat from an unresolved
// battle between militia and enemies. It will get called again AFTER autoresolve is finished.
if( gfAutomaticallyStartAutoResolve )
if( AutomaticallyStartAutoResolve() )
{
return( FALSE );
}
+8 -3
View File
@@ -53,7 +53,6 @@
#include "GameInitOptionsScreen.h"
extern void InitializeTacticalStatusAtBattleStart();
extern BOOLEAN gfDelayAutoResolveStart;
extern UILayout_Map UI_MAP;
#ifdef JA2BETAVERSION
@@ -69,12 +68,13 @@ GROUP *gpTacticalTraversalGroup = NULL;
SOLDIERTYPE *gpTacticalTraversalChosenSoldier = NULL;
BOOLEAN gfAutomaticallyStartAutoResolve = FALSE;
static BOOLEAN gfAutomaticallyStartAutoResolve = FALSE;
static BOOLEAN gfDelayAutoResolveStart = FALSE;
BOOLEAN gfAutoAmbush = FALSE;
BOOLEAN gfHighPotentialForAmbush = FALSE;
BOOLEAN gfGotoSectorTransition = FALSE;
BOOLEAN gfEnterAutoResolveMode = FALSE;
BOOLEAN gfEnteringMapScreenToEnterPreBattleInterface = FALSE;
static BOOLEAN gfEnteringMapScreenToEnterPreBattleInterface = FALSE;
BOOLEAN gfIgnoreAllInput = TRUE;
BOOLEAN gfZoomDone = FALSE;
@@ -215,6 +215,11 @@ void SetPreBattleInterfaceActive( BOOLEAN fActive ) { gfPreBattleInterfaceActive
BOOLEAN IsPersistantPBI() { return gfUsePersistantPBI; }
void SetPersistantPBI( BOOLEAN fPersistant ) { gfUsePersistantPBI = fPersistant; }
BOOLEAN AutomaticallyStartAutoResolve() { return gfAutomaticallyStartAutoResolve; }
void SetAutomaticallyStartAutoResolve( BOOLEAN fAuto ) { gfAutomaticallyStartAutoResolve = fAuto; }
void SetDelayAutoResolveStart( BOOLEAN fDelay ) { gfDelayAutoResolveStart = fDelay; }
void SetEnteringMapScreenToEnterPreBattleInterface( BOOLEAN fEntering ) { gfEnteringMapScreenToEnterPreBattleInterface = fEntering; }
INT32 giHilitedInvolved = 0;
INT32 giHilitedUninvolved = 0;
+4 -2
View File
@@ -13,8 +13,11 @@ BOOLEAN IsPreBattleInterfaceActive();
void SetPreBattleInterfaceActive( BOOLEAN fActive );
BOOLEAN IsPersistantPBI();
void SetPersistantPBI( BOOLEAN fPersistant );
BOOLEAN AutomaticallyStartAutoResolve();
void SetAutomaticallyStartAutoResolve( BOOLEAN fAuto );
void SetDelayAutoResolveStart( BOOLEAN fDelay );
void SetEnteringMapScreenToEnterPreBattleInterface( BOOLEAN fEntering );
extern BOOLEAN gfDisplayPotentialRetreatPaths;
extern BOOLEAN gfAutomaticallyStartAutoResolve;
extern BOOLEAN fDisableMapInterfaceDueToBattle;
extern GROUP *gpBattleGroup;
@@ -24,7 +27,6 @@ extern GROUP *gpTacticalTraversalGroup;
extern SOLDIERTYPE *gpTacticalTraversalChosenSoldier;
extern BOOLEAN gfGotoSectorTransition;
extern BOOLEAN gfEnteringMapScreenToEnterPreBattleInterface;
enum
{
+3 -5
View File
@@ -88,8 +88,6 @@ BOOLEAN ValidateGroups( GROUP *pGroup );
extern BOOLEAN gubNumAwareBattles;
extern INT8 SquadMovementGroups[ ];
BOOLEAN gfDelayAutoResolveStart = FALSE;
BOOLEAN gfRandomizingPatrolGroup = FALSE;
@@ -1052,7 +1050,7 @@ void PrepareForPreBattleInterface( GROUP *pPlayerDialogGroup, GROUP *pInitiating
if ( pPlayerDialogGroup->usGroupTeam == MILITIA_TEAM )
{
// force direct transition to autoresolve
gfDelayAutoResolveStart = TRUE;
SetDelayAutoResolveStart( TRUE );
// We MUST start combat, but donot play quote...
InitPreBattleInterface( pInitiatingBattleGroup, TRUE );
@@ -1376,7 +1374,7 @@ BOOLEAN CheckConditionsForBattle( GROUP *pGroup )
if( !fCombatAbleMerc )
{
//Prepare for instant autoresolve.
gfDelayAutoResolveStart = TRUE;
SetDelayAutoResolveStart( TRUE );
SetPersistantPBI( TRUE );
if( fMilitiaPresent )
{
@@ -6207,7 +6205,7 @@ void CheckCombatInSectorDueToUnusualEnemyArrival( UINT8 aTeam, INT16 sX, INT16 s
if ( !fCombatAbleMerc )
{
//Prepare for instant autoresolve.
gfDelayAutoResolveStart = TRUE;
SetDelayAutoResolveStart( TRUE );
SetPersistantPBI( TRUE );
if ( fMilitiaPresent )
{
+1 -1
View File
@@ -1124,7 +1124,7 @@ void HandleMilitiaStatusInCurrentMapBeforeLoadingNewMap( void )
HandleMilitiaDefections( gWorldSectorX, gWorldSectorY );
gTacticalStatus.Team[ MILITIA_TEAM ].bSide = 0;
}
else if( !gfAutomaticallyStartAutoResolve )
else if( !AutomaticallyStartAutoResolve() )
{ //Don't promote militia if we are going directly to autoresolve to finish the current battle.
HandleMilitiaPromotions();
}
+2 -2
View File
@@ -6523,8 +6523,8 @@ BOOLEAN HandlePotentialBringUpAutoresolveToFinishBattle( int pSectorX, int pSect
pMilitia->bSectorZ == pSectorZ )
{ //We have militia and enemies and no mercs! Let's finish this battle in autoresolve.
gfEnteringMapScreen = TRUE;
gfEnteringMapScreenToEnterPreBattleInterface = TRUE;
gfAutomaticallyStartAutoResolve = TRUE;
SetEnteringMapScreenToEnterPreBattleInterface( TRUE );
SetAutomaticallyStartAutoResolve( TRUE );
SetPersistantPBI( FALSE );
gubPBSectorX = (UINT8)pSectorX;
gubPBSectorY = (UINT8)pSectorY;