]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/cheats.qc
Use a different way to check distance and dragging requirements. This fixes a bug...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / cheats.qc
index 0d95c453a1e6685b1d7032dd06dd520670ae628b..e5a78a05edd5fa59f6f03358c03bf6d497fcead0 100644 (file)
@@ -664,7 +664,7 @@ float CheatCommand(float argc)
        END_CHEAT_FUNCTION();
 }
 
-void crosshair_trace_plusvisibletriggers(entity pl);
+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);
@@ -682,6 +682,35 @@ float CheatFrame()
 {
        BEGIN_CHEAT_FUNCTION();
 
+       switch(0)
+       {
+               default:
+                       if(self.BUTTON_DRAG && !cvar("g_sandbox"))
+                       {
+                               // consider dragging a cheat only if sandbox mode is disabled
+                               IS_CHEAT(0, 0, CHRAME_DRAG);
+                       }
+                       if(autocvar_sv_cheats)
+                       {
+                               // only use cheat dragging if cheats are enabled
+                               crosshair_trace_plusvisibletriggers(self);
+                               if(Drag(trace_ent, TRUE) && !cvar("g_sandbox"))
+                                       DID_CHEAT();
+                       }
+                       break;
+       }
+
+       END_CHEAT_FUNCTION();
+}
+
+
+
+
+
+// ENTITY DRAGGING
+
+float Drag(entity e, float candrag)
+{
        if(Drag_IsDragging(self))
        {
                if(self.BUTTON_DRAG)
@@ -716,49 +745,21 @@ float CheatFrame()
        else
        {
                if(Drag_CanDrag(self))
-                       if(self.BUTTON_DRAG)
+                       if(self.BUTTON_DRAG && candrag)
                        {
-                               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(e)
+                                       if(Drag_IsDraggable(e))
+                                       {
+                                                       if(e.draggedby)
+                                                               Drag_Finish(e.draggedby);
+                                                       if(e.tag_entity)
+                                                               detach_sameorigin(e);
+                                                       Drag_Begin(self, e, 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: