forked from 0ad/0ad
Fix building with --without-lobby. Fixes #2249.
This was SVN commit r14113.
This commit is contained in:
parent
0f8d3e23db
commit
81cf02cc13
@ -398,7 +398,7 @@ function handleNetMessage(message)
|
||||
break;
|
||||
|
||||
case "start":
|
||||
if (g_IsController)
|
||||
if (g_IsController && Engine.HasXmppClient())
|
||||
{
|
||||
var players = [ assignment.name for each (assignment in g_PlayerAssignments) ]
|
||||
Engine.SendChangeStateGame(Object.keys(g_PlayerAssignments).length, players.join(", "));
|
||||
@ -588,13 +588,14 @@ function cancelSetup()
|
||||
{
|
||||
Engine.DisconnectNetworkGame();
|
||||
|
||||
// Set player presence
|
||||
Engine.LobbySetPlayerPresence("available");
|
||||
|
||||
if(g_IsController)
|
||||
if (Engine.HasXmppClient())
|
||||
{
|
||||
// Set player presence
|
||||
Engine.LobbySetPlayerPresence("available");
|
||||
|
||||
// Unregister the game
|
||||
Engine.SendUnregisterGame();
|
||||
if (g_IsController)
|
||||
Engine.SendUnregisterGame();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1526,6 +1527,9 @@ function keywordTestOR(keywords, matches)
|
||||
|
||||
function sendRegisterGameStanza()
|
||||
{
|
||||
if (!Engine.HasXmppClient())
|
||||
return;
|
||||
|
||||
var selectedMapSize = getGUIObjectByName("mapSize").selected;
|
||||
var selectedVictoryCondition = getGUIObjectByName("victoryCondition").selected;
|
||||
|
||||
|
@ -45,7 +45,8 @@ function cancelSetup()
|
||||
if (g_IsConnecting)
|
||||
Engine.DisconnectNetworkGame();
|
||||
// Set player lobby presence
|
||||
Engine.LobbySetPlayerPresence("available");
|
||||
if (Engine.HasXmppClient())
|
||||
Engine.LobbySetPlayerPresence("available");
|
||||
Engine.PopGuiPage();
|
||||
}
|
||||
|
||||
@ -200,7 +201,8 @@ function startHost(playername, servername)
|
||||
startConnectionStatus("server");
|
||||
g_ServerName = servername;
|
||||
// Set player lobby presence
|
||||
Engine.LobbySetPlayerPresence("playing");
|
||||
if (Engine.HasXmppClient())
|
||||
Engine.LobbySetPlayerPresence("playing");
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -221,6 +223,7 @@ function startJoin(playername, ip)
|
||||
|
||||
startConnectionStatus("client");
|
||||
// Set player lobby presence
|
||||
Engine.LobbySetPlayerPresence("playing");
|
||||
if (Engine.HasXmppClient())
|
||||
Engine.LobbySetPlayerPresence("playing");
|
||||
return true;
|
||||
}
|
||||
|
@ -420,6 +420,9 @@ function openManual()
|
||||
|
||||
function toggleDeveloperOverlay()
|
||||
{
|
||||
if (Engine.HasXmppClient() && Engine.IsRankedGame())
|
||||
return;
|
||||
|
||||
var devCommands = getGUIObjectByName("devCommands");
|
||||
var text = devCommands.hidden ? "opened." : "closed.";
|
||||
submitChatDirectly("The Developer Overlay was " + text);
|
||||
|
@ -258,10 +258,9 @@ function leaveGame()
|
||||
stopAmbient();
|
||||
endGame();
|
||||
|
||||
if (g_IsController)
|
||||
{
|
||||
if (g_IsController && Engine.HasXmppClient())
|
||||
Engine.SendUnregisterGame();
|
||||
}
|
||||
|
||||
Engine.SwitchGuiPage("page_summary.xml", {
|
||||
"gameResult" : gameResult,
|
||||
"timeElapsed" : extendedSimState.timeElapsed,
|
||||
@ -700,6 +699,9 @@ function stopAmbient()
|
||||
// Send a report on the game status to the lobby
|
||||
function reportGame(extendedSimState)
|
||||
{
|
||||
if (!Engine.HasXmppClient())
|
||||
return;
|
||||
|
||||
// Resources gathered and used
|
||||
var playerFoodGatheredString = "";
|
||||
var playerWoodGatheredString = "";
|
||||
|
@ -247,9 +247,7 @@
|
||||
<!-- Dev/cheat commands -->
|
||||
<object name="devCommands" size="100%-156 50%-88 100%-8 50%+104" type="image" sprite="devCommandsBackground" z="40"
|
||||
hidden="true" hotkey="session.devcommands.toggle">
|
||||
<action on="Press">
|
||||
if (!Engine.IsRankedGame()) toggleDeveloperOverlay();
|
||||
</action>
|
||||
<action on="Press">toggleDeveloperOverlay();</action>
|
||||
|
||||
<object size="0 0 100%-18 16" type="text" style="devCommandsText">Control all units</object>
|
||||
<object size="100%-16 0 100% 16" type="checkbox" name="devControlAll" style="StoneCrossBox">
|
||||
@ -537,7 +535,10 @@
|
||||
<!-- Settings / Dev Overlay -->
|
||||
<object size="0 310 100%-80 335" type="text" style="RightLabelText" ghost="true">Developer Overlay</object>
|
||||
<object name="developerOverlayCheckbox" size="100%-56 315 100%-30 340" type="checkbox" style="StoneCrossBox" checked="false">
|
||||
<action on="Load">if (Engine.IsRankedGame()) this.enabled = false;</action>
|
||||
<action on="Load"><![CDATA[
|
||||
if (Engine.HasXmppClient() && Engine.IsRankedGame())
|
||||
this.enabled = false;
|
||||
]]></action>
|
||||
<action on="Press">toggleDeveloperOverlay();</action>
|
||||
</object>
|
||||
</object>
|
||||
|
@ -574,6 +574,7 @@ function setup_all_libs ()
|
||||
}
|
||||
setup_static_lib_project("network", source_dirs, extern_libs, {})
|
||||
|
||||
|
||||
if not _OPTIONS["without-lobby"] then
|
||||
source_dirs = {
|
||||
"lobby",
|
||||
@ -585,25 +586,29 @@ function setup_all_libs ()
|
||||
"gloox",
|
||||
}
|
||||
setup_static_lib_project("lobby", source_dirs, extern_libs, {})
|
||||
|
||||
if _OPTIONS["use-shared-glooxwrapper"] and not _OPTIONS["build-shared-glooxwrapper"] then
|
||||
table.insert(static_lib_names_debug, "glooxwrapper_dbg")
|
||||
table.insert(static_lib_names_release, "glooxwrapper")
|
||||
else
|
||||
source_dirs = {
|
||||
"lobby/glooxwrapper",
|
||||
}
|
||||
extern_libs = {
|
||||
"boost",
|
||||
"gloox",
|
||||
}
|
||||
if _OPTIONS["build-shared-glooxwrapper"] then
|
||||
setup_shared_lib_project("glooxwrapper", source_dirs, extern_libs, {})
|
||||
else
|
||||
setup_static_lib_project("glooxwrapper", source_dirs, extern_libs, {})
|
||||
end
|
||||
end
|
||||
else
|
||||
setup_static_lib_project("lobby", {}, {}, {})
|
||||
files { source_root.."lobby/Globals.cpp" }
|
||||
end
|
||||
|
||||
if _OPTIONS["use-shared-glooxwrapper"] and not _OPTIONS["build-shared-glooxwrapper"] then
|
||||
table.insert(static_lib_names_debug, "glooxwrapper_dbg")
|
||||
table.insert(static_lib_names_release, "glooxwrapper")
|
||||
else
|
||||
source_dirs = {
|
||||
"lobby/glooxwrapper",
|
||||
}
|
||||
extern_libs = {
|
||||
"boost",
|
||||
"gloox",
|
||||
}
|
||||
if _OPTIONS["build-shared-glooxwrapper"] then
|
||||
setup_shared_lib_project("glooxwrapper", source_dirs, extern_libs, {})
|
||||
else
|
||||
setup_static_lib_project("glooxwrapper", source_dirs, extern_libs, {})
|
||||
end
|
||||
end
|
||||
|
||||
source_dirs = {
|
||||
"simulation2",
|
||||
@ -685,6 +690,7 @@ function setup_all_libs ()
|
||||
end
|
||||
setup_static_lib_project("graphics", source_dirs, extern_libs, {})
|
||||
|
||||
|
||||
source_dirs = {
|
||||
"tools/atlas/GameInterface",
|
||||
"tools/atlas/GameInterface/Handlers"
|
||||
|
@ -27,6 +27,8 @@
|
||||
#include "lib/timer.h"
|
||||
#include "lib/utf8.h"
|
||||
#include "lib/sysdep/sysdep.h"
|
||||
#include "lobby/IXmppClient.h"
|
||||
#include "lobby/sha.h"
|
||||
#include "maths/FixedVector3D.h"
|
||||
#include "network/NetClient.h"
|
||||
#include "network/NetServer.h"
|
||||
@ -50,8 +52,6 @@
|
||||
#include "ps/ConfigDB.h"
|
||||
#include "renderer/scripting/JSInterface_Renderer.h"
|
||||
#include "tools/atlas/GameInterface/GameLoop.h"
|
||||
#include "lobby/IXmppClient.h"
|
||||
#include "lobby/sha.h"
|
||||
|
||||
#include "simulation2/Simulation2.h"
|
||||
#include "simulation2/components/ICmpAIManager.h"
|
||||
@ -615,6 +615,11 @@ void RewindTimeWarp(void* UNUSED(cbdata))
|
||||
|
||||
/* Begin lobby related functions */
|
||||
|
||||
bool HasXmppClient(void* UNUSED(cbdata))
|
||||
{
|
||||
return (g_XmppClient ? true : false);
|
||||
}
|
||||
|
||||
void StartXmppClient(void* cbdata, std::string sUsername, std::string sPassword, std::string sRoom, std::string sNick)
|
||||
{
|
||||
CGUIManager* guiManager = static_cast<CGUIManager*> (cbdata);
|
||||
@ -634,11 +639,6 @@ void StartRegisterXmppClient(void* cbdata, std::string sUsername, std::string sP
|
||||
g_XmppClient = IXmppClient::create(guiManager->GetScriptInterface(), sUsername, sPassword, "", "", true);
|
||||
}
|
||||
|
||||
bool HasXmppClient(void* UNUSED(cbdata))
|
||||
{
|
||||
return (g_XmppClient ? true : false);
|
||||
}
|
||||
|
||||
void StopXmppClient(void* UNUSED(cbdata))
|
||||
{
|
||||
ENSURE(g_XmppClient);
|
||||
@ -964,11 +964,11 @@ void GuiScriptingInit(ScriptInterface& scriptInterface)
|
||||
scriptInterface.RegisterFunction<void, &RewindTimeWarp>("RewindTimeWarp");
|
||||
scriptInterface.RegisterFunction<void, bool, &SetBoundingBoxDebugOverlay>("SetBoundingBoxDebugOverlay");
|
||||
|
||||
#if CONFIG2_LOBBY // Allow the lobby to be disabled
|
||||
// Lobby functions
|
||||
scriptInterface.RegisterFunction<bool, &HasXmppClient>("HasXmppClient");
|
||||
#if CONFIG2_LOBBY // Allow the lobby to be disabled
|
||||
scriptInterface.RegisterFunction<void, std::string, std::string, std::string, std::string, &StartXmppClient>("StartXmppClient");
|
||||
scriptInterface.RegisterFunction<void, std::string, std::string, &StartRegisterXmppClient>("StartRegisterXmppClient");
|
||||
scriptInterface.RegisterFunction<bool, &HasXmppClient>("HasXmppClient");
|
||||
scriptInterface.RegisterFunction<void, &StopXmppClient>("StopXmppClient");
|
||||
scriptInterface.RegisterFunction<void, &ConnectXmppClient>("ConnectXmppClient");
|
||||
scriptInterface.RegisterFunction<void, &DisconnectXmppClient>("DisconnectXmppClient");
|
||||
|
23
source/lobby/Globals.cpp
Normal file
23
source/lobby/Globals.cpp
Normal file
@ -0,0 +1,23 @@
|
||||
/* Copyright (C) 2013 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* 0 A.D. is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "precompiled.h"
|
||||
|
||||
#include "IXmppClient.h"
|
||||
|
||||
IXmppClient *g_XmppClient = NULL;
|
||||
bool g_rankedGame = false;
|
@ -33,10 +33,6 @@
|
||||
// Configuration
|
||||
#include "ps/ConfigDB.h"
|
||||
|
||||
//global
|
||||
IXmppClient *g_XmppClient = NULL;
|
||||
bool g_rankedGame = false;
|
||||
|
||||
//debug
|
||||
#if 1
|
||||
#define DbgXMPP(x)
|
||||
|
@ -685,9 +685,7 @@ void Shutdown(int UNUSED(flags))
|
||||
{
|
||||
EndGame();
|
||||
|
||||
#if CONFIG2_LOBBY
|
||||
SAFE_DELETE(g_XmppClient);
|
||||
#endif
|
||||
SAFE_DELETE(g_XmppClient);
|
||||
|
||||
ShutdownPs(); // Must delete g_GUI before g_ScriptingHost
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user