From: Freddy Date: Sun, 4 Mar 2018 17:21:58 +0000 (+0100) Subject: Remove magic numbers from platforms (func_plat) X-Git-Tag: xonotic-v0.8.5~2176^2~52 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=0369f8def4b07e7254f98c316963d819c200ae86;p=xonotic%2Fxonotic-data.pk3dir.git Remove magic numbers from platforms (func_plat) --- diff --git a/qcsrc/common/triggers/func/plat.qc b/qcsrc/common/triggers/func/plat.qc index 9f97a1cea..d3f9587b8 100644 --- a/qcsrc/common/triggers/func/plat.qc +++ b/qcsrc/common/triggers/func/plat.qc @@ -60,7 +60,10 @@ spawnfunc(func_plat) { if (this.sounds == 0) this.sounds = 2; - if (this.spawnflags & 4) this.dmg = 10000; + if (this.spawnflags & PLAT_CRUSH) + { + this.dmg = 10000; + } if (this.dmg && (this.message == "")) this.message = "was squished"; if (this.dmg && (this.message2 == "")) this.message2 = "was squished by"; diff --git a/qcsrc/common/triggers/platforms.qc b/qcsrc/common/triggers/platforms.qc index 8ea48275d..83664cc44 100644 --- a/qcsrc/common/triggers/platforms.qc +++ b/qcsrc/common/triggers/platforms.qc @@ -61,7 +61,7 @@ void plat_spawn_inside_trigger(entity this) void plat_hit_top(entity this) { _sound (this, CH_TRIGGER_SINGLE, this.noise1, VOL_BASE, ATTEN_NORM); - this.state = 1; + this.state = STATE_TOP; setthink(this, plat_go_down); this.nextthink = this.ltime + 3; @@ -70,20 +70,20 @@ void plat_hit_top(entity this) void plat_hit_bottom(entity this) { _sound (this, CH_TRIGGER_SINGLE, this.noise1, VOL_BASE, ATTEN_NORM); - this.state = 2; + this.state = STATE_BOTTOM; } void plat_go_down(entity this) { _sound (this, CH_TRIGGER_SINGLE, this.noise, VOL_BASE, ATTEN_NORM); - this.state = 3; + this.state = STATE_DOWN; SUB_CalcMove (this, this.pos2, TSPEED_LINEAR, this.speed, plat_hit_bottom); } void plat_go_up(entity this) { _sound (this, CH_TRIGGER_SINGLE, this.noise, VOL_BASE, ATTEN_NORM); - this.state = 4; + this.state = STATE_UP; SUB_CalcMove (this, this.pos1, TSPEED_LINEAR, this.speed, plat_hit_top); } @@ -102,9 +102,9 @@ void plat_center_touch(entity this, entity toucher) return; #endif - if (this.enemy.state == 2) { + if (this.enemy.state == STATE_BOTTOM) { plat_go_up(this.enemy); - } else if (this.enemy.state == 1) + } else if (this.enemy.state == STATE_TOP) this.enemy.nextthink = this.enemy.ltime + 1; } @@ -121,7 +121,7 @@ void plat_outside_touch(entity this, entity toucher) return; #endif - if (this.enemy.state == 1) { + if (this.enemy.state == STATE_TOP) { entity e = this.enemy; plat_go_down(e); } @@ -137,7 +137,7 @@ void plat_trigger_use(entity this, entity actor, entity trigger) void plat_crush(entity this, entity blocker) { - if((this.spawnflags & 4) && (blocker.takedamage != DAMAGE_NO)) + if((this.spawnflags & PLAT_CRUSH) && (blocker.takedamage != DAMAGE_NO)) { // KIll Kill Kill!! #ifdef SVQC Damage (blocker, this, this, 10000, DEATH_HURTTRIGGER.m_id, DMG_NOWEP, blocker.origin, '0 0 0'); @@ -155,9 +155,9 @@ void plat_crush(entity this, entity blocker) } #endif - if (this.state == 4) + if (this.state == STATE_UP) plat_go_down (this); - else if (this.state == 3) + else if (this.state == STATE_DOWN) plat_go_up (this); // when in other states, then the plat_crush event came delayed after // plat state already had changed @@ -168,7 +168,7 @@ void plat_crush(entity this, entity blocker) void plat_use(entity this, entity actor, entity trigger) { this.use = func_null; - if (this.state != 4) + if (this.state != STATE_UP) objerror (this, "plat_use: not in up state"); plat_go_down(this); } @@ -180,13 +180,13 @@ void plat_reset(entity this) IFTARGETED { setorigin(this, this.pos1); - this.state = 4; + this.state = STATE_UP; this.use = plat_use; } else { setorigin(this, this.pos2); - this.state = 2; + this.state = STATE_BOTTOM; this.use = plat_trigger_use; } diff --git a/qcsrc/common/triggers/platforms.qh b/qcsrc/common/triggers/platforms.qh index c40467494..72e17cd9e 100644 --- a/qcsrc/common/triggers/platforms.qh +++ b/qcsrc/common/triggers/platforms.qh @@ -10,4 +10,6 @@ void plat_go_down(entity this); void plat_crush(entity this, entity blocker); const float PLAT_LOW_TRIGGER = 1; +const int PLAT_CRUSH = BIT(2); + .float dmg; diff --git a/qcsrc/common/triggers/subs.qh b/qcsrc/common/triggers/subs.qh index 1b3bc5e69..04b9ecd0d 100644 --- a/qcsrc/common/triggers/subs.qh +++ b/qcsrc/common/triggers/subs.qh @@ -44,14 +44,14 @@ void SUB_VanishOrRemove (entity ent); #ifdef CSQC // this stuff is defined in the server side engine VM, so we must define it separately here .float takedamage; -const float DAMAGE_NO = 0; -const float DAMAGE_YES = 1; -const float DAMAGE_AIM = 2; - -float STATE_TOP = 0; -float STATE_BOTTOM = 1; -float STATE_UP = 2; -float STATE_DOWN = 3; +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