From e02f1855a702f26f0ec2a130fe805ec6343c42b1 Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 4 Dec 2015 13:32:05 +1000 Subject: [PATCH] Use exact trigger hack on teleporters --- qcsrc/common/triggers/trigger/teleport.qc | 121 ++++++++++++++-------- 1 file changed, 77 insertions(+), 44 deletions(-) diff --git a/qcsrc/common/triggers/trigger/teleport.qc b/qcsrc/common/triggers/trigger/teleport.qc index 9fb6f48b6..252ead261 100644 --- a/qcsrc/common/triggers/trigger/teleport.qc +++ b/qcsrc/common/triggers/trigger/teleport.qc @@ -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; } -- 2.39.2