Fix server shutdown crash under mono.

This commit is contained in:
Paul Chote
2010-12-30 20:29:11 +13:00
parent 4f6f3eb80d
commit dc012c0faf

View File

@@ -38,15 +38,10 @@ namespace OpenRA.Server
public ModData ModData; public ModData ModData;
public Map Map; public Map Map;
bool shutdown = false;
public void Shutdown() public void Shutdown()
{ {
conns.Clear(); shutdown = true;
GameStarted = false;
foreach (var t in ServerTraits.WithInterface<INotifyServerShutdown>())
t.ServerShutdown(this);
try { listener.Stop(); }
catch { }
} }
public Server(ModData modData, Settings settings, string map) public Server(ModData modData, Settings settings, string map)
@@ -103,13 +98,17 @@ namespace OpenRA.Server
foreach (var t in ServerTraits.WithInterface<ITick>()) foreach (var t in ServerTraits.WithInterface<ITick>())
t.Tick(this); t.Tick(this);
if (conns.Count() == 0) if (conns.Count() == 0 || shutdown)
{
listener.Stop();
GameStarted = false;
break; break;
}
} }
GameStarted = false;
foreach (var t in ServerTraits.WithInterface<INotifyServerShutdown>())
t.ServerShutdown(this);
conns.Clear();
try { listener.Stop(); }
catch { }
} ) { IsBackground = true }.Start(); } ) { IsBackground = true }.Start();
} }