]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/warpzonelib/server.qc
Use SELFPARAM() in every function that uses self
[xonotic/xonotic-data.pk3dir.git] / qcsrc / warpzonelib / server.qc
index 5d529c12e215ab78c66f85c48d7c79a8f3800147..8d5a6b68a8f35cb24c23444fb777f8f2a142258c 100644 (file)
@@ -1,15 +1,17 @@
+#include "server.qh"
+
+#include "common.qh"
 #if defined(CSQC)
 #elif defined(MENUQC)
 #elif defined(SVQC)
-       #include "../dpdefs/progsdefs.qh"
-       #include "../dpdefs/dpextensions.qh"
-       #include "common.qh"
-       #include "server.qh"
        #include "../common/constants.qh"
+       #include "../common/triggers/subs.qh"
        #include "../common/util.qh"
+       #include "../dpdefs/dpextensions.qh"
+       #include "../dpdefs/progsdefs.qh"
+       #include "../server/command/common.qh"
        #include "../server/constants.qh"
        #include "../server/defs.qh"
-       #include "../server/command/common.qh"
 #endif
 
 #ifdef WARPZONELIB_KEEPDEBUG
@@ -51,8 +53,8 @@ void WarpZone_TeleportPlayer(entity teleporter, entity player, vector to, vector
        WarpZone_PostTeleportPlayer_Callback(player);
 }
 
