From: TimePath Date: Tue, 6 Oct 2015 10:08:39 +0000 (+1100) Subject: Items: rename registry globals X-Git-Tag: xonotic-v0.8.2~1869 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=0c071920ffd10ccebde36092b7b91eb1673ae856;p=xonotic%2Fxonotic-data.pk3dir.git Items: rename registry globals --- diff --git a/qcsrc/common/items/all.qc b/qcsrc/common/items/all.qc index 8a9e31402..927b2ece2 100644 --- a/qcsrc/common/items/all.qc +++ b/qcsrc/common/items/all.qc @@ -6,7 +6,7 @@ void Dump_Items() { - FOREACH(ITEMS, true, LAMBDA( + FOREACH(Items, true, LAMBDA( ITEM_HANDLE(Show, it); )); } diff --git a/qcsrc/common/items/all.qh b/qcsrc/common/items/all.qh index 3f8c603e7..b2b0dc1e4 100644 --- a/qcsrc/common/items/all.qh +++ b/qcsrc/common/items/all.qh @@ -1,12 +1,12 @@ #ifndef ITEMS_ALL_H #define ITEMS_ALL_H -void RegisterItems(); -const int MAX_ITEMS = 24; -entity ITEMS[MAX_ITEMS], ITEMS_first, ITEMS_last; -int ITEM_COUNT; +#include "item.qh" + +REGISTRY(Items, 24) +REGISTER_REGISTRY(RegisterItems) /** If you register a new item, make sure to add it to all.inc */ -#define REGISTER_ITEM(id, class) REGISTER(RegisterItems, ITEM, ITEMS, ITEM_COUNT, id, m_id, NEW(class)) +#define REGISTER_ITEM(id, class) REGISTER(RegisterItems, ITEM, Items, Items_COUNT, id, m_id, NEW(class)) REGISTER_REGISTRY(RegisterItems) void Dump_Items(); diff --git a/qcsrc/common/items/inventory.qh b/qcsrc/common/items/inventory.qh index 2ec8837d4..64fa29cfc 100644 --- a/qcsrc/common/items/inventory.qh +++ b/qcsrc/common/items/inventory.qh @@ -6,7 +6,7 @@ entityclass(Inventory); /** Stores counts of items, the id being the index */ -class(Inventory) .int inv_items[MAX_ITEMS]; +class(Inventory) .int inv_items[Items_MAX]; /** Player inventory; Inventories also have one inventory for storing the previous state */ .Inventory inventory; @@ -15,11 +15,11 @@ class(Inventory) .int inv_items[MAX_ITEMS]; void Inventory_Read(Inventory data) { const int bits = ReadInt24_t(); - FOREACH(ITEMS, bits & BIT(i), LAMBDA( + FOREACH(Items, bits & BIT(i), LAMBDA( .int fld = inv_items[i]; int prev = data.(fld); int next = data.(fld) = ReadByte(); - LOG_TRACEF("%s: %.0f -> %.0f\n", ITEMS[i].m_name, prev, next); + LOG_TRACEF("%s: %.0f -> %.0f\n", Items[i].m_name, prev, next); )); } #endif @@ -28,12 +28,12 @@ void Inventory_Read(Inventory data) void Inventory_Write(Inventory data) { int bits = 0; - FOREACH(ITEMS, true, LAMBDA( + FOREACH(Items, true, LAMBDA( .int fld = inv_items[i]; bits = BITSET(bits, BIT(i), data.inventory.(fld) != (data.inventory.(fld) = data.(fld))); )); WriteInt24_t(MSG_ENTITY, bits); - FOREACH(ITEMS, bits & BIT(i), LAMBDA( + FOREACH(Items, bits & BIT(i), LAMBDA( WriteByte(MSG_ENTITY, data.inv_items[i]); )); } diff --git a/qcsrc/common/mutators/mutator/itemstime.qc b/qcsrc/common/mutators/mutator/itemstime.qc index 3cdb7b699..1f17450e2 100644 --- a/qcsrc/common/mutators/mutator/itemstime.qc +++ b/qcsrc/common/mutators/mutator/itemstime.qc @@ -12,8 +12,8 @@ void IT_Write(entity e, int i, float f) { #endif #ifdef CSQC -float ItemsTime_time[MAX_ITEMS]; -float ItemsTime_availableTime[MAX_ITEMS]; +float ItemsTime_time[Items_MAX]; +float ItemsTime_availableTime[Items_MAX]; MUTATOR_HOOKFUNCTION(itemstime, CSQC_Parse_TempEntity) { if (MUTATOR_RETURNVALUE) return false; if (!ReadMutatorEquals(mutator_argv_int_0, itemstime)) return false; @@ -60,11 +60,11 @@ bool Item_ItemsTime_Allow(GameItem it, WepSet _weapons) #ifdef SVQC -float it_times[MAX_ITEMS]; +float it_times[Items_MAX]; void Item_ItemsTime_Init() { - FOREACH(ITEMS, true, LAMBDA( + FOREACH(Items, true, LAMBDA( it_times[it.m_id] = -1; )); } @@ -76,21 +76,21 @@ STATIC_INIT(ItemsTime_Init) { void Item_ItemsTime_ResetTimes() { - FOREACH(ITEMS, true, LAMBDA( + FOREACH(Items, true, LAMBDA( it_times[it.m_id] = (it_times[it.m_id] == -1) ? -1 : 0; )); } void Item_ItemsTime_ResetTimesForPlayer(entity e) { - FOREACH(ITEMS, true, LAMBDA( + FOREACH(Items, true, LAMBDA( IT_Write(e, it.m_id, (it_times[it.m_id] == -1) ? -1 : 0); )); } void Item_ItemsTime_SetTimesForPlayer(entity e) { - FOREACH(ITEMS, true, LAMBDA( + FOREACH(Items, true, LAMBDA( IT_Write(e, it.m_id, it_times[it.m_id]); )); } @@ -265,15 +265,15 @@ void HUD_ItemsTime() int count = 0; if (autocvar_hud_panel_itemstime_hidespawned == 1) - FOREACH(ITEMS, Item_ItemsTime_Allow(it, '0 0 0'), LAMBDA( + FOREACH(Items, Item_ItemsTime_Allow(it, '0 0 0'), LAMBDA( count += (ItemsTime_time[i] > time || -ItemsTime_time[i] > time); )); else if (autocvar_hud_panel_itemstime_hidespawned == 2) - FOREACH(ITEMS, Item_ItemsTime_Allow(it, '0 0 0'), LAMBDA( + FOREACH(Items, Item_ItemsTime_Allow(it, '0 0 0'), LAMBDA( count += (ItemsTime_time[i] > time); )); else - FOREACH(ITEMS, Item_ItemsTime_Allow(it, '0 0 0'), LAMBDA( + FOREACH(Items, Item_ItemsTime_Allow(it, '0 0 0'), LAMBDA( count += (ItemsTime_time[i] != -1); )); if (count == 0) @@ -346,7 +346,7 @@ void HUD_ItemsTime() float row = 0, column = 0; bool item_available; - FOREACH(ITEMS, Item_ItemsTime_Allow(it, '0 0 0') && ItemsTime_time[i] != -1, LAMBDA( + FOREACH(Items, Item_ItemsTime_Allow(it, '0 0 0') && ItemsTime_time[i] != -1, LAMBDA( float item_time = ItemsTime_time[i]; if (item_time < -1) { diff --git a/qcsrc/common/mutators/mutator/waypoints/waypointsprites.qc b/qcsrc/common/mutators/mutator/waypoints/waypointsprites.qc index 2015acb5f..a083ae159 100644 --- a/qcsrc/common/mutators/mutator/waypoints/waypointsprites.qc +++ b/qcsrc/common/mutators/mutator/waypoints/waypointsprites.qc @@ -237,7 +237,7 @@ float spritelookupblinkvalue(string s) if (get_weaponinfo(self.wp_extra).spawnflags & WEP_FLAG_SUPERWEAPON) return 2; } - if (s == WP_Item.netname) return ITEMS[self.wp_extra].m_waypointblink; + if (s == WP_Item.netname) return Items[self.wp_extra].m_waypointblink; return 1; } @@ -245,7 +245,7 @@ float spritelookupblinkvalue(string s) vector spritelookupcolor(string s, vector def) {SELFPARAM(); if (s == WP_Weapon.netname) return get_weaponinfo(self.wp_extra).wpcolor; - if (s == WP_Item.netname) return ITEMS[self.wp_extra].m_color; + if (s == WP_Item.netname) return Items[self.wp_extra].m_color; if (s == WP_Buff.netname) return BUFFS[self.wp_extra].m_color; return def; } @@ -254,7 +254,7 @@ string spritelookuptext(string s) {SELFPARAM(); if (s == WP_RaceStartFinish.netname) return (race_checkpointtime || race_mycheckpointtime) ? _("Finish") : _("Start"); if (s == WP_Weapon.netname) return get_weaponinfo(self.wp_extra).message; - if (s == WP_Item.netname) return ITEMS[self.wp_extra].m_waypoint; + if (s == WP_Item.netname) return Items[self.wp_extra].m_waypoint; if (s == WP_Buff.netname) return BUFFS[self.wp_extra].m_prettyName; if (s == WP_Monster.netname) return get_monsterinfo(self.wp_extra).monster_name;