]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
fix a warpzone connection bug when using random warpzone arrangement
authorRudolf Polzer <divverent@alientrap.org>
Fri, 25 Jun 2010 10:11:59 +0000 (12:11 +0200)
committerRudolf Polzer <divverent@alientrap.org>
Fri, 25 Jun 2010 10:11:59 +0000 (12:11 +0200)
qcsrc/warpzonelib/server.qc

index 6388fbaade6c847d3ac8a1200285519aae27509d..4f8d83ac64c6a0e765249fd778be5737ca0ee992 100644 (file)
@@ -394,21 +394,29 @@ void WarpZone_InitStep_ClearTarget()
        self.enemy = world;
 }
 
        self.enemy = world;
 }
 
+entity warpzone_first; .entity warpzone_next;
 void WarpZone_InitStep_FindTarget()
 {
        float i;
        entity e, e2;
 
 void WarpZone_InitStep_FindTarget()
 {
        float i;
        entity e, e2;
 
+       if(self.enemy)
+               return;
+
        // this way only one of the two ents needs to target
        if(self.target != "")
        {
        // this way only one of the two ents needs to target
        if(self.target != "")
        {
+               self.enemy = self; // so the if(!e.enemy) check also skips self, saves one IF
+
                e2 = world;
                e2 = world;
-               for(e = world; (e = find(e, targetname, self.target)); )
+               for(e = world, i = 0; (e = find(e, targetname, self.target)); )
                        if(!e.enemy)
                        if(!e.enemy)
-                               if(random() * ++i < 1)
-                                       e2 = e;
+                               if(e.classname == self.classname) // possibly non-warpzones may use the same targetname!
+                                       if(random() * ++i < 1)
+                                               e2 = e;
                if(!e2)
                {
                if(!e2)
                {
+                       self.enemy = world;
                        error("Warpzone with non-existing target");
                        return;
                }
                        error("Warpzone with non-existing target");
                        return;
                }