]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/triggers/trigger/viewloc.qc
Merge branch 'master' into Lyberta/StandaloneOverkillWeapons
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / triggers / trigger / viewloc.qc
index d65fe953f39d2de0bd015d6ed74f747e53f5591c..ffc04a0782bf8d0a5b59c00876adf0b8319dc078 100644 (file)
@@ -1,3 +1,4 @@
+#include "viewloc.qh"
 #if defined(CSQC)
 #elif defined(MENUQC)
 #elif defined(SVQC)
@@ -17,27 +18,27 @@ void viewloc_think(entity this)
        // we abuse this method, rather than using normal .touch, because touch isn't reliable with multiple clients inside the same trigger, and can't "untouch" entities
 
        // set myself as current viewloc where possible
-       for(e = world; (e = findentity(e, viewloc, self)); )
-               e.viewloc = world;
+       for(e = NULL; (e = findentity(e, viewloc, this)); )
+               e.viewloc = NULL;
 
-               for(e = findradius((self.absmin + self.absmax) * 0.5, vlen(self.absmax - self.absmin) * 0.5 + 1); e; e = e.chain)
+               for(e = findradius((this.absmin + this.absmax) * 0.5, vlen(this.absmax - this.absmin) * 0.5 + 1); e; e = e.chain)
                        if(!e.viewloc)
                                if(IS_PLAYER(e)) // should we support non-player entities with this?
                                //if(!IS_DEAD(e)) // death view is handled separately, we can't override this just yet
                                {
                                        vector emin = e.absmin;
                                        vector emax = e.absmax;
-                                       if(self.solid == SOLID_BSP)
+                                       if(this.solid == SOLID_BSP)
                                        {
                                                emin -= '1 1 1';
                                                emax += '1 1 1';
                                        }
-                                       if(boxesoverlap(emin, emax, self.absmin, self.absmax)) // quick
-                                               if(WarpZoneLib_BoxTouchesBrush(emin, emax, self, e)) // accurate
-                                                       e.viewloc = self;
+                                       if(boxesoverlap(emin, emax, this.absmin, this.absmax)) // quick
+                                               if(WarpZoneLib_BoxTouchesBrush(emin, emax, this, e)) // accurate
+                                                       e.viewloc = this;
                                }
 
-       self.nextthink = time;
+       this.nextthink = time;
 }
 
 bool trigger_viewloc_send(entity this, entity to, int sf)
@@ -58,20 +59,20 @@ bool trigger_viewloc_send(entity this, entity to, int sf)
 void viewloc_init(entity this)
 {
        entity e;
-       for(e = world; (e = find(e, targetname, this.target)); )
+       for(e = NULL; (e = find(e, targetname, this.target)); )
                if(e.classname == "target_viewlocation_start")
                {
                        this.enemy = e;
                        break;
                }
-       for(e = world; (e = find(e, targetname, this.target2)); )
+       for(e = NULL; (e = find(e, targetname, this.target2)); )
                if(e.classname == "target_viewlocation_end")
                {
                        this.goalentity = e;
                        break;
                }
 
-       if(!this.enemy) { LOG_INFO("^1FAIL!\n"); remove(this); return; }
+       if(!this.enemy) { LOG_INFO("^1FAIL!"); delete(this); return; }
 
        if(!this.goalentity)
                this.goalentity = this.enemy; // make them match so CSQC knows what to do
@@ -85,7 +86,7 @@ void viewloc_init(entity this)
 spawnfunc(trigger_viewlocation)
 {
        // we won't check target2 here yet, as it may not even need to exist
-       if(this.target == "") { LOG_INFO("^1FAIL!\n"); remove(this); return; }
+       if(this.target == "") { LOG_INFO("^1FAIL!"); delete(this); return; }
 
        EXACTTRIGGER_INIT;
        InitializeEntity(this, viewloc_init, INITPRIO_FINDTARGET);
@@ -101,9 +102,9 @@ bool viewloc_send(entity this, entity to, int sf)
        WriteCoord(MSG_ENTITY, this.origin_y);
        WriteCoord(MSG_ENTITY, this.origin_z);
 
-       WriteCoord(MSG_ENTITY, this.angles_x);
-       WriteCoord(MSG_ENTITY, this.angles_y);
-       WriteCoord(MSG_ENTITY, this.angles_z);
+       WriteAngle(MSG_ENTITY, this.angles_x);
+       WriteAngle(MSG_ENTITY, this.angles_y);
+       WriteAngle(MSG_ENTITY, this.angles_z);
 
        return true;
 }
@@ -136,8 +137,8 @@ spawnfunc(target_viewlocation) { spawnfunc_target_viewlocation_start(this); }
 
 void trigger_viewloc_updatelink(entity this)
 {
-       self.enemy = findfloat(world, entnum, self.cnt);
-       self.goalentity = findfloat(world, entnum, self.count);
+       this.enemy = findfloat(NULL, entnum, this.cnt);
+       this.goalentity = findfloat(NULL, entnum, this.count);
 }
 
 NET_HANDLE(ENT_CLIENT_VIEWLOC_TRIGGER, bool isnew)
@@ -145,8 +146,8 @@ NET_HANDLE(ENT_CLIENT_VIEWLOC_TRIGGER, bool isnew)
        float point1 = ReadShort();
        float point2 = ReadShort();
 
-       this.enemy = findfloat(world, entnum, point1);
-       this.goalentity = findfloat(world, entnum, point2);
+       this.enemy = findfloat(NULL, entnum, point1);
+       this.goalentity = findfloat(NULL, entnum, point2);
 
        this.origin_x = ReadCoord();
        this.origin_y = ReadCoord();
@@ -175,9 +176,9 @@ NET_HANDLE(ENT_CLIENT_VIEWLOC, bool isnew)
        this.origin_z = ReadCoord();
        setorigin(this, this.origin);
 
-       this.movedir_x = ReadCoord();
-       this.movedir_y = ReadCoord();
-       this.movedir_z = ReadCoord();
+       this.movedir_x = ReadAngle();
+       this.movedir_y = ReadAngle();
+       this.movedir_z = ReadAngle();
 
        return = true;