Fix: possible underflow in UB code

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8605 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Flugente
2018-08-28 20:44:16 +00:00
parent 5d04583e13
commit e205697804
12 changed files with 171 additions and 247 deletions
+2 -2
View File
@@ -66,11 +66,11 @@ typedef struct
BOOLEAN fEnemyShouldImmediatelySeekThePlayer; BOOLEAN fEnemyShouldImmediatelySeekThePlayer;
INT8 bSectorTheEnemyWillSeekEnemy; INT8 bSectorTheEnemyWillSeekEnemy;
INT8 bNewMercProfileIDForSayingMorrisNote; UINT8 usFiller1;
UINT8 ubDisplayCommanderMorrisNote; UINT8 ubDisplayCommanderMorrisNote;
UINT16 usFiller1; INT16 bNewMercProfileIDForSayingMorrisNote;
UINT32 uiTurnLastSaidSeeEnemyQuote; UINT32 uiTurnLastSaidSeeEnemyQuote;
+53 -62
View File
@@ -6897,15 +6897,14 @@ typedef struct
void HandlePlayerTeamQuotesWhenEnteringSector( INT16 sSectorX, INT16 sSectorY, INT16 sSectorZ ) void HandlePlayerTeamQuotesWhenEnteringSector( INT16 sSectorX, INT16 sSectorY, INT16 sSectorZ )
{ {
UINT32 uiCnt; UINT32 uiCnt;
INT8 bNumValidMercs = -1; UINT8 usNumValidMercs = 0;
INT32 iSectorID = SECTOR( sSectorX, sSectorY ); INT32 iSectorID = SECTOR( sSectorX, sSectorY );
UINT8 ubValidMercProfileIDArray[NUM_MERCS_WITH_NEW_QUOTES]; UINT8 ubValidMercProfileIDArray[NUM_MERCS_WITH_NEW_QUOTES];
SOLDIERTYPE *pSoldier = NULL; SOLDIERTYPE *pSoldier = NULL;
#define NUM_VALID_SECTORS 6
#define NUM_VALID_SECTORS 6 #define DELAY_FOR_PLAYER_DESC_OF_SECTOR 2
#define DELAY_FOR_PLAYER_DESC_OF_SECTOR 2
ENTER_SECTOR_PLAYER_QUOTE PlayerSectorDescQuote[ NUM_VALID_SECTORS ] = ENTER_SECTOR_PLAYER_QUOTE PlayerSectorDescQuote[ NUM_VALID_SECTORS ] =
{ {
@@ -6929,7 +6928,7 @@ void HandlePlayerTeamQuotesWhenEnteringSector( INT16 sSectorX, INT16 sSectorY, I
}; };
//loop through all the sectors that have the quotes //loop through all the sectors that have the quotes
for ( uiCnt = 0; uiCnt<NUM_VALID_SECTORS; uiCnt++ ) for ( uiCnt = 0; uiCnt<NUM_VALID_SECTORS; ++uiCnt )
{ {
//if this sector is the right x & y //if this sector is the right x & y
if ( PlayerSectorDescQuote[uiCnt].sSectorID == iSectorID ) if ( PlayerSectorDescQuote[uiCnt].sSectorID == iSectorID )
@@ -6937,69 +6936,67 @@ void HandlePlayerTeamQuotesWhenEnteringSector( INT16 sSectorX, INT16 sSectorY, I
//if is the right level //if is the right level
if ( PlayerSectorDescQuote[uiCnt].bSectorZ == sSectorZ ) if ( PlayerSectorDescQuote[uiCnt].bSectorZ == sSectorZ )
{ {
// If the player has never said the "enter sector" desc before // If the player has never said the "enter sector" desc before
if ( GetSectorFlagStatus( sSectorX, sSectorY, (UINT8)sSectorZ, SF_HAVE_SAID_PLAYER_QUOTE_NEW_SECTOR ) != TRUE ) if ( GetSectorFlagStatus( sSectorX, sSectorY, (UINT8)sSectorZ, SF_HAVE_SAID_PLAYER_QUOTE_NEW_SECTOR ) != TRUE )
{ {
//Get # of valid mercs //Get # of valid mercs
bNumValidMercs = GetNumSoldierIdAndProfileIdOfTheNewMercsOnPlayerTeam( NULL, ubValidMercProfileIDArray ); usNumValidMercs = GetNumSoldierIdAndProfileIdOfTheNewMercsOnPlayerTeam( NULL, ubValidMercProfileIDArray );
//if there isnt any valid mercs //if there isnt any valid mercs
if ( bNumValidMercs == 0 ) if ( usNumValidMercs == 0 )
{ {
//exit //exit
return; return;
} }
//Switch on the town ID //Switch on the town ID
//I10 //I10
if ( iSectorID == SECTOR( gGameUBOptions.FristSectorTownX, gGameUBOptions.FristSectorTownY ) ) if ( iSectorID == SECTOR( gGameUBOptions.FristSectorTownX, gGameUBOptions.FristSectorTownY ) )
{ {
UINT8 cnt; UINT8 cnt;
for( cnt=0; cnt<bNumValidMercs; cnt++ ) for( cnt=0; cnt<usNumValidMercs; ++cnt )
{
//Say the qoute in a couple of seconds
DelayedMercQuote( ubValidMercProfileIDArray[ cnt ], PlayerSectorDescQuote[ uiCnt ].ubQuoteNum, GetWorldTotalSeconds() + DELAY_FOR_PLAYER_DESC_OF_SECTOR + cnt );
}
}
//J13
else if ( iSectorID == SECTOR( gGameUBOptions.SectorFanX, gGameUBOptions.SectorFanY ) )
{ {
//Say the qoute in a couple of seconds
DelayedMercQuote( ubValidMercProfileIDArray[ cnt ], PlayerSectorDescQuote[ uiCnt ].ubQuoteNum, GetWorldTotalSeconds() + DELAY_FOR_PLAYER_DESC_OF_SECTOR + cnt );
}
}
//J13
else if ( iSectorID == SECTOR( gGameUBOptions.SectorFanX, gGameUBOptions.SectorFanY ) )
{
if( PlayerSectorDescQuote[ uiCnt ].bSectorZ == gGameUBOptions.SectorFanZ )
{
//See if Manuel is on the team
pSoldier = FindSoldierByProfileID( MANUEL_UB, TRUE );
if( PlayerSectorDescQuote[ uiCnt ].bSectorZ == gGameUBOptions.SectorFanZ ) //if he is ON the team
if( pSoldier != NULL )
{ {
//See if Manuel is on the team //get manuel to say the quote
pSoldier = FindSoldierByProfileID( MANUEL_UB, TRUE ); DelayedMercQuote( MANUEL_UB, PlayerSectorDescQuote[ uiCnt ].ubQuoteNum, GetWorldTotalSeconds() + DELAY_FOR_PLAYER_DESC_OF_SECTOR );
//get manuel to say his additional quote
DelayedMercQuote( MANUEL_UB, QUOTE_ENTER_SECTOR_WITH_FAN_2, GetWorldTotalSeconds() + DELAY_FOR_PLAYER_DESC_OF_SECTOR );
}
else
{
//else if Biggens is not on the team, check for biggens
pSoldier = FindSoldierByProfileID( BIGGENS_UB, TRUE );
//if he is ON the team //if he is ON the team
if( pSoldier != NULL ) if( pSoldier != NULL )
{ {
//get manuel to say the quote //get manuel to say the quote
DelayedMercQuote( MANUEL_UB, PlayerSectorDescQuote[ uiCnt ].ubQuoteNum, GetWorldTotalSeconds() + DELAY_FOR_PLAYER_DESC_OF_SECTOR ); DelayedMercQuote( BIGGENS_UB, PlayerSectorDescQuote[ uiCnt ].ubQuoteNum, GetWorldTotalSeconds() + DELAY_FOR_PLAYER_DESC_OF_SECTOR );
//get manuel to say his additional quote //Remember he said
DelayedMercQuote( MANUEL_UB, QUOTE_ENTER_SECTOR_WITH_FAN_2, GetWorldTotalSeconds() + DELAY_FOR_PLAYER_DESC_OF_SECTOR ); SetJa25GeneralFlag( JA_GF__BIGGENS_SAID_QUOTE_117 );
} }
else
{
//else if Biggens is not on the team, check for biggens
pSoldier = FindSoldierByProfileID( BIGGENS_UB, TRUE );
//if he is ON the team
if( pSoldier != NULL )
{
//get manuel to say the quote
DelayedMercQuote( BIGGENS_UB, PlayerSectorDescQuote[ uiCnt ].ubQuoteNum, GetWorldTotalSeconds() + DELAY_FOR_PLAYER_DESC_OF_SECTOR );
//Remember he said
SetJa25GeneralFlag( JA_GF__BIGGENS_SAID_QUOTE_117 );
}
}
//Remeber the quote was said
SetFactTrue( FACT_PLAYER_KNOWS_ABOUT_FAN_STOPPING );
} }
//Remeber the quote was said
SetFactTrue( FACT_PLAYER_KNOWS_ABOUT_FAN_STOPPING );
}
} }
//J14 //J14
else if ( iSectorID == SECTOR( gGameUBOptions.ExitForFanToPowerGenSectorX, gGameUBOptions.ExitForFanToPowerGenSectorY ) ) else if ( iSectorID == SECTOR( gGameUBOptions.ExitForFanToPowerGenSectorX, gGameUBOptions.ExitForFanToPowerGenSectorY ) )
@@ -7009,12 +7006,12 @@ void HandlePlayerTeamQuotesWhenEnteringSector( INT16 sSectorX, INT16 sSectorY, I
} }
else else
{ {
//Get a random merc from the list //Get a random merc from the list
UINT8 ubMercToSayQuote = RandomProfileIdFromNewMercsOnPlayerTeam(); INT16 sMercToSayQuote = RandomProfileIdFromNewMercsOnPlayerTeam();
//Say the qoute in a couple of seconds
DelayedMercQuote( ubMercToSayQuote, PlayerSectorDescQuote[ uiCnt ].ubQuoteNum, GetWorldTotalSeconds() + DELAY_FOR_PLAYER_DESC_OF_SECTOR );
//Say the qoute in a couple of seconds
if ( sMercToSayQuote > -1 )
DelayedMercQuote( (UINT16)sMercToSayQuote, PlayerSectorDescQuote[ uiCnt ].ubQuoteNum, GetWorldTotalSeconds() + DELAY_FOR_PLAYER_DESC_OF_SECTOR );
} }
/* /*
switch ( iSectorID ) switch ( iSectorID )
@@ -7112,8 +7109,6 @@ void HandlePlayerTeamQuotesWhenEnteringSector( INT16 sSectorX, INT16 sSectorY, I
void HandlePlayerQuotesWhenEnteringFirstTunnelSector( ) void HandlePlayerQuotesWhenEnteringFirstTunnelSector( )
{ {
UINT8 ubID;
//if the player got through using the timed method //if the player got through using the timed method
if ( gJa25SaveStruct.ubHowPlayerGotThroughFan == PG__PLAYER_STOPPED_FAN_TO_GET_THROUGH ) if ( gJa25SaveStruct.ubHowPlayerGotThroughFan == PG__PLAYER_STOPPED_FAN_TO_GET_THROUGH )
{ {
@@ -7121,38 +7116,34 @@ void HandlePlayerQuotesWhenEnteringFirstTunnelSector( )
UINT8 ubNumPlayersOnTeam = NumberOfMercsOnPlayerTeam( ); UINT8 ubNumPlayersOnTeam = NumberOfMercsOnPlayerTeam( );
//Get a random qualified merc to say the quote //Get a random qualified merc to say the quote
ubID = RandomSoldierIdFromNewMercsOnPlayerTeam( ); INT16 bID = RandomSoldierIdFromNewMercsOnPlayerTeam( );
//if there is no valid merc //if there is no valid merc
if ( ubID == -1 ) if ( bID == -1 )
return; return;
//if not all the players made it through //if not all the players made it through
if ( ubNumPlayersInSector < ubNumPlayersOnTeam ) if ( ubNumPlayersInSector < ubNumPlayersOnTeam )
{ {
// TacticalCharacterDialogue( &Menptr[ ubID ], QUOTE_CONTRACTS_OVER ); // TacticalCharacterDialogue( &Menptr[ ubID ], QUOTE_CONTRACTS_OVER );
DelayedMercQuote( Menptr[ubID].ubProfile, QUOTE_CONTRACTS_OVER, GetWorldTotalSeconds( ) + DELAY_FOR_PLAYER_DESC_OF_SECTOR ); DelayedMercQuote( Menptr[bID].ubProfile, QUOTE_CONTRACTS_OVER, GetWorldTotalSeconds( ) + DELAY_FOR_PLAYER_DESC_OF_SECTOR );
} }
//if ALL mercs made it through //if ALL mercs made it through
else if ( ubNumPlayersInSector == ubNumPlayersOnTeam ) else if ( ubNumPlayersInSector == ubNumPlayersOnTeam )
{ {
DelayedMercQuote( Menptr[ubID].ubProfile, QUOTE_CONTRACT_ACCEPTANCE, GetWorldTotalSeconds( ) + DELAY_FOR_PLAYER_DESC_OF_SECTOR ); DelayedMercQuote( Menptr[bID].ubProfile, QUOTE_CONTRACT_ACCEPTANCE, GetWorldTotalSeconds( ) + DELAY_FOR_PLAYER_DESC_OF_SECTOR );
// TacticalCharacterDialogue( &Menptr[ ubID ], QUOTE_CONTRACT_ACCEPTANCE ); // TacticalCharacterDialogue( &Menptr[ ubID ], QUOTE_CONTRACT_ACCEPTANCE );
} }
} }
/*else if ( gJa25SaveStruct.ubHowPlayerGotThroughFan == PG__PLAYER_BLEW_UP_FAN_TO_GET_THROUGH )
else if ( gJa25SaveStruct.ubHowPlayerGotThroughFan == PG__PLAYER_BLEW_UP_FAN_TO_GET_THROUGH )
{ {
/*
Chnaged to be played when fan blows up Chnaged to be played when fan blows up
//Get a random qualified merc to say the quote //Get a random qualified merc to say the quote
ubID = RandomSoldierIdFromNewMercsOnPlayerTeam(); ubID = RandomSoldierIdFromNewMercsOnPlayerTeam();
DelayedMercQuote( Menptr[ ubID ].ubProfile, QUOTE_ACCEPT_CONTRACT_RENEWAL, GetWorldTotalSeconds() + DELAY_FOR_PLAYER_DESC_OF_SECTOR ); DelayedMercQuote( Menptr[ ubID ].ubProfile, QUOTE_ACCEPT_CONTRACT_RENEWAL, GetWorldTotalSeconds() + DELAY_FOR_PLAYER_DESC_OF_SECTOR );
*/ }*/
}
else else
{ {
Assert( 0 ); Assert( 0 );
+2 -5
View File
@@ -734,7 +734,7 @@ void HandleDialogue( )
if( ubNumQualifiedMercs != 0 ) if( ubNumQualifiedMercs != 0 )
{ {
//loop through all the mercs //loop through all the mercs
for( ubCnt=0; ubCnt<ubNumQualifiedMercs; ubCnt++ ) for( ubCnt=0; ubCnt<ubNumQualifiedMercs; ++ubCnt )
{ {
pSoldier = MercPtrs[ ubQualifiedSoldierIDArray[ ubCnt ] ]; pSoldier = MercPtrs[ ubQualifiedSoldierIDArray[ ubCnt ] ];
@@ -752,14 +752,12 @@ void HandleDialogue( )
} }
} }
return; return;
} }
#else //Ja25: no mike #else //Ja25: no mike
if ( iQSize == 0 ) if ( iQSize == 0 )
{ {
if ( gfMikeShouldSayHi == TRUE ) if ( gfMikeShouldSayHi == TRUE )
{ {
SOLDIERTYPE * pMike; SOLDIERTYPE * pMike;
@@ -1039,7 +1037,6 @@ void HandleDialogue( )
gubCurrentTalkingID = QItem->ubCharacterNum; gubCurrentTalkingID = QItem->ubCharacterNum;
ExecuteCharacterDialogue( QItem->ubCharacterNum, QItem->usQuoteNum, QItem->iFaceIndex, QItem->bUIHandlerID, QItem->fFromSoldier ); ExecuteCharacterDialogue( QItem->ubCharacterNum, QItem->usQuoteNum, QItem->iFaceIndex, QItem->bUIHandlerID, QItem->fFromSoldier );
} }
if ( QItem->uiSpecialEventFlag & DIALOGUE_SPECIAL_EVENT_ENABLE_AI ) if ( QItem->uiSpecialEventFlag & DIALOGUE_SPECIAL_EVENT_ENABLE_AI )
@@ -3911,7 +3908,7 @@ void HandlePlayerClosingMorrisNoteDisplayedOnScreen()
} }
else else
{ {
DelayedMercQuote( gJa25SaveStruct.bNewMercProfileIDForSayingMorrisNote, DQ__MORRIS_NOTE_DISPLAY_NOTE_1, GetWorldTotalSeconds() + 1 ); DelayedMercQuote( (UINT16)(gJa25SaveStruct.bNewMercProfileIDForSayingMorrisNote), DQ__MORRIS_NOTE_DISPLAY_NOTE_1, GetWorldTotalSeconds() + 1 );
} }
} }
#endif #endif
+17 -38
View File
@@ -5188,39 +5188,22 @@ void CarmenLeavesSectorCallback( void )
#ifdef JA2UB #ifdef JA2UB
//JA25 UB //JA25 UB
void PerformJerryMiloAction301() void PerformJerryMiloAction301()
{ {
UINT8 ubMercsPresent[NUM_MERCS_WITH_NEW_QUOTES]; UINT8 ubMercsPresent[NUM_MERCS_WITH_NEW_QUOTES];
INT8 bNumMercsPresent=-1; UINT8 usNumMercsPresent;
SOLDIERTYPE *pSoldier=NULL; SOLDIERTYPE *pSoldier=NULL;
INT32 cnt;
UINT8 ubId; UINT8 ubId;
//Get the number and array of the new soldiers //Get the number and array of the new soldiers
bNumMercsPresent = GetNumSoldierIdAndProfileIdOfTheNewMercsOnPlayerTeam( ubMercsPresent, NULL ); usNumMercsPresent = GetNumSoldierIdAndProfileIdOfTheNewMercsOnPlayerTeam( ubMercsPresent, NULL );
//Randomly choose one
/* //if there is at least 1 of the desired mercs found
if( bNumMercsPresent != -1 )
{
ubId = ubMercsPresent[ Random( bNumMercsPresent ) ];
pSoldier = MercPtrs[ ubId ];
TacticalCharacterDialogue( pSoldier, QUOTE_DEATH_RATE_REFUSAL );
}
*/
//Have them all say their quote //Have them all say their quote
for( UINT8 cnt=0; cnt<usNumMercsPresent; ++cnt )
for( cnt=0; cnt<bNumMercsPresent; cnt++ )
{ {
ubId = ubMercsPresent[ cnt ]; ubId = ubMercsPresent[ cnt ];
pSoldier = MercPtrs[ ubId ]; TacticalCharacterDialogue( MercPtrs[ubId], QUOTE_DEATH_RATE_REFUSAL );
TacticalCharacterDialogue( pSoldier, QUOTE_DEATH_RATE_REFUSAL );
} }
//Trigger Jerry Milo's script record 11 ( call action 302 ) //Trigger Jerry Milo's script record 11 ( call action 302 )
@@ -5233,29 +5216,27 @@ void PerformJerryMiloAction301()
void PerformJerryMiloAction302() void PerformJerryMiloAction302()
{ {
UINT8 ubMercsPresent[NUM_MERCS_WITH_NEW_QUOTES]; UINT8 ubMercsPresent[NUM_MERCS_WITH_NEW_QUOTES];
INT8 bNumMercsPresent=-1; UINT8 usNumMercsPresent;
SOLDIERTYPE *pSoldier=NULL;
UINT8 ubId;
//off jazz //off jazz
//Get the number and array of the new soldiers //Get the number and array of the new soldiers
bNumMercsPresent = GetNumSoldierIdAndProfileIdOfTheNewMercsOnPlayerTeam( ubMercsPresent, NULL ); usNumMercsPresent = GetNumSoldierIdAndProfileIdOfTheNewMercsOnPlayerTeam( ubMercsPresent, NULL );
//Randomly choose one //Randomly choose one
//if there is at least 1 of the desired mercs found //if there is at least 1 of the desired mercs found
if( bNumMercsPresent != 0 ) if( usNumMercsPresent > 0 )
{ {
UINT8 ubProfileID = NO_PROFILE; UINT8 ubProfileID = NO_PROFILE;
UINT8 ubIdOfMercWhoSaidQuote; UINT8 ubIdOfMercWhoSaidQuote;
ubIdOfMercWhoSaidQuote = Random( bNumMercsPresent ); ubIdOfMercWhoSaidQuote = Random( usNumMercsPresent );
ubId = ubMercsPresent[ ubIdOfMercWhoSaidQuote ]; UINT8 ubId = ubMercsPresent[ ubIdOfMercWhoSaidQuote ];
pSoldier = MercPtrs[ ubId ]; SOLDIERTYPE* pSoldier = MercPtrs[ ubId ];
TacticalCharacterDialogue( pSoldier, QUOTE_LAME_REFUSAL ); TacticalCharacterDialogue( pSoldier, QUOTE_LAME_REFUSAL );
if( bNumMercsPresent == 1 ) if( usNumMercsPresent == 1 )
ubProfileID = MercPtrs[ ubId ]->ubProfile; ubProfileID = MercPtrs[ ubId ]->ubProfile;
else else
{ {
@@ -5263,7 +5244,7 @@ void PerformJerryMiloAction302()
while( !fDone ) while( !fDone )
{ {
ubProfileID = Random( bNumMercsPresent ); ubProfileID = Random( usNumMercsPresent );
if( ubProfileID != ubIdOfMercWhoSaidQuote ) if( ubProfileID != ubIdOfMercWhoSaidQuote )
{ {
@@ -5277,7 +5258,6 @@ void PerformJerryMiloAction302()
//Say the quote in 15 seconds //Say the quote in 15 seconds
DelayedMercQuote( ubProfileID, QUOTE_DEPARTING_COMMENT_CONTRACT_NOT_RENEWED_OR_48_OR_MORE, GetWorldTotalSeconds( ) + 15 ); DelayedMercQuote( ubProfileID, QUOTE_DEPARTING_COMMENT_CONTRACT_NOT_RENEWED_OR_48_OR_MORE, GetWorldTotalSeconds( ) + 15 );
} }
//handle the merc arrives quotes now //handle the merc arrives quotes now
@@ -5388,7 +5368,7 @@ void HandleSpecificQuoteWhenLeavingNpcTalkMenu()
void HaveQualifiedMercSayQuoteAboutNpcWhenLeavingTalkScreen( UINT8 ubNpcProfileID, UINT32 uiQuoteNum ) void HaveQualifiedMercSayQuoteAboutNpcWhenLeavingTalkScreen( UINT8 ubNpcProfileID, UINT32 uiQuoteNum )
{ {
INT8 bNumMercsPresent=-1; UINT8 usNumMercsPresent;
UINT8 SoldierIdArray[NUM_MERCS_WITH_NEW_QUOTES]; UINT8 SoldierIdArray[NUM_MERCS_WITH_NEW_QUOTES];
UINT8 ValidSoldierIdArray[NUM_MERCS_WITH_NEW_QUOTES] = {0}; UINT8 ValidSoldierIdArray[NUM_MERCS_WITH_NEW_QUOTES] = {0};
UINT8 ubNumValidSoldiers=0; UINT8 ubNumValidSoldiers=0;
@@ -5403,17 +5383,16 @@ void HaveQualifiedMercSayQuoteAboutNpcWhenLeavingTalkScreen( UINT8 ubNpcProfileI
} }
//Get the number and array of the new soldiers //Get the number and array of the new soldiers
bNumMercsPresent = GetNumSoldierIdAndProfileIdOfTheNewMercsOnPlayerTeam( SoldierIdArray, NULL ); usNumMercsPresent = GetNumSoldierIdAndProfileIdOfTheNewMercsOnPlayerTeam( SoldierIdArray, NULL );
//if the player doesnt have any qualified players on the team //if the player doesnt have any qualified players on the team
if( bNumMercsPresent == -1 ) if( !usNumMercsPresent )
{ {
return; return;
} }
//loop through the mercs and see if there in range of the dealer //loop through the mercs and see if there in range of the dealer
for( ubCnt=0; ubCnt<bNumMercsPresent; ubCnt++) for( ubCnt=0; ubCnt<usNumMercsPresent; ++ubCnt )
{ {
pSoldier = &Menptr[ SoldierIdArray[ ubCnt ] ]; pSoldier = &Menptr[ SoldierIdArray[ ubCnt ] ];
@@ -5422,7 +5401,7 @@ void HaveQualifiedMercSayQuoteAboutNpcWhenLeavingTalkScreen( UINT8 ubNpcProfileI
SoldierTo3DLocationLineOfSightTest( pSoldier, pNPC->sGridNo, 0, 0, (UINT8)MaxDistanceVisible(), TRUE ) ) SoldierTo3DLocationLineOfSightTest( pSoldier, pNPC->sGridNo, 0, 0, (UINT8)MaxDistanceVisible(), TRUE ) )
{ {
ValidSoldierIdArray[ ubNumValidSoldiers ] = pSoldier->ubID; ValidSoldierIdArray[ ubNumValidSoldiers ] = pSoldier->ubID;
ubNumValidSoldiers++; ++ubNumValidSoldiers;
} }
} }
+47 -73
View File
@@ -259,7 +259,6 @@ void Old_UB_Inventory ()
MORRIS_INSTRUCTION_NOTE = 336; MORRIS_INSTRUCTION_NOTE = 336;
} }
void New_UB_Inventory () void New_UB_Inventory ()
{ {
//inshy: chenge index of items to 1.13 version. Now we dont need Items.xml in UB-113 folder //inshy: chenge index of items to 1.13 version. Now we dont need Items.xml in UB-113 folder
@@ -391,7 +390,6 @@ void InitGridNoUB()
CALICO_900_UB = gGameUBOptions.ubCALICO_900_UB; CALICO_900_UB = gGameUBOptions.ubCALICO_900_UB;
} }
BOOLEAN IsSoldierQualifiedMerc( SOLDIERTYPE *pSoldier ) BOOLEAN IsSoldierQualifiedMerc( SOLDIERTYPE *pSoldier )
{ {
if( pSoldier->ubProfile == GASTON_UB || /// GASTON if( pSoldier->ubProfile == GASTON_UB || /// GASTON
@@ -411,7 +409,6 @@ BOOLEAN IsSoldierQualifiedMerc( SOLDIERTYPE *pSoldier )
} }
} }
BOOLEAN IsSoldierQualifiedMercForSeeingPowerGenFan( SOLDIERTYPE *pSoldier ) BOOLEAN IsSoldierQualifiedMercForSeeingPowerGenFan( SOLDIERTYPE *pSoldier )
{ {
if( pSoldier->ubProfile == MANUEL_UB ||//MANUEL || if( pSoldier->ubProfile == MANUEL_UB ||//MANUEL ||
@@ -428,7 +425,6 @@ BOOLEAN IsSoldierQualifiedMercForSeeingPowerGenFan( SOLDIERTYPE *pSoldier )
} }
} }
BOOLEAN IsSoldierQualifiedGunCommenterMerc( SOLDIERTYPE *pSoldier ) BOOLEAN IsSoldierQualifiedGunCommenterMerc( SOLDIERTYPE *pSoldier )
{ {
if( pSoldier->ubProfile == GASTON_UB || // GASTON if( pSoldier->ubProfile == GASTON_UB || // GASTON
@@ -445,7 +441,6 @@ BOOLEAN IsSoldierQualifiedGunCommenterMerc( SOLDIERTYPE *pSoldier )
} }
} }
BOOLEAN IsSoldierQualifiedInitialHireMerc( SOLDIERTYPE *pSoldier ) BOOLEAN IsSoldierQualifiedInitialHireMerc( SOLDIERTYPE *pSoldier )
{ {
if( pSoldier->ubProfile == GASTON_UB || // GASTON if( pSoldier->ubProfile == GASTON_UB || // GASTON
@@ -461,13 +456,10 @@ BOOLEAN IsSoldierQualifiedInitialHireMerc( SOLDIERTYPE *pSoldier )
} }
} }
UINT8 GetNumSoldierIdAndProfileIdOfTheNewMercsOnPlayerTeam( UINT8 *pSoldierIdArray, UINT8 *pProfileIdArray )
INT8 GetNumSoldierIdAndProfileIdOfTheNewMercsOnPlayerTeam( UINT8 *pSoldierIdArray, UINT8 *pProfileIdArray )
{ {
SOLDIERTYPE *pSoldier=NULL; SOLDIERTYPE *pSoldier=NULL;
INT32 cnt; UINT8 usNumMercsPresent=0;
INT8 bNumMercsPresent=0;
if( pSoldierIdArray ) if( pSoldierIdArray )
memset( pSoldierIdArray, NOBODY, NUM_MERCS_WITH_NEW_QUOTES ); memset( pSoldierIdArray, NOBODY, NUM_MERCS_WITH_NEW_QUOTES );
@@ -475,10 +467,10 @@ INT8 GetNumSoldierIdAndProfileIdOfTheNewMercsOnPlayerTeam( UINT8 *pSoldierIdArra
if( pProfileIdArray ) if( pProfileIdArray )
memset( pProfileIdArray, NO_PROFILE, NUM_MERCS_WITH_NEW_QUOTES ); memset( pProfileIdArray, NO_PROFILE, NUM_MERCS_WITH_NEW_QUOTES );
cnt = gTacticalStatus.Team[ OUR_TEAM ].bFirstID; INT32 cnt = gTacticalStatus.Team[ OUR_TEAM ].bFirstID;
//Check to see if Gaston, Stogie or the PGC is on the team //Check to see if Gaston, Stogie or the PGC is on the team
for ( pSoldier = MercPtrs[ cnt ]; cnt <= gTacticalStatus.Team[ OUR_TEAM ].bLastID; cnt++,pSoldier++) for ( pSoldier = MercPtrs[ cnt ]; cnt <= gTacticalStatus.Team[ OUR_TEAM ].bLastID; ++cnt, ++pSoldier )
{ {
//if the merc is alive, in sector, etc... //if the merc is alive, in sector, etc...
//Note: cant do the OK_CONTROLLABLE_MERC() cause it does bInSector which is not set when EnterSector is finshed ( we need it then ) //Note: cant do the OK_CONTROLLABLE_MERC() cause it does bInSector which is not set when EnterSector is finshed ( we need it then )
@@ -506,30 +498,28 @@ INT8 GetNumSoldierIdAndProfileIdOfTheNewMercsOnPlayerTeam( UINT8 *pSoldierIdArra
pSoldierIdArray[ bNumMercsPresent ] = pSoldier->ubID; pSoldierIdArray[ bNumMercsPresent ] = pSoldier->ubID;
} }
bNumMercsPresent++; ++usNumMercsPresent;
} }
} }
} }
return( bNumMercsPresent ); return usNumMercsPresent;
} }
INT16 RandomProfileIdFromNewMercsOnPlayerTeam()
INT8 RandomProfileIdFromNewMercsOnPlayerTeam()
{ {
INT8 bNumMercsPresent=-1; UINT8 usNumMercsPresent;
UINT8 ProfileIdArray[NUM_MERCS_WITH_NEW_QUOTES]; UINT8 ProfileIdArray[NUM_MERCS_WITH_NEW_QUOTES];
//Get the number and array of the new soldiers //Get the number and array of the new soldiers
bNumMercsPresent = GetNumSoldierIdAndProfileIdOfTheNewMercsOnPlayerTeam( NULL, ProfileIdArray ); usNumMercsPresent = GetNumSoldierIdAndProfileIdOfTheNewMercsOnPlayerTeam( NULL, ProfileIdArray );
Assert( bNumMercsPresent < NUM_MERCS_WITH_NEW_QUOTES ); Assert( usNumMercsPresent < NUM_MERCS_WITH_NEW_QUOTES );
if( bNumMercsPresent != 0 ) if( usNumMercsPresent > 0 )
{ {
//return a random merc from the array //return a random merc from the array
return( ProfileIdArray[ Random( bNumMercsPresent ) ] ); return( (INT16)(ProfileIdArray[ Random( usNumMercsPresent ) ]) );
} }
else else
{ {
@@ -537,21 +527,20 @@ INT8 RandomProfileIdFromNewMercsOnPlayerTeam()
} }
} }
INT16 RandomSoldierIdFromNewMercsOnPlayerTeam()
INT8 RandomSoldierIdFromNewMercsOnPlayerTeam()
{ {
INT8 bNumMercsPresent=-1; UINT8 usNumMercsPresent;
UINT8 SoldierIdArray[NUM_MERCS_WITH_NEW_QUOTES]; UINT8 SoldierIdArray[NUM_MERCS_WITH_NEW_QUOTES];
//Get the number and array of the new soldiers //Get the number and array of the new soldiers
bNumMercsPresent = GetNumSoldierIdAndProfileIdOfTheNewMercsOnPlayerTeam( SoldierIdArray, NULL ); usNumMercsPresent = GetNumSoldierIdAndProfileIdOfTheNewMercsOnPlayerTeam( SoldierIdArray, NULL );
Assert( bNumMercsPresent < NUM_MERCS_WITH_NEW_QUOTES ); Assert( usNumMercsPresent < NUM_MERCS_WITH_NEW_QUOTES );
if( bNumMercsPresent != 0 ) if( usNumMercsPresent > 0 )
{ {
//return a random merc from the array //return a random merc from the array
return( SoldierIdArray[ Random( bNumMercsPresent ) ] ); return( (INT16)( SoldierIdArray[ Random( usNumMercsPresent ) ] ));
} }
else else
{ {
@@ -559,13 +548,11 @@ INT8 RandomSoldierIdFromNewMercsOnPlayerTeam()
} }
} }
UINT8 RandomArrayOfQualifiedMercs( UINT8 *pRandomSoldierIdArray )
INT8 RandomArrayOfQualifiedMercs( UINT8 *pRandomSoldierIdArray )
{ {
INT8 bNumMercsPresent=-1; UINT8 usNumMercsPresent;
UINT8 SoldierIdArray[NUM_MERCS_WITH_NEW_QUOTES]; UINT8 SoldierIdArray[NUM_MERCS_WITH_NEW_QUOTES];
BOOLEAN UsedArray[NUM_MERCS_WITH_NEW_QUOTES]; BOOLEAN UsedArray[NUM_MERCS_WITH_NEW_QUOTES];
UINT8 ubCnt;
BOOLEAN fFound=FALSE; BOOLEAN fFound=FALSE;
UINT8 ubRand; UINT8 ubRand;
@@ -573,21 +560,21 @@ INT8 RandomArrayOfQualifiedMercs( UINT8 *pRandomSoldierIdArray )
memset( pRandomSoldierIdArray, NOBODY, NUM_MERCS_WITH_NEW_QUOTES ); memset( pRandomSoldierIdArray, NOBODY, NUM_MERCS_WITH_NEW_QUOTES );
//Get the number and array of the new soldiers //Get the number and array of the new soldiers
bNumMercsPresent = GetNumSoldierIdAndProfileIdOfTheNewMercsOnPlayerTeam( SoldierIdArray, NULL ); usNumMercsPresent = GetNumSoldierIdAndProfileIdOfTheNewMercsOnPlayerTeam( SoldierIdArray, NULL );
Assert( bNumMercsPresent < NUM_MERCS_WITH_NEW_QUOTES ); Assert( bNumMercsPresent < NUM_MERCS_WITH_NEW_QUOTES );
if( bNumMercsPresent != 0 ) if( usNumMercsPresent > 0 )
{ {
//loop through all the available mercs //loop through all the available mercs
for( ubCnt=0; ubCnt<bNumMercsPresent; ubCnt++ ) for( UINT8 ubCnt=0; ubCnt<usNumMercsPresent; ++ubCnt )
{ {
fFound = FALSE; fFound = FALSE;
//loop //loop
while( !fFound ) while( !fFound )
{ {
ubRand = Random( bNumMercsPresent ); ubRand = Random( usNumMercsPresent );
if( !UsedArray[ ubRand ] ) if( !UsedArray[ ubRand ] )
{ {
UsedArray[ ubRand ] = TRUE; UsedArray[ ubRand ] = TRUE;
@@ -597,19 +584,19 @@ INT8 RandomArrayOfQualifiedMercs( UINT8 *pRandomSoldierIdArray )
} }
} }
} }
return( bNumMercsPresent );
}
return( usNumMercsPresent );
}
UINT8 Get3RandomQualifiedMercs( UINT8 *pSoldierId1, UINT8 *pSoldierId2, UINT8 *pSoldierId3 ) UINT8 Get3RandomQualifiedMercs( UINT8 *pSoldierId1, UINT8 *pSoldierId2, UINT8 *pSoldierId3 )
{ {
UINT8 bNumMercs; UINT8 usNumMercs;
UINT8 RandomSoldierIdArray[ NUM_MERCS_WITH_NEW_QUOTES ]; UINT8 RandomSoldierIdArray[ NUM_MERCS_WITH_NEW_QUOTES ];
UINT8 ubNumberDifMercsAssigned=0; UINT8 ubNumberDifMercsAssigned=0;
bNumMercs = RandomArrayOfQualifiedMercs( RandomSoldierIdArray ); usNumMercs = RandomArrayOfQualifiedMercs( RandomSoldierIdArray );
if( bNumMercs == 0 ) if( usNumMercs == 0 )
{ {
return( 0 ); return( 0 );
} }
@@ -623,14 +610,13 @@ UINT8 Get3RandomQualifiedMercs( UINT8 *pSoldierId1, UINT8 *pSoldierId2, UINT8 *p
if( pSoldierId3 != NULL ) if( pSoldierId3 != NULL )
*pSoldierId3 = NOBODY; *pSoldierId3 = NOBODY;
if( usNumMercs >= 1 && pSoldierId1 != NULL )
if( bNumMercs >= 1 && pSoldierId1 != NULL )
{ {
*pSoldierId1 = RandomSoldierIdArray[ 0 ]; *pSoldierId1 = RandomSoldierIdArray[ 0 ];
ubNumberDifMercsAssigned++; ubNumberDifMercsAssigned++;
} }
if( bNumMercs >= 2 && pSoldierId2 != NULL ) if( usNumMercs >= 2 && pSoldierId2 != NULL )
{ {
*pSoldierId2 = RandomSoldierIdArray[ 1 ]; *pSoldierId2 = RandomSoldierIdArray[ 1 ];
ubNumberDifMercsAssigned++; ubNumberDifMercsAssigned++;
@@ -642,12 +628,12 @@ UINT8 Get3RandomQualifiedMercs( UINT8 *pSoldierId1, UINT8 *pSoldierId2, UINT8 *p
if( pSoldierId3 != NULL ) if( pSoldierId3 != NULL )
{ {
if( bNumMercs >= 3 ) if( usNumMercs >= 3 )
{ {
*pSoldierId3 = RandomSoldierIdArray[ 2 ]; *pSoldierId3 = RandomSoldierIdArray[ 2 ];
ubNumberDifMercsAssigned++; ubNumberDifMercsAssigned++;
} }
else if( bNumMercs >= 2 ) else if( usNumMercs >= 2 )
{ {
if( Chance( 50 ) ) if( Chance( 50 ) )
*pSoldierId3 = RandomSoldierIdArray[ 1 ]; *pSoldierId3 = RandomSoldierIdArray[ 1 ];
@@ -659,7 +645,6 @@ UINT8 Get3RandomQualifiedMercs( UINT8 *pSoldierId1, UINT8 *pSoldierId2, UINT8 *p
return( ubNumberDifMercsAssigned ); return( ubNumberDifMercsAssigned );
} }
void HandleWhenCertainPercentageOfEnemiesDie() void HandleWhenCertainPercentageOfEnemiesDie()
{ {
UINT32 uiPercentEnemiesKilled; UINT32 uiPercentEnemiesKilled;
@@ -685,10 +670,10 @@ void HandleWhenCertainPercentageOfEnemiesDie()
//all enemies are dead and if the quote hasnt been said yet //all enemies are dead and if the quote hasnt been said yet
if( uiPercentEnemiesKilled >= 100 && !( gJa25SaveStruct.uiJa25GeneralFlags & JA_GF__ALL_DEAD_TOP_LEVEL_OF_COMPLEX ) ) if( uiPercentEnemiesKilled >= 100 && !( gJa25SaveStruct.uiJa25GeneralFlags & JA_GF__ALL_DEAD_TOP_LEVEL_OF_COMPLEX ) )
{ {
INT8 bProfile = RandomProfileIdFromNewMercsOnPlayerTeam(); INT16 bProfile = RandomProfileIdFromNewMercsOnPlayerTeam();
if( bProfile != -1 ) if( bProfile != -1 )
DelayedMercQuote( bProfile, QUOTE_WONT_RENEW_CONTRACT_LAME_REFUSAL, GetWorldTotalSeconds() + 5 ); DelayedMercQuote( (UINT16)bProfile, QUOTE_WONT_RENEW_CONTRACT_LAME_REFUSAL, GetWorldTotalSeconds() + 5 );
gJa25SaveStruct.uiJa25GeneralFlags |= JA_GF__ALL_DEAD_TOP_LEVEL_OF_COMPLEX; gJa25SaveStruct.uiJa25GeneralFlags |= JA_GF__ALL_DEAD_TOP_LEVEL_OF_COMPLEX;
} }
@@ -885,7 +870,7 @@ void HandlePowerGenAlarm()
// //
if( gubFact[ FACT_PLAYER_KNOWS_ABOUT_FAN_STOPPING ] ) if( gubFact[ FACT_PLAYER_KNOWS_ABOUT_FAN_STOPPING ] )
{ {
INT8 bID = RandomSoldierIdFromNewMercsOnPlayerTeam(); INT16 bID = RandomSoldierIdFromNewMercsOnPlayerTeam();
if( bID != -1 ) if( bID != -1 )
{ {
@@ -971,10 +956,8 @@ BOOLEAN HandlePlayerSayingQuoteWhenFailingToOpenGateInTunnel( SOLDIERTYPE *pSold
{ {
INT8 bSlot; INT8 bSlot;
UINT32 cnt; UINT32 cnt;
UINT8 ubID;
SOLDIERTYPE *pSoldier; SOLDIERTYPE *pSoldier;
//is this the right sector K14-1 //is this the right sector K14-1
if( !( gWorldSectorX == SECTOR_OPEN_GATE_IN_TUNNEL_X && gWorldSectorY == SECTOR_OPEN_GATE_IN_TUNNEL_Y && gbWorldSectorZ == SECTOR_OPEN_GATE_IN_TUNNEL_Z ) ) if( !( gWorldSectorX == SECTOR_OPEN_GATE_IN_TUNNEL_X && gWorldSectorY == SECTOR_OPEN_GATE_IN_TUNNEL_Y && gbWorldSectorZ == SECTOR_OPEN_GATE_IN_TUNNEL_Z ) )
{ {
@@ -1008,12 +991,12 @@ BOOLEAN HandlePlayerSayingQuoteWhenFailingToOpenGateInTunnel( SOLDIERTYPE *pSold
} }
} }
ubID = RandomSoldierIdFromNewMercsOnPlayerTeam(); INT16 bID = RandomSoldierIdFromNewMercsOnPlayerTeam();
if( ubID != -1 ) if( bID != -1 )
{ {
//have the merc say the quote about the tough gate //have the merc say the quote about the tough gate
TacticalCharacterDialogue( &Menptr[ ubID ], QUOTE_IMPATIENT_QUOTE ); TacticalCharacterDialogue( &Menptr[ bID ], QUOTE_IMPATIENT_QUOTE );
} }
//remeber we said the quote //remeber we said the quote
@@ -1077,26 +1060,23 @@ void HandlePlayingQuoteWhenHiringNpc( UINT8 ubProfile )
} }
else if ( ubProfile == TEX_UB ) //TEX: else if ( ubProfile == TEX_UB ) //TEX:
SayQuoteFromAllNewHiredMercButDoGastonLast( ubProfile, QUOTE_DEATH_RATE_RENEWAL ); SayQuoteFromAllNewHiredMercButDoGastonLast( ubProfile, QUOTE_DEATH_RATE_RENEWAL );
} }
BOOLEAN SayQuoteFromAllNewHiredMercButDoGastonLast( UINT8 ubProfile, UINT32 uiQuoteNum ) BOOLEAN SayQuoteFromAllNewHiredMercButDoGastonLast( UINT8 ubProfile, UINT32 uiQuoteNum )
{ {
INT8 bNumMercsPresent=-1; UINT8 usNumMercsPresent;
UINT8 SoldierIdArray[NUM_MERCS_WITH_NEW_QUOTES]; UINT8 SoldierIdArray[NUM_MERCS_WITH_NEW_QUOTES];
INT32 iCnt;
SOLDIERTYPE *pSoldier=NULL; SOLDIERTYPE *pSoldier=NULL;
//Get an array of the mercs on the team //Get an array of the mercs on the team
bNumMercsPresent = GetNumSoldierIdAndProfileIdOfTheNewMercsOnPlayerTeam( SoldierIdArray, NULL ); usNumMercsPresent = GetNumSoldierIdAndProfileIdOfTheNewMercsOnPlayerTeam( SoldierIdArray, NULL );
if( bNumMercsPresent == -1 ) if( !usNumMercsPresent )
{ {
return( FALSE ); return( FALSE );
} }
for( iCnt=0; iCnt<bNumMercsPresent; iCnt++ ) for ( UINT8 iCnt=0; iCnt<usNumMercsPresent; ++iCnt )
{ {
//Do Gaston and the newly hired RPC last //Do Gaston and the newly hired RPC last
if( Menptr[ SoldierIdArray[ iCnt ] ].ubProfile == GASTON_UB || Menptr[ SoldierIdArray[ iCnt ] ].ubProfile == ubProfile) // GASTON if( Menptr[ SoldierIdArray[ iCnt ] ].ubProfile == GASTON_UB || Menptr[ SoldierIdArray[ iCnt ] ].ubProfile == ubProfile) // GASTON
@@ -1316,8 +1296,6 @@ void SetNewGunQuoteToBePlayedForThisGun( INT32 iItemIndex )
void HandlePickingUpMorrisInstructionNote( SOLDIERTYPE *pSoldier, INT32 iIndex ) void HandlePickingUpMorrisInstructionNote( SOLDIERTYPE *pSoldier, INT32 iIndex )
{ {
INT8 bID=-1;
if( iIndex != MORRIS_INSTRUCTION_NOTE ) if( iIndex != MORRIS_INSTRUCTION_NOTE )
{ {
return; return;
@@ -1332,7 +1310,7 @@ void HandlePickingUpMorrisInstructionNote( SOLDIERTYPE *pSoldier, INT32 iIndex )
} }
*/ */
bID = RandomSoldierIdFromNewMercsOnPlayerTeam(); INT16 bID = RandomSoldierIdFromNewMercsOnPlayerTeam();
//if this is a qualified merc on the team //if this is a qualified merc on the team
if( IsSoldierQualifiedMerc( pSoldier ) ) if( IsSoldierQualifiedMerc( pSoldier ) )
@@ -1343,7 +1321,6 @@ void HandlePickingUpMorrisInstructionNote( SOLDIERTYPE *pSoldier, INT32 iIndex )
//Delaying the merc to say the note //Delaying the merc to say the note
DelayedMercQuote( pSoldier->ubProfile, DQ__NEW_MERC_SAY_NOTE_QUOTES, GetWorldTotalSeconds()+1 ); DelayedMercQuote( pSoldier->ubProfile, DQ__NEW_MERC_SAY_NOTE_QUOTES, GetWorldTotalSeconds()+1 );
} }
//else if there is a new merc on the team //else if there is a new merc on the team
else if( bID != -1 ) else if( bID != -1 )
{ {
@@ -1373,7 +1350,6 @@ void HandlePickingUpMorrisInstructionNote( SOLDIERTYPE *pSoldier, INT32 iIndex )
DelayedMercQuote( NOBODY, DQ__MORRIS_NOTE_NEW_MERC_DELAY, uiTime ); DelayedMercQuote( NOBODY, DQ__MORRIS_NOTE_NEW_MERC_DELAY, uiTime );
} }
else else
{ {
// //
@@ -1897,8 +1873,6 @@ void DisplayCommanderMorrisNote( SOLDIERTYPE *pSoldier )
void HandleCommanderMorrisNewMercWantsNoteDelayedSpeech() void HandleCommanderMorrisNewMercWantsNoteDelayedSpeech()
{ {
INT8 bID=-1;
//if the note has already been picked up by a new merc, or the note has been displayed //if the note has already been picked up by a new merc, or the note has been displayed
if( gJa25SaveStruct.ubMorrisNoteState == MN__PICKED_UP_BY_NEW_MERC || if( gJa25SaveStruct.ubMorrisNoteState == MN__PICKED_UP_BY_NEW_MERC ||
gJa25SaveStruct.ubMorrisNoteState == MN__FINISHED ) gJa25SaveStruct.ubMorrisNoteState == MN__FINISHED )
@@ -1907,7 +1881,7 @@ void HandleCommanderMorrisNewMercWantsNoteDelayedSpeech()
} }
//if the original merc who said the quote is valid //if the original merc who said the quote is valid
bID = gJa25SaveStruct.bNewMercProfileIDForSayingMorrisNote; INT16 bID = gJa25SaveStruct.bNewMercProfileIDForSayingMorrisNote;
if( bID != -1 && IsSoldierQualifiedMerc( &Menptr[ bID ] ) ) if( bID != -1 && IsSoldierQualifiedMerc( &Menptr[ bID ] ) )
{ {
} }
+4 -4
View File
@@ -36,9 +36,9 @@ typedef struct
*/ */
extern BOOLEAN gfFirstTimeInGameHeliCrash; extern BOOLEAN gfFirstTimeInGameHeliCrash;
INT8 RandomProfileIdFromNewMercsOnPlayerTeam(); INT16 RandomProfileIdFromNewMercsOnPlayerTeam();
INT8 RandomSoldierIdFromNewMercsOnPlayerTeam(); INT16 RandomSoldierIdFromNewMercsOnPlayerTeam();
INT8 GetNumSoldierIdAndProfileIdOfTheNewMercsOnPlayerTeam( UINT8 *pSoldierIdArray, UINT8 *pProfileIdArray ); UINT8 GetNumSoldierIdAndProfileIdOfTheNewMercsOnPlayerTeam( UINT8 *pSoldierIdArray, UINT8 *pProfileIdArray );
BOOLEAN IsSoldierQualifiedMerc( SOLDIERTYPE *pSoldier ); BOOLEAN IsSoldierQualifiedMerc( SOLDIERTYPE *pSoldier );
BOOLEAN IsSoldierQualifiedInitialHireMerc( SOLDIERTYPE *pSoldier ); BOOLEAN IsSoldierQualifiedInitialHireMerc( SOLDIERTYPE *pSoldier );
BOOLEAN IsSoldierQualifiedMercForSeeingPowerGenFan( SOLDIERTYPE *pSoldier ); BOOLEAN IsSoldierQualifiedMercForSeeingPowerGenFan( SOLDIERTYPE *pSoldier );
@@ -47,7 +47,7 @@ BOOLEAN SayQuoteFromAllNewHiredMercButDoGastonLast( UINT8 ubProfile, UINT32 uiQu
//Pass in an array of size NUM_MERCS_WITH_NEW_QUOTES, array will be filled with //Pass in an array of size NUM_MERCS_WITH_NEW_QUOTES, array will be filled with
//random soldier IDs of the qualified mercs //random soldier IDs of the qualified mercs
INT8 RandomArrayOfQualifiedMercs( UINT8 *pRandomSoldierIdArray ); UINT8 RandomArrayOfQualifiedMercs( UINT8 *pRandomSoldierIdArray );
extern UINT8 Get3RandomQualifiedMercs( UINT8 *pSoldierId1, UINT8 *pSoldierId2, UINT8 *pSoldierId3 ); extern UINT8 Get3RandomQualifiedMercs( UINT8 *pSoldierId1, UINT8 *pSoldierId2, UINT8 *pSoldierId3 );
+23 -29
View File
@@ -414,7 +414,7 @@ UINT8 NumEnemyInSectorNotDeadOrDying( );
UINT8 NumBloodcatsInSectorNotDeadOrDying( ); UINT8 NumBloodcatsInSectorNotDeadOrDying( );
UINT8 gubWaitingForAllMercsToExitCode = 0; UINT8 gubWaitingForAllMercsToExitCode = 0;
INT8 gbNumMercsUntilWaitingOver = 0; UINT8 gusNumMercsUntilWaitingOver = 0;
UINT32 guiWaitingForAllMercsToExitData[3]; UINT32 guiWaitingForAllMercsToExitData[3];
UINT32 guiWaitingForAllMercsToExitTimer = 0; UINT32 guiWaitingForAllMercsToExitTimer = 0;
BOOLEAN gfKillingGuysForLosingBattle = FALSE; BOOLEAN gfKillingGuysForLosingBattle = FALSE;
@@ -1359,7 +1359,7 @@ BOOLEAN ExecuteOverhead( )
else if ( pSoldier->ubWaitActionToDo == 1 ) else if ( pSoldier->ubWaitActionToDo == 1 )
{ {
pSoldier->ubWaitActionToDo = 0; pSoldier->ubWaitActionToDo = 0;
gbNumMercsUntilWaitingOver--; gusNumMercsUntilWaitingOver = max(0, gusNumMercsUntilWaitingOver - 1);
pSoldier->SoldierGotoStationaryStance( ); pSoldier->SoldierGotoStationaryStance( );
// If we are at an exit-grid, make disappear..... // If we are at an exit-grid, make disappear.....
if ( gubWaitingForAllMercsToExitCode == WAIT_FOR_MERCS_TO_WALK_TO_GRIDNO ) if ( gubWaitingForAllMercsToExitCode == WAIT_FOR_MERCS_TO_WALK_TO_GRIDNO )
@@ -1915,7 +1915,7 @@ BOOLEAN ExecuteOverhead( )
#ifdef JA2BETAVERSION #ifdef JA2BETAVERSION
ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_DEBUG, L"Waiting too long for Mercs to exit...forcing entry." ); ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_DEBUG, L"Waiting too long for Mercs to exit...forcing entry." );
#endif #endif
gbNumMercsUntilWaitingOver = 0; gusNumMercsUntilWaitingOver = 0;
// Reset all waitng codes // Reset all waitng codes
for ( cnt = 0; cnt < guiNumMercSlots; cnt++ ) for ( cnt = 0; cnt < guiNumMercSlots; cnt++ )
@@ -1929,12 +1929,11 @@ BOOLEAN ExecuteOverhead( )
} }
} }
if ( gbNumMercsUntilWaitingOver == 0 ) if ( gusNumMercsUntilWaitingOver == 0 )
{ {
// ATE: Unset flag to ignore sight... // ATE: Unset flag to ignore sight...
gTacticalStatus.uiFlags &= ( ~DISALLOW_SIGHT ); gTacticalStatus.uiFlags &= ( ~DISALLOW_SIGHT );
// OK cheif, do something here.... // OK cheif, do something here....
switch( gubWaitingForAllMercsToExitCode ) switch( gubWaitingForAllMercsToExitCode )
{ {
@@ -3807,28 +3806,24 @@ void HandleNPCTeamMemberDeath( SOLDIERTYPE *pSoldierOld )
#ifdef JA2UB #ifdef JA2UB
if ( pSoldierOld->ubProfile == MORRIS_UB ) if ( pSoldierOld->ubProfile == MORRIS_UB )
{ {
{ INT16 bSoldierID;
INT8 bSoldierID; SOLDIERTYPE* pOther = FindSoldierByProfileID( MORRIS_UB, FALSE );
SOLDIERTYPE * pOther; if ( pOther )
{
OBJECTTYPE Object;
CreateItem( MORRIS_INSTRUCTION_NOTE, 100, &Object );
AutoPlaceObject( pOther, &Object, TRUE );
}
pOther = FindSoldierByProfileID( MORRIS_UB, FALSE ); //Geta a random soldier ID
if ( pOther ) bSoldierID = RandomSoldierIdFromNewMercsOnPlayerTeam();
{
OBJECTTYPE Object;
CreateItem( MORRIS_INSTRUCTION_NOTE, 100, &Object );
AutoPlaceObject( pOther, &Object, TRUE );
}
//Geta a random soldier ID //if there is any
bSoldierID = RandomSoldierIdFromNewMercsOnPlayerTeam(); if( bSoldierID != -1 )
{
//if there is any //say the MORRIS dead quote
if( bSoldierID != -1 ) TacticalCharacterDialogue( &Menptr[ bSoldierID ], QUOTE_LEARNED_TO_HATE_ON_TEAM_WONT_RENEW );
{ }
//say the MORRIS dead quote
TacticalCharacterDialogue( &Menptr[ bSoldierID ], QUOTE_LEARNED_TO_HATE_ON_TEAM_WONT_RENEW );
}
}
} }
// Ja25no queen // Ja25no queen
#else #else
@@ -9682,10 +9677,10 @@ void ResetAllMercSpeeds( )
} }
void SetActionToDoOnceMercsGetToLocation( UINT8 ubActionCode, INT8 bNumMercsWaiting, UINT32 uiData1, UINT32 uiData2, UINT32 uiData3 ) void SetActionToDoOnceMercsGetToLocation( UINT8 ubActionCode, UINT8 uiNumMercsWaiting, UINT32 uiData1, UINT32 uiData2, UINT32 uiData3 )
{ {
gubWaitingForAllMercsToExitCode = ubActionCode; gubWaitingForAllMercsToExitCode = ubActionCode;
gbNumMercsUntilWaitingOver = bNumMercsWaiting; gusNumMercsUntilWaitingOver = uiNumMercsWaiting;
guiWaitingForAllMercsToExitData[ 0 ] = uiData1; guiWaitingForAllMercsToExitData[ 0 ] = uiData1;
guiWaitingForAllMercsToExitData[ 1 ] = uiData2; guiWaitingForAllMercsToExitData[ 1 ] = uiData2;
guiWaitingForAllMercsToExitData[ 2 ] = uiData3; guiWaitingForAllMercsToExitData[ 2 ] = uiData3;
@@ -9695,7 +9690,6 @@ void SetActionToDoOnceMercsGetToLocation( UINT8 ubActionCode, INT8 bNumMercsWa
// ATE: Set flag to ignore sight... // ATE: Set flag to ignore sight...
gTacticalStatus.uiFlags |= ( DISALLOW_SIGHT ); gTacticalStatus.uiFlags |= ( DISALLOW_SIGHT );
} }
void HandleBloodForNewGridNo( SOLDIERTYPE *pSoldier ) void HandleBloodForNewGridNo( SOLDIERTYPE *pSoldier )
+1 -1
View File
@@ -282,7 +282,7 @@ void CycleThroughKnownEnemies( BOOLEAN backward = FALSE );
BOOLEAN CheckForEndOfCombatMode( BOOLEAN fIncrementTurnsNotSeen ); BOOLEAN CheckForEndOfCombatMode( BOOLEAN fIncrementTurnsNotSeen );
SOLDIERTYPE * FreeUpAttacker( ); SOLDIERTYPE * FreeUpAttacker( );
BOOLEAN PlayerTeamFull( ); BOOLEAN PlayerTeamFull( );
void SetActionToDoOnceMercsGetToLocation( UINT8 ubActionCode, INT8 bNumMercsWaiting, UINT32 uiData1, UINT32 uiData2, UINT32 uiData3 ); void SetActionToDoOnceMercsGetToLocation( UINT8 ubActionCode, UINT8 uiNumMercsWaiting, UINT32 uiData1, UINT32 uiData2, UINT32 uiData3 );
void ResetAllMercSpeeds( ); void ResetAllMercSpeeds( );
BOOLEAN HandleGotoNewGridNo( SOLDIERTYPE *pSoldier, BOOLEAN *pfKeepMoving, BOOLEAN fInitialMove, UINT16 usAnimState ); BOOLEAN HandleGotoNewGridNo( SOLDIERTYPE *pSoldier, BOOLEAN *pfKeepMoving, BOOLEAN fInitialMove, UINT16 usAnimState );
SOLDIERTYPE * ReduceAttackBusyCount( ); SOLDIERTYPE * ReduceAttackBusyCount( );
+3 -5
View File
@@ -1180,13 +1180,11 @@ BOOLEAN ExitShopKeeperInterface()
//if the laptop was just fixed //if the laptop was just fixed
if( gubQuest[ QUEST_FIX_LAPTOP ] == QUESTDONE && !( gJa25SaveStruct.uiJa25GeneralFlags & JA_GF__PLAYER_SAID_LAPTOP_FIXED_QUOTE ) ) if( gubQuest[ QUEST_FIX_LAPTOP ] == QUESTDONE && !( gJa25SaveStruct.uiJa25GeneralFlags & JA_GF__PLAYER_SAID_LAPTOP_FIXED_QUOTE ) )
{ {
INT8 bSoldierID=-1;
//Have a new merc say a quote //Have a new merc say a quote
bSoldierID = RandomSoldierIdFromNewMercsOnPlayerTeam(); INT16 bSoldierID = RandomSoldierIdFromNewMercsOnPlayerTeam();
if( bSoldierID != -1 ) if( bSoldierID > -1 )
{ {
TacticalCharacterDialogue( &Menptr[ bSoldierID ], QUOTE_JA2UB_LAPTOP_FIXED ); TacticalCharacterDialogue( &Menptr[bSoldierID], QUOTE_JA2UB_LAPTOP_FIXED );
} }
gJa25SaveStruct.uiJa25GeneralFlags |= JA_GF__PLAYER_SAID_LAPTOP_FIXED_QUOTE; gJa25SaveStruct.uiJa25GeneralFlags |= JA_GF__PLAYER_SAID_LAPTOP_FIXED_QUOTE;
-3
View File
@@ -51,15 +51,12 @@
#include "Soldier macros.h" #include "Soldier macros.h"
#endif #endif
extern INT8 gbNumMercsUntilWaitingOver;
extern UINT8 gubWaitingForAllMercsToExitCode; extern UINT8 gubWaitingForAllMercsToExitCode;
//forward declarations of common classes to eliminate includes //forward declarations of common classes to eliminate includes
class OBJECTTYPE; class OBJECTTYPE;
class SOLDIERTYPE; class SOLDIERTYPE;
#define NEXT_TILE_CHECK_DELAY 700 #define NEXT_TILE_CHECK_DELAY 700
#ifdef JA2BETAVERSION #ifdef JA2BETAVERSION
+6 -6
View File
@@ -2464,13 +2464,13 @@ void ManSeesMan(SOLDIERTYPE *pSoldier, SOLDIERTYPE *pOpponent, INT32 sOppGridNo,
else if ( pSoldier->bTeam == gbPlayerNum ) else if ( pSoldier->bTeam == gbPlayerNum )
{ {
#ifdef JA2UB #ifdef JA2UB
if( (pOpponent->ubProfile == MORRIS_UB ) && if ( (pOpponent->ubProfile == MORRIS_UB ) &&
( GetNumSoldierIdAndProfileIdOfTheNewMercsOnPlayerTeam( NULL, NULL ) != 0 ) && ( GetNumSoldierIdAndProfileIdOfTheNewMercsOnPlayerTeam( NULL, NULL ) > 0 ) &&
!( pSoldier->usQuoteSaidExtFlags & SOLDIER_QUOTE_SAID_EXT_MORRIS ) && !( pSoldier->usQuoteSaidExtFlags & SOLDIER_QUOTE_SAID_EXT_MORRIS ) &&
!( gMercProfiles[ MORRIS_UB ].ubMiscFlags2 & PROFILE_MISC_FLAG2_SAID_FIRSTSEEN_QUOTE ) ) !( gMercProfiles[ MORRIS_UB ].ubMiscFlags2 & PROFILE_MISC_FLAG2_SAID_FIRSTSEEN_QUOTE ) )
{ {
gfMorrisShouldSayHi = TRUE; gfMorrisShouldSayHi = TRUE;
} }
#else #else
if ( (pOpponent->ubProfile == MIKE) && ( pSoldier->ubWhatKindOfMercAmI == MERC_TYPE__AIM_MERC || pSoldier->ubWhatKindOfMercAmI == MERC_TYPE__MERC ) && !(pSoldier->usQuoteSaidExtFlags & SOLDIER_QUOTE_SAID_EXT_MIKE) ) if ( (pOpponent->ubProfile == MIKE) && ( pSoldier->ubWhatKindOfMercAmI == MERC_TYPE__AIM_MERC || pSoldier->ubWhatKindOfMercAmI == MERC_TYPE__MERC ) && !(pSoldier->usQuoteSaidExtFlags & SOLDIER_QUOTE_SAID_EXT_MIKE) )
{ {
+3 -9
View File
@@ -5483,7 +5483,6 @@ BOOLEAN IsFanGraphicInSectorAtThisGridNo( UINT32 sGridNo )
void HandleDestructionOfPowerGenFan() void HandleDestructionOfPowerGenFan()
{ {
UINT8 ubShadeLevel=0; UINT8 ubShadeLevel=0;
INT8 bID;
//if we have already destroyed the fan //if we have already destroyed the fan
if( gJa25SaveStruct.ubHowPlayerGotThroughFan == PG__PLAYER_BLEW_UP_FAN_TO_GET_THROUGH ) if( gJa25SaveStruct.ubHowPlayerGotThroughFan == PG__PLAYER_BLEW_UP_FAN_TO_GET_THROUGH )
@@ -5524,12 +5523,11 @@ void HandleDestructionOfPowerGenFan()
//Stop the fan sound //Stop the fan sound
HandleRemovingPowerGenFanSound(); HandleRemovingPowerGenFanSound();
// //
// Have a qualified merc say a quote // Have a qualified merc say a quote
// //
//Get a random qualified merc to say the quote //Get a random qualified merc to say the quote
bID = RandomSoldierIdFromNewMercsOnPlayerTeam(); INT16 bID = RandomSoldierIdFromNewMercsOnPlayerTeam();
if( bID != -1 ) if( bID != -1 )
{ {
DelayedMercQuote( Menptr[ bID ].ubProfile, QUOTE_ACCEPT_CONTRACT_RENEWAL, GetWorldTotalSeconds() + 2 ); DelayedMercQuote( Menptr[ bID ].ubProfile, QUOTE_ACCEPT_CONTRACT_RENEWAL, GetWorldTotalSeconds() + 2 );
@@ -5552,8 +5550,6 @@ void HandleExplosionsInTunnelSector( UINT32 sGridNo )
void HandleSeeingFortifiedDoor( UINT32 sGridNo ) void HandleSeeingFortifiedDoor( UINT32 sGridNo )
{ {
INT32 sID=0;
//if this isnt the First level of the complex K15-1 //if this isnt the First level of the complex K15-1
if( !( gWorldSectorX == gGameUBOptions.SectorDoorInTunnelX && gWorldSectorY == gGameUBOptions.SectorDoorInTunnelY && gbWorldSectorZ == gGameUBOptions.SectorDoorInTunnelZ ) ) if( !( gWorldSectorX == gGameUBOptions.SectorDoorInTunnelX && gWorldSectorY == gGameUBOptions.SectorDoorInTunnelY && gbWorldSectorZ == gGameUBOptions.SectorDoorInTunnelZ ) )
{ {
@@ -5572,7 +5568,7 @@ void HandleSeeingFortifiedDoor( UINT32 sGridNo )
gJa25SaveStruct.uiJa25GeneralFlags |= JA_GF__PLAYER_HAS_SEEN_FORTIFIED_DOOR; gJa25SaveStruct.uiJa25GeneralFlags |= JA_GF__PLAYER_HAS_SEEN_FORTIFIED_DOOR;
//find out whos is the one walking across the trap //find out whos is the one walking across the trap
sID = WhoIsThere2( sGridNo, 0 ); INT16 sID = WhoIsThere2( sGridNo, 0 );
if( sID != NOBODY && IsSoldierQualifiedMerc( &Menptr[ sID ] ) ) if( sID != NOBODY && IsSoldierQualifiedMerc( &Menptr[ sID ] ) )
{ {
} }
@@ -5591,8 +5587,6 @@ void HandleSeeingFortifiedDoor( UINT32 sGridNo )
void HandleSwitchToOpenFortifiedDoor( UINT32 sGridNo ) void HandleSwitchToOpenFortifiedDoor( UINT32 sGridNo )
{ {
INT8 bID;
//if the door is already opened //if the door is already opened
if( gJa25SaveStruct.ubStatusOfFortifiedDoor == FD__OPEN ) if( gJa25SaveStruct.ubStatusOfFortifiedDoor == FD__OPEN )
{ {
@@ -5602,7 +5596,7 @@ void HandleSwitchToOpenFortifiedDoor( UINT32 sGridNo )
//remeber that the switch to open the forified door on level 1, has been pulled //remeber that the switch to open the forified door on level 1, has been pulled
gJa25SaveStruct.ubStatusOfFortifiedDoor = FD__OPEN; gJa25SaveStruct.ubStatusOfFortifiedDoor = FD__OPEN;
bID = RandomSoldierIdFromNewMercsOnPlayerTeam(); INT16 bID = RandomSoldierIdFromNewMercsOnPlayerTeam();
if( bID != -1 ) if( bID != -1 )
{ {