-float WarpZone_Teleported_Send(entity to, float sf)
-{
+bool WarpZone_Teleported_Send(entity to, int sf)
+{SELFPARAM();
        WriteByte(MSG_ENTITY, ENT_CLIENT_WARPZONE_TELEPORTED);
        WriteCoord(MSG_ENTITY, self.angles.x);
        WriteCoord(MSG_ENTITY, self.angles.y);
@@ -110,7 +112,7 @@ float WarpZone_Teleport(entity wz, entity player, float f0, float f1)
                }
                else
                {
-                       print("would have to put player in solid, won't do that\n");
+                       LOG_INFO("would have to put player in solid, won't do that\n");
                        setorigin(player, o0 - player.view_ofs);
                        return 0;
                }
@@ -130,6 +132,8 @@ float WarpZone_Teleport(entity wz, entity player, float f0, float f1)
                player.warpzone_teleport_finishtime += sys_frametime - dt;
 
 #ifndef WARPZONE_USE_FIXANGLE
+       if(IS_VEHICLE(player) && player.owner)
+               player = player.owner; // hax
        if(IS_PLAYER(player))
        {
                // instead of fixangle, send the transform to the client for smoother operation
@@ -154,7 +158,7 @@ float WarpZone_Teleport(entity wz, entity player, float f0, float f1)
 }
 
 void WarpZone_Touch (void)
-{
+{SELFPARAM();
        entity oldself;
 
        if(other.classname == "trigger_warpzone")
@@ -212,12 +216,12 @@ void WarpZone_Touch (void)
        }
        else
        {
-               dprint("WARPZONE FAIL AHAHAHAHAH))\n");
+               LOG_TRACE("WARPZONE FAIL AHAHAHAHAH))\n");
        }
 }
 
-float WarpZone_Send(entity to, float sendflags)
-{
+bool WarpZone_Send(entity to, int sendflags)
+{SELFPARAM();
        WriteByte(MSG_ENTITY, ENT_CLIENT_WARPZONE);
 
        // we must send this flag for clientside to match properly too
@@ -270,8 +274,8 @@ float WarpZone_Send(entity to, float sendflags)
        return true;
 }
 
-float WarpZone_Camera_Send(entity to, float sendflags)
-{
+bool WarpZone_Camera_Send(entity to, int sendflags)
+{SELFPARAM();
        int f = 0;
        WriteByte(MSG_ENTITY, ENT_CLIENT_WARPZONE_CAMERA);
 
@@ -317,7 +321,7 @@ float WarpZone_Camera_Send(entity to, float sendflags)
 
 #ifdef WARPZONELIB_KEEPDEBUG
 float WarpZone_CheckProjectileImpact(entity player)
-{
+{SELFPARAM();
        vector o0, v0;
 
        o0 = player.origin + player.view_ofs;
@@ -334,13 +338,13 @@ float WarpZone_CheckProjectileImpact(entity player)
                return 0;
 
 #ifdef WARPZONELIB_REMOVEHACK
-       print("impactfilter found something - and it no longer gets handled correctly - please tell divVerent whether anything behaves broken now\n");
+       LOG_INFO("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");
+       LOG_INFO("impactfilter found something - and it even gets handled correctly - please tell divVerent that this code apparently gets triggered again\n");
 #endif
-       print("Entity type: ", player.classname, "\n");
-       print("Origin: ", vtos(player.origin), "\n");
-       print("Velocity: ", vtos(player.velocity), "\n");
+       LOG_INFO("Entity type: ", player.classname, "\n");
+       LOG_INFO("Origin: ", vtos(player.origin), "\n");
+       LOG_INFO("Velocity: ", vtos(player.velocity), "\n");
 
 #ifdef WARPZONELIB_REMOVEHACK
        return 0;
@@ -384,7 +388,7 @@ float WarpZone_CheckProjectileImpact(entity player)
 #endif
 
 float WarpZone_Projectile_Touch()
-{
+{SELFPARAM();
        if(other.classname == "trigger_warpzone")
                return true;
 
@@ -452,7 +456,7 @@ float WarpZone_Projectile_Touch()
 }
 
 void WarpZone_InitStep_FindOriginTarget()
-{
+{SELFPARAM();
        if(self.killtarget != "")
        {
                self.aiment = find(world, targetname, self.killtarget);
@@ -466,7 +470,7 @@ void WarpZone_InitStep_FindOriginTarget()
 }
 
 void WarpZonePosition_InitStep_FindTarget()
-{
+{SELFPARAM();
        if(self.target == "")
        {
                error("Warp zone position with no target");
@@ -488,7 +492,7 @@ void WarpZonePosition_InitStep_FindTarget()
 }
 
 void WarpZoneCamera_Think(void)
-{
+{SELFPARAM();
        if(self.warpzone_save_origin != self.origin
        || self.warpzone_save_angles != self.angles
        || self.warpzone_save_eorigin != self.enemy.origin
@@ -504,7 +508,7 @@ void WarpZoneCamera_Think(void)
 }
 
 void WarpZoneCamera_InitStep_FindTarget()
-{
+{SELFPARAM();
        entity e;
        float i;
        if(self.target == "")
@@ -534,10 +538,10 @@ void WarpZoneCamera_InitStep_FindTarget()
 }
 
 void WarpZone_InitStep_UpdateTransform()
-{
+{SELFPARAM();
        vector org, ang, norm, point;
        float area;
-       vector tri, a, b, c, p, q, n;
+       vector tri, a, b, c, n;
        float i_s, i_t, n_t;
        string tex;
 
@@ -561,11 +565,7 @@ void WarpZone_InitStep_UpdateTransform()
                        a = getsurfacepoint(self, i_s, tri.x);
                        b = getsurfacepoint(self, i_s, tri.y);
                        c = getsurfacepoint(self, i_s, tri.z);
-                       p = b - a;
-                       q = c - a;
-                       n =     '1 0 0' * (q.y * p.z - q.z * p.y)
-                       +       '0 1 0' * (q.z * p.x - q.x * p.z)
-                       +       '0 0 1' * (q.x * p.y - q.y * p.x);
+                       n = cross(c - a, b - a);
                        area = area + vlen(n);
                        norm = norm + n;
                        point = point + vlen(n) * (a + b + c);
@@ -577,7 +577,7 @@ void WarpZone_InitStep_UpdateTransform()
                point = point * (1 / (3 * area));
                if(vlen(norm) < 0.99)
                {
-                       print("trigger_warpzone near ", vtos(self.aiment.origin), " is nonplanar. BEWARE.\n");
+                       LOG_INFO("trigger_warpzone near ", vtos(self.aiment.origin), " is nonplanar. BEWARE.\n");
                        area = 0; // no autofixing in this case
                }
                norm = normalize(norm);
@@ -594,15 +594,15 @@ void WarpZone_InitStep_UpdateTransform()
                        makevectors(ang);
                        if(norm * v_forward < 0)
                        {
-                               print("Position target of trigger_warpzone near ", vtos(self.aiment.origin), " points into trigger_warpzone. BEWARE.\n");
+                               LOG_INFO("Position target of trigger_warpzone near ", vtos(self.aiment.origin), " points into trigger_warpzone. BEWARE.\n");
                                norm = -1 * norm;
                        }
                        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");
+                               LOG_INFO("trigger_warpzone near ", vtos(self.aiment.origin), " has been turned to match plane orientation (", vtos(self.aiment.angles), " -> ", vtos(ang), "\n");
                        if(vlen(org - self.aiment.origin) > 0.5)
-                               print("trigger_warpzone near ", vtos(self.aiment.origin), " has been moved to match the plane (", vtos(self.aiment.origin), " -> ", vtos(org), ").\n");
+                               LOG_INFO("trigger_warpzone near ", vtos(self.aiment.origin), " has been moved to match the plane (", vtos(self.aiment.origin), " -> ", vtos(org), ").\n");
                }
        }
        else if(area > 0)
@@ -619,7 +619,7 @@ void WarpZone_InitStep_UpdateTransform()
 }
 
 void WarpZone_InitStep_ClearTarget()
-{
+{SELFPARAM();
        if(self.enemy)
                self.enemy.enemy = world;
        self.enemy = world;
@@ -627,7 +627,7 @@ void WarpZone_InitStep_ClearTarget()
 
 entity warpzone_first; .entity warpzone_next;
 void WarpZone_InitStep_FindTarget()
-{
+{SELFPARAM();
        float i;
        entity e, e2;
 
@@ -658,7 +658,7 @@ void WarpZone_InitStep_FindTarget()
 
 void WarpZone_Think();
 void WarpZone_InitStep_FinalizeTransform()
-{
+{SELFPARAM();
        if(!self.enemy || self.enemy.enemy != self)
        {
                error("Invalid warp zone detected. Killed.");
@@ -684,7 +684,7 @@ entity warpzone_position_first;
 entity warpzone_camera_first;
 .entity warpzone_next;
 void spawnfunc_misc_warpzone_position(void)
-{
+{SELFPARAM();
        // "target", "angles", "origin"
        self.warpzone_next = warpzone_position_first;
        warpzone_position_first = self;
@@ -694,7 +694,7 @@ void spawnfunc_trigger_warpzone_position(void)
        spawnfunc_misc_warpzone_position();
 }
 void spawnfunc_trigger_warpzone(void)
-{
+{SELFPARAM();
        // warp zone entities must have:
        // "killtarget" pointing to a target_position with a direction arrow
        //              that points AWAY from the warp zone, and that is inside
@@ -732,7 +732,7 @@ void spawnfunc_trigger_warpzone(void)
        warpzone_first = self;
 }
 void spawnfunc_func_camera(void)
-{
+{SELFPARAM();
        if(!self.scale)
                self.scale = self.modelscale;
        if(!self.scale)
@@ -757,7 +757,7 @@ void spawnfunc_func_camera(void)
        warpzone_camera_first = self;
 }
 void WarpZones_Reconnect()
-{
+{SELFPARAM();
        entity e;
        e = self;
        for(self = warpzone_first; self; self = self.warpzone_next)
@@ -772,7 +772,7 @@ void WarpZones_Reconnect()
 }
 
 void WarpZone_Think()
-{
+{SELFPARAM();
        if(self.warpzone_save_origin != self.origin
        || self.warpzone_save_angles != self.angles
        || self.warpzone_save_eorigin != self.enemy.origin
@@ -797,7 +797,7 @@ void WarpZone_Think()
 }
 
 void WarpZone_StartFrame()
-{
+{SELFPARAM();
        entity e;
        if(warpzone_initialized == 0)
        {
@@ -867,7 +867,7 @@ float visible_to_some_client(entity ent)
        return 0;
 }
 void trigger_warpzone_reconnect_use()
-{
+{SELFPARAM();
        entity e;
        e = self;
        // NOTE: this matches for target, not targetname, but of course
@@ -892,7 +892,7 @@ void trigger_warpzone_reconnect_use()
 }
 
 void spawnfunc_trigger_warpzone_reconnect()
-{
+{SELFPARAM();
        self.use = trigger_warpzone_reconnect_use;
 }
 
@@ -902,7 +902,7 @@ void spawnfunc_target_warpzone_reconnect()
 }
 
 void WarpZone_PlayerPhysics_FixVAngle(void)
-{
+{SELFPARAM();
 #ifndef WARPZONE_DONT_FIX_VANGLE
        if(IS_REAL_CLIENT(self))
        if(self.v_angle.z <= 360) // if not already adjusted