diff --git a/GameSettings.cpp b/GameSettings.cpp index 7dd9b2c1..369a10ae 100644 --- a/GameSettings.cpp +++ b/GameSettings.cpp @@ -763,41 +763,7 @@ void LoadGameExternalOptions() gGameExternalOptions.fBackGround = iniReader.ReadBoolean("Data File Settings", "BACKGROUNDS", TRUE ); //################# Merc Recruitment Settings ################# - - // WDS: Allow flexible numbers of IMPs of each sex - // SANDRO - moved to the game itself - gGameExternalOptions.iMaxIMPCharacters = iniReader.ReadInteger("Recruitment Settings","MAX_IMP_CHARACTERS",1, 1, NUM_PROFILES); - // - // Note: put -1 between male/female slots and -1 at end. This allows everything to be - // counted dynamically quite easily. Note that all the code assumes there is AT - // LEAST ONE slot for each sex. If that changes the code will have to be updated. - // - // Because errors in these values can really goof things up we will try to fix up bad - // values and use the defaults instead. - // - char caIMPCountStr[] = "IMP_%d"; - char caCountStr[20]; - - gGameExternalOptions.iaIMPSlots = (INT32*)MemAlloc( (gGameExternalOptions.iMaxIMPCharacters) * sizeof( UINT32 ) ); - for (int idx = 0; idx < gGameExternalOptions.iMaxIMPCharacters; ++idx) - { - sprintf( caCountStr, caIMPCountStr, idx+1); - gGameExternalOptions.iaIMPSlots[idx] = iniReader.ReadInteger("Recruitment Settings",caCountStr, -1, -1, NUM_PROFILES-1); - if (gGameExternalOptions.iaIMPSlots[idx] < 0) - { - if (idx < COUNT_STANDARD_MALE_SLOTS) - { - gGameExternalOptions.iaIMPSlots[idx] = FIRST_STANDARD_MALE_SLOT+idx; - } - else if ( idx < COUNT_STANDARD_FEMALE_SLOTS ) - { - // This is bad so just use the last standard slot # - gGameExternalOptions.iaIMPSlots[idx] = FIRST_STANDARD_MALE_SLOT+COUNT_STANDARD_MALE_SLOTS-1; - } - } - } - // silversurfer: read early recruitment options 1=immediately (control Omerta), 2=early (control 1, 2, 3 towns including Omerta) // 3=normal (control 3, 4, 5 towns including Omerta), 4=after liberating Omerta and solving the "Deliver Food Quest" for Miguel gGameExternalOptions.ubEarlyRebelsRecruitment[0] = iniReader.ReadInteger("Recruitment Settings","EARLY_REBELS_RECRUITMENT", 3, 1, 4); @@ -3777,8 +3743,6 @@ void LoadCreaturesSettings() void FreeGameExternalOptions() { - if (gGameExternalOptions.iaIMPSlots != NULL) // OJW - 20081129 - Fix memory leak when calling LoadGameExternalOptions twice - MemFree( gGameExternalOptions.iaIMPSlots); } BOOLEAN GetCDLocation( ) diff --git a/GameSettings.h b/GameSettings.h index ce5b0b6c..2a29fb31 100644 --- a/GameSettings.h +++ b/GameSettings.h @@ -291,14 +291,7 @@ typedef struct BOOLEAN fSellAll; INT16 iPriceModifier; - - // Flugente: max number of IMPs, regardless of gender - INT32 iMaxIMPCharacters; // Limit of how many to allow - // - // iaIMPSlots is an array of the slots (in prof.dat) to use for IMPs. - // - INT32 *iaIMPSlots; - + // SANDRO was here - some changes done INT32 iIMPProfileCost; BOOLEAN fDynamicIMPProfileCost; diff --git a/Laptop/IMP MainPage.cpp b/Laptop/IMP MainPage.cpp index 0fc74ad5..e8dfd41d 100644 --- a/Laptop/IMP MainPage.cpp +++ b/Laptop/IMP MainPage.cpp @@ -83,7 +83,8 @@ INT32 iCurrentProfileMode = IMP__REGISTRY; BOOLEAN IsIMPSlotFree(INT32 iIMPId) { - if ((iIMPId >= 0) && (iIMPId < NUM_PROFILES) && + if ((iIMPId >= 0) && (iIMPId < NUM_PROFILES) && (iIMPId != NO_PROFILE) && + ( gMercProfiles[iIMPId].Type == PROFILETYPE_IMP ) && ((wcscmp(gMercProfiles[iIMPId].zName, L"") == 0) || (gMercProfiles[iIMPId].bMercStatus == MERC_IS_DEAD))) { @@ -750,10 +751,10 @@ INT32 CountFilledIMPSlots() INT32 iCount = 0; // Count the used slots - for ( INT32 i = 0; i < gGameExternalOptions.iMaxIMPCharacters; ++i) + for ( int i = 0; i < NUM_PROFILES; ++i ) { - if ((gGameExternalOptions.iaIMPSlots[i] != -1) && - (!IsIMPSlotFree(gGameExternalOptions.iaIMPSlots[i]))) + if ( (gMercProfiles[i].Type == PROFILETYPE_IMP ) && ( i != NO_PROFILE ) && + !IsIMPSlotFree(i) ) { ++iCount; } @@ -768,9 +769,9 @@ INT32 CountEmptyIMPSlots() INT32 iCount = 0; // Count the free slots - for ( INT32 i = 0; i < gGameExternalOptions.iMaxIMPCharacters; ++i) + for ( int i = 0; i < NUM_PROFILES; ++i ) { - if (IsIMPSlotFree(gGameExternalOptions.iaIMPSlots[i])) + if (IsIMPSlotFree(i)) { ++iCount; } @@ -794,12 +795,12 @@ INT32 GetFreeIMPSlot(INT32 iDefaultIMPId) // The default IMP id is already used, find next free imp id // Find a free imp slot - for (INT32 i = 0; i < gGameExternalOptions.iMaxIMPCharacters; ++i) + for (int i = 0; i < NUM_PROFILES; ++i) { // Found a free imp slot - if (IsIMPSlotFree(gGameExternalOptions.iaIMPSlots[i])) + if (IsIMPSlotFree(i)) { - return gGameExternalOptions.iaIMPSlots[i]; + return i; } } diff --git a/Tactical/Soldier Profile.cpp b/Tactical/Soldier Profile.cpp index e107dbdd..2be79c6f 100644 --- a/Tactical/Soldier Profile.cpp +++ b/Tactical/Soldier Profile.cpp @@ -284,6 +284,12 @@ BOOLEAN LoadNewSystemMercsToSaveGameFile( HWFILE hFile ) } } + // for whatever bizarre reason, this function is called way after the profiles themselves are loaded - so we now have to overwrite the types in there + for ( int i = 0; i < NUM_PROFILES; ++i ) + { + gMercProfiles[i].Type = gProfileType[i]; + } + return( TRUE ); }