From: Mircea Kitsune Date: Thu, 27 Oct 2011 13:23:33 +0000 (+0300) Subject: Fix detaching of objects. Attached objects are no longer traced (and would be impossi... X-Git-Tag: xonotic-v0.6.0~35^2~18^2~123 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=4f3f31faa1b8764fcd4f1c1c65d01de3aaf8c59b;p=xonotic%2Fxonotic-data.pk3dir.git 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. --- 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()