diff --git a/webAO/client.ts b/webAO/client.ts index 2f94bae8..5b37c819 100644 --- a/webAO/client.ts +++ b/webAO/client.ts @@ -62,10 +62,7 @@ export const setExtraFeatures = (val: any) => { extrafeatures = val; }; -export let banned: boolean = false; -export const setBanned = (val: boolean) => { - banned = val; -}; + let hdid: string; const fpPromise = FingerprintJS.load(); @@ -183,6 +180,7 @@ class Client extends EventEmitter { } }; + this.banned = false; this.hp = [0, 0]; this.playerID = 1; this.charID = -1; @@ -276,13 +274,20 @@ class Client extends EventEmitter { onClose(e: CloseEvent) { client.state = clientState.NotConnected; console.error(`The connection was closed: ${e.reason} (${e.code})`); - if (extrafeatures.length == 0 && banned === false) { + console.log(this.areas.length); + console.log(this.banned); + if (this.banned === false) { + if (this.areas.length > 0) { document.getElementById("client_errortext").textContent = - "Could not connect to the server"; + "You were disconnected from the server."; + } else { + document.getElementById("client_errortext").textContent = + "Could not connect to the server."; + } } document.getElementById("client_waiting").style.display = "block"; document.getElementById("client_error").style.display = "flex"; - document.getElementById("client_loading").style.display = "none"; + document.getElementById("client_loading").style.display = "none"; document.getElementById("error_id").textContent = String(e.code); this.cleanup(); } diff --git a/webAO/packets/handlers/handleBD.ts b/webAO/packets/handlers/handleBD.ts index 47c191d5..fde4fe1c 100644 --- a/webAO/packets/handlers/handleBD.ts +++ b/webAO/packets/handlers/handleBD.ts @@ -1,4 +1,4 @@ -import { setBanned } from "../../client"; +import { client } from "../../client"; import { handleBans } from "../../client/handleBans"; /** @@ -7,6 +7,6 @@ import { handleBans } from "../../client/handleBans"; * @param {Array} args ban reason */ export const handleBD = (args: string[]) => { + client.banned = true; handleBans("Banned", args[1]); - setBanned(true); }; diff --git a/webAO/packets/handlers/handleKB.ts b/webAO/packets/handlers/handleKB.ts index 78f57219..4679780c 100644 --- a/webAO/packets/handlers/handleKB.ts +++ b/webAO/packets/handlers/handleKB.ts @@ -1,4 +1,4 @@ -import { setBanned } from "../../client"; +import { client } from "../../client"; import { handleBans } from "../../client/handleBans"; /** @@ -7,6 +7,6 @@ import { handleBans } from "../../client/handleBans"; * @param {Array} args ban reason */ export const handleKB = (args: string[]) => { + client.banned = true; handleBans("Banned", args[1]); - setBanned(true); }; diff --git a/webAO/packets/handlers/handleKK.ts b/webAO/packets/handlers/handleKK.ts index 41141397..7aedaa4f 100644 --- a/webAO/packets/handlers/handleKK.ts +++ b/webAO/packets/handlers/handleKK.ts @@ -1,4 +1,4 @@ -import { safeTags } from "../../encoding"; +import { client } from "../../client"; import { handleBans } from "../../client/handleBans"; /** @@ -6,5 +6,6 @@ import { handleBans } from "../../client/handleBans"; * @param {Array} args kick reason */ export const handleKK = (args: string[]) => { - handleBans("Kicked", safeTags(args[1])); + client.banned = true; + handleBans("Kicked", args[1]); };