aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Skoland <davidskoland@gmail.com>2026-02-07 22:21:42 +0100
committerDavid Skoland <davidskoland@gmail.com>2026-02-07 22:21:42 +0100
commitf26d35429e66ddcdd02c10f57b315b0f02b4add2 (patch)
treeb7110ef85b9ef153b9c8e33a29a135368d23f993
parent95e4124b0c02b4e5be383c41ed4241566f40e6e6 (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.ts19
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}`;
+ }
+ }
+ }
+ }
};