From f26d35429e66ddcdd02c10f57b315b0f02b4add2 Mon Sep 17 00:00:00 2001 From: David Skoland Date: Sat, 7 Feb 2026 22:21:42 +0100 Subject: Fix playerlist icons using wrong asset URL PR/PU packets arrive before the ASS packet, so playerlist icon srcs were set with the default AO_HOST. Now handleASS re-applies the correct asset URL to existing playerlist images after AO_HOST updates. Co-Authored-By: Claude Opus 4.6 --- webAO/packets/handlers/handleASS.ts | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'webAO/packets/handlers/handleASS.ts') diff --git a/webAO/packets/handlers/handleASS.ts b/webAO/packets/handlers/handleASS.ts index a46d68e..1ecfd04 100644 --- a/webAO/packets/handlers/handleASS.ts +++ b/webAO/packets/handlers/handleASS.ts @@ -1,4 +1,5 @@ -import { setAOhost } from "../../client/aoHost"; +import { setAOhost, AO_HOST } from "../../client/aoHost"; +import { client } from "../../client"; /** * new asset url!! @@ -6,4 +7,20 @@ import { setAOhost } from "../../client/aoHost"; */ export const handleASS = (args: string[]) => { if (args[1] !== "None") setAOhost(args[1]); + + // Re-apply playerlist icon srcs that were set before AO_HOST was known + const iconExt = client.charicon_extensions[0] || ".png"; + for (const [playerID, player] of client.players) { + if (player.charId >= 0) { + const char = client.chars[player.charId]; + if (char) { + const img = document.querySelector( + `#client_playerlist_entry${playerID} img` + ); + if (img) { + img.src = `${AO_HOST}characters/${encodeURI(char.name.toLowerCase())}/char_icon${iconExt}`; + } + } + } + } }; -- cgit From 9c68a1afcf178a86063f094b96471fa73531bd9a Mon Sep 17 00:00:00 2001 From: David Skoland Date: Sat, 7 Feb 2026 23:01:25 +0100 Subject: Use setAOhost return value instead of stale AO_HOST import setAOhost now returns the current AO_HOST so handleASS can use the freshly set value rather than the import captured before the update. Co-Authored-By: Claude Opus 4.6 --- webAO/packets/handlers/handleASS.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'webAO/packets/handlers/handleASS.ts') diff --git a/webAO/packets/handlers/handleASS.ts b/webAO/packets/handlers/handleASS.ts index 1ecfd04..092e4f9 100644 --- a/webAO/packets/handlers/handleASS.ts +++ b/webAO/packets/handlers/handleASS.ts @@ -1,4 +1,4 @@ -import { setAOhost, AO_HOST } from "../../client/aoHost"; +import { setAOhost } from "../../client/aoHost"; import { client } from "../../client"; /** @@ -6,7 +6,7 @@ import { client } from "../../client"; * @param {Array} args packet arguments */ export const handleASS = (args: string[]) => { - if (args[1] !== "None") setAOhost(args[1]); + const host = args[1] !== "None" ? setAOhost(args[1]) : args[1]; // Re-apply playerlist icon srcs that were set before AO_HOST was known const iconExt = client.charicon_extensions[0] || ".png"; @@ -18,7 +18,7 @@ export const handleASS = (args: string[]) => { `#client_playerlist_entry${playerID} img` ); if (img) { - img.src = `${AO_HOST}characters/${encodeURI(char.name.toLowerCase())}/char_icon${iconExt}`; + img.src = `${host}characters/${encodeURI(char.name.toLowerCase())}/char_icon${iconExt}`; } } } -- cgit From 020dfcda00ca06b9a06e7076eaf8a0164ae1327e Mon Sep 17 00:00:00 2001 From: David Skoland Date: Tue, 10 Feb 2026 23:38:17 +0100 Subject: Refactor playerlist to state-driven rendering with renderPlayerList handlePR and handlePU now only update client.playerlist state, and renderPlayerList handles all DOM rendering from that state. Co-Authored-By: Claude Opus 4.6 --- webAO/packets/handlers/handleASS.ts | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) (limited to 'webAO/packets/handlers/handleASS.ts') diff --git a/webAO/packets/handlers/handleASS.ts b/webAO/packets/handlers/handleASS.ts index 092e4f9..c50443a 100644 --- a/webAO/packets/handlers/handleASS.ts +++ b/webAO/packets/handlers/handleASS.ts @@ -1,26 +1,11 @@ import { setAOhost } from "../../client/aoHost"; -import { client } from "../../client"; +import { renderPlayerList } from "../../dom/renderPlayerList"; /** * new asset url!! * @param {Array} args packet arguments */ export const handleASS = (args: string[]) => { - const host = args[1] !== "None" ? setAOhost(args[1]) : args[1]; - - // Re-apply playerlist icon srcs that were set before AO_HOST was known - const iconExt = client.charicon_extensions[0] || ".png"; - for (const [playerID, player] of client.players) { - if (player.charId >= 0) { - const char = client.chars[player.charId]; - if (char) { - const img = document.querySelector( - `#client_playerlist_entry${playerID} img` - ); - if (img) { - img.src = `${host}characters/${encodeURI(char.name.toLowerCase())}/char_icon${iconExt}`; - } - } - } - } + if (args[1] !== "None") setAOhost(args[1]); + renderPlayerList(); }; -- cgit