From 3b414b1f89a4808d1a6eb37d789c276a6afeae60 Mon Sep 17 00:00:00 2001 From: Jage9 Date: Fri, 27 Feb 2026 01:12:24 -0500 Subject: [PATCH] Apply clock announcement spatial range from server --- client/public/version.js | 2 +- client/src/audio/clockAnnouncer.ts | 6 +++--- client/src/main.ts | 4 ++-- client/src/network/messageHandlers.ts | 4 ++-- client/src/network/protocol.ts | 1 + server/app/models.py | 1 + server/app/server.py | 2 ++ 7 files changed, 12 insertions(+), 8 deletions(-) diff --git a/client/public/version.js b/client/public/version.js index 8bfd76e..fdf6acd 100644 --- a/client/public/version.js +++ b/client/public/version.js @@ -1,5 +1,5 @@ // Maintainer-controlled web client version. // Format: YYYY.MM.DD Rn (example: 2026.02.20 R2) -window.CHGRID_WEB_VERSION = "2026.02.25 R270"; +window.CHGRID_WEB_VERSION = "2026.02.25 R271"; // Optional display timezone for timestamps. Falls back to America/Detroit if unset/invalid. window.CHGRID_TIME_ZONE = "America/Detroit"; diff --git a/client/src/audio/clockAnnouncer.ts b/client/src/audio/clockAnnouncer.ts index 2367196..5553117 100644 --- a/client/src/audio/clockAnnouncer.ts +++ b/client/src/audio/clockAnnouncer.ts @@ -13,14 +13,14 @@ export class ClockAnnouncer { private readonly getListenerPosition: ListenerPositionGetter, ) {} - async playSequence(sounds: string[], sourceX: number, sourceY: number): Promise { + async playSequence(sounds: string[], sourceX: number, sourceY: number, range?: number): Promise { if (sounds.length === 0) return; const token = ++this.playToken; + const effectiveRange = Number.isFinite(range) && (range as number) > 0 ? (range as number) : undefined; for (const sound of sounds) { if (token !== this.playToken) return; const listener = this.getListenerPosition(); - await this.audio.playSpatialSampleAndWait(sound, { x: sourceX, y: sourceY }, listener, 1); + await this.audio.playSpatialSampleAndWait(sound, { x: sourceX, y: sourceY }, listener, 1, effectiveRange); } } } - diff --git a/client/src/main.ts b/client/src/main.ts index 9570a44..29a8977 100644 --- a/client/src/main.ts +++ b/client/src/main.ts @@ -1660,8 +1660,8 @@ const onAppMessage = createOnMessageHandler({ playIncomingItemUseSound: (url, x, y, range) => { void audio.playSpatialSample(url, { x, y }, { x: state.player.x, y: state.player.y }, 1, range ?? HEARING_RADIUS); }, - playClockAnnouncement: (sounds, x, y) => { - void clockAnnouncer.playSequence(sounds.map(resolveIncomingSoundUrl), x, y); + playClockAnnouncement: (sounds, x, y, range) => { + void clockAnnouncer.playSequence(sounds.map(resolveIncomingSoundUrl), x, y, range); }, handleAuthRequired, handleAuthResult, diff --git a/client/src/network/messageHandlers.ts b/client/src/network/messageHandlers.ts index b150793..4fd861d 100644 --- a/client/src/network/messageHandlers.ts +++ b/client/src/network/messageHandlers.ts @@ -69,7 +69,7 @@ type MessageHandlerDeps = { playLocateToneAt: (x: number, y: number) => void; resolveIncomingSoundUrl: (url: string) => string; playIncomingItemUseSound: (url: string, x: number, y: number, range?: number) => void; - playClockAnnouncement: (sounds: string[], x: number, y: number) => void; + playClockAnnouncement: (sounds: string[], x: number, y: number, range?: number) => void; handleAuthRequired: (message: Extract) => void; handleAuthResult: (message: Extract) => Promise; isPeerNegotiationReady: () => boolean; @@ -310,7 +310,7 @@ export function createOnMessageHandler(deps: MessageHandlerDeps): (message: Inco case 'item_clock_announce': { if (!deps.getAudioLayers().world) break; - deps.playClockAnnouncement(message.sounds, message.x, message.y); + deps.playClockAnnouncement(message.sounds, message.x, message.y, message.range); break; } diff --git a/client/src/network/protocol.ts b/client/src/network/protocol.ts index 2ba476d..658f1c5 100644 --- a/client/src/network/protocol.ts +++ b/client/src/network/protocol.ts @@ -222,6 +222,7 @@ export const itemClockAnnounceSchema = z.object({ sounds: z.array(z.string()), x: z.number().int(), y: z.number().int(), + range: z.number().int().positive().optional(), }); export const itemPianoNoteSchema = z.object({ diff --git a/server/app/models.py b/server/app/models.py index b64202a..9a36629 100644 --- a/server/app/models.py +++ b/server/app/models.py @@ -301,6 +301,7 @@ class ItemClockAnnouncePacket(BasePacket): sounds: list[str] x: int y: int + range: int | None = None class ItemPianoNoteBroadcastPacket(BasePacket): diff --git a/server/app/server.py b/server/app/server.py index cb34877..6d44c00 100644 --- a/server/app/server.py +++ b/server/app/server.py @@ -495,6 +495,7 @@ class SignalingServer: """Broadcast one server-authoritative clock speech sequence from item position.""" sound_x, sound_y = self._get_item_sound_source_position(item) + sound_range = self._get_item_emit_range(item) sounds = self._build_clock_announcement_sounds(item.params, top_of_hour=top_of_hour) if not sounds: return @@ -505,6 +506,7 @@ class SignalingServer: sounds=sounds, x=sound_x, y=sound_y, + range=sound_range, ) )