]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Attempt to separate the drag function from the cheats code, so the sandbox system...
authorMircea Kitsune <sonichedgehog_hyperblast00@yahoo.com>
Mon, 24 Oct 2011 21:35:14 +0000 (00:35 +0300)
committerMircea Kitsune <sonichedgehog_hyperblast00@yahoo.com>
Mon, 24 Oct 2011 21:35:14 +0000 (00:35 +0300)
qcsrc/server/cheats.qc
qcsrc/server/mutators/sandbox.qc

index 0d95c453a1e6685b1d7032dd06dd520670ae628b..6bed7eb322ea8ed09fc7b04a676d9cdf9d7a39bb 100644 (file)
@@ -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:
index 7b929ecd841a41bfa4094fad5440ebb51a10ab8b..73701a9225d83565563b98ffa3d26b50cb007151 100644 (file)
@@ -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;