]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/items/all.qh
Registry: use BITS everywhere
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / items / all.qh
index 1786b4261131d020fa92996027dee78c44c25a8d..4d76aa3386dfb8cd54b0ad104f07017df9554a14 100644 (file)
@@ -1,19 +1,36 @@
-#ifndef ALL_H
-#define ALL_H
+#ifndef ITEMS_ALL_H
+#define ITEMS_ALL_H
 
-const int MAX_ITEMS = 24;
-entity ITEMS[MAX_ITEMS];
+#include "../command/all.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"
+
+REGISTRY(Items, BITS(5))
+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, id, m_id, NEW(class))
+
+REGISTRY_SORT(Items, m_name, 0)
+STATIC_INIT(Items) { FOREACH(Items, true, LAMBDA(it.m_id = i)); }
 
-void RegisterItems();
 void Dump_Items();
 
+GENERIC_COMMAND(dumpitems, "Dump all items to the console") {
+    switch (request) {
+        case CMD_REQUEST_COMMAND: {
+            Dump_Items();
+            return;
+        }
+        default:
+        case CMD_REQUEST_USAGE: {
+            LOG_INFOF("\nUsage:^3 %s dumpitems", GetProgramCommandPrefix());
+            return;
+        }
+    }
+}
+
+#ifndef MENUQC
+string Item_Model(string item_mdl);
 #endif
 
-#include "inventory.qh"
+#endif