Exemple #1
0
 public static void savealldata()
 {
     AvatarSaveProc.SaveAll();
     ServerSaveManager.AutoSave();
     Helper.CreateSaves();
     DataStore.GetInstance().Save();
 }
Exemple #2
0
        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();
        }
Exemple #3
0
 public override void Execute(ref ConsoleSystem.Arg Arguments, ref string[] ChatArguments)
 {
     if (ChatArguments.Length == 1)
     {
         if (ChatArguments[0] == "urgent")
         {
             Fougerite.Hooks.IsShuttingDown = true;
             Fougerite.Server.GetServer().BroadcastFrom(Core.Name, "Server Shutdown NOW!");
             //UnityEngine.Application.Quit();
             Process.GetCurrentProcess().Kill();
         }
         else if (ChatArguments[0] == "safeurgent")
         {
             Fougerite.Hooks.IsShuttingDown = true;
             Fougerite.Server.GetServer().BroadcastFrom(Core.Name, "Saving Server...");
             AvatarSaveProc.SaveAll();
             ServerSaveManager.AutoSave();
             Helper.CreateSaves();
             Fougerite.Server.GetServer().BroadcastFrom(Core.Name, "Saved Server Data!");
             Fougerite.Server.GetServer().BroadcastFrom(Core.Name, "Server is shutting down in " + ShutdownTime + " seconds.");
             _timer          = new Timer(TriggerTime * 1000);
             _timer.Elapsed += Trigger;
             _timer.Start();
         }
         return;
     }
     StartShutdown();
 }
Exemple #4
0
        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();
            });
        }
Exemple #5
0
 public static void savealldata()
 {
     try
     {
         AvatarSaveProc.SaveAll();
         ServerSaveManager.AutoSave();
     }
     catch {}
 }
Exemple #6
0
 public override void Execute(ref ConsoleSystem.Arg Arguments, ref string[] ChatArguments)
 {
     AvatarSaveProc.SaveAll();
     Util.sayUser(Arguments.argUser.networkPlayer, Core.Name, "Saved ALL Avatar files!");
     ServerSaveManager.AutoSave();
     Util.sayUser(Arguments.argUser.networkPlayer, Core.Name, "Saved server global state!");
     Helper.CreateSaves();
     Util.sayUser(Arguments.argUser.networkPlayer, Core.Name, "Saved " + Core.Name + " data!");
 }
        public override void Execute(ref ConsoleSystem.Arg Arguments, ref string[] ChatArguments)
        {
            var pl = Fougerite.Server.Cache[Arguments.argUser.userID];

            AvatarSaveProc.SaveAll();
            pl.MessageFrom(Core.Name, "Saved ALL Avatar files!");
            ServerSaveManager.AutoSave();
            pl.MessageFrom(Core.Name, "Saved server global state!");
            Helper.CreateSaves();
            pl.MessageFrom(Core.Name, "Saved " + Core.Name + " data!");
        }
Exemple #8
0
 public static void EventServerRestart(EventTimer sender, int ShutdownTime, ref int Timeleft)
 {
     if (Timeleft != 0)
     {
         if (Timeleft <= 5)
         {
             Broadcast.NoticeAll("☢", Config.GetMessage("Server.WillRestart", null, null).Replace("%SECONDS%", Timeleft.ToString()), null, 1f);
         }
         else if (Timeleft == 10)
         {
             Broadcast.NoticeAll("☢", Config.GetMessage("Server.WillRestart", null, null).Replace("%SECONDS%", Timeleft.ToString()), null, 5f);
         }
         else if (Timeleft == 30)
         {
             Broadcast.NoticeAll("☢", Config.GetMessage("Server.WillRestart", null, null).Replace("%SECONDS%", Timeleft.ToString()), null, 10f);
         }
         else if (Timeleft == 60)
         {
             Broadcast.NoticeAll("☢", Config.GetMessage("Server.WillRestart", null, null).Replace("%SECONDS%", Timeleft.ToString()), null, 10f);
         }
         else if (Timeleft == ShutdownTime)
         {
             Broadcast.NoticeAll("☢", Config.GetMessage("Server.Restart", null, null).Replace("%SECONDS%", Timeleft.ToString()), null, 10f);
         }
     }
     if (Timeleft > 0)
     {
         Timeleft--;
     }
     else
     {
         try
         {
             if (sender != null)
             {
                 sender.Stop();
             }
             AvatarSaveProc.SaveAll();
             ServerSaveManager.AutoSave();
             string text      = Environment.GetCommandLineArgs()[0];
             string arguments = string.Join(" ", Environment.GetCommandLineArgs()).Replace(text, "").Trim();
             Process.Start(text, arguments);
             Process.GetCurrentProcess().Kill();
         }
         catch (Exception ex)
         {
             Helper.LogError(ex.ToString(), true);
         }
     }
 }
