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