From 5ad529b4655008df26b11265ba8cfd55cd6d54d9 Mon Sep 17 00:00:00 2001 From: paste Date: Fri, 17 Jul 2026 15:31:09 -0500 Subject: [PATCH] Guard CharacterOrder_Save against empty char list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CHARACTER_LIST_UPDATE can fire with numChars == 0 in a transient state when returning to the glue screen after /logout, before the server's SMSG_CHAR_ENUM re-populates the character list. Without this guard, CharacterOrder_Save writes an empty string to the vault, wiping the saved order. The real CHARACTER_LIST_UPDATE that follows then reads that empty string in Apply, returns early, and leaves the table at server-default identity order — sort order silently reset. Fix: skip the write when numChars is 0. The only legitimate zero case is a brand-new account with no characters, where there's nothing to persist anyway. --- CharacterSelect.lua | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CharacterSelect.lua b/CharacterSelect.lua index 9535b65..d6f5d2d 100644 --- a/CharacterSelect.lua +++ b/CharacterSelect.lua @@ -685,6 +685,12 @@ function CharacterOrder_Save() local realm = GetServerName() or ""; if ( realm == "" ) then return; end local numChars = GetNumCharacters(); + -- Skip when the list is empty. CHARACTER_LIST_UPDATE can fire in a + -- transient state (returning to glue after logout, before the server's + -- SMSG_CHAR_ENUM populates the list) where numChars is briefly 0. + -- Writing an empty string here would wipe the saved order before the + -- real update arrives to Apply it. + if ( numChars == 0 ) then return; end local names = {}; for i = 1, numChars do local name = GetCharacterInfo(GetCharIDFromIndex(i));