]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Replace magic numbers in func_train
authorFreddy <schro.sb@gmail.com>
Fri, 9 Mar 2018 17:39:09 +0000 (18:39 +0100)
committerFreddy <schro.sb@gmail.com>
Fri, 9 Mar 2018 17:39:09 +0000 (18:39 +0100)
qcsrc/common/triggers/func/train.qc
qcsrc/common/triggers/func/train.qh
qcsrc/common/triggers/spawnflags.qh

index ead086708196889075c18ae958df185dccb02606..4e9c334562c97cc1bad305ccb2abf279a3d20fa4 100644 (file)
@@ -16,7 +16,7 @@ void train_wait(entity this)
                entity targ, cp;
                vector ang;
                targ = this.future_target;
-               if((this.spawnflags & 1) && targ.curvetarget)
+               if((this.spawnflags & TRAIN_CURVE) && targ.curvetarget)
                        cp = find(NULL, targetname, targ.curvetarget);
                else
                        cp = NULL;
@@ -43,7 +43,7 @@ void train_wait(entity this)
 
 #ifdef SVQC
        entity tg = this.future_target;
-       if(tg.spawnflags & 4)
+       if(tg.spawnflags & TRAIN_NEEDACTIVATION)
        {
                this.use = train_use;
                setthink(this, func_null);
@@ -91,7 +91,7 @@ void train_next(entity this)
        this.target_random = targ.target_random;
        this.future_target = train_next_find(targ);
 
-       if (this.spawnflags & 1)
+       if (this.spawnflags & TRAIN_CURVE)
        {
                if(targ.curvetarget)
                {
@@ -195,7 +195,7 @@ void train_use(entity this, entity actor, entity trigger)
 {
        this.nextthink = this.ltime + 1;
        setthink(this, train_next);
-       this.use = func_null; // not again
+       this.use = func_null; // not again, next target can set it again if needed
        if(trigger.target2 && trigger.target2 != "")
                this.future_target = find(NULL, targetname, trigger.target2);
 }
@@ -211,7 +211,7 @@ void func_train_find(entity this)
                objerror(this, "func_train_find: no next target");
        setorigin(this, targ.origin - this.view_ofs);
 
-       if(!(this.spawnflags & 4))
+       if(!(this.spawnflags & TRAIN_NEEDACTIVATION))
        {
                this.nextthink = this.ltime + 1;
                setthink(this, train_next);
@@ -242,10 +242,10 @@ spawnfunc(func_train)
                return;
        this.effects |= EF_LOWPRECISION;
 
-       if(this.spawnflags & 4)
+       if(this.spawnflags & TRAIN_NEEDACTIVATION)
                this.use = train_use;
 
-       if (this.spawnflags & 2)
+       if (this.spawnflags & TRAIN_TURN)
        {
                this.platmovetype_turn = true;
                this.view_ofs = '0 0 0'; // don't offset a rotating train, origin works differently now
index 8b6f7c02da22651e3f44884e76b9968d5a86c874..0a4605243af3810b642979903e119a3228a94b32 100644 (file)
@@ -1,4 +1,5 @@
 #pragma once
+#include "../spawnflags.qh"
 
 #ifdef CSQC
 .float dmgtime;
index 5a3e4b1f46d21be8bcbf612cd7fecaca8ba152b7..fb34b3f162f6c04e046b5e18295ffc0634adbb89 100644 (file)
@@ -47,6 +47,11 @@ const int FUNC_ROTATING_XAXIS = BIT(2);
 const int FUNC_ROTATING_YAXIS = BIT(3);
 const int FUNC_ROTATING_STARTOFF = BIT(4);
 
+// train
+const int TRAIN_CURVE = BIT(0);
+const int TRAIN_TURN = BIT(1);
+const int TRAIN_NEEDACTIVATION = BIT(2);
+
 // jumppads
 const int PUSH_ONCE = BIT(0);
 const int PUSH_SILENT = BIT(1); // not used?