]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Stats: remove dependence on engine assigned stats
authorTimePath <andrew.hardaker1995@gmail.com>
Tue, 24 Nov 2015 11:16:50 +0000 (22:16 +1100)
committerTimePath <andrew.hardaker1995@gmail.com>
Tue, 24 Nov 2015 11:16:50 +0000 (22:16 +1100)
12 files changed:
qcsrc/client/announcer.qc
qcsrc/client/hud/panel/timer.qc
qcsrc/client/main.qc
qcsrc/client/quickmenu.qc
qcsrc/client/scoreboard.qc
qcsrc/client/view.qc
qcsrc/common/movetypes/movetypes.qh
qcsrc/common/physics.qh
qcsrc/common/stats.qh
qcsrc/dpdefs/csprogsdefs.qh
qcsrc/lib/stats.qh
qcsrc/server/sv_main.qc

index ab1cd1366240eafcd1cfb3d058bec1d70a0f5122..a0c496abcd93b70c7b5b94d53d304cd147fb9957 100644 (file)
@@ -100,7 +100,7 @@ void Announcer_Gamestart()
 // Plays the 1 minute or 5 minutes (of maptime) remaining sound, if client wants it
 void Announcer_Time()
 {
-       float timelimit = getstatf(STAT_TIMELIMIT);
+       float timelimit = STAT(TIMELIMIT);
        float timeleft = max(0, timelimit * 60 + STAT(GAMESTARTTIME) - time);
        float warmup_timeleft = 0;
 
index f709b41ec9ba7909f93ab01357a56e7b7fbfc26e..4de0c1e5f6ce76a51a72707db74acb1ad9ad8cbc 100644 (file)
@@ -23,7 +23,7 @@ void HUD_Timer()
        string timer;
        float timelimit, elapsedTime, timeleft, minutesLeft;
 
-       timelimit = getstatf(STAT_TIMELIMIT);
+       timelimit = STAT(TIMELIMIT);
 
        timeleft = max(0, timelimit * 60 + STAT(GAMESTARTTIME) - time);
        timeleft = ceil(timeleft);
index badc78ce69fca9ca08a318455741b88fdedccc0e..1e4720d4d111c083853acf0cbb975a3b679a1743 100644 (file)
@@ -768,7 +768,7 @@ void CSQC_Ent_Update(float bIsNewEntity)
        else
        {
                serverprevtime = time;
-               serverdeltatime = getstatf(STAT_MOVEVARS_TICRATE) * getstatf(STAT_MOVEVARS_TIMESCALE);
+               serverdeltatime = STAT(MOVEVARS_TICRATE) * STAT(MOVEVARS_TIMESCALE);
                time = serverprevtime + serverdeltatime;
        }
 
index a4fdfea382f170bfb1f69bb3583a7883901c7c56..e0e758c2fb192e3061b91fce2459ec83f2f847b6 100644 (file)
@@ -847,7 +847,7 @@ void QuickMenu_Default(string target_submenu)
        QUICKMENU_SMENU(CTX(_("QMCMD^Call a vote")), "Call a vote")
                QUICKMENU_ENTRY(CTX(_("QMCMD^Restart the map")), "vcall restart")
                QUICKMENU_ENTRY(CTX(_("QMCMD^End match")), "vcall endmatch")
-               if(getstatf(STAT_TIMELIMIT) > 0)
+               if(STAT(TIMELIMIT) > 0)
                {
                QUICKMENU_ENTRY(CTX(_("QMCMD^Reduce match time")), "vcall reducematchtime")
                QUICKMENU_ENTRY(CTX(_("QMCMD^Extend match time")), "vcall extendmatchtime")
index b00690ff86a8410bf44c6e14860d0b75b396a69c..f25a368fb472ac6be4427012bfb8a52a68f558c2 100644 (file)
@@ -1402,8 +1402,8 @@ void HUD_DrawScoreboard()
        // Print info string
        float tl, fl, ll;
        str = sprintf(_("playing ^3%s^7 on ^2%s^7"), MapInfo_Type_ToText(gametype), shortmapname);
-       tl = getstatf(STAT_TIMELIMIT);
-       fl = getstatf(STAT_FRAGLIMIT);
+       tl = STAT(TIMELIMIT);
+       fl = STAT(FRAGLIMIT);
        ll = STAT(LEADLIMIT);
        if(gametype == MAPINFO_TYPE_LMS)
        {
index e853e6b622e83828f6936a4bb8e293e88f3a5b3f..6e828d7ebe8ed55a2c27b296dd4b7c1469f163b7 100644 (file)
@@ -1112,7 +1112,7 @@ void CSQC_UpdateView(float w, float h)
                prev_myteam = myteam;
        }
 
-       ticrate = getstatf(STAT_MOVEVARS_TICRATE) * getstatf(STAT_MOVEVARS_TIMESCALE);
+       ticrate = STAT(MOVEVARS_TICRATE) * STAT(MOVEVARS_TIMESCALE);
 
        float is_dead = (getstati(STAT_HEALTH) <= 0);
 
index 362075da2d3bfdd2f9a5e22378f547463678e40c..60417a9cf4846a39830a09507aab18a9a66d2899 100644 (file)
@@ -35,7 +35,7 @@ float autocvar_cl_gameplayfix_fixedcheckwatertransition = 1;
 
 #define TICRATE sys_frametime
 #elif defined(CSQC)
-#define GRAVITY_UNAFFECTED_BY_TICRATE (getstati(STAT_MOVEFLAGS) & MOVEFLAG_GRAVITYUNAFFECTEDBYTICRATE)
+#define GRAVITY_UNAFFECTED_BY_TICRATE (STAT(MOVEFLAGS) & MOVEFLAG_GRAVITYUNAFFECTEDBYTICRATE)
 #define UPWARD_VELOCITY_CLEARS_ONGROUND getstati(STAT_GAMEPLAYFIX_UPVELOCITYCLEARSONGROUND)
 
 #define TICRATE ticrate
@@ -91,13 +91,13 @@ const int FL_ONGROUND                               = 512;
 
 const int MOVETYPE_FAKEPUSH         = 13;
 
-const float MOVEFLAG_Q2AIRACCELERATE            = 1;
-const float MOVEFLAG_NOGRAVITYONGROUND          = 2;
-const float MOVEFLAG_GRAVITYUNAFFECTEDBYTICRATE = 4;
+const int MOVEFLAG_VALID = BIT(31);
+const int MOVEFLAG_Q2AIRACCELERATE = BIT(0);
+const int MOVEFLAG_NOGRAVITYONGROUND = BIT(1);
+const int MOVEFLAG_GRAVITYUNAFFECTEDBYTICRATE = BIT(2);
 
 #ifdef CSQC
-// TODO: figure out server's version of this
-#define moveflags (getstati(STAT_MOVEFLAGS))
+#define moveflags STAT(MOVEFLAGS)
 #endif
 
 #endif
index 16e028e048900126e3c20b825043bc3a9aefdad1..124518a586ceda9414f01a544ddeabacb5de45ac 100644 (file)
@@ -138,17 +138,17 @@ bool IsFlying(entity a);
        #define PHYS_AIRSTOPACCELERATE                          getstatf(STAT_MOVEVARS_AIRSTOPACCELERATE)
        #define PHYS_AIRSTRAFEACCEL_QW(s)                       getstatf(STAT_MOVEVARS_AIRSTRAFEACCEL_QW)
        #define PHYS_AIRSTRAFEACCELERATE(s)                     getstatf(STAT_MOVEVARS_AIRSTRAFEACCELERATE)
-       #define PHYS_ENTGRAVITY(s)                                      getstatf(STAT_MOVEVARS_ENTGRAVITY)
+       #define PHYS_ENTGRAVITY(s)                                      STAT(MOVEVARS_ENTGRAVITY)
        #define PHYS_FRICTION                                           getstatf(STAT_MOVEVARS_FRICTION)
        #define PHYS_FRICTION_SLICK                                     getstatf(STAT_MOVEVARS_FRICTION_SLICK)
        #define PHYS_FRICTION_ONLAND                            getstatf(STAT_MOVEVARS_FRICTION_ONLAND)
-       #define PHYS_GRAVITY                                            getstatf(STAT_MOVEVARS_GRAVITY)
+       #define PHYS_GRAVITY                                            STAT(MOVEVARS_GRAVITY)
        #define PHYS_HIGHSPEED                                          getstatf(STAT_MOVEVARS_HIGHSPEED)
        #define PHYS_JUMPVELOCITY                                       getstatf(STAT_MOVEVARS_JUMPVELOCITY)
        #define PHYS_MAXAIRSPEED(s)                                     getstatf(STAT_MOVEVARS_MAXAIRSPEED)
        #define PHYS_MAXAIRSTRAFESPEED                          getstatf(STAT_MOVEVARS_MAXAIRSTRAFESPEED)
        #define PHYS_MAXSPEED(s)                                        getstatf(STAT_MOVEVARS_MAXSPEED)
-       #define PHYS_STEPHEIGHT                                         getstatf(STAT_MOVEVARS_STEPHEIGHT)
+       #define PHYS_STEPHEIGHT                                         STAT(MOVEVARS_STEPHEIGHT)
        #define PHYS_STOPSPEED                                          getstatf(STAT_MOVEVARS_STOPSPEED)
        #define PHYS_WARSOWBUNNY_ACCEL                          getstatf(STAT_MOVEVARS_WARSOWBUNNY_ACCEL)
        #define PHYS_WARSOWBUNNY_BACKTOSIDERATIO        getstatf(STAT_MOVEVARS_WARSOWBUNNY_BACKTOSIDERATIO)
@@ -156,7 +156,7 @@ bool IsFlying(entity a);
        #define PHYS_WARSOWBUNNY_TOPSPEED                       getstatf(STAT_MOVEVARS_WARSOWBUNNY_TOPSPEED)
        #define PHYS_WARSOWBUNNY_TURNACCEL                      getstatf(STAT_MOVEVARS_WARSOWBUNNY_TURNACCEL)
 
-       #define PHYS_WALLFRICTION                                       getstati(STAT_MOVEVARS_WALLFRICTION)
+       #define PHYS_WALLFRICTION                                       STAT(MOVEVARS_WALLFRICTION)
 
        #define PHYS_JETPACK_ACCEL_UP                           getstatf(STAT_JETPACK_ACCEL_UP)
        #define PHYS_JETPACK_ACCEL_SIDE                         getstatf(STAT_JETPACK_ACCEL_SIDE)
index fa245d9d84bbf1977afb4d8dabef9aca68c2841f..b893feae73127d145ee39463f3199a1b396cbd92 100644 (file)
@@ -4,54 +4,18 @@
 // Full list of all stat constants, included in a single location for easy reference
 // 255 is the current limit (MAX_CL_STATS - 1), engine will need to be modified if you wish to add more stats
 
-const int MAX_CL_STATS                = 256;
-// -Wdouble-declaration
-// const int STAT_HEALTH                 = 0;
-// 1 empty?
-const int STAT_WEAPON                 = 2;
-// -Wdouble-declaration
-// const int STAT_AMMO                   = 3;
-// -Wdouble-declaration
-// const int STAT_ARMOR                  = 4;
-// -Wdouble-declaration
-// const int STAT_WEAPONFRAME            = 5;
-// -Wdouble-declaration
-// const int STAT_SHELLS                 = 6;
-// -Wdouble-declaration
-// const int STAT_NAILS                  = 7;
-// -Wdouble-declaration
-// const int STAT_ROCKETS                = 8;
-// -Wdouble-declaration
-// const int STAT_CELLS                  = 9;
-// -Wdouble-declaration
-// const int STAT_ACTIVEWEAPON           = 10;
-// -Wdouble-declaration
-// const int STAT_TOTALSECRETS           = 11;
-// -Wdouble-declaration
-// const int STAT_TOTALMONSTERS          = 12;
-// -Wdouble-declaration
-// const int STAT_SECRETS                = 13;
-// -Wdouble-declaration
-// const int STAT_MONSTERS               = 14;
-// -Wdouble-declaration
-// const int STAT_ITEMS                  = 15;
-// -Wdouble-declaration
-// const int STAT_VIEWHEIGHT             = 16;
-// 17 empty?
-// 18 empty?
-// 19 empty?
-// 20 empty?
-const int STAT_VIEWZOOM               = 21;
-// 22 empty?
-// 23 empty?
-// 24 empty?
-// 25 empty?
-// 26 empty?
-// 27 empty?
-// 28 empty?
-// 29 empty?
-// 30 empty?
-// 31 empty?
+const int MAX_CL_STATS = 256;
+#ifndef CSQC
+const int STAT_HEALTH = 0; // .health
+const int STAT_ARMOR = 4; // .armorvalue
+const int STAT_SHELLS = 6; // .ammo_shells
+const int STAT_NAILS = 7; // .ammo_nails
+const int STAT_ROCKETS = 8; // .ammo_rockets
+const int STAT_CELLS = 9; // .ammo_cells
+const int STAT_ACTIVEWEAPON = 10; // .weapon
+const int STAT_ITEMS = 15; // .items | .items2 << 23 | serverflags << 28
+const int STAT_VIEWHEIGHT = 16; // .view_ofs_z
+#endif
 
 enum {
     STAT_WEAPONS = 32,
@@ -89,7 +53,7 @@ enum {
     STAT_LAST_VECTOR
 };
 
-const int REGISTERED_STATS = 50;
+const int REGISTERED_STATS = 59;
 
 REGISTER_STAT(KH_KEYS, int)
 /** weapon requested to switch to; next WANTED weapon (for HUD) */
@@ -252,12 +216,24 @@ enum {
 #define ASSERT_LESS(name, var, const) noref int name[(const - var + 1)];
 ASSERT_LESS(stat_limit, STAT_LAST, 220)
 
+#ifdef SVQC
+void GlobalStats_update(entity e) {}
+#define STAT_GLOBAL(T, x, expr) REGISTER_STAT(x, T); [[accumulate]] void GlobalStats_update(entity e) { STAT(x, e) = (expr); }
+#include "movetypes/movetypes.qh"
+#else
+#define STAT_GLOBAL(T, x, expr) REGISTER_STAT(x, T)
+#endif
+
 const int STAT_MOVEVARS_AIRACCEL_QW_STRETCHFACTOR     = 220;
 const int STAT_MOVEVARS_AIRCONTROL_PENALTY            = 221;
 const int STAT_MOVEVARS_AIRSPEEDLIMIT_NONQW           = 222;
 const int STAT_MOVEVARS_AIRSTRAFEACCEL_QW             = 223;
 const int STAT_MOVEVARS_AIRCONTROL_POWER              = 224;
-const int STAT_MOVEFLAGS                              = 225;
+noref bool autocvar_sv_gameplayfix_nogravityonground;
+STAT_GLOBAL(int, MOVEFLAGS, MOVEFLAG_VALID
+                            | (autocvar_sv_gameplayfix_q2airaccelerate ? MOVEFLAG_Q2AIRACCELERATE : 0)
+                            | (autocvar_sv_gameplayfix_nogravityonground ? MOVEFLAG_NOGRAVITYONGROUND : 0)
+                            | (autocvar_sv_gameplayfix_gravityunaffectedbyticrate ? MOVEFLAG_GRAVITYUNAFFECTEDBYTICRATE : 0))
 const int STAT_MOVEVARS_WARSOWBUNNY_AIRFORWARDACCEL   = 226;
 const int STAT_MOVEVARS_WARSOWBUNNY_ACCEL             = 227;
 const int STAT_MOVEVARS_WARSOWBUNNY_TOPSPEED          = 228;
@@ -267,30 +243,23 @@ const int STAT_MOVEVARS_AIRSTOPACCELERATE             = 231;
 const int STAT_MOVEVARS_AIRSTRAFEACCELERATE           = 232;
 const int STAT_MOVEVARS_MAXAIRSTRAFESPEED             = 233;
 const int STAT_MOVEVARS_AIRCONTROL                    = 234;
-// -Wdouble-declaration
-// const int STAT_FRAGLIMIT                              = 235;
-// -Wdouble-declaration
-// const int STAT_TIMELIMIT                              = 236;
-const int STAT_MOVEVARS_WALLFRICTION                  = 237;
+STAT_GLOBAL(float, FRAGLIMIT, autocvar_fraglimit)
+STAT_GLOBAL(float, TIMELIMIT, autocvar_timelimit)
+noref float autocvar_sv_wallfriction;
+STAT_GLOBAL(int, MOVEVARS_WALLFRICTION, autocvar_sv_wallfriction)
 const int STAT_MOVEVARS_FRICTION                      = 238;
-const int STAT_MOVEVARS_WATERFRICTION                 = 239;
-// -Wdouble-declaration
-// const int STAT_MOVEVARS_TICRATE                       = 240;
-// -Wdouble-declaration
-// const int STAT_MOVEVARS_TIMESCALE                     = 241;
-// -Wdouble-declaration
-// const int STAT_MOVEVARS_GRAVITY                       = 242;
+STAT_GLOBAL(float, MOVEVARS_TICRATE, autocvar_sys_ticrate)
+STAT_GLOBAL(float, MOVEVARS_TIMESCALE, autocvar_slowmo)
+STAT_GLOBAL(float, MOVEVARS_GRAVITY, autocvar_sv_gravity)
 const int STAT_MOVEVARS_STOPSPEED                     = 243;
 const int STAT_MOVEVARS_MAXSPEED                      = 244;
-const int STAT_MOVEVARS_SPECTATORMAXSPEED             = 245;
 const int STAT_MOVEVARS_ACCELERATE                    = 246;
 const int STAT_MOVEVARS_AIRACCELERATE                 = 247;
-const int STAT_MOVEVARS_WATERACCELERATE               = 248;
-const int STAT_MOVEVARS_ENTGRAVITY                    = 249;
+.float gravity;
+STAT_GLOBAL(float, MOVEVARS_ENTGRAVITY, (e.gravity) ? e.gravity : 1)
 const int STAT_MOVEVARS_JUMPVELOCITY                  = 250;
-const int STAT_MOVEVARS_EDGEFRICTION                  = 251;
 const int STAT_MOVEVARS_MAXAIRSPEED                   = 252;
-const int STAT_MOVEVARS_STEPHEIGHT                    = 253;
+STAT_GLOBAL(float, MOVEVARS_STEPHEIGHT, autocvar_sv_stepheight)
 const int STAT_MOVEVARS_AIRACCEL_QW                   = 254;
 const int STAT_MOVEVARS_AIRACCEL_SIDEWAYS_FRICTION    = 255;
 #endif
index 6f9c9d637ff3a927faae655e701e09d7c73d22a9..79cfe76c6ae205178718acc53989b509630ad0a3 100644 (file)
 #define pointparticles __pointparticles
 #define setmodel _setmodel
 
+#define STAT_FRAGLIMIT _STAT_FRAGLIMIT
+#define STAT_TIMELIMIT _STAT_TIMELIMIT
+#define STAT_MOVEVARS_TICRATE _STAT_MOVEVARS_TICRATE
+#define STAT_MOVEVARS_TIMESCALE _STAT_MOVEVARS_TIMESCALE
+#define STAT_MOVEVARS_GRAVITY _STAT_MOVEVARS_GRAVITY
+
 #include "upstream/csprogsdefs.qc"
 
 #undef true
 #undef pointparticles
 #undef setmodel
 
+#undef STAT_FRAGLIMIT
+#undef STAT_TIMELIMIT
+#undef STAT_MOVEVARS_TICRATE
+#undef STAT_MOVEVARS_TIMESCALE
+#undef STAT_MOVEVARS_GRAVITY
+
 #pragma noref 0
 
 #define ReadFloat() ReadCoord()
index f522023ef8aa662ebfb45d800ee9b5e736c9b66d..ca42150dcc9fd5c30d98fd0e80cad9388f69cfb2 100644 (file)
@@ -1,6 +1,8 @@
 #ifndef LIB_STATS_H
 #define LIB_STATS_H
 
+// TODO: rename to 'netvars'
+
 #include "registry.qh"
 #include "sort.qh"
 
index 09c9263d7d6753f8cb1261394f3cca1e60953840..9989cb9ab1b814aca66362f6c52106e5ad6386b5 100644 (file)
@@ -262,6 +262,13 @@ void StartFrame()
        bot_serverframe();
        anticheat_startframe();
        MUTATOR_CALLHOOK(SV_StartFrame);
+       {
+        entity e;
+        FOR_EACH_CLIENT(e)
+        {
+            GlobalStats_update(e);
+        }
+    }
 }
 
 .vector originjitter;