Unhandled exceptions in zombie survival should not crash the entire server. (Thanks goodlyay)

This commit is contained in:
UnknownShadow200 2016-04-07 16:12:18 +10:00
parent c03e09b853
commit 95aeffe10e
2 changed files with 15 additions and 4 deletions

View File

@ -27,6 +27,21 @@ namespace MCGalaxy.Games {
public sealed partial class ZombieGame {
void MainLoop() {
// Make sure that in the worst case, we do not crash the entire server.
try {
MainLoopCore();
} catch (Exception ex) {
Server.ErrorLog(ex);
Player.GlobalMessage("&cZombie survival disabled due to an error.");
try {
ResetState();
} catch (Exception ex2) {
Server.ErrorLog(ex2);
}
}
}
void MainLoopCore() {
if (Status == ZombieGameStatus.NotStarted) return;
if (!initialChangeLevel) {
ChooseNextLevel();

View File

@ -215,10 +215,6 @@ namespace MCGalaxy.Games {
LastLevelName = "";
CurLevelName = "";
CurLevel = null;
foreach (Player pl in online) {
pl.Game.RatedMap = false;
pl.Game.PledgeSurvive = false;
}
}
void UpdatePlayerStatus(Player p) {