From: terencehill Date: Fri, 6 Sep 2024 15:14:24 +0000 (+0200) Subject: Fix int and bool STATs working as float STATs X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=1a3a0cc5f3d7d8f57c98b3ffb31bd1fc866d2784;p=xonotic%2Fxonotic-data.pk3dir.git Fix int and bool STATs working as float STATs --- diff --git a/qcsrc/common/stats.qh b/qcsrc/common/stats.qh index 9b4394e45..7783fa97e 100644 --- a/qcsrc/common/stats.qh +++ b/qcsrc/common/stats.qh @@ -68,7 +68,7 @@ REGISTER_STAT(PL_MAX, vector) REGISTER_STAT(PL_CROUCH_MAX, vector) // networked bitflag for game objective display (modicons) -REGISTER_STAT(OBJECTIVE_STATUS, int) +REGISTER_STAT_INT(OBJECTIVE_STATUS, int) #ifdef SVQC SPECTATE_COPYFIELD(_STAT(OBJECTIVE_STATUS)) #endif @@ -89,51 +89,51 @@ int timeout_status; // (values: 0, 1, 2) contains whether a timeout is not activ #define autocvar_timelimit_override cvar("timelimit_override") #endif REGISTER_STAT(WEAPONRATEFACTOR, float, W_WeaponRateFactor(this)) -REGISTER_STAT(GAME_STOPPED, int, game_stopped) +REGISTER_STAT_INT(GAME_STOPPED, int, game_stopped) REGISTER_STAT(GAMESTARTTIME, float, game_starttime) /** arc heat in [0,1] */ -REGISTER_STAT(PRESSED_KEYS, int) -REGISTER_STAT(FUEL, int) +REGISTER_STAT_INT(PRESSED_KEYS, int) +REGISTER_STAT_INT(FUEL, int) /** compressShotOrigin */ -REGISTER_STAT(SHOTORG, int) +REGISTER_STAT_INT(SHOTORG, int) REGISTER_STAT(LEADLIMIT, float, autocvar_leadlimit) REGISTER_STAT(LEADLIMIT_AND_FRAGLIMIT, float, autocvar_leadlimit_and_fraglimit) REGISTER_STAT(LAST_PICKUP, float) -REGISTER_STAT(HUD, int) +REGISTER_STAT_INT(HUD, int) REGISTER_STAT(HIT_TIME, float) -REGISTER_STAT(HITSOUND_DAMAGE_DEALT_TOTAL, int) +REGISTER_STAT_INT(HITSOUND_DAMAGE_DEALT_TOTAL, int) REGISTER_STAT(TYPEHIT_TIME, float) REGISTER_STAT(AIR_FINISHED, float) -REGISTER_STAT(VEHICLESTAT_HEALTH, int) -REGISTER_STAT(VEHICLESTAT_SHIELD, int) -REGISTER_STAT(VEHICLESTAT_ENERGY, int) -REGISTER_STAT(VEHICLESTAT_AMMO1, int) -REGISTER_STAT(VEHICLESTAT_RELOAD1, int) -REGISTER_STAT(VEHICLESTAT_AMMO2, int) -REGISTER_STAT(VEHICLESTAT_RELOAD2, int) -REGISTER_STAT(VEHICLESTAT_W2MODE, int) +REGISTER_STAT_INT(VEHICLESTAT_HEALTH, int) +REGISTER_STAT_INT(VEHICLESTAT_SHIELD, int) +REGISTER_STAT_INT(VEHICLESTAT_ENERGY, int) +REGISTER_STAT_INT(VEHICLESTAT_AMMO1, int) +REGISTER_STAT_INT(VEHICLESTAT_RELOAD1, int) +REGISTER_STAT_INT(VEHICLESTAT_AMMO2, int) +REGISTER_STAT_INT(VEHICLESTAT_RELOAD2, int) +REGISTER_STAT_INT(VEHICLESTAT_W2MODE, int) REGISTER_STAT(NADE_TIMER, float) -REGISTER_STAT(SECRETS_TOTAL, int, secrets_total) -REGISTER_STAT(SECRETS_FOUND, int, secrets_found) +REGISTER_STAT_INT(SECRETS_TOTAL, int, secrets_total) +REGISTER_STAT_INT(SECRETS_FOUND, int, secrets_found) REGISTER_STAT(RESPAWN_TIME, float) REGISTER_STAT(ROUNDSTARTTIME, float, round_starttime) -REGISTER_STAT(OVERTIMES, int, overtimes) -REGISTER_STAT(TIMEOUT_STATUS, int, timeout_status) -REGISTER_STAT(MONSTERS_TOTAL, int) -REGISTER_STAT(MONSTERS_KILLED, int) +REGISTER_STAT_INT(OVERTIMES, int, overtimes) +REGISTER_STAT_INT(TIMEOUT_STATUS, int, timeout_status) +REGISTER_STAT_INT(MONSTERS_TOTAL, int) +REGISTER_STAT_INT(MONSTERS_KILLED, int) REGISTER_STAT(NADE_BONUS, float) -REGISTER_STAT(NADE_BONUS_TYPE, int) +REGISTER_STAT_INT(NADE_BONUS_TYPE, int) REGISTER_STAT(NADE_BONUS_SCORE, float) REGISTER_STAT(NADE_DARKNESS_TIME, float) -REGISTER_STAT(PLASMA, int) -REGISTER_STAT(FROZEN, int) +REGISTER_STAT_INT(PLASMA, int) +REGISTER_STAT_INT(FROZEN, int) REGISTER_STAT(REVIVE_PROGRESS, float) -REGISTER_STAT(ROUNDLOST, int) +REGISTER_STAT_INT(ROUNDLOST, int) REGISTER_STAT(CAPTURE_PROGRESS, float) -REGISTER_STAT(ITEMSTIME, int, autocvar_sv_itemstime) +REGISTER_STAT_INT(ITEMSTIME, int, autocvar_sv_itemstime) REGISTER_STAT(KILL_TIME, float) -REGISTER_STAT(TKA_BALLSTATUS, int) +REGISTER_STAT_INT(TKA_BALLSTATUS, int) #ifdef SVQC float autocvar_sv_showfps = 0; @@ -143,7 +143,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_BOOL(CTF_SHOWLEADERBOARD, bool, autocvar_g_ctf_leaderboard) #ifdef SVQC int autocvar_g_multijump; @@ -153,15 +153,15 @@ float autocvar_g_multijump_maxspeed; float autocvar_g_multijump_dodging = 1; bool autocvar_g_multijump_client = true; #endif -REGISTER_STAT(MULTIJUMP_DODGING, int, autocvar_g_multijump_dodging) +REGISTER_STAT_INT(MULTIJUMP_DODGING, int, autocvar_g_multijump_dodging) REGISTER_STAT(MULTIJUMP_MAXSPEED, float, autocvar_g_multijump_maxspeed) -REGISTER_STAT(MULTIJUMP_ADD, int, autocvar_g_multijump_add) +REGISTER_STAT_INT(MULTIJUMP_ADD, int, autocvar_g_multijump_add) REGISTER_STAT(MULTIJUMP_SPEED, float, autocvar_g_multijump_speed) -REGISTER_STAT(MULTIJUMP_CLIENT, bool, autocvar_g_multijump_client) +REGISTER_STAT_BOOL(MULTIJUMP_CLIENT, bool, autocvar_g_multijump_client) .int multijump_count; -REGISTER_STAT(MULTIJUMP_COUNT, int, this.multijump_count) -REGISTER_STAT(MULTIJUMP, int, autocvar_g_multijump) -REGISTER_STAT(DOUBLEJUMP, int, autocvar_sv_doublejump) +REGISTER_STAT_INT(MULTIJUMP_COUNT, int, this.multijump_count) +REGISTER_STAT_INT(MULTIJUMP, int, autocvar_g_multijump) +REGISTER_STAT_INT(DOUBLEJUMP, int, autocvar_sv_doublejump) #ifdef SVQC bool g_bugrigs; @@ -181,18 +181,18 @@ float g_bugrigs_speed_pow; float g_bugrigs_steer; #endif #if 0 -REGISTER_STAT(BUGRIGS, int, g_bugrigs) +REGISTER_STAT_INT(BUGRIGS, int, g_bugrigs) REGISTER_STAT(BUGRIGS_ACCEL, float, g_bugrigs_accel) -REGISTER_STAT(BUGRIGS_AIR_STEERING, int, g_bugrigs_air_steering) -REGISTER_STAT(BUGRIGS_ANGLE_SMOOTHING, int, g_bugrigs_angle_smoothing) -REGISTER_STAT(BUGRIGS_CAR_JUMPING, int, g_bugrigs_planar_movement_car_jumping) +REGISTER_STAT_INT(BUGRIGS_AIR_STEERING, int, g_bugrigs_air_steering) +REGISTER_STAT_INT(BUGRIGS_ANGLE_SMOOTHING, int, g_bugrigs_angle_smoothing) +REGISTER_STAT_INT(BUGRIGS_CAR_JUMPING, int, g_bugrigs_planar_movement_car_jumping) REGISTER_STAT(BUGRIGS_FRICTION_AIR, float, g_bugrigs_friction_air) REGISTER_STAT(BUGRIGS_FRICTION_BRAKE, float, g_bugrigs_friction_brake) REGISTER_STAT(BUGRIGS_FRICTION_FLOOR, float, g_bugrigs_friction_floor) -REGISTER_STAT(BUGRIGS_PLANAR_MOVEMENT, int, g_bugrigs_planar_movement) -REGISTER_STAT(BUGRIGS_REVERSE_SPEEDING, int, g_bugrigs_reverse_speeding) -REGISTER_STAT(BUGRIGS_REVERSE_SPINNING, int, g_bugrigs_reverse_spinning) -REGISTER_STAT(BUGRIGS_REVERSE_STOPPING, int, g_bugrigs_reverse_stopping) +REGISTER_STAT_INT(BUGRIGS_PLANAR_MOVEMENT, int, g_bugrigs_planar_movement) +REGISTER_STAT_INT(BUGRIGS_REVERSE_SPEEDING, int, g_bugrigs_reverse_speeding) +REGISTER_STAT_INT(BUGRIGS_REVERSE_SPINNING, int, g_bugrigs_reverse_spinning) +REGISTER_STAT_INT(BUGRIGS_REVERSE_STOPPING, int, g_bugrigs_reverse_stopping) REGISTER_STAT(BUGRIGS_SPEED_POW, float, g_bugrigs_speed_pow) REGISTER_STAT(BUGRIGS_SPEED_REF, float, g_bugrigs_speed_ref) REGISTER_STAT(BUGRIGS_STEER, float, g_bugrigs_steer) @@ -213,22 +213,22 @@ int autocvar_sv_gameplayfix_noairborncorpse_allowsuspendeditems = 1; int autocvar_sv_gameplayfix_delayprojectiles = 0; bool autocvar_sv_gameplayfix_upwardvelocityclearsongroundflag = true; #endif -REGISTER_STAT(GAMEPLAYFIX_DOWNTRACEONGROUND, int, autocvar_sv_gameplayfix_downtracesupportsongroundflag) -REGISTER_STAT(GAMEPLAYFIX_EASIERWATERJUMP, int, autocvar_sv_gameplayfix_easierwaterjump) -REGISTER_STAT(GAMEPLAYFIX_STEPDOWN, int, autocvar_sv_gameplayfix_stepdown) +REGISTER_STAT_INT(GAMEPLAYFIX_DOWNTRACEONGROUND, int, autocvar_sv_gameplayfix_downtracesupportsongroundflag) +REGISTER_STAT_INT(GAMEPLAYFIX_EASIERWATERJUMP, int, autocvar_sv_gameplayfix_easierwaterjump) +REGISTER_STAT_INT(GAMEPLAYFIX_STEPDOWN, int, autocvar_sv_gameplayfix_stepdown) REGISTER_STAT(GAMEPLAYFIX_STEPDOWN_MAXSPEED, float, autocvar_sv_gameplayfix_stepdown_maxspeed) -REGISTER_STAT(GAMEPLAYFIX_STEPMULTIPLETIMES, int, autocvar_sv_gameplayfix_stepmultipletimes) -REGISTER_STAT(GAMEPLAYFIX_UNSTICKPLAYERS, int, autocvar_sv_gameplayfix_unstickplayers) -REGISTER_STAT(GAMEPLAYFIX_UPVELOCITYCLEARSONGROUND, int, autocvar_sv_gameplayfix_upwardvelocityclearsongroundflag) -REGISTER_STAT(GAMEPLAYFIX_WATERTRANSITION, int, autocvar_sv_gameplayfix_fixedcheckwatertransition) -REGISTER_STAT(GAMEPLAYFIX_SLIDEMOVEPROJECTILES, int, autocvar_sv_gameplayfix_slidemoveprojectiles) -REGISTER_STAT(GAMEPLAYFIX_GRENADEBOUNCESLOPES, int, autocvar_sv_gameplayfix_grenadebouncedownslopes) -REGISTER_STAT(GAMEPLAYFIX_NOAIRBORNCORPSE, int, autocvar_sv_gameplayfix_noairborncorpse) -REGISTER_STAT(NOAIRBORNCORPSE_ALLOWSUSPENDED, int, autocvar_sv_gameplayfix_noairborncorpse_allowsuspendeditems) -REGISTER_STAT(GAMEPLAYFIX_DELAYPROJECTILES, int, autocvar_sv_gameplayfix_delayprojectiles) - -REGISTER_STAT(MOVEVARS_JUMPSTEP, int, cvar("sv_jumpstep")) -REGISTER_STAT(NOSTEP, int, cvar("sv_nostep")) +REGISTER_STAT_INT(GAMEPLAYFIX_STEPMULTIPLETIMES, int, autocvar_sv_gameplayfix_stepmultipletimes) +REGISTER_STAT_INT(GAMEPLAYFIX_UNSTICKPLAYERS, int, autocvar_sv_gameplayfix_unstickplayers) +REGISTER_STAT_INT(GAMEPLAYFIX_UPVELOCITYCLEARSONGROUND, int, autocvar_sv_gameplayfix_upwardvelocityclearsongroundflag) +REGISTER_STAT_INT(GAMEPLAYFIX_WATERTRANSITION, int, autocvar_sv_gameplayfix_fixedcheckwatertransition) +REGISTER_STAT_INT(GAMEPLAYFIX_SLIDEMOVEPROJECTILES, int, autocvar_sv_gameplayfix_slidemoveprojectiles) +REGISTER_STAT_INT(GAMEPLAYFIX_GRENADEBOUNCESLOPES, int, autocvar_sv_gameplayfix_grenadebouncedownslopes) +REGISTER_STAT_INT(GAMEPLAYFIX_NOAIRBORNCORPSE, int, autocvar_sv_gameplayfix_noairborncorpse) +REGISTER_STAT_INT(NOAIRBORNCORPSE_ALLOWSUSPENDED, int, autocvar_sv_gameplayfix_noairborncorpse_allowsuspendeditems) +REGISTER_STAT_INT(GAMEPLAYFIX_DELAYPROJECTILES, int, autocvar_sv_gameplayfix_delayprojectiles) + +REGISTER_STAT_INT(MOVEVARS_JUMPSTEP, int, cvar("sv_jumpstep")) +REGISTER_STAT_INT(NOSTEP, int, cvar("sv_nostep")) #ifdef SVQC float autocvar_sv_friction_on_land; @@ -238,10 +238,10 @@ REGISTER_STAT(MOVEVARS_FRICTION, float) REGISTER_STAT(MOVEVARS_FRICTION_SLICK, float, autocvar_sv_friction_slick) REGISTER_STAT(MOVEVARS_FRICTION_ONLAND, float, autocvar_sv_friction_on_land) -REGISTER_STAT(MOVEVARS_JUMPSPEEDCAP_DISABLE_ONRAMPS, int, autocvar_sv_jumpspeedcap_max_disable_on_ramps) -REGISTER_STAT(MOVEVARS_TRACK_CANJUMP, int) +REGISTER_STAT_INT(MOVEVARS_JUMPSPEEDCAP_DISABLE_ONRAMPS, int, autocvar_sv_jumpspeedcap_max_disable_on_ramps) +REGISTER_STAT_INT(MOVEVARS_TRACK_CANJUMP, int) /** cvar loopback */ -REGISTER_STAT(MOVEVARS_CL_TRACK_CANJUMP, int) +REGISTER_STAT_INT(MOVEVARS_CL_TRACK_CANJUMP, int) #ifdef SVQC int g_dodging; @@ -265,10 +265,10 @@ bool autocvar_sv_dodging_clientselect; #endif #if 0 -REGISTER_STAT(DODGING, int, g_dodging) +REGISTER_STAT_INT(DODGING, int, g_dodging) REGISTER_STAT(DODGING_DELAY, float, autocvar_sv_dodging_delay) REGISTER_STAT(DODGING_DISTANCE_THRESHOLD, float, autocvar_sv_dodging_wall_distance_threshold) -REGISTER_STAT(DODGING_FROZEN_DOUBLETAP, int, autocvar_sv_dodging_frozen_doubletap) +REGISTER_STAT_INT(DODGING_FROZEN_DOUBLETAP, int, autocvar_sv_dodging_frozen_doubletap) REGISTER_STAT(DODGING_HEIGHT_THRESHOLD, float, autocvar_sv_dodging_height_threshold) REGISTER_STAT(DODGING_HORIZ_SPEED_MIN, float, autocvar_sv_dodging_horiz_speed_min) REGISTER_STAT(DODGING_HORIZ_SPEED_MAX, float, autocvar_sv_dodging_horiz_speed_max) @@ -277,14 +277,14 @@ 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_BOOL(DODGING_WALL, bool, autocvar_sv_dodging_wall_dodging) +REGISTER_STAT_BOOL(DODGING_AIR, bool, 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_BOOL(DODGING_CLIENTSELECT, bool, autocvar_sv_dodging_clientselect) #endif /** cvar loopback */ -REGISTER_STAT(DODGING_FROZEN, int, autocvar_sv_dodging_frozen) +REGISTER_STAT_INT(DODGING_FROZEN, int, autocvar_sv_dodging_frozen) REGISTER_STAT(DODGING_TIMEOUT, float) #ifdef SVQC @@ -313,7 +313,7 @@ AUTOCVAR(g_walljump_force, float, 300, "How far to bounce/jump off the wall"); AUTOCVAR(g_walljump_velocity_xy_factor, float, 1.15, "How much to slow down along horizontal axis, higher value = higher deceleration, if factor is < 1, you accelerate by wall jumping"); AUTOCVAR(g_walljump_velocity_z_factor, float, 0.5, "Upwards velocity factor, multiplied by normal jump velocity"); #endif -REGISTER_STAT(WALLJUMP, int, autocvar_g_walljump) +REGISTER_STAT_INT(WALLJUMP, int, autocvar_g_walljump) REGISTER_STAT(WALLJUMP_VELOCITY_Z_FACTOR, float, autocvar_g_walljump_velocity_z_factor) REGISTER_STAT(WALLJUMP_VELOCITY_XY_FACTOR, float, autocvar_g_walljump_velocity_xy_factor) REGISTER_STAT(WALLJUMP_DELAY, float, autocvar_g_walljump_delay) @@ -326,10 +326,10 @@ float autocvar_g_bloodloss; REGISTER_STAT(BLOODLOSS, float, autocvar_g_bloodloss) // freeze tag, clan arena -REGISTER_STAT(REDALIVE, int) -REGISTER_STAT(BLUEALIVE, int) -REGISTER_STAT(YELLOWALIVE, int) -REGISTER_STAT(PINKALIVE, int) +REGISTER_STAT_INT(REDALIVE, int) +REGISTER_STAT_INT(BLUEALIVE, int) +REGISTER_STAT_INT(YELLOWALIVE, int) +REGISTER_STAT_INT(PINKALIVE, int) // domination REGISTER_STAT(DOM_TOTAL_PPS, float) @@ -347,18 +347,18 @@ float autocvar_g_teleport_minspeed; #endif REGISTER_STAT(TELEPORT_MAXSPEED, float, autocvar_g_teleport_maxspeed) REGISTER_STAT(TELEPORT_MINSPEED, float, autocvar_g_teleport_minspeed) -REGISTER_STAT(TELEPORT_TELEFRAG_AVOID, int, autocvar_g_telefrags_avoid) +REGISTER_STAT_INT(TELEPORT_TELEFRAG_AVOID, int, autocvar_g_telefrags_avoid) -REGISTER_STAT(CAMERA_SPECTATOR, int) +REGISTER_STAT_INT(CAMERA_SPECTATOR, int) REGISTER_STAT(SPECTATORSPEED, float) #ifdef SVQC bool autocvar_sv_slick_applygravity; #endif -REGISTER_STAT(SLICK_APPLYGRAVITY, bool, autocvar_sv_slick_applygravity) +REGISTER_STAT_BOOL(SLICK_APPLYGRAVITY, bool, autocvar_sv_slick_applygravity) -REGISTER_STAT(Q3COMPAT, int, q3compat) +REGISTER_STAT_INT(Q3COMPAT, int, q3compat) // FIXME: workaround for https://gitlab.com/xonotic/xonotic-data.pk3dir/-/issues/2812 #ifdef SVQC #define Q3COMPAT_COMMON q3compat @@ -377,22 +377,22 @@ int rounds_played; 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_BOOL(SHOOTFROMEYE, bool, autocvar_g_shootfromeye) +REGISTER_STAT_BOOL(SHOOTFROMCENTER, bool, 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_BOOL(MOVEVARS_AIRCONTROL_BACKWARDS, bool) +REGISTER_STAT_BOOL(MOVEVARS_AIRCONTROL_SIDEWARDS, bool) #ifdef SVQC float autocvar_sv_gameplayfix_q2airaccelerate = 1; bool autocvar_sv_gameplayfix_nogravityonground = true; bool autocvar_sv_gameplayfix_gravityunaffectedbyticrate = true; #endif -REGISTER_STAT(MOVEFLAGS, int, MOVEFLAG_VALID +REGISTER_STAT_INT(MOVEFLAGS, int, MOVEFLAG_VALID | (autocvar_sv_gameplayfix_q2airaccelerate ? MOVEFLAG_Q2AIRACCELERATE : 0) | (autocvar_sv_gameplayfix_nogravityonground ? MOVEFLAG_NOGRAVITYONGROUND : 0) | (autocvar_sv_gameplayfix_gravityunaffectedbyticrate ? MOVEFLAG_GRAVITYUNAFFECTEDBYTICRATE : 0)) @@ -410,14 +410,14 @@ REGISTER_STAT(MOVEVARS_AIRCONTROL, float) REGISTER_STAT(FRAGLIMIT, float, autocvar_fraglimit) REGISTER_STAT(TIMELIMIT, float, autocvar_timelimit) REGISTER_STAT(WARMUP_TIMELIMIT, float, warmup_limit) -REGISTER_STAT(ROUNDS_PLAYED, int, rounds_played) +REGISTER_STAT_INT(ROUNDS_PLAYED, int, rounds_played) REGISTER_STAT(ROUND_TIMELIMIT, float, round_limit) #ifdef SVQC float autocvar_sv_wallfriction; #define autocvar_sv_gravity cvar("sv_gravity") float autocvar_sv_stepheight; #endif -REGISTER_STAT(MOVEVARS_WALLFRICTION, int, autocvar_sv_wallfriction) +REGISTER_STAT_INT(MOVEVARS_WALLFRICTION, int, autocvar_sv_wallfriction) REGISTER_STAT(MOVEVARS_TICRATE, float, autocvar_sys_ticrate) REGISTER_STAT(MOVEVARS_TIMESCALE, float, autocvar_slowmo) REGISTER_STAT(MOVEVARS_GRAVITY, float, autocvar_sv_gravity) @@ -437,9 +437,9 @@ REGISTER_STAT(MOVEVARS_AIRACCEL_SIDEWAYS_FRICTION, float) #ifdef SVQC int autocvar_sv_wallclip; #endif -REGISTER_STAT(MOVEVARS_WALLCLIP, int, autocvar_sv_wallclip) +REGISTER_STAT_INT(MOVEVARS_WALLCLIP, int, autocvar_sv_wallclip) -REGISTER_STAT(GUNALIGN, int) +REGISTER_STAT_INT(GUNALIGN, int) #ifdef SVQC SPECTATE_COPYFIELD(_STAT(GUNALIGN)) #endif diff --git a/qcsrc/lib/stats.qh b/qcsrc/lib/stats.qh index 5d0721f6e..a5be8841a 100644 --- a/qcsrc/lib/stats.qh +++ b/qcsrc/lib/stats.qh @@ -61,8 +61,18 @@ int g_magic_stats_hole = 0; it.m_id += g_magic_stats_hole; \ MAGIC_STATS(MAGIC_STATS_FIX_MANUAL, it) { MAGIC_STATS(MAGIC_STATS_FIX_AUTO, it) } +// REGISTER_STAT_INT and REGISTER_STAT_BOOL exist because REGISTER_STAT can't create a proper +// int / bool STAT due to int and bool types being expanded to float when REGISTER_STAT gets called + +#define REGISTER_STAT_BOOL(...) EVAL_REGISTER_STAT_BOOL(OVERLOAD(REGISTER_STAT_BOOL, __VA_ARGS__)) +#define EVAL_REGISTER_STAT_BOOL(...) __VA_ARGS__ + +#define REGISTER_STAT_INT(...) EVAL_REGISTER_STAT_INT(OVERLOAD(REGISTER_STAT_INT, __VA_ARGS__)) +#define EVAL_REGISTER_STAT_INT(...) __VA_ARGS__ + #define REGISTER_STAT(...) EVAL_REGISTER_STAT(OVERLOAD(REGISTER_STAT, __VA_ARGS__)) #define EVAL_REGISTER_STAT(...) __VA_ARGS__ + #if defined(CSQC) /** Get all stats and store them as globals, access with `STAT(ID)` */ void stats_get() {} @@ -78,6 +88,33 @@ int g_magic_stats_hole = 0; #define getstat_vectori(id) vec3(getstat_int(id + 0), getstat_int(id + 1), getstat_int(id + 2)) #define _STAT(id) g_stat_##id + + // mostly duplicate of REGISTER_STAT_2 + #define REGISTER_STAT_BOOL_2(id, T) \ + T _STAT(id); \ + /* T CAT(_STAT(id), _prev); */ \ + REGISTER(Stats, STAT_##id, m_id, new_pure(stat)) {} \ + ACCUMULATE void stats_get() \ + { \ + T it = getstat_bool(STAT_##id.m_id); \ + /* if (it != CAT(_STAT(id), _prev)) \ + CAT(_STAT(id), _prev) = */ _STAT(id) = it; \ + } + #define REGISTER_STAT_BOOL_3(id, T, expr) REGISTER_STAT_BOOL_2(id, T) + + // mostly duplicate of REGISTER_STAT_2 + #define REGISTER_STAT_INT_2(id, T) \ + T _STAT(id); \ + /* T CAT(_STAT(id), _prev); */ \ + REGISTER(Stats, STAT_##id, m_id, new_pure(stat)) {} \ + ACCUMULATE void stats_get() \ + { \ + T it = getstat_int(STAT_##id.m_id); \ + /* if (it != CAT(_STAT(id), _prev)) \ + CAT(_STAT(id), _prev) = */ _STAT(id) = it; \ + } + #define REGISTER_STAT_INT_3(id, T, expr) REGISTER_STAT_INT_2(id, T) + #define REGISTER_STAT_2(id, T) \ T _STAT(id); \ /* T CAT(_STAT(id), _prev); */ \ @@ -94,7 +131,7 @@ int g_magic_stats_hole = 0; /* if (it != CAT(_STAT(id), _prev)) \ CAT(_STAT(id), _prev) = */ _STAT(id) = it; \ } - #define REGISTER_STAT_3(x, T, expr) REGISTER_STAT_2(x, T) + #define REGISTER_STAT_3(id, T, expr) REGISTER_STAT_2(id, T) #elif defined(SVQC) /** Internal use only */ entity STATS; @@ -137,6 +174,27 @@ int g_magic_stats_hole = 0; } #define _STAT(id) stat_##id + + // mostly duplicate of REGISTER_STAT_2 + #define REGISTER_STAT_BOOL_2(id, T) \ + .T _STAT(id); \ + REGISTER(Stats, STAT_##id, m_id, new_pure(stat)) {} \ + ACCUMULATE void stats_add() \ + { \ + .T fld = _STAT(id); \ + addstat_int(STAT_##id.m_id, fld); \ + } + + // mostly duplicate of REGISTER_STAT_2 + #define REGISTER_STAT_INT_2(id, T) \ + .T _STAT(id); \ + REGISTER(Stats, STAT_##id, m_id, new_pure(stat)) {} \ + ACCUMULATE void stats_add() \ + { \ + .T fld = _STAT(id); \ + addstat_int(STAT_##id.m_id, fld); \ + } + #define REGISTER_STAT_2(id, T) \ .T _STAT(id); \ REGISTER(Stats, STAT_##id, m_id, new_pure(stat)) \ @@ -153,15 +211,31 @@ int g_magic_stats_hole = 0; } void GlobalStats_update(entity this) {} void GlobalStats_updateglobal() {} - /** TODO: do we want the global copy to update? */ - #define REGISTER_STAT_3(id, T, expr) \ - REGISTER_STAT_2(id, T); \ + + #define _REGISTER_STAT_2(id, expr) \ ACCUMULATE void GlobalStats_update(entity this) { STAT(id, this) = (expr); } \ ACCUMULATE void GlobalStats_updateglobal() { entity this = STATS; STAT(id, this) = (expr); } \ STATIC_INIT(worldstat_##id) { entity this = STATS; STAT(id, this) = (expr); } + + /** TODO: do we want the global copy to update? */ + #define REGISTER_STAT_BOOL_3(id, T, expr) \ + REGISTER_STAT_BOOL_2(id, T); \ + _REGISTER_STAT_2(id, expr) + + #define REGISTER_STAT_INT_3(id, T, expr) \ + REGISTER_STAT_INT_2(id, T); \ + _REGISTER_STAT_2(id, expr) + + #define REGISTER_STAT_3(id, T, expr) \ + REGISTER_STAT_2(id, T); \ + _REGISTER_STAT_2(id, expr) #else - #define REGISTER_STAT_2(id, type) + #define REGISTER_STAT_2(id, T) #define REGISTER_STAT_3(id, T, expr) + #define REGISTER_STAT_INT_2(id, T) + #define REGISTER_STAT_INT_3(id, T, expr) + #define REGISTER_STAT_BOOL_2(id, T) + #define REGISTER_STAT_BOOL_3(id, T, expr) #endif REGISTRY(Stats, 256 - STATS_ENGINE_RESERVE)