]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Items: rename registry globals
authorTimePath <andrew.hardaker1995@gmail.com>
Tue, 6 Oct 2015 10:08:39 +0000 (21:08 +1100)
committerTimePath <andrew.hardaker1995@gmail.com>
Tue, 6 Oct 2015 10:08:39 +0000 (21:08 +1100)
qcsrc/common/items/all.qc
qcsrc/common/items/all.qh
qcsrc/common/items/inventory.qh
qcsrc/common/mutators/mutator/itemstime.qc
qcsrc/common/mutators/mutator/waypoints/waypointsprites.qc

index 8a9e314020bd16f100774837050c14d3ed3019a5..927b2ece26c1ed5282d9dda604c765a1aac0c281 100644 (file)
@@ -6,7 +6,7 @@
 
 void Dump_Items()
 {
-    FOREACH(ITEMS, true, LAMBDA(
+    FOREACH(Items, true, LAMBDA(
         ITEM_HANDLE(Show, it);
     ));
 }
index 3f8c603e7ab2aabeb75c74f438a00e73bba7593b..b2b0dc1e411f59616a9f198902e6c3f3f17ad0dc 100644 (file)
@@ -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();
index 2ec8837d48e16d527114973be62f1c75b5e3c516..64fa29cfc9f31fa312a567bd1dbcd3245caa3257 100644 (file)
@@ -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]);
     ));
 }
index 3cdb7b69978ad6ef98c85787bc733bf0913378f9..1f17450e2faedd572d011d52257a75422b58eae2 100644 (file)
@@ -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)
         {
index 2015acb5f8cda0d73408d9794465873fbf1b5aa6..a083ae15925684cb8c67ca1eff236944ce62ea32 100644 (file)
@@ -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;