]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Support CSQC_Ent_Update mutator hooks
authorTimePath <andrew.hardaker1995@gmail.com>
Mon, 24 Aug 2015 05:40:42 +0000 (15:40 +1000)
committerTimePath <andrew.hardaker1995@gmail.com>
Mon, 24 Aug 2015 06:02:30 +0000 (16:02 +1000)
qcsrc/client/main.qc
qcsrc/client/mutators/events.qh
qcsrc/client/waypointsprites.qc
qcsrc/common/constants.qh
qcsrc/common/mutators/all.inc
qcsrc/common/mutators/mutator/waypointsprites.qc [new file with mode: 0644]
qcsrc/server/waypointsprites.qc

index 9e7b8bd6859d51680edd513216a03eddf6e677dc..e39b3346a354ec5fc5b7f1d80a6c3cc9286f1670 100644 (file)
@@ -845,6 +845,12 @@ void CSQC_Ent_Update(float bIsNewEntity)
        self.enttype = t;
        switch(t)
        {
+               case ENT_CLIENT_MUTATOR: {
+                       int mutID = ReadMutator();
+                       if (!MUTATOR_CALLHOOK(CSQC_Ent_Update, mutID, bIsNewEntity))
+                       error(sprintf("Unknown mutator type in CSQC_Ent_Update (mutID: %d, edict: %d, classname: %s)\n", mutID, num_for_edict(self), self.classname));
+                       break;
+               }
                case ENT_CLIENT_ENTCS: Ent_ReadEntCS(); break;
                case ENT_CLIENT_SCORES: Ent_ReadPlayerScore(); break;
                case ENT_CLIENT_TEAMSCORES: Ent_ReadTeamScore(); break;
@@ -853,7 +859,6 @@ void CSQC_Ent_Update(float bIsNewEntity)
                case ENT_CLIENT_LASER: Ent_Laser(); break;
                case ENT_CLIENT_NAGGER: Ent_Nagger(); break;
                case ENT_CLIENT_ELIMINATEDPLAYERS: Ent_EliminatedPlayers(); break;
-               case ENT_CLIENT_WAYPOINT: Ent_WaypointSprite(); break;
                case ENT_CLIENT_RADARLINK: Ent_RadarLink(); break;
                case ENT_CLIENT_PROJECTILE: Ent_Projectile(); break;
                case ENT_CLIENT_GIBSPLASH: Ent_GibSplash(bIsNewEntity); break;
index 893765a7e1f85e322e768c73055183079b68d102..16ae922f220ba774fb3dfdc892eb411de9b89da1 100644 (file)
@@ -45,10 +45,22 @@ MUTATOR_HOOKABLE(UpdateCrosshair, EV_NO_ARGS);
  * NOTE: return true if you handled the command, return false to continue handling
  */
 #define EV_CSQC_Parse_TempEntity(i, o) \
-    /** entity id */ i(int, mutator_argv_int_0) \
+    /** mutator id */ i(int, mutator_argv_int_0) \
     /**/
 MUTATOR_HOOKABLE(CSQC_Parse_TempEntity, EV_CSQC_Parse_TempEntity);
 
+/**
+ * Called when a shared entity is updated
+ * NOTE: hooks MUST start with `if (MUTATOR_RETURNVALUE) return false;`
+ * NOTE: hooks MUST start with `if (!ReadMutatorEquals(mutator_argv_int_0, name_of_mutator)) return false;`
+ * NOTE: return true if you handled the command, return false to continue handling
+ */
+#define EV_CSQC_Ent_Update(i, o) \
+    /** mutator id */ i(int, mutator_argv_int_0) \
+    /** bIsNewEntity */ i(bool, mutator_argv_bool_0) \
+    /**/
+MUTATOR_HOOKABLE(CSQC_Ent_Update, EV_CSQC_Ent_Update);
+
 /** Called when a projectile is linked with CSQC */
 #define EV_Ent_Projectile(i, o) \
     /** entity id */ i(entity, self) \
index 8c7c54af2d682f7e9e68ba1d6a2f48e0e45c83ad..aa5ec5fae0aed7a8c0dada8264ab6a305a1ff207 100644 (file)
@@ -591,6 +591,7 @@ void Ent_RemoveWaypointSprite()
                strunzone(self.netname3);
 }
 
+/** flags origin [team displayrule] [spritename] [spritename2] [spritename3] [lifetime maxdistance hideable] */
 void Ent_WaypointSprite()
 {
        int sendflags, f, t;
index 1e77197f6f62cd731fd6438924c1c91ed3d3dcfa..7de2a888322d72b6ac3eb693b7852ef0d5138607 100644 (file)
@@ -79,7 +79,6 @@ const int ENT_CLIENT_POINTPARTICLES = 6;
 const int ENT_CLIENT_RAINSNOW = 7;
 const int ENT_CLIENT_LASER = 8;
 const int ENT_CLIENT_NAGGER = 9; // flags [votecalledvote]
-const int ENT_CLIENT_WAYPOINT = 10; // flags origin [team displayrule] [spritename] [spritename2] [spritename3] [lifetime maxdistance hideable]
 const int ENT_CLIENT_RADARLINK = 11; // flags [startorigin] [endorigin] [startcolor+16*endcolor]
 const int ENT_CLIENT_PROJECTILE = 12;
 const int ENT_CLIENT_GIBSPLASH = 13;
@@ -131,6 +130,8 @@ const int ENT_CLIENT_VIEWLOC_TRIGGER = 79;
 
 const int ENT_CLIENT_HEALING_ORB = 80;
 
+const int ENT_CLIENT_MUTATOR = TE_CSQC_MUTATOR; // 99
+
 const int SPRITERULE_DEFAULT = 0;
 const int SPRITERULE_TEAMPLAY = 1;
 const int SPRITERULE_SPECTATOR = 2;
index 44a2a4be1d1e8c2dc7354d100c026d18b332c6d4..0471dff7cd700623d9c28941e4495791643e7216 100644 (file)
@@ -1,2 +1,3 @@
 #include "mutator/damagetext.qc"
 #include "mutator/itemstime.qc"
+#include "mutator/waypointsprites.qc"
diff --git a/qcsrc/common/mutators/mutator/waypointsprites.qc b/qcsrc/common/mutators/mutator/waypointsprites.qc
new file mode 100644 (file)
index 0000000..f8055ad
--- /dev/null
@@ -0,0 +1,11 @@
+REGISTER_MUTATOR(waypointsprites, true);
+
+#ifdef CSQC
+void Ent_WaypointSprite();
+MUTATOR_HOOKFUNCTION(waypointsprites, CSQC_Ent_Update) {
+    if (MUTATOR_RETURNVALUE) return false;
+    if (!ReadMutatorEquals(mutator_argv_int_0, waypointsprites)) return false;
+    Ent_WaypointSprite();
+    return true;
+}
+#endif
index 136beddb96829c21be5adcbf2cf7384df49d054b..8c47014f7e5e3b691a9c97cb6a64dd8d3d48998c 100644 (file)
@@ -260,7 +260,7 @@ float WaypointSprite_SendEntity(entity to, float sendflags)
 {
        float dt;
 
-       WriteByte(MSG_ENTITY, ENT_CLIENT_WAYPOINT);
+       WriteMutator(MSG_ENTITY, waypointsprites);
 
        sendflags = sendflags & 0x7F;