]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Remove a few more magic numbers and minor code cleanup
authorFreddy <schro.sb@gmail.com>
Thu, 15 Mar 2018 23:30:31 +0000 (00:30 +0100)
committerFreddy <schro.sb@gmail.com>
Thu, 15 Mar 2018 23:30:31 +0000 (00:30 +0100)
qcsrc/common/triggers/spawnflags.qh
qcsrc/common/triggers/trigger/multivibrator.qc
qcsrc/common/triggers/trigger/relay.qc
qcsrc/common/triggers/trigger/relay_if.qc
qcsrc/common/triggers/trigger/relay_teamcheck.qc
qcsrc/common/triggers/trigger/teleport.qc
qcsrc/common/triggers/trigger/viewloc.qc

index 44d129d4e28a70fceada084e1da88281976aa023..02f80d6f08e41d4f6fb36388c10d44fe8ffb8a78 100644 (file)
@@ -131,6 +131,13 @@ const int MAGICEAR_TUBA_EXACTPITCH = BIT(9);
 // monoflop
 const int MONOFLOP_FIXED = BIT(0);
 
+// relay_if
+const int RELAYIF_NEGATE = BIT(0);
+
+// relay_teamcheck
+const int RELAYTEAMCHECK_NOTEAM = BIT(0);
+const int RELAYTEAMCHECK_INVERT = BIT(1);
+
 //----------
 // SENDFLAGS
 //----------
index d946efe5f17cc533c2b104b52fb1dc2c2e37ba82..932fda13ca94a5984f9e4d286848430147575158 100644 (file)
@@ -43,13 +43,13 @@ void multivibrator_toggle(entity this, entity actor, entity trigger)
 
 void multivibrator_reset(entity this)
 {
-       if(!(this.spawnflags & 1))
+       if(!(this.spawnflags & START_ENABLED))
                this.nextthink = 0; // wait for a trigger event
        else
                this.nextthink = max(1, time);
 }
 
-/*QUAKED trigger_multivibrator (.5 .5 .5) (-8 -8 -8) (8 8 8) START_ON
+/*QUAKED trigger_multivibrator (.5 .5 .5) (-8 -8 -8) (8 8 8) START_ENABLED
 "Multivibrator" trigger gate... repeatedly sends trigger events. When triggered, turns on or off.
 -------- KEYS --------
 target: trigger all entities with this targetname when it goes off
@@ -58,7 +58,7 @@ phase: offset of the timing
 wait: "on" cycle time (default: 1)
 respawntime: "off" cycle time (default: same as wait)
 -------- SPAWNFLAGS --------
-START_ON: assume it is already turned on (when targeted)
+START_ENABLED: assume it is already turned on (when targeted)
 */
 spawnfunc(trigger_multivibrator)
 {
index e5d0018032de0f67c63fc4ce91c5d5eaed56314a..f99d364aec5bdb560d9c1f51f5d92b3f8e77d714 100644 (file)
@@ -19,5 +19,8 @@ spawnfunc(trigger_relay)
        this.reset = spawnfunc_trigger_relay; // this spawnfunc resets fully
 }
 
-spawnfunc(target_relay) { spawnfunc_trigger_relay(this); }
+spawnfunc(target_relay)
+{
+       spawnfunc_trigger_relay(this);
+}
 #endif
index 728252c70400972a4259b3f49eea02c5100027d2..9adcd666ecc7ab3e73a8416ddfd118c869adce91 100644 (file)
@@ -6,7 +6,7 @@ void trigger_relay_if_use(entity this, entity actor, entity trigger)
 
        // TODO make this generic AND faster than nextent()ing through all, if somehow possible
        n = (cvar_string(this.netname) == cvar_string(this.message));
-       if(this.spawnflags & 1)
+       if(this.spawnflags & RELAYIF_NEGATE)
                n = !n;
 
        if(n)
index fee28df51af0842986aeed926ee23aad1744f933..bf03b1542f0f957279c80f8f81ed1dbb891c0eaa 100644 (file)
@@ -4,7 +4,7 @@ void trigger_relay_teamcheck_use(entity this, entity actor, entity trigger)
 {
        if(actor.team)
        {
-               if(this.spawnflags & 2)
+               if(this.spawnflags & RELAYTEAMCHECK_INVERT)
                {
                        if(DIFF_TEAM(actor, this))
                                SUB_UseTargets(this, actor, trigger);
@@ -17,7 +17,7 @@ void trigger_relay_teamcheck_use(entity this, entity actor, entity trigger)
        }
        else
        {
-               if(this.spawnflags & 1)
+               if(this.spawnflags & RELAYTEAMCHECK_NOTEAM)
                        SUB_UseTargets(this, actor, trigger);
        }
 }
index 0330ce8d8cc46b1e9065ff29065ff51f233dadfd..825dd01ddeea559ac5f52d8cbd944904f0a0f0f0 100644 (file)
@@ -36,7 +36,7 @@ bool Teleport_Active(entity this, entity player)
                return false;
 
        if(this.team)
-               if(((this.spawnflags & 4) == 0) == (DIFF_TEAM(this, player)))
+               if(((this.spawnflags & INVERT_TEAMS) == 0) == (DIFF_TEAM(this, player)))
                        return false;
 
        return true;
@@ -83,7 +83,10 @@ void target_teleport_use(entity this, entity actor, entity trigger)
 
        string s = this.target; this.target = string_null;
        SUB_UseTargets(this, player, player); // TODO: should we be using toucher for trigger too?
-       if (!this.target) this.target = s;
+       if (!this.target)
+       {
+               this.target = s;
+       }
 
        SUB_UseTargets(e, player, player);
 }
@@ -157,7 +160,11 @@ NET_HANDLE(ENT_CLIENT_TRIGGER_TELEPORT, bool isnew)
        this.classname = "trigger_teleport";
        if(isnew)
                IL_PUSH(g_teleporters, this);
-       int mytm = ReadByte(); if(mytm) { this.team = mytm - 1; }
+       int mytm = ReadByte();
+       if(mytm)
+       {
+               this.team = mytm - 1;
+       }
        this.spawnflags = ReadInt24_t();
        this.active = ReadByte();
        this.speed = ReadCoord();
index 8b985795da8b8701bb69239f52caa7629df156d9..ba5dcbe443ea4c26e955adfa68b9f997eb0f8d69 100644 (file)
@@ -154,7 +154,10 @@ spawnfunc(target_viewlocation_end)
 }
 
 // compatibility
-spawnfunc(target_viewlocation) { spawnfunc_target_viewlocation_start(this); }
+spawnfunc(target_viewlocation)
+{
+       spawnfunc_target_viewlocation_start(this);
+}
 
 #elif defined(CSQC)