]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Make the trigger functions handle fixing of trigger model, fixes most triggers with...
authorMario <mario@smbclan.net>
Fri, 4 Dec 2015 05:09:35 +0000 (15:09 +1000)
committerMario <mario@smbclan.net>
Fri, 4 Dec 2015 05:10:15 +0000 (15:10 +1000)
qcsrc/common/triggers/func/door.qc
qcsrc/common/triggers/func/ladder.qc
qcsrc/common/triggers/func/plat.qc
qcsrc/common/triggers/func/train.qc
qcsrc/common/triggers/trigger/impulse.qc
qcsrc/common/triggers/trigger/jumppads.qc
qcsrc/common/triggers/trigger/keylock.qc
qcsrc/common/triggers/trigger/swamp.qc
qcsrc/common/triggers/trigger/teleport.qc
qcsrc/common/triggers/triggers.qc
qcsrc/common/triggers/triggers.qh

index 87496b217649b97e07041cb78ab5350f1e9be4aa..35a2ff8f71529991254240a5f695757a3a21f4df 100644 (file)
@@ -643,7 +643,7 @@ float door_send(entity to, float sf)
 
                WriteString(MSG_ENTITY, self.model);
 
-               trigger_common_write(true);
+               trigger_common_write(self, true);
 
                WriteCoord(MSG_ENTITY, self.pos1_x);
                WriteCoord(MSG_ENTITY, self.pos1_y);
index edba032336ee45017104a46bb0a801f225b2ecde..bcf994ff4e42de7b845ab1c319592ef6d649980d 100644 (file)
@@ -20,35 +20,11 @@ bool func_ladder_send(entity to, int sf)
 {SELFPARAM();
        WriteHeader(MSG_ENTITY, ENT_CLIENT_LADDER);
 
-       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);
-
-       // we need THESE to render the warpzone (and cull properly)...
-       if(f & 4)
-       {
-               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));
-
        WriteString(MSG_ENTITY, self.classname);
        WriteByte(MSG_ENTITY, self.skin);
        WriteCoord(MSG_ENTITY, self.speed);
 
-       trigger_common_write(false);
+       trigger_common_write(self, false);
 
        return true;
 }
@@ -62,22 +38,9 @@ void func_ladder_link()
 
 void func_ladder_init()
 {
-       //self.mdl = self.model;
-       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.touch = func_ladder_touch;
-       BITSET_ASSIGN(self.effects, EF_NODEPTHTEST);
 
+       trigger_init(self);
        func_ladder_link();
 }
 
