]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Move non-cheat grabbing back into cheatfrae, so all code is in one place. Also remove...
authorMircea Kitsune <sonichedgehog_hyperblast00@yahoo.com>
Sun, 6 Nov 2011 11:45:51 +0000 (13:45 +0200)
committerMircea Kitsune <sonichedgehog_hyperblast00@yahoo.com>
Sun, 6 Nov 2011 11:45:51 +0000 (13:45 +0200)
qcsrc/server/cheats.qc
qcsrc/server/cl_client.qc
qcsrc/server/mutators/sandbox.qc

index ece6fa6cd11a8d6f4f0c17bda89ea3647019adfc..9d5da0d415c8b3ff96b03999128fe38aa096f4db 100644 (file)
@@ -692,18 +692,51 @@ float CheatFrame()
        switch(0)
        {
                default:
-                       if(self.BUTTON_DRAG && !autocvar_g_grab)
-                       {
-                               // consider dragging a cheat only if g_grab is disabled
-                               IS_CHEAT(0, 0, CHRAME_DRAG);
-                       }
                        if(autocvar_sv_cheats)
                        {
-                               // only use cheat dragging if cheats are enabled
+                               // use cheat dragging if cheats are enabled
+                               IS_CHEAT(0, 0, CHRAME_DRAG);
                                crosshair_trace_plusvisibletriggers(self);
-                               if(Drag(trace_ent, TRUE) && !autocvar_g_grab)
+                               if(Drag(trace_ent, TRUE))
                                        DID_CHEAT();
                        }
+                       else if(autocvar_g_grab)
+                       {
+                               // drag is TRUE if the object can be picked up. While an object is being carried, the Drag() function
+                               // must execute for it either way, otherwise it would cause bugs if it went out of the player's trace.
+                               // This also makes sure that an object can only pe picked up if in range, but does not get dropped if
+                               // it goes out of range while slinging it around.
+
+                               float drag;
+                               makevectors(self.v_angle);
+                               WarpZone_TraceLine(self.origin + self.view_ofs, self.origin + self.view_ofs + v_forward * autocvar_g_sandbox_editor_distance_edit, MOVE_NORMAL, self);
+                               switch(trace_ent.grab)
+                               {
+                                       case 0: // can't grab
+                                               break;
+                                       case 1: // owner can grab
+                                               if(trace_ent.owner == self || trace_ent.realowner == self)
+                                                       drag = TRUE;
+                                               break;
+                                       case 2: // owner and team mates can grab
+                                               if(trace_ent.owner == self || trace_ent.realowner == self)
+                                                       drag = TRUE;
+                                               if(!IsDifferentTeam(trace_ent.owner, self) || !IsDifferentTeam(trace_ent.realowner, self))
+                                                       drag = TRUE;
+                                               break;
+                                       case 3: // anyone can grab
+                                               drag = TRUE;
+                                               break;
+                                       default:
+                                               break;
+                               }
+                               Drag(trace_ent, drag); // execute dragging
+                       }
+                       else if(self.BUTTON_DRAG)
+                       {
+                               // consider dragging a cheat if g_grab is disabled
+                               IS_CHEAT(0, 0, CHRAME_DRAG);
+                       }
                        break;
        }
 
@@ -841,6 +874,8 @@ void Drag_Finish(entity dragger)
 float Drag_IsDraggable(entity draggee)
 {
        // TODO add more checks for bad stuff here
+       if(draggee == world)
+               return FALSE;
        if(draggee.classname == "func_bobbing")
                return FALSE;
        if(draggee.classname == "door") // FIXME find out why these must be excluded, or work around the problem (trying to drag these causes like 4 fps)
index 1881fcb3a36eeb79f89add57dcb4bcec0f0ef795..7445c6b38b0cf5f2c4f4f43ea47ea3cf11ab1efc 100644 (file)
@@ -2792,43 +2792,6 @@ void PlayerPreThink (void)
 
        PrintWelcomeMessage();
 
-       // if the player is close enough to a dragable entity, they can grab it
-       if(autocvar_g_grab && !autocvar_sv_cheats) // cheat dragging is used instead
-       {
-               // drag is TRUE if the object can be picked up. While an object is being carried, the Drag() function
-               // must execute for it either way, otherwise it would cause bugs if it went out of the player's trace.
-               // This also makes sure that an object can only pe picked up if in range, but does not get dropped if
-               // it goes out of range while slinging it around.
-
-               float drag;
-               makevectors(self.v_angle);
-               WarpZone_TraceLine(self.origin + self.view_ofs, self.origin + self.view_ofs + v_forward * autocvar_g_sandbox_editor_distance_edit, MOVE_NORMAL, self);
-               if(trace_ent != world)
-               {
-                       switch(trace_ent.grab)
-                       {
-                               case 0: // can't grab
-                                       break;
-                               case 1: // owner can grab
-                                       if(trace_ent.owner == self || trace_ent.realowner == self)
-                                               drag = TRUE;
-                                       break;
-                               case 2: // owner and team mates can grab
-                                       if(trace_ent.owner == self || trace_ent.realowner == self)
-                                               drag = TRUE;
-                                       if(!IsDifferentTeam(trace_ent.owner, self) || !IsDifferentTeam(trace_ent.realowner, self))
-                                               drag = TRUE;
-                                       break;
-                               case 3: // anyone can grab
-                                       drag = TRUE;
-                                       break;
-                               default:
-                                       break;
-                       }
-               }
-               Drag(trace_ent, drag); // execute dragging
-       }
-
        if(self.classname == "player") {
 //             if(self.netname == "Wazat")
 //                     bprint(self.classname, "\n");
index 73436eb3f81cee08e24e0a8183baead268faafd6..2c4b27034e667298af111d6721410612d6d03392 100644 (file)
@@ -716,31 +716,6 @@ MUTATOR_HOOKFUNCTION(sandbox_PlayerCommand)
        return FALSE;
 }
 
-MUTATOR_HOOKFUNCTION(sandbox_PlayerPreThink)
-{
-       // if the player is close enough to their object, they can drag it
-
-       if(autocvar_sv_cheats)
-               return FALSE; // cheat dragging is used instead
-
-       // grab is TRUE if the object can be picked up. While an object is being carried, the Drag() function
-       // must execute for it either way, otherwise it would cause bugs if it went out of the player's trace.
-       // This also makes sure that an object can only pe picked up if in range, but does not get dropped if
-       // it goes out of range while slinging it around.
-
-       entity e;
-       float grab;
-
-       e = sandbox_ObjectEdit_Get(TRUE);
-       if(e != world && vlen(e.origin - self.origin) <= autocvar_g_sandbox_editor_distance_edit)
-               grab = TRUE;
-
-       if(Drag(e, grab)) // execute dragging
-               return TRUE;
-
-       return FALSE;
-}
-
 float autosave_time;
 MUTATOR_HOOKFUNCTION(sandbox_StartFrame)
 {
@@ -759,7 +734,6 @@ MUTATOR_DEFINITION(sandbox)
 {
        MUTATOR_HOOK(SV_ParseClientCommand, sandbox_PlayerCommand, CBC_ORDER_ANY);
        MUTATOR_HOOK(SV_StartFrame, sandbox_StartFrame, CBC_ORDER_ANY);
-       MUTATOR_HOOK(PlayerPreThink, sandbox_PlayerPreThink, CBC_ORDER_ANY);
 
        MUTATOR_ONADD
        {