]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Fix powerup sound not stopped on disconnection and becoming observer
authorterencehill <piuntn@gmail.com>
Sun, 6 Mar 2022 16:20:22 +0000 (17:20 +0100)
committerterencehill <piuntn@gmail.com>
Sun, 6 Mar 2022 16:20:22 +0000 (17:20 +0100)
qcsrc/common/mutators/mutator/status_effects/sv_status_effects.qc
qcsrc/server/client.qc

index 90fda09cb47a52f7fe0c767c2072bc41d43be305..9d97e94b697ebe918f8aaaa12a2aa9099983e4f6 100644 (file)
@@ -70,11 +70,20 @@ MUTATOR_HOOKFUNCTION(status_effects, PlayerDies)
        StatusEffects_removeall(frag_target, STATUSEFFECT_REMOVE_NORMAL);
 }
 
+MUTATOR_HOOKFUNCTION(status_effects, ClientDisconnect)
+{
+       entity player = M_ARGV(0, entity);
+
+       StatusEffects_removeall(player, STATUSEFFECT_REMOVE_NORMAL); // just to get rid of the pickup sound
+       return true;
+}
+
 MUTATOR_HOOKFUNCTION(status_effects, MakePlayerObserver)
 {
        entity player = M_ARGV(0, entity);
 
        // no need to network updates, as there is no statuseffects object attached
+       StatusEffects_removeall(player, STATUSEFFECT_REMOVE_NORMAL); // just to get rid of the pickup sound
        StatusEffects_clearall(player.statuseffects_store);
 
        // don't delete spectatee's effects!
@@ -86,6 +95,7 @@ MUTATOR_HOOKFUNCTION(status_effects, reset_map_global)
 {
        FOREACH_CLIENT(IS_PLAYER(it) && it.statuseffects,
        {
+               StatusEffects_removeall(it, STATUSEFFECT_REMOVE_NORMAL); // just to get rid of the pickup sound
                StatusEffects_clearall(it.statuseffects);
                StatusEffects_update(it);
        });
index aeb392c606483d8ee6da5e4ce02265ca4c0225a9..8ae3df19380ab918478f3514035d0e0fc9a970c7 100644 (file)
@@ -361,6 +361,7 @@ void PutObserverInServer(entity this, bool is_forced, bool use_spawnpoint)
        this.revival_time = 0;
        this.draggable = drag_undraggable;
 
+       player_powerups_remove_all(this);
        this.items = 0;
        STAT(WEAPONS, this) = '0 0 0';
        this.drawonlytoclient = this;
@@ -1452,15 +1453,17 @@ void play_countdown(entity this, float finished, Sound samp)
                                sound (this, CH_INFO, samp, VOL_BASE, ATTEN_NORM);
 }
 
+// it removes special powerups not handled by StatusEffects
 void player_powerups_remove_all(entity this)
 {
-       if (this.items & IT_SUPERWEAPON)
+       if (this.items & (IT_SUPERWEAPON | IT_UNLIMITED_AMMO | IT_UNLIMITED_SUPERWEAPONS))
        {
                // don't play the poweroff sound when the game restarts or the player disconnects
                if (time > game_starttime + 1 && IS_CLIENT(this))
                        sound(this, CH_INFO, SND_POWEROFF, VOL_BASE, ATTEN_NORM);
-               stopsound(this, CH_TRIGGER_SINGLE); // get rid of the pickup sound
-               this.items -= (this.items & IT_SUPERWEAPON);
+               if (this.items & (IT_UNLIMITED_AMMO | IT_UNLIMITED_SUPERWEAPONS))
+                       stopsound(this, CH_TRIGGER_SINGLE); // get rid of the pickup sound
+               this.items -= (this.items & (IT_SUPERWEAPON | IT_UNLIMITED_AMMO | IT_UNLIMITED_SUPERWEAPONS));
        }
 }