MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / ObjDeleteDead

Function ObjDeleteDead

Descent3/object.cpp:2012–2104  ·  view source on GitHub ↗

------------------------------------------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

2010
2011// ------------------------------------------------------------------------------------------------------------------
2012void ObjDeleteDead() {
2013 int i;
2014 object *objp;
2015 int local_dead_player_object = -1;
2016
2017 // Move all objects
2018 objp = Objects;
2019
2020 for (i = 0; i <= Highest_object_index; i++) {
2021 if ((objp->type != OBJ_NONE) && (objp->flags & OF_DEAD)) {
2022 if (objp->flags & OF_INFORM_DESTROY_TO_LG) {
2023 Level_goals.Inform(LIT_OBJECT, LGF_COMP_DESTROY, objp->handle);
2024 }
2025
2026 if (objp->flags & OF_INPLAYERINVENTORY) {
2027 // this object is in a player inventory somewhere...remove it first!
2028 InventoryRemoveObject(objp->handle);
2029 }
2030
2031 if (objp->type == OBJ_DUMMY) {
2032 // unghost the object before deleting it
2033 ObjUnGhostObject(i);
2034
2035 // tell clients to unghost
2036 if ((Game_mode & GM_MULTI) && (Netgame.local_role != LR_CLIENT)) {
2037 MultiSendGhostObject(&Objects[i], false);
2038 }
2039 }
2040
2041 if (objp->flags & OF_POLYGON_OBJECT) {
2042 if (objp->flags & OF_ATTACHED) {
2043 tOSIRISEventInfo ei;
2044 ei.evt_child_died.it_handle = objp->handle;
2045
2046 Osiris_CallEvent(ObjGet(objp->attach_ultimate_handle), EVT_CHILD_DIED, &ei);
2047 }
2048
2049 UnattachFromParent(objp);
2050 UnattachChildren(objp);
2051 }
2052
2053 // Execute script for death
2054 tOSIRISEventInfo ei;
2055 ei.evt_destroy.is_dying = 1;
2056 Osiris_CallEvent(objp, EVT_DESTROY, &ei);
2057
2058 if (Game_mode & GM_MULTI) {
2059 DLLInfo.me_handle = DLLInfo.it_handle = objp->handle;
2060 CallGameDLL(EVT_GAMEOBJDESTROYED, &DLLInfo);
2061 }
2062
2063 // detach any scripts attached
2064 Osiris_DetachScriptsFromObject(objp);
2065
2066 // if it's flag to tell the clients to remove is set, tell them now
2067 if ((Game_mode & GM_MULTI) && (Netgame.local_role != LR_CLIENT)) {
2068 bool removed = false;
2069

Callers 1

ObjDoFrameAllFunction · 0.85

Calls 13

InventoryRemoveObjectFunction · 0.85
ObjUnGhostObjectFunction · 0.85
MultiSendGhostObjectFunction · 0.85
Osiris_CallEventFunction · 0.85
ObjGetFunction · 0.85
UnattachFromParentFunction · 0.85
UnattachChildrenFunction · 0.85
CallGameDLLFunction · 0.85
MultiSendRemoveObjectFunction · 0.85
ObjDeleteFunction · 0.85
VisEffectDeleteDeadFunction · 0.85

Tested by

no test coverage detected