@@ -102,25 +65,6 @@ void func_ladder_remove()
 
 NET_HANDLE(ENT_CLIENT_LADDER, bool isnew)
 {
-       int f = ReadByte();
-       self.warpzone_isboxy = (f & 1);
-       if(f & 4)
-       {
-               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 = strzone(ReadString());
        self.skin = ReadByte();
        self.speed = ReadCoord();
index 9e98d12ba25416508e57e06d22c865080fc35594..ea546164ce71fb0589b03f12f8fea3962c82f214 100644 (file)
@@ -23,7 +23,7 @@ float plat_send(entity to, float sf)
 
                WriteString(MSG_ENTITY, self.model);
 
-               trigger_common_write(true);
+               trigger_common_write(self, true);
 
                WriteCoord(MSG_ENTITY, self.pos1_x);
                WriteCoord(MSG_ENTITY, self.pos1_y);
index 80350e743b94ba07c27abf54cb3eb7c0f0bd47fb..e02b917d1cc118cfc73c0cffea72f60790f3ee29 100644 (file)
@@ -117,7 +117,7 @@ float train_send(entity to, float sf)
 
                WriteString(MSG_ENTITY, self.model);
 
-               trigger_common_write(true);
+               trigger_common_write(self, true);
 
                WriteString(MSG_ENTITY, self.curvetarget);
 
index abb40563ec33c672e29a895ba5d5f499bcd8c0f0..c2b59a3e0b40b348b25b8ca6f09f8b61955e54e5 100644 (file)
@@ -168,27 +168,28 @@ bool trigger_impulse_send(entity this, entity to, int sf)
 {
        WriteHeader(MSG_ENTITY, ENT_CLIENT_TRIGGER_IMPULSE);
 
-       WriteInt24_t(MSG_ENTITY, self.spawnflags);
-       WriteCoord(MSG_ENTITY, self.radius);
-       WriteCoord(MSG_ENTITY, self.strength);
-       WriteByte(MSG_ENTITY, self.falloff);
-       WriteByte(MSG_ENTITY, self.active);
+       WriteInt24_t(MSG_ENTITY, this.spawnflags);
+       WriteCoord(MSG_ENTITY, this.radius);
+       WriteCoord(MSG_ENTITY, this.strength);
+       WriteByte(MSG_ENTITY, this.falloff);
+       WriteByte(MSG_ENTITY, this.active);
 
-       trigger_common_write(true);
+       trigger_common_write(this, true);
 
        return true;
 }
 
 void trigger_impulse_link()
 {
-       Net_LinkEntity(self, 0, false, trigger_impulse_send);
+       trigger_link(self, trigger_impulse_send);
 }
 
 spawnfunc(trigger_impulse)
 {
        self.active = ACTIVE_ACTIVE;
 
-       EXACTTRIGGER_INIT;
+       trigger_init(self);
+
        if(self.radius)
        {
                if(!self.strength) self.strength = 2000 * autocvar_g_triggerimpulse_radial_multiplier;
index ea3170a24f4826bff2acca9f568765a7728556db..cdd383e536216af459824fbfd2be574b3d33d848 100644 (file)
@@ -323,23 +323,13 @@ void trigger_push_findtarget()
 float trigger_push_send(entity this, entity to, float sf)
 {
        WriteHeader(MSG_ENTITY, ENT_CLIENT_TRIGGER_PUSH);
-       WriteByte(MSG_ENTITY, sf);
 
-       if(sf & 1)
-       {
-               WriteByte(MSG_ENTITY, self.team);
-               WriteInt24_t(MSG_ENTITY, self.spawnflags);
-               WriteByte(MSG_ENTITY, self.active);
-               WriteCoord(MSG_ENTITY, self.height);
+       WriteByte(MSG_ENTITY, self.team);
+       WriteInt24_t(MSG_ENTITY, self.spawnflags);
+       WriteByte(MSG_ENTITY, self.active);
+       WriteCoord(MSG_ENTITY, self.height);
 
-               trigger_common_write(true);
-       }
-
-       if(sf & 2)
-       {
-               WriteByte(MSG_ENTITY, self.team);
-               WriteByte(MSG_ENTITY, self.active);
-       }
+       trigger_common_write(self, true);
 
        return true;
 }
@@ -351,8 +341,7 @@ void trigger_push_updatelink()
 
 void trigger_push_link()
 {
-       BITSET_ASSIGN(self.effects, EF_NODEPTHTEST);
-       Net_LinkEntity(self, false, 0, trigger_push_send);
+       trigger_link(self, trigger_push_send);
 }
 
 /*
@@ -371,7 +360,7 @@ spawnfunc(trigger_push)
 {
        SetMovedir(self);
 
-       EXACTTRIGGER_INIT;
+       trigger_init(self);
 
        self.active = ACTIVE_ACTIVE;
        self.use = trigger_push_use;
@@ -424,32 +413,23 @@ spawnfunc(target_position) { make_pure(this); target_push_link(); }
 NET_HANDLE(ENT_CLIENT_TRIGGER_PUSH, bool isnew)
 {
        make_pure(this);
-       float sf = ReadByte();
 
-       if(sf & 1)
-       {
-               self.classname = "jumppad";
-               int mytm = ReadByte(); if(mytm) { self.team = mytm - 1; }
-               self.spawnflags = ReadInt24_t();
-               self.active = ReadByte();
-               self.height = 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, trigger_push_findtarget);
-       }
+       self.classname = "jumppad";
+       int mytm = ReadByte(); if(mytm) { self.team = mytm - 1; }
+       self.spawnflags = ReadInt24_t();
+       self.active = ReadByte();
+       self.height = 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, trigger_push_findtarget);
 
-       if(sf & 2)
-       {
-               self.team = ReadByte();
-               self.active = ReadByte();
-       }
        return true;
 }
 
index 98b121d6eebc9eca44930c10f61ea0f442775b1a..b628eaf8250baa7e9591db4028d07673b4385176 100644 (file)
@@ -104,7 +104,7 @@ bool trigger_keylock_send(entity to, int sf)
        WriteInt24_t(MSG_ENTITY, self.itemkeys);
        WriteByte(MSG_ENTITY, self.height);
 
-       trigger_common_write(true);
+       trigger_common_write(self, true);
 
        return true;
 }
index 768a3c78b9a94ffccd33b06c01b78d5181dcd4f8..2a03db78da3dc507bb8602a11d36f0ed319276d2 100644 (file)
@@ -99,18 +99,18 @@ float swamp_send(entity this, entity to, float sf)
 {
        WriteHeader(MSG_ENTITY, ENT_CLIENT_SWAMP);
 
-       WriteByte(MSG_ENTITY, self.dmg); // can probably get away with using a single byte here
-       WriteByte(MSG_ENTITY, self.swamp_slowdown);
-       WriteByte(MSG_ENTITY, self.swamp_interval);
+       WriteByte(MSG_ENTITY, this.dmg); // can probably get away with using a single byte here
+       WriteByte(MSG_ENTITY, this.swamp_slowdown);
+       WriteByte(MSG_ENTITY, this.swamp_interval);
 
-       trigger_common_write(false);
+       trigger_common_write(this, false);
 
        return true;
 }
 
 void swamp_link()
 {SELFPARAM();
-       Net_LinkEntity(self, false, 0, swamp_send);
+       trigger_link(self, swamp_send);
 }
 
 /*QUAKED spawnfunc_trigger_swamp (.5 .5 .5) ?
@@ -120,7 +120,7 @@ get slowd down and damaged
 spawnfunc(trigger_swamp)
 {
        // Init stuff
-       EXACTTRIGGER_INIT;
+       trigger_init(self);
        self.touch = swamp_touch;
 
        // Setup default keys, if missing
index 252ead261ec700a3551edf49133d7a8fae0c1a14..48b0341d33c832315133470715c668d844fd6b4c 100644 (file)
@@ -56,67 +56,31 @@ void Teleport_Touch ()
 }
 
 #ifdef SVQC
-float trigger_teleport_send(entity to, float sf)
-{SELFPARAM();
+float trigger_teleport_send(entity this, entity to, float sf)
+{
        WriteHeader(MSG_ENTITY, ENT_CLIENT_TRIGGER_TELEPORT);
 
-       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);
-
-       if(f & 4)
-       {
-               WriteCoord(MSG_ENTITY, self.origin.x);
-               WriteCoord(MSG_ENTITY, self.origin.y);
-               WriteCoord(MSG_ENTITY, self.origin.z);
-       }
+       WriteByte(MSG_ENTITY, this.team);
+       WriteInt24_t(MSG_ENTITY, this.spawnflags);
+       WriteByte(MSG_ENTITY, this.active);
+       WriteCoord(MSG_ENTITY, this.speed);
 
-       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);
+       trigger_common_write(this, true);
 
        return true;
 }
 
 void trigger_teleport_link(entity this)
 {
-       this.SendEntity = trigger_teleport_send;
-       this.SendFlags = 0xFFFFFF;
+       trigger_link(this, trigger_teleport_send);
 }
 
 spawnfunc(trigger_teleport)
 {
        self.angles = '0 0 0';
 
-       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);
+       trigger_init(self);
        self.use = trigger_teleport_use;
 
        // this must be called to spawn the teleport waypoints for bots
@@ -134,25 +98,6 @@ spawnfunc(trigger_teleport)
 #elif defined(CSQC)
 NET_HANDLE(ENT_CLIENT_TRIGGER_TELEPORT, bool isnew)
 {
-       int f = ReadByte();
-       self.warpzone_isboxy = (f & 1);
-       if(f & 4)
-       {
-               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();
index cce879eed9b7905c2792ed154fca116ef9ca3a65..cd1d0260c01c8d2836f6e1fc369ae1208591e0a2 100644 (file)
@@ -21,47 +21,82 @@ void FixSize(entity e)
 }
 
 #ifdef SVQC
-void trigger_common_write(bool withtarget)
-{SELFPARAM();
-       WriteByte(MSG_ENTITY, self.warpzone_isboxy);
-       WriteByte(MSG_ENTITY, self.scale);
 
-       if(withtarget)
-       {
-               WriteString(MSG_ENTITY, self.target);
-               WriteString(MSG_ENTITY, self.target2);
-               WriteString(MSG_ENTITY, self.target3);
-               WriteString(MSG_ENTITY, self.target4);
-               WriteString(MSG_ENTITY, self.targetname);
-               WriteString(MSG_ENTITY, self.killtarget);
+void trigger_init(entity this)
+{
+       string m = this.model;
+       WITH(entity, self, this, WarpZoneLib_ExactTrigger_Init());
+       if(m != "")
+       {
+               precache_model(m);
+               _setmodel(this, m); // no precision needed
        }
+       setorigin(this, this.origin);
+       if(this.scale)
+               setsize(this, this.mins * this.scale, this.maxs * this.scale);
+       else
+               setsize(this, this.mins, this.maxs);
 
-       WriteCoord(MSG_ENTITY, self.origin_x);
-       WriteCoord(MSG_ENTITY, self.origin_y);
-       WriteCoord(MSG_ENTITY, self.origin_z);
+       BITSET_ASSIGN(this.effects, EF_NODEPTHTEST);
+}
 
-       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);
+void trigger_link(entity this, bool(entity this, entity to, int sendflags) sendfunc)
+{
+       this.SendEntity = SendEntity_self;
+       this.SendEntity3 = sendfunc;
+       this.SendFlags = 0xFFFFFF;
+}
 
-       WriteCoord(MSG_ENTITY, self.movedir_x);
-       WriteCoord(MSG_ENTITY, self.movedir_y);
-       WriteCoord(MSG_ENTITY, self.movedir_z);
+void trigger_common_write(entity this, bool withtarget)
+{
+       int f = 0;
+       if(this.warpzone_isboxy)
+               BITSET_ASSIGN(f, 1);
+       if(this.origin != '0 0 0')
+               BITSET_ASSIGN(f, 4);
+       WriteByte(MSG_ENTITY, f);
 
-       WriteCoord(MSG_ENTITY, self.angles_x);
-       WriteCoord(MSG_ENTITY, self.angles_y);
-       WriteCoord(MSG_ENTITY, self.angles_z);
+       if(withtarget)
+       {
+               WriteString(MSG_ENTITY, this.target);
+               WriteString(MSG_ENTITY, this.target2);
+               WriteString(MSG_ENTITY, this.target3);
+               WriteString(MSG_ENTITY, this.target4);
+               WriteString(MSG_ENTITY, this.targetname);
+               WriteString(MSG_ENTITY, this.killtarget);
+       }
+
+       if(f & 4)
+       {
+               WriteCoord(MSG_ENTITY, this.origin.x);
+               WriteCoord(MSG_ENTITY, this.origin.y);
+               WriteCoord(MSG_ENTITY, this.origin.z);
+       }
+
+       WriteShort(MSG_ENTITY, this.modelindex);
+       WriteCoord(MSG_ENTITY, this.mins.x);
+       WriteCoord(MSG_ENTITY, this.mins.y);
+       WriteCoord(MSG_ENTITY, this.mins.z);
+       WriteCoord(MSG_ENTITY, this.maxs.x);
+       WriteCoord(MSG_ENTITY, this.maxs.y);
+       WriteCoord(MSG_ENTITY, this.maxs.z);
+       WriteByte(MSG_ENTITY, bound(1, this.scale * 16, 255));
+
+       WriteCoord(MSG_ENTITY, this.movedir_x);
+       WriteCoord(MSG_ENTITY, this.movedir_y);
+       WriteCoord(MSG_ENTITY, this.movedir_z);
+
+       WriteCoord(MSG_ENTITY, this.angles_x);
+       WriteCoord(MSG_ENTITY, this.angles_y);
+       WriteCoord(MSG_ENTITY, this.angles_z);
 }
 
 #elif defined(CSQC)
 
 void trigger_common_read(bool withtarget)
 {SELFPARAM();
-       self.warpzone_isboxy = ReadByte();
-       self.scale = ReadByte();
+       int f = ReadByte();
+       self.warpzone_isboxy = (f & 1);
 
        if(withtarget)
        {
@@ -79,17 +114,24 @@ void trigger_common_read(bool withtarget)
                self.killtarget = strzone(ReadString());
        }
 
-       self.origin_x = ReadCoord();
-       self.origin_y = ReadCoord();
-       self.origin_z = ReadCoord();
+       if(f & 4)
+       {
+               self.origin_x = ReadCoord();
+               self.origin_y = ReadCoord();
+               self.origin_z = ReadCoord();
+       }
+       else
+               self.origin = '0 0 0';
        setorigin(self, self.origin);
 
+       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;
        setsize(self, self.mins, self.maxs);
 
        self.movedir_x = ReadCoord();
index c8e593f9cb53666eb6418b2d18033b7dac31783b..31b8be4416b83f7beb86644549b66197bca4628a 100644 (file)
@@ -22,7 +22,7 @@ const float   SPAWNFLAG_NOTOUCH = 1;
 
 // used elsewhere (will fix)
 #ifdef SVQC
-void trigger_common_write(bool withtarget);
+void trigger_common_write(entity this, bool withtarget);
 
 string trigger_magicear_processmessage_forallears(entity source, float teamsay, entity privatesay, string msgin);