]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
target_speaker: deprecate GLOBAL (BIT(2)) spawnflag, remove magic numbers
authorFreddy <schro.sb@gmail.com>
Sun, 11 Mar 2018 16:18:12 +0000 (17:18 +0100)
committerFreddy <schro.sb@gmail.com>
Sun, 11 Mar 2018 16:18:12 +0000 (17:18 +0100)
qcsrc/common/triggers/spawnflags.qh
qcsrc/common/triggers/target/speaker.qc

index b4a97de60c29dabae051548e70880b20c44b717a..6e213fa76d29a41fc07f1fef6f5ca7ee721e69f3 100644 (file)
@@ -84,6 +84,12 @@ const int PLAT_CRUSH = BIT(2);
 // changelevel
 const int CHANGELEVEL_MULTIPLAYER = BIT(1);
 
+// speaker
+const int SPEAKER_LOOPED_ON = BIT(0);
+const int SPEAKER_LOOPED_OFF = BIT(1);
+const int SPEAKER_GLOBAL = BIT(2); // legacy, set speaker atten to -1 instead
+const int SPEAKER_ACTIVATOR = BIT(3);
+
 // teleport
 const int TELEPORT_FLAG_SOUND = BIT(0);
 const int TELEPORT_FLAG_PARTICLES = BIT(1);
index af327b443bc21febb1c8494829bfd10e1fb4543a..11c9ad7baef1d7c682feae42db5fa9162325532a 100644 (file)
@@ -54,7 +54,7 @@ void target_speaker_use_on(entity this, entity actor, entity trigger)
        else
                snd = this.noise;
        _sound(this, CH_TRIGGER_SINGLE, snd, VOL_BASE * this.volume, this.atten);
-       if(this.spawnflags & 3)
+       if(this.spawnflags & (SPEAKER_LOOPED_ON + SPEAKER_LOOPED_OFF))
                this.use = target_speaker_use_off;
 }
 void target_speaker_use_off(entity this, entity actor, entity trigger)
@@ -64,12 +64,12 @@ void target_speaker_use_off(entity this, entity actor, entity trigger)
 }
 void target_speaker_reset(entity this)
 {
-       if(this.spawnflags & 1) // LOOPED_ON
+       if(this.spawnflags & SPEAKER_LOOPED_ON)
        {
                if(this.use == target_speaker_use_on)
                        target_speaker_use_on(this, NULL, NULL);
        }
-       else if(this.spawnflags & 2)
+       else if(this.spawnflags & SPEAKER_LOOPED_OFF)
        {
                if(this.use == target_speaker_use_off)
                        target_speaker_use_off(this, NULL, NULL);
@@ -83,7 +83,13 @@ spawnfunc(target_speaker)
        if(this.noise)
                precache_sound (this.noise);
 
-       if(!this.atten && !(this.spawnflags & 4))
+       if(!this.atten && (this.spawnflags & SPEAKER_GLOBAL))
+       {
+               LOG_WARN("target_speaker uses legacy spawnflag GLOBAL (BIT(2)), please set atten to -1 instead");
+               this.atten = -1;
+       }
+
+       if(!this.atten)
        {
                IFTARGETED
                        this.atten = ATTEN_NORM;
@@ -98,14 +104,14 @@ spawnfunc(target_speaker)
 
        IFTARGETED
        {
-               if(this.spawnflags & 8) // ACTIVATOR
+               if(this.spawnflags & SPEAKER_ACTIVATOR)
                        this.use = target_speaker_use_activator;
-               else if(this.spawnflags & 1) // LOOPED_ON
+               else if(this.spawnflags & SPEAKER_LOOPED_ON)
                {
                        target_speaker_use_on(this, NULL, NULL);
                        this.reset = target_speaker_reset;
                }
-               else if(this.spawnflags & 2) // LOOPED_OFF
+               else if(this.spawnflags & SPEAKER_LOOPED_OFF)
                {
                        this.use = target_speaker_use_on;
                        this.reset = target_speaker_reset;
@@ -113,12 +119,12 @@ spawnfunc(target_speaker)
                else
                        this.use = target_speaker_use_on;
        }
-       else if(this.spawnflags & 1) // LOOPED_ON
+       else if(this.spawnflags & SPEAKER_LOOPED_ON)
        {
                ambientsound (this.origin, this.noise, VOL_BASE * this.volume, this.atten);
                delete(this);
        }
-       else if(this.spawnflags & 2) // LOOPED_OFF
+       else if(this.spawnflags & SPEAKER_LOOPED_OFF)
        {
                objerror(this, "This sound entity can never be activated");
        }