Exemplo n.º 1
0
        void cMapSave(ConsoleSystem.Arg arg)
        {
            if (arg.connection != null && arg.connection.authLevel < 2)
            {
                return;
            }
            if (SaveRestore.IsSaving)
            {
                SendReply(arg, lang.GetMessage("alreadysaving", this, arg.connection != null ? arg.connection.userid.ToString() : null));
                return;
            }
            SaveBackupCreate();
            string saveName;

            saveName = saveFolder + SaveRestore.SaveFileName;
            try {
                foreach (BaseEntity current in BaseEntity.saveList)
                {
                    current.InvalidateNetworkCache();
                }
                IEnumerator enumerator = SaveRestore.Save(saveName, true);
                while (enumerator.MoveNext())
                {
                }
                Interface.Oxide.DataFileSystem.WriteObject(this.Title, new List <object>(new object[] { saveName, "custom" }));
                arg.ReplyWith(lang.GetMessage("customsavecomplete", this, arg.connection != null ? arg.connection.userid.ToString() : null));
            }
            catch { PrintWarning(lang.GetMessage("dirnotfound", this)); }
        }
Exemplo n.º 2
0
        void cMapSave(ConsoleSystem.Arg arg)
        {
            if (arg.Connection != null && arg.Connection.authLevel < 2)
            {
                return;
            }
            if (SaveRestore.IsSaving)
            {
                SendReply(arg, lang.GetMessage("alreadysaving", this, arg.Connection != null ? arg.Connection.userid.ToString() : null));
                return;
            }
            SaveBackupCreate();
            string saveName;

            saveName = saveFolder + SaveRestore.SaveFileName;
            foreach (BaseEntity current in BaseEntity.saveList)
            {
                current.InvalidateNetworkCache();
            }
            Diag.Stopwatch stopwatch = Diag.Stopwatch.StartNew();
            UnityEngine.Debug.Log("Invalidate Network Cache took " + stopwatch.Elapsed.TotalSeconds.ToString("0.00") + " seconds");
            try {
                BaseEntity.saveList.RemoveWhere(p => !p);
                BaseEntity.saveList.RemoveWhere(p => p == null);
                IEnumerator enumerator = SaveRestore.Save(saveName, true);
                while (enumerator.MoveNext())
                {
                }
                Interface.Oxide.DataFileSystem.WriteObject(this.Title, new List <object>(new object[] { saveName, "custom" }));
                arg.ReplyWith(lang.GetMessage("customsavecomplete", this, arg.Connection != null ? arg.Connection.userid.ToString() : null));
            }
            catch { PrintWarning(lang.GetMessage("dirnotfound", this)); }
            CallOnServerSave();
        }
Exemplo n.º 3
0
        void cLoadFile(ConsoleSystem.Arg arg)
        {
            if (arg.connection != null && arg.connection.authLevel < 2)
            {
                return;
            }
            if (arg.Args == null || arg.Args.Length < 1)
            {
                SendReply(arg, lang.GetMessage("definefilename", this, arg.connection != null ? arg.connection.userid.ToString() : null));
                return;
            }
            int folderNumber = -1;

            if (arg.Args[0].Length <= 4 && arg.Args[0] != "last" && !int.TryParse(arg.Args[0], out folderNumber))
            {
                SendReply(arg, lang.GetMessage("lastfilename", this, arg.connection != null ? arg.connection.userid.ToString() : null));
                return;
            }
            string file = "";

            if (arg.Args[0] == "last")
            {
                List <string> filename = Interface.Oxide.DataFileSystem.ReadObject <List <string> >(this.Title);
                if (filename != null)
                {
                    file = filename.First();
                }
            }
            else if (int.TryParse(arg.Args[0], out folderNumber))
            {
                file = $"{ConVar.Server.rootFolder}/saves/{folderNumber}/{SaveRestore.SaveFileName}";
            }
            if (file == "")
            {
                file = saveFolder + arg.Args[0];
            }

            foreach (var player in BasePlayer.activePlayerList.ToList())
            {
                player.Kick(lang.GetMessage("kickreason", this));
            }

            if (SaveRestore.Load(file, allowOutOfDateSaves))
            {
                if (saveAfterLoadFile)
                {
                    foreach (BaseEntity current in BaseEntity.saveList)
                    {
                        current.InvalidateNetworkCache();
                    }
                    SaveRestore.Save(true);
                }
            }
            else
            {
                SendReply(arg, lang.GetMessage("filenotfound", this, arg.connection != null ? arg.connection.userid.ToString() : null));
                return;
            }
        }
