remove a structure from a game without any visible effects bDestroy = true if the object is to be destroyed (for example used to change the type of wall at a location)
| 4563 | // bDestroy = true if the object is to be destroyed |
| 4564 | // (for example used to change the type of wall at a location) |
| 4565 | bool removeStruct(STRUCTURE *psDel, bool bDestroy) |
| 4566 | { |
| 4567 | bool resourceFound = false; |
| 4568 | FLAG_POSITION *psAssemblyPoint = nullptr; |
| 4569 | |
| 4570 | ASSERT_OR_RETURN(false, psDel != nullptr, "Invalid structure pointer"); |
| 4571 | |
| 4572 | int prevResearchState = intGetResearchState(); |
| 4573 | |
| 4574 | if (bDestroy) |
| 4575 | { |
| 4576 | removeStructFromMap(psDel); |
| 4577 | } |
| 4578 | |
| 4579 | if (bDestroy) |
| 4580 | { |
| 4581 | //if the structure is a resource extractor, need to put the resource back in the map |
| 4582 | /*ONLY IF ANY POWER LEFT - HACK HACK HACK!!!! OIL POOLS NEED TO KNOW |
| 4583 | HOW MUCH IS THERE && NOT RES EXTRACTORS */ |
| 4584 | if (psDel->pStructureType->type == REF_RESOURCE_EXTRACTOR) |
| 4585 | { |
| 4586 | FEATURE *psOil = buildFeature(oilResFeature, psDel->pos.x, psDel->pos.y, false); |
| 4587 | memcpy(psOil->seenThisTick, psDel->visible, sizeof(psOil->seenThisTick)); |
| 4588 | resourceFound = true; |
| 4589 | } |
| 4590 | } |
| 4591 | |
| 4592 | if (psDel->pStructureType->type == REF_RESOURCE_EXTRACTOR) |
| 4593 | { |
| 4594 | //tell associated Power Gen |
| 4595 | releaseResExtractor(psDel); |
| 4596 | //tell keybind that this is going away (to prevent dangling pointer in kf_JumpToResourceExtractor) |
| 4597 | keybindInformResourceExtractorRemoved(psDel); |
| 4598 | } |
| 4599 | |
| 4600 | if (psDel->pStructureType->type == REF_POWER_GEN) |
| 4601 | { |
| 4602 | //tell associated Res Extractors |
| 4603 | releasePowerGen(psDel); |
| 4604 | } |
| 4605 | |
| 4606 | //check for a research topic currently under way |
| 4607 | if (psDel->pStructureType->type == REF_RESEARCH) |
| 4608 | { |
| 4609 | if (psDel->pFunctionality->researchFacility.psSubject) |
| 4610 | { |
| 4611 | //cancel the topic |
| 4612 | cancelResearch(psDel, ModeImmediate); |
| 4613 | } |
| 4614 | } |
| 4615 | |
| 4616 | if (psDel->pStructureType->type == REF_REPAIR_FACILITY) |
| 4617 | { |
| 4618 | if (psDel->pFunctionality && psDel->pFunctionality->repairFacility.state == RepairState::Repairing) |
| 4619 | { |
| 4620 | if (psDel->pFunctionality->repairFacility.psObj != nullptr) |
| 4621 | { |
| 4622 | droidRepairStopped(castDroid(psDel->pFunctionality->repairFacility.psObj), psDel); |
no test coverage detected