From 96f40ca69036b7c38be9fde04fd73b94bfcca761 Mon Sep 17 00:00:00 2001 From: TimePath Date: Sat, 7 Nov 2015 14:04:12 +1100 Subject: [PATCH] Stats: register a few more stats --- qcsrc/client/announcer.qc | 8 ++++---- qcsrc/client/hud/panel/infomessages.qc | 4 ++-- qcsrc/client/hud/panel/powerups.qc | 4 ++-- qcsrc/client/hud/panel/timer.qc | 6 +++--- qcsrc/client/view.qc | 4 ++-- qcsrc/common/stats.qh | 13 ++++++++----- qcsrc/common/weapons/all.qh | 1 + qcsrc/common/weapons/weapon/arc.qc | 2 +- qcsrc/server/defs.qh | 6 +++--- qcsrc/server/g_world.qc | 5 ----- 10 files changed, 26 insertions(+), 27 deletions(-) diff --git a/qcsrc/client/announcer.qc b/qcsrc/client/announcer.qc index 9da998ae6..fa8f2b005 100644 --- a/qcsrc/client/announcer.qc +++ b/qcsrc/client/announcer.qc @@ -18,7 +18,7 @@ string AnnouncerOption() void Announcer_Countdown() { SELFPARAM(); - float starttime = getstatf(STAT_GAMESTARTTIME); + float starttime = STAT(GAMESTARTTIME); float roundstarttime = getstatf(STAT_ROUNDSTARTTIME); if(roundstarttime == -1) { @@ -69,7 +69,7 @@ void Announcer_Countdown() float previous_game_starttime; void Announcer_Gamestart() { - float startTime = getstatf(STAT_GAMESTARTTIME); + float startTime = STAT(GAMESTARTTIME); float roundstarttime = getstatf(STAT_ROUNDSTARTTIME); if(roundstarttime > startTime) startTime = roundstarttime; @@ -101,12 +101,12 @@ void Announcer_Gamestart() void Announcer_Time() { float timelimit = getstatf(STAT_TIMELIMIT); - float timeleft = max(0, timelimit * 60 + getstatf(STAT_GAMESTARTTIME) - time); + float timeleft = max(0, timelimit * 60 + STAT(GAMESTARTTIME) - time); float warmup_timeleft = 0; if(warmup_stage) if(autocvar_g_warmup_limit > 0) - warmup_timeleft = max(0, autocvar_g_warmup_limit + getstatf(STAT_GAMESTARTTIME) - time); + warmup_timeleft = max(0, autocvar_g_warmup_limit + STAT(GAMESTARTTIME) - time); // 5 minute check if(autocvar_cl_announcer_maptime >= 2) diff --git a/qcsrc/client/hud/panel/infomessages.qc b/qcsrc/client/hud/panel/infomessages.qc index b4b571358..2bcad6426 100644 --- a/qcsrc/client/hud/panel/infomessages.qc +++ b/qcsrc/client/hud/panel/infomessages.qc @@ -96,10 +96,10 @@ void HUD_InfoMessages() drawInfoMessage(s); //show restart countdown: - if (time < getstatf(STAT_GAMESTARTTIME)) { + if (time < STAT(GAMESTARTTIME)) { float countdown; //we need to ceil, otherwise the countdown would be off by .5 when using round() - countdown = ceil(getstatf(STAT_GAMESTARTTIME) - time); + countdown = ceil(STAT(GAMESTARTTIME) - time); s = sprintf(_("^1Game starts in ^3%d^1 seconds"), countdown); drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL); o.y += fontsize.y; diff --git a/qcsrc/client/hud/panel/powerups.qc b/qcsrc/client/hud/panel/powerups.qc index a13b9a559..4e509e5c5 100644 --- a/qcsrc/client/hud/panel/powerups.qc +++ b/qcsrc/client/hud/panel/powerups.qc @@ -68,8 +68,8 @@ void HUD_Powerups() if(getstati(STAT_HEALTH) <= 0) return; if(!(allItems & (ITEM_Strength.m_itemid | ITEM_Shield.m_itemid | IT_SUPERWEAPON)) && !allBuffs) return; - strengthTime = bound(0, getstatf(STAT_STRENGTH_FINISHED) - time, 99); - shieldTime = bound(0, getstatf(STAT_INVINCIBLE_FINISHED) - time, 99); + strengthTime = bound(0, STAT(STRENGTH_FINISHED) - time, 99); + shieldTime = bound(0, STAT(INVINCIBLE_FINISHED) - time, 99); superTime = bound(0, getstatf(STAT_SUPERWEAPONS_FINISHED) - time, 99); if(allItems & IT_UNLIMITED_SUPERWEAPONS) diff --git a/qcsrc/client/hud/panel/timer.qc b/qcsrc/client/hud/panel/timer.qc index 80f58012c..f709b41ec 100644 --- a/qcsrc/client/hud/panel/timer.qc +++ b/qcsrc/client/hud/panel/timer.qc @@ -25,7 +25,7 @@ void HUD_Timer() timelimit = getstatf(STAT_TIMELIMIT); - timeleft = max(0, timelimit * 60 + getstatf(STAT_GAMESTARTTIME) - time); + timeleft = max(0, timelimit * 60 + STAT(GAMESTARTTIME) - time); timeleft = ceil(timeleft); minutesLeft = floor(timeleft / 60); @@ -39,11 +39,11 @@ void HUD_Timer() timer_color = '1 0 0'; //red if (autocvar_hud_panel_timer_increment || timelimit == 0 || warmup_stage) { - if (time < getstatf(STAT_GAMESTARTTIME)) { + if (time < STAT(GAMESTARTTIME)) { //while restart is still active, show 00:00 timer = seconds_tostring(0); } else { - elapsedTime = floor(time - getstatf(STAT_GAMESTARTTIME)); //127 + elapsedTime = floor(time - STAT(GAMESTARTTIME)); //127 timer = seconds_tostring(elapsedTime); } } else { diff --git a/qcsrc/client/view.qc b/qcsrc/client/view.qc index 935507046..c319dfcf0 100644 --- a/qcsrc/client/view.qc +++ b/qcsrc/client/view.qc @@ -830,7 +830,7 @@ void HUD_Crosshair() vortex_charge = getstatf(STAT_VORTEX_CHARGE); vortex_chargepool = getstatf(STAT_VORTEX_CHARGEPOOL); - float arc_heat = getstatf(STAT_ARC_HEAT); + float arc_heat = STAT(ARC_HEAT); if(vortex_charge_movingavg == 0) // this should only happen if we have just loaded up the game vortex_charge_movingavg = vortex_charge; @@ -1793,7 +1793,7 @@ void CSQC_UpdateView(float w, float h) } // edge detection postprocess handling done second (used by hud_powerup) - float sharpen_intensity = 0, strength_finished = getstatf(STAT_STRENGTH_FINISHED), invincible_finished = getstatf(STAT_INVINCIBLE_FINISHED); + float sharpen_intensity = 0, strength_finished = STAT(STRENGTH_FINISHED), invincible_finished = STAT(INVINCIBLE_FINISHED); if (strength_finished - time > 0) { sharpen_intensity += (strength_finished - time); } if (invincible_finished - time > 0) { sharpen_intensity += (invincible_finished - time); } diff --git a/qcsrc/common/stats.qh b/qcsrc/common/stats.qh index 62458fbd0..cbf54fef2 100644 --- a/qcsrc/common/stats.qh +++ b/qcsrc/common/stats.qh @@ -89,17 +89,20 @@ enum { STAT_LAST_VECTOR }; +const int REGISTERED_STATS = 6; + REGISTER_STAT(KH_KEYS, int) /** weapon requested to switch to; next WANTED weapon (for HUD) */ REGISTER_STAT(SWITCHWEAPON, int) +REGISTER_STAT(GAMESTARTTIME, float) +REGISTER_STAT(STRENGTH_FINISHED, float) +REGISTER_STAT(INVINCIBLE_FINISHED, float) +/** arc heat in [0,1] */ +REGISTER_STAT(ARC_HEAT, float) enum { - STAT_FIRST_MAIN = (STAT_LAST_VECTOR - 1) + 2, + STAT_FIRST_MAIN = (STAT_LAST_VECTOR - 1) + REGISTERED_STATS, - STAT_GAMESTARTTIME, - STAT_STRENGTH_FINISHED, - STAT_INVINCIBLE_FINISHED, - STAT_ARC_HEAT, STAT_PRESSED_KEYS, /** this stat could later contain some other bits of info, like, more server-side particle config */ STAT_ALLOW_OLDVORTEXBEAM, STAT_FUEL, diff --git a/qcsrc/common/weapons/all.qh b/qcsrc/common/weapons/all.qh index 10e804b47..af2795064 100644 --- a/qcsrc/common/weapons/all.qh +++ b/qcsrc/common/weapons/all.qh @@ -2,6 +2,7 @@ #define WEAPONS_ALL_H #include "../command/all.qh" +#include "../stats.qh" #include "config.qh" // weapon sets diff --git a/qcsrc/common/weapons/weapon/arc.qc b/qcsrc/common/weapons/weapon/arc.qc index 218edb6a8..b873e6238 100644 --- a/qcsrc/common/weapons/weapon/arc.qc +++ b/qcsrc/common/weapons/weapon/arc.qc @@ -92,7 +92,7 @@ ARC_SETTINGS(WEP_ADD_CVAR, WEP_ADD_PROP) .float beam_heat; // (beam) amount of heat produced .float arc_overheat; // (dropped arc/player) time during which it's too hot .float arc_cooldown; // (dropped arc/player) cooling speed -.float arc_heat_percent; // (player) arc heat in [0,1] (stat) +.float arc_heat_percent = _STAT(ARC_HEAT); .float arc_smoke_sound; #endif #ifdef CSQC diff --git a/qcsrc/server/defs.qh b/qcsrc/server/defs.qh index d0e30bacd..f4053cb33 100644 --- a/qcsrc/server/defs.qh +++ b/qcsrc/server/defs.qh @@ -77,8 +77,8 @@ float server_is_dedicated; .float pain_frame; //" .float crouch; // Crouching or not? -.float strength_finished; -.float invincible_finished; +.float strength_finished = _STAT(STRENGTH_FINISHED); +.float invincible_finished = _STAT(INVINCIBLE_FINISHED); .float superweapons_finished; .float cnt; // used in too many places @@ -397,7 +397,7 @@ float cvar_purechanges_count; float game_starttime; //point in time when the countdown to game start is over float round_starttime; //point in time when the countdown to round start is over -.float stat_game_starttime; +.float stat_game_starttime = _STAT(GAMESTARTTIME); .float stat_round_starttime; void W_Porto_Remove (entity p); diff --git a/qcsrc/server/g_world.qc b/qcsrc/server/g_world.qc index 5b9fc3f73..6f3b56d77 100644 --- a/qcsrc/server/g_world.qc +++ b/qcsrc/server/g_world.qc @@ -758,13 +758,10 @@ spawnfunc(worldspawn) WepSet_AddStat(); WepSet_AddStat_InMap(); addstat(STAT_SWITCHINGWEAPON, AS_INT, switchingweapon); - addstat(STAT_GAMESTARTTIME, AS_FLOAT, stat_game_starttime); addstat(STAT_ROUNDSTARTTIME, AS_FLOAT, stat_round_starttime); addstat(STAT_ALLOW_OLDVORTEXBEAM, AS_INT, stat_allow_oldvortexbeam); Nagger_Init(); - addstat(STAT_STRENGTH_FINISHED, AS_FLOAT, strength_finished); - addstat(STAT_INVINCIBLE_FINISHED, AS_FLOAT, invincible_finished); addstat(STAT_SUPERWEAPONS_FINISHED, AS_FLOAT, superweapons_finished); addstat(STAT_PRESSED_KEYS, AS_FLOAT, pressedkeys); addstat(STAT_FUEL, AS_INT, ammo_fuel); @@ -784,8 +781,6 @@ spawnfunc(worldspawn) addstat(STAT_HAGAR_LOAD, AS_INT, hagar_load); - addstat(STAT_ARC_HEAT, AS_FLOAT, arc_heat_percent); - // freeze attacks addstat(STAT_FROZEN, AS_INT, frozen); addstat(STAT_REVIVE_PROGRESS, AS_FLOAT, revive_progress); -- 2.39.2