From 2f3abfdae3af4d2fb20d30d00b06bc9273d9d52e Mon Sep 17 00:00:00 2001 From: VariableVince <24507472+VariableVince@users.noreply.github.com> Date: Sat, 23 May 2026 22:56:22 +0200 Subject: [PATCH] Don't early return if no myPlayer, so we can still play nuke sounds in a replay (and possibly others in the future that are not local-player bound) --- src/client/controllers/SoundController.ts | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/client/controllers/SoundController.ts b/src/client/controllers/SoundController.ts index fcd773608..2d66f570d 100644 --- a/src/client/controllers/SoundController.ts +++ b/src/client/controllers/SoundController.ts @@ -28,19 +28,22 @@ export class SoundController implements Controller { if ((gu.pendingTurns ?? 0) > 1 || this.view.ticks() <= 0) return; const myPlayer = this.view.myPlayer(); - if (!myPlayer) return; // 1. Process Conquests - gu.updates[GameUpdateType.ConquestEvent]?.forEach((cu: ConquestUpdate) => { - if (cu.conquerorId === myPlayer.id()) { - this.eventBus.emit(new PlaySoundEffectEvent(SoundEffect.KaChing)); - } - }); + if (myPlayer) { + gu.updates[GameUpdateType.ConquestEvent]?.forEach( + (cu: ConquestUpdate) => { + if (cu.conquerorId === myPlayer.id()) { + this.eventBus.emit(new PlaySoundEffectEvent(SoundEffect.KaChing)); + } + }, + ); + } // 2. Process Units gu.updates[GameUpdateType.Unit]?.forEach((u: UnitUpdate) => { const existingUnit = this.view.unit(u.id); - const isMine = u.ownerID === myPlayer.smallID(); + const isMine = myPlayer ? u.ownerID === myPlayer.smallID() : false; if (!existingUnit) { this.handleNewUnitSounds(u.unitType, isMine);