Skip to content

Commit

Permalink
Fix: loadSaveStructure2 production run invalid template handling
Browse files Browse the repository at this point in the history
  • Loading branch information
past-due committed Aug 21, 2023
1 parent ee5c269 commit b804a5e
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/game.cpp
Expand Up @@ -6300,6 +6300,11 @@ static bool loadSaveStructure2(const char *pFileName)
}
if (player == productionPlayer)
{
if (psFactory->psAssemblyPoint->factoryInc >= asProductionRun[psFactory->psAssemblyPoint->factoryType].size())
{
asProductionRun[psFactory->psAssemblyPoint->factoryType].resize(psFactory->psAssemblyPoint->factoryInc + 1);
}

for (int runNum = 0; runNum < ini.value("Factory/productionRuns", 0).toInt(); runNum++)
{
ProductionRunEntry currentProd;
Expand All @@ -6309,12 +6314,12 @@ static bool loadSaveStructure2(const char *pFileName)
{
int tid = ini.value("Factory/Run/" + WzString::number(runNum) + "/template").toInt();
DROID_TEMPLATE *psTempl = getTemplateFromMultiPlayerID(tid);
if (!psTempl)
{
ASSERT(psTempl, "No template found for template ID %d for %s (%d)", tid, objInfo(psStructure), id);
continue;
}
currentProd.psTemplate = psTempl;
ASSERT(psTempl, "No template found for template ID %d for %s (%d)", tid, objInfo(psStructure), id);
}
if (psFactory->psAssemblyPoint->factoryInc >= asProductionRun[psFactory->psAssemblyPoint->factoryType].size())
{
asProductionRun[psFactory->psAssemblyPoint->factoryType].resize(psFactory->psAssemblyPoint->factoryInc + 1);
}
asProductionRun[psFactory->psAssemblyPoint->factoryType][psFactory->psAssemblyPoint->factoryInc].push_back(currentProd);
}
Expand Down

0 comments on commit b804a5e

Please sign in to comment.