]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/mutators/base.qh
Merge remote branch 'origin/master' into samual/updatecommands
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / mutators / base.qh
index aa581228bd474fc32a12bc885291d0ae9a0c9775..e26280e61a695cf0fedcff92ff3fd487c803a830 100644 (file)
@@ -3,6 +3,8 @@
 #define CBC_ORDER_LAST 2
 #define CBC_ORDER_ANY 4
 
+float CallbackChain_ReturnValue; // read-only field of the current return value
+
 entity CallbackChain_New(string name);
 float CallbackChain_Add(entity cb, float() func, float order)
 float CallbackChain_Remove(entity cb, float() func);
@@ -16,11 +18,12 @@ float CallbackChain_Call(entity cb);
 
 #define MUTATOR_REMOVING 0
 #define MUTATOR_ADDING 1
-float Mutator_Add(float(float) func);
-void Mutator_Remove(float(float) func); // calls error() on fail
+typedef float(float) mutatorfunc_t;
+float Mutator_Add(mutatorfunc_t func, string name);
+void Mutator_Remove(mutatorfunc_t func, string name); // calls error() on fail
 
-#define MUTATOR_ADD(name) Mutator_Add(MUTATOR_##name)
-#define MUTATOR_REMOVE(name) Mutator_Remove(MUTATOR_##name)
+#define MUTATOR_ADD(name) Mutator_Add(MUTATOR_##name, #name)
+#define MUTATOR_REMOVE(name) Mutator_Remove(MUTATOR_##name, #name)
 #define MUTATOR_DEFINITION(name) float MUTATOR_##name(float mode)
 #define MUTATOR_DECLARATION(name) float MUTATOR_##name(float mode)
 #define MUTATOR_HOOKFUNCTION(name) float HOOKFUNCTION_##name()
@@ -31,6 +34,7 @@ void Mutator_Remove(float(float) func); // calls error() on fail
 #define MUTATOR_HOOKABLE(cb) entity HOOK_##cb
 #define MUTATOR_CALLHOOK(cb) CallbackChain_Call(HOOK_##cb)
 
+#define MUTATOR_RETURNVALUE CallbackChain_ReturnValue
 
 
 
@@ -150,3 +154,8 @@ MUTATOR_HOOKABLE(PlayerPowerups);
        // INPUT
        entity self;
        float olditems; // also technically output, but since it is at the end of the function it's useless for that :P 
+
+MUTATOR_HOOKABLE(PlayerUseKey);
+       // called when the use key is pressed
+       // if MUTATOR_RETURNVALUE is 1, don't do anything
+       // return 1 if the use key actually did something