]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Use exact trigger hack on teleporters
authorMario <mario@smbclan.net>
Fri, 4 Dec 2015 03:32:05 +0000 (13:32 +1000)
committerMario <mario@smbclan.net>
Fri, 4 Dec 2015 03:32:05 +0000 (13:32 +1000)
qcsrc/common/triggers/trigger/teleport.qc

index 9fb6f48b61c9ea1586ad2b083384a61d6b4cd22b..252ead261ec700a3551edf49133d7a8fae0c1a14 100644 (file)
@@ -56,43 +56,67 @@ void Teleport_Touch ()
 }
 
 #ifdef SVQC
-float trigger_teleport_send(entity this, entity to, float sf)
-{
+float trigger_teleport_send(entity to, float sf)
+{SELFPARAM();
        WriteHeader(MSG_ENTITY, ENT_CLIENT_TRIGGER_TELEPORT);
-       WriteByte(MSG_ENTITY, sf);
 
-       if(sf & 1)
-       {
-               WriteByte(MSG_ENTITY, this.team);
-               WriteInt24_t(MSG_ENTITY, this.spawnflags);
-               WriteByte(MSG_ENTITY, this.active);
-               WriteCoord(MSG_ENTITY, this.speed);
+       int f = 0;
+       if(self.warpzone_isboxy)
+               BITSET_ASSIGN(f, 1);
+       if(self.origin != '0 0 0')
+               BITSET_ASSIGN(f, 4);
+       WriteByte(MSG_ENTITY, f);
 
-               trigger_common_write(true);
-       }
-
-       if(sf & 2)
+       if(f & 4)
        {
-               WriteByte(MSG_ENTITY, this.team);
-               WriteByte(MSG_ENTITY, this.active);
+               WriteCoord(MSG_ENTITY, self.origin.x);
+               WriteCoord(MSG_ENTITY, self.origin.y);
+               WriteCoord(MSG_ENTITY, self.origin.z);
        }
 
+       WriteShort(MSG_ENTITY, self.modelindex);
+       WriteCoord(MSG_ENTITY, self.mins.x);
+       WriteCoord(MSG_ENTITY, self.mins.y);
+       WriteCoord(MSG_ENTITY, self.mins.z);
+       WriteCoord(MSG_ENTITY, self.maxs.x);
+       WriteCoord(MSG_ENTITY, self.maxs.y);
+       WriteCoord(MSG_ENTITY, self.maxs.z);
+       WriteByte(MSG_ENTITY, bound(1, self.scale * 16, 255));
+       WriteByte(MSG_ENTITY, self.team);
+       WriteInt24_t(MSG_ENTITY, self.spawnflags);
+       WriteByte(MSG_ENTITY, self.active);
+       WriteCoord(MSG_ENTITY, self.speed);
+
+       trigger_common_write(true);
+
        return true;
 }
 
 void trigger_teleport_link(entity this)
 {
-       Net_LinkEntity(this, false, 0, trigger_teleport_send);
+       this.SendEntity = trigger_teleport_send;
+       this.SendFlags = 0xFFFFFF;
 }
 
 spawnfunc(trigger_teleport)
 {
        self.angles = '0 0 0';
 
-       EXACTTRIGGER_INIT;
+       string m = self.model;
+       WarpZoneLib_ExactTrigger_Init();
+       if(m != "")
+       {
+               precache_model(m);
+               _setmodel(self, m); // no precision needed
+       }
+       setorigin(self, self.origin);
+       if(self.scale)
+               setsize(self, self.mins * self.scale, self.maxs * self.scale);
+       else
+               setsize(self, self.mins, self.maxs);
 
        self.active = ACTIVE_ACTIVE;
-
+       BITSET_ASSIGN(self.effects, EF_NODEPTHTEST);
        self.use = trigger_teleport_use;
 
        // this must be called to spawn the teleport waypoints for bots
@@ -110,35 +134,44 @@ spawnfunc(trigger_teleport)
 #elif defined(CSQC)
 NET_HANDLE(ENT_CLIENT_TRIGGER_TELEPORT, bool isnew)
 {
-       int sf = ReadByte();
-
-       if(sf & 1)
+       int f = ReadByte();
+       self.warpzone_isboxy = (f & 1);
+       if(f & 4)
        {
-               self.classname = "trigger_teleport";
-               int mytm = ReadByte(); if(mytm) { self.team = mytm - 1; }
-               self.spawnflags = ReadInt24_t();
-               self.active = ReadByte();
-               self.speed = ReadCoord();
-
-               trigger_common_read(true);
-
-               self.entremove = trigger_remove_generic;
-               self.solid = SOLID_TRIGGER;
-               //self.draw = trigger_draw_generic;
-               //self.move_touch = trigger_push_touch;
-               self.drawmask = MASK_NORMAL;
-               self.move_time = time;
-               defer(self, 0.25, teleport_findtarget);
-
-               self.teleport_next = teleport_first;
-               teleport_first = self;
+               self.origin_x = ReadCoord();
+               self.origin_y = ReadCoord();
+               self.origin_z = ReadCoord();
        }
+       else
+               self.origin = '0 0 0';
+
+       self.modelindex = ReadShort();
+       self.mins_x = ReadCoord();
+       self.mins_y = ReadCoord();
+       self.mins_z = ReadCoord();
+       self.maxs_x = ReadCoord();
+       self.maxs_y = ReadCoord();
+       self.maxs_z = ReadCoord();
+       self.scale = ReadByte() / 16;
+       self.classname = "trigger_teleport";
+       int mytm = ReadByte(); if(mytm) { self.team = mytm - 1; }
+       self.spawnflags = ReadInt24_t();
+       self.active = ReadByte();
+       self.speed = ReadCoord();
+
+       trigger_common_read(true);
+
+       self.entremove = trigger_remove_generic;
+       self.solid = SOLID_TRIGGER;
+       //self.draw = trigger_draw_generic;
+       //self.move_touch = trigger_push_touch;
+       self.drawmask = MASK_NORMAL;
+       self.move_time = time;
+       defer(self, 0.25, teleport_findtarget);
+
+       self.teleport_next = teleport_first;
+       teleport_first = self;
 
-       if(sf & 2)
-       {
-               self.team = ReadByte();
-               self.active = ReadByte();
-       }
        return true;
 }