mirror of
https://github.com/brues-code/ClassicAPI.git
synced 2026-11-16 08:00:42 +00:00
The persistent name cache cut names at 16 bytes. A Chinese character is 3 bytes in UTF-8, so a 6-character name lost part of its last character. The limit is now the engine's own: the name cache store (0x0055F310) copies the name with SStrCopy(dst, src, 0x30) and the realm with SStrCopy(dst, src, 0x100), now PLAYER_INFO_NAME_SIZE and PLAYER_INFO_REALM_SIZE in Offsets.h. A longer name from Lua is cut on a UTF-8 lead byte, never inside a character. Entries are now keyed by GUID, the engine name cache's own key, and keep the record's server name (+0x30, empty for a player on this realm). The by-name index uses the form the engine itself shows for a player from another realm: ClientChatHandler (0x0049D560) builds the sender as name, "-", and the realm with spaces and tabs removed. A bare name stands for this realm. Player::FullName builds and parses that form. Two players with one name from two realms no longer replace each other, C_PlayerCache.GetPlayerInfoByName takes "Name-Realm" (a chat sender name as it comes), and the persistent fallbacks of GetPlayerInfoByGUID and UnitNameFromGUID return the stored realm. A "Name-Realm" skips the by-name search and the friends list, which keep no realm. The engine name cache walk moved from Unit::Identity into Player::Info, its one caller. The cache is one flat file per realm, WTF\ClassicAPI\NameCache-<realm>@<realmList>.txt, in a v5 format split on tabs (a realm can hold spaces): guid, name, realm, class, race, sex. The v4 file under WTF\ClassicAPI\<realmList>\<realm>\ is migrated on first load and deleted, with its emptied folders, once v5 is saved. The old import from the per-account path is gone. The store loaded once per process and saved to whatever realm was current, so logging out into another realm wrote the first realm's players into the second realm's file. It now records the file it holds: every access compares that with the current realm's file, and on a change saves the old realm's entries to their own file before loading the new one. A failed rename leaves the cache dirty for the next flush. Verified on Octo: all 63,178 N'Zoth v4 entries migrated unchanged, 13 of 13 C'Thun entries migrated, the v4 folders were removed, and a N'Zoth to C'Thun switch in one session kept the two files apart. Fixes #119