]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/items/all.qh
Merge branch 'master' into Mario/bulldozer
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / items / all.qh
index 7290b95a90f1c26c3509198193b8bdb98b4d3060..ab86ea6736eaca2b592cb6e212bdc1aa6b42392b 100644 (file)
@@ -1,38 +1,38 @@
-#ifndef ALL_H
-#define ALL_H
+#ifndef ITEMS_ALL_H
+#define ITEMS_ALL_H
 
-const int MAX_ITEMS = 23;
-entity ITEMS[MAX_ITEMS];
+#include "../command/all.qh"
 
-#define ITEMS_FOREACH(pred, body) do {      \
-    for (int i = 0; i < ITEM_COUNT; i++) {  \
-        const entity it = ITEMS[i];         \
-        if (pred) { body }                  \
-    }                                       \
-} while(0)
+#include "item.qh"
+
+REGISTRY(Items, BITS(5))
+#define Items_from(i) _Items_from(i, NULL)
+REGISTER_REGISTRY(Items)
+/** If you register a new item, make sure to add it to all.inc */
+#define REGISTER_ITEM(id, class) REGISTER(Items, ITEM, id, m_id, NEW(class))
+
+REGISTRY_SORT(Items, 0)
+REGISTRY_CHECK(Items)
+STATIC_INIT(Items) { FOREACH(Items, true, LAMBDA(it.m_id = i)); }
 
-void RegisterItems();
 void Dump_Items();
 
-#ifdef CSQC
-void ReadItems()
-{
-/*
-    const int flags = read();
-    for (int i = 0; i < MAX_ITEMS; i++) {
-        if (flags & BIT(i)) {
-            self.items[i] = read();
+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;
         }
     }
-*/
 }
-#endif
-
-#ifdef SVQC
-void WriteItems()
-{
 
-}
+#ifndef MENUQC
+string Item_Model(string item_mdl);
 #endif
 
 #endif