Simplify GUI g_IsNetworked variable init.
Just test if a NetClient is present rather than passing a state boolean
from GUI page to GUI page (since 1c0536bf08
or sooner).
This was SVN commit r21650.
This commit is contained in:
parent
4a9f15930f
commit
100be98215
@ -225,7 +225,7 @@ var g_TriggerDifficultyList;
|
||||
/**
|
||||
* Whether this is a single- or multiplayer match.
|
||||
*/
|
||||
var g_IsNetworked;
|
||||
const g_IsNetworked = Engine.HasNetClient();
|
||||
|
||||
/**
|
||||
* Is this user in control of game settings (i.e. singleplayer or host of a multiplayergame).
|
||||
@ -1106,7 +1106,6 @@ function init(attribs)
|
||||
return;
|
||||
}
|
||||
|
||||
g_IsNetworked = attribs.type != "offline";
|
||||
g_IsController = attribs.type != "client";
|
||||
g_IsTutorial = !!attribs.tutorial;
|
||||
g_ServerName = attribs.serverName;
|
||||
@ -1507,7 +1506,6 @@ function handleGamestartMessage(message)
|
||||
|
||||
Engine.SwitchGuiPage("page_loading.xml", {
|
||||
"attribs": g_GameAttributes,
|
||||
"isNetworked": g_IsNetworked,
|
||||
"playerAssignments": g_PlayerAssignments,
|
||||
"isController": g_IsController
|
||||
});
|
||||
@ -2237,7 +2235,6 @@ function launchGame()
|
||||
Engine.StartGame(g_GameAttributes, playerID);
|
||||
Engine.SwitchGuiPage("page_loading.xml", {
|
||||
"attribs": g_GameAttributes,
|
||||
"isNetworked": g_IsNetworked,
|
||||
"playerAssignments": g_PlayerAssignments
|
||||
});
|
||||
}
|
||||
|
@ -197,7 +197,6 @@ function pollAndHandleNetworkClient()
|
||||
|
||||
Engine.SwitchGuiPage("page_loading.xml", {
|
||||
"attribs": g_GameAttributes,
|
||||
"isNetworked": true,
|
||||
"isRejoining": g_IsRejoining,
|
||||
"playerAssignments": g_PlayerAssignments
|
||||
});
|
||||
|
@ -191,7 +191,6 @@ function reallyLoadGame(gameId)
|
||||
|
||||
Engine.SwitchGuiPage("page_loading.xml", {
|
||||
"attribs": metadata.initAttributes,
|
||||
"isNetworked": false,
|
||||
"playerAssignments": {
|
||||
"local": {
|
||||
"name": pData ? pData.Name : singleplayerName(),
|
||||
|
@ -65,7 +65,6 @@ function reallyStartVisualReplay(replayDirectory)
|
||||
|
||||
Engine.SwitchGuiPage("page_loading.xml", {
|
||||
"attribs": Engine.GetReplayAttributes(replayDirectory),
|
||||
"isNetworked": false,
|
||||
"playerAssignments": {
|
||||
"local": {
|
||||
"name": singleplayerName(),
|
||||
|
@ -52,7 +52,7 @@ var g_IsController;
|
||||
/**
|
||||
* True if this is a multiplayer game.
|
||||
*/
|
||||
var g_IsNetworked = false;
|
||||
const g_IsNetworked = Engine.HasNetClient();
|
||||
|
||||
/**
|
||||
* Whether we have finished the synchronization and
|
||||
@ -263,7 +263,6 @@ function init(initData, hotloadData)
|
||||
|
||||
if (initData)
|
||||
{
|
||||
g_IsNetworked = initData.isNetworked;
|
||||
g_IsController = initData.isController;
|
||||
g_PlayerAssignments = initData.playerAssignments;
|
||||
g_ReplaySelectionData = initData.replaySelectionData;
|
||||
|
@ -487,7 +487,6 @@ function startReplay()
|
||||
|
||||
Engine.SwitchGuiPage("page_loading.xml", {
|
||||
"attribs": Engine.GetReplayAttributes(g_GameData.gui.replayDirectory),
|
||||
"isNetworked": false,
|
||||
"playerAssignments": {
|
||||
"local": {
|
||||
"name": singleplayerName(),
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2017 Wildfire Games.
|
||||
/* Copyright (C) 2018 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -34,6 +34,11 @@ u16 JSI_Network::GetDefaultPort(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
|
||||
return PS_DEFAULT_PORT;
|
||||
}
|
||||
|
||||
bool JSI_Network::HasNetClient(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
|
||||
{
|
||||
return !!g_NetClient;
|
||||
}
|
||||
|
||||
JS::Value JSI_Network::FindStunEndpoint(ScriptInterface::CxPrivate* pCxPrivate, int port)
|
||||
{
|
||||
return StunClient::FindStunEndpointHost(*(pCxPrivate->pScriptInterface), port);
|
||||
@ -214,6 +219,7 @@ void JSI_Network::SetTurnLength(ScriptInterface::CxPrivate* UNUSED(pCxPrivate),
|
||||
void JSI_Network::RegisterScriptFunctions(const ScriptInterface& scriptInterface)
|
||||
{
|
||||
scriptInterface.RegisterFunction<u16, &GetDefaultPort>("GetDefaultPort");
|
||||
scriptInterface.RegisterFunction<bool, &HasNetClient>("HasNetClient");
|
||||
scriptInterface.RegisterFunction<JS::Value, int, &FindStunEndpoint>("FindStunEndpoint");
|
||||
scriptInterface.RegisterFunction<void, CStrW, u16, CStr, bool, &StartNetworkHost>("StartNetworkHost");
|
||||
scriptInterface.RegisterFunction<void, CStrW, CStr, u16, bool, CStr, &StartNetworkJoin>("StartNetworkJoin");
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2017 Wildfire Games.
|
||||
/* Copyright (C) 2018 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -24,6 +24,7 @@
|
||||
namespace JSI_Network
|
||||
{
|
||||
u16 GetDefaultPort(ScriptInterface::CxPrivate* pCxPrivate);
|
||||
bool HasNetClient(ScriptInterface::CxPrivate* pCxPrivate);
|
||||
void StartNetworkGame(ScriptInterface::CxPrivate* pCxPrivate);
|
||||
void SetNetworkGameAttributes(ScriptInterface::CxPrivate* pCxPrivate, JS::HandleValue attribs1);
|
||||
void StartNetworkHost(ScriptInterface::CxPrivate* pCxPrivate, const CStrW& playerName, const u16 serverPort, const CStr& hostLobbyName, bool useLobbyAuth);
|
||||
|
Loading…
Reference in New Issue
Block a user