diff options
| author | David Skoland <davidskoland@gmail.com> | 2026-02-07 22:21:42 +0100 |
|---|---|---|
| committer | David Skoland <davidskoland@gmail.com> | 2026-02-07 22:21:42 +0100 |
| commit | f26d35429e66ddcdd02c10f57b315b0f02b4add2 (patch) | |
| tree | b7110ef85b9ef153b9c8e33a29a135368d23f993 | |
| parent | 95e4124b0c02b4e5be383c41ed4241566f40e6e6 (diff) | |
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 <noreply@anthropic.com>
| -rw-r--r-- | webAO/packets/handlers/handleASS.ts | 19 |
1 files changed, 18 insertions, 1 deletions
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<HTMLImageElement>( + `#client_playerlist_entry${playerID} img` + ); + if (img) { + img.src = `${AO_HOST}characters/${encodeURI(char.name.toLowerCase())}/char_icon${iconExt}`; + } + } + } + } }; |
