From a9be46cec90c47bc04c66b82185bcbd024f5bc74 Mon Sep 17 00:00:00 2001 From: Freddy Date: Fri, 9 Mar 2018 18:39:09 +0100 Subject: [PATCH] Replace magic numbers in func_train --- qcsrc/common/triggers/func/train.qc | 14 +++++++------- qcsrc/common/triggers/func/train.qh | 1 + qcsrc/common/triggers/spawnflags.qh | 5 +++++ 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/qcsrc/common/triggers/func/train.qc b/qcsrc/common/triggers/func/train.qc index ead086708..4e9c33456 100644 --- a/qcsrc/common/triggers/func/train.qc +++ b/qcsrc/common/triggers/func/train.qc @@ -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 diff --git a/qcsrc/common/triggers/func/train.qh b/qcsrc/common/triggers/func/train.qh index 8b6f7c02d..0a4605243 100644 --- a/qcsrc/common/triggers/func/train.qh +++ b/qcsrc/common/triggers/func/train.qh @@ -1,4 +1,5 @@ #pragma once +#include "../spawnflags.qh" #ifdef CSQC .float dmgtime; diff --git a/qcsrc/common/triggers/spawnflags.qh b/qcsrc/common/triggers/spawnflags.qh index 5a3e4b1f4..fb34b3f16 100644 --- a/qcsrc/common/triggers/spawnflags.qh +++ b/qcsrc/common/triggers/spawnflags.qh @@ -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? -- 2.39.2