Use a different way to check distance and dragging requirements. This fixes a bug...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / mutators / sandbox.qc
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;
 }