From b5053dbdec5749068aeb94ad665b15ea9e11432a Mon Sep 17 00:00:00 2001 From: Mircea Kitsune Date: Tue, 25 Oct 2011 00:35:14 +0300 Subject: [PATCH] Attempt to separate the drag function from the cheats code, so the sandbox system can use it too. I hope I did this properly. --- qcsrc/server/cheats.qc | 83 ++++++++++++++++++-------------- qcsrc/server/mutators/sandbox.qc | 5 +- 2 files changed, 48 insertions(+), 40 deletions(-) diff --git a/qcsrc/server/cheats.qc b/qcsrc/server/cheats.qc index 0d95c453a..6bed7eb32 100644 --- a/qcsrc/server/cheats.qc +++ b/qcsrc/server/cheats.qc @@ -665,6 +665,7 @@ float CheatCommand(float argc) } void crosshair_trace_plusvisibletriggers(entity pl); +float Drag(); void Drag_Begin(entity dragger, entity draggee, vector touchpoint); void Drag_Finish(entity dragger); float Drag_IsDraggable(entity draggee); @@ -682,6 +683,43 @@ float CheatFrame() { BEGIN_CHEAT_FUNCTION(); + switch(0) + { + default: + if(self.BUTTON_DRAG) + IS_CHEAT(0, 0, CHRAME_DRAG); + if(Drag()) + DID_CHEAT(); + break; + } + + END_CHEAT_FUNCTION(); +} + + + + + +// ENTITY DRAGGING + +void crosshair_trace_plusvisibletriggers(entity pl) +{ + entity first; + entity e; + first = findchainfloat(solid, SOLID_TRIGGER); + + for (e = first; e; e = e.chain) + if (e.model != "") + e.solid = SOLID_BSP; + + crosshair_trace(pl); + + for (e = first; e; e = e.chain) + e.solid = SOLID_TRIGGER; +} + +float Drag() +{ if(Drag_IsDragging(self)) { if(self.BUTTON_DRAG) @@ -721,44 +759,17 @@ float CheatFrame() crosshair_trace_plusvisibletriggers(self); if(trace_ent) if(Drag_IsDraggable(trace_ent)) - switch(0) - { - default: - IS_CHEAT(0, 0, CHRAME_DRAG); - if(trace_ent.draggedby) - Drag_Finish(trace_ent.draggedby); - if(trace_ent.tag_entity) - detach_sameorigin(trace_ent); - Drag_Begin(self, trace_ent, trace_endpos); - DID_CHEAT(); - break; - } + { + if(trace_ent.draggedby) + Drag_Finish(trace_ent.draggedby); + if(trace_ent.tag_entity) + detach_sameorigin(trace_ent); + Drag_Begin(self, trace_ent, trace_endpos); + return TRUE; + } } } - - END_CHEAT_FUNCTION(); -} - - - - - -// ENTITY DRAGGING - -void crosshair_trace_plusvisibletriggers(entity pl) -{ - entity first; - entity e; - first = findchainfloat(solid, SOLID_TRIGGER); - - for (e = first; e; e = e.chain) - if (e.model != "") - e.solid = SOLID_BSP; - - crosshair_trace(pl); - - for (e = first; e; e = e.chain) - e.solid = SOLID_TRIGGER; + return FALSE; } // on dragger: diff --git a/qcsrc/server/mutators/sandbox.qc b/qcsrc/server/mutators/sandbox.qc index 7b929ecd8..73701a922 100644 --- a/qcsrc/server/mutators/sandbox.qc +++ b/qcsrc/server/mutators/sandbox.qc @@ -31,15 +31,12 @@ MUTATOR_HOOKFUNCTION(sandbox_PlayerCommand) return TRUE; } - // spawn a new object + // spawn a new object with default properties entity e; e = spawn(); - e.realowner = self; e.classname = "object"; e.takedamage = DAMAGE_NO; - - // those properties are defaults that can be edited later e.movetype = MOVETYPE_TOSS; e.solid = SOLID_BSP; -- 2.39.2