From 30d99ccbd1fa3eb2d8321c74a080a6683b85b45a Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Mon, 11 Jul 2016 11:40:13 +1000 Subject: [PATCH] Fix rare case in which level blockdb is not saved after level is auto-saved. --- Games/Countdown/CountdownGame.cs | 2 -- Levels/Level.cs | 20 ++++++++++---------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/Games/Countdown/CountdownGame.cs b/Games/Countdown/CountdownGame.cs index acc2550cd..6ea272aec 100644 --- a/Games/Countdown/CountdownGame.cs +++ b/Games/Countdown/CountdownGame.cs @@ -104,7 +104,6 @@ namespace MCGalaxy.Games { } else { SendFreezeMessages(); MessageAll("&bPlayers Frozen"); - mapon.countdowninprogress = true; gamestatus = CountdownGameStatus.InProgress; foreach (Player pl in players) pl.countdownsettemps = true; @@ -239,7 +238,6 @@ namespace MCGalaxy.Games { Cuboid(maxX - 4, 4, 4, maxX - 4, 4, maxZ - 4, Block.air, mapon); if (!freezemode) { - mapon.countdowninprogress = true; gamestatus = CountdownGameStatus.InProgress; } } diff --git a/Levels/Level.cs b/Levels/Level.cs index 492389bfb..579f6d7e7 100644 --- a/Levels/Level.cs +++ b/Levels/Level.cs @@ -91,11 +91,8 @@ namespace MCGalaxy public bool cancelsave1; public bool cancelunload; public bool changed; - public bool physicschanged - { - get { return ListCheck.Count > 0; } - } - public bool countdowninprogress; + public bool physicschanged { get { return ListCheck.Count > 0; } } + public bool ctfmode; public int currentUndo; public ushort Width, Height, Length; @@ -401,10 +398,9 @@ namespace MCGalaxy } MovePlayersToMain(); - if (changed && ShouldSaveChanges()) { - Save(false, true); - saveChanges(); - } + if (changed && ShouldSaveChanges()) Save(false, true); + if (ShouldSaveChanges()) saveChanges(); + if (TntWarsGame.Find(this) != null) { foreach (TntWarsGame.player pl in TntWarsGame.Find(this).Players) @@ -683,7 +679,11 @@ namespace MCGalaxy return false; } - public void saveChanges() { LevelDB.SaveBlockDB(this); } + readonly object dbLock = new object(); + public void saveChanges() { + lock (dbLock) + LevelDB.SaveBlockDB(this); + } public List getPlayers() { Player[] players = PlayerInfo.Online.Items;