Exemple #9
0
 public static void shutdown_tick()
 {
     if (time == 0)
     {
         API.sayAll("Server Shutdown NOW!");
         AvatarSaveProc.SaveAll();
         ServerSaveManager.AutoSave();
     }
     else
     {
         API.sayAll("Server Shutting down in " + time + " seconds");
     }
     time -= 10;
 }
Exemple #10
0
 public static void savealldata()
 {
     try
     {
         AvatarSaveProc.SaveAll();
         ServerSaveManager.AutoSave();
         Helper.CreateSaves();
         DataStore.GetInstance().Save();
     }
     catch (Exception ex)
     {
         Logger.LogException(ex);
         Logger.Log("Error while auto-saving!");
     }
 }
Exemple #11
0
 public static void EventServerShutdown(EventTimer sender, int ShutdownTime, ref int Timeleft)
 {
     if (Timeleft != 0)
     {
         if (Timeleft <= 5)
         {
             Broadcast.NoticeAll("☢", Config.GetMessage("Server.WillShutdown", null, null).Replace("%SECONDS%", Timeleft.ToString()), null, 1f);
         }
         else if (Timeleft == 10)
         {
             Broadcast.NoticeAll("☢", Config.GetMessage("Server.WillShutdown", null, null).Replace("%SECONDS%", Timeleft.ToString()), null, 5f);
         }
         else if (Timeleft == 30)
         {
             Broadcast.NoticeAll("☢", Config.GetMessage("Server.WillShutdown", null, null).Replace("%SECONDS%", Timeleft.ToString()), null, 10f);
         }
         else if (Timeleft == 60)
         {
             Broadcast.NoticeAll("☢", Config.GetMessage("Server.WillShutdown", null, null).Replace("%SECONDS%", Timeleft.ToString()), null, 10f);
         }
         else if (Timeleft == ShutdownTime)
         {
             Broadcast.NoticeAll("☢", Config.GetMessage("Server.Shutdown", null, null).Replace("%SECONDS%", Timeleft.ToString()), null, 10f);
         }
     }
     if (Timeleft > 0)
     {
         Timeleft--;
     }
     else
     {
         try
         {
             if (sender != null)
             {
                 sender.Stop();
             }
             AvatarSaveProc.SaveAll();
             ServerSaveManager.AutoSave();
             Process.GetCurrentProcess().Kill();
         }
         catch (Exception ex)
         {
             Helper.LogError(ex.ToString(), true);
         }
     }
 }
Exemple #12
0
        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();
        }
Exemple #13
0
 internal static void Trigger(object sender, ElapsedEventArgs elapsedEventArgs)
 {
     Time += TriggerTime;
     if (Time >= ShutdownTime)
     {
         _timer.Dispose();
         Fougerite.Server.GetServer().BroadcastFrom(Core.Name, "Saving Server...");
         AvatarSaveProc.SaveAll();
         ServerSaveManager.AutoSave();
         Helper.CreateSaves();
         Fougerite.Server.GetServer().BroadcastFrom(Core.Name, "Saved Server Data!");
         Fougerite.Server.GetServer().BroadcastFrom(Core.Name, "Server shutdown in 5 seconds!");
         _timer2          = new Timer(5000);
         _timer2.Elapsed += Trigger2;
         _timer2.Start();
     }
     else
     {
         Fougerite.Server.GetServer().BroadcastFrom(Core.Name, "Server is shutting down in " + (ShutdownTime - Time) + " seconds.");
     }
 }
