Skip to content

Commit

Permalink
Fix assert in campaign transitions.
Browse files Browse the repository at this point in the history
Problem was caused by new limits code.
Missing reset of counts between missions.
  • Loading branch information
perim committed Dec 17, 2017
1 parent 5ab7002 commit 9c272aa
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
2 changes: 2 additions & 0 deletions src/game.cpp
Expand Up @@ -2141,6 +2141,7 @@ bool loadGame(const char *pGameToLoad, bool keepObjects, bool freeMem, bool User
}
}

initStructLimits();
aFileName[fileExten] = '\0';
strcat(aFileName, "mstruct.json");

Expand Down Expand Up @@ -2380,6 +2381,7 @@ bool loadGame(const char *pGameToLoad, bool keepObjects, bool freeMem, bool User
}

//load in the structures
initStructLimits();
aFileName[fileExten] = '\0';
strcat(aFileName, "struct.json");
if (!loadSaveStructure2(aFileName, apsStructLists))
Expand Down
17 changes: 12 additions & 5 deletions src/structure.cpp
Expand Up @@ -236,28 +236,35 @@ bool isBlueprint(const BASE_OBJECT *psObject)
return psObject->type == OBJ_STRUCTURE && structureIsBlueprint((STRUCTURE *)psObject);
}

void structureInitVars()
void initStructLimits()
{
int i, j;
for (int i = 0; i < numStructureStats; i++)
{
memset(asStructureStats[i].curCount, 0, sizeof(asStructureStats[i].curCount));
}
}

void structureInitVars()
{
asStructureStats = nullptr;
numStructureStats = 0;
factoryModuleStat = 0;
powerModuleStat = 0;
researchModuleStat = 0;
lastMaxUnitMessage = 0;

for (i = 0; i < MAX_PLAYERS; i++)
initStructLimits();
for (int i = 0; i < MAX_PLAYERS; i++)
{
droidLimit[i] = INT16_MAX;
commanderLimit[i] = INT16_MAX;
constructorLimit[i] = INT16_MAX;
for (j = 0; j < NUM_FLAG_TYPES; j++)
for (int j = 0; j < NUM_FLAG_TYPES; j++)
{
factoryNumFlag[i][j].clear();
}
}
for (i = 0; i < MAX_PLAYERS; i++)
for (int i = 0; i < MAX_PLAYERS; i++)
{
satUplinkExists[i] = false;
lasSatExists[i] = false;
Expand Down
1 change: 1 addition & 0 deletions src/structure.h
Expand Up @@ -475,6 +475,7 @@ void checkStructure(const STRUCTURE *psStructure, const char *const location_des
#define CHECK_STRUCTURE(object) checkStructure((object), AT_MACRO, __FUNCTION__, max_check_object_recursion)

void structureInitVars();
void initStructLimits();

#define syncDebugStructure(psStruct, ch) _syncDebugStructure(__FUNCTION__, psStruct, ch)
void _syncDebugStructure(const char *function, STRUCTURE const *psStruct, char ch);
Expand Down

0 comments on commit 9c272aa

Please sign in to comment.