Exemplo n.º 4
0
        IEnumerator SaveLoop()
        {
            if (!Initialized)
            {
                yield return(null);
            }
            WaitForFixedUpdate waitU = new WaitForFixedUpdate();

            BaseEntity.saveList.RemoveWhere(p => !p);
            BaseEntity.saveList.RemoveWhere(p => p == null);
            Diag.Stopwatch stopwatch = Diag.Stopwatch.StartNew();
            foreach (BaseEntity current in BaseEntity.saveList)
            {
                current.InvalidateNetworkCache();
            }
            Debug.Log("Invalidate Network Cache took " + stopwatch.Elapsed.TotalSeconds.ToString("0.00") + " seconds");
            if (Rounds < saveCustomAfter && saveCustomAfter > 0)
            {
                IEnumerator original = SaveRestore.Save(ConVar.Server.rootFolder + "/" + SaveRestore.SaveFileName, true);
                while (original.MoveNext())
                {
                }
                Debug.Log("Saving complete");
                if (!callOnServerSave)
                {
                    Interface.Oxide.DataFileSystem.WriteObject(this.Title, new List <object>(new object[] { ConVar.Server.rootFolder + "/" + SaveRestore.SaveFileName, "default" }));
                }
                Rounds++;
                CallOnServerSave();
            }
            else
            {
                string file = saveFolder + SaveRestore.SaveFileName;
                DirectoryEx.Backup(SaveFolders());
                yield return(waitU);

                ConVar.Server.GetServerFolder("saves/0/");
                yield return(waitU);

                try {
                    IEnumerator custom = SaveRestore.Save(file, true);
                    while (custom.MoveNext())
                    {
                    }
                    Debug.Log("Custom Saving complete");
                    if (!callOnServerSave)
                    {
                        Interface.Oxide.DataFileSystem.WriteObject(this.Title, new List <object>(new object[] { file, "custom" }));
                    }
                }
                catch { PrintWarning(lang.GetMessage("dirnotfound", this)); }
                CallOnServerSave();
                Rounds = 0;
            }
            yield return(null);
        }
Exemplo n.º 5
0
        public static void save(Arg arg)
        {
            Stopwatch stopwatch = Stopwatch.StartNew();

            foreach (BaseEntity save in BaseEntity.saveList)
            {
                save.InvalidateNetworkCache();
            }
            UnityEngine.Debug.Log("Invalidate Network Cache took " + stopwatch.Elapsed.TotalSeconds.ToString("0.00") + " seconds");
            SaveRestore.Save(true);
        }
Exemplo n.º 6
0
        public static void save(ConsoleSystem.Arg arg)
        {
            Stopwatch stopwatch = Stopwatch.StartNew();

            foreach (BaseNetworkable save in BaseEntity.saveList)
            {
                save.InvalidateNetworkCache();
            }
            Debug.Log((object)("Invalidate Network Cache took " + stopwatch.Elapsed.TotalSeconds.ToString("0.00") + " seconds"));
            SaveRestore.Save(true);
        }
