]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Convert more calls
authorTimePath <andrew.hardaker1995@gmail.com>
Sat, 15 Aug 2015 09:40:46 +0000 (19:40 +1000)
committerTimePath <andrew.hardaker1995@gmail.com>
Sat, 15 Aug 2015 09:40:46 +0000 (19:40 +1000)
qcsrc/server/command/cmd.qc
qcsrc/server/mutators/base.qh
qcsrc/server/mutators/mutator_buffs.qc
qcsrc/server/mutators/mutator_nades.qc
qcsrc/server/portals.qc
qcsrc/server/spawnpoints.qc
qcsrc/server/t_items.qc
qcsrc/server/weapons/spawning.qc

index eec507f07e71033de427af4001a1fef4385721f6..cc8e19673a4760e257894d768ced8c11d8aad771 100644 (file)
@@ -888,11 +888,6 @@ void SV_ParseClientCommand(string command)
 
        float argc = tokenize_console(command);
 
-       // for the mutator hook system
-       cmd_name = strtolower(argv(0));
-       cmd_argc = argc;
-       cmd_string = command;
-
        // Guide for working with argc arguments by example:
        // argc:   1    - 2      - 3     - 4
        // argv:   0    - 1      - 2     - 3
@@ -941,7 +936,7 @@ void SV_ParseClientCommand(string command)
                        return;
                }
        }
-       else if(MUTATOR_CALLHOOK(SV_ParseClientCommand))
+       else if(MUTATOR_CALLHOOK(SV_ParseClientCommand, strtolower(argv(0)), argc, command))
        {
                return; // handled by a mutator
        }
index 478a0b9636f8fe3a261f9ea9b3c6665532daf47d..9ffd08e8ca35e8842f48465afd3d575aa28a6b2c 100644 (file)
@@ -370,85 +370,104 @@ float regen_mod_rot;
 float regen_mod_limit;
 MUTATOR_HOOKABLE(PlayerRegen, EV_PlayerRegen);
 
+/**
+ * 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
+ */
 MUTATOR_HOOKABLE(PlayerUseKey, EV_NO_ARGS);
-       // 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
-
-MUTATOR_HOOKABLE(SV_ParseClientCommand, EV_NO_ARGS);
-       // called when a client command is parsed
-       // NOTE: hooks MUST start with if(MUTATOR_RETURNVALUE) return 0;
-       // NOTE: return 1 if you handled the command, return 0 to continue handling
-       // NOTE: THESE HOOKS MUST NEVER EVER CALL tokenize()
-       // INPUT
-       string cmd_name; // command name
-       int cmd_argc; // also, argv() can be used
-       string cmd_string; // whole command, use only if you really have to
-       /*
-               // example:
-               MUTATOR_HOOKFUNCTION(foo_SV_ParseClientCommand)
-               {
-                       if(MUTATOR_RETURNVALUE) // command was already handled?
-                               return 0;
-                       if(cmd_name == "echocvar" && cmd_argc >= 2)
-                       {
-                               print(cvar_string(argv(1)), "\n");
-                               return 1;
-                       }
-                       if(cmd_name == "echostring" && cmd_argc >= 2)
-                       {
-                               print(substring(cmd_string, argv_start_index(1), argv_end_index(-1) - argv_start_index(1)), "\n");
-                               return 1;
-                       }
-                       return 0;
-               }
-       */
-
-MUTATOR_HOOKABLE(Spawn_Score, EV_NO_ARGS);
-       // called when a spawnpoint is being evaluated
-       // return 1 to make the spawnpoint unusable
-       // INPUT
-//     entity self; // player wanting to spawn
-//     entity spawn_spot; // spot to be evaluated
-       // IN+OUT
-       vector spawn_score; // _x is priority, _y is "distance"
 
