]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/triggers/trigger/viewloc.qc
take3: format 903 files
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / triggers / trigger / viewloc.qc
index ffc04a0782bf8d0a5b59c00876adf0b8319dc078..7d9c93155fbc44567ebc4efb655af6f335c45ce7 100644 (file)
@@ -2,8 +2,8 @@
 #if defined(CSQC)
 #elif defined(MENUQC)
 #elif defined(SVQC)
-    #include <lib/warpzone/util_server.qh>
-    #include <server/defs.qh>
+#include <lib/warpzone/util_server.qh>
+#include <server/defs.qh>
 #endif
 
 REGISTER_NET_LINKED(ENT_CLIENT_VIEWLOC)
@@ -18,25 +18,28 @@ 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 = NULL; (e = findentity(e, viewloc, this)); )
+       for (e = NULL; (e = findentity(e, viewloc, this)); ) {
                e.viewloc = NULL;
-
-               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(this.solid == SOLID_BSP)
-                                       {
-                                               emin -= '1 1 1';
-                                               emax += '1 1 1';
+       }
+
+       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 (this.solid == SOLID_BSP) {
+                                       emin -= '1 1 1';
+                                       emax += '1 1 1';
+                               }
+                               if (boxesoverlap(emin, emax, this.absmin, this.absmax)) { // quick
+                                       if (WarpZoneLib_BoxTouchesBrush(emin, emax, this, e)) { // accurate
+                                               e.viewloc = this;
                                        }
-                                       if(boxesoverlap(emin, emax, this.absmin, this.absmax)) // quick
-                                               if(WarpZoneLib_BoxTouchesBrush(emin, emax, this, e)) // accurate
-                                                       e.viewloc = this;
                                }
+                       }
+               }
+       }
 
        this.nextthink = time;
 }
@@ -59,24 +62,24 @@ bool trigger_viewloc_send(entity this, entity to, int sf)
 void viewloc_init(entity this)
 {
        entity e;
-       for(e = NULL; (e = find(e, targetname, this.target)); )
-               if(e.classname == "target_viewlocation_start")
-               {
+       for (e = NULL; (e = find(e, targetname, this.target)); ) {
+               if (e.classname == "target_viewlocation_start") {
                        this.enemy = e;
                        break;
                }
-       for(e = NULL; (e = find(e, targetname, this.target2)); )
-               if(e.classname == "target_viewlocation_end")
-               {
+       }
+       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!"); delete(this); return; }
+       if (!this.enemy) { LOG_INFO("^1FAIL!"); delete(this); return; }
 
-       if(!this.goalentity)
+       if (!this.goalentity) {
                this.goalentity = this.enemy; // make them match so CSQC knows what to do
-
+       }
        Net_LinkEntity(this, false, 0, trigger_viewloc_send);
 
        setthink(this, viewloc_think);
@@ -86,7 +89,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!"); delete(this); return; }
+       if (this.target == "") { LOG_INFO("^1FAIL!"); delete(this); return; }
 
        EXACTTRIGGER_INIT;
        InitializeEntity(this, viewloc_init, INITPRIO_FINDTARGET);
@@ -112,8 +115,9 @@ bool viewloc_send(entity this, entity to, int sf)
 .float angle;
 void viewloc_link(entity this)
 {
-       if(this.angle)
+       if (this.angle) {
                this.angles_y = this.angle;
+       }
        Net_LinkEntity(this, false, 0, viewloc_send);
 }
 
@@ -131,7 +135,10 @@ spawnfunc(target_viewlocation_end)
 }
 
 // compatibility
-spawnfunc(target_viewlocation) { spawnfunc_target_viewlocation_start(this); }
+spawnfunc(target_viewlocation)
+{
+       spawnfunc_target_viewlocation_start(this);
+}
 
 #elif defined(CSQC)
 
@@ -161,7 +168,7 @@ NET_HANDLE(ENT_CLIENT_VIEWLOC_TRIGGER, bool isnew)
        this.count = point2;
 
        setthink(this, trigger_viewloc_updatelink);
-       this.nextthink = time + 1; // we need to delay this or else
+       this.nextthink = time + 1;   // we need to delay this or else
 
        this.classname = "trigger_viewlocation";
        this.drawmask = MASK_NORMAL; // not so concerned, but better keep it alive