Skip to content

Commit

Permalink
Do not crash on build cancelations. Hopefully closes ticket:3807
Browse files Browse the repository at this point in the history
  • Loading branch information
perim committed Nov 24, 2012
1 parent ffda8b2 commit 2884e6d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/structure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -993,16 +993,16 @@ bool structSetManufacture(STRUCTURE *psStruct, DROID_TEMPLATE *psTempl, QUEUE_MO
|| psStruct->pStructureType->type == REF_VTOL_FACTORY, "Invalid structure type %d for factory",
(int)psStruct->pStructureType->type);
/* psTempl might be NULL if the build is being cancelled in the middle */

ASSERT_OR_RETURN(false, (validTemplateForFactory(psTempl, psStruct) && researchedTemplate(psTempl, psStruct->player, true)) || psStruct->player == scavengerPlayer() || !bMultiPlayer, "Wrong template for player %d factory, type %d.", psStruct->player, psStruct->pStructureType->type);
ASSERT_OR_RETURN(false, !psTempl || (validTemplateForFactory(psTempl, psStruct) && researchedTemplate(psTempl, psStruct->player, true))
|| psStruct->player == scavengerPlayer() || !bMultiPlayer,
"Wrong template for player %d factory, type %d.", psStruct->player, psStruct->pStructureType->type);

psFact = &psStruct->pFunctionality->factory;

if (mode == ModeQueue)
{
sendStructureInfo(psStruct, STRUCTUREINFO_MANUFACTURE, psTempl);
setStatusPendingStart(*psFact, psTempl);

return true; // Wait for our message before doing anything.
}

Expand Down
1 change: 1 addition & 0 deletions src/template.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ static bool researchedWeap(DROID_TEMPLATE *psCurr, int player, int weapIndex, bo

bool researchedTemplate(DROID_TEMPLATE *psCurr, int player, bool allowRedundant)
{
ASSERT_OR_RETURN(false, psCurr, "Given a null template");
// super hack -- cyborgs and transports are special, only check their body
switch (psCurr->droidType)
{
Expand Down

0 comments on commit 2884e6d

Please sign in to comment.