From 09dae4a483fc31bc94a2c19922c3fd0d1c7951e3 Mon Sep 17 00:00:00 2001 From: TimePath Date: Sat, 7 Nov 2015 15:56:17 +1100 Subject: [PATCH] Stats: register FUEL --- qcsrc/client/hud/panel/healtharmor.qc | 2 +- qcsrc/common/physics.qh | 6 ++---- qcsrc/common/stats.qh | 4 ++-- qcsrc/common/weapons/all.qc | 2 +- qcsrc/common/weapons/weapon.qh | 11 +++++++++++ qcsrc/server/g_world.qc | 1 - 6 files changed, 17 insertions(+), 9 deletions(-) diff --git a/qcsrc/client/hud/panel/healtharmor.qc b/qcsrc/client/hud/panel/healtharmor.qc index 83043293c..bab17556d 100644 --- a/qcsrc/client/hud/panel/healtharmor.qc +++ b/qcsrc/client/hud/panel/healtharmor.qc @@ -41,7 +41,7 @@ void HUD_HealthArmor() prev_health = 0; prev_armor = 0; } - fuel = getstati(STAT_FUEL); + fuel = STAT(FUEL); } else { diff --git a/qcsrc/common/physics.qh b/qcsrc/common/physics.qh index 5ee8954d0..f05578cb7 100644 --- a/qcsrc/common/physics.qh +++ b/qcsrc/common/physics.qh @@ -24,6 +24,8 @@ float AdjustAirAccelQW(float accelqw, float factor); bool IsFlying(entity a); +#define PHYS_AMMO_FUEL(s) STAT(FUEL, s) + #ifdef CSQC const int FL_WATERJUMP = 2048; // player jumping out of water @@ -98,8 +100,6 @@ bool IsFlying(entity a); #define ITEMS_STAT(s) (s).items #define BUFFS_STAT(s) getstati(STAT_BUFFS) - #define PHYS_AMMO_FUEL(s) getstati(STAT_FUEL) - #define PHYS_FROZEN(s) getstati(STAT_FROZEN) #define PHYS_DOUBLEJUMP getstati(STAT_DOUBLEJUMP) @@ -301,8 +301,6 @@ bool IsFlying(entity a); #define ITEMS_STAT(s) s.items #define BUFFS_STAT(s) (s).buffs - #define PHYS_AMMO_FUEL(s) s.ammo_fuel - #define PHYS_FROZEN(s) s.frozen #define PHYS_DOUBLEJUMP autocvar_sv_doublejump diff --git a/qcsrc/common/stats.qh b/qcsrc/common/stats.qh index 1a9a38fc5..0096000e4 100644 --- a/qcsrc/common/stats.qh +++ b/qcsrc/common/stats.qh @@ -89,7 +89,7 @@ enum { STAT_LAST_VECTOR }; -const int REGISTERED_STATS = 8; +const int REGISTERED_STATS = 9; REGISTER_STAT(KH_KEYS, int) /** weapon requested to switch to; next WANTED weapon (for HUD) */ @@ -102,11 +102,11 @@ REGISTER_STAT(ARC_HEAT, float) REGISTER_STAT(PRESSED_KEYS, int) /** this stat could later contain some other bits of info, like, more server-side particle config */ REGISTER_STAT(ALLOW_OLDVORTEXBEAM, bool) +REGISTER_STAT(FUEL, int) enum { STAT_FIRST_MAIN = (STAT_LAST_VECTOR - 1) + REGISTERED_STATS, - STAT_FUEL, STAT_NB_METERSTART, /** compressShotOrigin */ STAT_SHOTORG, STAT_LEADLIMIT, diff --git a/qcsrc/common/weapons/all.qc b/qcsrc/common/weapons/all.qc index b33812213..f0d7b19b6 100644 --- a/qcsrc/common/weapons/all.qc +++ b/qcsrc/common/weapons/all.qc @@ -283,7 +283,7 @@ int GetAmmoStat(.int ammotype) case ammo_rockets: return STAT_ROCKETS; case ammo_cells: return STAT_CELLS; case ammo_plasma: return STAT_PLASMA; - case ammo_fuel: return STAT_FUEL; + case ammo_fuel: return STAT_FUEL.m_id; default: return -1; } } diff --git a/qcsrc/common/weapons/weapon.qh b/qcsrc/common/weapons/weapon.qh index 3a878a461..162443bf0 100644 --- a/qcsrc/common/weapons/weapon.qh +++ b/qcsrc/common/weapons/weapon.qh @@ -1,6 +1,7 @@ #ifndef WEAPON_H #define WEAPON_H #include "../items/item/pickup.qh" +#include "../stats.qh" const int MAX_WEAPONSLOTS = 2; .entity weaponentities[MAX_WEAPONSLOTS]; @@ -17,6 +18,15 @@ int weaponslot(.entity weaponentity) return 0; } +#ifdef SVQC +.int ammo_shells; +.int ammo_nails; +.int ammo_rockets; +.int ammo_cells; +.int ammo_plasma; +.int ammo_fuel = _STAT(FUEL); +.int ammo_none; +#else .int ammo_shells; .int ammo_nails; .int ammo_rockets; @@ -24,6 +34,7 @@ int weaponslot(.entity weaponentity) .int ammo_plasma; .int ammo_fuel; .int ammo_none; +#endif /** fields which are explicitly/manually set are marked with "M", fields set automatically are marked with "A" */ CLASS(Weapon, Object) diff --git a/qcsrc/server/g_world.qc b/qcsrc/server/g_world.qc index eeb6801de..202ed1190 100644 --- a/qcsrc/server/g_world.qc +++ b/qcsrc/server/g_world.qc @@ -762,7 +762,6 @@ spawnfunc(worldspawn) Nagger_Init(); addstat(STAT_SUPERWEAPONS_FINISHED, AS_FLOAT, superweapons_finished); - addstat(STAT_FUEL, AS_INT, ammo_fuel); addstat(STAT_PLASMA, AS_INT, ammo_plasma); addstat(STAT_SHOTORG, AS_INT, stat_shotorg); addstat(STAT_LEADLIMIT, AS_FLOAT, stat_leadlimit); -- 2.39.2