]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Clean up a few comments and reduce code indentation in cheats.qc
authorterencehill <piuntn@gmail.com>
Wed, 3 Jun 2020 20:06:47 +0000 (22:06 +0200)
committerterencehill <piuntn@gmail.com>
Wed, 3 Jun 2020 20:06:47 +0000 (22:06 +0200)
qcsrc/server/cheats.qc

index 186677df9492f4caf1fa7c7d22711a62692ed133..760162e313f2e87933654f9236435b0e53f827dd 100644 (file)
@@ -62,13 +62,11 @@ void CheatShutdown()
 
 float CheatsAllowed(entity this, float i, int argc, float fr) // the cheat gets passed as argument for possible future ACL checking
 {
-       // dead people cannot cheat
        if(IS_DEAD(this))
                return 0;
        if(gamestart_sv_cheats < 2 && !IS_PLAYER(this))
                return 0;
 
-       // sv_clones
        if(i == CHIMPULSE_CLONE_MOVING.impulse || i == CHIMPULSE_CLONE_STANDING.impulse)
                if(this.lip < sv_clones)
                        return 1;
@@ -77,7 +75,6 @@ float CheatsAllowed(entity this, float i, int argc, float fr) // the cheat gets
        if(this.maycheat)
                return 1;
 
-       // sv_cheats
        if(gamestart_sv_cheats && autocvar_sv_cheats)
                return 1;
 
@@ -126,6 +123,7 @@ void info_autoscreenshot_findtarget(entity this)
 }
 spawnfunc(info_autoscreenshot)
 {
+       // this one just has to exist
        if(++num_autoscreenshot > autocvar_g_max_info_autoscreenshot)
        {
                objerror(this, "Too many info_autoscreenshot entitites. FAIL!");
@@ -133,7 +131,6 @@ spawnfunc(info_autoscreenshot)
        }
        if(this.target != "")
                InitializeEntity(this, info_autoscreenshot_findtarget, INITPRIO_FINDTARGET);
-       // this one just has to exist
 }
 
 float CheatImpulse(entity this, int imp)
@@ -803,59 +800,51 @@ float Drag(entity this, float force_allow_pick, float ischeat)
                                        Drag_Finish(this);
                                }
                        }
-                       else
+                       else if(Drag_CanDrag(this) && PHYS_INPUT_BUTTON_DRAG(this))
                        {
-                               if(Drag_CanDrag(this))
-                                       if(PHYS_INPUT_BUTTON_DRAG(this))
-                                       {
-                                               crosshair_trace_plusvisibletriggers(this);
-                                               entity e = trace_ent;
-                                               float pick = force_allow_pick;
-                                               if (e && !pick)
-                                               {
-                                                       // pick 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.
+                               crosshair_trace_plusvisibletriggers(this);
+                               entity e = trace_ent;
+                               float pick = force_allow_pick;
+                               if (e && !pick && vdist(this.origin - e.origin, <=, autocvar_g_grab_range))
+                               {
+                                       // pick 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.
 
-                                                       if(vdist(this.origin - e.origin, <=, autocvar_g_grab_range))
-                                                       {
-                                                               switch(e.grab)
-                                                               {
-                                                                       case 0: // can't grab
-                                                                               break;
-                                                                       case 1: // owner can grab
-                                                                               if(e.owner == this || e.realowner == this)
-                                                                                       pick = true;
-                                                                               break;
-                                                                       case 2: // owner and team mates can grab
-                                                                               if(SAME_TEAM(e.owner, this) || SAME_TEAM(e.realowner, this) || e.team == this.team)
-                                                                                       pick = true;
-                                                                               break;
-                                                                       case 3: // anyone can grab
-                                                                               pick = true;
-                                                                               break;
-                                                                       default:
-                                                                               break;
-                                                               }
-                                                       }
-                                               }
-                                               // Find e and pick
-                                               if(e && pick)
-                                                       if(Drag_IsDraggable(e, this))
-                                                       {
-                                                               if(ischeat)
-                                                                       IS_CHEAT(this, 0, 0, CHRAME_DRAG);
-                                                               if(e.draggedby)
-                                                                       Drag_Finish(e.draggedby);
-                                                               if(e.tag_entity)
-                                                                       detach_sameorigin(e);
-                                                               Drag_Begin(this, e, trace_endpos);
-                                                               if(ischeat)
-                                                                       DID_CHEAT();
-                                                               return true;
-                                                       }
+                                       switch(e.grab)
+                                       {
+                                               case 0: // can't grab
+                                                       break;
+                                               case 1: // owner can grab
+                                                       if(e.owner == this || e.realowner == this)
+                                                               pick = true;
+                                                       break;
+                                               case 2: // owner and team mates can grab
+                                                       if(SAME_TEAM(e.owner, this) || SAME_TEAM(e.realowner, this) || e.team == this.team)
+                                                               pick = true;
+                                                       break;
+                                               case 3: // anyone can grab
+                                                       pick = true;
+                                                       break;
+                                               default:
+                                                       break;
                                        }
+                               }
+                               // Find e and pick
+                               if(e && pick && Drag_IsDraggable(e, this))
+                               {
+                                       if(ischeat)
+                                               IS_CHEAT(this, 0, 0, CHRAME_DRAG);
+                                       if(e.draggedby)
+                                               Drag_Finish(e.draggedby);
+                                       if(e.tag_entity)
+                                               detach_sameorigin(e);
+                                       Drag_Begin(this, e, trace_endpos);
+                                       if(ischeat)
+                                               DID_CHEAT();
+                                       return true;
+                               }
                        }
                        break;
        }
@@ -932,8 +921,8 @@ float Drag_IsDraggable(entity draggee, entity dragger)
                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)
                return false; // probably due to BSP collision
-//     if(draggee.model == "")
-//             return false;
+       //if(draggee.model == "")
+       //      return false;
 
        return ((draggee.draggable) ? draggee.draggable(draggee, dragger) : true);
 }