#include "../registry.qh"
-#ifndef ALL_H
-#define ALL_H
+#ifndef ITEMS_ALL_H
+#define ITEMS_ALL_H
void RegisterItems();
const int MAX_ITEMS = 24;
entity ITEMS[MAX_ITEMS];
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, class)
+#define REGISTER_ITEM(id, class) REGISTER(RegisterItems, ITEM, ITEMS, ITEM_COUNT, id, class, m_id)
#define ITEMS_FOREACH(pred, body) do { \
for (int i = 0; i < ITEM_COUNT; i++) { \
#ifndef REGISTRY_H
#define REGISTRY_H
-#define REGISTER(initfunc, ns, array, counter, id, class) \
- entity ns##_##id; \
- void Register_##ns##_##id##_init(entity this) { } \
- void Register_##ns##_##id() { \
- entity this = NEW(class); \
- ns##_##id = this; \
- this.m_id = ns##_COUNT; \
- array[counter++] = this; \
- Register_##ns##_##id##_init(this); \
- } \
- ACCUMULATE_FUNCTION(initfunc, Register_##ns##_##id) \
- [[accumulate]] void Register_##ns##_##id##_init(entity this)
+#define REGISTER_INIT(ns, id) [[accumulate]] void Register_##ns##_##id##_init(entity this)
+
+#define REGISTER(initfunc, ns, array, counter, id, class, fld) \
+ entity ns##_##id; \
+ REGISTER_INIT(ns, id) { } \
+ void Register_##ns##_##id() { \
+ entity this = NEW(class); \
+ ns##_##id = this; \
+ this.fld = ns##_COUNT; \
+ array[counter++] = this; \
+ Register_##ns##_##id##_init(this); \
+ } \
+ ACCUMULATE_FUNCTION(initfunc, Register_##ns##_##id) \
+ REGISTER_INIT(ns, id)
#endif