+/**
+ * called when a client command is parsed
+ * NOTE: hooks MUST start with if(MUTATOR_RETURNVALUE) return 0;
+ * NOTE: return 1 if you handled the command, return 0 to continue handling
+ * NOTE: THESE HOOKS MUST NEVER EVER CALL tokenize()
+ * // example:
+ * MUTATOR_HOOKFUNCTION(foo_SV_ParseClientCommand)
+ * {
+ *     if (MUTATOR_RETURNVALUE) // command was already handled?
+ *         return false;
+ *     if (cmd_name == "echocvar" && cmd_argc >= 2)
+ *     {
+ *         print(cvar_string(argv(1)), "\n");
+ *         return true;
+ *     }
+ *     if (cmd_name == "echostring" && cmd_argc >= 2)
+ *     {
+ *         print(substring(cmd_string, argv_start_index(1), argv_end_index(-1) - argv_start_index(1)), "\n");
+ *         return true;
+ *     }
+ *     return false;
+ * }
+ */
+#define EV_SV_ParseClientCommand(i, o) \
+    /** command name */ i(string, cmd_name) \
+    /** also, argv() can be used */ i(int, cmd_argc) \
+    /** whole command, use only if you really have to */ i(string, cmd_string) \
+    /**/
+string cmd_name;
+int cmd_argc;
+string cmd_string;
+MUTATOR_HOOKABLE(SV_ParseClientCommand, EV_SV_ParseClientCommand);
+
+/**
+ * called when a spawnpoint is being evaluated
+ * return 1 to make the spawnpoint unusable
+ */
+#define EV_Spawn_Score(i, o) \
+    /** player wanting to spawn */ i(entity, self) \
+    /** spot to be evaluated */ i(entity, spawn_spot) \
+    /** _x is priority, _y is "distance" */ i(vector, spawn_score) \
+    /**/ o(vector, spawn_score) \
+    /**/
+vector spawn_score;
+MUTATOR_HOOKABLE(Spawn_Score, EV_Spawn_Score);
+
+/** runs globally each server frame */
 MUTATOR_HOOKABLE(SV_StartFrame, EV_NO_ARGS);
-       // runs globally each server frame
 
-MUTATOR_HOOKABLE(SetModname, EV_NO_ARGS);
-       // OUT
-//     string modname; // name of the mutator/mod if it warrants showing as such in the server browser
+#define EV_SetModname(i, o) \
+    /** name of the mutator/mod if it warrants showing as such in the server browser */ \
+    o(string, modname) \
+    /**/
+MUTATOR_HOOKABLE(SetModname, EV_SetModname);
 
-MUTATOR_HOOKABLE(Item_Spawn, EV_NO_ARGS);
-       // called for each item being spawned on a map, including dropped weapons
-       // return 1 to remove an item
-       // INPUT
-//     entity self; // the item
+/**
+ * called for each item being spawned on a map, including dropped weapons
+ * return 1 to remove an item
+ */
+#define EV_Item_Spawn(i, o) \
+    /** the item */ i(entity, self) \
+    /**/
+MUTATOR_HOOKABLE(Item_Spawn, EV_Item_Spawn);
 
-MUTATOR_HOOKABLE(SetWeaponreplace, EV_NO_ARGS);
-       // IN
-//             entity self; // map entity
-//             entity other; // weapon info
-       // IN+OUT
-//             string ret_string;
+#define EV_SetWeaponreplace(i, o) \
+    /** map entity */ i(entity, self) \
+    /** weapon info */ i(entity, other) \
+    /**/ i(string, ret_string) \
+    /**/ o(string, ret_string) \
+    /**/
+MUTATOR_HOOKABLE(SetWeaponreplace, EV_SetWeaponreplace);
 
+/** called when an item is about to respawn */
 MUTATOR_HOOKABLE(Item_RespawnCountdown, EV_NO_ARGS);
-       // called when an item is about to respawn
        // INPUT+OUTPUT:
        string item_name;
        vector item_color;
 
+/** called when a bot checks a target to attack */
 MUTATOR_HOOKABLE(BotShouldAttack, EV_NO_ARGS);
-       // called when a bot checks a target to attack
        // INPUT
        entity checkentity;
 
-MUTATOR_HOOKABLE(PortalTeleport, EV_NO_ARGS);
-       // called whenever a player goes through a portal gun teleport
-       // allows you to strip a player of an item if they go through the teleporter to help prevent cheating
-       // INPUT
-//     entity self;
+/**
+ * called whenever a player goes through a portal gun teleport
+ * allows you to strip a player of an item if they go through the teleporter to help prevent cheating
+ */
+ #define EV_PortalTeleport(i, o) \
+     /**/ i(entity, self) \
+     /**/
+MUTATOR_HOOKABLE(PortalTeleport, EV_PortalTeleport);
 
 MUTATOR_HOOKABLE(HelpMePing, EV_NO_ARGS);
        // called whenever a player uses impulse 33 (help me) in cl_impulse.qc
