From 603a36826fcb4172ac845c0cb0f7a47d22943385 Mon Sep 17 00:00:00 2001 From: Flugente Date: Tue, 16 Apr 2013 22:34:49 +0000 Subject: [PATCH] increased number of merc opinions to 255 git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@6012 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- GameVersion.h | 3 +- SaveLoadGame.cpp | 19 +- Strategic/Game Init.cpp | 2 +- Tactical/Soldier Control.cpp | 4 +- Tactical/Soldier Profile.cpp | 2 +- Tactical/Soldier Profile.h | 2 +- Tactical/XML_Opinions.cpp | 634 ++------------------------------ Tactical/soldier profile type.h | 19 +- 8 files changed, 67 insertions(+), 618 deletions(-) diff --git a/GameVersion.h b/GameVersion.h index 209ca387e..d51e5bbd3 100644 --- a/GameVersion.h +++ b/GameVersion.h @@ -21,6 +21,7 @@ extern CHAR16 zTrackingNumber[16]; // Keeps track of the saved game version. Increment the saved game version whenever // you will invalidate the saved game file +#define ENLARGED_OPINIONS 141 // Flugente: increased numberof merc opinions to 255, thus need to change savegame reading #define MODULARIZED_AI 140 // Flugente: new savegame version due to modularized AI #define MILITIA_EQUIPMENT 139 // Flugente: militia can equip from sector inventory #define MULTITURN_ACTIONS 138 // Flugente: multiturn actions @@ -59,7 +60,7 @@ extern CHAR16 zTrackingNumber[16]; #define AP100_SAVEGAME_DATATYPE_CHANGE 105 // Before this, we didn't have the 100AP structure changes #define NIV_SAVEGAME_DATATYPE_CHANGE 102 // Before this, we used the old structure system -#define SAVE_GAME_VERSION MODULARIZED_AI +#define SAVE_GAME_VERSION ENLARGED_OPINIONS //#define RUSSIANGOLD #ifdef __cplusplus diff --git a/SaveLoadGame.cpp b/SaveLoadGame.cpp index cd75effa5..a12670cad 100644 --- a/SaveLoadGame.cpp +++ b/SaveLoadGame.cpp @@ -1235,7 +1235,7 @@ BOOLEAN SOLDIERCREATE_STRUCT::Load(HWFILE hFile, int versionToLoad, bool loadChe BOOLEAN MERCPROFILESTRUCT::Load(HWFILE hFile, bool forceLoadOldVersion, bool forceLoadOldEncryption, bool wasSavedWithEncryption) { UINT32 uiNumBytesRead; - INT32 numBytesRead = 0, temp = 0; + INT32 numBytesRead = 0, temp = 0, buffer = 0; UINT8 filler = 0; this->initialize(); @@ -1400,7 +1400,20 @@ BOOLEAN MERCPROFILESTRUCT::Load(HWFILE hFile, bool forceLoadOldVersion, bool for numBytesRead = ReadFieldByField( hFile, &this->bTown, sizeof(this->bTown), sizeof(INT8), numBytesRead); numBytesRead = ReadFieldByField( hFile, &this->bTownAttachment, sizeof(this->bTownAttachment), sizeof(INT8), numBytesRead); numBytesRead = ReadFieldByField( hFile, &this->usOptionalGearCost, sizeof(this->usOptionalGearCost), sizeof(UINT16), numBytesRead); - numBytesRead = ReadFieldByField( hFile, this->bMercOpinion, sizeof(this->bMercOpinion), sizeof(INT8), numBytesRead); + + if ( guiCurrentSaveGameVersion >= ENLARGED_OPINIONS ) + { + numBytesRead = ReadFieldByField( hFile, this->bMercOpinion, sizeof(this->bMercOpinion), sizeof(INT8), numBytesRead); + } + else + { + // Flugente: for old savegames, only read the number of old opinions, and then add a buffer value to get fitting sizes + numBytesRead = ReadFieldByField( hFile, this->bMercOpinion, NUMBER_OF_OPINIONS_OLD, sizeof(INT8), numBytesRead); + + for(int i = 0; i < sizeof(this->bMercOpinion) - NUMBER_OF_OPINIONS_OLD; ++i) + ++buffer; + } + numBytesRead = ReadFieldByField( hFile, &this->bApproached, sizeof(this->bApproached), sizeof(INT8), numBytesRead); numBytesRead = ReadFieldByField( hFile, &this->bMercStatus, sizeof(this->bMercStatus), sizeof(INT8), numBytesRead); numBytesRead = ReadFieldByField( hFile, this->bHatedTime, sizeof(this->bHatedTime), sizeof(INT8), numBytesRead); @@ -1441,7 +1454,7 @@ BOOLEAN MERCPROFILESTRUCT::Load(HWFILE hFile, bool forceLoadOldVersion, bool for //DBrot: More rooms int size; - if ( numBytesRead != SIZEOF_MERCPROFILESTRUCT_POD ) + if ( numBytesRead + buffer != SIZEOF_MERCPROFILESTRUCT_POD ) { return(FALSE); } diff --git a/Strategic/Game Init.cpp b/Strategic/Game Init.cpp index e8cb3f622..8b98557cd 100644 --- a/Strategic/Game Init.cpp +++ b/Strategic/Game Init.cpp @@ -962,7 +962,7 @@ void QuickSetupOfMercProfileItems( UINT32 uiCount, UINT8 ubProfileIndex ) // TEMP! // make carman's opinion of us high! if (OKToCheckOpinion(ubProfileIndex)) - gMercProfiles[ 78 ].bMercOpinion[ ubProfileIndex ] = 25; + gMercProfiles[ CARMEN ].bMercOpinion[ ubProfileIndex ] = 25; } else if ( uiCount == 1 ) diff --git a/Tactical/Soldier Control.cpp b/Tactical/Soldier Control.cpp index ce4a6f1dd..53027034e 100644 --- a/Tactical/Soldier Control.cpp +++ b/Tactical/Soldier Control.cpp @@ -1260,7 +1260,9 @@ MERCPROFILESTRUCT& MERCPROFILESTRUCT::operator=(const OLD_MERCPROFILESTRUCT_101& memcpy( &(this->ubApproachVal), &(src.ubApproachVal), 4 * sizeof (UINT8)); memcpy( &(this->ubApproachMod), &(src.ubApproachMod), 3 * 4 * sizeof (UINT8)); - memcpy( &(this->bMercOpinion), &(src.bMercOpinion), DontUseMeDirectly::MaxIDToCheckForMorale * sizeof (INT8)); + + // Flugente: opinion has 255 entries now, old had 75 - only copy over the old + memcpy( &(this->bMercOpinion), &(src.bMercOpinion), NUMBER_OF_OPINIONS_OLD * sizeof (INT8)); memcpy( &(this->usStatChangeChances), &(src.usStatChangeChances), 12 * sizeof (UINT16));// used strictly for balancing, never shown! memcpy( &(this->usStatChangeSuccesses), &(src.usStatChangeSuccesses), 12 * sizeof (UINT16));// used strictly for balancing, never shown! diff --git a/Tactical/Soldier Profile.cpp b/Tactical/Soldier Profile.cpp index fd56d52c8..d4379eaaf 100644 --- a/Tactical/Soldier Profile.cpp +++ b/Tactical/Soldier Profile.cpp @@ -2543,7 +2543,7 @@ void OverwriteMercOpinionsWithXMLData( UINT32 uiLoop ) { UINT8 cnt; - for (cnt=0; cnt<75; cnt++ ) + for (cnt=0; cnt< NUMBER_OF_OPINIONS; ++cnt ) { gMercProfiles[ uiLoop ].bMercOpinion[cnt] = tempProfiles[ uiLoop ].bMercOpinion[cnt] ; } diff --git a/Tactical/Soldier Profile.h b/Tactical/Soldier Profile.h index fbfbdb816..7acb77314 100644 --- a/Tactical/Soldier Profile.h +++ b/Tactical/Soldier Profile.h @@ -388,7 +388,7 @@ typedef struct UINT16 usApproachFactor[4]; - INT8 bMercOpinion[75]; + INT8 bMercOpinion[NUMBER_OF_OPINIONS]; UINT32 Type; diff --git a/Tactical/XML_Opinions.cpp b/Tactical/XML_Opinions.cpp index b3098d86d..f67290380 100644 --- a/Tactical/XML_Opinions.cpp +++ b/Tactical/XML_Opinions.cpp @@ -68,88 +68,29 @@ opinionStartElementHandle(void *userData, const XML_Char *name, const XML_Char * } else if(pData->curElement == ELEMENT && (strcmp(name, "zNickname") == 0 || - strcmp(name, "uiIndex") == 0 || - strcmp(name, "Opinion0") == 0 || - strcmp(name, "Opinion1") == 0 || - strcmp(name, "Opinion2") == 0 || - strcmp(name, "Opinion3") == 0 || - strcmp(name, "Opinion4") == 0 || - strcmp(name, "Opinion5") == 0 || - strcmp(name, "Opinion6") == 0 || - strcmp(name, "Opinion7") == 0 || - strcmp(name, "Opinion8") == 0 || - strcmp(name, "Opinion9") == 0 || - strcmp(name, "Opinion10") == 0 || - strcmp(name, "Opinion11") == 0 || - strcmp(name, "Opinion12") == 0 || - strcmp(name, "Opinion13") == 0 || - strcmp(name, "Opinion14") == 0 || - strcmp(name, "Opinion15") == 0 || - strcmp(name, "Opinion16") == 0 || - strcmp(name, "Opinion17") == 0 || - strcmp(name, "Opinion18") == 0 || - strcmp(name, "Opinion19") == 0 || - strcmp(name, "Opinion20") == 0 || - strcmp(name, "Opinion21") == 0 || - strcmp(name, "Opinion22") == 0 || - strcmp(name, "Opinion23") == 0 || - strcmp(name, "Opinion24") == 0 || - strcmp(name, "Opinion25") == 0 || - strcmp(name, "Opinion26") == 0 || - strcmp(name, "Opinion27") == 0 || - strcmp(name, "Opinion28") == 0 || - strcmp(name, "Opinion29") == 0 || - strcmp(name, "Opinion30") == 0 || - strcmp(name, "Opinion31") == 0 || - strcmp(name, "Opinion32") == 0 || - strcmp(name, "Opinion33") == 0 || - strcmp(name, "Opinion34") == 0 || - strcmp(name, "Opinion35") == 0 || - strcmp(name, "Opinion36") == 0 || - strcmp(name, "Opinion37") == 0 || - strcmp(name, "Opinion38") == 0 || - strcmp(name, "Opinion39") == 0 || - strcmp(name, "Opinion40") == 0 || - strcmp(name, "Opinion41") == 0 || - strcmp(name, "Opinion42") == 0 || - strcmp(name, "Opinion43") == 0 || - strcmp(name, "Opinion44") == 0 || - strcmp(name, "Opinion45") == 0 || - strcmp(name, "Opinion46") == 0 || - strcmp(name, "Opinion47") == 0 || - strcmp(name, "Opinion48") == 0 || - strcmp(name, "Opinion49") == 0 || - strcmp(name, "Opinion50") == 0 || - strcmp(name, "Opinion51") == 0 || - strcmp(name, "Opinion52") == 0 || - strcmp(name, "Opinion53") == 0 || - strcmp(name, "Opinion54") == 0 || - strcmp(name, "Opinion55") == 0 || - strcmp(name, "Opinion56") == 0 || - strcmp(name, "Opinion57") == 0 || - strcmp(name, "Opinion58") == 0 || - strcmp(name, "Opinion59") == 0 || - strcmp(name, "Opinion60") == 0 || - strcmp(name, "Opinion61") == 0 || - strcmp(name, "Opinion62") == 0 || - strcmp(name, "Opinion63") == 0 || - strcmp(name, "Opinion64") == 0 || - strcmp(name, "Opinion65") == 0 || - strcmp(name, "Opinion66") == 0 || - strcmp(name, "Opinion67") == 0 || - strcmp(name, "Opinion68") == 0 || - strcmp(name, "Opinion69") == 0 || - strcmp(name, "Opinion70") == 0 || - strcmp(name, "Opinion71") == 0 || - strcmp(name, "Opinion72") == 0 || - strcmp(name, "Opinion73") == 0 || - strcmp(name, "Opinion74") == 0 - )) + strcmp(name, "uiIndex") == 0 )) { pData->curElement = ELEMENT_PROPERTY; pData->maxReadDepth++; //we are not skipping this element } + else if(pData->curElement == ELEMENT) + { + for(UINT8 i = 0; i < NUMBER_OF_OPINIONS; ++i) + { + XML_Char bla[12]; + sprintf(bla, "Opinion%d", i); + + if(strcmp(name, bla) == 0) + { + pData->curElement = ELEMENT_PROPERTY; + + pData->maxReadDepth++; //we are not skipping this element + + break; + } + } + } pData->szCharData[0] = '\0'; } @@ -191,7 +132,7 @@ opinionEndElementHandle(void *userData, const XML_Char *name) // Write data into a temporary array that holds profiles. We will later copy data from that // temp array into the REAL profile array, one item at a time, replacing PROF.DAT data. - memcpy( &(tempProfiles[pData->curIndex].bMercOpinion), &(pData->curProfile.bMercOpinion), 75 * sizeof(INT8) ); + memcpy( &(tempProfiles[pData->curIndex].bMercOpinion), &(pData->curProfile.bMercOpinion), NUMBER_OF_OPINIONS * sizeof(INT8) ); } } @@ -212,531 +153,24 @@ opinionEndElementHandle(void *userData, const XML_Char *name) pData->curIndex = (UINT32) strtoul(pData->szCharData, NULL, 0); } - else if(strcmp(name, "Opinion0") == 0) + else { - pData->curElement = ELEMENT; + for(UINT8 i = 0; i < NUMBER_OF_OPINIONS; ++i) + { + XML_Char bla[12]; + sprintf(bla, "Opinion%d", i); + + if(strcmp(name, bla) == 0) + { + pData->curElement = ELEMENT; - pData->curProfile.bMercOpinion[0] = (INT8) atol(pData->szCharData); - } - - else if(strcmp(name, "Opinion1") == 0) - { - pData->curElement = ELEMENT; - - pData->curProfile.bMercOpinion[1] = (INT8) atol(pData->szCharData); - } - - else if(strcmp(name, "Opinion2") == 0) - { - pData->curElement = ELEMENT; - - pData->curProfile.bMercOpinion[2] = (INT8) atol(pData->szCharData); - } - - else if(strcmp(name, "Opinion3") == 0) - { - pData->curElement = ELEMENT; - - pData->curProfile.bMercOpinion[3] = (INT8) atol(pData->szCharData); - } - - else if(strcmp(name, "Opinion4") == 0) - { - pData->curElement = ELEMENT; - - pData->curProfile.bMercOpinion[4] = (INT8) atol(pData->szCharData); - } - - else if(strcmp(name, "Opinion5") == 0) - { - pData->curElement = ELEMENT; - - pData->curProfile.bMercOpinion[5] = (INT8) atol(pData->szCharData); - } - - else if(strcmp(name, "Opinion6") == 0) - { - pData->curElement = ELEMENT; - - pData->curProfile.bMercOpinion[6] = (INT8) atol(pData->szCharData); - } - - else if(strcmp(name, "Opinion7") == 0) - { - pData->curElement = ELEMENT; - - pData->curProfile.bMercOpinion[7] = (INT8) atol(pData->szCharData); - } - - else if(strcmp(name, "Opinion8") == 0) - { - pData->curElement = ELEMENT; - - pData->curProfile.bMercOpinion[8] = (INT8) atol(pData->szCharData); - } - - else if(strcmp(name, "Opinion9") == 0) - { - pData->curElement = ELEMENT; - - pData->curProfile.bMercOpinion[9] = (INT8) atol(pData->szCharData); - } - - else if(strcmp(name, "Opinion10") == 0) - { - pData->curElement = ELEMENT; - - pData->curProfile.bMercOpinion[10] = (INT8) atol(pData->szCharData); - } - - else if(strcmp(name, "Opinion11") == 0) - { - pData->curElement = ELEMENT; - - pData->curProfile.bMercOpinion[11] = (INT8) atol(pData->szCharData); - } - - else if(strcmp(name, "Opinion12") == 0) - { - pData->curElement = ELEMENT; - - pData->curProfile.bMercOpinion[12] = (INT8) atol(pData->szCharData); - } - - else if(strcmp(name, "Opinion13") == 0) - { - pData->curElement = ELEMENT; - - pData->curProfile.bMercOpinion[13] = (INT8) atol(pData->szCharData); - } - - else if(strcmp(name, "Opinion14") == 0) - { - pData->curElement = ELEMENT; - - pData->curProfile.bMercOpinion[14] = (INT8) atol(pData->szCharData); - } - - else if(strcmp(name, "Opinion15") == 0) - { - pData->curElement = ELEMENT; - - pData->curProfile.bMercOpinion[15] = (INT8) atol(pData->szCharData); - } - - else if(strcmp(name, "Opinion16") == 0) - { - pData->curElement = ELEMENT; - - pData->curProfile.bMercOpinion[16] = (INT8) atol(pData->szCharData); - } - - else if(strcmp(name, "Opinion17") == 0) - { - pData->curElement = ELEMENT; - - pData->curProfile.bMercOpinion[17] = (INT8) atol(pData->szCharData); - } - - else if(strcmp(name, "Opinion18") == 0) - { - pData->curElement = ELEMENT; - - pData->curProfile.bMercOpinion[18] = (INT8) atol(pData->szCharData); - } - - else if(strcmp(name, "Opinion19") == 0) - { - pData->curElement = ELEMENT; - - pData->curProfile.bMercOpinion[19] = (INT8) atol(pData->szCharData); - } - - else if(strcmp(name, "Opinion20") == 0) - { - pData->curElement = ELEMENT; - - pData->curProfile.bMercOpinion[20] = (INT8) atol(pData->szCharData); - } - - else if(strcmp(name, "Opinion21") == 0) - { - pData->curElement = ELEMENT; - - pData->curProfile.bMercOpinion[21] = (INT8) atol(pData->szCharData); - } - - else if(strcmp(name, "Opinion22") == 0) - { - pData->curElement = ELEMENT; - - pData->curProfile.bMercOpinion[22] = (INT8) atol(pData->szCharData); - } - - else if(strcmp(name, "Opinion23") == 0) - { - pData->curElement = ELEMENT; - - pData->curProfile.bMercOpinion[23] = (INT8) atol(pData->szCharData); - } - - else if(strcmp(name, "Opinion24") == 0) - { - pData->curElement = ELEMENT; - - pData->curProfile.bMercOpinion[24] = (INT8) atol(pData->szCharData); - } - - else if(strcmp(name, "Opinion25") == 0) - { - pData->curElement = ELEMENT; - - pData->curProfile.bMercOpinion[25] = (INT8) atol(pData->szCharData); - } - - else if(strcmp(name, "Opinion26") == 0) - { - pData->curElement = ELEMENT; - - pData->curProfile.bMercOpinion[26] = (INT8) atol(pData->szCharData); - } - - else if(strcmp(name, "Opinion27") == 0) - { - pData->curElement = ELEMENT; - - pData->curProfile.bMercOpinion[27] = (INT8) atol(pData->szCharData); - } - - else if(strcmp(name, "Opinion28") == 0) - { - pData->curElement = ELEMENT; - - pData->curProfile.bMercOpinion[28] = (INT8) atol(pData->szCharData); - } - - else if(strcmp(name, "Opinion29") == 0) - { - pData->curElement = ELEMENT; - - pData->curProfile.bMercOpinion[29] = (INT8) atol(pData->szCharData); - } - - else if(strcmp(name, "Opinion30") == 0) - { - pData->curElement = ELEMENT; - - pData->curProfile.bMercOpinion[30] = (INT8) atol(pData->szCharData); - } - - else if(strcmp(name, "Opinion31") == 0) - { - pData->curElement = ELEMENT; - - pData->curProfile.bMercOpinion[31] = (INT8) atol(pData->szCharData); - } - - else if(strcmp(name, "Opinion32") == 0) - { - pData->curElement = ELEMENT; - - pData->curProfile.bMercOpinion[32] = (INT8) atol(pData->szCharData); - } - - else if(strcmp(name, "Opinion33") == 0) - { - pData->curElement = ELEMENT; - - pData->curProfile.bMercOpinion[33] = (INT8) atol(pData->szCharData); - } - - else if(strcmp(name, "Opinion34") == 0) - { - pData->curElement = ELEMENT; - - pData->curProfile.bMercOpinion[34] = (INT8) atol(pData->szCharData); - } - - else if(strcmp(name, "Opinion35") == 0) - { - pData->curElement = ELEMENT; - - pData->curProfile.bMercOpinion[35] = (INT8) atol(pData->szCharData); - } - - else if(strcmp(name, "Opinion36") == 0) - { - pData->curElement = ELEMENT; - - pData->curProfile.bMercOpinion[36] = (INT8) atol(pData->szCharData); - } - - else if(strcmp(name, "Opinion37") == 0) - { - pData->curElement = ELEMENT; - - pData->curProfile.bMercOpinion[37] = (INT8) atol(pData->szCharData); - } - - else if(strcmp(name, "Opinion38") == 0) - { - pData->curElement = ELEMENT; - - pData->curProfile.bMercOpinion[38] = (INT8) atol(pData->szCharData); - } - - else if(strcmp(name, "Opinion39") == 0) - { - pData->curElement = ELEMENT; - - pData->curProfile.bMercOpinion[39] = (INT8) atol(pData->szCharData); - } - - else if(strcmp(name, "Opinion40") == 0) - { - pData->curElement = ELEMENT; - - pData->curProfile.bMercOpinion[40] = (INT8) atol(pData->szCharData); - } - - else if(strcmp(name, "Opinion41") == 0) - { - pData->curElement = ELEMENT; - - pData->curProfile.bMercOpinion[41] = (INT8) atol(pData->szCharData); - } - - else if(strcmp(name, "Opinion42") == 0) - { - pData->curElement = ELEMENT; - - pData->curProfile.bMercOpinion[42] = (INT8) atol(pData->szCharData); - } - - else if(strcmp(name, "Opinion43") == 0) - { - pData->curElement = ELEMENT; - - pData->curProfile.bMercOpinion[43] = (INT8) atol(pData->szCharData); - } - - else if(strcmp(name, "Opinion44") == 0) - { - pData->curElement = ELEMENT; - - pData->curProfile.bMercOpinion[44] = (INT8) atol(pData->szCharData); - } - - else if(strcmp(name, "Opinion45") == 0) - { - pData->curElement = ELEMENT; - - pData->curProfile.bMercOpinion[45] = (INT8) atol(pData->szCharData); - } - - else if(strcmp(name, "Opinion46") == 0) - { - pData->curElement = ELEMENT; - - pData->curProfile.bMercOpinion[46] = (INT8) atol(pData->szCharData); - } - - else if(strcmp(name, "Opinion47") == 0) - { - pData->curElement = ELEMENT; - - pData->curProfile.bMercOpinion[47] = (INT8) atol(pData->szCharData); - } - - else if(strcmp(name, "Opinion48") == 0) - { - pData->curElement = ELEMENT; - - pData->curProfile.bMercOpinion[48] = (INT8) atol(pData->szCharData); - } - - else if(strcmp(name, "Opinion49") == 0) - { - pData->curElement = ELEMENT; - - pData->curProfile.bMercOpinion[49] = (INT8) atol(pData->szCharData); - } - - else if(strcmp(name, "Opinion50") == 0) - { - pData->curElement = ELEMENT; - - pData->curProfile.bMercOpinion[50] = (INT8) atol(pData->szCharData); - } - - else if(strcmp(name, "Opinion51") == 0) - { - pData->curElement = ELEMENT; - - pData->curProfile.bMercOpinion[51] = (INT8) atol(pData->szCharData); - } - - else if(strcmp(name, "Opinion52") == 0) - { - pData->curElement = ELEMENT; - - pData->curProfile.bMercOpinion[52] = (INT8) atol(pData->szCharData); - } - - else if(strcmp(name, "Opinion53") == 0) - { - pData->curElement = ELEMENT; - - pData->curProfile.bMercOpinion[53] = (INT8) atol(pData->szCharData); - } - - else if(strcmp(name, "Opinion54") == 0) - { - pData->curElement = ELEMENT; - - pData->curProfile.bMercOpinion[54] = (INT8) atol(pData->szCharData); - } - - else if(strcmp(name, "Opinion55") == 0) - { - pData->curElement = ELEMENT; - - pData->curProfile.bMercOpinion[55] = (INT8) atol(pData->szCharData); - } - - else if(strcmp(name, "Opinion56") == 0) - { - pData->curElement = ELEMENT; - - pData->curProfile.bMercOpinion[56] = (INT8) atol(pData->szCharData); - } - - else if(strcmp(name, "Opinion57") == 0) - { - pData->curElement = ELEMENT; - - pData->curProfile.bMercOpinion[57] = (INT8) atol(pData->szCharData); - } - - else if(strcmp(name, "Opinion58") == 0) - { - pData->curElement = ELEMENT; - - pData->curProfile.bMercOpinion[58] = (INT8) atol(pData->szCharData); - } - - else if(strcmp(name, "Opinion59") == 0) - { - pData->curElement = ELEMENT; - - pData->curProfile.bMercOpinion[59] = (INT8) atol(pData->szCharData); - } - - else if(strcmp(name, "Opinion60") == 0) - { - pData->curElement = ELEMENT; - - pData->curProfile.bMercOpinion[60] = (INT8) atol(pData->szCharData); - } - - else if(strcmp(name, "Opinion61") == 0) - { - pData->curElement = ELEMENT; - - pData->curProfile.bMercOpinion[61] = (INT8) atol(pData->szCharData); - } - - else if(strcmp(name, "Opinion62") == 0) - { - pData->curElement = ELEMENT; - - pData->curProfile.bMercOpinion[62] = (INT8) atol(pData->szCharData); - } - - else if(strcmp(name, "Opinion63") == 0) - { - pData->curElement = ELEMENT; - - pData->curProfile.bMercOpinion[63] = (INT8) atol(pData->szCharData); - } - - else if(strcmp(name, "Opinion64") == 0) - { - pData->curElement = ELEMENT; - - pData->curProfile.bMercOpinion[64] = (INT8) atol(pData->szCharData); - } - - else if(strcmp(name, "Opinion65") == 0) - { - pData->curElement = ELEMENT; + pData->curProfile.bMercOpinion[i] = (INT8) atol(pData->szCharData); - pData->curProfile.bMercOpinion[65] = (INT8) atol(pData->szCharData); + break; + } + } } - - else if(strcmp(name, "Opinion66") == 0) - { - pData->curElement = ELEMENT; - - pData->curProfile.bMercOpinion[66] = (INT8) atol(pData->szCharData); - } - - else if(strcmp(name, "Opinion67") == 0) - { - pData->curElement = ELEMENT; - - pData->curProfile.bMercOpinion[67] = (INT8) atol(pData->szCharData); - } - - else if(strcmp(name, "Opinion68") == 0) - { - pData->curElement = ELEMENT; - - pData->curProfile.bMercOpinion[68] = (INT8) atol(pData->szCharData); - } - - else if(strcmp(name, "Opinion69") == 0) - { - pData->curElement = ELEMENT; - - pData->curProfile.bMercOpinion[69] = (INT8) atol(pData->szCharData); - } - - else if(strcmp(name, "Opinion70") == 0) - { - pData->curElement = ELEMENT; - - pData->curProfile.bMercOpinion[70] = (INT8) atol(pData->szCharData); - } - - else if(strcmp(name, "Opinion71") == 0) - { - pData->curElement = ELEMENT; - - pData->curProfile.bMercOpinion[71] = (INT8) atol(pData->szCharData); - } - - else if(strcmp(name, "Opinion72") == 0) - { - pData->curElement = ELEMENT; - - pData->curProfile.bMercOpinion[72] = (INT8) atol(pData->szCharData); - } - - else if(strcmp(name, "Opinion73") == 0) - { - pData->curElement = ELEMENT; - - pData->curProfile.bMercOpinion[73] = (INT8) atol(pData->szCharData); - } - - else if(strcmp(name, "Opinion74") == 0) - { - pData->curElement = ELEMENT; - - pData->curProfile.bMercOpinion[74] = (INT8) atol(pData->szCharData); - } - + pData->maxReadDepth--; } @@ -883,7 +317,7 @@ BOOLEAN WriteMercOpinions() FilePrintf(hFile,"\r\n"); UINT8 cnt_b = 0; - for (cnt_b = 0; cnt_b < 75; cnt_b++) + for (cnt_b = 0; cnt_b < NUMBER_OF_OPINIONS; ++cnt_b) { FilePrintf(hFile,"\t\t%d\r\n", cnt_b, gMercProfiles[ cnt ].bMercOpinion[cnt_b], cnt_b); } diff --git a/Tactical/soldier profile type.h b/Tactical/soldier profile type.h index 8bfc518c8..87594270f 100644 --- a/Tactical/soldier profile type.h +++ b/Tactical/soldier profile type.h @@ -95,12 +95,13 @@ // The bMercOpinion array in MERCPROFILESTRUCT below only contains 75 entries. That // means profile ID#s of 75 and beyond are not valid to be used for checking morale. // -namespace DontUseMeDirectly { - const static int MaxIDToCheckForMorale = 75; -} +// Flugente 16/04/2013: Done +#define NUMBER_OF_OPINIONS_OLD 75 // for old structures, we need to keep this value. Do NOT change, or you'll be in a world of pain. I warned you. +#define NUMBER_OF_OPINIONS 255 + inline bool OKToCheckOpinion(int profileNumber) { - return (profileNumber < DontUseMeDirectly::MaxIDToCheckForMorale); + return (profileNumber < NUMBER_OF_OPINIONS); } // SANDRO - replaced this list to represent the old traits only @@ -528,8 +529,7 @@ public: INT8 bTownAttachment; UINT16 usOptionalGearCost; - // See above note near the definition of MaxIDToCheckForMorale - INT8 bMercOpinion[DontUseMeDirectly::MaxIDToCheckForMorale]; + INT8 bMercOpinion[NUMBER_OF_OPINIONS_OLD]; // Flugente: old value has to be kept for compatibility. Do not change, or you'll be in a world of pain INT8 bApproached; INT8 bMercStatus; //The status of the merc. If negative, see flags at the top of this file. Positive: The number of days the merc is away for. 0: Not hired but ready to be. @@ -775,7 +775,7 @@ public: INT8 bTown; INT8 bTownAttachment; UINT16 usOptionalGearCost; - INT8 bMercOpinion[75]; + INT8 bMercOpinion[NUMBER_OF_OPINIONS]; INT8 bApproached; INT8 bMercStatus; //The status of the merc. If negative, see flags at the top of this file. Positive: The number of days the merc is away for. 0: Not hired but ready to be. INT8 bHatedTime[5]; @@ -989,8 +989,7 @@ public: INT8 bTownAttachment; UINT16 usOptionalGearCost; - // See above note near the definition of MaxIDToCheckForMorale - INT8 bMercOpinion[DontUseMeDirectly::MaxIDToCheckForMorale]; + INT8 bMercOpinion[NUMBER_OF_OPINIONS_OLD]; // Flugente: old value has to be kept for compatibility. Do not change, or you'll be in a world of pain INT8 bApproached; INT8 bMercStatus; //The status of the merc. If negative, see flags at the top of this file. Positive: The number of days the merc is away for. 0: Not hired but ready to be. @@ -1211,7 +1210,7 @@ typedef struct INT8 bTown; INT8 bTownAttachment; UINT16 usOptionalGearCost; - INT8 bMercOpinion[75]; + INT8 bMercOpinion[NUMBER_OF_OPINIONS]; INT8 bApproached; INT8 bMercStatus; //The status of the merc. If negative, see flags at the top of this file. Positive: The number of days the merc is away for. 0: Not hired but ready to be. INT8 bHatedTime[5];