From 094927ecdad9df116e2cde4b3557c68e4a6ab85d Mon Sep 17 00:00:00 2001 From: sD Date: Thu, 2 Apr 2020 11:31:55 +0200 Subject: don't throw an exception if the chars aren't loaded yet --- webAO/client.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/webAO/client.js b/webAO/client.js index fd92e90..f7e89a6 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -513,15 +513,22 @@ class Client extends EventEmitter { if (args[4] !== viewport.chatmsg.content) { document.getElementById("client_inner_chat").innerHTML = ""; + const char_id = Number(args[9]) + let msg_nameplate = args[3]; let msg_blips = "male"; + let char_muted = false; + try { - msg_nameplate = this.chars[args[9]].showname; - msg_blips = this.chars[args[9]].gender; + msg_nameplate = this.chars[char_id].showname; + msg_blips = this.chars[char_id].gender; + char_muted = this.chars[char_id].muted; } catch (e) { //we already set defaults } + if (char_muted === false) { + let chatmsg = { deskmod: safe_tags(args[1]).toLowerCase(), preanim: safe_tags(args[2]).toLowerCase(), // get preanim @@ -533,7 +540,7 @@ class Client extends EventEmitter { sound: safe_tags(args[7]).toLowerCase(), blips: safe_tags(msg_blips), type: Number(args[8]), - charid: Number(args[9]), + charid: char_id, snddelay: Number(args[10]), objection: Number(args[11]), evidence: safe_tags(args[12]), @@ -559,12 +566,13 @@ class Client extends EventEmitter { } } + // our own message appeared, reset the buttons if (chatmsg.charid === this.charID) { resetICParams(); } - if (client.chars[chatmsg.charid].muted === false) - viewport.say(chatmsg); // no await + viewport.say(chatmsg); // no await + } } } -- cgit From 9ef7df122e4174bbfbaf391f77ae1f652822a97b Mon Sep 17 00:00:00 2001 From: sD Date: Thu, 2 Apr 2020 11:38:08 +0200 Subject: detect iniedit and load the new char --- webAO/client.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/webAO/client.js b/webAO/client.js index f7e89a6..65e3798 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -513,7 +513,8 @@ class Client extends EventEmitter { if (args[4] !== viewport.chatmsg.content) { document.getElementById("client_inner_chat").innerHTML = ""; - const char_id = Number(args[9]) + const char_id = Number(args[9]); + const char_name = safe_tags(args[3]); let msg_nameplate = args[3]; let msg_blips = "male"; @@ -523,6 +524,11 @@ class Client extends EventEmitter { msg_nameplate = this.chars[char_id].showname; msg_blips = this.chars[char_id].gender; char_muted = this.chars[char_id].muted; + + if(this.chars[char_id].showname !== char_name) { + // someone is iniediting + this.handleCharacterInfo(char_name,char_id); + } } catch (e) { //we already set defaults } @@ -533,7 +539,7 @@ class Client extends EventEmitter { deskmod: safe_tags(args[1]).toLowerCase(), preanim: safe_tags(args[2]).toLowerCase(), // get preanim nameplate: msg_nameplate, // TODO: there's a new feature that let's people choose the name that's displayed - name: safe_tags(args[3]), + name: char_name, sprite: safe_tags(args[4]).toLowerCase(), content: this.prepChat(args[5]), // Escape HTML tags side: args[6].toLowerCase(), -- cgit From 9211eca4316ab10c8064678288228d7541542532 Mon Sep 17 00:00:00 2001 From: sD Date: Thu, 2 Apr 2020 11:49:45 +0200 Subject: name not showname and log it when it happens --- webAO/client.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/webAO/client.js b/webAO/client.js index 65e3798..2612bfc 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -525,12 +525,13 @@ class Client extends EventEmitter { msg_blips = this.chars[char_id].gender; char_muted = this.chars[char_id].muted; - if(this.chars[char_id].showname !== char_name) { - // someone is iniediting + if(this.chars[char_id].name !== char_name) { + console.info(this.chars[char_id].name + " is iniediting to " + char_name); this.handleCharacterInfo(char_name,char_id); } } catch (e) { //we already set defaults + console.error("we're still missing some character data"); } if (char_muted === false) { -- cgit From 8e18260349e57aaed9fd6a4ce77876f0f1423a14 Mon Sep 17 00:00:00 2001 From: sD Date: Thu, 2 Apr 2020 12:04:05 +0200 Subject: it wants an array, set better defaults --- webAO/client.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/webAO/client.js b/webAO/client.js index 2612bfc..84b7b87 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -527,10 +527,13 @@ class Client extends EventEmitter { if(this.chars[char_id].name !== char_name) { console.info(this.chars[char_id].name + " is iniediting to " + char_name); - this.handleCharacterInfo(char_name,char_id); + const chargs = (char_name + "&" + "filthy iniedtier").split("&"); + this.handleCharacterInfo(chargs,char_id); } } catch (e) { - //we already set defaults + msg_nameplate = args[3]; + msg_blips = "male"; + char_muted = false; console.error("we're still missing some character data"); } @@ -654,6 +657,7 @@ class Client extends EventEmitter { } catch (err) { cini = {}; img.classList.add("noini"); + console.warn("character " + chargs[0] + " is missing from webAO") // If it does, give the user a visual indication that the character is unusable } -- cgit 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(-) 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 From 8a52f77a50055a1d2f80a4e79582d521d8980c5a Mon Sep 17 00:00:00 2001 From: sD Date: Thu, 2 Apr 2020 12:51:27 +0200 Subject: it's not a const anymore --- webAO/client.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webAO/client.js b/webAO/client.js index d9eb830..e2d7911 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -622,7 +622,7 @@ class Client extends EventEmitter { } if (charID >= 0) { - const musicname = this.chars[charID].name; + musicname = this.chars[charID].name; appendICLog(`${musicname} changed music to ${track}`); } else { appendICLog(`The music was changed to ${track}`); -- cgit From beef46a39b486e025748d2c9d71e95382aa5e1da Mon Sep 17 00:00:00 2001 From: sD Date: Thu, 2 Apr 2020 12:55:52 +0200 Subject: this. --- webAO/client.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/webAO/client.js b/webAO/client.js index e2d7911..483468c 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -1525,7 +1525,7 @@ async changeBackground(position) { */ async say(chatmsg) { this.chatmsg = chatmsg; - this.blipChannels.forEach(channel => channel.src = `${AO_HOST}sounds/general/sfx-blip${encodeURI(chatmsg.blips.toLowerCase())}.wav`); + this.blipChannels.forEach(channel => channel.src = `${AO_HOST}sounds/general/sfx-blip${encodeURI(this.chatmsg.blips.toLowerCase())}.wav`); this.textnow = ""; this.sfxplayed = 0; this.textTimer = 0; @@ -1571,7 +1571,7 @@ async changeBackground(position) { } this.lastChar = this.chatmsg.name; - appendICLog(chatmsg.content, chatmsg.nameplate); + appendICLog(this.chatmsg.content, this.chatmsg.nameplate); // start checking the files try { @@ -1634,14 +1634,14 @@ async changeBackground(position) { chatBox.style.display = "none"; chatContainerBox.style.display = "none"; // If preanim existed then determine the length - gifLength = await this.getAnimLength(`${AO_HOST}characters/${encodeURI(chatmsg.name.toLowerCase())}/${encodeURI(chatmsg.preanim)}.gif`); + gifLength = await this.getAnimLength(`${AO_HOST}characters/${encodeURI(this.chatmsg.name.toLowerCase())}/${encodeURI(this.chatmsg.preanim)}.gif`); this.chatmsg.startspeaking = false; break; // case 5: // zoom default: // due to a retarded client bug, we need to strip the sfx from the MS, if the preanim isn't playing - chatmsg.sound = ""; + this.chatmsg.sound = ""; this.chatmsg.startspeaking = true; break; } -- cgit