]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
mutator system: refuse to add a mutator for the second time
authorRudolf Polzer <divVerent@xonotic.org>
Wed, 23 Feb 2011 19:45:36 +0000 (20:45 +0100)
committerRudolf Polzer <divVerent@xonotic.org>
Wed, 23 Feb 2011 19:45:36 +0000 (20:45 +0100)
qcsrc/server/cl_client.qc
qcsrc/server/mutators/base.qc

index 71584d350379869717ce8e3cd1ca6a2a3ce47f24..acf399f917b2372f5b2d0b8a3b0a101dc4eafedd 100644 (file)
@@ -2365,7 +2365,6 @@ void SpectateCopy(entity spectatee) {
        self.fixangle = TRUE;
        setorigin(self, spectatee.origin);
        setsize(self, spectatee.mins, spectatee.maxs);
-       SetZoomState(spectatee.zoomstate);
 
        anticheat_spectatecopy(spectatee);
 }
@@ -2402,6 +2401,8 @@ float SpectateNext() {
                self.movetype = MOVETYPE_NONE;
                accuracy_resend(self);
 
+               SetZoomState(spectatee.zoomstate);
+
                if(!SpectateUpdate())
                        PutObserverInServer();
 
index 0b1bea45edc46983f5f555db12eb3c9d0c56e043..8c0c9439cdb3c7a2a06f6b46178817aa02f2d486 100644 (file)
@@ -87,8 +87,26 @@ float CallbackChain_Call(entity cb)
        return r; // callbacks return an error status, so 0 is default return value
 }
 
+#define MAX_MUTATORS 8
+float(float) mutators[MAX_MUTATORS];
 float Mutator_Add(float(float) func)
 {
+       float i, j;
+       j = -1;
+       for(i = 0; i < MAX_MUTATORS; ++i)
+       {
+               if(func == mutators[i])
+                       return 1; // already added
+               if(func == func_null)
+                       j = i;
+       }
+       if(j < 0)
+       {
+               backtrace("WARNING: too many mutators, cannot add any more\n");
+               return 0;
+       }
+       mutators[j] = func;
+
        if(func(MUTATOR_ADDING) == 0)
        {
                // good
@@ -100,6 +118,17 @@ float Mutator_Add(float(float) func)
 }
 void Mutator_Remove(float(float) func)
 {
+       float i;
+       for(i = 0; i < MAX_MUTATORS; ++i)
+               if(func == mutators[i])
+                       break;
+       if(i >= MAX_MUTATORS)
+       {
+               backtrace("WARNING: removing not-added mutator\n");
+               return 0;
+       }
+       mutators[i] = func_null;
+
        if(func(MUTATOR_REMOVING) != 0)
        {
                // baaaaad