Unattaches an object from its parent
| 637 | |
| 638 | // Unattaches an object from its parent |
| 639 | bool 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 |
| 676 | bool UnattachChild(object *parent, char parent_ap) { |
no test coverage detected