]> 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 3f8c603e7ab2aabeb75c74f438a00e73bba7593b..359c0017955794bade60ea96a9565ed2edf5c009 100644 (file)
@@ -1,20 +1,39 @@
-#ifndef ITEMS_ALL_H
-#define ITEMS_ALL_H
+#pragma once
 
-void RegisterItems();
-const int MAX_ITEMS = 24;
-entity ITEMS[MAX_ITEMS], ITEMS_first, ITEMS_last;
-int ITEM_COUNT;
-/** 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))
-REGISTER_REGISTRY(RegisterItems)
+#include <common/command/_mod.qh>
 
-void Dump_Items();
+#include "item.qh"
 
-#ifndef MENUQC
-string Item_Model(string item_mdl);
+// 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))
 
-#endif
+REGISTRY_SORT(Items)
+REGISTRY_CHECK(Items)
 
-#include "inventory.qh"
+REGISTRY_DEFINE_GET(Items, NULL)
+STATIC_INIT(Items) { FOREACH(Items, true, it.m_id = i); }
+
+void Dump_Items();
+
+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;
+        }
+    }
+}
+
+#ifdef GAMEQC
+string Item_Model(string item_mdl);
+#endif