Change UINT8 to UINT16 for soldierInitLists & hostiles in sector

This commit is contained in:
Asdow
2024-11-10 01:19:05 +02:00
parent 5cf0ef4bde
commit 508310be3e
15 changed files with 236 additions and 224 deletions
+14 -14
View File
@@ -163,13 +163,13 @@ typedef struct AUTORESOLVE_STRUCT
UINT8 ubEnemyLeadership; UINT8 ubEnemyLeadership;
UINT8 ubPlayerLeadership; UINT8 ubPlayerLeadership;
UINT8 ubMercs, ubCivs, ubEnemies; UINT16 ubMercs, ubCivs, ubEnemies;
UINT8 ubAdmins, ubTroops, ubElites, ubTanks, ubJeeps, ubRobots; UINT16 ubAdmins, ubTroops, ubElites, ubTanks, ubJeeps, ubRobots;
UINT8 ubYMCreatures, ubYFCreatures, ubAMCreatures, ubAFCreatures; UINT16 ubYMCreatures, ubYFCreatures, ubAMCreatures, ubAFCreatures;
UINT8 ubBloodcats; UINT16 ubBloodcats;
UINT8 ubZombies; UINT16 ubZombies;
UINT8 ubBandits; UINT16 ubBandits;
UINT8 ubAliveMercs, ubAliveCivs, ubAliveEnemies; UINT16 ubAliveMercs, ubAliveCivs, ubAliveEnemies;
UINT8 ubMercCols, ubMercRows; UINT8 ubMercCols, ubMercRows;
UINT8 ubEnemyCols, ubEnemyRows; UINT8 ubEnemyCols, ubEnemyRows;
UINT8 ubCivCols, ubCivRows; UINT8 ubCivCols, ubCivRows;
@@ -410,10 +410,10 @@ void EliminateAllEnemies( UINT8 ubSectorX, UINT8 ubSectorY )
GROUP *pGroup, *pDeleteGroup; GROUP *pGroup, *pDeleteGroup;
SECTORINFO *pSector; SECTORINFO *pSector;
INT32 i; INT32 i;
UINT8 ubNumEnemies[ NUM_ENEMY_RANKS ]; UINT16 ubNumEnemies[NUM_ENEMY_RANKS]{};
UINT8 ubNumTanks = 0; UINT16 ubNumTanks = 0;
UINT8 ubNumJeeps = 0; UINT16 ubNumJeeps = 0;
UINT8 ubNumRobots = 0; UINT16 ubNumRobots = 0;
UINT8 ubRankIndex; UINT8 ubRankIndex;
//Clear any possible battle locator //Clear any possible battle locator
@@ -3067,7 +3067,7 @@ void CalculateAutoResolveInfo()
&gpAR->ubAMCreatures, &gpAR->ubAFCreatures ); &gpAR->ubAMCreatures, &gpAR->ubAFCreatures );
} }
gpAR->ubEnemies = (UINT8)min( gpAR->ubYMCreatures + gpAR->ubYFCreatures + gpAR->ubAMCreatures + gpAR->ubAFCreatures, MAX_AR_TEAM_SIZE ); gpAR->ubEnemies = min( gpAR->ubYMCreatures + gpAR->ubYFCreatures + gpAR->ubAMCreatures + gpAR->ubAFCreatures, MAX_AR_TEAM_SIZE );
} }
else if ( GetEnemyEncounterCode() == BLOODCAT_ATTACK_CODE || else if ( GetEnemyEncounterCode() == BLOODCAT_ATTACK_CODE ||
GetEnemyEncounterCode() == ZOMBIE_ATTACK_CODE || GetEnemyEncounterCode() == ZOMBIE_ATTACK_CODE ||
@@ -3087,7 +3087,7 @@ void CalculateAutoResolveInfo()
gpAR->ubBandits = gubNumCreaturesAttackingTown; gpAR->ubBandits = gubNumCreaturesAttackingTown;
} }
gpAR->ubEnemies = (UINT8)min( gubNumCreaturesAttackingTown, MAX_AR_TEAM_SIZE ); gpAR->ubEnemies = min( gubNumCreaturesAttackingTown, MAX_AR_TEAM_SIZE );
} }
else else
{ {
@@ -3096,7 +3096,7 @@ void CalculateAutoResolveInfo()
GetNumberOfEnemiesInFiveSectors( gpAR->ubSectorX, gpAR->ubSectorY, GetNumberOfEnemiesInFiveSectors( gpAR->ubSectorX, gpAR->ubSectorY,
&gpAR->ubAdmins, &gpAR->ubTroops, &gpAR->ubElites, &gpAR->ubRobots, &gpAR->ubTanks, &gpAR->ubJeeps ); &gpAR->ubAdmins, &gpAR->ubTroops, &gpAR->ubElites, &gpAR->ubRobots, &gpAR->ubTanks, &gpAR->ubJeeps );
gpAR->ubEnemies = (UINT8)min( gpAR->ubAdmins + gpAR->ubTroops + gpAR->ubElites + gpAR->ubTanks + gpAR->ubJeeps + gpAR->ubRobots, MAX_AR_TEAM_SIZE ); gpAR->ubEnemies = min( gpAR->ubAdmins + gpAR->ubTroops + gpAR->ubElites + gpAR->ubTanks + gpAR->ubJeeps + gpAR->ubRobots, MAX_AR_TEAM_SIZE );
} }
gfTransferTacticalOppositionToAutoResolve = FALSE; gfTransferTacticalOppositionToAutoResolve = FALSE;
+26 -26
View File
@@ -487,18 +487,18 @@ typedef struct SECTORINFO
//This value determines how quickly it is investigated by the enemy. //This value determines how quickly it is investigated by the enemy.
UINT8 ubGarrisonID; //IF the sector has an ID for this (non 255), then the queen values this sector and it UINT8 ubGarrisonID; //IF the sector has an ID for this (non 255), then the queen values this sector and it
//indexes the garrison group. //indexes the garrison group.
INT8 ubPendingReinforcements; //when the enemy owns this sector, this value will keep track of HIGH priority reinforcements -- not regular. INT8 ubPendingReinforcements; //when the enemy owns this sector, this value will keep track of HIGH priority reinforcements -- not regular.
BOOLEAN fMilitiaTrainingPaid; BOOLEAN fMilitiaTrainingPaid;
UINT8 ubMilitiaTrainingPercentDone; UINT8 ubMilitiaTrainingPercentDone;
UINT8 ubMilitiaTrainingHundredths; UINT8 ubMilitiaTrainingHundredths;
//enemy military presence //enemy military presence
BOOLEAN fPlayer[ 4 ]; //whether the player THINKS the sector is unde his control or not. array is for sublevels BOOLEAN fPlayer[ 4 ]; //whether the player THINKS the sector is unde his control or not. array is for sublevels
//enemy only info //enemy only info
UINT8 ubNumTroops; //the actual number of troops here. UINT16 ubNumTroops; //the actual number of troops here.
UINT8 ubNumElites; //the actual number of elites here. UINT16 ubNumElites; //the actual number of elites here.
UINT8 ubNumAdmins; //the actual number of admins here. UINT16 ubNumAdmins; //the actual number of admins here.
UINT8 ubNumCreatures; //only set when immediately before ground attack made! UINT16 ubNumCreatures; //only set when immediately before ground attack made!
UINT8 ubTroopsInBattle, ubElitesInBattle, ubAdminsInBattle, ubCreaturesInBattle; UINT16 ubTroopsInBattle, ubElitesInBattle, ubAdminsInBattle, ubCreaturesInBattle;
INT8 bLastKnownEnemies; // -1 means never been there, no idea, otherwise it's what we'd observed most recently INT8 bLastKnownEnemies; // -1 means never been there, no idea, otherwise it's what we'd observed most recently
// while this is being maintained (partially, surely buggy), nothing uses it anymore. ARM // while this is being maintained (partially, surely buggy), nothing uses it anymore. ARM
@@ -511,8 +511,8 @@ typedef struct SECTORINFO
//throught the sector without entering it. //throught the sector without entering it.
INT8 bNameId; INT8 bNameId;
INT8 bUSUSED; INT8 bUSUSED;
INT8 bBloodCats; INT16 bBloodCats;
INT8 bBloodCatPlacements; INT16 bBloodCatPlacements;
INT8 UNUSEDbSAMCondition; INT8 UNUSEDbSAMCondition;
UINT8 ubTravelRating; //Represents how travelled a sector is. Typically, the higher the travel rating, UINT8 ubTravelRating; //Represents how travelled a sector is. Typically, the higher the travel rating,
@@ -551,8 +551,8 @@ typedef struct SECTORINFO
UINT32 uiTimeAIArtillerywasOrdered; // Flugente: updated every time an artillery strike is ordered from the militia UINT32 uiTimeAIArtillerywasOrdered; // Flugente: updated every time an artillery strike is ordered from the militia
UINT8 ubNumTanks; UINT16 ubNumTanks;
UINT8 ubTanksInBattle; UINT16 ubTanksInBattle;
// Flugente: disease // Flugente: disease
UINT16 usNumCorpses; // number of corpses in this sector UINT16 usNumCorpses; // number of corpses in this sector
@@ -565,8 +565,8 @@ typedef struct SECTORINFO
FLOAT dFortification_UnappliedProgress; // progress done via assignment work. As we cannot update unloaded sectors, update happens once sector is loaded FLOAT dFortification_UnappliedProgress; // progress done via assignment work. As we cannot update unloaded sectors, update happens once sector is loaded
// Flugente: enemy jeeps // Flugente: enemy jeeps
UINT8 ubNumJeeps; UINT16 ubNumJeeps;
UINT8 ubJeepsInBattle; UINT16 ubJeepsInBattle;
UINT8 usWorkers; UINT8 usWorkers;
UINT8 ubWorkerTrainingHundredths; UINT8 ubWorkerTrainingHundredths;
@@ -583,8 +583,8 @@ typedef struct SECTORINFO
UINT8 ubNumElites_Turncoat; UINT8 ubNumElites_Turncoat;
UINT8 usExplorationProgress; UINT8 usExplorationProgress;
UINT8 ubNumRobots; UINT16 ubNumRobots;
UINT8 ubRobotsInBattle; UINT16 ubRobotsInBattle;
INT8 bPadding[ 6 ]; INT8 bPadding[ 6 ];
}SECTORINFO; }SECTORINFO;
@@ -600,18 +600,18 @@ typedef struct UNDERGROUND_SECTORINFO
{ {
UINT32 uiFlags; UINT32 uiFlags;
UINT8 ubSectorX, ubSectorY, ubSectorZ; UINT8 ubSectorX, ubSectorY, ubSectorZ;
UINT8 ubNumElites, ubNumTroops, ubNumAdmins, ubNumCreatures; UINT16 ubNumElites, ubNumTroops, ubNumAdmins, ubNumCreatures;
UINT8 fVisited; UINT8 fVisited;
INT8 ubTravelRating; //Represents how travelled a sector is. Typically, the higher the travel rating, INT8 ubTravelRating; //Represents how travelled a sector is. Typically, the higher the travel rating,
//the more people go near it. A travel rating of 0 means there are never people //the more people go near it. A travel rating of 0 means there are never people
//around. This value is used for determining how often items would "vanish" from //around. This value is used for determining how often items would "vanish" from
//a sector. //a sector.
UINT32 uiTimeCurrentSectorWasLastLoaded; //Specifies the last time the player was in the sector UINT32 uiTimeCurrentSectorWasLastLoaded; //Specifies the last time the player was in the sector
struct UNDERGROUND_SECTORINFO *next; struct UNDERGROUND_SECTORINFO *next;
UINT8 ubNumBloodcats; // Bloodcat population UINT16 ubNumBloodcats; // Bloodcat population
UINT8 ubCreatureHabitat; //determines how creatures live in this sector (see creature spreading.c) UINT8 ubCreatureHabitat; //determines how creatures live in this sector (see creature spreading.c)
UINT8 ubElitesInBattle, ubTroopsInBattle, ubAdminsInBattle, ubCreaturesInBattle; UINT16 ubElitesInBattle, ubTroopsInBattle, ubAdminsInBattle, ubCreaturesInBattle;
// adding these (should not change struct layout due to padding) // adding these (should not change struct layout due to padding)
UINT8 ubMusicMode, ubUnsed; UINT8 ubMusicMode, ubUnsed;
@@ -622,20 +622,20 @@ typedef struct UNDERGROUND_SECTORINFO
BOOLEAN fCampaignSector; BOOLEAN fCampaignSector;
#endif #endif
UINT8 uiNumberOfPrisonersOfWar[PRISONER_MAX]; UINT16 uiNumberOfPrisonersOfWar[PRISONER_MAX];
UINT8 ubNumTanks; UINT16 ubNumTanks;
UINT8 ubTanksInBattle; UINT16 ubTanksInBattle;
// Flugente: fortification // Flugente: fortification
FLOAT dFortification_MaxPossible; // the amount of fortification that can still be done in this sector, given the current layout plans. Is updated every time we unload a sector FLOAT dFortification_MaxPossible; // the amount of fortification that can still be done in this sector, given the current layout plans. Is updated every time we unload a sector
FLOAT dFortification_UnappliedProgress; // progress done via assignment work. As we cannot update unloaded sectors, update happens once sector is loaded FLOAT dFortification_UnappliedProgress; // progress done via assignment work. As we cannot update unloaded sectors, update happens once sector is loaded
UINT8 ubNumJeeps; UINT16 ubNumJeeps;
UINT8 ubJeepsInBattle; UINT16 ubJeepsInBattle;
UINT8 usExplorationProgress; UINT8 usExplorationProgress;
UINT8 ubNumRobots; UINT16 ubNumRobots;
UINT8 ubRobotsInBattle; UINT16 ubRobotsInBattle;
INT8 bPadding[10]; INT8 bPadding[10];
//no padding left! //no padding left!
@@ -656,4 +656,4 @@ enum CreateMusic
CM_ALWAYS, CM_ALWAYS,
}; };
#endif #endif
+18 -18
View File
@@ -139,11 +139,11 @@ INT32 giDestroyedLairID = 0;
//prebattle interface, autoresolve, etc. //prebattle interface, autoresolve, etc.
INT16 gsCreatureInsertionCode = 0; INT16 gsCreatureInsertionCode = 0;
INT32 gsCreatureInsertionGridNo = 0; INT32 gsCreatureInsertionGridNo = 0;
UINT8 gubNumCreaturesAttackingTown = 0; UINT16 gubNumCreaturesAttackingTown = 0;
UINT8 gubYoungMalesAttackingTown = 0; UINT16 gubYoungMalesAttackingTown = 0;
UINT8 gubYoungFemalesAttackingTown = 0; UINT16 gubYoungFemalesAttackingTown = 0;
UINT8 gubAdultMalesAttackingTown = 0; UINT16 gubAdultMalesAttackingTown = 0;
UINT8 gubAdultFemalesAttackingTown = 0; UINT16 gubAdultFemalesAttackingTown = 0;
UINT8 gubCreatureBattleCode = CREATURE_BATTLE_CODE_NONE; UINT8 gubCreatureBattleCode = CREATURE_BATTLE_CODE_NONE;
UINT8 gubSectorIDOfCreatureAttack = 0; UINT8 gubSectorIDOfCreatureAttack = 0;
@@ -1634,8 +1634,8 @@ BOOLEAN MineClearOfMonsters( UINT8 ubMineIndex )
return TRUE; return TRUE;
} }
void DetermineCreatureTownComposition( UINT8 ubNumCreatures, UINT8 *pubNumYoungMales, UINT8 *pubNumYoungFemales, void DetermineCreatureTownComposition( UINT16 ubNumCreatures, UINT16 *pubNumYoungMales, UINT16 *pubNumYoungFemales,
UINT8 *pubNumAdultMales, UINT8 *pubNumAdultFemales ) UINT16 *pubNumAdultMales, UINT16 *pubNumAdultFemales )
{ {
INT32 i, iRandom; INT32 i, iRandom;
UINT8 ubYoungMalePercentage = 10; UINT8 ubYoungMalePercentage = 10;
@@ -1667,8 +1667,8 @@ void DetermineCreatureTownComposition( UINT8 ubNumCreatures, UINT8 *pubNumYoungM
} }
} }
void DetermineCreatureTownCompositionBasedOnTacticalInformation( UINT8 *pubNumCreatures, UINT8 *pubNumYoungMales, UINT8 *pubNumYoungFemales, void DetermineCreatureTownCompositionBasedOnTacticalInformation( UINT16 *pubNumCreatures, UINT16 *pubNumYoungMales, UINT16 *pubNumYoungFemales,
UINT8 *pubNumAdultMales, UINT8 *pubNumAdultFemales ) UINT16 *pubNumAdultMales, UINT16 *pubNumAdultFemales )
{ {
SOLDIERTYPE *pSoldier; SOLDIERTYPE *pSoldier;
@@ -1704,7 +1704,7 @@ void DetermineCreatureTownCompositionBasedOnTacticalInformation( UINT8 *pubNumCr
} }
} }
void DetermineOtherCreatureTownCompositionBasedOnTacticalInformation( UINT8* pubNumCreatures, UINT8* pubNumBloodcats, UINT8* pubNumZombies, UINT8* pubNumBandits ) void DetermineOtherCreatureTownCompositionBasedOnTacticalInformation( UINT16* pubNumCreatures, UINT16* pubNumBloodcats, UINT16* pubNumZombies, UINT16* pubNumBandits )
{ {
SOLDIERTYPE *pSoldier; SOLDIERTYPE *pSoldier;
@@ -1750,13 +1750,13 @@ BOOLEAN PrepareCreaturesForBattle()
UINT8 ubAdultMalePercentage; UINT8 ubAdultMalePercentage;
UINT8 ubAdultFemalePercentage; UINT8 ubAdultFemalePercentage;
UINT8 ubCreatureHabitat; UINT8 ubCreatureHabitat;
UINT8 ubNumLarvae = 0; UINT16 ubNumLarvae = 0;
UINT8 ubNumInfants = 0; UINT16 ubNumInfants = 0;
UINT8 ubNumYoungMales = 0; UINT16 ubNumYoungMales = 0;
UINT8 ubNumYoungFemales = 0; UINT16 ubNumYoungFemales = 0;
UINT8 ubNumAdultMales = 0; UINT16 ubNumAdultMales = 0;
UINT8 ubNumAdultFemales = 0; UINT16 ubNumAdultFemales = 0;
UINT8 ubNumCreatures; UINT16 ubNumCreatures;
if( !gubCreatureBattleCode ) if( !gubCreatureBattleCode )
{ {
@@ -2422,4 +2422,4 @@ void ResetCreatureAttackVariables()
gubAdultFemalesAttackingTown = 0; gubAdultFemalesAttackingTown = 0;
gubCreatureBattleCode = CREATURE_BATTLE_CODE_NONE; gubCreatureBattleCode = CREATURE_BATTLE_CODE_NONE;
gubSectorIDOfCreatureAttack = 0; gubSectorIDOfCreatureAttack = 0;
} }
+13 -13
View File
@@ -30,11 +30,11 @@ BOOLEAN GetWarpOutOfMineCodes( INT16 *psSectorX, INT16 *psSectorY, INT8 *pbSecto
extern INT16 gsCreatureInsertionCode; extern INT16 gsCreatureInsertionCode;
extern INT32 gsCreatureInsertionGridNo; extern INT32 gsCreatureInsertionGridNo;
extern UINT8 gubNumCreaturesAttackingTown; extern UINT16 gubNumCreaturesAttackingTown;
extern UINT8 gubYoungMalesAttackingTown; extern UINT16 gubYoungMalesAttackingTown;
extern UINT8 gubYoungFemalesAttackingTown; extern UINT16 gubYoungFemalesAttackingTown;
extern UINT8 gubAdultMalesAttackingTown; extern UINT16 gubAdultMalesAttackingTown;
extern UINT8 gubAdultFemalesAttackingTown; extern UINT16 gubAdultFemalesAttackingTown;
extern UINT8 gubSectorIDOfCreatureAttack; extern UINT8 gubSectorIDOfCreatureAttack;
enum{ enum{
CREATURE_BATTLE_CODE_NONE, CREATURE_BATTLE_CODE_NONE,
@@ -53,15 +53,15 @@ enum {
}; };
extern UINT8 guCreatureAttackType; extern UINT8 guCreatureAttackType;
void DetermineCreatureTownComposition( UINT8 ubNumCreatures, void DetermineCreatureTownComposition( UINT16 ubNumCreatures,
UINT8 *pubNumYoungMales, UINT8 *pubNumYoungFemales, UINT16 *pubNumYoungMales, UINT16 *pubNumYoungFemales,
UINT8 *pubNumAdultMales, UINT8 *pubNumAdultFemales ); UINT16 *pubNumAdultMales, UINT16 *pubNumAdultFemales );
void DetermineCreatureTownCompositionBasedOnTacticalInformation( UINT8 *pubNumCreatures, void DetermineCreatureTownCompositionBasedOnTacticalInformation( UINT16 *pubNumCreatures,
UINT8 *pubNumYoungMales, UINT8 *pubNumYoungFemales, UINT16 *pubNumYoungMales, UINT16 *pubNumYoungFemales,
UINT8 *pubNumAdultMales, UINT8 *pubNumAdultFemales ); UINT16 *pubNumAdultMales, UINT16 *pubNumAdultFemales );
void DetermineOtherCreatureTownCompositionBasedOnTacticalInformation( UINT8* pubNumCreatures, UINT8* pubNumBloodcats, UINT8* pubNumZombies, UINT8* pubNumBandits ); void DetermineOtherCreatureTownCompositionBasedOnTacticalInformation( UINT16* pubNumCreatures, UINT16* pubNumBloodcats, UINT16* pubNumZombies, UINT16* pubNumBandits );
BOOLEAN PlayerGroupIsInACreatureInfestedMine(); BOOLEAN PlayerGroupIsInACreatureInfestedMine();
@@ -114,4 +114,4 @@ extern CREATURECOMPOSITION gCreatureComposition[ MAX_NUMBER_OF_CREATURE_COMPOSIT
// Flugente: reset code for creature attacks // Flugente: reset code for creature attacks
void ResetCreatureAttackVariables(); void ResetCreatureAttackVariables();
#endif #endif
+2 -2
View File
@@ -220,7 +220,7 @@ static int l_iStringToUse(lua_State *L);
static int l_StopVideo(lua_State *L); static int l_StopVideo(lua_State *L);
static int l_StartVideo(lua_State *L); static int l_StartVideo(lua_State *L);
UNDERGROUND_SECTORINFO* NewUndergroundNode( UINT8 ubSectorX, UINT8 ubSectorY, UINT8 ubSectorZ ); extern UNDERGROUND_SECTORINFO* NewUndergroundNode( UINT8 ubSectorX, UINT8 ubSectorY, UINT8 ubSectorZ );
BOOLEAN LoadLuaGlobalFromLoadGameFile( HWFILE hFile ); BOOLEAN LoadLuaGlobalFromLoadGameFile( HWFILE hFile );
BOOLEAN SaveLuaGlobalToSaveGameFile( HWFILE hFile ); BOOLEAN SaveLuaGlobalToSaveGameFile( HWFILE hFile );
@@ -13574,7 +13574,7 @@ static int l_SetPhotoFactLaptopData( lua_State *L )
return 0; return 0;
} }
extern UINT8 NumHostilesInSector( INT16 sSectorX, INT16 sSectorY, INT16 sSectorZ ); extern UINT16 NumHostilesInSector( INT16 sSectorX, INT16 sSectorY, INT16 sSectorZ );
static int l_GetNumHostilesInSector( lua_State *L ) static int l_GetNumHostilesInSector( lua_State *L )
{ {
+1 -1
View File
@@ -543,7 +543,7 @@ BOOLEAN SetThisSectorAsEnemyControlled( INT16 sMapX, INT16 sMapY, INT8 bMapZ, BO
{ {
// Enemies can steal items left lying about, each one can carry out up to X kg (defined in RemoveRandomItemsInSector). // Enemies can steal items left lying about, each one can carry out up to X kg (defined in RemoveRandomItemsInSector).
// Don't care underground sectors here -- we are in overground code branch. // Don't care underground sectors here -- we are in overground code branch.
UINT8 ubNumAdmins, ubNumTroops, ubNumElites, ubNumRobots, ubNumTanks, ubNumJeeps; UINT16 ubNumAdmins, ubNumTroops, ubNumElites, ubNumRobots, ubNumTanks, ubNumJeeps;
GetNumberOfStationaryEnemiesInSector( sMapX, sMapY, &ubNumAdmins, &ubNumTroops, &ubNumElites, &ubNumRobots, &ubNumTanks, &ubNumJeeps ); GetNumberOfStationaryEnemiesInSector( sMapX, sMapY, &ubNumAdmins, &ubNumTroops, &ubNumElites, &ubNumRobots, &ubNumTanks, &ubNumJeeps );
RemoveRandomItemsInSector( sMapX, sMapY, bMapZ, (UINT32)ubNumAdmins + ubNumTroops + ubNumElites ); RemoveRandomItemsInSector( sMapX, sMapY, bMapZ, (UINT32)ubNumAdmins + ubNumTroops + ubNumElites );
} }
+40 -41
View File
@@ -141,9 +141,9 @@ void ValidateEnemiesHaveWeapons()
} }
//Counts enemies and crepitus, but not bloodcats. //Counts enemies and crepitus, but not bloodcats.
UINT8 NumHostilesInSector( INT16 sSectorX, INT16 sSectorY, INT16 sSectorZ ) UINT16 NumHostilesInSector( INT16 sSectorX, INT16 sSectorY, INT16 sSectorZ )
{ {
UINT8 ubNumHostiles = 0; UINT16 ubNumHostiles = 0;
AssertGE( sSectorX, MINIMUM_VALID_X_COORDINATE); AssertGE( sSectorX, MINIMUM_VALID_X_COORDINATE);
AssertLE( sSectorX, MAXIMUM_VALID_X_COORDINATE ); AssertLE( sSectorX, MAXIMUM_VALID_X_COORDINATE );
@@ -158,7 +158,7 @@ UINT8 NumHostilesInSector( INT16 sSectorX, INT16 sSectorY, INT16 sSectorZ )
pSector = FindUnderGroundSector( sSectorX, sSectorY, (UINT8)sSectorZ ); pSector = FindUnderGroundSector( sSectorX, sSectorY, (UINT8)sSectorZ );
if( pSector ) if( pSector )
{ {
ubNumHostiles = (UINT8)(pSector->ubNumAdmins + pSector->ubNumTroops + pSector->ubNumElites + pSector->ubNumCreatures + pSector->ubNumRobots + pSector->ubNumJeeps + pSector->ubNumTanks); ubNumHostiles = (pSector->ubNumAdmins + pSector->ubNumTroops + pSector->ubNumElites + pSector->ubNumCreatures + pSector->ubNumRobots + pSector->ubNumJeeps + pSector->ubNumTanks);
} }
} }
else else
@@ -168,7 +168,7 @@ UINT8 NumHostilesInSector( INT16 sSectorX, INT16 sSectorY, INT16 sSectorZ )
//Count stationary hostiles //Count stationary hostiles
pSector = &SectorInfo[ SECTOR( sSectorX, sSectorY ) ]; pSector = &SectorInfo[ SECTOR( sSectorX, sSectorY ) ];
ubNumHostiles = (UINT8)(pSector->ubNumAdmins + pSector->ubNumTroops + pSector->ubNumElites + pSector->ubNumCreatures + pSector->ubNumRobots + pSector->ubNumJeeps + pSector->ubNumTanks); ubNumHostiles = (pSector->ubNumAdmins + pSector->ubNumTroops + pSector->ubNumElites + pSector->ubNumCreatures + pSector->ubNumRobots + pSector->ubNumJeeps + pSector->ubNumTanks);
//Count mobile enemies //Count mobile enemies
pGroup = gpGroupList; pGroup = gpGroupList;
@@ -185,9 +185,9 @@ UINT8 NumHostilesInSector( INT16 sSectorX, INT16 sSectorY, INT16 sSectorZ )
return ubNumHostiles; return ubNumHostiles;
} }
UINT8 NumEnemiesInAnySector( INT16 sSectorX, INT16 sSectorY, INT16 sSectorZ ) UINT16 NumEnemiesInAnySector( INT16 sSectorX, INT16 sSectorY, INT16 sSectorZ )
{ {
UINT8 ubNumEnemies = 0; UINT16 ubNumEnemies = 0;
AssertGE( sSectorX, MINIMUM_VALID_X_COORDINATE); AssertGE( sSectorX, MINIMUM_VALID_X_COORDINATE);
AssertLE( sSectorX, MAXIMUM_VALID_X_COORDINATE ); AssertLE( sSectorX, MAXIMUM_VALID_X_COORDINATE );
@@ -202,7 +202,7 @@ UINT8 NumEnemiesInAnySector( INT16 sSectorX, INT16 sSectorY, INT16 sSectorZ )
pSector = FindUnderGroundSector( sSectorX, sSectorY, (UINT8)sSectorZ ); pSector = FindUnderGroundSector( sSectorX, sSectorY, (UINT8)sSectorZ );
if( pSector ) if( pSector )
{ {
ubNumEnemies = (UINT8)(pSector->ubNumAdmins + pSector->ubNumTroops + pSector->ubNumElites + pSector->ubNumRobots + pSector->ubNumJeeps + pSector->ubNumTanks); ubNumEnemies = (pSector->ubNumAdmins + pSector->ubNumTroops + pSector->ubNumElites + pSector->ubNumRobots + pSector->ubNumJeeps + pSector->ubNumTanks);
} }
} }
else else
@@ -212,7 +212,7 @@ UINT8 NumEnemiesInAnySector( INT16 sSectorX, INT16 sSectorY, INT16 sSectorZ )
//Count stationary enemies //Count stationary enemies
pSector = &SectorInfo[ SECTOR( sSectorX, sSectorY ) ]; pSector = &SectorInfo[ SECTOR( sSectorX, sSectorY ) ];
ubNumEnemies = (UINT8)(pSector->ubNumAdmins + pSector->ubNumTroops + pSector->ubNumElites + pSector->ubNumRobots + pSector->ubNumJeeps + pSector->ubNumTanks); ubNumEnemies = (pSector->ubNumAdmins + pSector->ubNumTroops + pSector->ubNumElites + pSector->ubNumRobots + pSector->ubNumJeeps + pSector->ubNumTanks);
//Count mobile enemies //Count mobile enemies
pGroup = gpGroupList; pGroup = gpGroupList;
@@ -230,11 +230,11 @@ UINT8 NumEnemiesInAnySector( INT16 sSectorX, INT16 sSectorY, INT16 sSectorZ )
} }
// returns how many members of a team are in a sector - not intended for OUR_TEAM! // returns how many members of a team are in a sector - not intended for OUR_TEAM!
UINT8 NumNonPlayerTeamMembersInSector( INT16 sSectorX, INT16 sSectorY, UINT8 ubTeam ) UINT16 NumNonPlayerTeamMembersInSector( INT16 sSectorX, INT16 sSectorY, UINT8 ubTeam )
{ {
SECTORINFO *pSector; SECTORINFO *pSector;
GROUP *pGroup; GROUP *pGroup;
UINT8 ubNumTroops; UINT16 ubNumTroops = 0;
// HEADROCK: This is a TEMPORARY fix to avoid the assertion error. Not sure this is the best solution, // HEADROCK: This is a TEMPORARY fix to avoid the assertion error. Not sure this is the best solution,
// probably isn't. But I need this bit to work. // probably isn't. But I need this bit to work.
@@ -255,14 +255,14 @@ UINT8 NumNonPlayerTeamMembersInSector( INT16 sSectorX, INT16 sSectorY, UINT8 ubT
if ( ubTeam == ENEMY_TEAM ) if ( ubTeam == ENEMY_TEAM )
{ {
ubNumTroops = (UINT8)(pSector->ubNumAdmins + pSector->ubNumTroops + pSector->ubNumElites + pSector->ubNumRobots + pSector->ubNumJeeps + pSector->ubNumTanks); ubNumTroops = (pSector->ubNumAdmins + pSector->ubNumTroops + pSector->ubNumElites + pSector->ubNumRobots + pSector->ubNumJeeps + pSector->ubNumTanks);
if ( is_networked ) if ( is_networked )
ubNumTroops += numenemyLAN((UINT8)sSectorX,(UINT8)sSectorY ); //hayden ubNumTroops += numenemyLAN((UINT8)sSectorX,(UINT8)sSectorY ); //hayden
} }
else if ( ubTeam == MILITIA_TEAM ) else if ( ubTeam == MILITIA_TEAM )
{ {
ubNumTroops = (UINT8)(pSector->ubNumberOfCivsAtLevel[0] + pSector->ubNumberOfCivsAtLevel[1] + pSector->ubNumberOfCivsAtLevel[2]); ubNumTroops = (pSector->ubNumberOfCivsAtLevel[0] + pSector->ubNumberOfCivsAtLevel[1] + pSector->ubNumberOfCivsAtLevel[2]);
} }
else if ( ubTeam == CREATURE_TEAM ) else if ( ubTeam == CREATURE_TEAM )
{ {
@@ -309,7 +309,7 @@ UINT16 NumEnemyArmedVehiclesInSector( INT16 sSectorX, INT16 sSectorY, UINT8 usTe
{ {
SECTORINFO *pSector; SECTORINFO *pSector;
GROUP *pGroup; GROUP *pGroup;
UINT16 ubNum; UINT16 ubNum = 0;
// HEADROCK: This is a TEMPORARY fix to avoid the assertion error. Not sure this is the best solution, // HEADROCK: This is a TEMPORARY fix to avoid the assertion error. Not sure this is the best solution,
// probably isn't. But I need this bit to work. // probably isn't. But I need this bit to work.
@@ -344,7 +344,7 @@ UINT16 NumEnemyArmedVehiclesInSector( INT16 sSectorX, INT16 sSectorY, UINT8 usTe
return ubNum; return ubNum;
} }
UINT8 NumStationaryEnemiesInSector( INT16 sSectorX, INT16 sSectorY ) UINT16 NumStationaryEnemiesInSector( INT16 sSectorX, INT16 sSectorY )
{ {
SECTORINFO *pSector; SECTORINFO *pSector;
@@ -368,14 +368,14 @@ UINT8 NumStationaryEnemiesInSector( INT16 sSectorX, INT16 sSectorY )
return( 0 ); return( 0 );
} }
return (UINT8)(pSector->ubNumAdmins + pSector->ubNumTroops + pSector->ubNumElites + pSector->ubNumTanks + pSector->ubNumJeeps + pSector->ubNumRobots); return (pSector->ubNumAdmins + pSector->ubNumTroops + pSector->ubNumElites + pSector->ubNumTanks + pSector->ubNumJeeps + pSector->ubNumRobots);
} }
UINT8 NumMobileEnemiesInSector( INT16 sSectorX, INT16 sSectorY ) UINT16 NumMobileEnemiesInSector( INT16 sSectorX, INT16 sSectorY )
{ {
GROUP *pGroup; GROUP *pGroup;
SECTORINFO *pSector; SECTORINFO *pSector;
UINT8 ubNumTroops; UINT16 ubNumTroops;
AssertGE( sSectorX, MINIMUM_VALID_X_COORDINATE); AssertGE( sSectorX, MINIMUM_VALID_X_COORDINATE);
AssertLE( sSectorX, MAXIMUM_VALID_X_COORDINATE ); AssertLE( sSectorX, MAXIMUM_VALID_X_COORDINATE );
AssertGE( sSectorY, MINIMUM_VALID_Y_COORDINATE); AssertGE( sSectorY, MINIMUM_VALID_Y_COORDINATE);
@@ -396,13 +396,13 @@ UINT8 NumMobileEnemiesInSector( INT16 sSectorX, INT16 sSectorY )
if( pSector->ubGarrisonID == ROADBLOCK ) if( pSector->ubGarrisonID == ROADBLOCK )
{ {
//consider these troops as mobile troops even though they are in a garrison //consider these troops as mobile troops even though they are in a garrison
ubNumTroops += (UINT8)(pSector->ubNumAdmins + pSector->ubNumTroops + pSector->ubNumElites + pSector->ubNumRobots + pSector->ubNumJeeps + pSector->ubNumTanks); ubNumTroops += (pSector->ubNumAdmins + pSector->ubNumTroops + pSector->ubNumElites + pSector->ubNumRobots + pSector->ubNumJeeps + pSector->ubNumTanks);
} }
return ubNumTroops; return ubNumTroops;
} }
void GetNumberOfMobileEnemiesInSector( INT16 sSectorX, INT16 sSectorY, UINT8 *pubNumAdmins, UINT8 *pubNumTroops, UINT8 *pubNumElites, UINT8 *pubNumRobots, UINT8 *pubNumTanks, UINT8 *pubNumJeeps ) void GetNumberOfMobileEnemiesInSector( INT16 sSectorX, INT16 sSectorY, UINT16 *pubNumAdmins, UINT16 *pubNumTroops, UINT16 *pubNumElites, UINT16 *pubNumRobots, UINT16 *pubNumTanks, UINT16 *pubNumJeeps )
{ {
GROUP *pGroup; GROUP *pGroup;
SECTORINFO *pSector; SECTORINFO *pSector;
@@ -441,7 +441,7 @@ void GetNumberOfMobileEnemiesInSector( INT16 sSectorX, INT16 sSectorY, UINT8 *pu
} }
} }
void GetNumberOfMobileEnemiesInSectorWithoutRoadBlock( INT16 sSectorX, INT16 sSectorY, UINT8 usTeam, UINT8 *pubNumAdmins, UINT8 *pubNumTroops, UINT8 *pubNumElites, UINT8 *pubNumRobots, UINT8 *pubNumTanks, UINT8 *pubNumJeeps ) void GetNumberOfMobileEnemiesInSectorWithoutRoadBlock( INT16 sSectorX, INT16 sSectorY, UINT16 usTeam, UINT16 *pubNumAdmins, UINT16 *pubNumTroops, UINT16 *pubNumElites, UINT16 *pubNumRobots, UINT16 *pubNumTanks, UINT16 *pubNumJeeps )
{ {
GROUP *pGroup; GROUP *pGroup;
AssertGE( sSectorX, MINIMUM_VALID_X_COORDINATE); AssertGE( sSectorX, MINIMUM_VALID_X_COORDINATE);
@@ -468,7 +468,7 @@ void GetNumberOfMobileEnemiesInSectorWithoutRoadBlock( INT16 sSectorX, INT16 sSe
} }
void GetNumberOfStationaryEnemiesInSector( INT16 sSectorX, INT16 sSectorY, UINT8 *pubNumAdmins, UINT8 *pubNumTroops, UINT8 *pubNumElites, UINT8 *pubNumRobots, UINT8 *pubNumTanks, UINT8 *pubNumJeeps ) void GetNumberOfStationaryEnemiesInSector( INT16 sSectorX, INT16 sSectorY, UINT16 *pubNumAdmins, UINT16 *pubNumTroops, UINT16 *pubNumElites, UINT16 *pubNumRobots, UINT16 *pubNumTanks, UINT16 *pubNumJeeps )
{ {
SECTORINFO *pSector; SECTORINFO *pSector;
AssertGE( sSectorX, MINIMUM_VALID_X_COORDINATE); AssertGE( sSectorX, MINIMUM_VALID_X_COORDINATE);
@@ -486,9 +486,9 @@ void GetNumberOfStationaryEnemiesInSector( INT16 sSectorX, INT16 sSectorY, UINT8
*pubNumJeeps = pSector->ubNumJeeps; *pubNumJeeps = pSector->ubNumJeeps;
} }
void GetNumberOfEnemiesInSector( INT16 sSectorX, INT16 sSectorY, UINT8 *pubNumAdmins, UINT8 *pubNumTroops, UINT8 *pubNumElites, UINT8 *pubNumRobots, UINT8 *pubNumTanks, UINT8 *pubNumJeeps ) void GetNumberOfEnemiesInSector( INT16 sSectorX, INT16 sSectorY, UINT16 *pubNumAdmins, UINT16 *pubNumTroops, UINT16 *pubNumElites, UINT16 *pubNumRobots, UINT16 *pubNumTanks, UINT16 *pubNumJeeps )
{ {
UINT8 ubNumAdmins, ubNumTroops, ubNumElites, ubNumRobots, ubNumTanks, ubNumJeeps; UINT16 ubNumAdmins, ubNumTroops, ubNumElites, ubNumRobots, ubNumTanks, ubNumJeeps;
GetNumberOfStationaryEnemiesInSector( sSectorX, sSectorY, pubNumAdmins, pubNumTroops, pubNumElites, pubNumRobots, pubNumTanks, pubNumJeeps ); GetNumberOfStationaryEnemiesInSector( sSectorX, sSectorY, pubNumAdmins, pubNumTroops, pubNumElites, pubNumRobots, pubNumTanks, pubNumJeeps );
@@ -576,9 +576,9 @@ void EndTacticalBattleForEnemy()
} }
} }
UINT8 NumFreeSlots( UINT8 ubTeam ) UINT16 NumFreeSlots( UINT8 ubTeam )
{ {
UINT8 ubNumFreeSlots = 0; UINT16 ubNumFreeSlots = 0;
//Count the number of free enemy slots. It is possible to have multiple groups exceed the maximum. //Count the number of free enemy slots. It is possible to have multiple groups exceed the maximum.
for ( INT32 i = gTacticalStatus.Team[ubTeam].bFirstID; i <= gTacticalStatus.Team[ubTeam].bLastID; ++i ) for ( INT32 i = gTacticalStatus.Team[ubTeam].bFirstID; i <= gTacticalStatus.Team[ubTeam].bLastID; ++i )
@@ -590,13 +590,12 @@ UINT8 NumFreeSlots( UINT8 ubTeam )
// the militia team size can be restricted by the ini // the militia team size can be restricted by the ini
if ( ubTeam == MILITIA_TEAM ) if ( ubTeam == MILITIA_TEAM )
{ {
ubNumFreeSlots = (UINT8)max( 0, (INT8)ubNumFreeSlots - (INT8)(gGameExternalOptions.ubGameMaximumNumberOfRebels - gGameExternalOptions.iMaxMilitiaPerSector) ); ubNumFreeSlots = (UINT16)max( 0, (INT16)ubNumFreeSlots - (INT16)(gGameExternalOptions.ubGameMaximumNumberOfRebels - gGameExternalOptions.iMaxMilitiaPerSector) );
} }
return ubNumFreeSlots; return ubNumFreeSlots;
} }
#pragma optimize("",off)
//Called when entering a sector so the campaign AI can automatically insert the //Called when entering a sector so the campaign AI can automatically insert the
//correct number of troops of each type based on the current number in the sector //correct number of troops of each type based on the current number in the sector
//in global focus (gWorldSectorX/Y) //in global focus (gWorldSectorX/Y)
@@ -1187,7 +1186,7 @@ BOOLEAN PrepareEnemyForUndergroundBattle()
Assert( FALSE ); Assert( FALSE );
return FALSE; return FALSE;
} }
#pragma optimize("",on)
//The queen AI layer must process the event by subtracting forces, etc. //The queen AI layer must process the event by subtracting forces, etc.
void ProcessQueenCmdImplicationsOfDeath( SOLDIERTYPE *pSoldier ) void ProcessQueenCmdImplicationsOfDeath( SOLDIERTYPE *pSoldier )
{ {
@@ -2176,12 +2175,12 @@ void NotifyPlayersOfNewEnemies()
} }
} }
void AddEnemiesToBattle( GROUP *pGroup, UINT8 ubStrategicInsertionCode, UINT8 ubNumAdmins, UINT8 ubNumTroops, UINT8 ubNumElites, UINT8 ubNumRobots, UINT8 ubNumTanks, UINT8 ubNumJeeps, BOOLEAN fMagicallyAppeared ) void AddEnemiesToBattle( GROUP *pGroup, UINT8 ubStrategicInsertionCode, UINT16 ubNumAdmins, UINT16 ubNumTroops, UINT16 ubNumElites, UINT16 ubNumRobots, UINT16 ubNumTanks, UINT16 ubNumJeeps, BOOLEAN fMagicallyAppeared )
{ {
SOLDIERTYPE *pSoldier; SOLDIERTYPE *pSoldier;
MAPEDGEPOINTINFO MapEdgepointInfo; MAPEDGEPOINTINFO MapEdgepointInfo;
UINT8 ubCurrSlot; UINT16 ubCurrSlot;
UINT8 ubTotalSoldiers; UINT16 ubTotalSoldiers;
UINT8 bDesiredDirection=0; UINT8 bDesiredDirection=0;
// while transport groups can't normally reinforce, this covers the case where a transport group enters a sector (via normal movement) // while transport groups can't normally reinforce, this covers the case where a transport group enters a sector (via normal movement)
@@ -2323,7 +2322,7 @@ void AddEnemiesToBattle( GROUP *pGroup, UINT8 ubStrategicInsertionCode, UINT8 ub
} }
UpdateMercInSector( pSoldier, gWorldSectorX, gWorldSectorY, 0 ); UpdateMercInSector( pSoldier, gWorldSectorX, gWorldSectorY, 0 );
} }
else if( ubNumTroops && (UINT8)Random( ubTotalSoldiers ) < (UINT8)(ubNumElites + ubNumTroops) ) else if( ubNumTroops && Random( ubTotalSoldiers ) < (ubNumElites + ubNumTroops) )
{ {
ubNumTroops--; ubNumTroops--;
ubTotalSoldiers--; ubTotalSoldiers--;
@@ -2346,7 +2345,7 @@ void AddEnemiesToBattle( GROUP *pGroup, UINT8 ubStrategicInsertionCode, UINT8 ub
} }
UpdateMercInSector( pSoldier, gWorldSectorX, gWorldSectorY, 0 ); UpdateMercInSector( pSoldier, gWorldSectorX, gWorldSectorY, 0 );
} }
else if( ubNumAdmins && (UINT8)Random( ubTotalSoldiers ) < (UINT8)(ubNumElites + ubNumTroops + ubNumAdmins) ) else if( ubNumAdmins && Random( ubTotalSoldiers ) < (ubNumElites + ubNumTroops + ubNumAdmins) )
{ {
ubNumAdmins--; ubNumAdmins--;
ubTotalSoldiers--; ubTotalSoldiers--;
@@ -2369,7 +2368,7 @@ void AddEnemiesToBattle( GROUP *pGroup, UINT8 ubStrategicInsertionCode, UINT8 ub
} }
UpdateMercInSector( pSoldier, gWorldSectorX, gWorldSectorY, 0 ); UpdateMercInSector( pSoldier, gWorldSectorX, gWorldSectorY, 0 );
} }
else if( ubNumRobots && (UINT8)Random( ubTotalSoldiers ) < (UINT8)(ubNumElites + ubNumTroops + ubNumAdmins + ubNumRobots) ) else if( ubNumRobots && Random( ubTotalSoldiers ) < (ubNumElites + ubNumTroops + ubNumAdmins + ubNumRobots) )
{ {
ubNumRobots--; ubNumRobots--;
ubTotalSoldiers--; ubTotalSoldiers--;
@@ -2392,7 +2391,7 @@ void AddEnemiesToBattle( GROUP *pGroup, UINT8 ubStrategicInsertionCode, UINT8 ub
} }
UpdateMercInSector( pSoldier, gWorldSectorX, gWorldSectorY, 0 ); UpdateMercInSector( pSoldier, gWorldSectorX, gWorldSectorY, 0 );
} }
else if( ubNumTanks && (UINT8)Random( ubTotalSoldiers ) < (UINT8)(ubNumElites + ubNumTroops + ubNumAdmins + ubNumRobots + ubNumTanks) && ubNumberOfVehicles < 9 ) else if( ubNumTanks && Random( ubTotalSoldiers ) < (ubNumElites + ubNumTroops + ubNumAdmins + ubNumRobots + ubNumTanks) && ubNumberOfVehicles < 9 )
{ {
ubNumTanks--; ubNumTanks--;
ubTotalSoldiers--; ubTotalSoldiers--;
@@ -2415,7 +2414,7 @@ void AddEnemiesToBattle( GROUP *pGroup, UINT8 ubStrategicInsertionCode, UINT8 ub
} }
UpdateMercInSector( pSoldier, gWorldSectorX, gWorldSectorY, 0 ); UpdateMercInSector( pSoldier, gWorldSectorX, gWorldSectorY, 0 );
} }
else if ( ubNumJeeps && (UINT8)Random( ubTotalSoldiers ) < (UINT8)(ubNumElites + ubNumTroops + ubNumAdmins + ubNumRobots + ubNumTanks + ubNumJeeps) && ubNumberOfVehicles < 9 ) else if ( ubNumJeeps && Random( ubTotalSoldiers ) < (ubNumElites + ubNumTroops + ubNumAdmins + ubNumRobots + ubNumTanks + ubNumJeeps) && ubNumberOfVehicles < 9 )
{ {
ubNumJeeps--; ubNumJeeps--;
ubTotalSoldiers--; ubTotalSoldiers--;
@@ -2463,12 +2462,12 @@ void AddEnemiesToBattle( GROUP *pGroup, UINT8 ubStrategicInsertionCode, UINT8 ub
#endif #endif
} }
void AddMilitiaToBattle( GROUP *pGroup, UINT8 ubStrategicInsertionCode, UINT8 ubNumGreens, UINT8 ubNumRegulars, UINT8 ubNumElites, BOOLEAN fMagicallyAppeared ) void AddMilitiaToBattle( GROUP *pGroup, UINT8 ubStrategicInsertionCode, UINT16 ubNumGreens, UINT16 ubNumRegulars, UINT16 ubNumElites, BOOLEAN fMagicallyAppeared )
{ {
SOLDIERTYPE *pSoldier; SOLDIERTYPE *pSoldier;
MAPEDGEPOINTINFO MapEdgepointInfo; MAPEDGEPOINTINFO MapEdgepointInfo;
UINT8 ubCurrSlot; UINT16 ubCurrSlot;
UINT8 ubTotalSoldiers; UINT16 ubTotalSoldiers;
UINT8 bDesiredDirection = 0; UINT8 bDesiredDirection = 0;
switch ( ubStrategicInsertionCode ) switch ( ubStrategicInsertionCode )
@@ -2558,7 +2557,7 @@ void AddMilitiaToBattle( GROUP *pGroup, UINT8 ubStrategicInsertionCode, UINT8 ub
} }
UpdateMercInSector( pSoldier, gWorldSectorX, gWorldSectorY, 0 ); UpdateMercInSector( pSoldier, gWorldSectorX, gWorldSectorY, 0 );
} }
else if ( ubNumRegulars && (UINT8)Random( ubTotalSoldiers ) < (UINT8)(ubNumElites + ubNumRegulars) ) else if ( ubNumRegulars && Random( ubTotalSoldiers ) < (ubNumElites + ubNumRegulars) )
{ {
ubNumRegulars--; ubNumRegulars--;
ubTotalSoldiers--; ubTotalSoldiers--;
@@ -2581,7 +2580,7 @@ void AddMilitiaToBattle( GROUP *pGroup, UINT8 ubStrategicInsertionCode, UINT8 ub
} }
UpdateMercInSector( pSoldier, gWorldSectorX, gWorldSectorY, 0 ); UpdateMercInSector( pSoldier, gWorldSectorX, gWorldSectorY, 0 );
} }
else if ( ubNumGreens && (UINT8)Random( ubTotalSoldiers ) < (UINT8)(ubNumElites + ubNumRegulars + ubNumGreens) ) else if ( ubNumGreens && Random( ubTotalSoldiers ) < (ubNumElites + ubNumRegulars + ubNumGreens) )
{ {
ubNumGreens--; ubNumGreens--;
ubTotalSoldiers--; ubTotalSoldiers--;
+12 -12
View File
@@ -12,26 +12,26 @@
extern BOOLEAN gfPendingNonPlayerTeam[PLAYER_PLAN]; extern BOOLEAN gfPendingNonPlayerTeam[PLAYER_PLAN];
UINT8 NumFreeSlots( UINT8 ubTeam ); UINT16 NumFreeSlots( UINT8 ubTeam );
//Counts enemies and crepitus, but not bloodcats. //Counts enemies and crepitus, but not bloodcats.
UINT8 NumHostilesInSector( INT16 sSectorX, INT16 sSectorY, INT16 sSectorZ ); UINT16 NumHostilesInSector( INT16 sSectorX, INT16 sSectorY, INT16 sSectorZ );
UINT8 NumEnemiesInAnySector( INT16 sSectorX, INT16 sSectorY, INT16 sSectorZ ); UINT16 NumEnemiesInAnySector( INT16 sSectorX, INT16 sSectorY, INT16 sSectorZ );
// returns how many members of a team are in a sector - not intended for OUR_TEAM! // returns how many members of a team are in a sector - not intended for OUR_TEAM!
UINT8 NumNonPlayerTeamMembersInSector( INT16 sSectorX, INT16 sSectorY, UINT8 ubTeam ); UINT16 NumNonPlayerTeamMembersInSector( INT16 sSectorX, INT16 sSectorY, UINT8 ubTeam );
// returns how many members of a team are in a sector - only intended for OUR_TEAM! POWs not included // returns how many members of a team are in a sector - only intended for OUR_TEAM! POWs not included
UINT16 NumPlayerTeamMembersInSector( INT16 sSectorX, INT16 sSectorY, INT8 sSectorZ ); UINT16 NumPlayerTeamMembersInSector( INT16 sSectorX, INT16 sSectorY, INT8 sSectorZ );
UINT16 NumEnemyArmedVehiclesInSector( INT16 sSectorX, INT16 sSectorY, UINT8 usTeam ); UINT16 NumEnemyArmedVehiclesInSector( INT16 sSectorX, INT16 sSectorY, UINT8 usTeam );
UINT8 NumStationaryEnemiesInSector( INT16 sSectorX, INT16 sSectorY ); UINT16 NumStationaryEnemiesInSector( INT16 sSectorX, INT16 sSectorY );
UINT8 NumMobileEnemiesInSector( INT16 sSectorX, INT16 sSectorY ); UINT16 NumMobileEnemiesInSector( INT16 sSectorX, INT16 sSectorY );
void GetNumberOfMobileEnemiesInSector( INT16 sSectorX, INT16 sSectorY, UINT8 *pubNumAdmins, UINT8 *pubNumTroops, UINT8 *pubNumElites, UINT8 *pubNumRobots, UINT8 *pubNumTanks, UINT8 *pubNumJeeps ); void GetNumberOfMobileEnemiesInSector( INT16 sSectorX, INT16 sSectorY, UINT16 *pubNumAdmins, UINT16 *pubNumTroops, UINT16 *pubNumElites, UINT16 *pubNumRobots, UINT16 *pubNumTanks, UINT16 *pubNumJeeps );
void GetNumberOfMobileEnemiesInSectorWithoutRoadBlock( INT16 sSectorX, INT16 sSectorY, UINT8 usTeam, UINT8 *pubNumAdmins, UINT8 *pubNumTroops, UINT8 *pubNumElites, UINT8 *pubNumRobots, UINT8 *pubNumTanks, UINT8 *pubNumJeeps ); void GetNumberOfMobileEnemiesInSectorWithoutRoadBlock( INT16 sSectorX, INT16 sSectorY, UINT16 usTeam, UINT16 *pubNumAdmins, UINT16 *pubNumTroops, UINT16 *pubNumElites, UINT16 *pubNumRobots, UINT16 *pubNumTanks, UINT16 *pubNumJeeps );
void GetNumberOfStationaryEnemiesInSector( INT16 sSectorX, INT16 sSectorY, UINT8 *pubNumAdmins, UINT8 *pubNumTroops, UINT8 *pubNumElites, UINT8 *pubNumRobots, UINT8 *pubNumTanks, UINT8 *pubNumJeeps ); void GetNumberOfStationaryEnemiesInSector( INT16 sSectorX, INT16 sSectorY, UINT16 *pubNumAdmins, UINT16 *pubNumTroops, UINT16 *pubNumElites, UINT16 *pubNumRobots, UINT16 *pubNumTanks, UINT16 *pubNumJeeps );
void GetNumberOfEnemiesInSector( INT16 sSectorX, INT16 sSectorY, UINT8 *pubNumAdmins, UINT8 *pubNumTroops, UINT8 *pubNumElites, UINT8 *pubNumRobots, UINT8 *pubNumTanks, UINT8 *pubNumJeeps ); void GetNumberOfEnemiesInSector( INT16 sSectorX, INT16 sSectorY, UINT16 *pubNumAdmins, UINT16 *pubNumTroops, UINT16 *pubNumElites, UINT16 *pubNumRobots, UINT16 *pubNumTanks, UINT16 *pubNumJeeps );
//Called when entering a sector so the campaign AI can automatically insert the //Called when entering a sector so the campaign AI can automatically insert the
//correct number of troops of each type based on the current number in the sector //correct number of troops of each type based on the current number in the sector
@@ -39,8 +39,8 @@ void GetNumberOfEnemiesInSector( INT16 sSectorX, INT16 sSectorY, UINT8 *pubNumAd
BOOLEAN PrepareEnemyForSectorBattle(); BOOLEAN PrepareEnemyForSectorBattle();
BOOLEAN PrepareEnemyForUndergroundBattle(); BOOLEAN PrepareEnemyForUndergroundBattle();
void AddEnemiesToBattle( GROUP *pGroup, UINT8 ubStrategicInsertionCode, UINT8 ubNumAdmins, UINT8 ubNumTroops, UINT8 ubNumElites, UINT8 ubNumRobots, UINT8 ubNumTanks, UINT8 abNumJeeps, BOOLEAN fMagicallyAppeared ); void AddEnemiesToBattle( GROUP *pGroup, UINT8 ubStrategicInsertionCode, UINT16 ubNumAdmins, UINT16 ubNumTroops, UINT16 ubNumElites, UINT16 ubNumRobots, UINT16 ubNumTanks, UINT16 abNumJeeps, BOOLEAN fMagicallyAppeared );
void AddMilitiaToBattle( GROUP *pGroup, UINT8 ubStrategicInsertionCode, UINT8 ubNumGreens, UINT8 ubNumRegulars, UINT8 ubNumElites, BOOLEAN fMagicallyAppeared ); void AddMilitiaToBattle( GROUP *pGroup, UINT8 ubStrategicInsertionCode, UINT16 ubNumGreens, UINT16 ubNumRegulars, UINT16 ubNumElites, BOOLEAN fMagicallyAppeared );
void AddPossiblePendingEnemiesToBattle(); void AddPossiblePendingEnemiesToBattle();
void EndTacticalBattleForEnemy(); void EndTacticalBattleForEnemy();
+4 -4
View File
@@ -29,9 +29,9 @@
UINT8 gubReinforcementMinEnemyStaticGroupSize = 12; UINT8 gubReinforcementMinEnemyStaticGroupSize = 12;
UINT32 guiMilitiaReinforceTurn = 0, guiMilitiaArrived = 0;//dnl ch68 090913 UINT32 guiMilitiaReinforceTurn = 0, guiMilitiaArrived = 0;//dnl ch68 090913
void GetNumberOfEnemiesInFiveSectors( INT16 sSectorX, INT16 sSectorY, UINT8 *pubNumAdmins, UINT8 *pubNumTroops, UINT8 *pubNumElites, UINT8 *pubNumRobots, UINT8 *pubNumTanks, UINT8 *pubNumJeeps ) void GetNumberOfEnemiesInFiveSectors( INT16 sSectorX, INT16 sSectorY, UINT16 *pubNumAdmins, UINT16 *pubNumTroops, UINT16 *pubNumElites, UINT16 *pubNumRobots, UINT16 *pubNumTanks, UINT16 *pubNumJeeps )
{ {
UINT8 ubNumAdmins, ubNumTroops, ubNumElites, ubNumRobots, ubNumTanks, ubNumJeeps; UINT16 ubNumAdmins, ubNumTroops, ubNumElites, ubNumRobots, ubNumTanks, ubNumJeeps;
UINT16 pusMoveDir[4][3]; //first column in this matrix is number of sector, except for 4th row UINT16 pusMoveDir[4][3]; //first column in this matrix is number of sector, except for 4th row
UINT8 ubDirNumber, ubIndex; UINT8 ubDirNumber, ubIndex;
@@ -156,9 +156,9 @@ void ActivateTurncoatsForAutoResolve( INT16 sSectorX, INT16 sSectorY )
} }
} }
UINT8 NumEnemiesInFiveSectors( INT16 sMapX, INT16 sMapY ) UINT16 NumEnemiesInFiveSectors( INT16 sMapX, INT16 sMapY )
{ {
UINT8 ubNumAdmins, ubNumTroops, ubNumElites, ubNumRobots, ubNumTanks, ubNumJeeps; UINT16 ubNumAdmins, ubNumTroops, ubNumElites, ubNumRobots, ubNumTanks, ubNumJeeps;
GetNumberOfEnemiesInFiveSectors( sMapX, sMapY, &ubNumAdmins, &ubNumTroops, &ubNumElites, &ubNumRobots, &ubNumTanks, &ubNumJeeps ); GetNumberOfEnemiesInFiveSectors( sMapX, sMapY, &ubNumAdmins, &ubNumTroops, &ubNumElites, &ubNumRobots, &ubNumTanks, &ubNumJeeps );
+3 -3
View File
@@ -2,16 +2,16 @@
#define __REINFORCEMENT_H__ #define __REINFORCEMENT_H__
//For Autoresolve (mostly) //For Autoresolve (mostly)
void GetNumberOfEnemiesInFiveSectors( INT16 sSectorX, INT16 sSectorY, UINT8 *pubNumAdmins, UINT8 *pubNumTroops, UINT8 *pubNumElites, UINT8 *pubNumRobots, UINT8 *pubNumTanks, UINT8 *pubNumJeeps ); void GetNumberOfEnemiesInFiveSectors( INT16 sSectorX, INT16 sSectorY, UINT16 *pubNumAdmins, UINT16 *pubNumTroops, UINT16 *pubNumElites, UINT16 *pubNumRobots, UINT16 *pubNumTanks, UINT16 *pubNumJeeps );
void ActivateTurncoatsForAutoResolve( INT16 sSectorX, INT16 sSectorY ); void ActivateTurncoatsForAutoResolve( INT16 sSectorX, INT16 sSectorY );
BOOLEAN IsGroupInARightSectorToReinforce( GROUP *pGroup, INT16 sSectorX, INT16 sSectorY ); BOOLEAN IsGroupInARightSectorToReinforce( GROUP *pGroup, INT16 sSectorX, INT16 sSectorY );
UINT8 GetAdjacentSectors( UINT8 pSectors[4], INT16 sSectorX, INT16 sSectorY ); UINT8 GetAdjacentSectors( UINT8 pSectors[4], INT16 sSectorX, INT16 sSectorY );
UINT16 CountAllMilitiaInFiveSectors(INT16 sMapX, INT16 sMapY); UINT16 CountAllMilitiaInFiveSectors(INT16 sMapX, INT16 sMapY);
UINT8 NumEnemiesInFiveSectors( INT16 sMapX, INT16 sMapY ); UINT16 NumEnemiesInFiveSectors( INT16 sMapX, INT16 sMapY );
//For Tactical //For Tactical
UINT8 DoReinforcementAsPendingNonPlayer( INT16 sMapX, INT16 sMapY, UINT8 usTeam ); UINT8 DoReinforcementAsPendingNonPlayer( INT16 sMapX, INT16 sMapY, UINT8 usTeam );
void AddPossiblePendingMilitiaToBattle(); void AddPossiblePendingMilitiaToBattle();
GROUP* GetNonPlayerGroupInSectorForReinforcement( INT16 sMapX, INT16 sMapY, UINT8 usTeam ); GROUP* GetNonPlayerGroupInSectorForReinforcement( INT16 sMapX, INT16 sMapY, UINT8 usTeam );
#endif #endif
+16 -1
View File
@@ -19,7 +19,7 @@ extern "C" {
#include "connect.h" #include "connect.h"
// externals // externals
UNDERGROUND_SECTORINFO* NewUndergroundNode( UINT8 ubSectorX, UINT8 ubSectorY, UINT8 ubSectorZ ); extern UNDERGROUND_SECTORINFO* NewUndergroundNode( UINT8 ubSectorX, UINT8 ubSectorY, UINT8 ubSectorZ );
extern BOOLEAN gfGettingNameFromSaveLoadScreen; extern BOOLEAN gfGettingNameFromSaveLoadScreen;
// helper functions // helper functions
@@ -49,6 +49,21 @@ bool LuaTable::getValue<UINT8>(const char * index, UINT8& value)
return false; return false;
} }
template <>
bool LuaTable::getValue<UINT16>(const char* index, UINT16& value)
{
int dummy;
bool b = getValue(index, dummy);
if (b)
{
value = static_cast<UINT16>(dummy);
return true;
}
return false;
}
// Calls into Lua script to let build underground sector list. // Calls into Lua script to let build underground sector list.
BOOLEAN LuaUnderground::InitializeSectorList() BOOLEAN LuaUnderground::InitializeSectorList()
{ {
+6 -6
View File
@@ -39,7 +39,7 @@ int gCivPreservedTempFileVersion[256];
BOOLEAN AddPlacementToWorld( SOLDIERINITNODE *pNode, GROUP *pGroup = NULL ); BOOLEAN AddPlacementToWorld( SOLDIERINITNODE *pNode, GROUP *pGroup = NULL );
BOOLEAN CountNumberOfElitesRegularsAdminsAndCreaturesFromEnemySoldiersTempFile( UINT8 *pubNumRobots, UINT8 *pubNumElites, UINT8 *pubNumRegulars, UINT8 *pubNumAdmins, UINT8 *pubNumCreatures, UINT8 *pubNumTanks, UINT8 *pubNumJeeps ); BOOLEAN CountNumberOfElitesRegularsAdminsAndCreaturesFromEnemySoldiersTempFile( UINT16 *pubNumRobots, UINT16 *pubNumElites, UINT16 *pubNumRegulars, UINT16 *pubNumAdmins, UINT16 *pubNumCreatures, UINT16 *pubNumTanks, UINT16 *pubNumJeeps );
BOOLEAN gfRestoringEnemySoldiersFromTempFile = FALSE; BOOLEAN gfRestoringEnemySoldiersFromTempFile = FALSE;
BOOLEAN gfRestoringCiviliansFromTempFile = FALSE; BOOLEAN gfRestoringCiviliansFromTempFile = FALSE;
@@ -100,8 +100,8 @@ BOOLEAN LoadEnemySoldiersFromTempFile()
#endif #endif
INT8 bSectorZ; INT8 bSectorZ;
UINT8 ubSectorID; UINT8 ubSectorID;
UINT8 ubNumRobots = 0, ubNumElites = 0, ubNumTroops = 0, ubNumAdmins = 0, ubNumCreatures = 0, ubNumTanks = 0, ubNumJeeps = 0; UINT16 ubNumRobots = 0, ubNumElites = 0, ubNumTroops = 0, ubNumAdmins = 0, ubNumCreatures = 0, ubNumTanks = 0, ubNumJeeps = 0;
UINT8 ubStrategicRobots, ubStrategicElites, ubStrategicTroops, ubStrategicAdmins, ubStrategicCreatures, ubStrategicTanks, ubStrategicJeeps; UINT16 ubStrategicRobots, ubStrategicElites, ubStrategicTroops, ubStrategicAdmins, ubStrategicCreatures, ubStrategicTanks, ubStrategicJeeps;
gfRestoringEnemySoldiersFromTempFile = TRUE; gfRestoringEnemySoldiersFromTempFile = TRUE;
@@ -695,8 +695,8 @@ BOOLEAN NewWayOfLoadingEnemySoldiersFromTempFile()
#endif #endif
INT8 bSectorZ; INT8 bSectorZ;
UINT8 ubSectorID; UINT8 ubSectorID;
UINT8 ubNumRobots = 0, ubNumElites = 0, ubNumTroops = 0, ubNumAdmins = 0, ubNumCreatures = 0, ubNumTanks = 0, ubNumJeeps = 0; UINT16 ubNumRobots = 0, ubNumElites = 0, ubNumTroops = 0, ubNumAdmins = 0, ubNumCreatures = 0, ubNumTanks = 0, ubNumJeeps = 0;
UINT8 ubStrategicRobots = 0, ubStrategicElites, ubStrategicTroops, ubStrategicAdmins, ubStrategicCreatures, ubStrategicTanks, ubStrategicJeeps; UINT16 ubStrategicRobots = 0, ubStrategicElites, ubStrategicTroops, ubStrategicAdmins, ubStrategicCreatures, ubStrategicTanks, ubStrategicJeeps;
gfRestoringEnemySoldiersFromTempFile = TRUE; gfRestoringEnemySoldiersFromTempFile = TRUE;
@@ -1638,7 +1638,7 @@ BOOLEAN NewWayOfSavingEnemyAndCivliansToTempFile( INT16 sSectorX, INT16 sSectorY
BOOLEAN CountNumberOfElitesRegularsAdminsAndCreaturesFromEnemySoldiersTempFile( UINT8 *pubNumRobots, UINT8 *pubNumElites, UINT8 *pubNumRegulars, UINT8 *pubNumAdmins, UINT8 *pubNumCreatures, UINT8 *pubNumTanks, UINT8 *pubNumJeeps ) BOOLEAN CountNumberOfElitesRegularsAdminsAndCreaturesFromEnemySoldiersTempFile( UINT16 *pubNumRobots, UINT16 *pubNumElites, UINT16 *pubNumRegulars, UINT16 *pubNumAdmins, UINT16 *pubNumCreatures, UINT16 *pubNumTanks, UINT16 *pubNumJeeps )
{ {
// SOLDIERINITNODE *curr; // SOLDIERINITNODE *curr;
SOLDIERCREATE_STRUCT tempDetailedPlacement; SOLDIERCREATE_STRUCT tempDetailedPlacement;
+1 -1
View File
@@ -22475,7 +22475,7 @@ void SOLDIERTYPE::EVENT_SoldierBeginAttachCan( INT32 sGridNo, UINT8 ubDirection
} }
extern UINT8 NumEnemiesInAnySector( INT16 sSectorX, INT16 sSectorY, INT16 sSectorZ ); extern UINT16 NumEnemiesInAnySector( INT16 sSectorX, INT16 sSectorY, INT16 sSectorZ );
void SOLDIERTYPE::EVENT_SoldierBuildStructure( INT32 sGridNo, UINT8 ubDirection ) void SOLDIERTYPE::EVENT_SoldierBuildStructure( INT32 sGridNo, UINT8 ubDirection )
{ {
+71 -73
View File
@@ -318,8 +318,8 @@ BOOLEAN LoadSoldiersFromMap(INT8** hBuffer, FLOAT dMajorMapVersion, UINT8 ubMino
AssertMsg(0, "Failed to allocate memory for new basic placement in LoadSoldiersFromMap."); AssertMsg(0, "Failed to allocate memory for new basic placement in LoadSoldiersFromMap.");
return(FALSE); return(FALSE);
} }
Assert(cnt < 256); Assert(cnt < MAX_INDIVIDUALS);
pNode->ubNodeID = (UINT8)cnt; pNode->ubNodeID = cnt;
if(tempBasicPlacement.fDetailedPlacement) if(tempBasicPlacement.fDetailedPlacement)
{ {
// Add the static detailed placement information in the same newly created node as the basic placement. Read static detailed placement from file. // Add the static detailed placement information in the same newly created node as the basic placement. Read static detailed placement from file.
@@ -369,7 +369,7 @@ BOOLEAN SaveSoldiersToMap(HWFILE hFile, FLOAT dMajorMapVersion, UINT8 ubMinorMap
{ {
if(!curr) if(!curr)
return(FALSE); return(FALSE);
curr->ubNodeID = (UINT8)i; curr->ubNodeID = i;
curr->pBasicPlacement->Save(hFile, dMajorMapVersion, ubMinorMapVersion); curr->pBasicPlacement->Save(hFile, dMajorMapVersion, ubMinorMapVersion);
if(curr->pBasicPlacement->fDetailedPlacement) if(curr->pBasicPlacement->fDetailedPlacement)
{ {
@@ -577,7 +577,6 @@ void SortSoldierInitList()
} }
extern FLOAT gAmbushRadiusModifier; extern FLOAT gAmbushRadiusModifier;
#pragma optimize("",off)
BOOLEAN AddPlacementToWorld( SOLDIERINITNODE *curr, GROUP *pGroup = NULL ) BOOLEAN AddPlacementToWorld( SOLDIERINITNODE *curr, GROUP *pGroup = NULL )
{ {
UINT8 ubProfile; UINT8 ubProfile;
@@ -855,7 +854,7 @@ BOOLEAN AddPlacementToWorld( SOLDIERINITNODE *curr, GROUP *pGroup = NULL )
if(is_server) ScreenMsg( FONT_YELLOW, MSG_MPSYSTEM, L"report this MP error (AddPlacementToWorld-FAIL!)"); if(is_server) ScreenMsg( FONT_YELLOW, MSG_MPSYSTEM, L"report this MP error (AddPlacementToWorld-FAIL!)");
return FALSE; return FALSE;
} }
#pragma optimize("",on)
void AddPlacementToWorldByProfileID( UINT8 ubProfile ) void AddPlacementToWorldByProfileID( UINT8 ubProfile )
{ {
SOLDIERINITNODE * curr; SOLDIERINITNODE * curr;
@@ -874,12 +873,12 @@ void AddPlacementToWorldByProfileID( UINT8 ubProfile )
} }
} }
UINT8 AddSoldierInitListTeamToWorld( INT8 bTeam, UINT8 ubMaxNum ) UINT16 AddSoldierInitListTeamToWorld( INT8 bTeam, UINT16 ubMaxNum )
{ {
UINT8 ubNumAdded = 0; UINT16 ubNumAdded = 0;
SOLDIERINITNODE *mark; SOLDIERINITNODE *mark;
UINT8 ubSlotsToFill; UINT16 ubSlotsToFill;
UINT8 ubSlotsAvailable; UINT16 ubSlotsAvailable;
SOLDIERINITNODE *curr; SOLDIERINITNODE *curr;
DebugMsg(TOPIC_JA2,DBG_LEVEL_3,String("AddSoldierInitListTeamToWorld")); DebugMsg(TOPIC_JA2,DBG_LEVEL_3,String("AddSoldierInitListTeamToWorld"));
@@ -1046,22 +1045,22 @@ UINT8 AddSoldierInitListTeamToWorld( INT8 bTeam, UINT8 ubMaxNum )
return ubNumAdded; return ubNumAdded;
} }
#pragma optimize("",off)
void AddSoldierInitListEnemyDefenceSoldiers( UINT8 ubTotalAdmin, UINT8 ubTotalTroops, UINT8 ubTotalElite, UINT8 ubTotalRobots, UINT8 ubTotalTanks, UINT8 ubTotalJeeps ) void AddSoldierInitListEnemyDefenceSoldiers( UINT16 ubTotalAdmin, UINT16 ubTotalTroops, UINT16 ubTotalElite, UINT16 ubTotalRobots, UINT16 ubTotalTanks, UINT16 ubTotalJeeps )
{ {
SOLDIERINITNODE *mark; SOLDIERINITNODE *mark;
SOLDIERINITNODE *curr; SOLDIERINITNODE *curr;
INT32 iRandom; INT32 iRandom;
UINT8 ubMaxNum; UINT16 ubMaxNum;
UINT8 ubRobotPDSlots = 0, ubRobotDSlots = 0, ubRobotPSlots = 0, ubRobotBSlots = 0; UINT16 ubRobotPDSlots = 0, ubRobotDSlots = 0, ubRobotPSlots = 0, ubRobotBSlots = 0;
UINT8 ubElitePDSlots = 0, ubEliteDSlots = 0, ubElitePSlots = 0, ubEliteBSlots = 0; UINT16 ubElitePDSlots = 0, ubEliteDSlots = 0, ubElitePSlots = 0, ubEliteBSlots = 0;
UINT8 ubTroopPDSlots = 0, ubTroopDSlots = 0, ubTroopPSlots = 0, ubTroopBSlots = 0; UINT16 ubTroopPDSlots = 0, ubTroopDSlots = 0, ubTroopPSlots = 0, ubTroopBSlots = 0;
UINT8 ubAdminPDSlots = 0, ubAdminDSlots = 0, ubAdminPSlots = 0, ubAdminBSlots = 0; UINT16 ubAdminPDSlots = 0, ubAdminDSlots = 0, ubAdminPSlots = 0, ubAdminBSlots = 0;
UINT8 ubTankPDSlots = 0, ubTankDSlots = 0, ubTankPSlots = 0, ubTankBSlots = 0; UINT16 ubTankPDSlots = 0, ubTankDSlots = 0, ubTankPSlots = 0, ubTankBSlots = 0;
UINT8 ubJeepPDSlots = 0, ubJeepDSlots = 0, ubJeepPSlots = 0, ubJeepBSlots = 0; UINT16 ubJeepPDSlots = 0, ubJeepDSlots = 0, ubJeepPSlots = 0, ubJeepBSlots = 0;
UINT8 ubFreeSlots; UINT16 ubFreeSlots;
UINT8 *pCurrSlots=NULL; UINT16 *pCurrSlots=NULL;
UINT8 *pCurrTotal=NULL; UINT16 *pCurrTotal=NULL;
UINT8 ubCurrClass; UINT8 ubCurrClass;
DebugMsg(TOPIC_JA2,DBG_LEVEL_3,String("AddSoldierInitListEnemyDefenceSoldiers")); DebugMsg(TOPIC_JA2,DBG_LEVEL_3,String("AddSoldierInitListEnemyDefenceSoldiers"));
@@ -1601,25 +1600,25 @@ void AddSoldierInitListEnemyDefenceSoldiers( UINT8 ubTotalAdmin, UINT8 ubTotalTr
curr = curr->next; curr = curr->next;
} }
} }
#pragma optimize("",on)
//If we are adding militia to our map, then we do a few things differently. //If we are adding militia to our map, then we do a few things differently.
//First of all, they exist exclusively to the enemy troops, so if the militia exists in the //First of all, they exist exclusively to the enemy troops, so if the militia exists in the
//sector, then they get to use the enemy placements. However, we remove any orders from //sector, then they get to use the enemy placements. However, we remove any orders from
//placements containing RNDPTPATROL or POINTPATROL orders, as well as remove any detailed //placements containing RNDPTPATROL or POINTPATROL orders, as well as remove any detailed
//placement information. //placement information.
void AddSoldierInitListMilitia( UINT8 ubNumGreen, UINT8 ubNumRegs, UINT8 ubNumElites ) void AddSoldierInitListMilitia( UINT16 ubNumGreen, UINT16 ubNumRegs, UINT16 ubNumElites )
{ {
SOLDIERINITNODE *mark; SOLDIERINITNODE *mark;
SOLDIERINITNODE *curr; SOLDIERINITNODE *curr;
INT32 iRandom; INT32 iRandom;
UINT8 ubMaxNum; UINT16 ubMaxNum;
BOOLEAN fDoPlacement; BOOLEAN fDoPlacement;
UINT8 ubEliteSlots = 0; UINT16 ubEliteSlots = 0;
UINT8 ubRegSlots = 0; UINT16 ubRegSlots = 0;
UINT8 ubGreenSlots = 0; UINT16 ubGreenSlots = 0;
UINT8 ubFreeSlots; UINT16 ubFreeSlots;
UINT8 *pCurrSlots=NULL; UINT16 *pCurrSlots=NULL;
UINT8 *pCurrTotal=NULL; UINT16 *pCurrTotal=NULL;
DebugMsg(TOPIC_JA2,DBG_LEVEL_3,String("AddSoldierInitListMilitia")); DebugMsg(TOPIC_JA2,DBG_LEVEL_3,String("AddSoldierInitListMilitia"));
@@ -1955,22 +1954,22 @@ void AddSoldierInitListMilitia( UINT8 ubNumGreen, UINT8 ubNumRegs, UINT8 ubNumEl
} }
} }
void AddSoldierInitListCreatures( BOOLEAN fQueen, UINT8 ubNumLarvae, UINT8 ubNumInfants, void AddSoldierInitListCreatures( BOOLEAN fQueen, UINT16 ubNumLarvae, UINT16 ubNumInfants,
UINT8 ubNumYoungMales, UINT8 ubNumYoungFemales, UINT8 ubNumAdultMales, UINT16 ubNumYoungMales, UINT16 ubNumYoungFemales, UINT16 ubNumAdultMales,
UINT8 ubNumAdultFemales ) UINT16 ubNumAdultFemales )
{ {
SOLDIERINITNODE *curr; SOLDIERINITNODE *curr;
INT32 iRandom; INT32 iRandom;
UINT8 ubFreeSlots; UINT16 ubFreeSlots;
BOOLEAN fDoPlacement; BOOLEAN fDoPlacement;
UINT8 ubNumCreatures; UINT16 ubNumCreatures;
DebugMsg(TOPIC_JA2,DBG_LEVEL_3,String("AddSoldierInitListCreatures")); DebugMsg(TOPIC_JA2,DBG_LEVEL_3,String("AddSoldierInitListCreatures"));
SortSoldierInitList(); SortSoldierInitList();
//Okay, if we have a queen, place her first. She MUST have a special placement, else //Okay, if we have a queen, place her first. She MUST have a special placement, else
//we can't use anything. //we can't use anything.
ubNumCreatures = (UINT8)(ubNumLarvae + ubNumInfants + ubNumYoungMales + ubNumYoungFemales + ubNumAdultMales + ubNumAdultFemales); ubNumCreatures = (ubNumLarvae + ubNumInfants + ubNumYoungMales + ubNumYoungFemales + ubNumAdultMales + ubNumAdultFemales);
if( fQueen ) if( fQueen )
{ {
curr = gSoldierInitHead; curr = gSoldierInitHead;
@@ -2292,10 +2291,9 @@ void UseEditorAlternateList()
//if the map was loaded again! //if the map was loaded again!
void EvaluateDeathEffectsToSoldierInitList( SOLDIERTYPE *pSoldier ) void EvaluateDeathEffectsToSoldierInitList( SOLDIERTYPE *pSoldier )
{ {
SOLDIERINITNODE *curr; UINT16 ubNodeID = 0;
UINT8 ubNodeID; SOLDIERINITNODE* curr = gSoldierInitHead;
curr = gSoldierInitHead;
ubNodeID = 0;
if( pSoldier->bTeam == MILITIA_TEAM ) if( pSoldier->bTeam == MILITIA_TEAM )
return; return;
while( curr ) while( curr )
@@ -2319,7 +2317,7 @@ void EvaluateDeathEffectsToSoldierInitList( SOLDIERTYPE *pSoldier )
} }
} }
void RemoveDetailedPlacementInfo( UINT8 ubNodeID ) void RemoveDetailedPlacementInfo( UINT16 ubNodeID )
{ {
SOLDIERINITNODE *curr; SOLDIERINITNODE *curr;
curr = gSoldierInitHead; curr = gSoldierInitHead;
@@ -2345,7 +2343,7 @@ BOOLEAN SaveSoldierInitListLinks( HWFILE hfile )
{ {
SOLDIERINITNODE *curr; SOLDIERINITNODE *curr;
UINT32 uiNumBytesWritten; UINT32 uiNumBytesWritten;
UINT8 ubSlots = 0; UINT16 ubSlots = 0;
//count the number of soldier init nodes... //count the number of soldier init nodes...
curr = gSoldierInitHead; curr = gSoldierInitHead;
@@ -2355,8 +2353,8 @@ BOOLEAN SaveSoldierInitListLinks( HWFILE hfile )
curr = curr->next; curr = curr->next;
} }
//...and save it. //...and save it.
FileWrite( hfile, &ubSlots, 1, &uiNumBytesWritten ); FileWrite( hfile, &ubSlots, 2, &uiNumBytesWritten );
if( uiNumBytesWritten != 1 ) if( uiNumBytesWritten != 2 )
{ {
return FALSE; return FALSE;
} }
@@ -2368,8 +2366,8 @@ BOOLEAN SaveSoldierInitListLinks( HWFILE hfile )
{ {
curr->ubSoldierID = 0; curr->ubSoldierID = 0;
} }
FileWrite( hfile, &curr->ubNodeID, 1, &uiNumBytesWritten ); FileWrite( hfile, &curr->ubNodeID, 2, &uiNumBytesWritten );
if( uiNumBytesWritten != 1 ) if( uiNumBytesWritten != 2 )
{ {
return FALSE; return FALSE;
} }
@@ -2387,23 +2385,23 @@ BOOLEAN LoadSoldierInitListLinks( HWFILE hfile )
{ {
UINT32 uiNumBytesRead; UINT32 uiNumBytesRead;
SOLDIERINITNODE *curr; SOLDIERINITNODE *curr;
UINT8 ubSlots, ubNodeID; UINT16 ubSlots;
UINT16 ubSoldierID; UINT16 ubSoldierID, ubNodeID;
FileRead( hfile, &ubSlots, 1, &uiNumBytesRead ); FileRead( hfile, &ubSlots, 2, &uiNumBytesRead );
if( uiNumBytesRead != 1 ) if( uiNumBytesRead != 2 )
{ {
return FALSE; return FALSE;
} }
while( ubSlots-- ) while( ubSlots-- )
{ {
FileRead( hfile, &ubNodeID, 1, &uiNumBytesRead ); FileRead( hfile, &ubNodeID, 2, &uiNumBytesRead );
if( uiNumBytesRead != 1 ) if( uiNumBytesRead != 2 )
{ {
return FALSE; return FALSE;
} }
FileRead( hfile, &ubSoldierID, 1, &uiNumBytesRead ); FileRead( hfile, &ubSoldierID, 2, &uiNumBytesRead );
if( uiNumBytesRead != 1 ) if( uiNumBytesRead != 2 )
{ {
return FALSE; return FALSE;
} }
@@ -2799,18 +2797,18 @@ BOOLEAN NewWayOfLoadingEnemySoldierInitListLinks( HWFILE hfile )
{ {
UINT32 uiNumBytesRead; UINT32 uiNumBytesRead;
SOLDIERINITNODE *curr; SOLDIERINITNODE *curr;
UINT8 ubSlots, ubNodeID; UINT16 ubSlots;
UINT16 ubSoldierID; UINT16 ubSoldierID, ubNodeID;
FileRead( hfile, &ubSlots, 1, &uiNumBytesRead ); FileRead( hfile, &ubSlots, 2, &uiNumBytesRead );
if( uiNumBytesRead != 1 ) if( uiNumBytesRead != 2 )
{ {
return FALSE; return FALSE;
} }
while( ubSlots-- ) while( ubSlots-- )
{ {
FileRead( hfile, &ubNodeID, 1, &uiNumBytesRead ); FileRead( hfile, &ubNodeID, 2, &uiNumBytesRead );
if( uiNumBytesRead != 1 ) if( uiNumBytesRead != 2 )
{ {
return FALSE; return FALSE;
} }
@@ -2846,18 +2844,18 @@ BOOLEAN NewWayOfLoadingCivilianInitListLinks( HWFILE hfile )
{ {
UINT32 uiNumBytesRead; UINT32 uiNumBytesRead;
SOLDIERINITNODE *curr; SOLDIERINITNODE *curr;
UINT8 ubSlots, ubNodeID; UINT16 ubSlots;
UINT16 ubSoldierID; UINT16 ubSoldierID, ubNodeID;
FileRead( hfile, &ubSlots, 1, &uiNumBytesRead ); FileRead( hfile, &ubSlots, 2, &uiNumBytesRead );
if( uiNumBytesRead != 1 ) if( uiNumBytesRead != 2 )
{ {
return FALSE; return FALSE;
} }
while( ubSlots-- ) while( ubSlots-- )
{ {
FileRead( hfile, &ubNodeID, 1, &uiNumBytesRead ); FileRead( hfile, &ubNodeID, 2, &uiNumBytesRead );
if( uiNumBytesRead != 1 ) if( uiNumBytesRead != 2 )
{ {
return FALSE; return FALSE;
} }
@@ -2893,18 +2891,18 @@ BOOLEAN LookAtButDontProcessEnemySoldierInitListLinks( HWFILE hfile )
{ {
UINT32 uiNumBytesRead; UINT32 uiNumBytesRead;
SOLDIERINITNODE *curr; SOLDIERINITNODE *curr;
UINT8 ubSlots, ubNodeID; UINT16 ubSlots;
UINT16 ubSoldierID; UINT16 ubSoldierID, ubNodeID;
FileRead( hfile, &ubSlots, 1, &uiNumBytesRead ); FileRead( hfile, &ubSlots, 2, &uiNumBytesRead );
if( uiNumBytesRead != 1 ) if( uiNumBytesRead != 2 )
{ {
return FALSE; return FALSE;
} }
while( ubSlots-- ) while( ubSlots-- )
{ {
FileRead( hfile, &ubNodeID, 1, &uiNumBytesRead ); FileRead( hfile, &ubNodeID, 2, &uiNumBytesRead );
if( uiNumBytesRead != 1 ) if( uiNumBytesRead != 2 )
{ {
return FALSE; return FALSE;
} }
@@ -3329,4 +3327,4 @@ void SectorAddDownedPilot( INT16 sMapX, INT16 sMapY, INT16 sMapZ )
// remove the flag. We can only find the pilot the first time we visit this sector after the heli was shut down // remove the flag. We can only find the pilot the first time we visit this sector after the heli was shut down
pSector->usSectorInfoFlag &= ~SECTORINFO_ENEMYHELI_SHOTDOWN; pSector->usSectorInfoFlag &= ~SECTORINFO_ENEMYHELI_SHOTDOWN;
} }
} }
+9 -9
View File
@@ -6,7 +6,7 @@
typedef struct SOLDIERINITNODE typedef struct SOLDIERINITNODE
{ {
UINT8 ubNodeID; UINT16 ubNodeID;
UINT16 ubSoldierID; UINT16 ubSoldierID;
BASIC_SOLDIERCREATE_STRUCT *pBasicPlacement; BASIC_SOLDIERCREATE_STRUCT *pBasicPlacement;
SOLDIERCREATE_STRUCT *pDetailedPlacement; SOLDIERCREATE_STRUCT *pDetailedPlacement;
@@ -39,13 +39,13 @@ SOLDIERINITNODE* AddBasicPlacementToSoldierInitList( BASIC_SOLDIERCREATE_STRUCT
void RemoveSoldierNodeFromInitList( SOLDIERINITNODE *pNode ); void RemoveSoldierNodeFromInitList( SOLDIERINITNODE *pNode );
SOLDIERINITNODE* FindSoldierInitNodeWithID( UINT16 usID ); SOLDIERINITNODE* FindSoldierInitNodeWithID( UINT16 usID );
UINT8 AddSoldierInitListTeamToWorld( INT8 bTeam, UINT8 ubMaxNum ); UINT16 AddSoldierInitListTeamToWorld( INT8 bTeam, UINT16 ubMaxNum );
void AddSoldierInitListEnemyDefenceSoldiers( UINT8 ubTotalAdmin, UINT8 ubTotalTroops, UINT8 ubTotalElite, UINT8 ubTotalRobots, UINT8 ubTotalTanks, UINT8 ubTotalJeeps ); void AddSoldierInitListEnemyDefenceSoldiers( UINT16 ubTotalAdmin, UINT16 ubTotalTroops, UINT16 ubTotalElite, UINT16 ubTotalRobots, UINT16 ubTotalTanks, UINT16 ubTotalJeeps );
void AddSoldierInitListCreatures( BOOLEAN fQueen, UINT8 ubNumLarvae, UINT8 ubNumInfants, void AddSoldierInitListCreatures( BOOLEAN fQueen, UINT16 ubNumLarvae, UINT16 ubNumInfants,
UINT8 ubNumYoungMales, UINT8 ubNumYoungFemales, UINT8 ubNumAdultMales, UINT16 ubNumYoungMales, UINT16 ubNumYoungFemales, UINT16 ubNumAdultMales,
UINT8 ubNumAdultFemales ); UINT16 ubNumAdultFemales );
void AddSoldierInitListOtherCreatures( UINT8 usNum ); void AddSoldierInitListOtherCreatures( UINT8 usNum );
void AddSoldierInitListMilitia( UINT8 ubNumGreen, UINT8 ubNumReg, UINT8 ubNumElites ); void AddSoldierInitListMilitia( UINT16 ubNumGreen, UINT16 ubNumReg, UINT16 ubNumElites );
void AddSoldierInitListMilitiaOnEdge( UINT8 ubStrategicInsertionCode, UINT8 ubNumGreen, UINT8 ubNumReg, UINT8 ubNumElites ); void AddSoldierInitListMilitiaOnEdge( UINT8 ubStrategicInsertionCode, UINT8 ubNumGreen, UINT8 ubNumReg, UINT8 ubNumElites );
void AddSoldierInitListBloodcats(); void AddSoldierInitListBloodcats();
@@ -55,7 +55,7 @@ void UseEditorAlternateList();
void AddPlacementToWorldByProfileID( UINT8 ubProfile ); void AddPlacementToWorldByProfileID( UINT8 ubProfile );
void EvaluateDeathEffectsToSoldierInitList( SOLDIERTYPE *pSoldier ); void EvaluateDeathEffectsToSoldierInitList( SOLDIERTYPE *pSoldier );
void RemoveDetailedPlacementInfo( UINT8 ubNodeID ); void RemoveDetailedPlacementInfo( UINT16 ubNodeID );
void AddProfilesUsingProfileInsertionData(); void AddProfilesUsingProfileInsertionData();
void AddProfilesNotUsingProfileInsertionData(); void AddProfilesNotUsingProfileInsertionData();
@@ -69,4 +69,4 @@ void SectorAddPrisonersofWar( INT16 sMapX, INT16 sMapY, INT16 sMapZ );
// Flugente: decide wether to add a downed pilot if a helicopter was shot down here // Flugente: decide wether to add a downed pilot if a helicopter was shot down here
void SectorAddDownedPilot( INT16 sMapX, INT16 sMapY, INT16 sMapZ ); void SectorAddDownedPilot( INT16 sMapX, INT16 sMapY, INT16 sMapZ );
#endif #endif