Exemple #14
0
 public static void shutdown_tick()
 {
     if (time == 0)
     {
         Util.sayAll(Core.Name, "Server Shutdown NOW!");
         try
         {
             AvatarSaveProc.SaveAll();
             ServerSaveManager.AutoSave();
             Helper.CreateSaves();
             DataStore.GetInstance().Save();
         }
         catch (Exception ex)
         {
             Logger.LogException(ex);
         }
         Process.GetCurrentProcess().Kill();
     }
     else
     {
         Util.sayAll(Core.Name, "Server Shutting down in " + time + " seconds");
     }
     time -= 10;
 }
Exemple #15
0
        internal static void Trigger(object sender, ElapsedEventArgs elapsedEventArgs)
        {
            Time += TriggerTime;
            string cyan   = "[color #00FFFF]";
            string green  = "[color #00FF00]";
            string yellow = "[color #FFFF00]";
            string white  = "[color #FFFFFF]";

            if (Time >= ShutdownTime)
            {
                _timer.Dispose();
                Fougerite.Server.GetServer().BroadcastFrom(Core.Name, yellow + "☢ " + green + "Saving all server files...");
                ServerSaveManager.AutoSave();
                Fougerite.Server.GetServer().BroadcastFrom(Core.Name, yellow + "☢ " + green + "Saved all server files!");
                Fougerite.Server.GetServer().BroadcastFrom(Core.Name, "☢ Server is shutting down in: " + cyan + "15" + white + " seconds.");
                _timer2          = new Timer(15000);
                _timer2.Elapsed += Trigger2;
                _timer2.Start();
            }
            else
            {
                Fougerite.Server.GetServer().BroadcastFrom(Core.Name, "☢ Server is shutting down in: " + cyan + (ShutdownTime - Time) + white + " seconds.");
            }
        }
Exemple #16
0
        public static bool ConsoleReceived(ref ConsoleSystem.Arg a)
        {
            StringComparison ic          = StringComparison.InvariantCultureIgnoreCase;
            bool             external    = a.argUser == null;
            bool             adminRights = (a.argUser != null && a.argUser.admin) || external;

            string userid = "[external][external]";

            if (adminRights && !external)
            {
                userid = string.Format("[{0}][{1}]", a.argUser.displayName, a.argUser.userID.ToString());
            }

            string logmsg = string.Format("[ConsoleReceived] userid={0} adminRights={1} command={2}.{3} args={4}", userid, adminRights.ToString(), a.Class, a.Function, (a.HasArgs(1) ? a.ArgsStr : "none"));

            Logger.LogDebug(logmsg);

            if (a.Class.Equals("fougerite", ic) && a.Function.Equals("reload", ic))
            {
                if (adminRights)
                {
                    ModuleManager.ReloadModules();
                    a.ReplyWith("Fougerite: Reloaded!");
                }
            }
            else if (a.Class.Equals("fougerite", ic) && a.Function.Equals("save", ic))
            {
                AvatarSaveProc.SaveAll();
                ServerSaveManager.AutoSave();
                if (Fougerite.Server.GetServer().HasRustPP)
                {
                    Fougerite.Server.GetServer().GetRustPPAPI().RustPPSave();
                }
                DataStore.GetInstance().Save();
                a.ReplyWith("Fougerite: Saved!");
            }
            else if (a.Class.Equals("fougerite", ic) && a.Function.Equals("rustpp", ic))
            {
                foreach (var module in Fougerite.ModuleManager.Modules)
                {
                    if (module.Plugin.Name.Equals("RustPPModule"))
                    {
                        module.DeInitialize();
                        module.Initialize();
                        break;
                    }
                }
                a.ReplyWith("Rust++ Reloaded!");
            }
            else if (OnConsoleReceived != null)
            {
                OnConsoleReceived(ref a, external);
            }

            if (string.IsNullOrEmpty(a.Reply))
            {
                a.ReplyWith(string.Format("Fougerite: {0}.{1} was executed!", a.Class, a.Function));
            }

            return(true);
        }
Exemple #17
0
 /// <summary>
 /// Saves the server and any related information
 /// </summary>
 public void Save() => ServerSaveManager.AutoSave();
        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);
            }
        }
        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);
            }
        }
 public void Save()
 {
     AvatarSaveProc.SaveAll();
     ServerSaveManager.AutoSave();
 }