private void dedicatedProcess_Exited(object sender, EventArgs e) { try { Context.IsCrash = (process.ExitCode != 0) && !Context.WasKilled; process.UnsubscribeEvents(this); try { if (!process.WaitForExit(2000)) { process.Kill(); } } catch { } process = null; talker.UnsubscribeEvents(this); talker?.Close(); talker = null; Thread.Sleep(1000); if (LobbyStartContext != null) { foreach (var p in Context.ActualPlayers) { p.IsIngame = false; } } if (File.Exists(scriptPath)) { try { File.Delete(scriptPath); } catch { } } if (Context.OutputExtras.Count(x => x.StartsWith("award")) == 0) { //No awards received, do a strict majority vote on awards int playersReportingAwards = gamePrivateMessages.Where(x => x.Key.StartsWith("award")).SelectMany(x => x.Value).Distinct().Count(); Context.OutputExtras = gamePrivateMessages.Where(x => x.Value.Count >= playersReportingAwards / 2 + 1).Select(x => x.Key).ToList(); } DedicatedServerExited?.Invoke(this, Context); AnyDedicatedExited?.Invoke(this, Context); } catch (Exception ex) { Trace.TraceError("Error processing dedicated server exit: {0}", ex); } }
public void Dispose() { talker?.UnsubscribeEvents(this); talker?.Dispose(); timer?.Dispose(); process?.UnsubscribeEvents(this); Context = null; scriptPath = null; gamePrivateMessages = null; process = null; talker = null; }
private void dedicatedProcess_Exited(object sender, EventArgs e) { try { Context.IsCrash = (process.ExitCode != 0) && !Context.WasKilled; process.UnsubscribeEvents(this); try { if (!process.WaitForExit(2000)) { process.Kill(); } } catch { } process = null; talker.UnsubscribeEvents(this); talker?.Close(); talker = null; Thread.Sleep(1000); if (LobbyStartContext != null) { foreach (var p in Context.ActualPlayers) { p.IsIngame = false; } } if (File.Exists(scriptPath)) { try { File.Delete(scriptPath); } catch { } } DedicatedServerExited?.Invoke(this, Context); AnyDedicatedExited?.Invoke(this, Context); } catch (Exception ex) { Trace.TraceError("Error processing dedicated server exit: {0}", ex); } }