From 4f3f31faa1b8764fcd4f1c1c65d01de3aaf8c59b Mon Sep 17 00:00:00 2001 From: Mircea Kitsune Date: Thu, 27 Oct 2011 16:23:33 +0300 Subject: [PATCH] Fix detaching of objects. Attached objects are no longer traced (and would be impossible to edit), so the detach function addresses the parent instead. When used, all objects attached to it get detached. --- qcsrc/server/mutators/sandbox.qc | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/qcsrc/server/mutators/sandbox.qc b/qcsrc/server/mutators/sandbox.qc index 24b11abef..bf47b1753 100644 --- a/qcsrc/server/mutators/sandbox.qc +++ b/qcsrc/server/mutators/sandbox.qc @@ -75,9 +75,11 @@ void sandbox_EditObject_Scale(entity e, float f) void sandbox_AttachObject_Set(entity e, entity parent, string s) { + // attaches e to parent on string s + e.movetype = MOVETYPE_FOLLOW; e.solid = SOLID_NOT; - e.takedamage = DAMAGE_NO; + e.takedamage = DAMAGE_NO; // no longer trace it either setorigin(e, parent.origin); setattachment(e, parent, s); @@ -86,12 +88,22 @@ void sandbox_AttachObject_Set(entity e, entity parent, string s) void sandbox_AttachObject_Remove(entity e) { - e.movetype = MOVETYPE_TOSS; - e.solid = SOLID_BBOX; - e.takedamage = DAMAGE_AIM; + // detaches any object attached to e + + entity head; + for(head = world; (head = find(head, classname, "object")); ) + { + if(head.owner == e) + { + head.movetype = MOVETYPE_TOSS; + head.solid = SOLID_BBOX; + head.takedamage = DAMAGE_AIM; - setattachment(e, world, ""); - e.owner = world; + setattachment(head, world, ""); + setorigin(head, e.origin); // prevents a bug + head.owner = world; + } + } } entity sandbox_SpawnObject() -- 2.39.2