From 84c0ced228d0fbb6d73f4bf63bb5927697c8f519 Mon Sep 17 00:00:00 2001 From: Kelsi Date: Sun, 29 Mar 2026 19:22:55 -0700 Subject: [PATCH] fix: friend cache inserted empty key; ignore erase before server confirm handleFriendStatus inserted into friendsCache with an empty playerName when the name query hadn't resolved yet, creating a phantom "" entry. Now guards with !playerName.empty(). removeIgnore erased from ignoreCache immediately without waiting for server confirmation, desyncing the cache if the server rejected. Now only clears the GUID set and lets the next SMSG_IGNORE_LIST rebuild the cache, consistent with how removeFriend works. --- src/game/social_handler.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/game/social_handler.cpp b/src/game/social_handler.cpp index 93806764..19485c50 100644 --- a/src/game/social_handler.cpp +++ b/src/game/social_handler.cpp @@ -778,7 +778,11 @@ void SocialHandler::removeIgnore(const std::string& playerName) { auto packet = DelIgnorePacket::build(it->second); owner_.socket->send(packet); owner_.addSystemChatMessage("Removing " + playerName + " from ignore list..."); - owner_.ignoreCache.erase(it); + // Don't erase from ignoreCache here — wait for the server's SMSG_IGNORE_LIST + // response to confirm. Erasing optimistically desyncs the cache if the server + // rejects the request. (Compare with removeFriend which also waits for + // SMSG_FRIEND_STATUS before updating its cache.) + owner_.ignoreListGuids_.erase(it->second); LOG_INFO("Sent remove ignore request for: ", playerName); } @@ -1817,8 +1821,12 @@ void SocialHandler::handleFriendStatus(network::Packet& packet) { if (it != owner_.getPlayerNameCache().end()) playerName = it->second; } - if (data.status == 1 || data.status == 2) owner_.friendsCache[playerName] = data.guid; - else if (data.status == 0) owner_.friendsCache.erase(playerName); + // Only update friendsCache when we have a resolved name — inserting an empty + // key creates a phantom entry that masks the real one when the name arrives. + if (!playerName.empty()) { + if (data.status == 1 || data.status == 2) owner_.friendsCache[playerName] = data.guid; + else if (data.status == 0) owner_.friendsCache.erase(playerName); + } if (data.status == 0) { if (cit != owner_.contacts_.end())