]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Add a custom type for boolean stats too to ensure they're only sent as a single byte Mario/qc_stats
authorMario <mario.mario@y7mail.com>
Sat, 25 Jul 2020 07:05:59 +0000 (17:05 +1000)
committerMario <mario.mario@y7mail.com>
Sat, 25 Jul 2020 07:05:59 +0000 (17:05 +1000)
qcsrc/common/stats.qh
qcsrc/common/weapons/weapon/vortex.qc
qcsrc/lib/stats.qh

index 64ed3e84edae67e63a1026ccb593345519eb3400..43d38d89da29019766075787c44740d8fb1922ed 100644 (file)
@@ -87,7 +87,7 @@ REGISTER_STAT(INVINCIBLE_FINISHED, float)
 /** arc heat in [0,1] */
 REGISTER_STAT(PRESSED_KEYS, int24)
 /** this stat could later contain some other bits of info, like, more server-side particle config */
-REGISTER_STAT(ALLOW_OLDVORTEXBEAM, bool, autocvar_g_allow_oldvortexbeam)
+REGISTER_STAT(ALLOW_OLDVORTEXBEAM, bool8, autocvar_g_allow_oldvortexbeam)
 REGISTER_STAT(FUEL, int24)
 REGISTER_STAT(NB_METERSTART, float)
 /** compressShotOrigin */
@@ -145,7 +145,7 @@ REGISTER_STAT(SHOWFPS, float, autocvar_sv_showfps)
 #ifdef SVQC
 bool autocvar_g_ctf_leaderboard;
 #endif
-REGISTER_STAT(CTF_SHOWLEADERBOARD, bool, autocvar_g_ctf_leaderboard)
+REGISTER_STAT(CTF_SHOWLEADERBOARD, bool8, autocvar_g_ctf_leaderboard)
 
 #ifdef SVQC
 int autocvar_g_multijump;
@@ -159,7 +159,7 @@ REGISTER_STAT(MULTIJUMP_DODGING, int24, autocvar_g_multijump_dodging)
 REGISTER_STAT(MULTIJUMP_MAXSPEED, float, autocvar_g_multijump_maxspeed)
 REGISTER_STAT(MULTIJUMP_ADD, int24, autocvar_g_multijump_add)
 REGISTER_STAT(MULTIJUMP_SPEED, float, autocvar_g_multijump_speed)
-REGISTER_STAT(MULTIJUMP_CLIENT, bool, autocvar_g_multijump_client)
+REGISTER_STAT(MULTIJUMP_CLIENT, bool8, autocvar_g_multijump_client)
 .int multijump_count;
 REGISTER_STAT(MULTIJUMP_COUNT, int24, this.multijump_count)
 REGISTER_STAT(MULTIJUMP, int24, autocvar_g_multijump)
