Fix building with --without-lobby

Ifdef what is needed to let the game compile and link without gloox.

Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
This commit is contained in:
Ralph Sennhauser committed 2026-10-07 13:16:50 +02:00
1 parent ccd7481e5c
commit 67fdc35ee6
5 files changed
+25 -1

No files matched your search

+2
View File
@@ -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();
+7
View File
@@ -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<CNetMessage*>
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",
+5
View File
@@ -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.
@@ -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");
+2
View File
@@ -331,7 +331,9 @@ void ShutdownNetworkAndUI()
EndGame();
#if CONFIG2_LOBBY
SAFE_DELETE(g_XmppClient);
#endif
SAFE_DELETE(g_ModIo);