From: Rudolf Polzer Date: Fri, 25 Jun 2010 10:11:59 +0000 (+0200) Subject: fix a warpzone connection bug when using random warpzone arrangement X-Git-Tag: xonotic-v0.1.0preview~522 X-Git-Url: https://de.git.xonotic.org/?a=commitdiff_plain;h=6e02979d47e9ec07499c022caf96a03093218be6;p=xonotic%2Fxonotic-data.pk3dir.git fix a warpzone connection bug when using random warpzone arrangement --- diff --git a/qcsrc/warpzonelib/server.qc b/qcsrc/warpzonelib/server.qc index 6388fbaad..4f8d83ac6 100644 --- a/qcsrc/warpzonelib/server.qc +++ b/qcsrc/warpzonelib/server.qc @@ -394,21 +394,29 @@ void WarpZone_InitStep_ClearTarget() self.enemy = world; } +entity warpzone_first; .entity warpzone_next; 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 != "") { + self.enemy = self; // so the if(!e.enemy) check also skips self, saves one IF + 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(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) { + self.enemy = world; error("Warpzone with non-existing target"); return; }