Wrap PBI status flags in accessors

gfPreBattleInterfaceActive and gfUsePersistantPBI are now file-static in
PreBattle Interface.cpp, reached only through Is/Set accessors declared in
the header. No behavior change: getters return BOOLEAN so ==TRUE/==FALSE
sites are untouched semantically.

Verify: grep 'gfPreBattleInterfaceActive\|gfUsePersistantPBI' across the tree
hits only the two static definitions, the four accessor bodies (all in
PreBattle Interface.cpp), and two commented-out Asserts in Strategic
Movement.cpp. Every other former site now calls an accessor. 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 d683cdeb64
commit dbf6e1cd10
11 changed files with 68 additions and 64 deletions
+1 -1
View File
@@ -427,7 +427,7 @@ UINT32 MainGameScreenHandle(void)
// WANNE: Never show the helpscreen when leaving editor and going to the tactical game
#ifndef JA2EDITOR
if( !gfPreBattleInterfaceActive && ShouldTheHelpScreenComeUp( HELP_SCREEN_TACTICAL, FALSE ) )
if( !IsPreBattleInterfaceActive() && ShouldTheHelpScreenComeUp( HELP_SCREEN_TACTICAL, FALSE ) )
{
// handle the help screen
HelpScreenHandler();
+2 -2
View File
@@ -5867,7 +5867,7 @@ BOOLEAN GetCurrentBattleSectorXYZ( INT16 *psSectorX, INT16 *psSectorY, INT16 *ps
*psSectorZ = 0;
return TRUE;
}
else if( gfPreBattleInterfaceActive )
else if( IsPreBattleInterfaceActive() )
{
*psSectorX = gubPBSectorX;
*psSectorY = gubPBSectorY;
@@ -5905,7 +5905,7 @@ BOOLEAN GetCurrentBattleSectorXYZAndReturnTRUEIfThereIsABattle( INT16 *psSectorX
*psSectorZ = 0;
return TRUE;
}
else if( gfPreBattleInterfaceActive )
else if( IsPreBattleInterfaceActive() )
{
*psSectorX = gubPBSectorX;
*psSectorY = gubPBSectorY;
+1 -1
View File
@@ -1942,7 +1942,7 @@ BOOLEAN AllowedToExitFromMapscreenTo( INT8 bExitToWhere )
}
// battle about to occur?
if( ( fDisableDueToBattleRoster ) || ( fDisableMapInterfaceDueToBattle ) || ( gfPreBattleInterfaceActive ))
if( ( fDisableDueToBattleRoster ) || ( fDisableMapInterfaceDueToBattle ) || ( IsPreBattleInterfaceActive() ))
{
return( FALSE );
}
+7 -7
View File
@@ -1250,7 +1250,7 @@ void JumpToLevel( INT32 iLevel )
return;
}
if( gfPreBattleInterfaceActive == TRUE )
if( IsPreBattleInterfaceActive() == TRUE )
{
return;
}
@@ -2164,7 +2164,7 @@ void UpdateMapScreenAssignmentPositions( void )
if( bSelectedAssignChar == -1 )
{
if( gfPreBattleInterfaceActive == FALSE )
if( IsPreBattleInterfaceActive() == FALSE )
{
giBoxY = 0;
}
@@ -2173,14 +2173,14 @@ void UpdateMapScreenAssignmentPositions( void )
if( gCharactersList[ bSelectedAssignChar ].fValid == FALSE )
{
if( gfPreBattleInterfaceActive == FALSE )
if( IsPreBattleInterfaceActive() == FALSE )
{
giBoxY = 0;
}
return;
}
if( gfPreBattleInterfaceActive )
if( IsPreBattleInterfaceActive() )
{
// do nothing
}
@@ -2325,7 +2325,7 @@ void UpdateMapScreenMilitiaControlPositions( void )
if( bSelectedAssignChar == -1 )
{
if( gfPreBattleInterfaceActive == FALSE )
if( IsPreBattleInterfaceActive() == FALSE )
{
giBoxY = 0;
}
@@ -2334,14 +2334,14 @@ void UpdateMapScreenMilitiaControlPositions( void )
if( gCharactersList[ bSelectedAssignChar ].fValid == FALSE )
{
if( gfPreBattleInterfaceActive == FALSE )
if( IsPreBattleInterfaceActive() == FALSE )
{
giBoxY = 0;
}
return;
}
if( gfPreBattleInterfaceActive )
if( IsPreBattleInterfaceActive() )
{
// do nothing
}
+1 -1
View File
@@ -395,7 +395,7 @@ void CheckForMeanwhileOKStart( )
if ( gfMeanwhileTryingToStart )
{
// Are we in prebattle interface?
if ( gfPreBattleInterfaceActive )
if ( IsPreBattleInterfaceActive() )
{
return;
}
+17 -11
View File
@@ -142,7 +142,7 @@ SOLDIERTYPE* UninvolvedSoldier( INT32 index );
MOUSE_REGION PBInterfaceBlanket;
BOOLEAN gfPreBattleInterfaceActive = FALSE;
static BOOLEAN gfPreBattleInterfaceActive = FALSE;
UINT32 iPBButton[3] = {0,0,0};
UINT32 iPBButtonImage[3] = {0,0,0};
// WDS Graphics bug die to uninitialized variable
@@ -208,7 +208,13 @@ extern UINT8 gubPBSectorZ = 0;
BOOLEAN gfCantRetreatInPBI = FALSE;
//SAVE END
BOOLEAN gfUsePersistantPBI = FALSE;
static BOOLEAN gfUsePersistantPBI = FALSE;
BOOLEAN IsPreBattleInterfaceActive() { return gfPreBattleInterfaceActive; }
void SetPreBattleInterfaceActive( BOOLEAN fActive ) { gfPreBattleInterfaceActive = fActive; }
BOOLEAN IsPersistantPBI() { return gfUsePersistantPBI; }
void SetPersistantPBI( BOOLEAN fPersistant ) { gfUsePersistantPBI = fPersistant; }
INT32 giHilitedInvolved = 0;
INT32 giHilitedUninvolved = 0;
@@ -314,7 +320,7 @@ void InitPreBattleInterface( GROUP *pBattleGroup, BOOLEAN fPersistantPBI )
AbortMovementPlottingMode( );
}
if( gfPreBattleInterfaceActive )
if( IsPreBattleInterfaceActive() )
return;
//CHRISL: If for some reason we're not looking at a valid sector, leave the preBattleInterface.
@@ -361,7 +367,7 @@ void InitPreBattleInterface( GROUP *pBattleGroup, BOOLEAN fPersistantPBI )
gpBattleGroup = pBattleGroup;
gfEnteringMapScreen = TRUE;
gfEnteringMapScreenToEnterPreBattleInterface = TRUE;
gfUsePersistantPBI = TRUE;
SetPersistantPBI( TRUE );
return;
}
#endif
@@ -375,7 +381,7 @@ void InitPreBattleInterface( GROUP *pBattleGroup, BOOLEAN fPersistantPBI )
gpBattleGroup = pBattleGroup;
gfEnteringMapScreen = TRUE;
gfEnteringMapScreenToEnterPreBattleInterface = TRUE;
gfUsePersistantPBI = TRUE;
SetPersistantPBI( TRUE );
return;
}
@@ -585,7 +591,7 @@ void InitPreBattleInterface( GROUP *pBattleGroup, BOOLEAN fPersistantPBI )
gfPBButtonsHidden = TRUE;
// ARM: this must now be set before any calls utilizing the GetCurrentBattleSectorXYZ() function
gfPreBattleInterfaceActive = TRUE;
SetPreBattleInterfaceActive( TRUE );
CheckForRobotAndIfItsControlled();
@@ -1211,7 +1217,7 @@ void ScrollPreBattleInterface( BOOLEAN fUp )
void KillPreBattleInterface()
{
if( !gfPreBattleInterfaceActive )
if( !IsPreBattleInterfaceActive() )
return;
fDisableMapInterfaceDueToBattle = FALSE;
@@ -1234,7 +1240,7 @@ void KillPreBattleInterface()
MSYS_RemoveRegion( &UninvolvedRegion );
*/
gfPreBattleInterfaceActive = FALSE;
SetPreBattleInterfaceActive( FALSE );
//UpdateCharRegionHelpText( );
@@ -2685,17 +2691,17 @@ void HandlePreBattleInterfaceStates()
if( gfEnteringMapScreenToEnterPreBattleInterface && !gfEnteringMapScreen )
{
gfEnteringMapScreenToEnterPreBattleInterface = FALSE;
if( !gfUsePersistantPBI )
if( !IsPersistantPBI() )
{
InitPreBattleInterface( NULL, FALSE );
gfUsePersistantPBI = TRUE;
SetPersistantPBI( TRUE );
}
else
{
InitPreBattleInterface( gpBattleGroup, TRUE );
}
}
else if( gfDelayAutoResolveStart && gfPreBattleInterfaceActive )
else if( gfDelayAutoResolveStart && IsPreBattleInterfaceActive() )
{
gfDelayAutoResolveStart = FALSE;
gfAutomaticallyStartAutoResolve = TRUE;
+4 -1
View File
@@ -9,7 +9,10 @@ void KillPreBattleInterface();
void RenderPreBattleInterface();
void ScrollPreBattleInterface( BOOLEAN fUp );
extern BOOLEAN gfPreBattleInterfaceActive;
BOOLEAN IsPreBattleInterfaceActive();
void SetPreBattleInterfaceActive( BOOLEAN fActive );
BOOLEAN IsPersistantPBI();
void SetPersistantPBI( BOOLEAN fPersistant );
extern BOOLEAN gfDisplayPotentialRetreatPaths;
extern BOOLEAN gfAutomaticallyStartAutoResolve;
extern BOOLEAN fDisableMapInterfaceDueToBattle;
+3 -4
View File
@@ -80,7 +80,6 @@ GROUP *gpPendingSimultaneousGroup = NULL;
// is the bottom of the map panel dirty?
extern BOOLEAN fMapScreenBottomDirty;
extern BOOLEAN gfUsePersistantPBI;
extern BOOLEAN gfExitViewer;
BOOLEAN ValidateGroups( GROUP *pGroup );
@@ -1378,7 +1377,7 @@ BOOLEAN CheckConditionsForBattle( GROUP *pGroup )
{
//Prepare for instant autoresolve.
gfDelayAutoResolveStart = TRUE;
gfUsePersistantPBI = TRUE;
SetPersistantPBI( TRUE );
if( fMilitiaPresent )
{
NotifyPlayerOfInvasionByEnemyForces( pGroup->ubSectorX, pGroup->ubSectorY, 0, TriggerPrebattleInterface );
@@ -5504,7 +5503,7 @@ void NotifyPlayerOfBloodcatBattle( UINT8 ubSectorX, UINT8 ubSectorY )
RefreshScreen( NULL );
}
gfUsePersistantPBI = TRUE;
SetPersistantPBI( TRUE );
DoScreenIndependantMessageBox( str, MSG_BOX_FLAG_OK, TriggerPrebattleInterface );
}
@@ -6209,7 +6208,7 @@ void CheckCombatInSectorDueToUnusualEnemyArrival( UINT8 aTeam, INT16 sX, INT16 s
{
//Prepare for instant autoresolve.
gfDelayAutoResolveStart = TRUE;
gfUsePersistantPBI = TRUE;
SetPersistantPBI( TRUE );
if ( fMilitiaPresent )
{
NotifyPlayerOfInvasionByEnemyForces( sX, sY, 0, TriggerPrebattleInterface );
+30 -32
View File
@@ -578,8 +578,6 @@ extern BOOLEAN fMapScreenBottomDirty;
extern BOOLEAN fResetTimerForFirstEntryIntoMapScreen;
extern BOOLEAN gfStartedFromMapScreen;
extern BOOLEAN gfUsePersistantPBI;
extern BOOLEAN gfOneFramePauseOnExit;
// the selected list of mercs
@@ -6674,7 +6672,7 @@ UINT32 HandleMapUI( )
bMapZ=gCharactersList[bSelectedInfoChar].usSolID.bSectorZ;
if( ( sSelMapX != sMapX || sSelMapY != sMapY || iCurrentMapSectorZ != bMapZ ) &&
( gTacticalStatus.fDidGameJustStart == FALSE ) && ( gfPreBattleInterfaceActive == FALSE ) )
( gTacticalStatus.fDidGameJustStart == FALSE ) && ( IsPreBattleInterfaceActive() == FALSE ) )
{
ChangeSelectedMapSector( sMapX, sMapY, bMapZ );
@@ -7035,7 +7033,7 @@ void GetMapKeyboardInput( UINT32 *puiNewEvent )
case ESC:
gfDontStartTransitionFromLaptop = TRUE;
if( gfPreBattleInterfaceActive && !gfPersistantPBI )
if( IsPreBattleInterfaceActive() && !gfPersistantPBI )
{ //Non persistant PBI. Allow ESC to close it and return to mapscreen.
KillPreBattleInterface();
gpBattleGroup = NULL;
@@ -7207,7 +7205,7 @@ void GetMapKeyboardInput( UINT32 *puiNewEvent )
break;
case PGUP:
if (gfPreBattleInterfaceActive)
if (IsPreBattleInterfaceActive())
{
ScrollPreBattleInterface(TRUE);
}
@@ -7220,7 +7218,7 @@ void GetMapKeyboardInput( UINT32 *puiNewEvent )
break;
case PGDN:
if (gfPreBattleInterfaceActive)
if (IsPreBattleInterfaceActive())
{
ScrollPreBattleInterface(FALSE);
}
@@ -7650,7 +7648,7 @@ void GetMapKeyboardInput( UINT32 *puiNewEvent )
}
else
{
if( gfPreBattleInterfaceActive )
if( IsPreBattleInterfaceActive() )
{
//activate autoresolve in prebattle interface.
ActivatePreBattleAutoresolveAction();
@@ -7756,7 +7754,7 @@ void GetMapKeyboardInput( UINT32 *puiNewEvent )
#endif
break;
case 'e':
if( gfPreBattleInterfaceActive )
if( IsPreBattleInterfaceActive() )
{ //activate enter sector in prebattle interface.
gfHotKeyEnterSector = TRUE;
}
@@ -8194,7 +8192,7 @@ void GetMapKeyboardInput( UINT32 *puiNewEvent )
#endif
break;
case 'r':
if( gfPreBattleInterfaceActive )
if( IsPreBattleInterfaceActive() )
{ //activate autoresolve in prebattle interface.
ActivatePreBattleRetreatAction();
}
@@ -9176,7 +9174,7 @@ void PollLeftButtonInMapView( UINT32 *puiNewEvent )
{
if ( /*( gTacticalStatus.fDidGameJustStart == TRUE ) || */
// commented out to allow heli drop off change @/b4 start ;)
( gfPreBattleInterfaceActive == TRUE ) ||
( IsPreBattleInterfaceActive() == TRUE ) ||
( fDisableMapInterfaceDueToBattle == TRUE ) )
{
return;
@@ -9185,7 +9183,7 @@ void PollLeftButtonInMapView( UINT32 *puiNewEvent )
else
{
if ( ( gTacticalStatus.fDidGameJustStart == TRUE ) ||
( gfPreBattleInterfaceActive == TRUE ) ||
( IsPreBattleInterfaceActive() == TRUE ) ||
( fDisableMapInterfaceDueToBattle == TRUE ) )
{
return;
@@ -9293,7 +9291,7 @@ void PollRightButtonInMapView( UINT32 *puiNewEvent )
// ignore right clicks in the map area if:
// game just started or we're in the prebattle interface or if we are about to hit pre-battle
if ( ( gTacticalStatus.fDidGameJustStart == TRUE ) ||
( gfPreBattleInterfaceActive == TRUE ) ||
( IsPreBattleInterfaceActive() == TRUE ) ||
( fDisableMapInterfaceDueToBattle == TRUE ) )
{
return;
@@ -10922,7 +10920,7 @@ void BlitBackgroundToSaveBuffer( void )
// render character info
RenderCharacterInfoBackground( );
}
else if( gfPreBattleInterfaceActive )
else if( IsPreBattleInterfaceActive() )
{
ForceButtonUnDirty( giMapContractButton );
ForceButtonUnDirty( giCharInfoButton[ 0 ] );
@@ -11288,7 +11286,7 @@ void TeamListInfoRegionBtnCallBack(MOUSE_REGION *pRegion, INT32 iReason )
SOLDIERTYPE *pSoldier = NULL;
if( fLockOutMapScreenInterface || gfPreBattleInterfaceActive )
if( fLockOutMapScreenInterface || IsPreBattleInterfaceActive() )
{
return;
}
@@ -11410,7 +11408,7 @@ void TeamListInfoRegionMvtCallBack(MOUSE_REGION *pRegion, INT32 iReason )
INT32 iValue = 0;
if( fLockOutMapScreenInterface || gfPreBattleInterfaceActive )
if( fLockOutMapScreenInterface || IsPreBattleInterfaceActive() )
{
return;
}
@@ -11443,7 +11441,7 @@ void TeamListAssignmentRegionBtnCallBack(MOUSE_REGION *pRegion, INT32 iReason )
SOLDIERTYPE *pSoldier = NULL;
if( fLockOutMapScreenInterface || gfPreBattleInterfaceActive )
if( fLockOutMapScreenInterface || IsPreBattleInterfaceActive() )
{
return;
}
@@ -11624,7 +11622,7 @@ void TeamListAssignmentRegionMvtCallBack(MOUSE_REGION *pRegion, INT32 iReason )
INT32 iValue = 0;
if( fLockOutMapScreenInterface || gfPreBattleInterfaceActive )
if( fLockOutMapScreenInterface || IsPreBattleInterfaceActive() )
{
return;
}
@@ -11683,7 +11681,7 @@ void TeamListDestinationRegionBtnCallBack(MOUSE_REGION *pRegion, INT32 iReason )
{
INT32 iValue = 0;
if( fLockOutMapScreenInterface || gfPreBattleInterfaceActive || fShowMapInventoryPool )
if( fLockOutMapScreenInterface || IsPreBattleInterfaceActive() || fShowMapInventoryPool )
{
return;
}
@@ -11805,7 +11803,7 @@ void TeamListDestinationRegionMvtCallBack(MOUSE_REGION *pRegion, INT32 iReason )
INT32 iValue = -1;
if( fLockOutMapScreenInterface || gfPreBattleInterfaceActive )
if( fLockOutMapScreenInterface || IsPreBattleInterfaceActive() )
{
return;
}
@@ -11857,7 +11855,7 @@ void TeamListSleepRegionBtnCallBack( MOUSE_REGION *pRegion, INT32 iReason )
SOLDIERTYPE *pSoldier = NULL;
if( fLockOutMapScreenInterface || gfPreBattleInterfaceActive )
if( fLockOutMapScreenInterface || IsPreBattleInterfaceActive() )
{
return;
}
@@ -11946,7 +11944,7 @@ void TeamListSleepRegionMvtCallBack( MOUSE_REGION *pRegion, INT32 iReason )
INT32 iValue = -1;
if( fLockOutMapScreenInterface || gfPreBattleInterfaceActive )
if( fLockOutMapScreenInterface || IsPreBattleInterfaceActive() )
{
return;
}
@@ -12062,7 +12060,7 @@ void TeamListContractRegionBtnCallBack(MOUSE_REGION *pRegion, INT32 iReason )
INT32 iValue = 0;
if( fLockOutMapScreenInterface || gfPreBattleInterfaceActive )
if( fLockOutMapScreenInterface || IsPreBattleInterfaceActive() )
{
return;
}
@@ -12126,7 +12124,7 @@ void TeamListContractRegionMvtCallBack(MOUSE_REGION *pRegion, INT32 iReason )
INT32 iValue = -1;
if( fLockOutMapScreenInterface || gfPreBattleInterfaceActive )
if( fLockOutMapScreenInterface || IsPreBattleInterfaceActive() )
{
return;
}
@@ -13498,7 +13496,7 @@ void FaceRegionBtnCallback( MOUSE_REGION *pRegion, INT32 iReason )
return;
}
if( gfPreBattleInterfaceActive == TRUE )
if( IsPreBattleInterfaceActive() == TRUE )
{
return;
}
@@ -13736,7 +13734,7 @@ void UpdateStatusOfMapSortButtons( void )
static BOOLEAN fShownLastTime = FALSE;
if( ( gfPreBattleInterfaceActive ) || fShowInventoryFlag )
if( ( IsPreBattleInterfaceActive() ) || fShowInventoryFlag )
{
if ( fShownLastTime )
{
@@ -13752,7 +13750,7 @@ void UpdateStatusOfMapSortButtons( void )
HideButton( giMapMPButton[ iCounter ] );
}
}
if ( gfPreBattleInterfaceActive )
if ( IsPreBattleInterfaceActive() )
{
HideButton( giCharInfoButton[ 0 ] );
HideButton( giCharInfoButton[ 1 ] );
@@ -14112,7 +14110,7 @@ void MonitorMapUIMessage( void )
void HandlePreBattleInterfaceWithInventoryPanelUp( void )
{
if( ( gfPreBattleInterfaceActive == TRUE ) && ( fShowInventoryFlag == TRUE ) )
if( ( IsPreBattleInterfaceActive() == TRUE ) && ( fShowInventoryFlag == TRUE ) )
{
if( fShowDescriptionFlag == TRUE )
{
@@ -14334,7 +14332,7 @@ BOOLEAN CharacterIsInLoadedSectorAndWantsToMoveInventoryButIsNotAllowed( INT16 b
void UpdateTheStateOfTheNextPrevMapScreenCharacterButtons( void )
{
if( gfPreBattleInterfaceActive )
if( IsPreBattleInterfaceActive() )
{
if( IsMapScreenHelpTextUp() )
{
@@ -15169,7 +15167,7 @@ BOOLEAN CanToggleSelectedCharInventory( void )
SOLDIERTYPE *pSoldier = NULL;
if( gfPreBattleInterfaceActive == TRUE )
if( IsPreBattleInterfaceActive() == TRUE )
{
return(FALSE);
}
@@ -15293,7 +15291,7 @@ void ChangeSelectedMapSector( INT16 sMapX, INT16 sMapY, INT8 bMapZ )
if( fShowMapInventoryPool )
return;
if ( gfPreBattleInterfaceActive )
if ( IsPreBattleInterfaceActive() )
return;
if( !IsTheCursorAllowedToHighLightThisSector( sMapX, sMapY ) )
@@ -17196,7 +17194,7 @@ void RequestContractMenu( void )
return;
}
if( gfPreBattleInterfaceActive == TRUE )
if( IsPreBattleInterfaceActive() == TRUE )
{
return;
}
@@ -17253,7 +17251,7 @@ void ChangeCharacterListSortMethod( INT32 iValue )
return;
}
if( gfPreBattleInterfaceActive == TRUE )
if( IsPreBattleInterfaceActive() == TRUE )
{
return;
}
+1 -3
View File
@@ -178,8 +178,6 @@ INT8 gbRegToElitePromotions = 0;
INT8 gbMilitiaPromotions = 0;
extern BOOLEAN gfUsePersistantPBI;
BOOLEAN gfUseAlternateMap = FALSE;
// whether or not we have found Orta yet
BOOLEAN fFoundOrta = FALSE;
@@ -6527,7 +6525,7 @@ BOOLEAN HandlePotentialBringUpAutoresolveToFinishBattle( int pSectorX, int pSect
gfEnteringMapScreen = TRUE;
gfEnteringMapScreenToEnterPreBattleInterface = TRUE;
gfAutomaticallyStartAutoResolve = TRUE;
gfUsePersistantPBI = FALSE;
SetPersistantPBI( FALSE );
gubPBSectorX = (UINT8)pSectorX;
gubPBSectorY = (UINT8)pSectorY;
gubPBSectorZ = (UINT8)pSectorZ;
+1 -1
View File
@@ -239,7 +239,7 @@ BOOLEAN BeginAirRaid( )
DebugMsg(TOPIC_JA2,DBG_LEVEL_3,"BeginAirRaid: in pre-battle interface?");
// ( unless we are in prebattle interface, then ignore... )
if ( gfPreBattleInterfaceActive )
if ( IsPreBattleInterfaceActive() )
{
return( FALSE );
}