fix(audio): portal cues fire on the sequencer's sound events, not the tunnel visuals

Slice A4 hung UI_EnterPortal on TeleportAnimEvent.EnterTunnel — the first
tunnel-family frame — so the cue landed a whole TunnelFadeIn after retail
plays it. Retail's site is gmSmartBoxUI::BeginTeleportAnimation
@0x004D638E, i.e. Begin(), which the sequencer already marks as
TeleportAnimEvent.PlayEnterSound.

That event has existed since the R6 portal-space work, complete with a
'Begin(): sound_ui_enter_portal' comment, and no consumer has ever
handled it — the switch in LocalPlayerTeleportController had cases for
Place, EnterTunnel, PlayExitSound and FireLoginComplete only, so the
sequencer emitted PlayEnterSound into nothing. A4 filled the gap in the
wrong place rather than filling it.

Both cues now go through named presentation methods driven by the
matching events: PlayEnterCue on PlayEnterSound, PlayExitCue on
PlayExitSound (the TunnelFadeOut -> WorldFadeIn edge, @0x004D7405, the
same tick the world viewport is revealed). EnterTunnel/ExitTunnel are
visuals again. The exit cue was already firing at the right moment, since
ExitTunnel was called from inside the PlayExitSound case — correct by
accident, explicit now.

Found by the user asking when the recall cues play.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Erik 2026-08-09 08:22:48 +02:00
parent aa82ff7bf1
commit 2914e43aa9
3 changed files with 73 additions and 10 deletions

View file

@ -309,6 +309,8 @@ internal interface ILocalPlayerTeleportPresentation : IDisposable
(TeleportAnimSnapshot Snapshot, IReadOnlyList<TeleportAnimEvent> Events)
Tick(float deltaSeconds, bool worldReady);
void TickTunnel(float deltaSeconds);
void PlayEnterCue();
void PlayExitCue();
void EnterTunnel();
void ExitTunnel();
void SetWaitCue(bool visible);
@ -360,17 +362,26 @@ internal sealed class LocalPlayerTeleportPresentation
/// </summary>
public Action<SoundId>? UiSoundSink { get; set; }
public void EnterTunnel()
{
_tunnel.Enter();
UiSoundSink?.Invoke(SoundId.UI_EnterPortal);
}
/// <summary>
/// <c>Sound_UI_EnterPortal</c>, at retail's moment: the START of the
/// teleport animation (<c>gmSmartBoxUI::BeginTeleportAnimation</c> @
/// <c>0x004D638E</c>), which the sequencer marks as
/// <c>TeleportAnimEvent.PlayEnterSound</c> — NOT when the tunnel viewport
/// first appears, which is a TunnelFadeIn later.
/// </summary>
public void PlayEnterCue() => UiSoundSink?.Invoke(SoundId.UI_EnterPortal);
public void ExitTunnel()
{
_tunnel.Exit();
UiSoundSink?.Invoke(SoundId.UI_ExitPortal);
}
/// <summary>
/// <c>Sound_UI_ExitPortal</c> @ <c>0x004D7405</c>, at the
/// TunnelFadeOut to WorldFadeIn edge — the sequencer's
/// <c>TeleportAnimEvent.PlayExitSound</c>, the same tick the world viewport
/// is revealed.
/// </summary>
public void PlayExitCue() => UiSoundSink?.Invoke(SoundId.UI_ExitPortal);
public void EnterTunnel() => _tunnel.Enter();
public void ExitTunnel() => _tunnel.Exit();
public void SetWaitCue(bool visible) => _tunnel.SetWaitCue(visible);
public void Reset()
@ -601,6 +612,14 @@ internal sealed class LocalPlayerTeleportController
if (!IsCurrentLifetime(generation, sequence))
return;
break;
case TeleportAnimEvent.PlayEnterSound:
// Retail plays the enter cue as the animation BEGINS, before
// the tunnel is visible. The sequencer has always emitted
// this event; nothing consumed it until Campaign A.
_presentation.PlayEnterCue();
if (!IsCurrentLifetime(generation, sequence))
return;
break;
case TeleportAnimEvent.EnterTunnel:
_presentation.EnterTunnel();
if (!IsCurrentLifetime(generation, sequence))
@ -611,6 +630,9 @@ internal sealed class LocalPlayerTeleportController
// cell blocking at the exact portal/world viewport swap.
// LoginComplete remains one WorldFadeIn second later.
_worldReveal.RevealWorldViewport();
if (!IsCurrentLifetime(generation, sequence))
return;
_presentation.PlayExitCue();
if (!IsCurrentLifetime(generation, sequence))
return;
_presentation.ExitTunnel();