]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Move some race related stuff out of the main physics function
authorMario <mario@smbclan.net>
Wed, 14 Oct 2015 16:27:25 +0000 (02:27 +1000)
committerMario <mario@smbclan.net>
Wed, 14 Oct 2015 16:27:25 +0000 (02:27 +1000)
qcsrc/common/physics.qc
qcsrc/server/mutators/gamemode_cts.qc
qcsrc/server/mutators/gamemode_race.qc
qcsrc/server/race.qh

index 54a7002056f9b681e4a741034ec24656911a6742..b3954d2eefd8cead759f5cde23e747fc8b463a64 100644 (file)
@@ -975,17 +975,6 @@ void SpecialCommand()
 #endif
 }
 
-void PM_check_race_movetime(void)
-{SELFPARAM();
-#ifdef SVQC
-       self.race_movetime_frac += PHYS_INPUT_TIMELENGTH;
-       float f = floor(self.race_movetime_frac);
-       self.race_movetime_frac -= f;
-       self.race_movetime_count += f;
-       self.race_movetime = self.race_movetime_frac + self.race_movetime_count;
-#endif
-}
-
 float PM_check_specialcommand(float buttons)
 {SELFPARAM();
 #ifdef SVQC
@@ -1145,40 +1134,6 @@ void PM_check_blocked(void)
 #endif
 }
 
-#ifdef SVQC
-float speedaward_lastsent;
-float speedaward_lastupdate;
-#endif
-void PM_check_race(void)
-{SELFPARAM();
-#ifdef SVQC
-       if(!(g_cts || g_race))
-               return;
-       if (vlen(self.velocity - self.velocity_z * '0 0 1') > speedaward_speed)
-       {
-               speedaward_speed = vlen(self.velocity - self.velocity_z * '0 0 1');
-               speedaward_holder = self.netname;
-               speedaward_uid = self.crypto_idfp;
-               speedaward_lastupdate = time;
-       }
-       if (speedaward_speed > speedaward_lastsent && time - speedaward_lastupdate > 1)
-       {
-               string rr = (g_cts) ? CTS_RECORD : RACE_RECORD;
-               race_send_speedaward(MSG_ALL);
-               speedaward_lastsent = speedaward_speed;
-               if (speedaward_speed > speedaward_alltimebest && speedaward_uid != "")
-               {
-                       speedaward_alltimebest = speedaward_speed;
-                       speedaward_alltimebest_holder = speedaward_holder;
-                       speedaward_alltimebest_uid = speedaward_uid;
-                       db_put(ServerProgsDB, strcat(GetMapname(), rr, "speed/speed"), ftos(speedaward_alltimebest));
-                       db_put(ServerProgsDB, strcat(GetMapname(), rr, "speed/crypto_idfp"), speedaward_alltimebest_uid);
-                       race_send_speedaward_alltimebest(MSG_ALL);
-               }
-       }
-#endif
-}
-
 void PM_check_vortex(void)
 {SELFPARAM();
 #ifdef SVQC
@@ -1675,7 +1630,6 @@ void PM_Main()
                        return;
 #endif
 
-       PM_check_race_movetime();
 #ifdef SVQC
        anticheat_physics();
 #endif
@@ -1708,17 +1662,7 @@ void PM_Main()
        if (IS_PLAYER(self))
 #endif
        {
-#ifdef SVQC
-               if (self.race_penalty)
-                       if (time > self.race_penalty)
-                               self.race_penalty = 0;
-#endif
-
                bool not_allowed_to_move = false;
-#ifdef SVQC
-               if (self.race_penalty)
-                       not_allowed_to_move = true;
-#endif
 #ifdef SVQC
                if (time < game_starttime)
                        not_allowed_to_move = true;
@@ -1893,10 +1837,6 @@ void PM_Main()
        else
                PM_air(buttons_prev, maxspeed_mod);
 
-#ifdef SVQC
-       if (!IS_OBSERVER(self))
-               PM_check_race();
-#endif
        PM_check_vortex();
 
 :end
index a45367afae314916a8c35495eb52485b33ca2cd7..679bbb094e53a268b65178b639ca6fac26474f76 100644 (file)
@@ -71,6 +71,27 @@ void CTS_ClientKill(entity e) // silent version of ClientKill, used when player
 
 MUTATOR_HOOKFUNCTION(cts, PlayerPhysics)
 {SELFPARAM();
+       self.race_movetime_frac += PHYS_INPUT_TIMELENGTH;
+       float f = floor(self.race_movetime_frac);
+       self.race_movetime_frac -= f;
+       self.race_movetime_count += f;
+       self.race_movetime = self.race_movetime_frac + self.race_movetime_count;
+
+#ifdef SVQC
+       if(IS_PLAYER(self))
+       {
+               if (self.race_penalty)
+                       if (time > self.race_penalty)
+                               self.race_penalty = 0;
+               if(self.race_penalty)
+               {
+                       self.velocity = '0 0 0';
+                       self.movetype = MOVETYPE_NONE;
+                       self.disableclientprediction = 2;
+               }
+       }
+#endif
+
        // force kbd movement for fairness
        float wishspeed;
        vector wishvel;
@@ -261,6 +282,32 @@ MUTATOR_HOOKFUNCTION(cts, GetPressedKeys)
                }
        }
 
+       if (!IS_OBSERVER(self))
+       {
+               if (vlen(self.velocity - self.velocity_z * '0 0 1') > speedaward_speed)
+               {
+                       speedaward_speed = vlen(self.velocity - self.velocity_z * '0 0 1');
+                       speedaward_holder = self.netname;
+                       speedaward_uid = self.crypto_idfp;
+                       speedaward_lastupdate = time;
+               }
+               if (speedaward_speed > speedaward_lastsent && time - speedaward_lastupdate > 1)
+               {
+                       string rr = CTS_RECORD;
+                       race_send_speedaward(MSG_ALL);
+                       speedaward_lastsent = speedaward_speed;
+                       if (speedaward_speed > speedaward_alltimebest && speedaward_uid != "")
+                       {
+                               speedaward_alltimebest = speedaward_speed;
+                               speedaward_alltimebest_holder = speedaward_holder;
+                               speedaward_alltimebest_uid = speedaward_uid;
+                               db_put(ServerProgsDB, strcat(GetMapname(), rr, "speed/speed"), ftos(speedaward_alltimebest));
+                               db_put(ServerProgsDB, strcat(GetMapname(), rr, "speed/crypto_idfp"), speedaward_alltimebest_uid);
+                               race_send_speedaward_alltimebest(MSG_ALL);
+                       }
+               }
+       }
+
        return false;
 }
 
