From 2b9e81b2a9e52149f23adcae509afe6904db372b Mon Sep 17 00:00:00 2001 From: oldmud0 Date: Tue, 22 May 2018 22:46:57 -0500 Subject: Stop throwing away players' messages Only clear the chat input once our message has been actually sent. --- webAO/client.js | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'webAO') diff --git a/webAO/client.js b/webAO/client.js index 8dcb929..f90c61a 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -261,6 +261,10 @@ class Client { } } + if (chatmsg.character == this.charID) { + resetICParams(); + } + viewport.say(chatmsg); } } @@ -754,17 +758,24 @@ export function onEnter(event) { ssfxname = myemo.sfx; ssfxdelay = myemo.sfxdelay; } - // TODO URGENT: Do NOT send if we know that our message is going to get thrown away! client.sendIC(myemo.speaking, mychar.name, myemo.silent, document.getElementById("client_inputbox").value, mychar.side, ssfxname, myemo.zoom, ssfxdelay, selectedShout); - document.getElementById("client_inputbox").value = ""; - if (selectedShout) { - document.getElementById("button_" + selectedShout).className = "client_button"; - selectedShout = 0; - } } } window.onEnter = onEnter; +/** + * Resets the IC parameters for the player to enter a new chat message. + * This should only be called when the player's previous chat message + * was successfully sent/presented. + */ +function resetICParams() { + document.getElementById("client_inputbox").value = ""; + if (selectedShout) { + document.getElementById("button_" + selectedShout).className = "client_button"; + selectedShout = 0; + } +} + /** * Triggered when an item on the music list is clicked. * @param {MouseEvent} event -- cgit