#include "teams.qh"
#include "util.qh"
-#include "registry.qh"
-
void RegisterBuffs();
const int BUFFS_MAX = 16;
entity BUFFS[BUFFS_MAX], BUFFS_first, BUFFS_last;
-#include "../registry.qh"
-
#ifndef ITEMS_ALL_H
#define ITEMS_ALL_H
#ifndef GAMEITEM_H
#define GAMEITEM_H
-#include "../oo.qh"
#define ITEM_HANDLE(signal, ...) __Item_Send_##signal(__VA_ARGS__)
/** If you register a new item, make sure to add it to all.inc */
CLASS(GameItem, Object)
-#include "../registry.qh"
-
#ifndef MONSTERS_ALL_H
#define MONSTERS_ALL_H
bool m_null(int) { return false; }
-#include "../oo.qh"
/** If you register a new monster, make sure to add it to all.inc */
CLASS(Monster, Object)
ATTRIB(Monster, monsterid, int, 0)
-#include "../../../registry.qh"
-
#ifndef WAYPOINTS_ALL_H
#define WAYPOINTS_ALL_H
#ifndef NADES_H
#define NADES_H
-#include "oo.qh"
-#include "registry.qh"
#include "teams.qh"
.float healer_lifetime;
+++ /dev/null
-#ifndef OO_H
-#define OO_H
-
-#include "registry.qh"
-
-#ifdef MENUQC
- #define NULL (null_entity)
-#else
- #define NULL (world)
-#endif
-
-.string classname;
-/** Location entity was spawned from in source */
-.string sourceLocFile;
-.int sourceLocLine;
-entity _spawn();
-entity __spawn(string _classname, string _sourceFile, int _sourceLine) {
- entity this = _spawn();
- this.classname = _classname;
- this.sourceLocFile = _sourceFile;
- this.sourceLocLine = _sourceLine;
- return this;
-}
-
-
-
-#define entityclass(...) OVERLOAD(entityclass, __VA_ARGS__)
-#define entityclass_1(name) entityclass_2(name, Object)
-#ifndef QCC_SUPPORT_ENTITYCLASS
- #define entityclass_2(name, base) typedef entity name
- #define class(name)
- #define new(class) __spawn(#class, __FILE__, __LINE__)
-#else
- #define entityclass_2(name, base) entityclass name : base {}
- #define class(name) [[class(name)]]
- #define new(class) ((class) __spawn(#class, __FILE__, __LINE__))
-#endif
-
-// Classes have a `spawn##cname(entity)` constructor
-// The parameter is used across [[accumulate]] functions
-
-// Macro to hide this implementation detail
-#define NEW(cname, ...) \
- OVERLOAD(spawn##cname, new(cname), ##__VA_ARGS__)
-
-#define CONSTRUCT(cname, ...) \
- OVERLOAD(spawn##cname, this, ##__VA_ARGS__)
-
-#define CONSTRUCTOR(cname, ...) \
- cname OVERLOAD(spawn##cname, cname this, __VA_ARGS__) { return = this; } \
- [[accumulate]] cname OVERLOAD(spawn##cname, cname this, __VA_ARGS__)
-
-.string vtblname;
-.entity vtblbase;
-
-void RegisterClasses() { }
-STATIC_INIT(RegisterClasses) { RegisterClasses(); }
-
-#define VTBL(cname, base) \
- INIT_STATIC(cname); \
- entity cname##_vtbl; \
- void cname##_vtbl_init() { \
- cname e = new(vtbl); \
- spawn##cname##_static(e); \
- e.vtblname = #cname; \
- /* Top level objects refer to themselves */ \
- e.vtblbase = base##_vtbl ? base##_vtbl : e; \
- cname##_vtbl = e; \
- } \
- ACCUMULATE_FUNCTION(RegisterClasses, cname##_vtbl_init)
-
-#define INIT_STATIC(cname) [[accumulate]] void spawn##cname##_static(cname this)
-#define INIT(cname) [[accumulate]] cname spawn##cname##_1(cname this)
-
-#define CLASS(cname, base) \
- entityclass(cname, base); \
- class(cname) .bool instanceOf##cname; \
- VTBL(cname, base) \
- INIT_STATIC(cname) { \
- if (cname##_vtbl) { \
- copyentity(cname##_vtbl, this); \
- return; \
- } \
- spawn##base##_static(this); \
- this.instanceOf##cname = true; \
- } \
- INIT(cname) { \
- /* Only statically initialize the current class, it contains everything it inherits */ \
- if (cname##_vtbl.vtblname == this.classname) { \
- spawn##cname##_static(this); \
- this.classname = #cname; \
- this.vtblname = string_null; \
- this.vtblbase = cname##_vtbl; \
- } \
- spawn##base##_1(this); \
- }
-
-#define METHOD(cname, name, prototype) \
- class(cname) .prototype name; \
- prototype cname##_##name; \
- INIT_STATIC(cname) { this.name = cname##_##name; } \
- prototype cname##_##name
-
-#define ATTRIB(cname, name, type, val) \
- class(cname) .type name; \
- INIT(cname) { this.name = val; }
-
-#define ATTRIBARRAY(cname, name, type, cnt) \
- class(cname) .type name[cnt];
-
-#define ENDCLASS(cname) \
- [[last]] INIT(cname) { return this; }
-
-#define SUPER(cname) (cname##_vtbl.vtblbase)
-#define super (this.vtblbase.vtblbase)
-
-#define spawn_static(this)
-#define spawn_1(this)
-#define _vtbl NULL
-CLASS(Object, );
- METHOD(Object, describe, string(entity this)) {
- string s = _("No description");
- if (cvar("developer")) {
- for (int i = 0, n = numentityfields(); i < n; ++i) {
- string value = getentityfieldstring(i, this);
- if (value != "") s = sprintf("%s\n%s = %s", s, entityfieldname(i), value);
- }
- }
- return s;
- }
- METHOD(Object, display, void(entity this, void(string name, string icon) returns)) {
- returns(sprintf("entity %i", this), "nopreview_map");
- }
-ENDCLASS(Object)
-#undef spawn_static
-#undef spawn_1
-#undef _vtbl
-
-#endif
+++ /dev/null
-#ifndef REGISTRY_H
-#define REGISTRY_H
-
-#include "oo.qh"
-#include "util.qh"
-
-#define REGISTER_INIT(ns, id) [[accumulate]] void Register_##ns##_##id##_init(entity this)
-#define REGISTER_INIT_POST(ns, id) [[accumulate]] void Register_##ns##_##id##_init_post(entity this)
-
-#define REGISTER(initfunc, ns, array, counter, id, fld, inst) \
- entity ns##_##id; \
- REGISTER_INIT(ns, id) { } \
- REGISTER_INIT_POST(ns, id) { } \
- .entity enemy; /* internal next pointer */ \
- void Register_##ns##_##id() { \
- entity this = inst; \
- ns##_##id = this; \
- this.fld = counter; \
- array[counter++] = this; \
- if (!array##_first) array##_first = this; \
- if ( array##_last) array##_last.enemy = this; \
- array##_last = this; \
- Register_##ns##_##id##_init(this); \
- Register_##ns##_##id##_init_post(this); \
- } \
- ACCUMULATE_FUNCTION(initfunc, Register_##ns##_##id) \
- REGISTER_INIT(ns, id)
-
-void __static_init() { }
-#define static_init() CALL_ACCUMULATED_FUNCTION(__static_init)
-#define REGISTER_REGISTRY(func) ACCUMULATE_FUNCTION(__static_init, func)
-
-#define STATIC_INIT(func) \
- void _static_##func(); \
- ACCUMULATE_FUNCTION(__static_init, _static_##func) \
- void _static_##func()
-
-#endif
#define spawn() new(entity)
-#include "oo.qh"
-
#endif
#ifndef COMMON_UTIL_H
#define COMMON_UTIL_H
-#ifdef QCC_SUPPORT_ACCUMULATE
-# define ACCUMULATE_FUNCTION(func,otherfunc) \
- [[accumulate]] void func() { otherfunc(); }
-# define CALL_ACCUMULATED_FUNCTION(func) \
- func()
-#else
-#ifdef HAVE_YO_DAWG_CPP
-// TODO make ascii art pic of xzibit
-// YO DAWG!
-// I HERD YO LIEK MACROS
-// SO I PUT A MACRO DEFINITION IN YO MACRO DEFINITION
-// SO YO CAN EXPAND MACROS WHILE YO EXPAND MACROS
-# define ACCUMULATE_FUNCTION(func,otherfunc) \
- #ifdef func \
- void __merge__##otherfunc() { func(); otherfunc(); } \
- #undef func \
- #define func __merge__##otherfunc \
- #else \
- #define func otherfunc \
- #endif
-# define CALL_ACCUMULATED_FUNCTION(func) \
- func()
-#else
-# define ACCUMULATE_FUNCTION(func,otherfunc) \
- .float _ACCUMULATE_##func##__##otherfunc
-void ACCUMULATE_call(string func)
-{
- float i;
- float n = numentityfields();
- string funcprefix = strcat("_ACCUMULATE_", func, "__");
- float funcprefixlen = strlen(funcprefix);
- for(i = 0; i < n; ++i)
- {
- string name = entityfieldname(i);
- if(substring(name, 0, funcprefixlen) == funcprefix)
- callfunction(substring(name, funcprefixlen, -1));
- }
-}
-# define CALL_ACCUMULATED_FUNCTION(func) \
- ACCUMULATE_call(#func)
-#endif
-#endif
-
-// used for simplifying ACCUMULATE_FUNCTIONs
-#define SET_FIRST_OR_LAST(input,first,count) if(!input) { input = (first + count); }
-#define SET_FIELD_COUNT(field,first,count) if(!field) { field = (first + count); ++count; }
-#define CHECK_MAX_COUNT(name,max,count,type) if(count > max) { error(strcat("Maximum ", type, " hit: ", #name, ": ", ftos(count), ".\n")); }
-
// this returns a tempstring containing a copy of s with additional \n newlines added, it also replaces \n in the text with a real newline
// NOTE: s IS allowed to be a tempstring
string wordwrap(string s, float l);
#endif
#endif
-// the NULL function
-#ifdef QCC_SUPPORT_NIL
-#define func_null nil
-#define string_null nil
-#else
-var void func_null(void);
-string string_null;
-#endif
float float2range11(float f);
float float2range01(float f);
void dedicated_print(string input);
#endif
-// todo: better way to do this?
-#ifdef MENUQC
-#define PROGNAME "MENUQC"
-#else
-#ifdef SVQC
-#define PROGNAME "SVQC"
-#else
-#define PROGNAME "CSQC"
-#endif
-#endif
-
#ifndef MENUQC
const float CNT_NORMAL = 1;
const float CNT_GAMESTART = 2;
--- /dev/null
+#ifndef ACCUMULATE_H
+#define ACCUMULATE_H
+
+#ifdef QCC_SUPPORT_ACCUMULATE
+# define ACCUMULATE_FUNCTION(func, otherfunc) \
+ [[accumulate]] void func() { otherfunc(); }
+# define CALL_ACCUMULATED_FUNCTION(func) \
+ func()
+#else
+#ifdef HAVE_YO_DAWG_CPP
+// TODO make ascii art pic of xzibit
+// YO DAWG!
+// I HERD YO LIEK MACROS
+// SO I PUT A MACRO DEFINITION IN YO MACRO DEFINITION
+// SO YO CAN EXPAND MACROS WHILE YO EXPAND MACROS
+# define ACCUMULATE_FUNCTION(func,otherfunc) \
+ #ifdef func \
+ void __merge__##otherfunc() { func(); otherfunc(); } \
+ #undef func \
+ #define func __merge__##otherfunc \
+ #else \
+ #define func otherfunc \
+ #endif
+# define CALL_ACCUMULATED_FUNCTION(func) \
+ func()
+#else
+# define ACCUMULATE_FUNCTION(func,otherfunc) \
+ .float _ACCUMULATE_##func##__##otherfunc
+void ACCUMULATE_call(string func)
+{
+ float i;
+ float n = numentityfields();
+ string funcprefix = strcat("_ACCUMULATE_", func, "__");
+ float funcprefixlen = strlen(funcprefix);
+ for(i = 0; i < n; ++i)
+ {
+ string name = entityfieldname(i);
+ if(substring(name, 0, funcprefixlen) == funcprefix)
+ callfunction(substring(name, funcprefixlen, -1));
+ }
+}
+# define CALL_ACCUMULATED_FUNCTION(func) \
+ ACCUMULATE_call(#func)
+#endif
+#endif
+
+// used for simplifying ACCUMULATE_FUNCTIONs
+#define SET_FIRST_OR_LAST(input,first,count) if(!input) { input = (first + count); }
+#define SET_FIELD_COUNT(field,first,count) if(!field) { field = (first + count); ++count; }
+#define CHECK_MAX_COUNT(name,max,count,type) if(count > max) { error(strcat("Maximum ", type, " hit: ", #name, ": ", ftos(count), ".\n")); }
+
+#endif
#ifndef LAZY_H
#define LAZY_H
+
+#include "OO.qh"
+
CLASS(Lazy, Object)
ATTRIB(Lazy, m_get, entity(), func_null);
CONSTRUCTOR(Lazy, entity() _compute) { this.m_get = _compute; }
--- /dev/null
+#ifndef NIL_H
+#define NIL_H
+
+#ifdef QCC_SUPPORT_NIL
+#define func_null nil
+#define string_null nil
+#else
+// the NULL function
+var void func_null(void);
+string string_null;
+#endif
+
+#endif
--- /dev/null
+#ifndef OO_H
+#define OO_H
+
+#include "Nil.qh"
+#include "Registry.qh"
+
+#ifdef MENUQC
+ #define NULL (null_entity)
+#else
+ #define NULL (world)
+#endif
+
+.string classname;
+/** Location entity was spawned from in source */
+.string sourceLocFile;
+.int sourceLocLine;
+entity _spawn();
+entity __spawn(string _classname, string _sourceFile, int _sourceLine) {
+ entity this = _spawn();
+ this.classname = _classname;
+ this.sourceLocFile = _sourceFile;
+ this.sourceLocLine = _sourceLine;
+ return this;
+}
+
+
+
+#define entityclass(...) OVERLOAD(entityclass, __VA_ARGS__)
+#define entityclass_1(name) entityclass_2(name, Object)
+#ifndef QCC_SUPPORT_ENTITYCLASS
+ #define entityclass_2(name, base) typedef entity name
+ #define class(name)
+ #define new(class) __spawn(#class, __FILE__, __LINE__)
+#else
+ #define entityclass_2(name, base) entityclass name : base {}
+ #define class(name) [[class(name)]]
+ #define new(class) ((class) __spawn(#class, __FILE__, __LINE__))
+#endif
+
+// Classes have a `spawn##cname(entity)` constructor
+// The parameter is used across [[accumulate]] functions
+
+// Macro to hide this implementation detail
+#define NEW(cname, ...) \
+ OVERLOAD(spawn##cname, new(cname), ##__VA_ARGS__)
+
+#define CONSTRUCT(cname, ...) \
+ OVERLOAD(spawn##cname, this, ##__VA_ARGS__)
+
+#define CONSTRUCTOR(cname, ...) \
+ cname OVERLOAD(spawn##cname, cname this, __VA_ARGS__) { return = this; } \
+ [[accumulate]] cname OVERLOAD(spawn##cname, cname this, __VA_ARGS__)
+
+.string vtblname;
+.entity vtblbase;
+
+void RegisterClasses() { }
+STATIC_INIT(RegisterClasses) { RegisterClasses(); }
+
+#define VTBL(cname, base) \
+ INIT_STATIC(cname); \
+ entity cname##_vtbl; \
+ void cname##_vtbl_init() { \
+ cname e = new(vtbl); \
+ spawn##cname##_static(e); \
+ e.vtblname = #cname; \
+ /* Top level objects refer to themselves */ \
+ e.vtblbase = base##_vtbl ? base##_vtbl : e; \
+ cname##_vtbl = e; \
+ } \
+ ACCUMULATE_FUNCTION(RegisterClasses, cname##_vtbl_init)
+
+#define INIT_STATIC(cname) [[accumulate]] void spawn##cname##_static(cname this)
+#define INIT(cname) [[accumulate]] cname spawn##cname##_1(cname this)
+
+#define CLASS(cname, base) \
+ entityclass(cname, base); \
+ class(cname) .bool instanceOf##cname; \
+ VTBL(cname, base) \
+ INIT_STATIC(cname) { \
+ if (cname##_vtbl) { \
+ copyentity(cname##_vtbl, this); \
+ return; \
+ } \
+ spawn##base##_static(this); \
+ this.instanceOf##cname = true; \
+ } \
+ INIT(cname) { \
+ /* Only statically initialize the current class, it contains everything it inherits */ \
+ if (cname##_vtbl.vtblname == this.classname) { \
+ spawn##cname##_static(this); \
+ this.classname = #cname; \
+ this.vtblname = string_null; \
+ this.vtblbase = cname##_vtbl; \
+ } \
+ spawn##base##_1(this); \
+ }
+
+#define METHOD(cname, name, prototype) \
+ class(cname) .prototype name; \
+ prototype cname##_##name; \
+ INIT_STATIC(cname) { this.name = cname##_##name; } \
+ prototype cname##_##name
+
+#define ATTRIB(cname, name, type, val) \
+ class(cname) .type name; \
+ INIT(cname) { this.name = val; }
+
+#define ATTRIBARRAY(cname, name, type, cnt) \
+ class(cname) .type name[cnt];
+
+#define ENDCLASS(cname) \
+ [[last]] INIT(cname) { return this; }
+
+#define SUPER(cname) (cname##_vtbl.vtblbase)
+#define super (this.vtblbase.vtblbase)
+
+#define spawn_static(this)
+#define spawn_1(this)
+#define _vtbl NULL
+CLASS(Object, );
+ METHOD(Object, describe, string(entity this)) {
+ string s = _("No description");
+ if (cvar("developer")) {
+ for (int i = 0, n = numentityfields(); i < n; ++i) {
+ string value = getentityfieldstring(i, this);
+ if (value != "") s = sprintf("%s\n%s = %s", s, entityfieldname(i), value);
+ }
+ }
+ return s;
+ }
+ METHOD(Object, display, void(entity this, void(string name, string icon) returns)) {
+ returns(sprintf("entity %i", this), "nopreview_map");
+ }
+ENDCLASS(Object)
+#undef spawn_static
+#undef spawn_1
+#undef _vtbl
+
+#endif
--- /dev/null
+#ifndef PROGNAME_H
+#define PROGNAME_H
+
+#if defined(MENUQC)
+ #define PROGNAME "MENUQC"
+#elif defined(SVQC)
+ #define PROGNAME "SVQC"
+#elif defined(CSQC)
+ #define PROGNAME "CSQC"
+#else
+ #error "Unable to detect PROGNAME"
+#endif
+
+#endif
--- /dev/null
+#ifndef REGISTRY_H
+#define REGISTRY_H
+
+#include "OO.qh"
+
+#define REGISTER_INIT(ns, id) [[accumulate]] void Register_##ns##_##id##_init(entity this)
+#define REGISTER_INIT_POST(ns, id) [[accumulate]] void Register_##ns##_##id##_init_post(entity this)
+
+#define REGISTER(initfunc, ns, array, counter, id, fld, inst) \
+ entity ns##_##id; \
+ REGISTER_INIT(ns, id) { } \
+ REGISTER_INIT_POST(ns, id) { } \
+ .entity enemy; /* internal next pointer */ \
+ void Register_##ns##_##id() { \
+ entity this = inst; \
+ ns##_##id = this; \
+ this.fld = counter; \
+ array[counter++] = this; \
+ if (!array##_first) array##_first = this; \
+ if ( array##_last) array##_last.enemy = this; \
+ array##_last = this; \
+ Register_##ns##_##id##_init(this); \
+ Register_##ns##_##id##_init_post(this); \
+ } \
+ ACCUMULATE_FUNCTION(initfunc, Register_##ns##_##id) \
+ REGISTER_INIT(ns, id)
+
+void __static_init() { }
+#define static_init() CALL_ACCUMULATED_FUNCTION(__static_init)
+#define REGISTER_REGISTRY(func) ACCUMULATE_FUNCTION(__static_init, func)
+
+#define STATIC_INIT(func) \
+ void _static_##func(); \
+ ACCUMULATE_FUNCTION(__static_init, _static_##func) \
+ void _static_##func()
+
+#endif
+#include "Accumulate.qh"
#include "Cvar.qh"
#include "Lazy.qh"
+#include "Nil.qh"
+#include "OO.qh"
+#include "Progname.qh"
+#include "Registry.qh"
#ifndef BASE_H
#define BASE_H
-#include "../../common/oo.qh"
-
#include "../../common/util.qh"
#include "../../dpdefs/keycodes.qh"