index 170f59874fbb45803574bd10bd35d9993542946d..b582e168604c9626b579258e19810c245144bd66 100644 (file)
@@ -629,7 +629,7 @@ MUTATOR_HOOKFUNCTION(buffs_PlayerThrowKey)
                        if(closest.flagcarried) { ctf_Handle_Throw(closest, world, DROP_THROW); }
                        if(closest.nade) { toss_nade(closest, '0 0 0', time + 0.05); }
 
-                       MUTATOR_CALLHOOK(PortalTeleport); // initiate flag dropper
+                       MUTATOR_CALLHOOK(PortalTeleport, self); // initiate flag dropper
 
                        setorigin(self, their_org);
                        setorigin(closest, my_org);
index f4267716e7bbfa860b8b2fc7f4cfee28be2703b2..40f4f7247db6fb284d272732724c71e0aff6e0d5 100644 (file)
@@ -360,11 +360,7 @@ void nade_translocate_boom()
 
        makevectors(self.realowner.angles);
 
-       entity oldself = self;
-       self = self.realowner;
-       MUTATOR_CALLHOOK(PortalTeleport);
-       self.realowner = self;
-       self = oldself;
+       MUTATOR_CALLHOOK(PortalTeleport, self.realowner);
 
        TeleportPlayer(self, self.realowner, locout, self.realowner.angles, v_forward * vlen(self.realowner.velocity), '0 0 0', '0 0 0', TELEPORT_FLAGS_TELEPORTER);
 }
index ad8aea50cdf068c9c0f164a2ab384b9e5fa7bac9..438ff00d3453e443e4d7e7d0f63970a5e0dcdf45 100644 (file)
@@ -170,11 +170,7 @@ float Portal_TeleportPlayer(entity teleporter, entity player)
        // factor -1 allows chaining portals, but may be weird
        player.right_vector = -1 * AnglesTransform_Apply(transform, player.right_vector);
 
-       entity oldself = self;
-       self = player;
-       MUTATOR_CALLHOOK(PortalTeleport);
-       player = self;
-       self = oldself;
+       MUTATOR_CALLHOOK(PortalTeleport, player);
 
        if (!teleporter.enemy)
        {
index b86da6b54ee9f0823dec8d72f2a34d11de7f40b0..bc191f74f46be02808a00148036e1e6ef5e92641 100644 (file)
@@ -228,7 +228,7 @@ vector Spawn_Score(entity spot, float mindist, float teamcheck)
                }
        }
 
-       MUTATOR_CALLHOOK(Spawn_Score);
+       MUTATOR_CALLHOOK(Spawn_Score, self, spawn_spot, spawn_score);
        return spawn_score;
 }
 
index 873f7a53c1f89159e32534626b6609221d15bd23..ffcf7624d70ff551384288eb967c1a4925e63e6e 100644 (file)
@@ -1358,7 +1358,7 @@ void StartItem (string itemmodel, string pickupsound, float defaultrespawntime,
                self.SendFlags |= ISF_ANGLES;
 
        // call this hook after everything else has been done
-       if(MUTATOR_CALLHOOK(Item_Spawn))
+       if(MUTATOR_CALLHOOK(Item_Spawn, self))
        {
                startitem_failed = true;
                remove(self);
index 9096b2f9c72d9ff3e54063ec33a1d0be7cbcd0bb..8e7810bbb117de338ed62dc6a32e6684466e8f1e 100644 (file)
@@ -55,9 +55,7 @@ void weapon_defaultspawnfunc(float wpn)
                }
 
                s = W_Apply_Weaponreplace(e.netname);
-               ret_string = s;
-               other = e;
-               MUTATOR_CALLHOOK(SetWeaponreplace);
+               MUTATOR_CALLHOOK(SetWeaponreplace, self, e, s);
                s = ret_string;
                if(s == "")
                {