@@ -270,11 +270,11 @@ REGISTER_STAT(DODGING_HORIZ_FORCE_FASTEST, float, autocvar_sv_dodging_horiz_forc
 REGISTER_STAT(DODGING_HORIZ_FORCE_FROZEN, float, autocvar_sv_dodging_horiz_force_frozen)
 REGISTER_STAT(DODGING_RAMP_TIME, float, autocvar_sv_dodging_ramp_time)
 REGISTER_STAT(DODGING_UP_SPEED, float, autocvar_sv_dodging_up_speed)
-REGISTER_STAT(DODGING_WALL, bool, autocvar_sv_dodging_wall_dodging)
-REGISTER_STAT(DODGING_AIR, bool, autocvar_sv_dodging_air_dodging)
+REGISTER_STAT(DODGING_WALL, bool8, autocvar_sv_dodging_wall_dodging)
+REGISTER_STAT(DODGING_AIR, bool8, autocvar_sv_dodging_air_dodging)
 REGISTER_STAT(DODGING_MAXSPEED, float, autocvar_sv_dodging_maxspeed)
 REGISTER_STAT(DODGING_AIR_MAXSPEED, float, autocvar_sv_dodging_air_maxspeed)
-REGISTER_STAT(DODGING_CLIENTSELECT, bool, autocvar_sv_dodging_clientselect)
+REGISTER_STAT(DODGING_CLIENTSELECT, bool8, autocvar_sv_dodging_clientselect)
 #endif
 /** cvar loopback */
 REGISTER_STAT(DODGING_FROZEN, int24, autocvar_sv_dodging_frozen)
@@ -332,12 +332,12 @@ REGISTER_STAT(SPECTATORSPEED, float)
 #ifdef SVQC
 bool autocvar_sv_slick_applygravity;
 #endif
-REGISTER_STAT(SLICK_APPLYGRAVITY, bool, autocvar_sv_slick_applygravity)
+REGISTER_STAT(SLICK_APPLYGRAVITY, bool8, autocvar_sv_slick_applygravity)
 
 #ifdef SVQC
 bool autocvar_sv_q3defragcompat;
 #endif
-REGISTER_STAT(Q3DEFRAGCOMPAT, bool, autocvar_sv_q3defragcompat)
+REGISTER_STAT(Q3DEFRAGCOMPAT, bool8, autocvar_sv_q3defragcompat)
 
 #ifdef SVQC
 #include "physics/movetypes/movetypes.qh"
@@ -348,16 +348,16 @@ float warmup_limit;
 bool autocvar_g_shootfromcenter;
 bool autocvar_g_shootfromeye;
 #endif
-REGISTER_STAT(SHOOTFROMEYE, bool, autocvar_g_shootfromeye)
-REGISTER_STAT(SHOOTFROMCENTER, bool, autocvar_g_shootfromcenter)
+REGISTER_STAT(SHOOTFROMEYE, bool8, autocvar_g_shootfromeye)
+REGISTER_STAT(SHOOTFROMCENTER, bool8, autocvar_g_shootfromcenter)
 
 REGISTER_STAT(MOVEVARS_AIRACCEL_QW_STRETCHFACTOR, float)
 REGISTER_STAT(MOVEVARS_AIRCONTROL_PENALTY, float)
 REGISTER_STAT(MOVEVARS_AIRSPEEDLIMIT_NONQW, float)
 REGISTER_STAT(MOVEVARS_AIRSTRAFEACCEL_QW, float)
 REGISTER_STAT(MOVEVARS_AIRCONTROL_POWER, float)
-REGISTER_STAT(MOVEVARS_AIRCONTROL_BACKWARDS, bool)
-REGISTER_STAT(MOVEVARS_AIRCONTROL_SIDEWARDS, bool)
+REGISTER_STAT(MOVEVARS_AIRCONTROL_BACKWARDS, bool8)
+REGISTER_STAT(MOVEVARS_AIRCONTROL_SIDEWARDS, bool8)
 noref bool autocvar_sv_gameplayfix_nogravityonground = true;
 REGISTER_STAT(MOVEFLAGS, int24, MOVEFLAG_VALID
                               | (autocvar_sv_gameplayfix_q2airaccelerate ? MOVEFLAG_Q2AIRACCELERATE : 0)
@@ -397,7 +397,7 @@ REGISTER_STAT(MOVEVARS_MAXAIRSPEED, float)
 REGISTER_STAT(MOVEVARS_STEPHEIGHT, float, autocvar_sv_stepheight)
 REGISTER_STAT(MOVEVARS_AIRACCEL_QW, float)
 REGISTER_STAT(MOVEVARS_AIRACCEL_SIDEWAYS_FRICTION, float)
-REGISTER_STAT(MOVEVARS_SPECIALCOMMAND, bool)
+REGISTER_STAT(MOVEVARS_SPECIALCOMMAND, bool8)
 #ifdef SVQC
 int autocvar_sv_wallclip;
 #endif
index bf179e374d3d24df2ddae085a84b33e124104765..ec2b8af3f8f805e3bfef1e5b016ad4968aa1087c 100644 (file)
@@ -1,6 +1,6 @@
 #include "vortex.qh"
 
-//REGISTER_STAT(WEP_CVAR_vortex_charge, bool, WEP_CVAR(vortex, charge))
+//REGISTER_STAT(WEP_CVAR_vortex_charge, bool8, WEP_CVAR(vortex, charge))
 //REGISTER_STAT(WEP_CVAR_vortex_charge_animlimit, float, WEP_CVAR(vortex, charge_animlimit))
 
 #if defined(GAMEQC)
index 2894d0e0793e38a2ae16e8a68c9455a550cfbf23..46ccf15a2e2367f529c71512bc33fe89e3b02a72 100644 (file)
@@ -8,6 +8,7 @@
 .int m_id;
 USING(vectori, vector);
 USING(int24, int);
+USING(bool8, bool);
 
 REGISTRY(Stats, 256)
 REGISTER_REGISTRY(Stats)
@@ -22,7 +23,7 @@ REGISTRY_DEFINE_GET(Stats, NULL)
 
 #if defined(CSQC)
        #define stats_get_int24() ReadInt24_t()
-       #define stats_get_bool() boolean(ReadByte())
+       #define stats_get_bool8() boolean(ReadByte())
        #define stats_get_float() ReadFloat()
        #define stats_get_vector() ReadVector()
        #define stats_get_vectori() ReadInt72_t()
@@ -30,19 +31,19 @@ REGISTRY_DEFINE_GET(Stats, NULL)
 .void(entity ent) m_receive;
 #elif defined(SVQC)
        #define stats_write_int24(chan,id,ent) WriteInt24_t(chan, STAT(id, ent))
-       #define stats_write_bool(chan,id,ent) WriteByte(chan, STAT(id, ent))
+       #define stats_write_bool8(chan,id,ent) WriteByte(chan, STAT(id, ent))
        #define stats_write_float(chan,id,ent) WriteFloat(chan, STAT(id, ent))
        #define stats_write_vector(chan,id,ent) WriteVector(chan, STAT(id, ent))
        #define stats_write_vectori(chan,id,ent) WriteInt72_t(chan, STAT(id, ent))
 
        #define stats_set_int24(id,ent,val) STAT(id, ent) = rint(val)
-       #define stats_set_bool(id,ent,val) STAT(id, ent) = (val)
+       #define stats_set_bool8(id,ent,val) STAT(id, ent) = boolean(val)
        #define stats_set_float(id,ent,val) STAT(id, ent) = (val)
        #define stats_set_vector(id,ent,val) STAT(id, ent) = (val)
        #define stats_set_vectori(id,ent,val) STAT(id, ent) = vec_rint(val)
 
        #define stats_check_int24(id,ent,val) (STAT(id, ent) != rint(val))
-       #define stats_check_bool(id,ent,val) (STAT(id, ent) != (val))
+       #define stats_check_bool8(id,ent,val) (STAT(id, ent) != boolean(val))
        #define stats_check_float(id,ent,val) (STAT(id, ent) != (val))
        #define stats_check_vector(id,ent,val) (STAT(id, ent) != (val))
        #define stats_check_vectori(id,ent,val) (STAT(id, ent) != vec_rint(val))