From 625f9551b8fc5de7fdc49343e232915e43347aca Mon Sep 17 00:00:00 2001 From: sD Date: Thu, 26 Dec 2019 20:56:14 +0100 Subject: move chatmsg isnew stuff to say to get rid of the 60ms delay --- webAO/client.js | 96 ++++++++++++++++++++++++++++++--------------------------- 1 file changed, 50 insertions(+), 46 deletions(-) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index d1bbe79..f8a57c2 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -1167,27 +1167,71 @@ class Viewport { */ async say(chatmsg) { this.chatmsg = chatmsg; - appendICLog(chatmsg.content, chatmsg.nameplate); - changeBackground(chatmsg.side); this.blipChannels.forEach(channel => channel.src = `${AO_HOST}sounds/general/sfx-blip${encodeURI(chatmsg.blips.toLowerCase())}.wav`); this.textnow = ""; this.sfxplayed = 0; this.textTimer = 0; this._animating = true; + const nameBox = document.getElementById("client_name"); + const chatBox = document.getElementById("client_chat"); + const eviBox = document.getElementById("client_evi"); + const shoutSprite = document.getElementById("client_shout"); + const chatBoxInner = document.getElementById("client_inner_chat"); + const fg = document.getElementById("client_fg"); + const gamewindow = document.getElementById("client_gamewindow"); + // Reset CSS animation - document.getElementById("client_fg").style.animation = ""; - document.getElementById("client_gamewindow").style.animation = ""; + fg.style.animation = ""; + gamewindow.style.animation = ""; + chatBoxInner.className = ""; + eviBox.style.opacity = "0"; + eviBox.style.height = "0%"; + appendICLog(chatmsg.content, chatmsg.nameplate); + changeBackground(chatmsg.side); clearTimeout(this.updater); + + const shouts = [ + undefined, + "holdit", + "objection", + "takethat" + ]; + + // gets which shout shall played + const shout = shouts[this.chatmsg.objection]; + if (shout) { + // Hide message box + nameBox.style.display = "none"; + chatBox.style.display = "none"; + shoutSprite.src = client.resources[shout]["src"]; + this.shoutaudio.src=`${AO_HOST}characters/${encodeURI(this.chatmsg.name.toLowerCase())}/${shout}.wav`; + this.shoutaudio.play(); + this.shoutTimer = 850; + } else { + this.shoutTimer = 0; + } + + this.chatmsg.isnew = false; + this.chatmsg.startpreanim = true; + // If preanim existed then determine the length - if (chatmsg.preanim !== "-") { + if (this.chatmsg.preanim !== "-") { + // Hide message box + nameBox.style.display = "none"; + chatBox.style.display = "none"; const delay = await this.getAnimLength(`${AO_HOST}characters/${encodeURI(chatmsg.name.toLowerCase())}/${encodeURI(chatmsg.preanim)}.gif`); chatmsg.preanimdelay = delay; this.initUpdater(delay); } else { this.initUpdater(0); } + + //Set the nameplate after it (might) have been hidden + nameBox.innerText = this.chatmsg.nameplate; + //Clear out the last message + chatBoxInner.innerText = this.textnow; } /** @@ -1349,7 +1393,6 @@ class Viewport { const charSprite = document.getElementById("client_char"); const pairSprite = document.getElementById("client_pair_char"); const eviBox = document.getElementById("client_evi"); - const background = document.getElementById("client_background"); const shoutSprite = document.getElementById("client_shout"); const chatBoxInner = document.getElementById("client_inner_chat"); @@ -1373,37 +1416,6 @@ class Viewport { this.updater = setTimeout(() => this.tick(), UPDATE_INTERVAL); } - if (this.chatmsg.isnew) { - // Reset screen background - background.style.backgroundColor = "transparent"; - // Hide message and evidence window - nameBox.style.display = "none"; - chatBox.style.display = "none"; - chatBoxInner.className = ""; - eviBox.style.opacity = "0"; - eviBox.style.height = "0%"; - const shouts = [ - undefined, - "holdit", - "objection", - "takethat" - ]; - - // gets which shout shall played - const shout = shouts[this.chatmsg.objection]; - if (shout) { - shoutSprite.src = client.resources[shout]["src"]; - this.shoutaudio.src=`${AO_HOST}characters/${encodeURI(this.chatmsg.name.toLowerCase())}/${shout}.wav`; - this.shoutaudio.play(); - this.shoutTimer = 850; - } else { - this.shoutTimer = 0; - } - - this.chatmsg.isnew = false; - this.chatmsg.startpreanim = true; - } - // TODO: preanims sometimes play when they're not supposed to if (this.textTimer >= this.shoutTimer && this.chatmsg.startpreanim) { // Effect stuff @@ -1472,11 +1484,6 @@ class Viewport { nameBox.style.display = "block"; nameBox.style.fontSize = (nameBox.offsetHeight * 0.7) + "px"; - while (nameBox.hasChildNodes()) { - nameBox.removeChild(nameBox.firstChild); - } - nameBox.appendChild(document.createTextNode(this.chatmsg.nameplate)); - chatBox.style.display = "block"; chatBox.style.fontSize = (chatBox.offsetHeight * 0.25) + "px"; @@ -1525,10 +1532,7 @@ class Viewport { } this.textnow = this.chatmsg.content.substring(0, this.textnow.length + 1); - while (chatBoxInner.hasChildNodes()) { - chatBoxInner.removeChild(chatBoxInner.firstChild); - } - chatBoxInner.appendChild(document.createTextNode(this.textnow)); + chatBoxInner.innerText = this.textnow; if (this.textnow === this.chatmsg.content) { this.textTimer = 0; -- cgit From 45aa343058d46df594faa353772067aaa630ee35 Mon Sep 17 00:00:00 2001 From: sD Date: Fri, 27 Dec 2019 02:20:26 +0100 Subject: charid is a number --- webAO/client.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index 5b58d10..58da942 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -1036,10 +1036,9 @@ class Client extends EventEmitter { * @param {Array} args packet arguments */ async handlePV(args) { - this.charID = args[3]; + this.charID = Number(args[3]); document.getElementById("client_charselect").style.display = "none"; - document.getElementById("client_inputbox").style.display = ""; const me = this.character; this.selectedEmote = -1; @@ -2020,8 +2019,6 @@ export function pickChar(ccharacter) { } else { // Spectator document.getElementById("client_charselect").style.display = "none"; - document.getElementById("client_inputbox").style.display = "none"; - document.getElementById("client_emo").style.display = "none"; } } window.pickChar = pickChar; -- cgit From 11bec733825bbfab18f0159b918a8dcb27db3d5c Mon Sep 17 00:00:00 2001 From: sD Date: Fri, 27 Dec 2019 16:44:41 +0100 Subject: more numbers --- webAO/client.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index 58da942..59cdf1d 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -529,7 +529,7 @@ class Client extends EventEmitter { music.pause(); music.src = MUSIC_HOST + track.toLowerCase(); music.play(); - if (args[2] >= 0) { + if (Number(args[2]) >= 0) { const musicname = this.chars[charID].name; appendICLog(`${musicname} changed music to ${track}`); } else { @@ -843,7 +843,7 @@ class Client extends EventEmitter { * @param {Array} args packet arguments */ handleHP(args) { - const percent_hp = args[2] * 10; + const percent_hp = Number(args[2]) * 10; let healthbox; if (args[1] === "1") { // Def hp @@ -889,7 +889,7 @@ class Client extends EventEmitter { * @param {Array} args packet arguments */ handleID(args) { - this.playerID = args[1]; + this.playerID = Number(args[1]); this.serverSoftware = args[2].split("&")[0]; if (this.serverSoftware === "serverD") this.serverVersion = args[2].split("&")[1]; @@ -917,19 +917,19 @@ class Client extends EventEmitter { for (let i = 1; i < args.length - 1; i++) { if (this.areas[i]) { // the server sends us ARUP before we even get the area list const thisarea = document.getElementById("area" + i); - switch(args[0]) { - case "0": // playercount + switch(Number(args[0])) { + case 0: // playercount this.areas[i].players = Number(args[i]); thisarea.innerText = `${this.areas[i].name} (${this.areas[i].players})`; break; - case "1": // status + case 1: // status this.areas[i].status = safe_tags(args[i]); thisarea.classList = "area-button area-" + this.areas[i].status.toLowerCase(); break; - case "2": + case 2: this.areas[i].cm = safe_tags(args[i]); break; - case "3": + case 3: this.areas[i].locked = safe_tags(args[i]); break; } @@ -974,8 +974,8 @@ class Client extends EventEmitter { handleSI(args) { this.char_list_length = Number(args[1]); this.char_list_length += 1; // some servers count starting from 0 some from 1... - this.evidence_list_length = args[2]; - this.music_list_length = args[3]; + this.evidence_list_length = Number(args[2]); + this.music_list_length = Number(args[3]); // create the charselect grid, to be filled by the character loader document.getElementById("client_chartable").innerHTML = ""; -- cgit From 790b7ee755db01559fb45e930046fb1ce2c930ab Mon Sep 17 00:00:00 2001 From: sD Date: Sat, 28 Dec 2019 17:23:49 +0100 Subject: make the id stick better --- webAO/client.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'webAO/client.js') diff --git a/webAO/client.js b/webAO/client.js index 59cdf1d..5c211c3 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -51,9 +51,16 @@ const fp = new Fingerprint({ screen_resolution: true }); -// An emulated, semi-unique HDID that is generally safe for HDID bans. -const hdid = fp.get(); -console.info(`Your emulated HDID is ${hdid}`); +/** An emulated, semi-unique HDID that is generally safe for HDID bans. */ +const cookieid = getCookie("fingerprint"); +let hdid; +if (cookieid) { + hdid = cookieid; +} else { + hdid = fp.get(); + setCookie("fingerprint",hdid); +} +console.log(`Your emulated HDID is ${hdid}`); let lastICMessageTime = new Date(0); -- cgit