From a2534e940afed54c3f1ba5ab159254c21b40334f Mon Sep 17 00:00:00 2001 From: TimePath Date: Tue, 6 Oct 2015 21:16:24 +1100 Subject: [PATCH] Models: rename registry globals --- qcsrc/client/_all.qh | 2 +- qcsrc/common/models/{models.inc => all.inc} | 6 +++--- qcsrc/common/models/{models.qh => all.qh} | 17 +++++++---------- qcsrc/common/weapons/all.qh | 2 +- qcsrc/server/_all.qh | 2 +- 5 files changed, 13 insertions(+), 16 deletions(-) rename qcsrc/common/models/{models.inc => all.inc} (99%) rename qcsrc/common/models/{models.qh => all.qh} (75%) diff --git a/qcsrc/client/_all.qh b/qcsrc/client/_all.qh index a1fcb931f..0fe1c616f 100644 --- a/qcsrc/client/_all.qh +++ b/qcsrc/client/_all.qh @@ -8,7 +8,7 @@ #include "../dpdefs/csprogsdefs.qh" -#include "../common/models/models.qh" +#include "../common/models/all.qh" #include "../common/sounds/all.qh" #endif diff --git a/qcsrc/common/models/models.inc b/qcsrc/common/models/all.inc similarity index 99% rename from qcsrc/common/models/models.inc rename to qcsrc/common/models/all.inc index d398cc951..f675d8a9e 100644 --- a/qcsrc/common/models/models.inc +++ b/qcsrc/common/models/all.inc @@ -144,7 +144,7 @@ MODEL(GIB_ROBO_7, "models/gibs/robo7.md3"); MODEL(GIB_ROBO_8, "models/gibs/robo8.md3"); Model MDL_GIB_ROBO_RANDOM() { int i = floor(random() * 8); - return MODELS[MDL_GIB_ROBO_1.m_id + i]; + return Models[MDL_GIB_ROBO_1.m_id + i]; } MODEL(CASING_SHELL, "models/casing_shell.mdl"); @@ -345,9 +345,9 @@ MODEL(8, "models/sprites/8.spr32"); MODEL(9, "models/sprites/9.spr32"); MODEL(10, "models/sprites/10.spr32"); Model MDL_NUM(int i) { - if (!(i >= 0 && i <= 10)) + if ((i >= 0 && i <= 10)) + return Models[MDL_0.m_id + i]; return MDL_Null; - return MODELS[MDL_0.m_id + i]; } MODEL(WAYPOINT, "models/runematch/rune.mdl"); diff --git a/qcsrc/common/models/models.qh b/qcsrc/common/models/all.qh similarity index 75% rename from qcsrc/common/models/models.qh rename to qcsrc/common/models/all.qh index 0d17f43ab..0f9464431 100644 --- a/qcsrc/common/models/models.qh +++ b/qcsrc/common/models/all.qh @@ -1,12 +1,10 @@ -#ifndef MODELS_H -#define MODELS_H +#ifndef MODELS_ALL_H +#define MODELS_ALL_H #define setmodel(e, m) _setmodel((e), (m).model_str()) -void RegisterModels(); -const int MAX_MODELS = 128; -entity MODELS[MAX_MODELS], MODELS_first, MODELS_last; -int MODELS_COUNT; +REGISTRY(Models, 128) +REGISTER_REGISTRY(RegisterModels) CLASS(Model, Object) ATTRIB(Model, m_id, int, 0) @@ -29,16 +27,15 @@ ENDCLASS(Model) #define MODEL(name, path) \ string MDL_##name##_get() { return path; } \ - REGISTER(RegisterModels, MDL, MODELS, MODELS_COUNT, name, m_id, NEW(Model, MDL_##name##_get)) -REGISTER_REGISTRY(RegisterModels) + REGISTER(RegisterModels, MDL, Models, Models_COUNT, name, m_id, NEW(Model, MDL_##name##_get)) STATIC_INIT(RegisterModels_precache) { - FOREACH(MODELS, true, LAMBDA({ + FOREACH(Models, true, LAMBDA({ it.model_precache(it); })); } MODEL(Null, "null"); -#include "models.inc" +#include "all.inc" #endif diff --git a/qcsrc/common/weapons/all.qh b/qcsrc/common/weapons/all.qh index baba31192..c1b8527af 100644 --- a/qcsrc/common/weapons/all.qh +++ b/qcsrc/common/weapons/all.qh @@ -21,7 +21,7 @@ WepSet ReadWepSet(); #ifndef MENUQC #include "calculations.qh" -#include "../models/models.qh" +#include "../models/all.qh" #endif #include "../util.qh" diff --git a/qcsrc/server/_all.qh b/qcsrc/server/_all.qh index f5644c004..3e99cabeb 100644 --- a/qcsrc/server/_all.qh +++ b/qcsrc/server/_all.qh @@ -9,7 +9,7 @@ #include "../dpdefs/progsdefs.qh" #include "../dpdefs/dpextensions.qh" -#include "../common/models/models.qh" +#include "../common/models/all.qh" #include "../common/sounds/all.qh" #endif -- 2.39.2