Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge remote-tracking branch 'remotes/trunk'

  • Loading branch information...
commit d83218b34862bb94a600250b23067770d7229c9b 2 parents f131211 + 5afc958
Kieran Pilkington KieranP authored
6 binaries/data/mods/public/gui/session/messages.js
View
@@ -118,6 +118,10 @@ function handleNetMessage(message)
switch (message.type)
{
case "netstatus":
+ // If we lost connection, further netstatus messages are useless
+ if (g_Disconnected)
+ return;
+
var obj = getGUIObjectByName("netStatus");
switch (message.status)
{
@@ -142,9 +146,9 @@ function handleNetMessage(message)
obj.hidden = false;
break;
case "disconnected":
+ g_Disconnected = true;
obj.caption = "Connection to the server has been lost.\n\nThe game has ended.";
obj.hidden = false;
- getGUIObjectByName("disconnectedExitButton").hidden = false;
break;
default:
error("Unrecognised netstatus type "+message.status);
10 binaries/data/mods/public/gui/session/session.js
View
@@ -26,6 +26,8 @@ var g_EntityStates = {}; // {id:entState}
// Whether the player has lost/won and reached the end of their game
var g_GameEnded = false;
+var g_Disconnected = false; // Lost connection to server
+
// Colors to flash when pop limit reached
const DEFAULT_POPULATION_COLOR = "white";
const POPULATION_ALERT_COLOR = "orange";
@@ -148,7 +150,7 @@ function resignGame()
var simState = Engine.GuiInterfaceCall("GetSimulationState");
// Players can't resign if they've already won or lost.
- if (simState.players[Engine.GetPlayerID()].state != "active")
+ if (simState.players[Engine.GetPlayerID()].state != "active" || g_Disconnected)
return;
// Tell other players that we have given up and been defeated
@@ -167,7 +169,11 @@ function leaveGame()
var playerState = extendedSimState.players[Engine.GetPlayerID()];
var gameResult;
- if (playerState.state == "won")
+ if (g_Disconnected)
+ {
+ gameResult = "You have been disconnected."
+ }
+ else if (playerState.state == "won")
{
gameResult = "You have won the battle!";
}
1  binaries/data/mods/public/gui/session/session.xml
View
@@ -1113,7 +1113,6 @@
style="StoneButton"
size="50%-84 50%+128 50%+84 50%+160"
tooltip_style="sessionToolTip"
- hidden="true"
>
<object size="0 0 100% 100%" type="text" style="CenteredButtonText" name="disconnectedExitButtonText" ghost="true">Return to Main Menu</object>
<action on="Press">leaveGame()</action>
3  source/simulation2/components/CCmpCommandQueue.cpp
View
@@ -89,7 +89,8 @@ class CCmpCommandQueue : public ICmpCommandQueue
PROFILE2_ATTR("command: %s", GetSimContext().GetScriptInterface().StringifyJSON(cmd.get(), false).c_str());
// TODO: would be nicer to not use globals
- g_Game->GetTurnManager()->PostCommand(CScriptValRooted(cx, cmd));
+ if (g_Game && g_Game->GetTurnManager())
+ g_Game->GetTurnManager()->PostCommand(CScriptValRooted(cx, cmd));
}
virtual void FlushTurn(const std::vector<SimulationCommand>& commands)
Please sign in to comment.
Something went wrong with that request. Please try again.