From: TimePath Date: Mon, 24 Aug 2015 05:40:42 +0000 (+1000) Subject: Support CSQC_Ent_Update mutator hooks X-Git-Tag: xonotic-v0.8.2~2041 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=5d0e03ed840a2aa0a5fabb161a781d985a4bc502;p=xonotic%2Fxonotic-data.pk3dir.git Support CSQC_Ent_Update mutator hooks --- diff --git a/qcsrc/client/main.qc b/qcsrc/client/main.qc index 9e7b8bd68..e39b3346a 100644 --- a/qcsrc/client/main.qc +++ b/qcsrc/client/main.qc @@ -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; diff --git a/qcsrc/client/mutators/events.qh b/qcsrc/client/mutators/events.qh index 893765a7e..16ae922f2 100644 --- a/qcsrc/client/mutators/events.qh +++ b/qcsrc/client/mutators/events.qh @@ -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) \ diff --git a/qcsrc/client/waypointsprites.qc b/qcsrc/client/waypointsprites.qc index 8c7c54af2..aa5ec5fae 100644 --- a/qcsrc/client/waypointsprites.qc +++ b/qcsrc/client/waypointsprites.qc @@ -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; diff --git a/qcsrc/common/constants.qh b/qcsrc/common/constants.qh index 1e77197f6..7de2a8883 100644 --- a/qcsrc/common/constants.qh +++ b/qcsrc/common/constants.qh @@ -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; diff --git a/qcsrc/common/mutators/all.inc b/qcsrc/common/mutators/all.inc index 44a2a4be1..0471dff7c 100644 --- a/qcsrc/common/mutators/all.inc +++ b/qcsrc/common/mutators/all.inc @@ -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 index 000000000..f8055ad95 --- /dev/null +++ b/qcsrc/common/mutators/mutator/waypointsprites.qc @@ -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 diff --git a/qcsrc/server/waypointsprites.qc b/qcsrc/server/waypointsprites.qc index 136beddb9..8c47014f7 100644 --- a/qcsrc/server/waypointsprites.qc +++ b/qcsrc/server/waypointsprites.qc @@ -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;