From 2455c2c4678a1f17ae1a67e0764f3f89551a15c1 Mon Sep 17 00:00:00 2001 From: Flugente Date: Tue, 30 Apr 2013 21:31:04 +0000 Subject: [PATCH] changed hardcoded numbers to enums in preparation for total merc number increase git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@6042 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- Editor/EditorMercs.cpp | 8 ++++---- Editor/LoadScreen.cpp | 8 ++++---- Laptop/personnel.cpp | 12 ++++++------ SaveLoadGame.cpp | 2 +- Strategic/Auto Resolve.cpp | 2 +- Strategic/Game Init.cpp | 4 ++-- Strategic/LuaInitNPCs.cpp | 18 +++++++++--------- Tactical/Faces.cpp | 2 +- Tactical/Soldier Create.cpp | 8 ++++---- Tactical/faces.h | 3 ++- TileEngine/Explosion Control.cpp | 2 +- 11 files changed, 35 insertions(+), 34 deletions(-) diff --git a/Editor/EditorMercs.cpp b/Editor/EditorMercs.cpp index 1ac165ae..4f48a51c 100644 --- a/Editor/EditorMercs.cpp +++ b/Editor/EditorMercs.cpp @@ -699,10 +699,10 @@ void ResetAllMercPositions() //} curr = curr->next; } - AddSoldierInitListTeamToWorld( ENEMY_TEAM, 255 ); - AddSoldierInitListTeamToWorld( CREATURE_TEAM, 255 ); - AddSoldierInitListTeamToWorld( MILITIA_TEAM, 255 ); - AddSoldierInitListTeamToWorld( CIV_TEAM, 255 ); + AddSoldierInitListTeamToWorld( ENEMY_TEAM, TOTAL_SOLDIERS + 1 ); + AddSoldierInitListTeamToWorld( CREATURE_TEAM, TOTAL_SOLDIERS + 1 ); + AddSoldierInitListTeamToWorld( MILITIA_TEAM, TOTAL_SOLDIERS + 1 ); + AddSoldierInitListTeamToWorld( CIV_TEAM, TOTAL_SOLDIERS + 1 ); gpSelected = NULL; gsSelectedMercID = -1; } diff --git a/Editor/LoadScreen.cpp b/Editor/LoadScreen.cpp index 530ce575..eb086cfc 100644 --- a/Editor/LoadScreen.cpp +++ b/Editor/LoadScreen.cpp @@ -1073,10 +1073,10 @@ UINT32 ProcessFileIO() //ATE: Any current mercs are transfered here... //UpdateMercsInSector( gWorldSectorX, gWorldSectorY, gbWorldSectorZ ); - AddSoldierInitListTeamToWorld( ENEMY_TEAM, 255 ); - AddSoldierInitListTeamToWorld( CREATURE_TEAM, 255 ); - AddSoldierInitListTeamToWorld( MILITIA_TEAM, 255 ); - AddSoldierInitListTeamToWorld( CIV_TEAM, 255 ); + AddSoldierInitListTeamToWorld( ENEMY_TEAM, TOTAL_SOLDIERS + 1 ); + AddSoldierInitListTeamToWorld( CREATURE_TEAM, TOTAL_SOLDIERS + 1 ); + AddSoldierInitListTeamToWorld( MILITIA_TEAM, TOTAL_SOLDIERS + 1 ); + AddSoldierInitListTeamToWorld( CIV_TEAM, TOTAL_SOLDIERS + 1 ); iCurrentAction = ACTION_NULL; gbCurrentFileIOStatus = IOSTATUS_NONE; if( !gfCaves && !gfBasement ) diff --git a/Laptop/personnel.cpp b/Laptop/personnel.cpp index f4f7b19e..b0fc4703 100644 --- a/Laptop/personnel.cpp +++ b/Laptop/personnel.cpp @@ -3076,14 +3076,14 @@ INT32 GetIdOfDepartedMercWithHighestStat( INT32 iStat ) for( uiLoopCounter=0; fNotDone ; uiLoopCounter++ ) { //if we are at the end of - if( uiLoopCounter == 255 && bCurrentList == 2 ) + if( uiLoopCounter == NUM_PROFILES && bCurrentList == 2 ) { fNotDone = FALSE; continue; } // check if we need to move to the next list - if( uiLoopCounter == 255 ) + if( uiLoopCounter == NUM_PROFILES ) { if( bCurrentList == 0 ) { @@ -3249,7 +3249,7 @@ INT32 GetIdOfDepartedMercWithLowestStat( INT32 iStat ) } */ //if we are at the end of - if( uiLoopCounter == 255 && bCurrentList == 2 ) + if( uiLoopCounter == NUM_PROFILES && bCurrentList == 2 ) { fNotDone = FALSE; continue; @@ -3257,7 +3257,7 @@ INT32 GetIdOfDepartedMercWithLowestStat( INT32 iStat ) // check if we need to move to the next list // if( *bCurrentListValue == -1 ) - if( uiLoopCounter == 255 ) + if( uiLoopCounter == NUM_PROFILES ) { if( bCurrentList == 0 ) { @@ -3786,7 +3786,7 @@ INT32 GetAvgStatOfPastTeamStat( INT32 iStat ) */ //if we are at the end of - if( uiLoopCounter == 255 && bCurrentList == 2 ) + if( uiLoopCounter == NUM_PROFILES && bCurrentList == 2 ) { fNotDone = FALSE; continue; @@ -3794,7 +3794,7 @@ INT32 GetAvgStatOfPastTeamStat( INT32 iStat ) // check if we need to move to the next list // if( *bCurrentListValue == -1 ) - if( uiLoopCounter == 255 ) + if( uiLoopCounter == NUM_PROFILES ) { if( bCurrentList == 0 ) { diff --git a/SaveLoadGame.cpp b/SaveLoadGame.cpp index a12670ca..82427c63 100644 --- a/SaveLoadGame.cpp +++ b/SaveLoadGame.cpp @@ -8367,7 +8367,7 @@ BOOLEAN LoadGeneralInfo( HWFILE hFile ) { //Camo Face by Jazz - for (int i=0;i<255;i++) + for (int i=0;iubSoldierClass ) { case SOLDIER_CLASS_GREEN_MILITIA: ubCurrentRank = GREEN_MILITIA; break; diff --git a/Strategic/Game Init.cpp b/Strategic/Game Init.cpp index 8b98557c..17d98175 100644 --- a/Strategic/Game Init.cpp +++ b/Strategic/Game Init.cpp @@ -645,7 +645,7 @@ fFirstTimeInMapScreen = TRUE; // ------------------------ if (gGameExternalOptions.fShowCamouflageFaces == TRUE ) { - for (int i=0;i<255;i++) + for (int i=0;i= 1 ) { @@ -5363,14 +5363,14 @@ UINT32 sGridNo = 0; pSoldier = FindSoldierByProfileID( ID, FALSE ); if (pSoldier) - { - sGridNo = pSoldier->usStrategicInsertionData; - } + { + sGridNo = pSoldier->usStrategicInsertionData; + } lua_pushinteger(L, sGridNo); } -return 1; + return 1; } static int l_bNeutral(lua_State *L) @@ -6719,7 +6719,7 @@ static int l_Action_door_close (lua_State *L) //action static int l_SetOffBombsByFrequency (lua_State *L) { - SOLDIERTYPE * pSoldier; + //SOLDIERTYPE * pSoldier; if ( lua_gettop(L) >= 2 ) { @@ -10625,7 +10625,7 @@ static int l_CheckFact (lua_State *L) ubProfileID = lua_tointeger(L,i); } - if ( ubProfileID != 255 && CheckFact( fact, ubProfileID ) ) + if ( ubProfileID != NUM_PROFILES && CheckFact( fact, ubProfileID ) ) { checkfact= TRUE; } diff --git a/Tactical/Faces.cpp b/Tactical/Faces.cpp index 603043c2..ddf40fad 100644 --- a/Tactical/Faces.cpp +++ b/Tactical/Faces.cpp @@ -65,7 +65,7 @@ extern BOOLEAN gfInItemPickupMenu; RPC_SMALL_FACE_VALUES gRPCSmallFaceValues[200]; UINT8 ubRPCNumSmallFaceValues = 200; -CAMO_FACE gCamoFace[255]; +CAMO_FACE gCamoFace[NUM_PROFILES]; FACE_GEAR_VALUES zNewFaceGear[MAXITEMS]; FACE_GEAR_VALUES zNewFaceGearIMP[MAXITEMS]; diff --git a/Tactical/Soldier Create.cpp b/Tactical/Soldier Create.cpp index 1f19a4dc..29e68adf 100644 --- a/Tactical/Soldier Create.cpp +++ b/Tactical/Soldier Create.cpp @@ -1151,11 +1151,11 @@ SOLDIERTYPE* TacticalCreateSoldier( SOLDIERCREATE_STRUCT *pCreateStruct, UINT8 * pSoldier = new SOLDIERTYPE(Soldier); //(SOLDIERTYPE*)MemAlloc( SIZEOF_SOLDIERTYPE ); if( !pSoldier ) return NULL; - pSoldier->ubID = 255; + pSoldier->ubID = NUM_PROFILES; pSoldier->sSectorX = (INT16)SECTORX( ubSectorID ); pSoldier->sSectorY = (INT16)SECTORY( ubSectorID ); pSoldier->bSectorZ = 0; - *pubID = 255; + *pubID = NUM_PROFILES; return pSoldier; } } @@ -2790,7 +2790,7 @@ SOLDIERTYPE* ReserveTacticalSoldierForAutoresolve( UINT8 ubSoldierClass ) return NULL; //Assign a bogus ID, then return it - pSoldier->ubID = 255; + pSoldier->ubID = NUM_PROFILES; return pSoldier; } } @@ -2971,7 +2971,7 @@ SOLDIERTYPE* ReserveTacticalMilitiaSoldierForAutoresolve( UINT8 ubSoldierClass ) MercPtrs[i]->bSoldierFlagMask |= SOLDIER_EQUIPMENT_DROPPED; //Assign a bogus ID, then return it - pSoldier->ubID = 255; + pSoldier->ubID = NUM_PROFILES; return pSoldier; } } diff --git a/Tactical/faces.h b/Tactical/faces.h index 94632e02..1c2a85ae 100644 --- a/Tactical/faces.h +++ b/Tactical/faces.h @@ -6,6 +6,7 @@ #define SURPRISED 3 #include "soldier control.h" +#include "soldier profile type.h" // Defines #define NUM_FACE_SLOTS 50 @@ -25,7 +26,7 @@ typedef struct BOOLEAN gSnowCamoface; } CAMO_FACE; -extern CAMO_FACE gCamoFace[255]; +extern CAMO_FACE gCamoFace[NUM_PROFILES]; typedef struct diff --git a/TileEngine/Explosion Control.cpp b/TileEngine/Explosion Control.cpp index 1c367cef..8ef780d4 100644 --- a/TileEngine/Explosion Control.cpp +++ b/TileEngine/Explosion Control.cpp @@ -366,7 +366,7 @@ void InternalIgniteExplosion( UINT8 ubOwner, INT16 sX, INT16 sY, INT16 sZ, INT32 // Flugente: if the explosion occured in a building, this might lower loyalty in town UINT16 tmp; - if ( Item[ usItem ].usItemClass & IC_EXPLOSV && ubOwner != NOBODY && ubOwner < 255 && InARoom( sGridNo, &tmp ) ) + if ( Item[ usItem ].usItemClass & IC_EXPLOSV && ubOwner != NOBODY && ubOwner < NUM_PROFILES && InARoom( sGridNo, &tmp ) ) { HandleLoyaltyForDemolitionOfBuilding( MercPtrs[ubOwner], Explosive[ Item[ usItem ].ubClassIndex ].ubDamage ); }