Merge pull request #7066 from WolfGaming/FixTimeoutInSinglePlayer
Fix: Game can no longer drop you in a single player game.
This commit is contained in:
@@ -34,37 +34,45 @@ namespace OpenRA.Mods.Common.Server
|
|||||||
{
|
{
|
||||||
isInitialPing = false;
|
isInitialPing = false;
|
||||||
lastPing = Game.RunTime;
|
lastPing = Game.RunTime;
|
||||||
foreach (var c in server.Conns.ToList())
|
|
||||||
{
|
// Ignore client timeout in singleplayer games to make debugging easier
|
||||||
if (c.TimeSinceLastResponse < ConnTimeout)
|
if (server.LobbyInfo.IsSinglePlayer && !server.Settings.Dedicated)
|
||||||
{
|
foreach (var c in server.Conns.ToList())
|
||||||
server.SendOrderTo(c, "Ping", Game.RunTime.ToString());
|
server.SendOrderTo(c, "Ping", Game.RunTime.ToString());
|
||||||
if (!c.TimeoutMessageShown && c.TimeSinceLastResponse > PingInterval * 2)
|
else
|
||||||
|
{
|
||||||
|
foreach (var c in server.Conns.ToList())
|
||||||
|
{
|
||||||
|
if (c.TimeSinceLastResponse < ConnTimeout)
|
||||||
{
|
{
|
||||||
server.SendMessage(server.GetClient(c).Name + " is experiencing connection problems.");
|
server.SendOrderTo(c, "Ping", Game.RunTime.ToString());
|
||||||
c.TimeoutMessageShown = true;
|
if (!c.TimeoutMessageShown && c.TimeSinceLastResponse > PingInterval * 2)
|
||||||
|
{
|
||||||
|
server.SendMessage(server.GetClient(c).Name + " is experiencing connection problems.");
|
||||||
|
c.TimeoutMessageShown = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
server.SendMessage(server.GetClient(c).Name + " has been dropped after timing out.");
|
||||||
|
server.DropClient(c, -1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
if (Game.RunTime - lastConnReport > ConnReportInterval)
|
||||||
{
|
{
|
||||||
server.SendMessage(server.GetClient(c).Name + " has been dropped after timing out.");
|
lastConnReport = Game.RunTime;
|
||||||
server.DropClient(c, -1);
|
|
||||||
|
var timeouts = server.Conns
|
||||||
|
.Where(c => c.TimeSinceLastResponse > ConnReportInterval && c.TimeSinceLastResponse < ConnTimeout)
|
||||||
|
.OrderBy(c => c.TimeSinceLastResponse);
|
||||||
|
|
||||||
|
foreach (var c in timeouts)
|
||||||
|
server.SendMessage("{0} will be dropped in {1} seconds.".F(
|
||||||
|
server.GetClient(c).Name, (ConnTimeout - c.TimeSinceLastResponse) / 1000));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Game.RunTime - lastConnReport > ConnReportInterval)
|
|
||||||
{
|
|
||||||
lastConnReport = Game.RunTime;
|
|
||||||
|
|
||||||
var timeouts = server.Conns
|
|
||||||
.Where(c => c.TimeSinceLastResponse > ConnReportInterval && c.TimeSinceLastResponse < ConnTimeout)
|
|
||||||
.OrderBy(c => c.TimeSinceLastResponse);
|
|
||||||
|
|
||||||
foreach (var c in timeouts)
|
|
||||||
server.SendMessage("{0} will be dropped in {1} seconds.".F(
|
|
||||||
server.GetClient(c).Name, (ConnTimeout - c.TimeSinceLastResponse) / 1000));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Net;
|
||||||
using OpenRA.Network;
|
using OpenRA.Network;
|
||||||
using OpenRA.Widgets;
|
using OpenRA.Widgets;
|
||||||
|
|
||||||
@@ -76,7 +77,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
latency.GetText = () => LobbyUtils.LatencyDescription(ping);
|
latency.GetText = () => LobbyUtils.LatencyDescription(ping);
|
||||||
latency.GetColor = () => LobbyUtils.LatencyColor(ping);
|
latency.GetColor = () => LobbyUtils.LatencyColor(ping);
|
||||||
var address = orderManager.LobbyInfo.ClientWithIndex(clientIndex).IpAddress;
|
var address = orderManager.LobbyInfo.ClientWithIndex(clientIndex).IpAddress;
|
||||||
if (address == "127.0.0.1" && UPnP.NatDevice != null)
|
if (address == IPAddress.Loopback.ToString() && UPnP.NatDevice != null)
|
||||||
address = UPnP.NatDevice.GetExternalIP().ToString();
|
address = UPnP.NatDevice.GetExternalIP().ToString();
|
||||||
var cachedDescriptiveIP = LobbyUtils.DescriptiveIpAddress(address);
|
var cachedDescriptiveIP = LobbyUtils.DescriptiveIpAddress(address);
|
||||||
ip.GetText = () => cachedDescriptiveIP;
|
ip.GetText = () => cachedDescriptiveIP;
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Net;
|
||||||
using OpenRA.Graphics;
|
using OpenRA.Graphics;
|
||||||
using OpenRA.Mods.Common.Widgets;
|
using OpenRA.Mods.Common.Widgets;
|
||||||
using OpenRA.Network;
|
using OpenRA.Network;
|
||||||
@@ -224,7 +225,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
{
|
{
|
||||||
if (ip == null)
|
if (ip == null)
|
||||||
return "Unknown Host";
|
return "Unknown Host";
|
||||||
if (ip == "127.0.0.1")
|
if (ip == IPAddress.Loopback.ToString())
|
||||||
return "Local Host";
|
return "Local Host";
|
||||||
return ip;
|
return ip;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user