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
+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.");
return(FALSE);
}
Assert(cnt < 256);
pNode->ubNodeID = (UINT8)cnt;
Assert(cnt < MAX_INDIVIDUALS);
pNode->ubNodeID = cnt;
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.
@@ -369,7 +369,7 @@ BOOLEAN SaveSoldiersToMap(HWFILE hFile, FLOAT dMajorMapVersion, UINT8 ubMinorMap
{
if(!curr)
return(FALSE);
curr->ubNodeID = (UINT8)i;
curr->ubNodeID = i;
curr->pBasicPlacement->Save(hFile, dMajorMapVersion, ubMinorMapVersion);
if(curr->pBasicPlacement->fDetailedPlacement)
{
@@ -577,7 +577,6 @@ void SortSoldierInitList()
}
extern FLOAT gAmbushRadiusModifier;
#pragma optimize("",off)
BOOLEAN AddPlacementToWorld( SOLDIERINITNODE *curr, GROUP *pGroup = NULL )
{
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!)");
return FALSE;
}
#pragma optimize("",on)
void AddPlacementToWorldByProfileID( UINT8 ubProfile )
{
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;
UINT8 ubSlotsToFill;
UINT8 ubSlotsAvailable;
UINT16 ubSlotsToFill;
UINT16 ubSlotsAvailable;
SOLDIERINITNODE *curr;
DebugMsg(TOPIC_JA2,DBG_LEVEL_3,String("AddSoldierInitListTeamToWorld"));
@@ -1046,22 +1045,22 @@ UINT8 AddSoldierInitListTeamToWorld( INT8 bTeam, UINT8 ubMaxNum )
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 *curr;
INT32 iRandom;
UINT8 ubMaxNum;
UINT8 ubRobotPDSlots = 0, ubRobotDSlots = 0, ubRobotPSlots = 0, ubRobotBSlots = 0;
UINT8 ubElitePDSlots = 0, ubEliteDSlots = 0, ubElitePSlots = 0, ubEliteBSlots = 0;
UINT8 ubTroopPDSlots = 0, ubTroopDSlots = 0, ubTroopPSlots = 0, ubTroopBSlots = 0;
UINT8 ubAdminPDSlots = 0, ubAdminDSlots = 0, ubAdminPSlots = 0, ubAdminBSlots = 0;
UINT8 ubTankPDSlots = 0, ubTankDSlots = 0, ubTankPSlots = 0, ubTankBSlots = 0;
UINT8 ubJeepPDSlots = 0, ubJeepDSlots = 0, ubJeepPSlots = 0, ubJeepBSlots = 0;
UINT8 ubFreeSlots;
UINT8 *pCurrSlots=NULL;
UINT8 *pCurrTotal=NULL;
UINT16 ubMaxNum;
UINT16 ubRobotPDSlots = 0, ubRobotDSlots = 0, ubRobotPSlots = 0, ubRobotBSlots = 0;
UINT16 ubElitePDSlots = 0, ubEliteDSlots = 0, ubElitePSlots = 0, ubEliteBSlots = 0;
UINT16 ubTroopPDSlots = 0, ubTroopDSlots = 0, ubTroopPSlots = 0, ubTroopBSlots = 0;
UINT16 ubAdminPDSlots = 0, ubAdminDSlots = 0, ubAdminPSlots = 0, ubAdminBSlots = 0;
UINT16 ubTankPDSlots = 0, ubTankDSlots = 0, ubTankPSlots = 0, ubTankBSlots = 0;
UINT16 ubJeepPDSlots = 0, ubJeepDSlots = 0, ubJeepPSlots = 0, ubJeepBSlots = 0;
UINT16 ubFreeSlots;
UINT16 *pCurrSlots=NULL;
UINT16 *pCurrTotal=NULL;
UINT8 ubCurrClass;
DebugMsg(TOPIC_JA2,DBG_LEVEL_3,String("AddSoldierInitListEnemyDefenceSoldiers"));
@@ -1601,25 +1600,25 @@ void AddSoldierInitListEnemyDefenceSoldiers( UINT8 ubTotalAdmin, UINT8 ubTotalTr
curr = curr->next;
}
}
#pragma optimize("",on)
//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
//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
//placement information.
void AddSoldierInitListMilitia( UINT8 ubNumGreen, UINT8 ubNumRegs, UINT8 ubNumElites )
void AddSoldierInitListMilitia( UINT16 ubNumGreen, UINT16 ubNumRegs, UINT16 ubNumElites )
{
SOLDIERINITNODE *mark;
SOLDIERINITNODE *curr;
INT32 iRandom;
UINT8 ubMaxNum;
UINT16 ubMaxNum;
BOOLEAN fDoPlacement;
UINT8 ubEliteSlots = 0;
UINT8 ubRegSlots = 0;
UINT8 ubGreenSlots = 0;
UINT8 ubFreeSlots;
UINT8 *pCurrSlots=NULL;
UINT8 *pCurrTotal=NULL;
UINT16 ubEliteSlots = 0;
UINT16 ubRegSlots = 0;
UINT16 ubGreenSlots = 0;
UINT16 ubFreeSlots;
UINT16 *pCurrSlots=NULL;
UINT16 *pCurrTotal=NULL;
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,
UINT8 ubNumYoungMales, UINT8 ubNumYoungFemales, UINT8 ubNumAdultMales,
UINT8 ubNumAdultFemales )
void AddSoldierInitListCreatures( BOOLEAN fQueen, UINT16 ubNumLarvae, UINT16 ubNumInfants,
UINT16 ubNumYoungMales, UINT16 ubNumYoungFemales, UINT16 ubNumAdultMales,
UINT16 ubNumAdultFemales )
{
SOLDIERINITNODE *curr;
INT32 iRandom;
UINT8 ubFreeSlots;
UINT16 ubFreeSlots;
BOOLEAN fDoPlacement;
UINT8 ubNumCreatures;
UINT16 ubNumCreatures;
DebugMsg(TOPIC_JA2,DBG_LEVEL_3,String("AddSoldierInitListCreatures"));
SortSoldierInitList();
//Okay, if we have a queen, place her first. She MUST have a special placement, else
//we can't use anything.
ubNumCreatures = (UINT8)(ubNumLarvae + ubNumInfants + ubNumYoungMales + ubNumYoungFemales + ubNumAdultMales + ubNumAdultFemales);
ubNumCreatures = (ubNumLarvae + ubNumInfants + ubNumYoungMales + ubNumYoungFemales + ubNumAdultMales + ubNumAdultFemales);
if( fQueen )
{
curr = gSoldierInitHead;
@@ -2292,10 +2291,9 @@ void UseEditorAlternateList()
//if the map was loaded again!
void EvaluateDeathEffectsToSoldierInitList( SOLDIERTYPE *pSoldier )
{
SOLDIERINITNODE *curr;
UINT8 ubNodeID;
curr = gSoldierInitHead;
ubNodeID = 0;
UINT16 ubNodeID = 0;
SOLDIERINITNODE* curr = gSoldierInitHead;
if( pSoldier->bTeam == MILITIA_TEAM )
return;
while( curr )
@@ -2319,7 +2317,7 @@ void EvaluateDeathEffectsToSoldierInitList( SOLDIERTYPE *pSoldier )
}
}
void RemoveDetailedPlacementInfo( UINT8 ubNodeID )
void RemoveDetailedPlacementInfo( UINT16 ubNodeID )
{
SOLDIERINITNODE *curr;
curr = gSoldierInitHead;
@@ -2345,7 +2343,7 @@ BOOLEAN SaveSoldierInitListLinks( HWFILE hfile )
{
SOLDIERINITNODE *curr;
UINT32 uiNumBytesWritten;
UINT8 ubSlots = 0;
UINT16 ubSlots = 0;
//count the number of soldier init nodes...
curr = gSoldierInitHead;
@@ -2355,8 +2353,8 @@ BOOLEAN SaveSoldierInitListLinks( HWFILE hfile )
curr = curr->next;
}
//...and save it.
FileWrite( hfile, &ubSlots, 1, &uiNumBytesWritten );
if( uiNumBytesWritten != 1 )
FileWrite( hfile, &ubSlots, 2, &uiNumBytesWritten );
if( uiNumBytesWritten != 2 )
{
return FALSE;
}
@@ -2368,8 +2366,8 @@ BOOLEAN SaveSoldierInitListLinks( HWFILE hfile )
{
curr->ubSoldierID = 0;
}
FileWrite( hfile, &curr->ubNodeID, 1, &uiNumBytesWritten );
if( uiNumBytesWritten != 1 )
FileWrite( hfile, &curr->ubNodeID, 2, &uiNumBytesWritten );
if( uiNumBytesWritten != 2 )
{
return FALSE;
}
@@ -2387,23 +2385,23 @@ BOOLEAN LoadSoldierInitListLinks( HWFILE hfile )
{
UINT32 uiNumBytesRead;
SOLDIERINITNODE *curr;
UINT8 ubSlots, ubNodeID;
UINT16 ubSoldierID;
UINT16 ubSlots;
UINT16 ubSoldierID, ubNodeID;
FileRead( hfile, &ubSlots, 1, &uiNumBytesRead );
if( uiNumBytesRead != 1 )
FileRead( hfile, &ubSlots, 2, &uiNumBytesRead );
if( uiNumBytesRead != 2 )
{
return FALSE;
}
while( ubSlots-- )
{
FileRead( hfile, &ubNodeID, 1, &uiNumBytesRead );
if( uiNumBytesRead != 1 )
FileRead( hfile, &ubNodeID, 2, &uiNumBytesRead );
if( uiNumBytesRead != 2 )
{
return FALSE;
}
FileRead( hfile, &ubSoldierID, 1, &uiNumBytesRead );
if( uiNumBytesRead != 1 )
FileRead( hfile, &ubSoldierID, 2, &uiNumBytesRead );
if( uiNumBytesRead != 2 )
{
return FALSE;
}
@@ -2799,18 +2797,18 @@ BOOLEAN NewWayOfLoadingEnemySoldierInitListLinks( HWFILE hfile )
{
UINT32 uiNumBytesRead;
SOLDIERINITNODE *curr;
UINT8 ubSlots, ubNodeID;
UINT16 ubSoldierID;
UINT16 ubSlots;
UINT16 ubSoldierID, ubNodeID;
FileRead( hfile, &ubSlots, 1, &uiNumBytesRead );
if( uiNumBytesRead != 1 )
FileRead( hfile, &ubSlots, 2, &uiNumBytesRead );
if( uiNumBytesRead != 2 )
{
return FALSE;
}
while( ubSlots-- )
{
FileRead( hfile, &ubNodeID, 1, &uiNumBytesRead );
if( uiNumBytesRead != 1 )
FileRead( hfile, &ubNodeID, 2, &uiNumBytesRead );
if( uiNumBytesRead != 2 )
{
return FALSE;
}
@@ -2846,18 +2844,18 @@ BOOLEAN NewWayOfLoadingCivilianInitListLinks( HWFILE hfile )
{
UINT32 uiNumBytesRead;
SOLDIERINITNODE *curr;
UINT8 ubSlots, ubNodeID;
UINT16 ubSoldierID;
UINT16 ubSlots;
UINT16 ubSoldierID, ubNodeID;
FileRead( hfile, &ubSlots, 1, &uiNumBytesRead );
if( uiNumBytesRead != 1 )
FileRead( hfile, &ubSlots, 2, &uiNumBytesRead );
if( uiNumBytesRead != 2 )
{
return FALSE;
}
while( ubSlots-- )
{
FileRead( hfile, &ubNodeID, 1, &uiNumBytesRead );
if( uiNumBytesRead != 1 )
FileRead( hfile, &ubNodeID, 2, &uiNumBytesRead );
if( uiNumBytesRead != 2 )
{
return FALSE;
}
@@ -2893,18 +2891,18 @@ BOOLEAN LookAtButDontProcessEnemySoldierInitListLinks( HWFILE hfile )
{
UINT32 uiNumBytesRead;
SOLDIERINITNODE *curr;
UINT8 ubSlots, ubNodeID;
UINT16 ubSoldierID;
UINT16 ubSlots;
UINT16 ubSoldierID, ubNodeID;
FileRead( hfile, &ubSlots, 1, &uiNumBytesRead );
if( uiNumBytesRead != 1 )
FileRead( hfile, &ubSlots, 2, &uiNumBytesRead );
if( uiNumBytesRead != 2 )
{
return FALSE;
}
while( ubSlots-- )
{
FileRead( hfile, &ubNodeID, 1, &uiNumBytesRead );
if( uiNumBytesRead != 1 )
FileRead( hfile, &ubNodeID, 2, &uiNumBytesRead );
if( uiNumBytesRead != 2 )
{
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
pSector->usSectorInfoFlag &= ~SECTORINFO_ENEMYHELI_SHOTDOWN;
}
}
}