Exemplo n.º 7
0
 void SaveLoop()
 {
     if (!Initialized)
     {
         return;
     }
     if (Rounds < saveCustomAfter && saveCustomAfter > 0)
     {
         foreach (BaseEntity current in BaseEntity.saveList)
         {
             current.InvalidateNetworkCache();
         }
         if (callOnServerSave)
         {
             timer.Once(delayCallOnServerSave, () => Interface.CallHook("OnServerSave", null));
         }
         IEnumerator original = SaveRestore.Save(ConVar.Server.rootFolder + "/" + SaveRestore.SaveFileName, true);
         while (original.MoveNext())
         {
         }
         if (!callOnServerSave)
         {
             Interface.Oxide.DataFileSystem.WriteObject(this.Title, new List <object>(new object[] { ConVar.Server.rootFolder + "/" + SaveRestore.SaveFileName, "default" }));
         }
         Rounds++;
     }
     else
     {
         string file = saveFolder + SaveRestore.SaveFileName;
         if (callOnServerSave)
         {
             timer.Once(delayCallOnServerSave, () => Interface.CallHook("OnServerSave", file));
         }
         try {
             SaveBackupCreate();
             foreach (BaseEntity current in BaseEntity.saveList)
             {
                 current.InvalidateNetworkCache();
             }
             IEnumerator custom = SaveRestore.Save(file, true);
             while (custom.MoveNext())
             {
             }
             if (!callOnServerSave)
             {
                 Interface.Oxide.DataFileSystem.WriteObject(this.Title, new List <object>(new object[] { file, "custom" }));
             }
         }
         catch { PrintWarning(lang.GetMessage("dirnotfound", this)); }
         Rounds = 0;
     }
 }
Exemplo n.º 8
0
        public static void save(ConsoleSystem.Arg arg)
        {
            Stopwatch stopwatch = Stopwatch.StartNew();

            foreach (BaseEntity baseEntity in BaseEntity.saveList)
            {
                baseEntity.InvalidateNetworkCache();
            }
            double totalSeconds = stopwatch.Elapsed.TotalSeconds;

            UnityEngine.Debug.Log(string.Concat("Invalidate Network Cache took ", totalSeconds.ToString("0.00"), " seconds"));
            SaveRestore.Save(true);
        }
Exemplo n.º 9
0
 void cmdConsoleSave(ConsoleSystem.Arg arg)
 {
     if (arg.connection != null)
     {
         if (arg.connection.authLevel < saveAuth)
         {
             SendReply(arg, noAccess);
             return;
         }
     }
     SaveRestore.Save();
     SendReply(arg, saved);
 }
Exemplo n.º 10
0
 void cmdChatSave(BasePlayer player, string command, string[] args)
 {
     if (!hasPermission(player))
     {
         SendReply(player, noAccess); return;
     }
     SaveRestore.Save();
     SendReply(player, saved);
     if (args.Length > 0)
     {
         float value;
         if (float.TryParse(args[0], out value))
         {
             ConsoleSystem.Run.Server.Normal("server.saveinterval " + args[0], new object[] { });
             SendReply(player, "set: server.saveinterval " + args[0]);
         }
     }
 }
Exemplo n.º 11
0
 void cLoadNamed(ConsoleSystem.Arg arg)
 {
     if (arg.Connection != null && arg.Connection.authLevel < 2)
     {
         return;
     }
     if (arg.Args == null || arg.Args.Length < 1)
     {
         SendReply(arg, lang.GetMessage("definefilename", this, arg.Connection != null ? arg.Connection.userid.ToString() : null));
         return;
     }
     foreach (var player in BasePlayer.activePlayerList.ToList())
     {
         player.Kick(lang.GetMessage("kickreason", this));
     }
     foreach (BaseEntity current in BaseEntity.saveList.ToList())
     {
         if (current != null)
         {
             current.Kill();
         }
     }
     BaseEntity.saveList.Clear();
     ItemManager.DoRemoves();
     if (SaveRestore.Load(ConVar.Server.rootFolder + "/" + arg.Args[0], true))
     {
         if (saveAfterLoadFile)
         {
             foreach (BaseEntity current in BaseEntity.saveList)
             {
                 current.InvalidateNetworkCache();
             }
             SaveRestore.Save(true);
         }
     }
     else
     {
         SendReply(arg, lang.GetMessage("filenotfound", this, arg.Connection != null ? arg.Connection.userid.ToString() : null));
         return;
     }
 }