Better handle missing .ini entries for IMP slots

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@825 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
SpaceViking
2007-04-02 00:50:19 +00:00
parent 1ef4419b0d
commit 1baf9b0bd1
2 changed files with 11 additions and 5 deletions
+7 -4
View File
@@ -338,7 +338,7 @@ void LoadGameExternalOptions()
char caFemaleCountStr [] = "IMP_FEMALE_%d";
char caCountStr[20];
gGameExternalOptions.iaIMPSlots = (UINT32*)MemAlloc( (gGameExternalOptions.iIMPMaleCharacterCount + gGameExternalOptions.iIMPFemaleCharacterCount + 2) * sizeof( UINT32 ) );
gGameExternalOptions.iaIMPSlots = (INT32*)MemAlloc( (gGameExternalOptions.iIMPMaleCharacterCount + gGameExternalOptions.iIMPFemaleCharacterCount + 2) * sizeof( UINT32 ) );
for (idx = 0; idx < gGameExternalOptions.iIMPMaleCharacterCount; ++idx)
{
sprintf( caCountStr, caMaleCountStr, idx+1);
@@ -357,13 +357,13 @@ void LoadGameExternalOptions()
{
sprintf( caCountStr, caFemaleCountStr, idx+1);
gGameExternalOptions.iaIMPSlots[idx+gGameExternalOptions.iIMPMaleCharacterCount+1] = iniReader.ReadInteger("JA2 Laptop Settings",caCountStr, -1, -1, NUM_PROFILES-1);
if (gGameExternalOptions.iaIMPSlots[idx] < 0)
if (gGameExternalOptions.iaIMPSlots[idx+gGameExternalOptions.iIMPMaleCharacterCount+1] < 0)
{
if (idx < COUNT_STANDARD_FEMALE_SLOTS)
gGameExternalOptions.iaIMPSlots[idx] = FIRST_STANDARD_FEMALE_SLOT+idx;
gGameExternalOptions.iaIMPSlots[idx+gGameExternalOptions.iIMPMaleCharacterCount+1] = FIRST_STANDARD_FEMALE_SLOT+idx;
else
// This is bad so just use the last standard slot #
gGameExternalOptions.iaIMPSlots[idx] = FIRST_STANDARD_FEMALE_SLOT+COUNT_STANDARD_FEMALE_SLOTS-1;
gGameExternalOptions.iaIMPSlots[idx+gGameExternalOptions.iIMPMaleCharacterCount+1] = FIRST_STANDARD_FEMALE_SLOT+COUNT_STANDARD_FEMALE_SLOTS-1;
}
}
gGameExternalOptions.iaIMPSlots[gGameExternalOptions.iIMPFemaleCharacterCount+gGameExternalOptions.iIMPMaleCharacterCount+1] = -1;
@@ -468,6 +468,9 @@ void LoadGameExternalOptions()
gGameExternalOptions.iPriceModifier = iniReader.ReadInteger("JA2 Gameplay Settings","PRICE_MODIFIER",10);
// WDS - Option to turn off stealing
gGameExternalOptions.fStealingDisabled = iniReader.ReadBoolean("JA2 Gameplay Settings","STEALING_FROM_SHIPMENTS_DISABLED",FALSE);
// WDS: Game progress
gGameExternalOptions.ubGameProgressPortionKills = iniReader.ReadInteger("JA2 Gameplay Settings","GAME_PROGRESS_KILLS",25);
gGameExternalOptions.ubGameProgressPortionControl = iniReader.ReadInteger("JA2 Gameplay Settings","GAME_PROGRESS_CONTROL",25);
+4 -1
View File
@@ -153,7 +153,7 @@ typedef struct
//
// iaIMPSlots is an array of the slots (in prof.dat) to use for IMPs.
//
UINT32 *iaIMPSlots;
INT32 *iaIMPSlots;
INT32 iMinAttribute;
INT32 iMaxAttribute;
@@ -223,6 +223,9 @@ typedef struct
//Sound settings
UINT32 guiWeaponSoundEffectsVolume;
// WDS - Option to turn off stealing
BOOLEAN fStealingDisabled;
// Militia Settings
BOOLEAN fAllowTacticalMilitiaCommand;
BOOLEAN gfTrainVeteranMilitia;