#pragma once
+#ifdef CSQC
+#include <client/main.qh>
+#endif
+
const int CBC_ORDER_FIRST = 1;
const int CBC_ORDER_LAST = 2;
const int CBC_ORDER_EXCLUSIVE = 3;
params(_MUTATOR_HANDLE_NOP, _MUTATOR_HANDLE_POPOUT) \
return ret; \
} \
- [[accumulate]] void RegisterHooks() { HOOK_##id = NEW(CallbackChain, #id); }
+ ACCUMULATE void RegisterHooks() { HOOK_##id = NEW(CallbackChain, #id); }
#define MUTATOR_CALLHOOK(id, ...) _MUTATOR_CALLHOOK(id, __VA_ARGS__)
#ifdef __STDC__
bool mutator_log = false;
.bool m_added;
+#define MUTATOR_IS_ENABLED(this) MUTATOR_##this.mutatorcheck()
+
#ifdef GAMEQC
/** server mutators activate corresponding client mutators for all clients */
REGISTER_NET_LINKED(Mutator)
void NET_Mutator_Remove(entity this)
{
string s = this.netname;
- WITH(bool, mutator_log, true, LAMBDA(
+ WITH(bool, mutator_log, true, {
FOREACH(Mutators, it.registered_id == s, Mutator_Remove(it));
- ));
+ });
}
NET_HANDLE(Mutator, bool isNew)
{
make_pure(this);
this.entremove = NET_Mutator_Remove;
int added = 0;
- WITH(bool, mutator_log, true, LAMBDA(
+ WITH(bool, mutator_log, true, {
FOREACH(Mutators, it.registered_id == s, { Mutator_Add(it); ++added; });
- ));
+ });
if (added > 1) LOG_WARNF("Added more than one mutator for %s", s);
}
}
bool MUTATOR_##id##_check() { return dependence; } \
REGISTER(Mutators, MUTATOR, id, m_id, NEW(Mutator, #id, MUTATORFUNCTION_##id)) \
{ this.mutatorcheck = MUTATOR_##id##_check; } \
- [[accumulate]] bool MUTATORFUNCTION_##id(int mode)
+ ACCUMULATE bool MUTATORFUNCTION_##id(int mode)
STATIC_INIT(Mutators) {
RegisterHooks();
#define MUTATOR_ONADD if (mode == MUTATOR_ADDING)
#define MUTATOR_ONREMOVE if (mode == MUTATOR_REMOVING)
#define MUTATOR_ONROLLBACK_OR_REMOVE if (mode == MUTATOR_REMOVING || mode == MUTATOR_ROLLING_BACK)
+
+#define MUTATOR_STATIC() MACRO_BEGIN { \
+ MUTATOR_ONADD { \
+ /* game loads at time 1 */ \
+ if (time > 1) { \
+ error("This is a game type and it cannot be added at runtime."); \
+ } \
+ } \
+ MUTATOR_ONREMOVE { \
+ LOG_INFO("This is a game type and it cannot be removed at runtime."); \
+ return -1; \
+ } \
+} MACRO_END
+
#define MUTATOR_ADD(name) Mutator_Add(MUTATOR_##name)
#define MUTATOR_REMOVE(name) Mutator_Remove(MUTATOR_##name)
#define MUTATOR_RETURNVALUE CallbackChain_ReturnValue
#define _MUTATOR_CALLBACK(name, func) \
Callback CALLBACK_##name; \
bool func(); \
- [[accumulate]] void RegisterCallbacks() { CALLBACK_##name = NEW(Callback, func); }
+ ACCUMULATE void RegisterCallbacks() { CALLBACK_##name = NEW(Callback, func); }
#define MUTATOR_HOOKFUNCTION(...) \
EVAL_MUTATOR_HOOKFUNCTION(OVERLOAD(MUTATOR_HOOKFUNCTION, __VA_ARGS__))
#define MUTATOR_HOOKFUNCTION_3(mut, cb, order) \
_MUTATOR_CALLBACK(mut##_##cb, mut##_##cb) \
- [[accumulate]] bool MUTATORFUNCTION_##mut##_hooks(int mode) { MUTATOR_HOOK(cb, mut##_##cb, order); } \
+ ACCUMULATE bool MUTATORFUNCTION_##mut##_hooks(int mode) { MUTATOR_HOOK(cb, mut##_##cb, order); } \
bool mut##_##cb() { return = false; } \
- [[accumulate]] bool mut##_##cb()
+ ACCUMULATE bool mut##_##cb()
#define MUTATOR_HOOK(cb, func, order) MACRO_BEGIN { \
MUTATOR_ONADD { \
if (!CallbackChain_Add(HOOK_##cb, CALLBACK_##func, order)) { \
- LOG_INFO("HOOK FAILED: ", #cb, ":", #func, "\n"); \
+ LOG_INFO("HOOK FAILED: ", #cb, ":", #func); \
return true; \
} \
} \