From: TimePath Date: Tue, 1 Dec 2015 22:20:59 +0000 (+1100) Subject: Mutators: network X-Git-Tag: xonotic-v0.8.2~1592 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=d3b685e255de5460a033701ea07c84e83cac8737;p=xonotic%2Fxonotic-data.pk3dir.git Mutators: network Overkill: fix viewmodels --- diff --git a/qcsrc/common/mutators/base.qh b/qcsrc/common/mutators/base.qh index 7cfc29789..6932db8bf 100644 --- a/qcsrc/common/mutators/base.qh +++ b/qcsrc/common/mutators/base.qh @@ -157,6 +157,49 @@ ENDCLASS(Mutator) REGISTRY(Mutators, BITS(7)) #define Mutators_from(i) _Mutators_from(i, NULL) Mutator loaded_mutators[Mutators_MAX]; +bool Mutator_Add(Mutator mut); +void Mutator_Remove(Mutator mut); +bool mutator_log = false; + +#ifndef MENUQC +REGISTER_NET_LINKED(Mutator) + +#ifdef SVQC +bool Mutator_SendEntity(entity this, entity to, int sf) +{ + int chan = MSG_ENTITY; + WriteHeader(chan, Mutator); + WriteString(chan, this.registered_id); + return true; +} +#endif + +#ifdef CSQC +void NET_Mutator_Remove() +{ + SELFPARAM(); + string s = this.netname; + WITH(bool, mutator_log, true, LAMBDA( + FOREACH(Mutators, it.registered_id == s, LAMBDA(Mutator_Remove(it))); + )); +} +NET_HANDLE(Mutator, bool isNew) +{ + string s = this.netname = ReadString(); + return = true; + if (isNew) + { + this.entremove = NET_Mutator_Remove; + int added = 0; + WITH(bool, mutator_log, true, LAMBDA( + FOREACH(Mutators, it.registered_id == s, LAMBDA(Mutator_Add(it); ++added)); + )); + if (added > 1) LOG_WARNINGF("Added more than one mutator for %s\n", s); + } +} +#endif + +#endif bool Mutator_Add(Mutator mut) { @@ -175,6 +218,10 @@ bool Mutator_Add(Mutator mut) mutatorfunc_t func = mut.mutatorfunc; if (!func(MUTATOR_ADDING)) { // good + if (mutator_log) LOG_TRACEF("Mutator: added %s\n", mut.m_name); +#ifdef SVQC + Net_LinkEntity(mut, false, 0, Mutator_SendEntity); +#endif return true; } backtrace("WARNING: when adding mutator: adding failed, rolling back\n"); @@ -201,6 +248,10 @@ void Mutator_Remove(Mutator mut) // baaaaad error("Mutator_Remove: removing mutator failed"); } + if (mutator_log) LOG_TRACEF("Mutator: removed %s\n", mut.m_name); +#ifdef SVQC + Net_UnlinkEntity(mut); +#endif } #define REGISTER_MUTATOR(id, dependence) \ diff --git a/qcsrc/common/mutators/mutator/overkill/module.inc b/qcsrc/common/mutators/mutator/overkill/module.inc index a8bde27b5..a7acff5a0 100644 --- a/qcsrc/common/mutators/mutator/overkill/module.inc +++ b/qcsrc/common/mutators/mutator/overkill/module.inc @@ -4,3 +4,16 @@ #ifdef SVQC #include "overkill.qc" #endif +#ifdef CSQC + #ifdef IMPLEMENTATION + REGISTER_MUTATOR(ok, false) + { + MUTATOR_ONADD { + cvar_settemp("g_overkill", "1"); + WEP_SHOTGUN.mdl = "ok_shotgun"; + WEP_MACHINEGUN.mdl = "ok_mg"; + WEP_VORTEX.mdl = "ok_sniper"; + } + } + #endif +#endif diff --git a/qcsrc/lib/net.qh b/qcsrc/lib/net.qh index bd1c5e14a..1e3d511c6 100644 --- a/qcsrc/lib/net.qh +++ b/qcsrc/lib/net.qh @@ -35,6 +35,11 @@ } } + void Net_UnlinkEntity(entity e) + { + e.SendEntity = func_null; + } + .void() uncustomizeentityforclient; .float uncustomizeentityforclient_set; diff --git a/qcsrc/server/scores.qc b/qcsrc/server/scores.qc index 2eca07bc9..03f3dbba3 100644 --- a/qcsrc/server/scores.qc +++ b/qcsrc/server/scores.qc @@ -533,21 +533,20 @@ void WinningConditionHelper() if(fullstatus) { s = GetPlayerScoreString(p, 1); - if(IS_REAL_CLIENT(p)) - s = strcat(s, ":human"); - else - s = strcat(s, ":bot"); + s = strcat(s, IS_REAL_CLIENT(p) ? ":human" : ":bot"); + ret_string = string_null; if(!IS_PLAYER(p) && !MUTATOR_CALLHOOK(GetPlayerStatus, p, s)) s = strcat(s, ":spectator"); - s = strcat(s, ret_string); + if (ret_string) s = strcat(s, ret_string); } else { - if(IS_PLAYER(p) || MUTATOR_CALLHOOK(GetPlayerStatus, p, s)) + ret_string = string_null; + if (IS_PLAYER(p) || MUTATOR_CALLHOOK(GetPlayerStatus, p, s)) s = GetPlayerScoreString(p, 2); else s = "-666"; - s = strcat(s, ret_string); + if (ret_string) s = strcat(s, ret_string); } if(p.clientstatus)