don't crash on in-game connection loss either
This commit is contained in:
@@ -217,6 +217,9 @@ namespace OpenRa
|
||||
var r = new Rectangle((Game.viewport.Width - w) / 2, (Game.viewport.Height - h) / 2, w, h);
|
||||
DrawDialogBackground(r, optionsSprites, true);
|
||||
DrawCentered(text, new int2(Game.viewport.Width / 2, Game.viewport.Height / 2 - 8), Color.White);
|
||||
|
||||
// don't allow clicks through the dialog
|
||||
AddButton(r, _ => { });
|
||||
}
|
||||
|
||||
public void DrawLobby()
|
||||
@@ -260,6 +263,9 @@ namespace OpenRa
|
||||
DrawDialogBackground(chatBox, panelSprites, false);
|
||||
|
||||
DrawChat(typingBox, chatBox);
|
||||
|
||||
// block clicks `through` the dialog
|
||||
AddButton(r, _ => { });
|
||||
}
|
||||
|
||||
public void TickRadarAnimation()
|
||||
|
||||
@@ -53,6 +53,10 @@ namespace OpenRa.Graphics
|
||||
{
|
||||
Game.world.WorldRenderer.Draw();
|
||||
Game.chrome.Draw();
|
||||
|
||||
if (Game.orderManager.IsNetplay &&
|
||||
Game.orderManager.Sources.OfType<NetworkOrderSource>().First().State == ConnectionState.NotConnected)
|
||||
Game.chrome.DrawDialog("Connection lost.");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -64,7 +68,7 @@ namespace OpenRa.Graphics
|
||||
switch (nos.State)
|
||||
{
|
||||
case ConnectionState.Connecting:
|
||||
Game.chrome.DrawDialog("Connecting to {0}:{1}".F( Game.Settings.NetworkHost, Game.Settings.NetworkPort ));
|
||||
Game.chrome.DrawDialog("Connecting to {0}:{1}...".F( Game.Settings.NetworkHost, Game.Settings.NetworkPort ));
|
||||
break;
|
||||
case ConnectionState.NotConnected:
|
||||
Game.chrome.DrawDialog("Connection failed.");
|
||||
|
||||
@@ -42,26 +42,34 @@ namespace OpenRa.Orders
|
||||
{
|
||||
var reader = new BinaryReader(socket.GetStream());
|
||||
|
||||
for (; ; )
|
||||
try
|
||||
{
|
||||
var len = reader.ReadInt32();
|
||||
var frame = reader.ReadInt32();
|
||||
var buf = reader.ReadBytes(len - 4);
|
||||
|
||||
lock (orderBuffers)
|
||||
for (; ; )
|
||||
{
|
||||
if (len == 5 && buf[0] == 0xef) /* got everything marker */
|
||||
gotEverything[frame] = true;
|
||||
else
|
||||
var len = reader.ReadInt32();
|
||||
var frame = reader.ReadInt32();
|
||||
var buf = reader.ReadBytes(len - 4);
|
||||
|
||||
lock (orderBuffers)
|
||||
{
|
||||
/* accumulate this chunk */
|
||||
if (!orderBuffers.ContainsKey(frame))
|
||||
orderBuffers[frame] = new List<byte[]> { buf };
|
||||
if (len == 5 && buf[0] == 0xef) /* got everything marker */
|
||||
gotEverything[frame] = true;
|
||||
else
|
||||
orderBuffers[frame].Add(buf);
|
||||
{
|
||||
/* accumulate this chunk */
|
||||
if (!orderBuffers.ContainsKey(frame))
|
||||
orderBuffers[frame] = new List<byte[]> { buf };
|
||||
else
|
||||
orderBuffers[frame].Add(buf);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
State = ConnectionState.NotConnected;
|
||||
}
|
||||
|
||||
}) { IsBackground = true }.Start();
|
||||
}
|
||||
catch
|
||||
|
||||
Reference in New Issue
Block a user