Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

structureBuild: Improve cleanup when starting to demolish #4020

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/objmem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
42 changes: 42 additions & 0 deletions src/structure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Loading