]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/lib/warpzone/server.qc
Merge branch 'master' into Mario/showspecs
[xonotic/xonotic-data.pk3dir.git] / qcsrc / lib / warpzone / server.qc
index a84b7a73984219626a7a91b3d2d62e6abd18d397..6dd0ea3c7f357ad960a801de459c13812c1d1b17 100644 (file)
@@ -47,7 +47,7 @@
 void WarpZone_TeleportPlayer(entity teleporter, entity player, vector to, vector to_angles, vector to_velocity)
 {
 #ifdef SVQC
-       setorigin (player, to); // NOTE: this also aborts the move, when this is called by touch
+       setorigin(player, to); // NOTE: this also aborts the move, when this is called by touch
        player.oldorigin = to; // for DP's unsticking
        player.angles = to_angles;
        player.fixangle = true;
@@ -111,7 +111,7 @@ float WarpZone_Teleport(entity wz, entity player, float f0, float f1)
                {
                        entity own;
                        own = player.owner;
-                       player.owner = world;
+                       player.owner = NULL;
                        tracebox(trace_endpos, player.mins, player.maxs, o1 - player.view_ofs + v1 * frametime * f1, MOVE_NORMAL, player); // this should get us through the warpzone
                        player.owner = own;
                }
@@ -189,29 +189,29 @@ float WarpZone_Teleport(entity wz, entity player, float f0, float f1)
        return 1;
 }
 
