Network cleanup.

Send the "client has rejoined" message after the synchronization
finished instead of right after the loading screen.
Patch by echotangoecho, refs #1949, #1950.

This was SVN commit r18203.
This commit is contained in:
elexis 2016-05-19 21:03:46 +00:00
parent 6f744aef88
commit 856dc1c999
5 changed files with 12 additions and 16 deletions

View File

@ -57,6 +57,7 @@
{"nick": "dumbo"},
{"nick": "dvangennip", "name": "Doménique"},
{"nick": "Echelon9", "name": "Rhys Kidd"},
{"nick": "echotangoecho"},
{"nick": "eihrul", "name": "Lee Salzman"},
{"nick": "elexis", "name": "Alexander Heinsius"},
{"nick": "EmjeR", "name": "Matthijs de Rijk"},

View File

@ -105,8 +105,4 @@ function reallyStartGame()
// Restore default cursor.
Engine.SetCursor("arrow-default");
// Notify the other clients that we have finished the loading screen
if (g_Data.isNetworked && g_Data.isRejoining)
Engine.SendNetworkRejoined();
}

View File

@ -458,13 +458,6 @@ void SendNetworkReady(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), int messag
g_NetClient->SendReadyMessage(message);
}
void SendNetworkRejoined(ScriptInterface::CxPrivate* UNUSED(pCxPrivate))
{
ENSURE(g_NetClient);
g_NetClient->SendRejoinedMessage();
}
JS::Value GetAIs(ScriptInterface::CxPrivate* pCxPrivate)
{
return ICmpAIManager::GetAIs(*(pCxPrivate->pScriptInterface));
@ -1052,7 +1045,6 @@ void GuiScriptingInit(ScriptInterface& scriptInterface)
scriptInterface.RegisterFunction<void, &ClearAllPlayerReady>("ClearAllPlayerReady");
scriptInterface.RegisterFunction<void, std::wstring, &SendNetworkChat>("SendNetworkChat");
scriptInterface.RegisterFunction<void, int, &SendNetworkReady>("SendNetworkReady");
scriptInterface.RegisterFunction<void, &SendNetworkRejoined>("SendNetworkRejoined");
scriptInterface.RegisterFunction<JS::Value, &GetAIs>("GetAIs");
scriptInterface.RegisterFunction<JS::Value, &GetEngineInfo>("GetEngineInfo");

View File

@ -72,7 +72,8 @@ CNetClient::CNetClient(CGame* game, bool isLocalClient) :
m_GUID(ps_generate_guid()), m_HostID((u32)-1), m_ClientTurnManager(NULL), m_Game(game),
m_GameAttributes(game->GetSimulation2()->GetScriptInterface().GetContext()),
m_IsLocalClient(isLocalClient),
m_LastConnectionCheck(0)
m_LastConnectionCheck(0),
m_Rejoin(false)
{
m_Game->SetTurnManager(NULL); // delete the old local turn manager so we don't accidentally use it
@ -487,13 +488,12 @@ bool CNetClient::OnAuthenticate(void* context, CFsmEvent* event)
LOGMESSAGE("Net: Authentication result: host=%u, %s", message->m_HostID, utf8_from_wstring(message->m_Message));
bool isRejoining = (message->m_Code == ARC_OK_REJOINING);
client->m_HostID = message->m_HostID;
client->m_Rejoin = message->m_Code == ARC_OK_REJOINING;
JS::RootedValue msg(cx);
client->GetScriptInterface().Eval("({'type':'netstatus','status':'authenticated'})", &msg);
client->GetScriptInterface().SetProperty(msg, "rejoining", isRejoining);
client->GetScriptInterface().SetProperty(msg, "rejoining", client->m_Rejoin);
client->PushGuiMessage(msg);
return true;
@ -743,6 +743,10 @@ bool CNetClient::OnLoadedGame(void* context, CFsmEvent* event)
client->GetScriptInterface().Eval("({'type':'netstatus','status':'active'})", &msg);
client->PushGuiMessage(msg);
// If we have rejoined an in progress game, send the rejoined message to the server.
if (client->m_Rejoin)
client->SendRejoinedMessage();
return true;
}

View File

@ -239,6 +239,9 @@ private:
/// Unique-per-game identifier of this client, used to identify the sender of simulation commands
u32 m_HostID;
/// True if the player is currently rejoining or has already rejoined the game.
bool m_Rejoin;
/// Whether to prevent the client of the host from timing out
bool m_IsLocalClient;