diff --git a/Commands/CPE/CmdCustomColors.cs b/Commands/CPE/CmdCustomColors.cs index d9865b5bd..6183a8157 100644 --- a/Commands/CPE/CmdCustomColors.cs +++ b/Commands/CPE/CmdCustomColors.cs @@ -110,7 +110,6 @@ namespace MCGalaxy.Commands.CPE { if (index >= offset) { count++; - Server.s.Log(col.Fallback.ToString()); const string format = "{4}{0} &{1}({2}){4} - %{1}, falls back to &{3}%{3}."; Player.SendMessage(p, String.Format(format, col.Name, col.Code, col.Hex(), col.Fallback, Server.DefaultColor), false); diff --git a/Levels/Level.cs b/Levels/Level.cs index d86dea3b4..40fdf0949 100644 --- a/Levels/Level.cs +++ b/Levels/Level.cs @@ -238,6 +238,7 @@ namespace MCGalaxy public bool bufferblocks = Server.bufferblocks; internal readonly object queueLock = new object(); + readonly object saveLock = new object(); public List blockqueue = new List(); private readonly object physThreadLock = new object(); BufferedBlockSender bulkSender; @@ -323,8 +324,7 @@ namespace MCGalaxy #region IDisposable Members - public void Dispose() - { + public void Dispose() { Extras.Clear(); liquids.Clear(); leaves.Clear(); @@ -333,10 +333,13 @@ namespace MCGalaxy UndoBuffer.Clear(); blockCache.Clear(); ZoneList.Clear(); + lock (queueLock) blockqueue.Clear(); - blocks = null; - CustomBlocks = null; + lock (saveLock) { + blocks = null; + CustomBlocks = null; + } } #endregion @@ -559,23 +562,10 @@ namespace MCGalaxy if (!Directory.Exists("levels/prev")) Directory.CreateDirectory("levels/prev"); if (changed || !File.Exists(path) || Override || (physicschanged && clearPhysics)) { - if (clearPhysics) - ClearPhysics(); + if (clearPhysics) ClearPhysics(); - if (File.Exists(path)) { - string prevPath = LevelInfo.PrevPath(name); - if (File.Exists(prevPath)) - File.Delete(prevPath); - File.Copy(path, prevPath, true); - File.Delete(path); - } - LvlFile.Save(this, path + ".backup"); - File.Copy(path + ".backup", path); - SaveSettings(this); - - Server.s.Log(string.Format("SAVED: Level \"{0}\". ({1}/{2}/{3})", name, players.Count, - PlayerInfo.Online.Count, Server.players)); - changed = false; + lock (saveLock) + SaveCore(path); } else { Server.s.Log("Skipping level save for " + name + "."); } @@ -587,6 +577,24 @@ namespace MCGalaxy GC.Collect(); GC.WaitForPendingFinalizers(); } + + void SaveCore(string path) { + if (blocks == null) return; + if (File.Exists(path)) { + string prevPath = LevelInfo.PrevPath(name); + if (File.Exists(prevPath)) File.Delete(prevPath); + File.Copy(path, prevPath, true); + File.Delete(path); + } + + LvlFile.Save(this, path + ".backup"); + File.Copy(path + ".backup", path); + SaveSettings(this); + + Server.s.Log(string.Format("SAVED: Level \"{0}\". ({1}/{2}/{3})", name, players.Count, + PlayerInfo.Online.Count, Server.players)); + changed = false; + } public int Backup(bool Forced = false, string backupName = "") { if (!backedup || Forced) { diff --git a/Player/Player.Handlers.cs b/Player/Player.Handlers.cs index 416fe5e12..0cb7d1b33 100644 --- a/Player/Player.Handlers.cs +++ b/Player/Player.Handlers.cs @@ -1198,6 +1198,10 @@ return; } } + public void HandleCommands(List cmds) { + + } + bool CheckCommand(string cmd) { if (cmd == "") { SendMessage("No command entered."); return false; } if (Server.agreetorulesonentry && !agreed && !(cmd == "agree" || cmd == "rules" || cmd == "disagree")) {