]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Common file for trigger/func states, replace more magic numbers
authorFreddy <schro.sb@gmail.com>
Tue, 6 Mar 2018 23:00:24 +0000 (00:00 +0100)
committerFreddy <schro.sb@gmail.com>
Tue, 6 Mar 2018 23:00:24 +0000 (00:00 +0100)
qcsrc/common/triggers/func/breakable.qh
qcsrc/common/triggers/func/button.qc
qcsrc/common/triggers/func/button.qh
qcsrc/common/triggers/func/conveyor.qc
qcsrc/common/triggers/func/conveyor.qh
qcsrc/common/triggers/spawnflags.qh
qcsrc/common/triggers/states.qh [new file with mode: 0644]
qcsrc/common/triggers/subs.qh

index 9a51be8c66de025f007d5d98916ac1d30f3ae961..9b16355ddd4e1015f0dd86fac9b384a44ed9abe0 100644 (file)
@@ -1,10 +1,8 @@
 #pragma once
 #include "../spawnflags.qh"
+#include "../states.qh"
 
 
-const int STATE_ALIVE = 0;
-const int STATE_BROKEN = 1;
-
 #ifdef SVQC
 spawnfunc(func_breakable);
 #endif
index fd113205f0e49627d57306ea92f6457a1a96d592..28e6481c880886c18d240fc3cc55719eb80668d6 100644 (file)
@@ -1,5 +1,4 @@
 #include "button.qh"
-#include "../spawnflags.qh"
 #ifdef SVQC
 // button and multiple button
 
index 6f70f09beec2219624baeca92e2cd7deaa104fb4..7c39519e10e9f29d62f38ee0bc76f0dd4b0ed584 100644 (file)
@@ -1 +1,2 @@
 #pragma once
+#include "../spawnflags.qh"
index 1802a75db4a96a74ab2b56eb9531a748923bfa91..375a6adb867bca7c02d800a7a26c05b43548b31d 100644 (file)
@@ -67,22 +67,25 @@ void conveyor_use(entity this, entity actor, entity trigger)
 {
        this.state = !this.state;
 
-       this.SendFlags |= 2;
+       this.SendFlags |= SF_TRIGGER_UPDATE;
 }
 
 void conveyor_reset(entity this)
 {
-       this.state = (this.spawnflags & 1);
+       if(this.spawnflags & CONVEYOR_START_ENABLED)
+       {
+               this.state = STATE_ON;
+       }
 
-       this.SendFlags |= 2;
+       this.SendFlags |= SF_TRIGGER_UPDATE;
 }
 
-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);
                WriteVector(MSG_ENTITY, this.origin);
@@ -99,7 +102,7 @@ bool conveyor_send(entity this, entity to, int sf)
                WriteString(MSG_ENTITY, this.target);
        }
 
-       if(sf & 2)
+       if(sendflags & SF_TRIGGER_UPDATE)
                WriteByte(MSG_ENTITY, this.state);
 
        return true;
@@ -118,13 +121,13 @@ void conveyor_init(entity this)
                this.reset(this);
        }
        else
-               this.state = 1;
+               this.state = STATE_ON;
 
        FixSize(this);
 
        Net_LinkEntity(this, 0, false, conveyor_send);
 
-       this.SendFlags |= 1;
+       this.SendFlags |= SF_TRIGGER_INIT;
 }
 
 spawnfunc(trigger_conveyor)
@@ -161,9 +164,9 @@ 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 = ReadVector();
@@ -184,7 +187,7 @@ NET_HANDLE(ENT_CLIENT_CONVEYOR, bool isnew)
                conveyor_init(this, isnew);
        }
 
-       if(sf & 2)
+       if(sendflags & SF_TRIGGER_UPDATE)
                this.state = ReadByte();
 
        return true;
index c12b52d2dd19118e4d0a7209329796446922cbeb..20b790f4a17fbf05f35b420a570a38584bd268d1 100644 (file)
@@ -1,4 +1,6 @@
 #pragma once
+#include "../spawnflags.qh"
+#include "../states.qh"
 
 IntrusiveList g_conveyed;
 STATIC_INIT(g_conveyed) { g_conveyed = IL_NEW(); }
index 8712e71107ee3b83307c6b5dd2166dc1c9d97899..b2e397d1b75dd07fdd1d8fd54a897f2665be4d2c 100644 (file)
@@ -15,6 +15,9 @@ const int BREAKABLE_NODAMAGE = BIT(2);
 // button
 const int BUTTON_DONTACCUMULATEDMG = BIT(7);
 
+// conveyor
+const int CONVEYOR_START_ENABLED = BIT(0);
+
 // door, door_rotating and door_secret
 const int DOOR_START_OPEN = BIT(0);
 const int DOOR_DONT_LINK = BIT(2);
diff --git a/qcsrc/common/triggers/states.qh b/qcsrc/common/triggers/states.qh
new file mode 100644 (file)
index 0000000..ace3de8
--- /dev/null
@@ -0,0 +1,17 @@
+#pragma once
+
+#ifdef CSQC
+// this stuff is defined in the server side engine VM, so we must define it separately here
+const int STATE_TOP = 0;
+const int STATE_BOTTOM = 1;
+const int STATE_UP = 2;
+const int STATE_DOWN = 3;
+#endif
+
+// generic
+const int STATE_OFF = 0;
+const int STATE_ON = 1;
+
+// breakable
+const int STATE_ALIVE = 0;
+const int STATE_BROKEN = 1;
index d2d36a8d16c5058711850a15754f82735f8cc018..d8d926c80dd51b296990a77cf2a675817e526b72 100644 (file)
@@ -1,4 +1,5 @@
 #pragma once
+#include "states.qh"
 
 void SUB_SetFade (entity ent, float when, float fading_time);
 void SUB_VanishOrRemove (entity ent);
@@ -50,11 +51,6 @@ const int DAMAGE_NO = 0;
 const int DAMAGE_YES = 1;
 const int DAMAGE_AIM = 2;
 
-const int STATE_TOP = 0;
-const int STATE_BOTTOM = 1;
-const int STATE_UP = 2;
-const int STATE_DOWN = 3;
-
 .string                noise, noise1, noise2, noise3;  // contains names of wavs to play
 
 .float         max_health;             // players maximum health is stored here