From a303b1b8c956c0476b0676dcea2fa0af1eab6b5b Mon Sep 17 00:00:00 2001 From: TimePath Date: Tue, 6 Oct 2015 20:57:58 +1100 Subject: [PATCH] Turrets: rename registry globals --- qcsrc/common/turrets/all.qc | 9 --------- qcsrc/common/turrets/all.qh | 21 +++++++++++++-------- qcsrc/common/turrets/config.qc | 4 ++-- 3 files changed, 15 insertions(+), 19 deletions(-) diff --git a/qcsrc/common/turrets/all.qc b/qcsrc/common/turrets/all.qc index c23a13861..d996778e6 100644 --- a/qcsrc/common/turrets/all.qc +++ b/qcsrc/common/turrets/all.qc @@ -1,14 +1,5 @@ #include "all.qh" -Turret get_turretinfo(int id) -{ - if (id < 1 || id > TUR_COUNT - 1) - return TUR_Null; - Turret m = turret_info[id]; - if (m) return m; - return TUR_Null; -} - #ifdef SVQC #include "sv_turrets.qh" #endif diff --git a/qcsrc/common/turrets/all.qh b/qcsrc/common/turrets/all.qh index 87a30c920..eb001bd4a 100644 --- a/qcsrc/common/turrets/all.qh +++ b/qcsrc/common/turrets/all.qh @@ -3,19 +3,24 @@ #include "turret.qh" -const int TUR_MAXCOUNT = 24; -entity turret_info[TUR_MAXCOUNT], turret_info_first, turret_info_last; -float TUR_COUNT; - -void RegisterTurrets(); +REGISTRY(Turrets, 24) REGISTER_REGISTRY(RegisterTurrets) +const int TUR_FIRST = 1; +#define TUR_LAST (Turrets_COUNT - 1) -#define REGISTER_TURRET(id, inst) REGISTER(RegisterTurrets, TUR, turret_info, TUR_COUNT, id, m_id, inst) - -entity get_turretinfo(int id); +#define REGISTER_TURRET(id, inst) REGISTER(RegisterTurrets, TUR, Turrets, Turrets_COUNT, id, m_id, inst) REGISTER_TURRET(Null, NEW(Turret)); +Turret get_turretinfo(int id) +{ + if (id >= TUR_FIRST && id <= TUR_LAST) { + Turret t = Turrets[id]; + if (t) return t; + } + return TUR_Null; +} + #include "all.inc" #endif diff --git a/qcsrc/common/turrets/config.qc b/qcsrc/common/turrets/config.qc index e052d6c1c..c2a609b15 100644 --- a/qcsrc/common/turrets/config.qc +++ b/qcsrc/common/turrets/config.qc @@ -28,7 +28,7 @@ float T_Config_Queue_Compare(float root, float child, entity pass) void Dump_Turret_Settings(void) { float x, totalsettings = 0; - FOREACH(turret_info, it != TUR_Null, LAMBDA({ + FOREACH(Turrets, it != TUR_Null, LAMBDA({ // step 1: clear the queue TUR_CONFIG_COUNT = 0; for(x = 0; x <= MAX_TUR_CONFIG; ++x) @@ -57,5 +57,5 @@ void Dump_Turret_Settings(void) { tur_config_queue[x] = string_null; } // extra information - LOG_INFO(sprintf("Totals: %d turrets, %d settings\n", (TUR_COUNT - 1), totalsettings)); + LOG_INFO(sprintf("Totals: %d turrets, %d settings\n", (Turrets_COUNT - 1), totalsettings)); } -- 2.39.2