]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/items/all.qh
Merge branch 'master' into Mario/speed_var
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / items / all.qh
index 1786b4261131d020fa92996027dee78c44c25a8d..359c0017955794bade60ea96a9565ed2edf5c009 100644 (file)
@@ -1,19 +1,39 @@
-#ifndef ALL_H
-#define ALL_H
+#pragma once
 
-const int MAX_ITEMS = 24;
-entity ITEMS[MAX_ITEMS];
+#include <common/command/_mod.qh>
 
-#define ITEMS_FOREACH(pred, body) do {      \
-    for (int i = 0; i < ITEM_COUNT; i++) {  \
-        const noref entity it = ITEMS[i];   \
-        if (pred) { body }                  \
-    }                                       \
-} while(0)
+#include "item.qh"
+
+// NOTE: 24 is the limit for the .items field
+REGISTRY(Items, 32)
+#ifdef GAMEQC
+REGISTRY_DEPENDS(Items, Models)
+#endif
+REGISTER_REGISTRY(Items)
+#define REGISTER_ITEM(id, class) REGISTER(Items, ITEM, id, m_id, NEW(class))
+
+REGISTRY_SORT(Items)
+REGISTRY_CHECK(Items)
+
+REGISTRY_DEFINE_GET(Items, NULL)
+STATIC_INIT(Items) { FOREACH(Items, true, it.m_id = i); }
 
-void RegisterItems();
 void Dump_Items();
 
-#endif
+GENERIC_COMMAND(dumpitems, "Dump all items to the console", false) {
+    switch (request) {
+        case CMD_REQUEST_COMMAND: {
+            Dump_Items();
+            return;
+        }
+        default:
+        case CMD_REQUEST_USAGE: {
+            LOG_HELPF("Usage:^3 %s dumpitems", GetProgramCommandPrefix());
+            return;
+        }
+    }
+}
 
-#include "inventory.qh"
+#ifdef GAMEQC
+string Item_Model(string item_mdl);
+#endif