From d41d90d8b3bd8ebbede2c34a7a3bd8cb0c7c6152 Mon Sep 17 00:00:00 2001 From: BjossiAlfreds Date: Thu, 29 Apr 2021 21:43:32 +0000 Subject: [PATCH] Fix for some player sound bugs --- src/game/header/local.h | 2 +- src/game/player/client.c | 13 ++++++++----- src/game/player/view.c | 20 +++++++++++++++++--- 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/src/game/header/local.h b/src/game/header/local.h index 861fae0c..e82c2182 100644 --- a/src/game/header/local.h +++ b/src/game/header/local.h @@ -1048,7 +1048,7 @@ struct edict_s int dmg; int radius_dmg; float dmg_radius; - int sounds; /* make this a spawntemp var? */ + int sounds; /* now also used for player death sound aggregation */ int count; edict_t *chain; diff --git a/src/game/player/client.c b/src/game/player/client.c index d8606015..6c74185e 100644 --- a/src/game/player/client.c +++ b/src/game/player/client.c @@ -908,9 +908,8 @@ player_die(edict_t *self, edict_t *inflictor, edict_t *attacker, if (self->health < -40) { - /* gib */ - gi.sound(self, CHAN_BODY, gi.soundindex( - "misc/udeath.wav"), 1, ATTN_NORM, 0); + /* gib (sound is played at end of server frame) */ + self->sounds = gi.soundindex("misc/udeath.wav"); for (n = 0; n < 4; n++) { @@ -958,8 +957,12 @@ player_die(edict_t *self, edict_t *inflictor, edict_t *attacker, } } - gi.sound(self, CHAN_VOICE, gi.soundindex(va("*death%i.wav", - (randk() % 4) + 1)), 1, ATTN_NORM, 0); + /* sound is played at end of server frame */ + if (!self->sounds) + { + self->sounds = gi.soundindex(va("*death%i.wav", + (randk() % 4) + 1)); + } } } diff --git a/src/game/player/view.c b/src/game/player/view.c index c1bebea3..399b75f5 100644 --- a/src/game/player/view.c +++ b/src/game/player/view.c @@ -82,6 +82,13 @@ P_DamageFeedback(edict_t *player) return; } + /* death/gib sound is now aggregated and played here */ + if (player->sounds) + { + gi.sound (player, CHAN_VOICE, player->sounds, 1, ATTN_NORM, 0); + player->sounds = 0; + } + client = player->client; /* flash the backgrounds behind the status numbers */ @@ -151,7 +158,8 @@ P_DamageFeedback(edict_t *player) /* play an apropriate pain sound */ if ((level.time > player->pain_debounce_time) && !(player->flags & FL_GODMODE) && - (client->invincible_framenum <= level.framenum)) + (client->invincible_framenum <= level.framenum) && + player->health > 0) { r = 1 + (randk() & 1); player->pain_debounce_time = level.time + 0.7; @@ -908,7 +916,8 @@ P_WorldEffects(void) { if ((current_player->health > 0) && (current_player->pain_debounce_time <= level.time) && - (current_client->invincible_framenum < level.framenum)) + (current_client->invincible_framenum < level.framenum) && + !(current_player->flags & FL_GODMODE)) { if (randk() & 1) { @@ -1026,6 +1035,11 @@ G_SetClientEvent(edict_t *ent) return; } + if (ent->health <= 0) + { + return; + } + if (g_footsteps->value == 1) { if (ent->groundentity && (xyspeed > 225)) @@ -1036,7 +1050,7 @@ G_SetClientEvent(edict_t *ent) } } } - if (g_footsteps->value == 2) + else if (g_footsteps->value == 2) { if ((int)(current_client->bobtime + bobmove) != bobcycle) {