]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Remove magic numbers from platforms (func_plat)
authorFreddy <schro.sb@gmail.com>
Sun, 4 Mar 2018 17:21:58 +0000 (18:21 +0100)
committerFreddy <schro.sb@gmail.com>
Sun, 4 Mar 2018 17:21:58 +0000 (18:21 +0100)
qcsrc/common/triggers/func/plat.qc
qcsrc/common/triggers/platforms.qc
qcsrc/common/triggers/platforms.qh
qcsrc/common/triggers/subs.qh

index 9f97a1cea09b764d2021900fb011be0978254541..d3f9587b832c79284139bc90eea34f747a2e366d 100644 (file)
@@ -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";
index 8ea48275d36b8d0f5d5ce9c98aacdfdf1d2a746d..83664cc44fe704d2554d1f5589727008d29a7303 100644 (file)
@@ -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;
        }
 
index c40467494f367adf9c68af7390dbd55ee6ec120c..72e17cd9ecea712f811805e6c18e2faa8822e825 100644 (file)
@@ -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;
index 1b3bc5e690d438f6eeb1b0bf228eab6efd7ee75a..04b9ecd0d3782132dfcb837ae96193b0b1e5f75e 100644 (file)
@@ -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