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

Function UnattachFromParent

Descent3/attach.cpp:639–673  ·  view source on GitHub ↗

Unattaches an object from its parent

Source from the content-addressed store, hash-verified

637
638// Unattaches an object from its parent
639bool UnattachFromParent(object *child) {
640 if (!(child->flags & OF_ATTACHED))
641 return false;
642
643 AttachPropagateMass(child, false);
644
645 object *parent = ObjGet(child->attach_parent_handle);
646 ASSERT(parent);
647
648 poly_model *parent_pm = &Poly_models[parent->rtype.pobj_info.model_num];
649 int i;
650
651 for (i = 0; i < parent_pm->n_attach; i++) {
652 if (parent->attach_children[i] == child->handle) {
653 parent->attach_children[i] = OBJECT_HANDLE_NONE;
654 break;
655 }
656 }
657
658 // ASSERT(i < parent_pm->n_attach); // Didn't find its parent? Get chris!
659
660 child->flags &= ~OF_ATTACHED;
661 child->attach_parent_handle = OBJECT_HANDLE_NONE;
662 child->attach_ultimate_handle = OBJECT_HANDLE_NONE;
663
664 ProprogateUltimateAttachParent(child, child->handle);
665 if ((Game_mode & GM_MULTI) && (Netgame.local_role == LR_SERVER)) {
666 MultiSendUnattach(child);
667 }
668 if (Demo_flags == DF_RECORDING) {
669 DemoWriteUnattachObj(child);
670 }
671
672 return true;
673}
674
675// Unattaches a child from an attach point
676bool UnattachChild(object *parent, char parent_ap) {

Callers 8

osipf_UnattachFromParentFunction · 0.85
MultiDoUnattachFunction · 0.85
dUnattachFromParentFunction · 0.85
ai_moveFunction · 0.85
ObjDeleteDeadFunction · 0.85
DemoReadUnattachObjFunction · 0.85
UnattachChildFunction · 0.85
UnattachChildrenFunction · 0.85

Calls 5

AttachPropagateMassFunction · 0.85
ObjGetFunction · 0.85
MultiSendUnattachFunction · 0.85
DemoWriteUnattachObjFunction · 0.85

Tested by

no test coverage detected