]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/triggers/func/conveyor.qc
Explicitly check for ACTIVE_ACTIVE
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / triggers / func / conveyor.qc
index edd8eb9a27fc5a034f1766e49f6f9f9b05b6024d..4214a73239628f1a06a405cda73f7d094a18e4cd 100644 (file)
@@ -10,16 +10,16 @@ void conveyor_think(entity this)
        if(dt <= 0) { return; }
 #endif
 
-       // set mythis as current conveyor where possible
+       // set myself as current conveyor where possible
        IL_EACH(g_conveyed, it.conveyor == this,
        {
                it.conveyor = NULL;
                IL_REMOVE(g_conveyed, it);
        });
 
-       if(this.state)
+       if(this.active == ACTIVE_ACTIVE)
        {
-               FOREACH_ENTITY_RADIUS((this.absmin + this.absmax) * 0.5, vlen(this.absmax - this.absmin) * 0.5 + 1, !it.conveyor.state && isPushable(it),
+               FOREACH_ENTITY_RADIUS((this.absmin + this.absmax) * 0.5, vlen(this.absmax - this.absmin) * 0.5 + 1, !it.conveyor.active && isPushable(it),
                {
                        vector emin = it.absmin;
                        vector emax = it.absmax;
@@ -63,52 +63,30 @@ void conveyor_think(entity this)
 
 #ifdef SVQC
 
-void conveyor_use(entity this, entity actor, entity trigger)
-{
-       this.state = !this.state;
-
-       this.SendFlags |= 2;
-}
-
-void conveyor_reset(entity this)
-{
-       this.state = (this.spawnflags & 1);
-
-       this.SendFlags |= 2;
-}
-
-bool conveyor_send(entity this, entity to, int sf)
+bool conveyor_send(entity this, entity to, int sendflags)
 {
        WriteHeader(MSG_ENTITY, ENT_CLIENT_CONVEYOR);
-       WriteByte(MSG_ENTITY, sf);
+       WriteByte(MSG_ENTITY, sendflags);
 
-       if(sf & 1)
+       if(sendflags & SF_TRIGGER_INIT)
        {
                WriteByte(MSG_ENTITY, this.warpzone_isboxy);
-               WriteCoord(MSG_ENTITY, this.origin_x);
-               WriteCoord(MSG_ENTITY, this.origin_y);
-               WriteCoord(MSG_ENTITY, this.origin_z);
+               WriteVector(MSG_ENTITY, this.origin);
 
-               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);
+               WriteVector(MSG_ENTITY, this.mins);
+               WriteVector(MSG_ENTITY, this.maxs);
 
-               WriteCoord(MSG_ENTITY, this.movedir_x);
-               WriteCoord(MSG_ENTITY, this.movedir_y);
-               WriteCoord(MSG_ENTITY, this.movedir_z);
+               WriteVector(MSG_ENTITY, this.movedir);
 
                WriteByte(MSG_ENTITY, this.speed);
-               WriteByte(MSG_ENTITY, this.state);
+               WriteByte(MSG_ENTITY, this.active);
 
                WriteString(MSG_ENTITY, this.targetname);
                WriteString(MSG_ENTITY, this.target);
        }
 
-       if(sf & 2)
-               WriteByte(MSG_ENTITY, this.state);
+       if(sendflags & SF_TRIGGER_UPDATE)
+               WriteByte(MSG_ENTITY, this.active);
 
        return true;
 }
@@ -119,20 +97,20 @@ void conveyor_init(entity this)
        this.movedir *= this.speed;
        setthink(this, conveyor_think);
        this.nextthink = time;
+       this.setactive = generic_netlinked_setactive;
        IFTARGETED
        {
-               this.use = conveyor_use;
-               this.reset = conveyor_reset;
-               this.reset(this);
+               // backwards compatibility
+               this.use = generic_netlinked_legacy_use;
        }
-       else
-               this.state = 1;
+       this.reset = generic_netlinked_reset;
+       this.reset(this);
 
        FixSize(this);
 
        Net_LinkEntity(this, 0, false, conveyor_send);
 
-       this.SendFlags |= 1;
+       this.SendFlags |= SF_TRIGGER_INIT;
 }
 
 spawnfunc(trigger_conveyor)
@@ -169,30 +147,22 @@ void conveyor_init(entity this, bool isnew)
 
 NET_HANDLE(ENT_CLIENT_CONVEYOR, bool isnew)
 {
-       int sf = ReadByte();
+       int sendflags = ReadByte();
 
-       if(sf & 1)
+       if(sendflags & SF_TRIGGER_INIT)
        {
                this.warpzone_isboxy = ReadByte();
-               this.origin_x = ReadCoord();
-               this.origin_y = ReadCoord();
-               this.origin_z = ReadCoord();
+               this.origin = ReadVector();
                setorigin(this, this.origin);
 
-               this.mins_x = ReadCoord();
-               this.mins_y = ReadCoord();
-               this.mins_z = ReadCoord();
-               this.maxs_x = ReadCoord();
-               this.maxs_y = ReadCoord();
-               this.maxs_z = ReadCoord();
+               this.mins = ReadVector();
+               this.maxs = ReadVector();
                setsize(this, this.mins, this.maxs);
 
-               this.movedir_x = ReadCoord();
-               this.movedir_y = ReadCoord();
-               this.movedir_z = ReadCoord();
+               this.movedir = ReadVector();
 
                this.speed = ReadByte();
-               this.state = ReadByte();
+               this.active = ReadByte();
 
                this.targetname = strzone(ReadString());
                this.target = strzone(ReadString());
@@ -200,8 +170,8 @@ NET_HANDLE(ENT_CLIENT_CONVEYOR, bool isnew)
                conveyor_init(this, isnew);
        }
 
-       if(sf & 2)
-               this.state = ReadByte();
+       if(sendflags & SF_TRIGGER_UPDATE)
+               this.active = ReadByte();
 
        return true;
 }