diff --git a/src/objmem.cpp b/src/objmem.cpp index af86063a757..12f641fab97 100644 --- a/src/objmem.cpp +++ b/src/objmem.cpp @@ -184,13 +184,13 @@ static bool _checkStructReferences(BASE_OBJECT *psVictim, const StructureList& p case REF_REPAIR_FACILITY: { REPAIR_FACILITY *psRepairFac = &psStruct->pFunctionality->repairFacility; - ASSERT_OR_RETURN_REPORT(false, psRepairFac->psObj != psVictim, "Illegal reference to p%d:%s:%" PRIu32 " (%s) in REPAIR_FACILITY.psObj in %s[%u] (state=%d)", (int)psVictim->player, objTypeToStr(psVictim->type), psVictim->id, getObjDebugDescriptiveName(psVictim), listName, player, (int)psRepairFac->state); + ASSERT_OR_RETURN_REPORT(false, psRepairFac->psObj != psVictim, "Illegal reference to p%d:%s:%" PRIu32 " (%s) in REPAIR_FACILITY.psObj in %s[%u] (state=%d) (struct.status: %d)", (int)psVictim->player, objTypeToStr(psVictim->type), psVictim->id, getObjDebugDescriptiveName(psVictim), listName, player, (int)psRepairFac->state, (int)psStruct->status); break; } case REF_REARM_PAD: { REARM_PAD *psReArmPad = &psStruct->pFunctionality->rearmPad; - ASSERT_OR_RETURN_REPORT(false, psReArmPad->psObj != psVictim, "Illegal reference to p%d:%s:%" PRIu32 " (%s) in REARM_PAD.psObj in %s[%u]", (int)psVictim->player, objTypeToStr(psVictim->type), psVictim->id, getObjDebugDescriptiveName(psVictim), listName, player); + ASSERT_OR_RETURN_REPORT(false, psReArmPad->psObj != psVictim, "Illegal reference to p%d:%s:%" PRIu32 " (%s) in REARM_PAD.psObj in %s[%u] (struct.status: %d)", (int)psVictim->player, objTypeToStr(psVictim->type), psVictim->id, getObjDebugDescriptiveName(psVictim), listName, player, (int)psStruct->status); break; } default: diff --git a/src/structure.cpp b/src/structure.cpp index 2fe90849eff..001cbdbcd19 100644 --- a/src/structure.cpp +++ b/src/structure.cpp @@ -990,12 +990,54 @@ void structureBuild(STRUCTURE *psStruct, DROID *psDroid, int buildPoints, int bu switch (psStruct->pStructureType->type) { + case REF_FACTORY: + case REF_CYBORG_FACTORY: + case REF_VTOL_FACTORY: + { + if (psStruct->pFunctionality) + { + FACTORY *psFactory = &psStruct->pFunctionality->factory; + if (psFactory->psCommander) + { + //remove the commander from the factory + syncDebugDroid(psFactory->psCommander, '-'); + assignFactoryCommandDroid(psStruct, nullptr); + } + } + break; + } case REF_POWER_GEN: releasePowerGen(psStruct); break; case REF_RESOURCE_EXTRACTOR: releaseResExtractor(psStruct); break; + case REF_REPAIR_FACILITY: + { + if (psStruct->pFunctionality) + { + REPAIR_FACILITY *psRepairFac = &psStruct->pFunctionality->repairFacility; + if (psRepairFac->psObj) + { + psRepairFac->psObj = nullptr; + psRepairFac->state = RepairState::Idle; + } + } + break; + } + case REF_REARM_PAD: + { + if (psStruct->pFunctionality) + { + REARM_PAD *psReArmPad = &psStruct->pFunctionality->rearmPad; + if (psReArmPad->psObj) + { + // Possible TODO: Need to do anything with the droid? (order it to find a new place to rearm?) + psReArmPad->psObj = nullptr; + } + } + break; + } default: break; }