#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
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)
{ 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));
}