]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/items/inventory.qh
Itemstime: fix regression introduced by 0c071920ffd10ccebde36092b7b91eb1673ae856
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / items / inventory.qh
index 89abc97cff2a82f252cca4730061a367b741c354..ba137a8f94ab3d7f98a7d4fcde1ab922abfb444f 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,12 +15,12 @@ class(Inventory) .int inv_items[MAX_ITEMS];
 void Inventory_Read(Inventory data)
 {
     const int bits = ReadInt24_t();
-    ITEMS_FOREACH(bits & BIT(i), LAMBDA({
-        .int fld = inv_items[i];
+    FOREACH(Items, bits & BIT(it.m_id), LAMBDA(
+        .int fld = inv_items[it.m_id];
         int prev = data.(fld);
         int next = data.(fld) = ReadByte();
-        dprintf("%s: %.0f -> %.0f\n", ITEMS[i].m_name, prev, next);
-    }));
+        LOG_TRACEF("%s: %.0f -> %.0f\n", it.m_name, prev, next);
+    ));
 }
 #endif
 
@@ -28,20 +28,20 @@ void Inventory_Read(Inventory data)
 void Inventory_Write(Inventory data)
 {
     int bits = 0;
-    ITEMS_FOREACH(true, LAMBDA({
-        .int fld = inv_items[i];
-        bits = BITSET(bits, BIT(i), data.inventory.(fld) != (data.inventory.(fld) = data.(fld)));
-    }));
+    FOREACH(Items, true, LAMBDA(
+        .int fld = inv_items[it.m_id];
+        bits = BITSET(bits, BIT(it.m_id), data.inventory.(fld) != (data.inventory.(fld) = data.(fld)));
+    ));
     WriteInt24_t(MSG_ENTITY, bits);
-    ITEMS_FOREACH(bits & BIT(i), LAMBDA({
-        WriteByte(MSG_ENTITY, data.inv_items[i]);
-    }));
+    FOREACH(Items, bits & BIT(it.m_id), LAMBDA(
+        WriteByte(MSG_ENTITY, data.inv_items[it.m_id]);
+    ));
 }
 #endif
 
 #ifdef SVQC
 bool Inventory_Send(entity to, int sf)
-{
+{SELFPARAM();
     WriteByte(MSG_ENTITY, ENT_CLIENT_INVENTORY);
     entity e = self.owner;
     if (IS_SPEC(e)) e = e.enemy;