mirror of
https://github.com/1dot13/source.git
synced 2026-09-16 14:47:17 +02:00
Allow for tactical numbers of people (mercs, militia, civs, creatures, and soldiers) to be increased via the .ini settings for a game already under way.
git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@3399 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
+47
-37
@@ -4499,6 +4499,7 @@ BOOLEAN LoadSavedGame( int ubSavedGameID )
|
|||||||
|
|
||||||
//now change the savegame format so that temp files are saved and loaded correctly
|
//now change the savegame format so that temp files are saved and loaded correctly
|
||||||
guiCurrentSaveGameVersion = SAVE_GAME_VERSION;
|
guiCurrentSaveGameVersion = SAVE_GAME_VERSION;
|
||||||
|
|
||||||
return( TRUE );
|
return( TRUE );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5368,51 +5369,60 @@ BOOLEAN LoadTacticalStatusFromSavedGame( HWFILE hFile )
|
|||||||
// Check that the team lists match what we expect given the .ini settings
|
// Check that the team lists match what we expect given the .ini settings
|
||||||
|
|
||||||
// WANNE: In a MP game the merc counts are different than in a SP game, so disable check in a MP game
|
// WANNE: In a MP game the merc counts are different than in a SP game, so disable check in a MP game
|
||||||
if (!is_networked)
|
if (!is_networked) {
|
||||||
{
|
AssertEQ(OUR_TEAM,0);
|
||||||
int cntFromFile = gTacticalStatus.Team[ OUR_TEAM ].bLastID - gTacticalStatus.Team[ OUR_TEAM ].bFirstID + 1;
|
AssertEQ(OUR_TEAM+1,ENEMY_TEAM);
|
||||||
int cntFromIni = gGameExternalOptions.ubGameMaximumNumberOfPlayerMercs + gGameExternalOptions.ubGameMaximumNumberOfPlayerVehicles;
|
AssertEQ(ENEMY_TEAM+1,CREATURE_TEAM);
|
||||||
if (cntFromFile != cntFromIni) {
|
AssertEQ(CREATURE_TEAM+1,MILITIA_TEAM);
|
||||||
CHAR16 errorMessage[512];
|
AssertEQ(MILITIA_TEAM+1,CIV_TEAM);
|
||||||
swprintf(errorMessage, L"Internal error in reading mercenary/vehicle slots from save file: number of slots in save file (%d) differs from number of slots in .ini (%d)", cntFromFile, cntFromIni);
|
|
||||||
DoScreenIndependantMessageBox(errorMessage, MSG_BOX_FLAG_OK, FailedLoadingGameCallBack );
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
cntFromFile = gTacticalStatus.Team[ ENEMY_TEAM ].bLastID - gTacticalStatus.Team[ ENEMY_TEAM ].bFirstID + 1;
|
int cntFromFile[CIV_TEAM+1];
|
||||||
cntFromIni = gGameExternalOptions.ubGameMaximumNumberOfEnemies;
|
for (int idx = OUR_TEAM; idx <= CIV_TEAM; ++idx) {
|
||||||
if (cntFromFile != cntFromIni) {
|
cntFromFile[ idx ] = gTacticalStatus.Team[ idx ].bLastID - gTacticalStatus.Team[ idx ].bFirstID + 1;
|
||||||
CHAR16 errorMessage[512];
|
|
||||||
swprintf(errorMessage, L"Internal error in reading enemy slots from save file: number of slots in save file (%d) differs from number of slots in .ini (%d)", cntFromFile, cntFromIni);
|
|
||||||
DoScreenIndependantMessageBox(errorMessage, MSG_BOX_FLAG_OK, FailedLoadingGameCallBack );
|
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
|
int cntFromIni[] = {gGameExternalOptions.ubGameMaximumNumberOfPlayerMercs + gGameExternalOptions.ubGameMaximumNumberOfPlayerVehicles,
|
||||||
|
gGameExternalOptions.ubGameMaximumNumberOfEnemies, gGameExternalOptions.ubGameMaximumNumberOfCreatures,
|
||||||
|
gGameExternalOptions.ubGameMaximumNumberOfRebels, gGameExternalOptions.ubGameMaximumNumberOfCivilians};
|
||||||
|
CHAR16 *errMsgTxt[] = {L"mercenary/vehicle", L"enemy", L"creature", L"militia", L"civilian"};
|
||||||
|
|
||||||
cntFromFile = gTacticalStatus.Team[ CREATURE_TEAM ].bLastID - gTacticalStatus.Team[ CREATURE_TEAM ].bFirstID + 1;
|
bool needToRejigger = false;
|
||||||
cntFromIni = gGameExternalOptions.ubGameMaximumNumberOfCreatures;
|
for (int idx = OUR_TEAM; idx <= CIV_TEAM; ++idx) {
|
||||||
if (cntFromFile != cntFromIni) {
|
if ((cntFromFile[ idx ] > cntFromIni[ idx ]) || ((cntFromFile[ idx ] < cntFromIni[ idx ]) && (idx == OUR_TEAM))) {
|
||||||
CHAR16 errorMessage[512];
|
CHAR16 errorMessage[512];
|
||||||
swprintf(errorMessage, L"Internal error in reading creature slots from save file: number of slots in save file (%d) differs from number of slots in .ini (%d)", cntFromFile, cntFromIni);
|
swprintf(errorMessage, L"Internal error in reading %s slots from save file: number of slots in save file (%d) differs from .ini setting (%d)", errMsgTxt [ idx ], cntFromFile[ idx ], cntFromIni[ idx ]);
|
||||||
DoScreenIndependantMessageBox(errorMessage, MSG_BOX_FLAG_OK, FailedLoadingGameCallBack );
|
DoScreenIndependantMessageBox(errorMessage, MSG_BOX_FLAG_OK, FailedLoadingGameCallBack );
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
} else if (cntFromFile[ idx ] < cntFromIni[ idx ]) {
|
||||||
|
needToRejigger = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
cntFromFile = gTacticalStatus.Team[ MILITIA_TEAM ].bLastID - gTacticalStatus.Team[ MILITIA_TEAM ].bFirstID + 1;
|
|
||||||
cntFromIni = gGameExternalOptions.ubGameMaximumNumberOfRebels;
|
|
||||||
if (cntFromFile != cntFromIni) {
|
|
||||||
CHAR16 errorMessage[512];
|
|
||||||
swprintf(errorMessage, L"Internal error in reading militia slots from save file: number of slots in save file (%d) differs from number of slots in .ini (%d)", cntFromFile, cntFromIni);
|
|
||||||
DoScreenIndependantMessageBox(errorMessage, MSG_BOX_FLAG_OK, FailedLoadingGameCallBack );
|
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
|
if (needToRejigger) {
|
||||||
cntFromFile = gTacticalStatus.Team[ CIV_TEAM ].bLastID - gTacticalStatus.Team[ CIV_TEAM ].bFirstID + 1;
|
// The .ini file asked for more slots than were in the save file, so expand the slots
|
||||||
cntFromIni = gGameExternalOptions.ubGameMaximumNumberOfCivilians;
|
for (int teamIdx = OUR_TEAM; teamIdx <= CIV_TEAM; ++teamIdx) {
|
||||||
if (cntFromFile != cntFromIni) {
|
unsigned max = 0;
|
||||||
CHAR16 errorMessage[512];
|
switch (teamIdx) {
|
||||||
swprintf(errorMessage, L"Internal error in reading civilian slots from save file: number of slots in save file (%d) differs from number of slots in .ini (%d)", cntFromFile, cntFromIni);
|
case OUR_TEAM:
|
||||||
DoScreenIndependantMessageBox(errorMessage, MSG_BOX_FLAG_OK, FailedLoadingGameCallBack );
|
max = gGameExternalOptions.ubGameMaximumNumberOfPlayerMercs + gGameExternalOptions.ubGameMaximumNumberOfPlayerVehicles;
|
||||||
return FALSE;
|
break;
|
||||||
|
case ENEMY_TEAM:
|
||||||
|
max = gGameExternalOptions.ubGameMaximumNumberOfEnemies;
|
||||||
|
break;
|
||||||
|
case CREATURE_TEAM:
|
||||||
|
max = gGameExternalOptions.ubGameMaximumNumberOfCreatures;
|
||||||
|
break;
|
||||||
|
case MILITIA_TEAM:
|
||||||
|
max = gGameExternalOptions.ubGameMaximumNumberOfRebels;
|
||||||
|
break;
|
||||||
|
case CIV_TEAM:
|
||||||
|
max = gGameExternalOptions.ubGameMaximumNumberOfCivilians;
|
||||||
|
break;
|
||||||
|
// Don't worry about the others
|
||||||
|
default:
|
||||||
|
//
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
gTacticalStatus.Team[ teamIdx ].bLastID = gTacticalStatus.Team[ teamIdx ].bFirstID + max - 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user