]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Stats: register a few more stats
authorTimePath <andrew.hardaker1995@gmail.com>
Sat, 7 Nov 2015 03:04:12 +0000 (14:04 +1100)
committerTimePath <andrew.hardaker1995@gmail.com>
Sat, 7 Nov 2015 03:04:12 +0000 (14:04 +1100)
qcsrc/client/announcer.qc
qcsrc/client/hud/panel/infomessages.qc
qcsrc/client/hud/panel/powerups.qc
qcsrc/client/hud/panel/timer.qc
qcsrc/client/view.qc
qcsrc/common/stats.qh
qcsrc/common/weapons/all.qh
qcsrc/common/weapons/weapon/arc.qc
qcsrc/server/defs.qh
qcsrc/server/g_world.qc

index 9da998ae679f65c6819a9141f2388cec8735d33b..fa8f2b0055b51395ed0248ae4129cc1e741d55fa 100644 (file)
@@ -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)
index b4b571358c684341e7e9545e2b58653f2c5a119e..2bcad642609d7b86dfc4b7dd0c1170566057c57a 100644 (file)
@@ -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;
index a13b9a559e1acea655f64080a19c82ae3fbd05e8..4e509e5c5fc7db3de6336c58cc8e6d0ccc71ce62 100644 (file)
@@ -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)
index 80f58012cbb35c3e21654c715fdc051c6fa8b630..f709b41ec9ba7909f93ab01357a56e7b7fbfc26e 100644 (file)
@@ -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 {
index 935507046e15f5467ae5430a12188a9e85ca4ccb..c319dfcf0bdbc339d011fe6edb13ad2958cf9d5d 100644 (file)
@@ -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); }
 
index 62458fbd025a5dffa535aa3f44599679647fa0ca..cbf54fef2918cc9f694c08913afe1c7251303926 100644 (file)
@@ -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,
index 10e804b479be2c3ab761b7c839258d705a1e1eb3..af279506448160bb2cf89b5c60fed8c60d8ac237 100644 (file)
@@ -2,6 +2,7 @@
 #define WEAPONS_ALL_H
 
 #include "../command/all.qh"
+#include "../stats.qh"
 #include "config.qh"
 
 // weapon sets
index 218edb6a86fb2e9c0ad0d9eb0195baaa9e6f7545..b873e62388d1c5f19755a9d3c6f5b0da5cdc63a0 100644 (file)
@@ -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
index d0e30bacd5a5693796264e8740f86be2aab01833..f4053cb33741432574c716c2aea8a5d90a1d067e 100644 (file)
@@ -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);
index 5b9fc3f73d5165199850f2dccb0d596a3bcc5011..6f3b56d779fd5c4d952450b8f8e88bc37089d50f 100644 (file)
@@ -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);