Cleaned up assignment menu code (WIP)

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8534 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Flugente
2018-03-03 16:04:47 +00:00
parent cf2f219067
commit 62f8b7d3e8
+65 -199
View File
@@ -16398,24 +16398,21 @@ void HandleShadingOfLinesForAttributeMenus( void )
{ {
// will do the same as updateassignments...but with training pop up box strings // will do the same as updateassignments...but with training pop up box strings
SOLDIERTYPE *pSoldier; SOLDIERTYPE *pSoldier;
INT8 bAttrib =0;
BOOLEAN fStatTrainable; BOOLEAN fStatTrainable;
if ( gAssignMenuState != ASMENU_TRAIN || ( ghTrainingBox == - 1 ) ) if ( gAssignMenuState != ASMENU_TRAIN || ( ghTrainingBox == - 1 ) )
{ {
return; return;
} }
if( ( fShowAttributeMenu == FALSE ) || ( ghAttributeBox == - 1 ) ) if ( !fShowAttributeMenu || ( ghAttributeBox == - 1 ) )
{ {
return; return;
} }
pSoldier = GetSelectedAssignSoldier( FALSE ); pSoldier = GetSelectedAssignSoldier( FALSE );
for( bAttrib = 0; bAttrib < ATTRIB_MENU_CANCEL; ++bAttrib ) for( INT8 bAttrib = 0; bAttrib < ATTRIB_MENU_CANCEL; ++bAttrib )
{ {
switch ( gbTrainingMode ) switch ( gbTrainingMode )
{ {
@@ -16447,8 +16444,6 @@ void HandleShadingOfLinesForAttributeMenus( void )
ShadeStringInBox( ghAttributeBox, bAttrib ); ShadeStringInBox( ghAttributeBox, bAttrib );
} }
} }
return;
} }
void HandleShadingOfLinesForSnitchMenu( void ) void HandleShadingOfLinesForSnitchMenu( void )
@@ -16485,21 +16480,17 @@ void HandleShadingOfLinesForSnitchMenu( void )
ShadeStringInBox( ghSnitchBox, SNITCH_MENU_TOGGLE ); ShadeStringInBox( ghSnitchBox, SNITCH_MENU_TOGGLE );
ShadeStringInBox( ghSnitchBox, SNITCH_MENU_SECTOR ); ShadeStringInBox( ghSnitchBox, SNITCH_MENU_SECTOR );
} }
//UnSecondaryShadeStringInBox( ghTrainingBox, TRAIN_MENU_TOWN );
return;
} }
void HandleShadingOfLinesForSnitchToggleMenu( void ) void HandleShadingOfLinesForSnitchToggleMenu( void )
{ {
SOLDIERTYPE *pSoldier = NULL;
// check if valid // check if valid
if( ( fShowSnitchToggleMenu == FALSE ) || ( ghSnitchToggleBox == - 1 ) ) if( ( fShowSnitchToggleMenu == FALSE ) || ( ghSnitchToggleBox == - 1 ) )
{ {
return; return;
} }
pSoldier = GetSelectedAssignSoldier( FALSE ); SOLDIERTYPE* pSoldier = GetSelectedAssignSoldier( FALSE );
if( pSoldier->usSoldierFlagMask2 & SOLDIER_SNITCHING_OFF ) if( pSoldier->usSoldierFlagMask2 & SOLDIER_SNITCHING_OFF )
{ {
@@ -16586,43 +16577,14 @@ void HandleShadingOfLinesForSnitchSectorMenu( void )
} }
} }
/*void ResetAssignmentsForAllSoldiersInSectorWhoAreTrainingTown( SOLDIERTYPE *pSoldier )
{
INT32 iNumberOnTeam = 0, iCounter = 0;
SOLDIERTYPE *pCurSoldier = NULL;
iNumberOnTeam = gTacticalStatus.Team[ OUR_TEAM ].bLastID;
for( iCounter = 0; iCounter < iNumberOnTeam; iCounter++ )
{
pCurSoldier = &Menptr[ iCounter ];
if( ( pCurSoldier->bActive ) && ( pCurSoldier->stats.bLife >= OKLIFE ) )
{
if( pCurSoldier->bAssignment == TRAIN_TOWN )
{
if( ( pCurSoldier->sSectorX == pSoldier->sSectorX ) && ( pCurSoldier->sSectorY == pSoldier->sSectorY ) && ( pSoldier->bSectorZ == 0 ) )
{
AddCharacterToAnySquad( pCurSoldier );
}
}
}
}
return;
}*/
void ReportTrainersTraineesWithoutPartners( void ) void ReportTrainersTraineesWithoutPartners( void )
{ {
SOLDIERTYPE *pTeamSoldier = NULL; SOLDIERTYPE *pTeamSoldier = NULL;
INT32 iCounter = 0, iNumberOnTeam = 0; INT32 iCounter = 0;
INT32 iNumberOnTeam = gTacticalStatus.Team[ OUR_TEAM ].bLastID;
iNumberOnTeam = gTacticalStatus.Team[ OUR_TEAM ].bLastID;
// check for each instructor // check for each instructor
for( iCounter = 0; iCounter < iNumberOnTeam; iCounter++ ) for( iCounter = 0; iCounter < iNumberOnTeam; ++iCounter )
{ {
pTeamSoldier = &Menptr[ iCounter ]; pTeamSoldier = &Menptr[ iCounter ];
@@ -16648,11 +16610,8 @@ void ReportTrainersTraineesWithoutPartners( void )
} }
} }
} }
return;
} }
BOOLEAN SetMercAsleep( SOLDIERTYPE *pSoldier, BOOLEAN fGiveWarning ) BOOLEAN SetMercAsleep( SOLDIERTYPE *pSoldier, BOOLEAN fGiveWarning )
{ {
if( CanCharacterSleep( pSoldier, fGiveWarning ) ) if( CanCharacterSleep( pSoldier, fGiveWarning ) )
@@ -16670,8 +16629,6 @@ BOOLEAN SetMercAsleep( SOLDIERTYPE *pSoldier, BOOLEAN fGiveWarning )
} }
} }
BOOLEAN PutMercInAsleepState( SOLDIERTYPE *pSoldier ) BOOLEAN PutMercInAsleepState( SOLDIERTYPE *pSoldier )
{ {
if( pSoldier->flags.fMercAsleep == FALSE ) if( pSoldier->flags.fMercAsleep == FALSE )
@@ -16699,7 +16656,6 @@ BOOLEAN PutMercInAsleepState( SOLDIERTYPE *pSoldier )
return( TRUE ); return( TRUE );
} }
BOOLEAN SetMercAwake( SOLDIERTYPE *pSoldier, BOOLEAN fGiveWarning, BOOLEAN fForceHim ) BOOLEAN SetMercAwake( SOLDIERTYPE *pSoldier, BOOLEAN fGiveWarning, BOOLEAN fForceHim )
{ {
// forcing him skips all normal checks! // forcing him skips all normal checks!
@@ -16712,10 +16668,10 @@ BOOLEAN SetMercAwake( SOLDIERTYPE *pSoldier, BOOLEAN fGiveWarning, BOOLEAN fForc
} }
PutMercInAwakeState( pSoldier ); PutMercInAwakeState( pSoldier );
return( TRUE ); return( TRUE );
} }
BOOLEAN PutMercInAwakeState( SOLDIERTYPE *pSoldier ) BOOLEAN PutMercInAwakeState( SOLDIERTYPE *pSoldier )
{ {
if ( pSoldier->flags.fMercAsleep ) if ( pSoldier->flags.fMercAsleep )
@@ -16767,7 +16723,6 @@ BOOLEAN IsThereASoldierInThisSector( INT16 sSectorX, INT16 sSectorY, INT8 bSecto
return( FALSE ); return( FALSE );
} }
// set the time this soldier's assignment changed // set the time this soldier's assignment changed
void SetTimeOfAssignmentChangeForMerc( SOLDIERTYPE *pSoldier ) void SetTimeOfAssignmentChangeForMerc( SOLDIERTYPE *pSoldier )
{ {
@@ -16785,8 +16740,6 @@ void SetTimeOfAssignmentChangeForMerc( SOLDIERTYPE *pSoldier )
// assigning new PATIENTs gives a DOCTOR something to do, etc., so set flag to recheck them all. // assigning new PATIENTs gives a DOCTOR something to do, etc., so set flag to recheck them all.
// CAN'T DO IT RIGHT AWAY IN HERE 'CAUSE WE TYPICALLY GET CALLED *BEFORE* bAssignment GETS SET TO NEW VALUE!! // CAN'T DO IT RIGHT AWAY IN HERE 'CAUSE WE TYPICALLY GET CALLED *BEFORE* bAssignment GETS SET TO NEW VALUE!!
gfReEvaluateEveryonesNothingToDo = TRUE; gfReEvaluateEveryonesNothingToDo = TRUE;
return;
} }
// have we spent enough time on assignment for it to count? // have we spent enough time on assignment for it to count?
@@ -16800,7 +16753,6 @@ BOOLEAN EnoughTimeOnAssignment( SOLDIERTYPE *pSoldier )
return( FALSE ); return( FALSE );
} }
BOOLEAN AnyMercInGroupCantContinueMoving( GROUP *pGroup ) BOOLEAN AnyMercInGroupCantContinueMoving( GROUP *pGroup )
{ {
PLAYERGROUP *pPlayer; PLAYERGROUP *pPlayer;
@@ -16850,8 +16802,6 @@ BOOLEAN AnyMercInGroupCantContinueMoving( GROUP *pGroup )
return( fGroupMustStop ); return( fGroupMustStop );
} }
BOOLEAN PlayerSoldierTooTiredToTravel( SOLDIERTYPE *pSoldier ) BOOLEAN PlayerSoldierTooTiredToTravel( SOLDIERTYPE *pSoldier )
{ {
Assert( pSoldier ); Assert( pSoldier );
@@ -16879,8 +16829,6 @@ BOOLEAN PlayerSoldierTooTiredToTravel( SOLDIERTYPE *pSoldier )
return( FALSE ); return( FALSE );
} }
BOOLEAN AssignMercToAMovementGroup( SOLDIERTYPE *pSoldier ) BOOLEAN AssignMercToAMovementGroup( SOLDIERTYPE *pSoldier )
{ {
// if merc doesn't have a group or is in a vehicle or on a squad assign to group // if merc doesn't have a group or is in a vehicle or on a squad assign to group
@@ -16925,7 +16873,6 @@ BOOLEAN AssignMercToAMovementGroup( SOLDIERTYPE *pSoldier )
return( TRUE ); return( TRUE );
} }
void NotifyPlayerOfAssignmentAttemptFailure( INT8 bAssignment ) void NotifyPlayerOfAssignmentAttemptFailure( INT8 bAssignment )
{ {
// notify player // notify player
@@ -16945,7 +16892,6 @@ void NotifyPlayerOfAssignmentAttemptFailure( INT8 bAssignment )
} }
} }
BOOLEAN HandleSelectedMercsBeingPutAsleep( BOOLEAN fWakeUp, BOOLEAN fDisplayWarning ) BOOLEAN HandleSelectedMercsBeingPutAsleep( BOOLEAN fWakeUp, BOOLEAN fDisplayWarning )
{ {
BOOLEAN fSuccess = TRUE; BOOLEAN fSuccess = TRUE;
@@ -16954,8 +16900,7 @@ BOOLEAN HandleSelectedMercsBeingPutAsleep( BOOLEAN fWakeUp, BOOLEAN fDisplayWarn
UINT8 ubNumberOfSelectedSoldiers = 0; UINT8 ubNumberOfSelectedSoldiers = 0;
CHAR16 sString[ 128 ]; CHAR16 sString[ 128 ];
for( iCounter = 0; iCounter < giMAXIMUM_NUMBER_OF_PLAYER_SLOTS; ++iCounter )
for( iCounter = 0; iCounter < giMAXIMUM_NUMBER_OF_PLAYER_SLOTS; iCounter++ )
{ {
pSoldier = NULL; pSoldier = NULL;
@@ -17036,11 +16981,9 @@ BOOLEAN HandleSelectedMercsBeingPutAsleep( BOOLEAN fWakeUp, BOOLEAN fDisplayWarn
BOOLEAN IsAnyOneOnPlayersTeamOnThisAssignment( INT8 bAssignment ) BOOLEAN IsAnyOneOnPlayersTeamOnThisAssignment( INT8 bAssignment )
{ {
INT32 iCounter = 0;
SOLDIERTYPE *pSoldier = NULL; SOLDIERTYPE *pSoldier = NULL;
for( INT32 iCounter = gTacticalStatus.Team[ OUR_TEAM ].bFirstID; iCounter <= gTacticalStatus.Team[ OUR_TEAM ].bLastID; ++iCounter )
for( iCounter = gTacticalStatus.Team[ OUR_TEAM ].bFirstID; iCounter <= gTacticalStatus.Team[ OUR_TEAM ].bLastID; iCounter++ )
{ {
// get the current soldier // get the current soldier
pSoldier = &Menptr[ iCounter ]; pSoldier = &Menptr[ iCounter ];
@@ -17060,7 +17003,6 @@ BOOLEAN IsAnyOneOnPlayersTeamOnThisAssignment( INT8 bAssignment )
return( FALSE ); return( FALSE );
} }
void RebuildAssignmentsBox( void ) void RebuildAssignmentsBox( void )
{ {
// destroy and recreate assignments box // destroy and recreate assignments box
@@ -17073,8 +17015,6 @@ void RebuildAssignmentsBox( void )
CreateAssignmentsBox( ); CreateAssignmentsBox( );
} }
void BandageBleedingDyingPatientsBeingTreated( ) void BandageBleedingDyingPatientsBeingTreated( )
{ {
INT32 iCounter = 0; INT32 iCounter = 0;
@@ -17086,7 +17026,6 @@ void BandageBleedingDyingPatientsBeingTreated( )
UINT32 uiKitPtsUsed; UINT32 uiKitPtsUsed;
BOOLEAN fSomeoneStillBleedingDying = FALSE; BOOLEAN fSomeoneStillBleedingDying = FALSE;
for( iCounter = gTacticalStatus.Team[ OUR_TEAM ].bFirstID; iCounter <= gTacticalStatus.Team[ OUR_TEAM ].bLastID; iCounter++ ) for( iCounter = gTacticalStatus.Team[ OUR_TEAM ].bFirstID; iCounter <= gTacticalStatus.Team[ OUR_TEAM ].bLastID; iCounter++ )
{ {
// get the soldier // get the soldier
@@ -17154,7 +17093,6 @@ void BandageBleedingDyingPatientsBeingTreated( )
} }
} }
// this event may be posted many times because of multiple assignment changes. Handle it only once per minute! // this event may be posted many times because of multiple assignment changes. Handle it only once per minute!
DeleteAllStrategicEventsOfType( EVENT_BANDAGE_BLEEDING_MERCS ); DeleteAllStrategicEventsOfType( EVENT_BANDAGE_BLEEDING_MERCS );
@@ -17164,8 +17102,6 @@ void BandageBleedingDyingPatientsBeingTreated( )
} }
} }
void ReEvaluateEveryonesNothingToDo( BOOLEAN aDoExtensiveCheck ) void ReEvaluateEveryonesNothingToDo( BOOLEAN aDoExtensiveCheck )
{ {
INT32 iCounter = 0; INT32 iCounter = 0;
@@ -17337,8 +17273,6 @@ void ReEvaluateEveryonesNothingToDo( BOOLEAN aDoExtensiveCheck )
fMapPanelDirty = TRUE; fMapPanelDirty = TRUE;
} }
void SetAssignmentForList( INT8 bAssignment, INT8 bParam ) void SetAssignmentForList( INT8 bAssignment, INT8 bParam )
{ {
INT32 iCounter = 0; INT32 iCounter = 0;
@@ -17366,9 +17300,8 @@ void SetAssignmentForList( INT8 bAssignment, INT8 bParam )
Assert( pSelectedSoldier && pSelectedSoldier->bActive ); Assert( pSelectedSoldier && pSelectedSoldier->bActive );
// sets assignment for the list // sets assignment for the list
for( iCounter = 0; iCounter < giMAXIMUM_NUMBER_OF_PLAYER_SLOTS; iCounter++ ) for( iCounter = 0; iCounter < giMAXIMUM_NUMBER_OF_PLAYER_SLOTS; ++iCounter )
{ {
if( ( gCharactersList[ iCounter ].fValid ) && if( ( gCharactersList[ iCounter ].fValid ) &&
( fSelectedListOfMercsForMapScreen[ iCounter ] == TRUE ) && ( fSelectedListOfMercsForMapScreen[ iCounter ] == TRUE ) &&
@@ -17764,14 +17697,10 @@ void SetAssignmentForList( INT8 bAssignment, INT8 bParam )
break; break;
}*/ }*/
// check if we should start/stop flashing any mercs' assignment strings after these changes // check if we should start/stop flashing any mercs' assignment strings after these changes
gfReEvaluateEveryonesNothingToDo = TRUE; gfReEvaluateEveryonesNothingToDo = TRUE;
return;
} }
BOOLEAN IsCharacterAliveAndConscious( SOLDIERTYPE *pCharacter ) BOOLEAN IsCharacterAliveAndConscious( SOLDIERTYPE *pCharacter )
{ {
// is the character alive and conscious? // is the character alive and conscious?
@@ -17783,8 +17712,6 @@ BOOLEAN IsCharacterAliveAndConscious( SOLDIERTYPE *pCharacter )
return ( TRUE ); return ( TRUE );
} }
BOOLEAN ValidTrainingPartnerInSameSectorOnAssignmentFound( SOLDIERTYPE *pTargetSoldier, INT8 bTargetAssignment, INT8 bTargetStat ) BOOLEAN ValidTrainingPartnerInSameSectorOnAssignmentFound( SOLDIERTYPE *pTargetSoldier, INT8 bTargetAssignment, INT8 bTargetStat )
{ {
INT32 iCounter = 0; INT32 iCounter = 0;
@@ -17792,11 +17719,10 @@ BOOLEAN ValidTrainingPartnerInSameSectorOnAssignmentFound( SOLDIERTYPE *pTargetS
INT16 sTrainingPts = 0; INT16 sTrainingPts = 0;
UINT16 usMaxPts; UINT16 usMaxPts;
// this function only makes sense for training teammates or by others, not for self training which doesn't require partners // this function only makes sense for training teammates or by others, not for self training which doesn't require partners
Assert( ( bTargetAssignment == TRAIN_TEAMMATE ) || ( bTargetAssignment == TRAIN_BY_OTHER ) ); Assert( ( bTargetAssignment == TRAIN_TEAMMATE ) || ( bTargetAssignment == TRAIN_BY_OTHER ) );
for( iCounter = 0; iCounter <= gTacticalStatus.Team[ OUR_TEAM ].bLastID; iCounter++ ) for( iCounter = 0; iCounter <= gTacticalStatus.Team[ OUR_TEAM ].bLastID; ++iCounter )
{ {
pSoldier = &Menptr[ iCounter ]; pSoldier = &Menptr[ iCounter ];
@@ -17925,7 +17851,6 @@ void UnEscortEPC( SOLDIERTYPE *pSoldier )
} }
} }
BOOLEAN CharacterIsTakingItEasy( SOLDIERTYPE *pSoldier ) BOOLEAN CharacterIsTakingItEasy( SOLDIERTYPE *pSoldier )
{ {
// actually asleep? // actually asleep?
@@ -17986,21 +17911,16 @@ BOOLEAN CharacterIsTakingItEasy( SOLDIERTYPE *pSoldier )
} }
} }
// on assignment, or walking/driving & unable to sleep // on assignment, or walking/driving & unable to sleep
return( FALSE ); return( FALSE );
} }
UINT8 CalcSoldierNeedForSleep( SOLDIERTYPE *pSoldier ) UINT8 CalcSoldierNeedForSleep( SOLDIERTYPE *pSoldier )
{ {
UINT8 ubNeedForSleep;
UINT8 ubPercentHealth; UINT8 ubPercentHealth;
// base comes from profile // base comes from profile
ubNeedForSleep = gMercProfiles[ pSoldier->ubProfile ].ubNeedForSleep; UINT8 ubNeedForSleep = gMercProfiles[ pSoldier->ubProfile ].ubNeedForSleep;
// Enforce a maximum of 12 hours before injury penalties. // Enforce a maximum of 12 hours before injury penalties.
if ( ubNeedForSleep > 12 ) if ( ubNeedForSleep > 12 )
@@ -18013,6 +17933,7 @@ UINT8 CalcSoldierNeedForSleep( SOLDIERTYPE *pSoldier )
{ {
ubNeedForSleep = 3; ubNeedForSleep = 3;
} }
// HEADROCK HAM 3.5: WTF! This calculation is NOT correct! // HEADROCK HAM 3.5: WTF! This calculation is NOT correct!
//ubPercentHealth = pSoldier->stats.bLife / pSoldier->stats.bLifeMax; //ubPercentHealth = pSoldier->stats.bLife / pSoldier->stats.bLifeMax;
ubPercentHealth = (pSoldier->stats.bLife*100) / pSoldier->stats.bLifeMax; ubPercentHealth = (pSoldier->stats.bLife*100) / pSoldier->stats.bLifeMax;
@@ -18020,7 +17941,7 @@ UINT8 CalcSoldierNeedForSleep( SOLDIERTYPE *pSoldier )
// Increase need for sleep based on injuries. // Increase need for sleep based on injuries.
if ( ubPercentHealth < 75 ) if ( ubPercentHealth < 75 )
{ {
ubNeedForSleep++; ++ubNeedForSleep;
if ( ubPercentHealth < 50 ) if ( ubPercentHealth < 50 )
{ {
@@ -18075,8 +17996,6 @@ UINT8 CalcSoldierNeedForSleep( SOLDIERTYPE *pSoldier )
return( ubNeedForSleep ); return( ubNeedForSleep );
} }
UINT32 GetLastSquadListedInSquadMenu( void ) UINT32 GetLastSquadListedInSquadMenu( void )
{ {
UINT32 uiMaxSquad; UINT32 uiMaxSquad;
@@ -18095,8 +18014,6 @@ UINT32 GetLastSquadListedInSquadMenu( void )
return( uiMaxSquad ); return( uiMaxSquad );
} }
BOOLEAN CanCharacterRepairAnotherSoldiersStuff( SOLDIERTYPE *pSoldier, SOLDIERTYPE *pOtherSoldier ) BOOLEAN CanCharacterRepairAnotherSoldiersStuff( SOLDIERTYPE *pSoldier, SOLDIERTYPE *pOtherSoldier )
{ {
if ( pOtherSoldier == pSoldier ) if ( pOtherSoldier == pSoldier )
@@ -18137,8 +18054,6 @@ BOOLEAN CanCharacterRepairAnotherSoldiersStuff( SOLDIERTYPE *pSoldier, SOLDIERTY
return( TRUE ); return( TRUE );
} }
SOLDIERTYPE *GetSelectedAssignSoldier( BOOLEAN fNullOK ) SOLDIERTYPE *GetSelectedAssignSoldier( BOOLEAN fNullOK )
{ {
SOLDIERTYPE *pSoldier = NULL; SOLDIERTYPE *pSoldier = NULL;
@@ -18178,8 +18093,6 @@ SOLDIERTYPE *GetSelectedAssignSoldier( BOOLEAN fNullOK )
return( pSoldier ); return( pSoldier );
} }
void ResumeOldAssignment( SOLDIERTYPE *pSoldier ) void ResumeOldAssignment( SOLDIERTYPE *pSoldier )
{ {
AddCharacterToAnySquad( pSoldier ); AddCharacterToAnySquad( pSoldier );
@@ -18193,8 +18106,6 @@ void ResumeOldAssignment( SOLDIERTYPE *pSoldier )
fMapPanelDirty = TRUE; fMapPanelDirty = TRUE;
} }
void RepairItemsOnOthers( SOLDIERTYPE *pSoldier, UINT8 *pubRepairPtsLeft ) void RepairItemsOnOthers( SOLDIERTYPE *pSoldier, UINT8 *pubRepairPtsLeft )
{ {
UINT8 ubPassType; UINT8 ubPassType;
@@ -18224,7 +18135,6 @@ void RepairItemsOnOthers( SOLDIERTYPE *pSoldier, UINT8 *pubRepairPtsLeft )
} }
} }
while ( *pubRepairPtsLeft > 0 ) while ( *pubRepairPtsLeft > 0 )
{ {
bBestPriority = -1; bBestPriority = -1;
@@ -18285,17 +18195,13 @@ void RepairItemsOnOthers( SOLDIERTYPE *pSoldier, UINT8 *pubRepairPtsLeft )
} }
} }
BOOLEAN UnjamGunsOnSoldier( SOLDIERTYPE *pOwnerSoldier, SOLDIERTYPE *pRepairSoldier, UINT8 *pubRepairPtsLeft ) BOOLEAN UnjamGunsOnSoldier( SOLDIERTYPE *pOwnerSoldier, SOLDIERTYPE *pRepairSoldier, UINT8 *pubRepairPtsLeft )
{ {
BOOLEAN fAnyGunsWereUnjammed = FALSE; BOOLEAN fAnyGunsWereUnjammed = FALSE;
INT8 bPocket;
// try to unjam everything before beginning any actual repairs.. successful unjamming costs 2 points per weapon // try to unjam everything before beginning any actual repairs.. successful unjamming costs 2 points per weapon
// CHRISL: Changed to dynamically determine max inventory locations. // CHRISL: Changed to dynamically determine max inventory locations.
for (bPocket = HANDPOS; bPocket < NUM_INV_SLOTS; bPocket++) for ( INT8 bPocket = HANDPOS; bPocket < NUM_INV_SLOTS; ++bPocket)
{ {
// the object a weapon? and jammed? // the object a weapon? and jammed?
if ( ( Item[ pOwnerSoldier->inv[ bPocket ].usItem ].usItemClass == IC_GUN ) && ( pOwnerSoldier->inv[ bPocket ][0]->data.gun.bGunAmmoStatus < 0 ) ) if ( ( Item[ pOwnerSoldier->inv[ bPocket ].usItem ].usItemClass == IC_GUN ) && ( pOwnerSoldier->inv[ bPocket ][0]->data.gun.bGunAmmoStatus < 0 ) )
@@ -18357,7 +18263,7 @@ BOOLEAN SetTrainerSleepWhenTraineesSleep( SOLDIERTYPE *pThisTrainee)
iNumberOnTeam =gTacticalStatus.Team[ OUR_TEAM ].bLastID; iNumberOnTeam =gTacticalStatus.Team[ OUR_TEAM ].bLastID;
// Check to see if all other trainees of the same stat are also asleep // Check to see if all other trainees of the same stat are also asleep
for( iCounter = 0; iCounter < iNumberOnTeam; iCounter++ ) for( iCounter = 0; iCounter < iNumberOnTeam; ++iCounter )
{ {
pOtherTrainee = &Menptr[ iCounter ]; pOtherTrainee = &Menptr[ iCounter ];
if (pOtherTrainee->bAssignment == TRAIN_BY_OTHER && pOtherTrainee->bTrainStat == pThisTrainee->bTrainStat && if (pOtherTrainee->bAssignment == TRAIN_BY_OTHER && pOtherTrainee->bTrainStat == pThisTrainee->bTrainStat &&
@@ -18368,11 +18274,12 @@ BOOLEAN SetTrainerSleepWhenTraineesSleep( SOLDIERTYPE *pThisTrainee)
fAllTraineesAsleep = FALSE; fAllTraineesAsleep = FALSE;
} }
} }
// If they are all asleep // If they are all asleep
if (fAllTraineesAsleep) if (fAllTraineesAsleep)
{ {
// Look for trainers of that stat, in the same sector // Look for trainers of that stat, in the same sector
for( iCounter = 0; iCounter < iNumberOnTeam; iCounter++ ) for( iCounter = 0; iCounter < iNumberOnTeam; ++iCounter )
{ {
pTrainer = &Menptr[ iCounter ]; pTrainer = &Menptr[ iCounter ];
if (pTrainer->bAssignment == TRAIN_TEAMMATE && pTrainer->bTrainStat == pThisTrainee->bTrainStat && if (pTrainer->bAssignment == TRAIN_TEAMMATE && pTrainer->bTrainStat == pThisTrainee->bTrainStat &&
@@ -18430,7 +18337,7 @@ BOOLEAN SetTraineesSleepWhenTrainerSleeps( SOLDIERTYPE *pTrainer)
iNumberOnTeam =gTacticalStatus.Team[ OUR_TEAM ].bLastID; iNumberOnTeam =gTacticalStatus.Team[ OUR_TEAM ].bLastID;
for( iCounter = 0; iCounter < iNumberOnTeam; iCounter++ ) for( iCounter = 0; iCounter < iNumberOnTeam; ++iCounter )
{ {
pTrainee = &Menptr[ iCounter ]; pTrainee = &Menptr[ iCounter ];
if (pTrainee->bAssignment == TRAIN_BY_OTHER && pTrainee->bTrainStat == pTrainer->bTrainStat && if (pTrainee->bAssignment == TRAIN_BY_OTHER && pTrainee->bTrainStat == pTrainer->bTrainStat &&
@@ -18454,17 +18361,9 @@ BOOLEAN SetTraineesSleepWhenTrainerSleeps( SOLDIERTYPE *pTrainer)
} }
} }
if (fTraineesSentToSleep) return fTraineesSentToSleep;
{
return(TRUE);
}
else
{
return(FALSE);
}
} }
BOOLEAN SetTrainerWakeWhenTraineesWake( SOLDIERTYPE *pThisTrainee) BOOLEAN SetTrainerWakeWhenTraineesWake( SOLDIERTYPE *pThisTrainee)
{ {
UINT16 sMapX = pThisTrainee->sSectorX; UINT16 sMapX = pThisTrainee->sSectorX;
@@ -18487,7 +18386,7 @@ BOOLEAN SetTrainerWakeWhenTraineesWake( SOLDIERTYPE *pThisTrainee)
iNumberOnTeam =gTacticalStatus.Team[ OUR_TEAM ].bLastID; iNumberOnTeam =gTacticalStatus.Team[ OUR_TEAM ].bLastID;
// Check to see if all other trainees of the same stat are also asleep // Check to see if all other trainees of the same stat are also asleep
for( iCounter = 0; iCounter < iNumberOnTeam; iCounter++ ) for( iCounter = 0; iCounter < iNumberOnTeam; ++iCounter )
{ {
pOtherTrainee = &Menptr[ iCounter ]; pOtherTrainee = &Menptr[ iCounter ];
if (pOtherTrainee->bAssignment == TRAIN_BY_OTHER && pOtherTrainee->bTrainStat == pThisTrainee->bTrainStat && if (pOtherTrainee->bAssignment == TRAIN_BY_OTHER && pOtherTrainee->bTrainStat == pThisTrainee->bTrainStat &&
@@ -18498,11 +18397,12 @@ BOOLEAN SetTrainerWakeWhenTraineesWake( SOLDIERTYPE *pThisTrainee)
fAllTraineesAwake = FALSE; fAllTraineesAwake = FALSE;
} }
} }
// If they are all awake // If they are all awake
if (fAllTraineesAwake) if (fAllTraineesAwake)
{ {
// Look for trainers of that stat, in the same sector // Look for trainers of that stat, in the same sector
for( iCounter = 0; iCounter < iNumberOnTeam; iCounter++ ) for( iCounter = 0; iCounter < iNumberOnTeam; ++iCounter )
{ {
pTrainer = &Menptr[ iCounter ]; pTrainer = &Menptr[ iCounter ];
if (pTrainer->bAssignment == TRAIN_TEAMMATE && pTrainer->bTrainStat == pThisTrainee->bTrainStat && if (pTrainer->bAssignment == TRAIN_TEAMMATE && pTrainer->bTrainStat == pThisTrainee->bTrainStat &&
@@ -18525,19 +18425,11 @@ BOOLEAN SetTrainerWakeWhenTraineesWake( SOLDIERTYPE *pThisTrainee)
} }
} }
} }
if (fTrainersWokenUp)
{ return fTrainersWokenUp;
return(TRUE);
}
else
{
return(FALSE);
}
}
else
{
return(FALSE);
} }
return FALSE;
} }
BOOLEAN SetTraineesWakeWhenTrainerWakes( SOLDIERTYPE *pTrainer) BOOLEAN SetTraineesWakeWhenTrainerWakes( SOLDIERTYPE *pTrainer)
@@ -18559,7 +18451,7 @@ BOOLEAN SetTraineesWakeWhenTrainerWakes( SOLDIERTYPE *pTrainer)
iNumberOnTeam =gTacticalStatus.Team[ OUR_TEAM ].bLastID; iNumberOnTeam =gTacticalStatus.Team[ OUR_TEAM ].bLastID;
for( iCounter = 0; iCounter < iNumberOnTeam; iCounter++ ) for( iCounter = 0; iCounter < iNumberOnTeam; ++iCounter )
{ {
pTrainee = &Menptr[ iCounter ]; pTrainee = &Menptr[ iCounter ];
if (pTrainee->bAssignment == TRAIN_BY_OTHER && pTrainee->bTrainStat == pTrainer->bTrainStat && if (pTrainee->bAssignment == TRAIN_BY_OTHER && pTrainee->bTrainStat == pTrainer->bTrainStat &&
@@ -18583,14 +18475,7 @@ BOOLEAN SetTraineesWakeWhenTrainerWakes( SOLDIERTYPE *pTrainer)
} }
} }
if (fTraineesWokenUp) return fTraineesWokenUp;
{
return(TRUE);
}
else
{
return(FALSE);
}
} }
void HandleTrainingSleepSynchronize( SOLDIERTYPE *pSoldier ) void HandleTrainingSleepSynchronize( SOLDIERTYPE *pSoldier )
@@ -18652,7 +18537,8 @@ BOOLEAN FindAnyAwakeTrainers( SOLDIERTYPE *pTrainee )
// Reset flag // Reset flag
fAllTrainersAsleep = FALSE; fAllTrainersAsleep = FALSE;
} }
ubCounter++;
++ubCounter;
} }
return(!fAllTrainersAsleep); return(!fAllTrainersAsleep);
@@ -18687,17 +18573,18 @@ BOOLEAN FindAnyAwakeTrainees( SOLDIERTYPE *pTrainer )
// Reset flag. // Reset flag.
fAllTraineesAsleep = FALSE; fAllTraineesAsleep = FALSE;
} }
ubCounter++;
++ubCounter;
} }
return(!fAllTraineesAsleep); return(!fAllTraineesAsleep);
} }
// HEADROCK HAM 3.6: A new set of functions (this & next) to determine whether a character can train Mobile Militia. // HEADROCK HAM 3.6: A new set of functions (this & next) to determine whether a character can train Mobile Militia.
// This function tests character statistics. // This function tests character statistics.
BOOLEAN BasicCanCharacterTrainMobileMilitia( SOLDIERTYPE *pSoldier ) BOOLEAN BasicCanCharacterTrainMobileMilitia( SOLDIERTYPE *pSoldier )
{ {
///////////////////////////////////////////////////// /////////////////////////////////////////////////////
// Tests whether character can do assignments at all! // Tests whether character can do assignments at all!
@@ -18810,13 +18697,8 @@ BOOLEAN BasicCanCharacterTrainMobileMilitia( SOLDIERTYPE *pSoldier )
} }
} }
} }
if (!fMobileMilitiaTrainingAllowed)
{
// Mobile Militia training NOT allowed here!
return ( FALSE );
}
return ( TRUE ); return fMobileMilitiaTrainingAllowed;
} }
// HEADROCK HAM 3.6: A new set of functions (this & previous) to determine whether a character can train Mobile Militia. // HEADROCK HAM 3.6: A new set of functions (this & previous) to determine whether a character can train Mobile Militia.
@@ -18968,7 +18850,7 @@ BOOLEAN CanCharacterTrainMobileMilitia( SOLDIERTYPE *pSoldier )
// HEADROCK HAM 3.5: Only facilities allow militia training, and determine how many trainers can work here. // HEADROCK HAM 3.5: Only facilities allow militia training, and determine how many trainers can work here.
// Does sector have at least one facility that allows training? // Does sector have at least one facility that allows training?
UINT8 ubFacilityTrainersAllowed = 0; UINT8 ubFacilityTrainersAllowed = 0;
for (UINT16 cnt = 0; cnt < NUM_FACILITY_TYPES; cnt++) for (UINT16 cnt = 0; cnt < NUM_FACILITY_TYPES; ++cnt)
{ {
// Is this facility here? // Is this facility here?
if (gFacilityLocations[SECTOR(pSoldier->sSectorX, pSoldier->sSectorY)][cnt].fFacilityHere) if (gFacilityLocations[SECTOR(pSoldier->sSectorX, pSoldier->sSectorY)][cnt].fFacilityHere)
@@ -18996,13 +18878,11 @@ BOOLEAN CanCharacterTrainMobileMilitia( SOLDIERTYPE *pSoldier )
// return( FALSE ); // return( FALSE );
//} //}
if ( 100 <= GetMobileMilitiaQuota( FALSE ) ) if ( 100 <= GetMobileMilitiaQuota( FALSE ) )
return ( FALSE ); return ( FALSE );
// If we've reached this, then all is well. // If we've reached this, then all is well.
return( TRUE ); return( TRUE );
} }
BOOLEAN CanCharacterTrainWorkers( SOLDIERTYPE *pSoldier ) BOOLEAN CanCharacterTrainWorkers( SOLDIERTYPE *pSoldier )
@@ -19083,7 +18963,6 @@ BOOLEAN CanCharacterTrainMilitiaWithErrorReport( SOLDIERTYPE *pSoldier )
if ( 100 <= GetMobileMilitiaQuota( TRUE ) ) if ( 100 <= GetMobileMilitiaQuota( TRUE ) )
return ( FALSE ); return ( FALSE );
/////////////////////////////// ///////////////////////////////
// Test for required Leadership // Test for required Leadership
@@ -19104,7 +18983,7 @@ BOOLEAN CanCharacterTrainMilitiaWithErrorReport( SOLDIERTYPE *pSoldier )
else else
{ {
// Modifier applied once for each TEACHING level. // Modifier applied once for each TEACHING level.
for (UINT8 i = 0; i < NUM_SKILL_TRAITS( pSoldier, TEACHING_OT ); i++ ) for (UINT8 i = 0; i < NUM_SKILL_TRAITS( pSoldier, TEACHING_OT ); ++i )
{ {
// This is a percentage modifier. // This is a percentage modifier.
usEffectiveLeadership = (usEffectiveLeadership * gGameExternalOptions.usTeacherTraitEffectOnLeadership)/100; usEffectiveLeadership = (usEffectiveLeadership * gGameExternalOptions.usTeacherTraitEffectOnLeadership)/100;
@@ -19197,7 +19076,7 @@ BOOLEAN CanCharacterTrainMilitiaWithErrorReport( SOLDIERTYPE *pSoldier )
// defaults. This renders the INI setting "MAX_MILITIA_TRAINERS.." obsolete. // defaults. This renders the INI setting "MAX_MILITIA_TRAINERS.." obsolete.
UINT8 ubFacilityTrainersAllowed = 0; UINT8 ubFacilityTrainersAllowed = 0;
for (UINT16 cnt = 0; cnt < NUM_FACILITY_TYPES; cnt++) for (UINT16 cnt = 0; cnt < NUM_FACILITY_TYPES; ++cnt)
{ {
// Is this facility here? // Is this facility here?
if (gFacilityLocations[SECTOR(pSoldier->sSectorX, pSoldier->sSectorY)][cnt].fFacilityHere) if (gFacilityLocations[SECTOR(pSoldier->sSectorX, pSoldier->sSectorY)][cnt].fFacilityHere)
@@ -19220,10 +19099,8 @@ BOOLEAN CanCharacterTrainMilitiaWithErrorReport( SOLDIERTYPE *pSoldier )
// No errors to report. Character can perform this assignment. // No errors to report. Character can perform this assignment.
return (TRUE); return (TRUE);
} }
BOOLEAN CanCharacterTrainMobileMilitiaWithErrorReport( SOLDIERTYPE *pSoldier ) BOOLEAN CanCharacterTrainMobileMilitiaWithErrorReport( SOLDIERTYPE *pSoldier )
{ {
// Temp string. // Temp string.
@@ -19241,7 +19118,6 @@ BOOLEAN CanCharacterTrainMobileMilitiaWithErrorReport( SOLDIERTYPE *pSoldier )
if ( 100 <= GetMobileMilitiaQuota( TRUE ) ) if ( 100 <= GetMobileMilitiaQuota( TRUE ) )
return ( FALSE ); return ( FALSE );
/////////////////////////////// ///////////////////////////////
// Test for required Leadership // Test for required Leadership
@@ -19268,6 +19144,7 @@ BOOLEAN CanCharacterTrainMobileMilitiaWithErrorReport( SOLDIERTYPE *pSoldier )
usEffectiveLeadership = (usEffectiveLeadership * gGameExternalOptions.usTeacherTraitEffectOnLeadership)/100; usEffectiveLeadership = (usEffectiveLeadership * gGameExternalOptions.usTeacherTraitEffectOnLeadership)/100;
} }
} }
usEffectiveLeadership = __min(100,usEffectiveLeadership); usEffectiveLeadership = __min(100,usEffectiveLeadership);
} }
@@ -19395,7 +19272,7 @@ BOOLEAN CanCharacterTrainMobileMilitiaWithErrorReport( SOLDIERTYPE *pSoldier )
NumNonPlayerTeamMembersInSector( sCurrentX, sCurrentY, ENEMY_TEAM ) > 0 ) NumNonPlayerTeamMembersInSector( sCurrentX, sCurrentY, ENEMY_TEAM ) > 0 )
{ {
// skip the rest. This sector cannot generate militia anyway. // skip the rest. This sector cannot generate militia anyway.
iCounter++; ++iCounter;
continue; continue;
} }
@@ -19408,7 +19285,8 @@ BOOLEAN CanCharacterTrainMobileMilitiaWithErrorReport( SOLDIERTYPE *pSoldier )
break; break;
} }
} }
iCounter++;
++iCounter;
} }
} }
@@ -19420,8 +19298,6 @@ BOOLEAN CanCharacterTrainMobileMilitiaWithErrorReport( SOLDIERTYPE *pSoldier )
return (FALSE); return (FALSE);
} }
////////////////////////////////////////////// //////////////////////////////////////////////
// HEADROCK HAM 3.5: Militia Training Facility // HEADROCK HAM 3.5: Militia Training Facility
// //
@@ -19431,7 +19307,7 @@ BOOLEAN CanCharacterTrainMobileMilitiaWithErrorReport( SOLDIERTYPE *pSoldier )
// defaults. This renders the INI setting "MAX_MILITIA_TRAINERS.." obsolete. // defaults. This renders the INI setting "MAX_MILITIA_TRAINERS.." obsolete.
UINT8 ubFacilityTrainersAllowed = 0; UINT8 ubFacilityTrainersAllowed = 0;
for (UINT16 cnt = 0; cnt < NUM_FACILITY_TYPES; cnt++) for (UINT16 cnt = 0; cnt < NUM_FACILITY_TYPES; ++cnt)
{ {
// Is this facility here? // Is this facility here?
if (gFacilityLocations[SECTOR(pSoldier->sSectorX, pSoldier->sSectorY)][cnt].fFacilityHere) if (gFacilityLocations[SECTOR(pSoldier->sSectorX, pSoldier->sSectorY)][cnt].fFacilityHere)
@@ -19452,8 +19328,8 @@ BOOLEAN CanCharacterTrainMobileMilitiaWithErrorReport( SOLDIERTYPE *pSoldier )
// No errors to report. Character can perform this assignment. // No errors to report. Character can perform this assignment.
return (TRUE); return (TRUE);
} }
// HEADROCK HAM 3.6: This function determines whether a character can use facilities at all, or whether the sector has // HEADROCK HAM 3.6: This function determines whether a character can use facilities at all, or whether the sector has
// any "useable" facilities at all. // any "useable" facilities at all.
BOOLEAN BasicCanCharacterFacility( SOLDIERTYPE *pSoldier ) BOOLEAN BasicCanCharacterFacility( SOLDIERTYPE *pSoldier )
@@ -19526,7 +19402,7 @@ BOOLEAN BasicCanCharacterFacility( SOLDIERTYPE *pSoldier )
UINT8 ubSector = SECTOR(pSoldier->sSectorX, pSoldier->sSectorY); UINT8 ubSector = SECTOR(pSoldier->sSectorX, pSoldier->sSectorY);
BOOLEAN fFoundUseableFacility = FALSE; BOOLEAN fFoundUseableFacility = FALSE;
for (UINT16 cnt = 0; cnt < NUM_FACILITY_TYPES; cnt++) for (UINT16 cnt = 0; cnt < NUM_FACILITY_TYPES; ++cnt)
{ {
if (gFacilityLocations[ubSector][cnt].fFacilityHere) if (gFacilityLocations[ubSector][cnt].fFacilityHere)
{ {
@@ -19536,13 +19412,8 @@ BOOLEAN BasicCanCharacterFacility( SOLDIERTYPE *pSoldier )
} }
} }
} }
if (!fFoundUseableFacility)
{
// No useable facilities in this sector.
return FALSE;
}
return ( TRUE ); return fFoundUseableFacility;
} }
BOOLEAN DisplayFacilityMenu( SOLDIERTYPE *pSoldier ) BOOLEAN DisplayFacilityMenu( SOLDIERTYPE *pSoldier )
@@ -19559,7 +19430,7 @@ BOOLEAN DisplayFacilityMenu( SOLDIERTYPE *pSoldier )
SetCurrentBox(ghFacilityBox); SetCurrentBox(ghFacilityBox);
// run through list of staff/use facilities in sector and add them to pop up box // run through list of staff/use facilities in sector and add them to pop up box
for ( iCounter = 0; iCounter < MAX_NUM_FACILITY_TYPES; iCounter++ ) for ( iCounter = 0; iCounter < MAX_NUM_FACILITY_TYPES; ++iCounter )
{ {
if ( gFacilityLocations[ SECTOR(pSoldier->sSectorX,pSoldier->sSectorY) ][iCounter].fFacilityHere ) if ( gFacilityLocations[ SECTOR(pSoldier->sSectorX,pSoldier->sSectorY) ][iCounter].fFacilityHere )
{ {
@@ -19615,14 +19486,14 @@ BOOLEAN DisplayFacilityAssignmentMenu( SOLDIERTYPE *pSoldier, UINT8 ubFacilityTy
BOOLEAN fAssignmentsFound = FALSE; BOOLEAN fAssignmentsFound = FALSE;
// Create a list of possible assignments at this facility // Create a list of possible assignments at this facility
for ( iCounter = 0; iCounter < NUM_FACILITY_ASSIGNMENTS; iCounter++ ) for ( iCounter = 0; iCounter < NUM_FACILITY_ASSIGNMENTS; ++iCounter )
{ {
if ( gFacilityTypes[ ubFacilityType ].AssignmentData[iCounter].ubStaffLimit ) if ( gFacilityTypes[ ubFacilityType ].AssignmentData[iCounter].ubStaffLimit )
{ {
if ( iCounter == FAC_REPAIR_VEHICLE ) if ( iCounter == FAC_REPAIR_VEHICLE )
{ {
// Test to see whether there are any. // Test to see whether there are any.
for ( iCounterB = 0; iCounterB < ubNumberOfVehicles; iCounterB++ ) for ( iCounterB = 0; iCounterB < ubNumberOfVehicles; ++iCounterB )
{ {
if ( pVehicleList[iCounterB].fValid == TRUE ) if ( pVehicleList[iCounterB].fValid == TRUE )
{ {
@@ -19636,6 +19507,7 @@ BOOLEAN DisplayFacilityAssignmentMenu( SOLDIERTYPE *pSoldier, UINT8 ubFacilityTy
} }
} }
} }
if (fFoundVehicle == FALSE) if (fFoundVehicle == FALSE)
{ {
// Create line that says "Repair Vehicle", and will be shaded. // Create line that says "Repair Vehicle", and will be shaded.
@@ -19665,6 +19537,7 @@ BOOLEAN DisplayFacilityAssignmentMenu( SOLDIERTYPE *pSoldier, UINT8 ubFacilityTy
{ {
AddMonoString((UINT32 *)&hStringHandle, gzFacilityAssignmentStrings[ iCounter ]); AddMonoString((UINT32 *)&hStringHandle, gzFacilityAssignmentStrings[ iCounter ]);
} }
fAssignmentsFound = TRUE; fAssignmentsFound = TRUE;
} }
} }
@@ -20520,22 +20393,20 @@ BOOLEAN CanCharacterFacilityWithErrorReport( SOLDIERTYPE *pSoldier, UINT8 ubFaci
void HandleShadingOfLinesForFacilityMenu( void ) void HandleShadingOfLinesForFacilityMenu( void )
{ {
SOLDIERTYPE *pSoldier = NULL;
INT32 iCounter = 0;
INT32 iNumLine = 0;
if ( gAssignMenuState != ASMENU_FACILITY || ( ghFacilityBox == -1 ) ) if ( gAssignMenuState != ASMENU_FACILITY || ( ghFacilityBox == -1 ) )
{ {
return; return;
} }
pSoldier = GetSelectedAssignSoldier( FALSE ); INT32 iNumLine = 0;
SOLDIERTYPE* pSoldier = GetSelectedAssignSoldier( FALSE );
// PLEASE NOTE: make sure any changes you do here are reflected in all 3 routines which must remain in synch: // PLEASE NOTE: make sure any changes you do here are reflected in all 3 routines which must remain in synch:
// CreateDestroyMouseRegionForMoveItemMenu(), DisplayRepairMenu(), and HandleShadingOfLinesForMoveItemMenu(). // CreateDestroyMouseRegionForMoveItemMenu(), DisplayRepairMenu(), and HandleShadingOfLinesForMoveItemMenu().
// run through list of staff/use facilities in sector and add them to pop up box // run through list of staff/use facilities in sector and add them to pop up box
for ( iCounter = 0; iCounter < MAX_NUM_FACILITY_TYPES; ++iCounter ) for ( INT32 iCounter = 0; iCounter < MAX_NUM_FACILITY_TYPES; ++iCounter )
{ {
if ( gFacilityLocations[ SECTOR(pSoldier->sSectorX,pSoldier->sSectorY) ][iCounter].fFacilityHere ) if ( gFacilityLocations[ SECTOR(pSoldier->sSectorX,pSoldier->sSectorY) ][iCounter].fFacilityHere )
{ {
@@ -21220,32 +21091,29 @@ BOOLEAN HandleAssignmentExpansionAndHighLightForFacilityMenu( void )
void HandleShadingOfLinesForFacilityAssignmentMenu( void ) void HandleShadingOfLinesForFacilityAssignmentMenu( void )
{ {
SOLDIERTYPE *pSoldier = NULL; if ( !fShowFacilityAssignmentMenu || ( ghFacilityAssignmentBox == -1 ) )
INT32 iCounter = 0;
INT32 iCounterB = 0;
INT32 iNumLine = 0;
UINT8 ubFacilityType = gubFacilityInSubmenu;
BOOLEAN fFoundVehicle = FALSE;
if( ( fShowFacilityAssignmentMenu == FALSE ) || ( ghFacilityAssignmentBox == -1 ) )
{ {
return; return;
} }
pSoldier = GetSelectedAssignSoldier( FALSE ); INT32 iNumLine = 0;
UINT8 ubFacilityType = gubFacilityInSubmenu;
BOOLEAN fFoundVehicle = FALSE;
SOLDIERTYPE* pSoldier = GetSelectedAssignSoldier( FALSE );
// PLEASE NOTE: make sure any changes you do here are reflected in all 3 routines which must remain in synch: // PLEASE NOTE: make sure any changes you do here are reflected in all 3 routines which must remain in synch:
// CreateDestroyMouseRegionForMoveItemMenu(), DisplayRepairMenu(), and HandleShadingOfLinesForMoveItemMenu(). // CreateDestroyMouseRegionForMoveItemMenu(), DisplayRepairMenu(), and HandleShadingOfLinesForMoveItemMenu().
// run through all possible assignments. Shade as necessary // run through all possible assignments. Shade as necessary
for ( iCounter = 0; iCounter < NUM_FACILITY_ASSIGNMENTS; ++iCounter ) for ( INT32 iCounter = 0; iCounter < NUM_FACILITY_ASSIGNMENTS; ++iCounter )
{ {
if ( gFacilityTypes[ubFacilityType].AssignmentData[iCounter].ubStaffLimit ) if ( gFacilityTypes[ubFacilityType].AssignmentData[iCounter].ubStaffLimit )
{ {
if ( iCounter == FAC_REPAIR_VEHICLE ) if ( iCounter == FAC_REPAIR_VEHICLE )
{ {
// Test to see whether there are any. // Test to see whether there are any.
for ( iCounterB = 0; iCounterB < ubNumberOfVehicles; ++iCounterB ) for ( INT32 iCounterB = 0; iCounterB < ubNumberOfVehicles; ++iCounterB )
{ {
if ( pVehicleList[iCounterB].fValid == TRUE ) if ( pVehicleList[iCounterB].fValid == TRUE )
{ {
@@ -22003,7 +21871,6 @@ BOOLEAN DisplayDiseaseMenu( SOLDIERTYPE *pSoldier )
void HandleShadingOfLinesForDiseaseMenu( void ) void HandleShadingOfLinesForDiseaseMenu( void )
{ {
INT32 iVehicleIndex = 0;
INT32 iCount = 0; INT32 iCount = 0;
if ( gAssignMenuState != ASMENU_DISEASE || (ghDiseaseBox == -1) ) if ( gAssignMenuState != ASMENU_DISEASE || (ghDiseaseBox == -1) )
@@ -22017,16 +21884,15 @@ void HandleShadingOfLinesForDiseaseMenu( void )
if ( 1 ) if ( 1 )
{ {
// unshade items line // unshade items line
UnShadeStringInBox( ghDiseaseBox, iCount ); UnShadeStringInBox( ghDiseaseBox, iCount++ );
} }
else else
{ {
// shade items line // shade items line
ShadeStringInBox( ghDiseaseBox, iCount ); ShadeStringInBox( ghDiseaseBox, iCount++ );
} }
} }
void CreateDestroyMouseRegionForDiseaseMenu( void ) void CreateDestroyMouseRegionForDiseaseMenu( void )
{ {
static BOOLEAN fCreated = FALSE; static BOOLEAN fCreated = FALSE;