Use XMPP Roster for BuddyList

This allows the same user to keep the buddy list across clients and
config resets. At the same time this allows for per lobby buddy lists
which is needed as the same nickname may refer to different people.

Use lower case comparison for buddy names. This is in line with the idea
of local part of jid should be seen as normalized nick and is used
server-side to compare user names.

The migration is kept simple. I.e. only attempted if the roster is
empty and the config indicates no migration was done before.

Fixes: #6824
Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
This commit is contained in:
Ralph Sennhauser committed 2026-10-19 20:31:27 +02:00
1 parent 72e12ddd6a
commit 830c97c521
16 files changed
+313 -65

No files matched your search

+8 -14
View File
@@ -118,9 +118,10 @@ static CStr DebugName(CNetServerSession* session)
CNetServerWorker::CNetServerWorker(const bool continueSavedGame, std::uint16_t port,
const bool useLobbyAuth, std::string password, std::string controllerSecret,
std::string initAttributes) :
std::string initAttributes, std::set<std::string> buddies) :
m_ContinuesSavedGame{continueSavedGame},
m_LobbyAuth{useLobbyAuth},
m_Buddies{std::move(buddies)},
m_ControllerSecret{std::move(controllerSecret)},
m_Password{std::move(password)}
{
@@ -1078,17 +1079,9 @@ bool CNetServerWorker::OnAuthenticate(CNetServerSession* session, CFsmEvent<CNet
}
else if (observerLateJoin == "buddies")
{
std::wstringstream buddiesStream(wstring_from_utf8(
g_ConfigDB.Get("lobby.buddies", std::string{})));
CStrW buddy;
while (std::getline(buddiesStream, buddy, L','))
{
if (buddy == usernameWithoutRating)
{
isRejoining = true;
break;
}
}
const std::string name{usernameWithoutRating.ToUTF8().LowerCase()};
if (server.m_Buddies.count(name) > 0)
isRejoining = true;
}
}
@@ -1695,9 +1688,10 @@ void CNetServerWorker::SendHolePunchingMessage(const CStr& ipStr, std::uint16_t
CNetServer::CNetServer(const bool continueSavedGame, std::uint16_t port, const bool useLobbyAuth,
std::string password, std::string controllerSecret, std::string initAttributes) :
std::string password, std::string controllerSecret, std::string initAttributes,
std::set<std::string> buddies) :
m_Worker{continueSavedGame, port, useLobbyAuth, password, std::move(controllerSecret),
std::move(initAttributes)},
std::move(initAttributes), std::move(buddies)},
m_LobbyAuth{useLobbyAuth},
m_Password{std::move(password)}
{