From 67fdc35ee63b953e664a0c7708562199d03f0db5 Mon Sep 17 00:00:00 2001 From: Ralph Sennhauser Date: Sun, 4 Oct 2026 21:54:30 +0200 Subject: [PATCH] Fix building with --without-lobby Ifdef what is needed to let the game compile and link without gloox. Signed-off-by: Ralph Sennhauser --- source/main.cpp | 2 ++ source/network/NetClient.cpp | 7 +++++++ source/network/NetClient.h | 5 +++++ source/network/scripting/JSInterface_Network.cpp | 10 +++++++++- source/ps/GameSetup/GameSetup.cpp | 2 ++ 5 files changed, 25 insertions(+), 1 deletion(-) diff --git a/source/main.cpp b/source/main.cpp index ea70a27169..2d41181560 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -439,8 +439,10 @@ static void Frame(RL::Interface* rlInterface, const int fixedFrameFrequency) } // Keep us connected to any XMPP servers +#if CONFIG2_LOBBY if (g_XmppClient) g_XmppClient->recv(); +#endif g_UserReporter.Update(); diff --git a/source/network/NetClient.cpp b/source/network/NetClient.cpp index 34f4e44c28..28bf52a3d4 100644 --- a/source/network/NetClient.cpp +++ b/source/network/NetClient.cpp @@ -20,6 +20,7 @@ #include "NetClient.h" #include "lib/byte_order.h" +#include "lib/config2.h" #include "lib/debug.h" #include "lib/external_libraries/enet.h" #include "lib/status.h" @@ -186,12 +187,14 @@ CNetClient::CNetClient(PrivateTag, CGame* game, std::string serverAddressOrHostn SetFirstState(NCS_UNCONNECTED); } +#if CONFIG2_LOBBY CNetClient::CNetClient(CGame* game, const CStrW& username, const CStr& hostJID, std::string hashedPassword, XmppClient& xmppClient) : CNetClient{PrivateTag{}, game, {}, 0, username, hostJID, std::move(hashedPassword)} { xmppClient.SendIqGetConnectionData(m_HostJID, m_Password, m_UserName.ToUTF8(), false); } +#endif // CONFIG2_LOBBY CNetClient::~CNetClient() { @@ -228,6 +231,7 @@ void CNetClient::HandleGetServerDataFailed(const CStr& error) ); } +#if CONFIG2_LOBBY bool CNetClient::TryToConnectWithSTUN(std::string serverAddressOrHostname, std::uint16_t serverPort, const CStr& hostJID, bool localNetwork) { @@ -333,6 +337,7 @@ bool CNetClient::TryToConnectWithSTUN(std::string serverAddressOrHostname, std:: return true; } +#endif // CONFIG2_LOBBY void CNetClient::SetAndOwnSession(CNetClientSession* session) @@ -756,9 +761,11 @@ bool CNetClient::OnHandshakeResponse(CNetClient* client, CFsmEvent if (message->m_Flags & PS_NETWORK_FLAG_REQUIRE_LOBBYAUTH) { +#if CONFIG2_LOBBY if (g_XmppClient && !client->m_HostJID.empty()) g_XmppClient->SendIqLobbyAuth(client->m_HostJID, client->m_GUID); else +#endif { client->PushGuiMessage( "type", "netstatus", diff --git a/source/network/NetClient.h b/source/network/NetClient.h index 521e86b8b5..7e2f2785fd 100644 --- a/source/network/NetClient.h +++ b/source/network/NetClient.h @@ -19,6 +19,7 @@ #define NETCLIENT_H #include "lib/code_annotation.h" +#include "lib/config2.h" #include "lib/external_libraries/enet.h" #include "network/FSM.h" #include "network/NetHost.h" @@ -87,8 +88,10 @@ public: * This constructor additionally requests connection information over the * lobby. */ +#if CONFIG2_LOBBY CNetClient(CGame* game, const CStrW& username, const CStr& hostJID, std::string hashedPassword, XmppClient& xmppClient); +#endif virtual ~CNetClient(); @@ -106,8 +109,10 @@ public: * @param localNetwork - if true, assume we are trying to connect on the local network. * @return true on success, false on connection failure */ +#if CONFIG2_LOBBY bool TryToConnectWithSTUN(std::string serverAddressOrHostname, std::uint16_t serverPort, const CStr& hostJID, bool localNetwork); +#endif /** * Destroy the connection to the server. diff --git a/source/network/scripting/JSInterface_Network.cpp b/source/network/scripting/JSInterface_Network.cpp index 62d13b9fa7..600e39569a 100644 --- a/source/network/scripting/JSInterface_Network.cpp +++ b/source/network/scripting/JSInterface_Network.cpp @@ -83,7 +83,11 @@ void StartNetworkHost(const CStrW& playerName, const std::uint16_t serverPort, c // Always use lobby authentication for lobby matches to prevent impersonation and smurfing, in particular through mods that implemented an UI for arbitrary or other players nicknames. const bool hasLobby = !!g_XmppClient; - const std::string hostJID{hasLobby ? g_XmppClient->GetJID() : ""}; + std::string hostJID; +#if CONFIG2_LOBBY + if (hasLobby) + hostJID = g_XmppClient->GetJID(); +#endif /** * Password security - we want 0 A.D. to protect players from malicious hosts. We assume that clients @@ -125,6 +129,7 @@ void StartNetworkJoin(const CStrW& playerName, const CStr& serverAddress, std::u g_NetClient = new CNetClient(g_Game, serverAddress, serverPort, playerName); } +#if CONFIG2_LOBBY /** * Requires XmppClient to send iq request to the server to get server's ip and port based on passed password. * This is needed to not force server to share it's public ip with all potential clients in the lobby. @@ -141,6 +146,7 @@ void StartNetworkJoinLobby(const CStrW& playerName, const CStr& hostJID, const C g_Game = new CGame(true); g_NetClient = new CNetClient(g_Game, playerName, hostJID, hashedPass, *g_XmppClient); } +#endif // CONFIG2_LOBBY void DisconnectNetworkGame() { @@ -294,7 +300,9 @@ void RegisterScriptFunctions(const Script::Request& rq) Script::Function::Register<&HasNetClient>(rq, "HasNetClient"); Script::Function::Register<&StartNetworkHost>(rq, "StartNetworkHost"); Script::Function::Register<&StartNetworkJoin>(rq, "StartNetworkJoin"); +#if CONFIG2_LOBBY Script::Function::Register<&StartNetworkJoinLobby>(rq, "StartNetworkJoinLobby"); +#endif Script::Function::Register<&DisconnectNetworkGame>(rq, "DisconnectNetworkGame"); Script::Function::Register<&GetPlayerGUID>(rq, "GetPlayerGUID"); Script::Function::Register<&PollNetworkClient>(rq, "PollNetworkClient"); diff --git a/source/ps/GameSetup/GameSetup.cpp b/source/ps/GameSetup/GameSetup.cpp index 957bca919e..17670d7698 100644 --- a/source/ps/GameSetup/GameSetup.cpp +++ b/source/ps/GameSetup/GameSetup.cpp @@ -331,7 +331,9 @@ void ShutdownNetworkAndUI() EndGame(); +#if CONFIG2_LOBBY SAFE_DELETE(g_XmppClient); +#endif SAFE_DELETE(g_ModIo);