From 91b95cce8b2100b35357780d0db55b05bcbb0a84 Mon Sep 17 00:00:00 2001 From: terencehill Date: Sun, 6 Mar 2022 17:20:22 +0100 Subject: [PATCH] Fix powerup sound not stopped on disconnection and becoming observer --- .../mutator/status_effects/sv_status_effects.qc | 10 ++++++++++ qcsrc/server/client.qc | 9 ++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/qcsrc/common/mutators/mutator/status_effects/sv_status_effects.qc b/qcsrc/common/mutators/mutator/status_effects/sv_status_effects.qc index 90fda09cb..9d97e94b6 100644 --- a/qcsrc/common/mutators/mutator/status_effects/sv_status_effects.qc +++ b/qcsrc/common/mutators/mutator/status_effects/sv_status_effects.qc @@ -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); }); diff --git a/qcsrc/server/client.qc b/qcsrc/server/client.qc index aeb392c60..8ae3df193 100644 --- a/qcsrc/server/client.qc +++ b/qcsrc/server/client.qc @@ -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)); } } -- 2.39.2