]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Mutators: network
authorTimePath <andrew.hardaker1995@gmail.com>
Tue, 1 Dec 2015 22:20:59 +0000 (09:20 +1100)
committerTimePath <andrew.hardaker1995@gmail.com>
Tue, 1 Dec 2015 22:20:59 +0000 (09:20 +1100)
Overkill: fix viewmodels

qcsrc/common/mutators/base.qh
qcsrc/common/mutators/mutator/overkill/module.inc
qcsrc/lib/net.qh
qcsrc/server/scores.qc

index 7cfc297896ab7fd9e6ca91789e5e481455a21afa..6932db8bf99dce6c69de41dfdcf9d3ae2147dda1 100644 (file)
@@ -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) \
index a8bde27b566028cb0bab2f617caec150fb734e46..a7acff5a09e05a580d703eef7f54a8b2a7af0133 100644 (file)
@@ -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
index bd1c5e14ad8c94f3b69c8429d662a07300c32c94..1e3d511c6ef00d00c2e18711bc59efeff38b9088 100644 (file)
                }
        }
 
+       void Net_UnlinkEntity(entity e)
+       {
+               e.SendEntity = func_null;
+       }
+
        .void() uncustomizeentityforclient;
        .float uncustomizeentityforclient_set;
 
index 2eca07bc94843d8e8a9c75bebe3067e9e2febe62..03f3dbba37208d2eed5c5c8cc26fd18e628d3f49 100644 (file)
@@ -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)