- Duke: added emulation for a sound system bug that prevents certain duplicate sounds from playing.

Since our sound system does not reject this case, the calling code must check for the relevant condition.
This commit is contained in:
Christoph Oelckers 2022-10-01 12:59:43 +02:00
parent d1b4bef98d
commit 9627f00f32
2 changed files with 10 additions and 3 deletions

View file

@ -2603,7 +2603,7 @@ void handle_se00(DDukeActor* actor)
{
actor->tempang += 4;
if (actor->tempang >= 256)
callsound(actor->sector(), actor);
callsound(actor->sector(), actor, true);
if (actor->spr.clipdist) l = 1;
else l = -1;
}
@ -2631,7 +2631,7 @@ void handle_se00(DDukeActor* actor)
{
actor->tempang -= 4;
if (actor->tempang <= 0)
callsound(actor->sector(), actor);
callsound(actor->sector(), actor, true);
if (actor->spr.clipdist) l = -1;
else l = 1;
}

View file

@ -95,9 +95,16 @@ int callsound(sectortype* sn, DDukeActor* whatsprite, bool endstate)
}
else if (act->spr.hitag < 1000)
{
// The original code performed these two actions in reverse order which in case of a looped sound being stopped
// being the same as the sound about to be started, the newly started sound would fall through some cracks in the sound system and be rejected.
// Here this case needs to be simulated.
bool stopped = false;
if ((flags & SF_LOOP) || (act->spr.hitag && act->spr.hitag != act->spr.lotag))
{
S_StopSound(act->spr.lotag, act->temp_actor);
if (act->spr.hitag) S_PlayActorSound(act->spr.hitag, whatsprite);
if (act->spr.hitag == act->spr.lotag) stopped = true;
}
if (act->spr.hitag && !stopped) S_PlayActorSound(act->spr.hitag, whatsprite);
act->temp_data[0] = 0;
act->temp_actor = whatsprite;
}