private bool ProcessoDeSalvamento() { if (ServerIsSaving) { Logger.Log("[Fougerite WorldSave] Server's thread is still saving. We are ignoring the save request."); return(false); } ServerIsSaving = true; path = ServerSaveManager.autoSavePath; AvatarSaveProc.SaveAll(); DataStore.GetInstance().Save(); restart = SystemTimestamp.Restart; if (path == string.Empty) { path = "savedgame.sav"; } if (!path.EndsWith(".sav")) { path = path + ".sav"; } if (ServerSaveManager._loading) { Logger.LogError("[Fougerite WorldSave] Currently loading, aborting save to " + path); return(false); } else { Debug.Log("Saving to '" + path + "'"); if (!ServerSaveManager._loadedOnce) { if (File.Exists(path)) { string[] textArray1 = new string[] { path, ".", ServerSaveManager.DateTimeFileString(File.GetLastWriteTime(path)), ".", ServerSaveManager.DateTimeFileString(DateTime.Now), ".bak" }; string destFileName = string.Concat(textArray1); File.Copy(path, destFileName); Logger.LogError( "A save file exists at target path, but it was never loaded!\n\tbacked up:" + Path.GetFullPath(destFileName)); } ServerSaveManager._loadedOnce = true; } using (Recycler <WorldSave, WorldSave.Builder> recycler = WorldSave.Recycler()) { if (recycler != null) { builder = recycler.OpenBuilder(); timestamp2 = SystemTimestamp.Restart; s = ServerSaveManager.Get(false); } else { Logger.LogError("SOMETHING IS F****D, RECYCLER IS NULL."); } } return(true); } }
private void StartBackGroundWorkerManualBackgroundSave() { if (ServerIsSaving) { Logger.Log( "[Fougerite WorldSave] Server's thread is still saving. We are ignoring the save request."); return; } try { ServerIsSaving = true; path = ServerSaveManager.autoSavePath; AvatarSaveProc.SaveAll(); DataStore.GetInstance().Save(); restart = SystemTimestamp.Restart; if (path == string.Empty) { path = "savedgame.sav"; } if (!path.EndsWith(".sav")) { path = path + ".sav"; } if (ServerSaveManager._loading) { Logger.LogError("[Fougerite WorldSave] Currently loading, aborting save to " + path); } else { Debug.Log("Saving to '" + path + "'"); if (!ServerSaveManager._loadedOnce) { if (File.Exists(path)) { string[] textArray1 = new string[] { path, ".", ServerSaveManager.DateTimeFileString(File.GetLastWriteTime(path)), ".", ServerSaveManager.DateTimeFileString(DateTime.Now), ".bak" }; string destFileName = string.Concat(textArray1); File.Copy(path, destFileName); Logger.LogError( "A save file exists at target path, but it was never loaded!\n\tbacked up:" + Path.GetFullPath(destFileName)); } ServerSaveManager._loadedOnce = true; } using (Recycler <WorldSave, WorldSave.Builder> recycler = WorldSave.Recycler()) { if (recycler != null) { builder = recycler.OpenBuilder(); timestamp2 = SystemTimestamp.Restart; s = ServerSaveManager.Get(false); } else { Logger.LogError("SOMETHING IS F****D, RECYCLER IS NULL."); } } BackgroundWorker BGW = new BackgroundWorker(); BGW.DoWork += new DoWorkEventHandler(SaveServerManualWithoutInvoke); BGW.RunWorkerAsync(); } } catch (Exception ex) { Logger.LogError("[ServerSaveHandler Error1] " + ex); } }