From: TimePath Date: Tue, 6 Oct 2015 10:04:49 +0000 (+1100) Subject: Monsters: rename registry globals X-Git-Tag: xonotic-v0.8.2~1870 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=fcee80c3699f658c200d27911472a248b7b22a9f;p=xonotic%2Fxonotic-data.pk3dir.git Monsters: rename registry globals --- diff --git a/qcsrc/common/monsters/all.qc b/qcsrc/common/monsters/all.qc index 232441e57..f4b2a4bf0 100644 --- a/qcsrc/common/monsters/all.qc +++ b/qcsrc/common/monsters/all.qc @@ -3,15 +3,6 @@ #include "all.qh" -entity get_monsterinfo(int id) -{ - if (id >= MON_FIRST && id <= MON_LAST) { - entity m = monster_info[id]; - if (m) return m; - } - return MON_Null; -} - #define IMPLEMENTATION #include "all.inc" #undef IMPLEMENTATION diff --git a/qcsrc/common/monsters/all.qh b/qcsrc/common/monsters/all.qh index 7c2f13ddf..f31e976d6 100644 --- a/qcsrc/common/monsters/all.qh +++ b/qcsrc/common/monsters/all.qh @@ -3,21 +3,24 @@ #include "monster.qh" -void RegisterMonsters(); -const int MON_MAXCOUNT = 24; -entity monster_info[MON_MAXCOUNT], monster_info_first, monster_info_last; -entity get_monsterinfo(float id); -int MON_COUNT; +REGISTRY(Monsters, 24) +REGISTER_REGISTRY(RegisterMonsters) const int MON_FIRST = 1; -#define MON_LAST (MON_FIRST + MON_COUNT - 1) +#define MON_LAST (Monsters_COUNT - 1) /** If you register a new monster, make sure to add it to all.inc */ -#define REGISTER_MONSTER(id, inst) REGISTER(RegisterMonsters, MON, monster_info, MON_COUNT, id, monsterid, inst) -REGISTER_REGISTRY(RegisterMonsters) - -entity get_monsterinfo(int id); +#define REGISTER_MONSTER(id, inst) REGISTER(RegisterMonsters, MON, Monsters, Monsters_COUNT, id, monsterid, inst) REGISTER_MONSTER(Null, NEW(Monster)); +Monster get_monsterinfo(int id) +{ + if (id >= MON_FIRST && id <= MON_LAST) { + Monster m = Monsters[id]; + if (m) return m; + } + return MON_Null; +} + #include "all.inc" #endif