Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

We’re showing branches in this repository, but you can also compare across forks.

base fork: Warzone2100/warzone2100
base: 316c0aff5f
...
head fork: Warzone2100/warzone2100
compare: 0de0c41629
  • 2 commits
  • 3 files changed
  • 0 commit comments
  • 1 contributor
Commits on Apr 26, 2012
vexed vexed Trying to find out why savegames are being broken.
Possibly helps in finding out why #3416 happens.

refs:3416
7f54b33
vexed vexed Only populate unique entries for the UI template list.
Fixes #3369
0de0c41
Showing with 39 additions and 9 deletions.
  1. +2 −0  src/frontend.cpp
  2. +20 −7 src/game.cpp
  3. +17 −2 src/template.cpp
2  src/frontend.cpp
View
@@ -274,6 +274,8 @@ static void SPinit(void)
{
uint8_t playercolor;
+ // clear out the skDiff array
+ memset(game.skDiff, 0x0, sizeof(game.skDiff));
NetPlay.bComms = false;
bMultiPlayer = false;
bMultiMessages = false;
27 src/game.cpp
View
@@ -3701,7 +3701,7 @@ static bool writeGameFile(const char* fileName, SDWORD saveType)
PHYSFS_file* fileHandle = openSaveFile(fileName);
if (!fileHandle)
{
- debug(LOG_ERROR, "writeGameFile: openSaveFile(\"%s\") failed", fileName);
+ debug(LOG_ERROR, "openSaveFile(\"%s\") failed", fileName);
return false;
}
@@ -3716,15 +3716,14 @@ static bool writeGameFile(const char* fileName, SDWORD saveType)
if (!serializeSaveGameHeader(fileHandle, &fileHeader))
{
- debug(LOG_ERROR, "game.c:writeGameFile: could not write header to %s; PHYSFS error: %s", fileName, PHYSFS_getLastError());
+ debug(LOG_ERROR, "could not write header to %s; PHYSFS error: %s", fileName, PHYSFS_getLastError());
PHYSFS_close(fileHandle);
return false;
}
- ASSERT( saveType == GTYPE_SAVE_START ||
- saveType == GTYPE_SAVE_MIDMISSION,
- "writeGameFile: invalid save type" );
-
+ ASSERT( saveType == GTYPE_SAVE_START || saveType == GTYPE_SAVE_MIDMISSION, "invalid save type" );
+ // clear out structure
+ memset(&saveGame, 0x0, sizeof(SAVE_GAME));
// saveKeymissionIsOffworld
saveGame.saveKey = getCampaignNumber();
if (missionIsOffworld())
@@ -3874,7 +3873,21 @@ static bool writeGameFile(const char* fileName, SDWORD saveType)
//version 38
sstrcpy(saveGame.modList, getModList());
-
+ // Attempt to see if we have a corrupted game structure in campaigns.
+ if (saveGame.sGame.type == CAMPAIGN)
+ {
+ // player 0 is always a human in campaign games
+ for (int i=1; i < MAX_PLAYERS; i++)
+ {
+ if (saveGame.sGame.skDiff[i] == UBYTE_MAX)
+ {
+ ASSERT(!"savegame corruption!","savegame corruption!");
+ debug(LOG_ERROR, "Savegame corruption detected, trying to salvage. Please Report this issue @ wz2100.net");
+ debug(LOG_ERROR, "skDiff[i] was %d, level %s / %s, ", (int)saveGame.sGame.skDiff[i], saveGame.levelName, saveGame.sGame.map);
+ saveGame.sGame.skDiff[i] = 0;
+ }
+ }
+ }
status = serializeSaveGameData(fileHandle, &saveGame);
// Close the file
19 src/template.cpp
View
@@ -354,8 +354,23 @@ bool loadDroidTemplates(const char *pDroidData, UDWORD bufferSize)
// This sets up the UI templates for display purposes ONLY--we still only use apsDroidTemplates for making them.
// FIXME: Why are we doing this here, and not on demmand ?
- localTemplates.push_front(design);
- localTemplates.front().pName = strdup(localTemplates.front().pName);
+ // Only add unique designs to the UI list (Note, perhaps better to use std::map instead?)
+ std::list<DROID_TEMPLATE>::iterator it;
+ for (it = localTemplates.begin(); it != localTemplates.end(); ++it)
+ {
+ DROID_TEMPLATE *psCurr = &*it;
+ if (psCurr->multiPlayerID == design.multiPlayerID)
+ {
+ debug(LOG_NEVER, "Design id:%d (%s) *NOT* added to UI list (duplicate), player= %d", design.multiPlayerID, design.aName, i);
+ break;
+ }
+ }
+ if (it == localTemplates.end())
+ {
+ debug(LOG_NEVER, "Design id:%d (%s) added to UI list, player =%d", design.multiPlayerID, design.aName, i);
+ localTemplates.push_front(design);
+ localTemplates.front().pName = strdup(localTemplates.front().pName);
+ }
}
else if (NetPlay.players[i].allocated) //skip the ones not meant for puny humans
{

No commit comments for this range

Something went wrong with that request. Please try again.