-void WarpZone_Touch (entity this)
+void WarpZone_Touch(entity this, entity toucher)
 {
-       if(other.classname == "trigger_warpzone")
+       if(toucher.classname == "trigger_warpzone")
                return;
 
-       if(time <= other.warpzone_teleport_finishtime) // already teleported this frame
+       if(time <= toucher.warpzone_teleport_finishtime) // already teleported this frame
                return;
 
        // FIXME needs a better check to know what is safe to teleport and what not
 #ifdef SVQC
-       if(other.movetype == MOVETYPE_NONE || other.movetype == MOVETYPE_FOLLOW || other.tag_entity)
+       if(toucher.movetype == MOVETYPE_NONE || toucher.movetype == MOVETYPE_FOLLOW || toucher.tag_entity)
 #elif defined(CSQC)
-       if(other.move_movetype == MOVETYPE_NONE || other.move_movetype == MOVETYPE_FOLLOW || other.tag_networkentity)
+       if(toucher.move_movetype == MOVETYPE_NONE || toucher.move_movetype == MOVETYPE_FOLLOW || toucher.tag_networkentity)
 #endif
                return;
 
-       if(WarpZoneLib_ExactTrigger_Touch(this, other))
+       if(WarpZoneLib_ExactTrigger_Touch(this, toucher))
                return;
 
 #ifdef SVQC
-       if(WarpZone_PlaneDist(this, other.origin + other.view_ofs) >= 0) // wrong side of the trigger_warpzone (don't teleport yet)
+       if(WarpZone_PlaneDist(this, toucher.origin + toucher.view_ofs) >= 0) // wrong side of the trigger_warpzone (don't teleport yet)
 #elif defined(CSQC)
-       if(WarpZone_PlaneDist(this, other.move_origin + other.view_ofs) >= 0) // wrong side of the trigger_warpzone (don't teleport yet)
+       if(WarpZone_PlaneDist(this, toucher.move_origin + toucher.view_ofs) >= 0) // wrong side of the trigger_warpzone (don't teleport yet)
 #endif
                return;
 
@@ -227,29 +227,29 @@ void WarpZone_Touch (entity this)
        //       24/(0.25/frametime)
        //       96*frametime
        float d;
-       d = 24 + max(vlen(other.mins), vlen(other.maxs));
-       if(IS_NOT_A_CLIENT(other))
+       d = 24 + max(vlen(toucher.mins), vlen(toucher.maxs));
+       if(IS_NOT_A_CLIENT(toucher))
        #ifdef SVQC
-               f = -d / bound(frametime * d * 1, frametime * vlen(other.velocity), d);
+               f = -d / bound(frametime * d * 1, frametime * vlen(toucher.velocity), d);
        #elif defined(CSQC)
-               f = -d / bound(frametime * d * 1, frametime * vlen(other.move_velocity), d);
+               f = -d / bound(frametime * d * 1, frametime * vlen(toucher.move_velocity), d);
        #endif
        else
                f = -1;
-       if(WarpZone_Teleport(this, other, f, 0))
+       if(WarpZone_Teleport(this, toucher, f, 0))
        {
 #ifdef SVQC
                string save1, save2;
 
                save1 = this.target; this.target = string_null;
                save2 = this.target3; this.target3 = string_null;
-               SUB_UseTargets(this, other, other); // use other too?
+               SUB_UseTargets(this, toucher, toucher); // use toucher too?
                if (!this.target) this.target = save1;
                if (!this.target3) this.target3 = save2;
 
                save1 = this.target; this.target = string_null;
                save2 = this.target2; this.target2 = string_null;
-               SUB_UseTargets(this.enemy, other, other); // use other too?
+               SUB_UseTargets(this.enemy, toucher, toucher); // use toucher too?
                if (!this.target) this.target = save1;
                if (!this.target2) this.target2 = save2;
 #endif
@@ -434,9 +434,9 @@ float WarpZone_CheckProjectileImpact(entity player)
 #endif
 #endif
 
-float WarpZone_Projectile_Touch(entity this)
+float WarpZone_Projectile_Touch(entity this, entity toucher)
 {
-       if(other.classname == "trigger_warpzone")
+       if(toucher.classname == "trigger_warpzone")
                return true;
 
        // no further impacts if we teleported this frame!
@@ -496,7 +496,7 @@ float WarpZone_Projectile_Touch(entity this)
        }
 #endif
 
-       if(WarpZone_Projectile_Touch_ImpactFilter_Callback(this, other))
+       if(WarpZone_Projectile_Touch_ImpactFilter_Callback(this, toucher))
                return true;
 #endif
 
@@ -509,8 +509,8 @@ void WarpZone_InitStep_FindOriginTarget(entity this)
 {
        if(this.killtarget != "")
        {
-               this.aiment = find(world, targetname, this.killtarget);
-               if(this.aiment == world)
+               this.aiment = find(NULL, targetname, this.killtarget);
+               if(this.aiment == NULL)
                {
                        error("Warp zone with nonexisting killtarget");
                        return;
@@ -526,8 +526,8 @@ void WarpZonePosition_InitStep_FindTarget(entity this)
                error("Warp zone position with no target");
                return;
        }
-       this.enemy = find(world, targetname, this.target);
-       if(this.enemy == world)
+       this.enemy = find(NULL, targetname, this.target);
+       if(this.enemy == NULL)
        {
                error("Warp zone position with nonexisting target");
                return;
@@ -566,11 +566,11 @@ void WarpZoneCamera_InitStep_FindTarget(entity this)
                error("Camera with no target");
                return;
        }
-       this.enemy = world;
-       for(e = world, i = 0; (e = find(e, targetname, this.target)); )
+       this.enemy = NULL;
+       for(e = NULL, i = 0; (e = find(e, targetname, this.target)); )
                if(random() * ++i < 1)
                        this.enemy = e;
-       if(this.enemy == world)
+       if(this.enemy == NULL)
        {
                error("Camera with nonexisting target");
                return;
@@ -671,8 +671,8 @@ void WarpZone_InitStep_UpdateTransform(entity this)
 void WarpZone_InitStep_ClearTarget(entity this)
 {
        if(this.enemy)
-               this.enemy.enemy = world;
-       this.enemy = world;
+               this.enemy.enemy = NULL;
+       this.enemy = NULL;
 }
 
 entity warpzone_first; .entity warpzone_next;
@@ -689,15 +689,15 @@ void WarpZone_InitStep_FindTarget(entity this)
        {
                this.enemy = this; // so the if(!e.enemy) check also skips this, saves one IF
 
-               e2 = world;
-               for(e = world, i = 0; (e = find(e, targetname, this.target)); )
+               e2 = NULL;
+               for(e = NULL, i = 0; (e = find(e, targetname, this.target)); )
                        if(!e.enemy)
                                if(e.classname == this.classname) // possibly non-warpzones may use the same targetname!
                                        if(random() * ++i < 1)
                                                e2 = e;
                if(!e2)
                {
-                       this.enemy = world;
+                       this.enemy = NULL;
                        error("Warpzone with non-existing target");
                        return;
                }
@@ -847,8 +847,6 @@ void WarpZone_StartFrame()
                WarpZone_PostInitialize_Callback();
        }
 
-       entity oldother = other;
-
        FOREACH_ENTITY(!is_pure(it),
        {
                if(warpzone_warpzones_exist)
@@ -857,28 +855,25 @@ void WarpZone_StartFrame()
                if(IS_OBSERVER(it) || it.solid == SOLID_NOT)
                if(IS_CLIENT(it)) // we don't care about it being a bot
                {
-                       other = it; // player
-
                        // warpzones
                        if (warpzone_warpzones_exist) {
                                entity e = WarpZone_Find(it.origin + it.mins, it.origin + it.maxs);
                                if (e)
-                               if (!WarpZoneLib_ExactTrigger_Touch(e, other))
+                               if (!WarpZoneLib_ExactTrigger_Touch(e, it))
                                if (WarpZone_PlaneDist(e, it.origin + it.view_ofs) <= 0)
                                        WarpZone_Teleport(e, it, -1, 0); // NOT triggering targets by this!
                        }
 
                        // teleporters
-                       if(other.teleportable)
+                       if(it.teleportable)
                        {
                                entity ent = Teleport_Find(it.origin + it.mins, it.origin + it.maxs);
                                if (ent)
-                               if (!WarpZoneLib_ExactTrigger_Touch(ent, other))
-                                       Simple_TeleportPlayer(ent, other); // NOT triggering targets by this!
+                               if (!WarpZoneLib_ExactTrigger_Touch(ent, it))
+                                       Simple_TeleportPlayer(ent, it); // NOT triggering targets by this!
                        }
                }
        });
-       other = oldother;
 }
 
 .float warpzone_reconnecting;