From 1907824670c211ea2cf133ba0b42cab9a689c851 Mon Sep 17 00:00:00 2001 From: PigeonBar <56974298+PigeonBar@users.noreply.github.com> Date: Wed, 16 Oct 2024 11:10:35 -0400 Subject: [PATCH] [P1] Fix party UI crash from unsanitized `lastCursor` pointing to empty Pokemon slot (#4672) --- src/ui/party-ui-handler.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/ui/party-ui-handler.ts b/src/ui/party-ui-handler.ts index e7c1b02cf01..cfc5e146f08 100644 --- a/src/ui/party-ui-handler.ts +++ b/src/ui/party-ui-handler.ts @@ -671,6 +671,9 @@ export default class PartyUiHandler extends MessageUiHandler { } else if (this.cursor === 6) { this.partyCancelButton.select(); } + if (this.lastCursor < 6 && this.lastCursor >= party.length) { + this.lastCursor = party.length - 1; + } for (const p in party) { const slotIndex = parseInt(p);