From: TimePath Date: Tue, 24 Nov 2015 11:16:50 +0000 (+1100) Subject: Stats: remove dependence on engine assigned stats X-Git-Tag: xonotic-v0.8.2~1609^2~9 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=a1c09c6b8a0203227e01157a2175d4c2a45be777;p=xonotic%2Fxonotic-data.pk3dir.git Stats: remove dependence on engine assigned stats --- diff --git a/qcsrc/client/announcer.qc b/qcsrc/client/announcer.qc index ab1cd1366..a0c496abc 100644 --- a/qcsrc/client/announcer.qc +++ b/qcsrc/client/announcer.qc @@ -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; diff --git a/qcsrc/client/hud/panel/timer.qc b/qcsrc/client/hud/panel/timer.qc index f709b41ec..4de0c1e5f 100644 --- a/qcsrc/client/hud/panel/timer.qc +++ b/qcsrc/client/hud/panel/timer.qc @@ -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); diff --git a/qcsrc/client/main.qc b/qcsrc/client/main.qc index badc78ce6..1e4720d4d 100644 --- a/qcsrc/client/main.qc +++ b/qcsrc/client/main.qc @@ -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; } diff --git a/qcsrc/client/quickmenu.qc b/qcsrc/client/quickmenu.qc index a4fdfea38..e0e758c2f 100644 --- a/qcsrc/client/quickmenu.qc +++ b/qcsrc/client/quickmenu.qc @@ -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") diff --git a/qcsrc/client/scoreboard.qc b/qcsrc/client/scoreboard.qc index b00690ff8..f25a368fb 100644 --- a/qcsrc/client/scoreboard.qc +++ b/qcsrc/client/scoreboard.qc @@ -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) { diff --git a/qcsrc/client/view.qc b/qcsrc/client/view.qc index e853e6b62..6e828d7eb 100644 --- a/qcsrc/client/view.qc +++ b/qcsrc/client/view.qc @@ -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); diff --git a/qcsrc/common/movetypes/movetypes.qh b/qcsrc/common/movetypes/movetypes.qh index 362075da2..60417a9cf 100644 --- a/qcsrc/common/movetypes/movetypes.qh +++ b/qcsrc/common/movetypes/movetypes.qh @@ -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 diff --git a/qcsrc/common/physics.qh b/qcsrc/common/physics.qh index 16e028e04..124518a58 100644 --- a/qcsrc/common/physics.qh +++ b/qcsrc/common/physics.qh @@ -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) diff --git a/qcsrc/common/stats.qh b/qcsrc/common/stats.qh index fa245d9d8..b893feae7 100644 --- a/qcsrc/common/stats.qh +++ b/qcsrc/common/stats.qh @@ -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 diff --git a/qcsrc/dpdefs/csprogsdefs.qh b/qcsrc/dpdefs/csprogsdefs.qh index 6f9c9d637..79cfe76c6 100644 --- a/qcsrc/dpdefs/csprogsdefs.qh +++ b/qcsrc/dpdefs/csprogsdefs.qh @@ -14,6 +14,12 @@ #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 @@ -27,6 +33,12 @@ #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() diff --git a/qcsrc/lib/stats.qh b/qcsrc/lib/stats.qh index f522023ef..ca42150dc 100644 --- a/qcsrc/lib/stats.qh +++ b/qcsrc/lib/stats.qh @@ -1,6 +1,8 @@ #ifndef LIB_STATS_H #define LIB_STATS_H +// TODO: rename to 'netvars' + #include "registry.qh" #include "sort.qh" diff --git a/qcsrc/server/sv_main.qc b/qcsrc/server/sv_main.qc index 09c9263d7..9989cb9ab 100644 --- a/qcsrc/server/sv_main.qc +++ b/qcsrc/server/sv_main.qc @@ -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;