]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/triggers/trigger/viewloc.qc
Merge branch 'master' into Mirio/balance
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / triggers / trigger / viewloc.qc
index 62c37a0f49630664ccbe8a7209b58f2082abd4ff..db75434bfb6f98bd226f81bc72c07bbec718683b 100644 (file)
@@ -1,15 +1,17 @@
 #if defined(CSQC)
 #elif defined(MENUQC)
 #elif defined(SVQC)
-       #include "../../../dpdefs/progsdefs.qh"
-    #include "../../../warpzonelib/util_server.qh"
-    #include "../../../server/defs.qh"
+    #include <lib/warpzone/util_server.qh>
+    #include <server/defs.qh>
 #endif
 
+REGISTER_NET_LINKED(ENT_CLIENT_VIEWLOC)
+REGISTER_NET_LINKED(ENT_CLIENT_VIEWLOC_TRIGGER)
+
 #ifdef SVQC
 
 void viewloc_think()
-{
+{SELFPARAM();
        entity e;
 
        // 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
@@ -21,7 +23,7 @@ void viewloc_think()
                for(e = findradius((self.absmin + self.absmax) * 0.5, vlen(self.absmax - self.absmin) * 0.5 + 1); e; e = e.chain)
                        if(!e.viewloc)
                                if(IS_PLAYER(e)) // should we support non-player entities with this?
-                               //if(e.deadflag == DEAD_NO) // death view is handled separately, we can't override this just yet
+                               //if(!IS_DEAD(e)) // death view is handled separately, we can't override this just yet
                                {
                                        vector emin = e.absmin;
                                        vector emax = e.absmax;
@@ -38,10 +40,10 @@ void viewloc_think()
        self.nextthink = time;
 }
 
-bool trigger_viewloc_send(entity to, int sf)
+bool trigger_viewloc_send(entity this, entity to, int sf)
 {
        // CSQC doesn't need to know our origin (yet), as we're only available for referencing
-       WriteByte(MSG_ENTITY, ENT_CLIENT_VIEWLOC_TRIGGER);
+       WriteHeader(MSG_ENTITY, ENT_CLIENT_VIEWLOC_TRIGGER);
 
        WriteEntity(MSG_ENTITY, self.enemy);
        WriteEntity(MSG_ENTITY, self.goalentity);
@@ -53,7 +55,7 @@ bool trigger_viewloc_send(entity to, int sf)
        return true;
 }
 
-void viewloc_init()
+void viewloc_init(entity this)
 {
        entity e;
        for(e = world; (e = find(e, targetname, self.target)); )
@@ -80,7 +82,7 @@ void viewloc_init()
        self.nextthink = time;
 }
 
-void spawnfunc_trigger_viewlocation()
+spawnfunc(trigger_viewlocation)
 {
        // we won't check target2 here yet, as it may not even need to exist
        if(self.target == "") { LOG_INFO("^1FAIL!\n"); remove(self); return; }
@@ -89,9 +91,9 @@ void spawnfunc_trigger_viewlocation()
        InitializeEntity(self, viewloc_init, INITPRIO_FINDTARGET);
 }
 
-bool viewloc_send(entity to, int sf)
+bool viewloc_send(entity this, entity to, int sf)
 {
-       WriteByte(MSG_ENTITY, ENT_CLIENT_VIEWLOC);
+       WriteHeader(MSG_ENTITY, ENT_CLIENT_VIEWLOC);
 
        WriteByte(MSG_ENTITY, self.cnt);
 
@@ -108,19 +110,19 @@ bool viewloc_send(entity to, int sf)
 
 .float angle;
 void viewloc_link()
-{
+{SELFPARAM();
        if(self.angle)
                self.angles_y = self.angle;
        Net_LinkEntity(self, false, 0, viewloc_send);
 }
 
-void spawnfunc_target_viewlocation_start()
+spawnfunc(target_viewlocation_start)
 {
        self.classname = "target_viewlocation_start";
        self.cnt = 1;
        viewloc_link();
 }
-void spawnfunc_target_viewlocation_end()
+spawnfunc(target_viewlocation_end)
 {
        self.classname = "target_viewlocation_end";
        self.cnt = 2;
@@ -128,17 +130,17 @@ void spawnfunc_target_viewlocation_end()
 }
 
 // compatibility
-void spawnfunc_target_viewlocation() { spawnfunc_target_viewlocation_start(); }
+spawnfunc(target_viewlocation) { spawnfunc_target_viewlocation_start(this); }
 
 #elif defined(CSQC)
 
 void trigger_viewloc_updatelink()
-{
+{SELFPARAM();
        self.enemy = findfloat(world, entnum, self.cnt);
        self.goalentity = findfloat(world, entnum, self.count);
 }
 
-void ent_viewloc_trigger()
+NET_HANDLE(ENT_CLIENT_VIEWLOC_TRIGGER, bool isnew)
 {
        float point1 = ReadShort();
        float point2 = ReadShort();
@@ -149,6 +151,9 @@ void ent_viewloc_trigger()
        self.origin_x = ReadCoord();
        self.origin_y = ReadCoord();
        self.origin_z = ReadCoord();
+
+       return = true;
+
        setorigin(self, self.origin);
 
        self.cnt = point1;
@@ -161,7 +166,7 @@ void ent_viewloc_trigger()
        self.drawmask = MASK_NORMAL; // not so concerned, but better keep it alive
 }
 
-void ent_viewloc()
+NET_HANDLE(ENT_CLIENT_VIEWLOC, bool isnew)
 {
        self.cnt = ReadByte();
 
@@ -174,6 +179,8 @@ void ent_viewloc()
        self.movedir_y = ReadCoord();
        self.movedir_z = ReadCoord();
 
+       return = true;
+
        self.classname = ((self.cnt == 2) ? "target_viewlocation_end" : "target_viewlocation_start");
        self.drawmask = MASK_NORMAL; // don't cull it
 }