Index: build/premake/premake5.lua
===================================================================
--- build/premake/premake5.lua
+++ build/premake/premake5.lua
@@ -641,18 +641,6 @@
setup_static_lib_project("glooxwrapper", source_dirs, extern_libs, {})
end
end
- else
- source_dirs = {
- "lobby/scripting",
- "third_party/encryption"
- }
- extern_libs = {
- "spidermonkey",
- "boost",
- "libsodium"
- }
- setup_static_lib_project("lobby", source_dirs, extern_libs, {})
- files { source_root.."lobby/Globals.cpp" }
end
@@ -1320,8 +1308,10 @@
local test_files = {}
for i,v in pairs(all_files) do
-- Don't include sysdep tests on the wrong sys
+ -- Don't include pbkdf2 tests unless pbkdf2/lobby is being built
-- Don't include Atlas tests unless Atlas is being built
if not (string.find(v, "/sysdep/os/win/") and not os.istarget("windows")) and
+ not (string.find(v, "/third_party/encryption/") and _OPTIONS["without-lobby"]) and
not (string.find(v, "/tools/atlas/") and not _OPTIONS["atlas"]) and
not (string.find(v, "/sysdep/arch/x86_x64/") and ((arch ~= "amd64") or (arch ~= "x86")))
then
Index: source/graphics/GameView.cpp
===================================================================
--- source/graphics/GameView.cpp
+++ source/graphics/GameView.cpp
@@ -37,7 +37,9 @@
#include "graphics/scripting/JSInterface_GameView.h"
#include "lib/input.h"
#include "lib/timer.h"
+#if CONFIG2_LOBBY
#include "lobby/IXmppClient.h"
+#endif
#include "maths/BoundingBoxAligned.h"
#include "maths/MathUtil.h"
#include "maths/Matrix3D.h"
@@ -1039,9 +1041,11 @@
if (hotkey == "wireframe")
{
+#if CONFIG2_LOBBY
if (g_XmppClient && g_rankedGame == true)
break;
- else if (g_Renderer.GetModelRenderMode() == SOLID)
+#endif
+ if (g_Renderer.GetModelRenderMode() == SOLID)
{
g_Renderer.SetTerrainRenderMode(EDGED_FACES);
g_Renderer.SetWaterRenderMode(EDGED_FACES);
Index: source/gui/scripting/ScriptFunctions.cpp
===================================================================
--- source/gui/scripting/ScriptFunctions.cpp
+++ source/gui/scripting/ScriptFunctions.cpp
@@ -1,4 +1,4 @@
-/* Copyright (C) 2018 Wildfire Games.
+/* Copyright (C) 2019 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@@ -24,7 +24,9 @@
#include "gui/scripting/JSInterface_GUIManager.h"
#include "gui/scripting/JSInterface_GUITypes.h"
#include "i18n/scripting/JSInterface_L10n.h"
+#if CONFIG2_LOBBY
#include "lobby/scripting/JSInterface_Lobby.h"
+#endif
#include "network/scripting/JSInterface_Network.h"
#include "ps/scripting/JSInterface_ConfigDB.h"
#include "ps/scripting/JSInterface_Console.h"
@@ -59,7 +61,9 @@
JSI_Game::RegisterScriptFunctions(scriptInterface);
JSI_GameView::RegisterScriptFunctions(scriptInterface);
JSI_L10n::RegisterScriptFunctions(scriptInterface);
+#if CONFIG2_LOBBY
JSI_Lobby::RegisterScriptFunctions(scriptInterface);
+#endif
JSI_Main::RegisterScriptFunctions(scriptInterface);
JSI_Mod::RegisterScriptFunctions(scriptInterface);
JSI_ModIo::RegisterScriptFunctions(scriptInterface);
Index: source/lobby/Globals.cpp
===================================================================
--- source/lobby/Globals.cpp
+++ source/lobby/Globals.cpp
@@ -1,4 +1,4 @@
-/* Copyright (C) 2013 Wildfire Games.
+/* Copyright (C) 2019 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@@ -15,9 +15,13 @@
* along with 0 A.D. If not, see .
*/
+#if CONFIG2_LOBBY
+
#include "precompiled.h"
#include "IXmppClient.h"
IXmppClient *g_XmppClient = NULL;
bool g_rankedGame = false;
+
+#endif // CONFIG2_LOBBY
Index: source/lobby/IXmppClient.h
===================================================================
--- source/lobby/IXmppClient.h
+++ source/lobby/IXmppClient.h
@@ -15,6 +15,8 @@
* along with 0 A.D. If not, see .
*/
+#if CONFIG2_LOBBY
+
#ifndef IXMPPCLIENT_H
#define IXMPPCLIENT_H
@@ -67,3 +69,4 @@
extern bool g_rankedGame;
#endif // XMPPCLIENT_H
+#endif // CONFIG2_LOBBY
Index: source/lobby/StanzaExtensions.h
===================================================================
--- source/lobby/StanzaExtensions.h
+++ source/lobby/StanzaExtensions.h
@@ -14,6 +14,8 @@
* You should have received a copy of the GNU General Public License
* along with 0 A.D. If not, see .
*/
+#if CONFIG2_LOBBY
+
#ifndef STANZAEXTENSIONS_H
#define STANZAEXTENSIONS_H
@@ -133,3 +135,4 @@
glooxwrapper::string m_Token;
};
#endif // STANZAEXTENSIONS_H
+#endif // CONFIG2_LOBBY
Index: source/lobby/StanzaExtensions.cpp
===================================================================
--- source/lobby/StanzaExtensions.cpp
+++ source/lobby/StanzaExtensions.cpp
@@ -14,6 +14,9 @@
* You should have received a copy of the GNU General Public License
* along with 0 A.D. If not, see .
*/
+
+#if CONFIG2_LOBBY
+
#include "precompiled.h"
#include "StanzaExtensions.h"
@@ -283,3 +286,5 @@
{
return new LobbyAuth();
}
+
+#endif // CONFIG2_LOBBY
Index: source/lobby/XmppClient.h
===================================================================
--- source/lobby/XmppClient.h
+++ source/lobby/XmppClient.h
@@ -15,8 +15,10 @@
* along with 0 A.D. If not, see .
*/
-#ifndef XXXMPPCLIENT_H
-#define XXXMPPCLIENT_H
+#if CONFIG2_LOBBY
+
+#ifndef XMPPCLIENT_H
+#define XMPPCLIENT_H
#include "IXmppClient.h"
@@ -183,3 +185,4 @@
};
#endif // XMPPCLIENT_H
+#endif // CONFIG2_LOBBY
Index: source/lobby/XmppClient.cpp
===================================================================
--- source/lobby/XmppClient.cpp
+++ source/lobby/XmppClient.cpp
@@ -15,6 +15,8 @@
* along with 0 A.D. If not, see .
*/
+#if CONFIG2_LOBBY
+
#include "precompiled.h"
#include "XmppClient.h"
@@ -1285,3 +1287,5 @@
g_NetServer->SendHolePunchingMessage(candidate.ip.to_string(), candidate.port);
}
+
+#endif CONFIG2_LOBBY
Index: source/lobby/glooxwrapper/glooxwrapper.h
===================================================================
--- source/lobby/glooxwrapper/glooxwrapper.h
+++ source/lobby/glooxwrapper/glooxwrapper.h
@@ -15,6 +15,8 @@
* along with 0 A.D. If not, see .
*/
+// CONFIG2_LOBBY check unnecessary, premake decides whether to include this
+
#ifndef INCLUDED_GLOOXWRAPPER_H
#define INCLUDED_GLOOXWRAPPER_H
Index: source/lobby/scripting/JSInterface_Lobby.h
===================================================================
--- source/lobby/scripting/JSInterface_Lobby.h
+++ source/lobby/scripting/JSInterface_Lobby.h
@@ -19,6 +19,9 @@
#define INCLUDED_JSI_LOBBY
#include "lib/config2.h"
+
+#if CONFIG2_LOBBY
+
#include "scriptinterface/ScriptInterface.h"
#include
@@ -30,8 +33,6 @@
bool HasXmppClient(ScriptInterface::CxPrivate* pCxPrivate);
bool IsRankedGame(ScriptInterface::CxPrivate* pCxPrivate);
void SetRankedGame(ScriptInterface::CxPrivate* pCxPrivate, bool isRanked);
-
-#if CONFIG2_LOBBY
void StartXmppClient(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& username, const std::wstring& password, const std::wstring& room, const std::wstring& nick, int historyRequestSize);
void StartRegisterXmppClient(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& username, const std::wstring& password);
void StopXmppClient(ScriptInterface::CxPrivate* pCxPrivate);
@@ -66,7 +67,8 @@
// Public hash interface.
std::wstring EncryptPassword(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& pass, const std::wstring& user);
-#endif // CONFIG2_LOBBY
}
+#endif // CONFIG2_LOBBY
+
#endif // INCLUDED_JSI_LOBBY
Index: source/lobby/scripting/JSInterface_Lobby.cpp
===================================================================
--- source/lobby/scripting/JSInterface_Lobby.cpp
+++ source/lobby/scripting/JSInterface_Lobby.cpp
@@ -15,13 +15,17 @@
* along with 0 A.D. If not, see .
*/
+#if CONFIG2_LOBBY
+
#include "precompiled.h"
#include "JSInterface_Lobby.h"
#include "gui/GUIManager.h"
#include "lib/utf8.h"
+#if CONFIG2_LOBBY
#include "lobby/IXmppClient.h"
+#endif
#include "network/NetServer.h"
#include "ps/CLogger.h"
#include "ps/CStr.h"
@@ -39,7 +43,6 @@
scriptInterface.RegisterFunction("HasXmppClient");
scriptInterface.RegisterFunction("IsRankedGame");
scriptInterface.RegisterFunction("SetRankedGame");
-#if CONFIG2_LOBBY // Allow the lobby to be disabled
scriptInterface.RegisterFunction("StartXmppClient");
scriptInterface.RegisterFunction("StartRegisterXmppClient");
scriptInterface.RegisterFunction("StopXmppClient");
@@ -69,7 +72,6 @@
scriptInterface.RegisterFunction("LobbyGetPlayerRole");
scriptInterface.RegisterFunction("EncryptPassword");
scriptInterface.RegisterFunction("LobbyGetRoomSubject");
-#endif // CONFIG2_LOBBY
}
bool JSI_Lobby::HasXmppClient(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
@@ -87,8 +89,6 @@
g_rankedGame = isRanked;
}
-#if CONFIG2_LOBBY
-
void JSI_Lobby::StartXmppClient(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::wstring& username, const std::wstring& password, const std::wstring& room, const std::wstring& nick, int historyRequestSize)
{
ENSURE(!g_XmppClient);
@@ -386,4 +386,4 @@
return wstring_from_utf8(subject);
}
-#endif
+#endif // CONFIG2_LOBBY
Index: source/main.cpp
===================================================================
--- source/main.cpp
+++ source/main.cpp
@@ -70,7 +70,9 @@
#include "network/NetClient.h"
#include "network/NetServer.h"
#include "network/NetSession.h"
+#if CONFIG2_LOBBY
#include "lobby/IXmppClient.h"
+#endif
#include "graphics/Camera.h"
#include "graphics/GameView.h"
#include "graphics/TextureManager.h"
@@ -399,9 +401,11 @@
if (g_NetClient)
g_NetClient->Flush();
+#if CONFIG2_LOBBY
// Keep us connected to any XMPP servers
if (g_XmppClient)
g_XmppClient->recv();
+#endif
g_UserReporter.Update();
Index: source/network/NetClient.cpp
===================================================================
--- source/network/NetClient.cpp
+++ source/network/NetClient.cpp
@@ -26,7 +26,9 @@
#include "lib/byte_order.h"
#include "lib/external_libraries/enet.h"
#include "lib/sysdep/sysdep.h"
+#if CONFIG2_LOBBY
#include "lobby/IXmppClient.h"
+#endif
#include "ps/CConsole.h"
#include "ps/CLogger.h"
#include "ps/Compress.h"
@@ -517,17 +519,15 @@
if (message->m_Flags & PS_NETWORK_FLAG_REQUIRE_LOBBYAUTH)
{
+#if CONFIG2_LOBBY
if (g_XmppClient && !client->m_HostingPlayerName.empty())
g_XmppClient->SendIqLobbyAuth(client->m_HostingPlayerName, client->m_GUID);
else
{
- client->PushGuiMessage(
- "type", "netstatus",
- "status", "disconnected",
- "reason", static_cast(NDR_LOBBY_AUTH_FAILED));
-
+ HandleDisconnect(NDR_LOBBY_AUTH_FAILED);
LOGMESSAGE("Net client: Couldn't send lobby auth xmpp message");
}
+#endif // CONFIG2_LOBBY
return true;
}
Index: source/network/scripting/JSInterface_Network.cpp
===================================================================
--- source/network/scripting/JSInterface_Network.cpp
+++ source/network/scripting/JSInterface_Network.cpp
@@ -22,7 +22,9 @@
#include "lib/external_libraries/enet.h"
#include "lib/external_libraries/libsdl.h"
#include "lib/types.h"
+#if CONFIG2_LOBBY
#include "lobby/IXmppClient.h"
+#endif
#include "network/NetClient.h"
#include "network/NetMessage.h"
#include "network/NetServer.h"
@@ -57,8 +59,13 @@
ENSURE(!g_NetServer);
ENSURE(!g_Game);
+#if CONFIG2_LOBBY
// 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.
g_NetServer = new CNetServer(static_cast(g_XmppClient));
+#else
+ g_NetServer = new CNetServer(false);
+#endif
+
if (!g_NetServer->SetupConnection(serverPort))
{
pCxPrivate->pScriptInterface->ReportError("Failed to start server");
@@ -86,6 +93,8 @@
ENSURE(!g_Game);
ENetHost* enetClient = nullptr;
+
+#if CONFIG2_LOBBY
if (g_XmppClient && useSTUN)
{
// Find an unused port
@@ -115,14 +124,20 @@
SDL_Delay(1000);
}
+#else
+ if (useSTUN)
+ LOGERROR("STUN cannot be used without lobby implementation!");
+#endif // CONFIG2_LOBBY
g_Game = new CGame(true);
g_NetClient = new CNetClient(g_Game, false);
g_NetClient->SetUserName(playerName);
g_NetClient->SetHostingPlayerName(hostJID.substr(0, hostJID.find("@")));
+#if CONFIG2_LOBBY
if (g_XmppClient && useSTUN)
StunClient::SendHolePunchingMessages(*enetClient, serverAddress, serverPort);
+#endif
if (!g_NetClient->SetupConnection(serverAddress, serverPort, enetClient))
{
Index: source/ps/GameSetup/GameSetup.cpp
===================================================================
--- source/ps/GameSetup/GameSetup.cpp
+++ source/ps/GameSetup/GameSetup.cpp
@@ -81,7 +81,9 @@
#include "scriptinterface/ScriptConversions.h"
#include "scriptinterface/ScriptRuntime.h"
#include "simulation2/Simulation2.h"
+#if CONFIG2_LOBBY
#include "lobby/IXmppClient.h"
+#endif
#include "soundmanager/scripting/JSInterface_Sound.h"
#include "soundmanager/ISoundManager.h"
#include "tools/atlas/GameInterface/GameLoop.h"
@@ -720,7 +722,9 @@
EndGame();
+#if CONFIG2_LOBBY
SAFE_DELETE(g_XmppClient);
+#endif
SAFE_DELETE(g_ModIo);