index b7c660a4622cde53a8aa42446d69b4f5d6561d03..7a56d7f9d00ae4d902e6b943c54e01f5f849206e 100644 (file)
@@ -69,6 +69,27 @@ void race_EventLog(string mode, entity actor) // use an alias for easy changing
 
 MUTATOR_HOOKFUNCTION(rc, PlayerPhysics)
 {SELFPARAM();
+       self.race_movetime_frac += PHYS_INPUT_TIMELENGTH;
+       float f = floor(self.race_movetime_frac);
+       self.race_movetime_frac -= f;
+       self.race_movetime_count += f;
+       self.race_movetime = self.race_movetime_frac + self.race_movetime_count;
+
+#ifdef SVQC
+       if(IS_PLAYER(self))
+       {
+               if (self.race_penalty)
+                       if (time > self.race_penalty)
+                               self.race_penalty = 0;
+               if(self.race_penalty)
+               {
+                       self.velocity = '0 0 0';
+                       self.movetype = MOVETYPE_NONE;
+                       self.disableclientprediction = 2;
+               }
+       }
+#endif
+
        // force kbd movement for fairness
        float wishspeed;
        vector wishvel;
@@ -260,6 +281,31 @@ MUTATOR_HOOKFUNCTION(rc, GetPressedKeys)
                }
        }
 
+       if (!IS_OBSERVER(self))
+       {
+               if (vlen(self.velocity - self.velocity_z * '0 0 1') > speedaward_speed)
+               {
+                       speedaward_speed = vlen(self.velocity - self.velocity_z * '0 0 1');
+                       speedaward_holder = self.netname;
+                       speedaward_uid = self.crypto_idfp;
+                       speedaward_lastupdate = time;
+               }
+               if (speedaward_speed > speedaward_lastsent && time - speedaward_lastupdate > 1)
+               {
+                       string rr = RACE_RECORD;
+                       race_send_speedaward(MSG_ALL);
+                       speedaward_lastsent = speedaward_speed;
+                       if (speedaward_speed > speedaward_alltimebest && speedaward_uid != "")
+                       {
+                               speedaward_alltimebest = speedaward_speed;
+                               speedaward_alltimebest_holder = speedaward_holder;
+                               speedaward_alltimebest_uid = speedaward_uid;
+                               db_put(ServerProgsDB, strcat(GetMapname(), rr, "speed/speed"), ftos(speedaward_alltimebest));
+                               db_put(ServerProgsDB, strcat(GetMapname(), rr, "speed/crypto_idfp"), speedaward_alltimebest_uid);
+                               race_send_speedaward_alltimebest(MSG_ALL);
+                       }
+               }
+       }
        return false;
 }
 
index 47c1db4a3860176672e7e9ad486be8cf06a1f181..5e9f0cf85c2513a0364a894af003badad78cb622 100644 (file)
@@ -1,6 +1,9 @@
 #ifndef RACE_H
 #define RACE_H
 
+float speedaward_lastsent;
+float speedaward_lastupdate;
+
 float race_spawns;
 float race_highest_place_spawn; // number of places; a place higher gets spawned at 0
 float race_lowest_place_spawn; // where to spawn in qualifying