diff options
| author | David Skoland <davidskoland@gmail.com> | 2026-02-11 00:20:47 +0100 |
|---|---|---|
| committer | David Skoland <davidskoland@gmail.com> | 2026-02-11 00:32:17 +0100 |
| commit | 287f2a178b7b64bfa41b7c55b97e17d90c9f0c78 (patch) | |
| tree | a17e8ac49a7700feee1df21742045d2c93bd9447 /webAO | |
| parent | 7391a61b881af5a515abfbf5905f65e749814fa4 (diff) | |
Deduce emote icon extension from first button to speed up loading
Instead of probing extensions for every emote button (N*M HEAD requests),
probe once using button1_off and reuse the result for all buttons.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Diffstat (limited to 'webAO')
| -rw-r--r-- | webAO/packets/handlers/handlePV.ts | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/webAO/packets/handlers/handlePV.ts b/webAO/packets/handlers/handlePV.ts index 4ac747f..a39a4dd 100644 --- a/webAO/packets/handlers/handlePV.ts +++ b/webAO/packets/handlers/handlePV.ts @@ -43,6 +43,16 @@ export const handlePV = async (args: string[]) => { alt="unavailable" class="emote_button">No emotes available</span>`; } else { + // Probe extensions once using button1_off, then reuse for all emotes + const charPath = `${AO_HOST}characters/${encodeURI(me.name.toLowerCase())}/emotions/`; + let emoteExtension = client.emotions_extensions[0]; + for (const extension of client.emotions_extensions) { + if (await fileExists(`${charPath}button1_off${extension}`)) { + emoteExtension = extension; + break; + } + } + for (let i = 1; i <= ini.emotions.number; i++) { try { const emoteinfo = ini.emotions[i].split("#"); @@ -56,20 +66,8 @@ export const handlePV = async (args: string[]) => { esfx = "0"; esfxd = 0; } - // Make sure the asset server is case insensitive, or that everything on it is lowercase - let url; - for (const extension of client.emotions_extensions) { - url = `${AO_HOST}characters/${encodeURI( - me.name.toLowerCase(), - )}/emotions/button${i}_off${extension}`; - - const exists = await fileExists(url); - - if (exists) { - break; - } - } + const url = `${charPath}button${i}_off${emoteExtension}`; emotes[i] = { desc: emoteinfo[0].toLowerCase(), |
