From 4c91874c653536a357f0f737190e1ea617df36f5 Mon Sep 17 00:00:00 2001 From: stonedDiscord <10584181+stonedDiscord@users.noreply.github.com> Date: Mon, 9 Nov 2020 20:42:53 +0100 Subject: greatly simplify missing shout logic --- webAO/client.js | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index a44f9d5..4a9e934 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -1916,19 +1916,7 @@ async changeBackground(position) { shoutSprite.style.opacity = 1; - let shoutUrl; - - try { - const { url: soundUrl } = await this.oneSuccess([ - this.rejectOnError(fetch(`${AO_HOST}characters/${encodeURI(this.chatmsg.name.toLowerCase())}/${shout}.wav`)), - this.rejectOnError(fetch(`${AO_HOST}misc/default/objection.wav`)) - ]); - shoutUrl = soundUrl; - } catch (error) { - shoutUrl = AO_HOST + `${AO_HOST}misc/default/objection.wav`; - } - - this.shoutaudio.src = shoutUrl; + this.shoutaudio.src = `${AO_HOST}characters/${encodeURI(this.chatmsg.name.toLowerCase())}/${shout}.wav`; this.shoutaudio.play(); this.shoutTimer = client.resources[shout]["duration"]; } else { @@ -2438,6 +2426,15 @@ export function changeShoutVolume() { } window.changeShoutVolume = changeShoutVolume; +/** + * Triggered when the shout could not be found + */ +export function shoutMissing(self) { + self.src = AO_HOST + `${AO_HOST}misc/default/objection.opus`; + self.play(); +} +window.shoutMissing = shoutMissing; + /** * Triggered by the testimony volume slider. */ -- cgit