]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/warpzonelib/server.qc
More cleanup
[xonotic/xonotic-data.pk3dir.git] / qcsrc / warpzonelib / server.qc
index e662bf41f315219f16e98bb0eb8770fd9f2a5c41..9b94640b5a2319c734a103db57e036b48dd26883 100644 (file)
@@ -1,4 +1,6 @@
-#define REMOVEHACK
+#ifdef WARPZONELIB_KEEPDEBUG
+#define WARPZONELIB_REMOVEHACK
+#endif
 
 // for think function
 .vector warpzone_save_origin;
@@ -21,7 +23,7 @@ void WarpZone_StoreProjectileData(entity e)
 
 void WarpZone_TeleportPlayer(entity teleporter, entity player, vector to, vector to_angles, vector to_velocity)
 {
-       setorigin (player, to);
+       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;
@@ -82,9 +84,6 @@ float WarpZone_Teleport(entity wz, entity player, float f0, float f1)
                        o1 = o1 - v1 * (d / dv);
        }
 
-       if(o1 == o0)
-               o1_z = nextafter(o1_z, world.maxs_z);
-
        // put him out of solid
        tracebox(o1 - player.view_ofs, player.mins, player.maxs, o1 - player.view_ofs, MOVE_NOMONSTERS, player);
        if(trace_startsolid)
@@ -260,7 +259,7 @@ float WarpZone_Send(entity to, float sendflags)
 
 float WarpZone_Camera_Send(entity to, float sendflags)
 {
-       float f;
+       float f = 0;
        WriteByte(MSG_ENTITY, ENT_CLIENT_WARPZONE_CAMERA);
 
        if(self.warpzone_fadestart)
@@ -303,6 +302,7 @@ float WarpZone_Camera_Send(entity to, float sendflags)
        return TRUE;
 }
 
+#ifdef WARPZONELIB_KEEPDEBUG
 float WarpZone_CheckProjectileImpact(entity player)
 {
        vector o0, v0;
@@ -320,7 +320,7 @@ float WarpZone_CheckProjectileImpact(entity player)
        if(!wz)
                return 0;
 
-#ifdef REMOVEHACK
+#ifdef WARPZONELIB_REMOVEHACK
        print("impactfilter found something - and it no longer gets handled correctly - please tell divVerent whether anything behaves broken now\n");
 #else
        print("impactfilter found something - and it even gets handled correctly - please tell divVerent that this code apparently gets triggered again\n");
@@ -329,10 +329,9 @@ float WarpZone_CheckProjectileImpact(entity player)
        print("Origin: ", vtos(player.origin), "\n");
        print("Velocity: ", vtos(player.velocity), "\n");
 
-#ifdef REMOVEHACK
+#ifdef WARPZONELIB_REMOVEHACK
        return 0;
-#endif
-
+#else
        // retry previous move
        setorigin(player, player.warpzone_oldorigin);
        player.velocity = player.warpzone_oldvelocity;
@@ -367,17 +366,25 @@ float WarpZone_CheckProjectileImpact(entity player)
        }
 
        return +1;
+#endif
 }
+#endif
+
 float WarpZone_Projectile_Touch()
 {
-       float f;
        if(other.classname == "trigger_warpzone")
                return TRUE;
 
        // no further impacts if we teleported this frame!
+       // this is because even if we did teleport, the engine still may raise
+       // touch events for the previous location
+       // engine now aborts moves on teleport, so this SHOULD not happen any more
+       // but if this is called from TouchAreaGrid of the projectile moving,
+       // then this won't do
        if(time == self.warpzone_teleport_time)
                return TRUE;
 
+#ifdef WARPZONELIB_KEEPDEBUG
        // this SEEMS to not happen at the moment, but if it did, it would be more reliable
        {
                float save_dpstartcontents;
@@ -406,6 +413,7 @@ float WarpZone_Projectile_Touch()
                save_ent = trace_ent;
                save_inopen = trace_inopen;
                save_inwater = trace_inwater;
+               float f;
                if((f = WarpZone_CheckProjectileImpact(self)) != 0)
                        return (f > 0);
                trace_dpstartcontents = save_dpstartcontents;
@@ -422,6 +430,7 @@ float WarpZone_Projectile_Touch()
                trace_inopen = save_inopen;
                trace_inwater = save_inwater;
        }
+#endif
 
        if(WarpZone_Projectile_Touch_ImpactFilter_Callback())
                return TRUE;
@@ -574,7 +583,7 @@ void WarpZone_InitStep_UpdateTransform()
                                print("Position target of trigger_warpzone near ", vtos(self.aiment.origin), " points into trigger_warpzone. BEWARE.\n");
                                norm = -1 * norm;
                        }
-                       ang = vectoangles(norm, v_up); // keep rotation, but turn exactly against plane
+                       ang = vectoangles2(norm, v_up); // keep rotation, but turn exactly against plane
                        ang_x = -ang_x;
                        if(norm * v_forward < 0.99)
                                print("trigger_warpzone near ", vtos(self.aiment.origin), " has been turned to match plane orientation (", vtos(self.aiment.angles), " -> ", vtos(ang), "\n");