IMP slots are now purely defined by <Type>6</Type> in MercProfiles.xml. Removed MAX_IMP_CHARACTERS and IMP_XXX settings.

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8622 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Flugente
2018-09-29 13:18:40 +00:00
parent 614d0c6c09
commit 0905d5aa47
4 changed files with 17 additions and 53 deletions
-36
View File
@@ -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( )
+1 -8
View File
@@ -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;
+10 -9
View File
@@ -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;
}
}
+6
View File
@@ -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 );
}