public static void SaveBW(object sender, DoWorkEventArgs e) { AvatarSaveProc.SaveAll(); //??????? WorldSave fsave; using (Recycler <WorldSave, WorldSave.Builder> recycler = WorldSave.Recycler()) { WorldSave.Builder builder = recycler.OpenBuilder(); ServerSaveManager.Get(false).DoSave(ref builder); fsave = builder.Build(); } if (ShowObjectCount) { ObjectsCount = fsave.SceneObjectCount + fsave.InstanceObjectCount; } FileStream stream2 = File.Open(Directory.GetCurrentDirectory() + @"\save\server_data\rust_island_2013.sav", FileMode.Create, FileAccess.Write); fsave.WriteTo(stream2); stream2.Flush(); stream2.Dispose(); //?? SaveEndTime = DateTime.Now; AnnounceResults(); BGW.Dispose(); }
public static void NormalSave() { Loom.QueueOnMainThread(() => { try { AvatarSaveProc.SaveAll(); //??????? } catch (Exception ex) { } WorldSave fsave; using (Recycler <WorldSave, WorldSave.Builder> recycler = WorldSave.Recycler()) { WorldSave.Builder builder = recycler.OpenBuilder(); ServerSaveManager.Get(false).DoSave(ref builder); fsave = builder.Build(); } if (ShowObjectCount) { ObjectsCount = fsave.SceneObjectCount + fsave.InstanceObjectCount; } FileStream stream2 = File.Open(Directory.GetCurrentDirectory() + @"\save\server_data\rust_island_2013.sav", FileMode.Create, FileAccess.Write); fsave.WriteTo(stream2); stream2.Flush(); stream2.Dispose(); //?? SaveEndTime = DateTime.Now; AnnounceResults(); }); }
public void StartSave() { SaveStartTime = DateTime.Now; if (!Directory.Exists(Directory.GetCurrentDirectory() + @"\save\server_data\BackUpSaves\")) { Directory.CreateDirectory(Directory.GetCurrentDirectory() + @"\save\server_data\BackUpSaves\"); } try { if (File.Exists(Directory.GetCurrentDirectory() + @"\save\server_data\rust_island_2013.sav")) { string d = System.DateTime.Now.Day.ToString(); string h = System.DateTime.Now.Hour.ToString(); string m = System.DateTime.Now.Minute.ToString(); string s = System.DateTime.Now.Second.ToString(); string date = "Day " + d + " Hour " + h + "-" + m + "-" + s; string name = "rust_island_2013 " + date + ".sav"; File.Copy(Directory.GetCurrentDirectory() + @"\save\server_data\rust_island_2013.sav", Directory.GetCurrentDirectory() + @"\save\server_data\BackUpSaves\" + name, true); } } catch (Exception ex) { } WorldSave fsave; using (Recycler <WorldSave, WorldSave.Builder> recycler = WorldSave.Recycler()) { WorldSave.Builder builder = recycler.OpenBuilder(); ServerSaveManager.Get(false).DoSave(ref builder); fsave = builder.Build(); } ObjectsCount = fsave.SceneObjectCount + fsave.InstanceObjectCount; FileStream stream2 = File.Open(Directory.GetCurrentDirectory() + @"\save\server_data\rust_island_2013.sav", FileMode.Create, FileAccess.Write); fsave.WriteTo(stream2); stream2.Flush(); stream2.Dispose(); //?? SaveEndTime = DateTime.Now; AnnounceResults(); }
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); } }