]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Use a different way to check distance and dragging requirements. This fixes a bug...
authorMircea Kitsune <sonichedgehog_hyperblast00@yahoo.com>
Mon, 24 Oct 2011 23:08:42 +0000 (02:08 +0300)
committerMircea Kitsune <sonichedgehog_hyperblast00@yahoo.com>
Mon, 24 Oct 2011 23:08:42 +0000 (02:08 +0300)
qcsrc/server/cheats.qc
qcsrc/server/cheats.qh
qcsrc/server/mutators/sandbox.qc

index 6995b415a4d0c21d743ad2716d8caf873645407b..e5a78a05edd5fa59f6f03358c03bf6d497fcead0 100644 (file)
@@ -664,7 +664,7 @@ float CheatCommand(float argc)
        END_CHEAT_FUNCTION();
 }
 
-float Drag(entity e, float dist);
+float Drag(entity e, float candrag);
 void Drag_Begin(entity dragger, entity draggee, vector touchpoint);
 void Drag_Finish(entity dragger);
 float Drag_IsDraggable(entity draggee);
@@ -692,9 +692,9 @@ float CheatFrame()
                        }
                        if(autocvar_sv_cheats)
                        {
-                               // only use non-sandbox dragging if cheats are enabled
+                               // only use cheat dragging if cheats are enabled
                                crosshair_trace_plusvisibletriggers(self);
-                               if(Drag(trace_ent, FALSE) && !cvar("g_sandbox"))
+                               if(Drag(trace_ent, TRUE) && !cvar("g_sandbox"))
                                        DID_CHEAT();
                        }
                        break;
@@ -709,12 +709,8 @@ float CheatFrame()
 
 // ENTITY DRAGGING
 
-float Drag(entity e, float dist)
+float Drag(entity e, float candrag)
 {
-       float inrange;
-       if(vlen(e.origin - self.origin) <= dist || !dist)
-               inrange = TRUE;
-
        if(Drag_IsDragging(self))
        {
                if(self.BUTTON_DRAG)
@@ -749,7 +745,7 @@ float Drag(entity e, float dist)
        else
        {
                if(Drag_CanDrag(self))
-                       if(self.BUTTON_DRAG && inrange)
+                       if(self.BUTTON_DRAG && candrag)
                        {
                                if(e)
                                        if(Drag_IsDraggable(e))
index b563c0e13b841a539a75c46ce35c3cfe68660371..dec12cbdb84b51c74c4b2be781e8c1bd27a003fb 100644 (file)
@@ -12,4 +12,4 @@ float CheatFrame();
 
 void Drag_MoveDrag(entity from, entity to); // call this from CopyBody
 
-float Drag(entity e, float dist); // used by sandbox code
\ No newline at end of file
+float Drag(entity e, float candrag); // used by sandbox code
\ No newline at end of file
index 685425102672b1597bff062b5ccb826a6ab74a82..ea41dcea3b7b092d737256b85028b8ae8b66ca7c 100644 (file)
@@ -110,10 +110,13 @@ MUTATOR_HOOKFUNCTION(sandbox_PlayerPreThink)
                return FALSE; // cheats already allow dragging all objects
 
        crosshair_trace_plusvisibletriggers(self);
-       if(trace_ent.classname == "object")
-               if(Drag(trace_ent, autocvar_g_sandbox_editor_distance_edit)) // execute the dragging
-                       if(autocvar_g_sandbox_info)
-                               print(strcat(self.netname, " grabbed an object at origin ", vtos(trace_ent.origin), "\n"));
+
+       float candrag;
+       if(trace_ent.classname == "object" && vlen(trace_ent.origin - self.origin) <= autocvar_g_sandbox_editor_distance_edit)
+               candrag = TRUE; // object can be picked up
+       if(Drag(trace_ent, candrag)) // execute dragging
+               if(autocvar_g_sandbox_info)
+                       print(strcat(self.netname, " grabbed an object at origin ", vtos(trace_ent.origin), "\n"));
 
        return FALSE;
 }