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(-) (limited to 'webAO/client.js') 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(-) (limited to 'webAO/client.js') 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(-) (limited to 'webAO/client.js') 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(-) (limited to 'webAO/client.js') 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(-) (limited to 'webAO/client.js') 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(-) (limited to 'webAO/client.js') 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(-) (limited to 'webAO/client.js') 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 From a7586b1280551b594d7b527b84232582acfd9f45 Mon Sep 17 00:00:00 2001 From: sD Date: Thu, 2 Apr 2020 13:05:51 +0200 Subject: add guilty sfx --- webAO/client.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index fd92e90..e6c0c29 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -144,14 +144,16 @@ class Client extends EventEmitter { "duration": 1600, "sfx": AO_HOST + "sounds/general/sfx-testimony2.wav" }, + "guilty": { + "src": AO_HOST + "themes/" + THEME + "/guilty.gif", + "duration": 2870, + "sfx": AO_HOST + "sounds/general/sfx-guilty.wav" + }, "notguilty": { "src": AO_HOST + "themes/" + THEME + "/notguilty.gif", - "duration": 2440 + "duration": 2440, + "sfx": AO_HOST + "sounds/general/sfx-notguilty.wav" }, - "guilty": { - "src": AO_HOST + "themes/" + THEME + "/guilty.gif", - "duration": 2870 - } }; this.selectedEmote = -1; -- cgit From eeb99309a07e45701f1b76676eec202bbf59a9c2 Mon Sep 17 00:00:00 2001 From: sD Date: Thu, 2 Apr 2020 22:45:19 +0200 Subject: remove modcall changing because the sfx barely work --- webAO/client.js | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index e6c0c29..796905d 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -385,13 +385,6 @@ class Client extends EventEmitter { evidence_select.add(new Option(evidence)); }); - // Load sfx for modcalls - const modcall_select = document.getElementById("client_modcall"); - sfx_arr.forEach(evidence => { - modcall_select.add(new Option(evidence)); - }); - document.getElementById("client_modcall").value = getCookie("modcall_sfx") || "sfx-gallery.wav"; - // Read cookies and set the UI to its values document.getElementById("OOC_name").value = getCookie("OOC_name") || "web"+parseInt(Math.random()*100+10); @@ -980,7 +973,7 @@ class Client extends EventEmitter { } /** - * Handles a call mod message. + * Handles a modcall * @param {Array} args packet arguments */ handleZZ(args) { @@ -989,11 +982,10 @@ class Client extends EventEmitter { if (oocLog.scrollTop > oocLog.scrollHeight - 60) { oocLog.scrollTop = oocLog.scrollHeight; } - const sfxname = document.getElementById("client_modcall").value; viewport.sfxaudio.pause(); const oldvolume = viewport.sfxaudio.volume; viewport.sfxaudio.volume = 1; - viewport.sfxaudio.src = AO_HOST + "sounds/general/" + sfxname + ".wav"; + viewport.sfxaudio.src = AO_HOST + "sounds/general/sfx-gallery.wav"; viewport.sfxaudio.play(); viewport.sfxaudio.volume = oldvolume; } @@ -2069,10 +2061,10 @@ window.reloadTheme = reloadTheme; /** * Triggered by the modcall sfx dropdown */ -export function changeModcall() { - setCookie("modcall_sfx", document.getElementById("client_modcall").value); +export function modcall_test() { + client.handleZZ("test#test".split("#")); } -window.changeModcall = changeModcall; +window.modcall_test = modcall_test; /** * Triggered by the ini button. -- cgit From 60a9f47f9117c4188f5eae26642b79bc8d8f7c74 Mon Sep 17 00:00:00 2001 From: sD Date: Sat, 4 Apr 2020 14:34:28 +0200 Subject: use prepChat for music and more in general --- webAO/client.js | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index 796905d..79759f0 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -6,7 +6,7 @@ import Fingerprint2 from 'fingerprintjs2'; -import { unescapeChat, escapeChat, encodeChat, decodeChat, safe_tags } from './encoding.js'; +import { escapeChat, encodeChat, prepChat, safe_tags } from './encoding.js'; // Load some defaults for the background and evidence dropdowns import character_arr from "./characters.js"; @@ -490,15 +490,6 @@ class Client extends EventEmitter { document.getElementById("client_chartable").innerHTML = ""; } - /** - * XXX: a nasty hack made by gameboyprinter. - * @param {string} msg chat message to prepare for display - */ - prepChat(msg) { - // TODO: make this less awful - return unescapeChat(decodeChat(msg)); - } - /** * Handles an in-character chat message. * @param {*} args packet arguments @@ -523,7 +514,7 @@ class Client extends EventEmitter { nameplate: msg_nameplate, // TODO: there's a new feature that let's people choose the name that's displayed name: safe_tags(args[3]), sprite: safe_tags(args[4]).toLowerCase(), - content: this.prepChat(args[5]), // Escape HTML tags + content: prepChat(args[5]), // Escape HTML tags side: args[6].toLowerCase(), sound: safe_tags(args[7]).toLowerCase(), blips: safe_tags(msg_blips), @@ -569,7 +560,7 @@ class Client extends EventEmitter { */ handleCT(args) { const oocLog = document.getElementById("client_ooclog"); - oocLog.innerHTML += `${decodeChat(unescapeChat(args[1]))}: ${decodeChat(unescapeChat(args[2]))}\r\n`; + oocLog.innerHTML += `${prepChat(args[1])}: ${prepChat(args[2])}\r\n`; if (oocLog.scrollTop > oocLog.scrollHeight - 600) { oocLog.scrollTop = oocLog.scrollHeight; } @@ -580,14 +571,14 @@ class Client extends EventEmitter { * @param {Array} args packet arguments */ handleMC(args) { - const track = args[1]; + const track = prepChat(args[1]); const charID = Number(args[2]); const music = viewport.music; music.pause(); if(track.startsWith("http")) { music.src = track; } else { - music.src = MUSIC_HOST + track.toLowerCase(); + music.src = MUSIC_HOST + encodeURI(track.toLowerCase()); } music.play(); if (charID >= 0) { @@ -735,8 +726,8 @@ class Client extends EventEmitter { for (let i = 1; i < args.length - 1; i++) { const arg = args[i].split("&"); this.evidences[i - 1] = { - name: decodeChat(unescapeChat(arg[0])), - desc: decodeChat(unescapeChat(arg[1])), + name: prepChat(arg[0]), + desc: prepChat(arg[1]), filename: safe_tags(arg[2]), icon: AO_HOST + "evidence/" + encodeURI(arg[2].toLowerCase()) }; @@ -978,7 +969,7 @@ class Client extends EventEmitter { */ handleZZ(args) { const oocLog = document.getElementById("client_ooclog"); - oocLog.innerHTML += `$Alert: ${decodeChat(unescapeChat(args[1]))}\r\n`; + oocLog.innerHTML += `$Alert: ${prepChat(args[1])}\r\n`; if (oocLog.scrollTop > oocLog.scrollHeight - 60) { oocLog.scrollTop = oocLog.scrollHeight; } @@ -1608,7 +1599,7 @@ async changeBackground(position) { // 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