Skip to content

Commit

Permalink
checkReferences: Additional structure reference checks
Browse files Browse the repository at this point in the history
  • Loading branch information
past-due committed Mar 3, 2024
1 parent 6186e8d commit 2dce1a5
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/objmem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,35 @@ static bool checkReferences(BASE_OBJECT *psVictim)
{
ASSERT_OR_RETURN(false, psStruct->psTarget[i] != psVictim, BADREF(psStruct->targetFunc[i], psStruct->targetLine[i]));
}

if (psStruct->pFunctionality && psStruct->pStructureType)
{
switch (psStruct->pStructureType->type)
{
case REF_FACTORY:
case REF_CYBORG_FACTORY:
case REF_VTOL_FACTORY:
{
FACTORY *psFactory = &psStruct->pFunctionality->factory;
ASSERT_OR_RETURN(false, psFactory->psCommander != psVictim, "Illegal reference to object %" PRIu32 " in FACTORY.psCommander", psFactory->psCommander->id);
break;
}
case REF_REPAIR_FACILITY:
{
REPAIR_FACILITY *psRepairFac = &psStruct->pFunctionality->repairFacility;
ASSERT_OR_RETURN(false, psRepairFac->psObj != psVictim, "Illegal reference to object %" PRIu32 " in REPAIR_FACILITY.psObj", psRepairFac->psObj->id);
break;
}
case REF_REARM_PAD:
{
REARM_PAD *psReArmPad = &psStruct->pFunctionality->rearmPad;
ASSERT_OR_RETURN(false, psReArmPad->psObj != psVictim, "Illegal reference to object %" PRIu32 " in REARM_PAD.psObj", psReArmPad->psObj->id);
break;
}
default:
break;
}
}
}
for (const DROID *psDroid : apsDroidLists[plr])
{
Expand Down

0 comments on commit 2dce1a5

Please sign in to comment.