From f87f98d1e265bf205579b69c41e5df5f3267a625 Mon Sep 17 00:00:00 2001 From: sD Date: Thu, 2 Apr 2020 12:07:07 +0200 Subject: if we don't know the name display a generic message --- webAO/client.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'webAO') diff --git a/webAO/client.js b/webAO/client.js index 84b7b87..d9eb830 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -604,8 +604,9 @@ class Client extends EventEmitter { */ handleMC(args) { const track = args[1]; - const charID = Number(args[2]); + let charID = Number(args[2]); const music = viewport.music; + let musicname; music.pause(); if(track.startsWith("http")) { music.src = track; @@ -613,6 +614,13 @@ class Client extends EventEmitter { music.src = MUSIC_HOST + track.toLowerCase(); } music.play(); + + try { + musicname = this.chars[charID].name; + } catch(e) { + charID = -1; + } + if (charID >= 0) { const musicname = this.chars[charID].name; appendICLog(`${musicname} changed music to ${track}`); @@ -657,7 +665,7 @@ class Client extends EventEmitter { } catch (err) { cini = {}; img.classList.add("noini"); - console.warn("character " + chargs[0] + " is missing from webAO") + console.warn("character " + chargs[0] + " is missing from webAO"); // If it does, give the user a visual indication that the character is unusable } -- cgit