Exemplo n.º 1
0
 object OnSaveLoad(Dictionary <BaseEntity, ProtoBuf.Entity> dictionary)
 {
     if (Initialized || loadReload)
     {
         return(null);
     }
     if (!enableLoadOverride)
     {
         return(null);
     }
     if (!loadReload)
     {
         List <string> filename = Interface.Oxide.DataFileSystem.ReadObject <List <string> >(this.Title);
         if (filename != null && filename.Count == 2)
         {
             if (filename[1] == "custom")
             {
                 loadReload = true;
                 if (SaveRestore.Load(filename[0], allowOutOfDateSaves))
                 {
                     dictionary.Clear();
                     Puts(lang.GetMessage("loadoverride", this));
                     return(true);
                 }
             }
         }
     }
     return(null);
 }
Exemplo n.º 2
0
        void OnNewSave(string strFilename)
        {
            if (Initialized || loadReload || !enableLoadOverride)
            {
                return;
            }
            List <string> filename = Interface.Oxide.DataFileSystem.ReadObject <List <string> >(this.Title);

            if (filename != null && filename.Count == 2 && !filename[0].Contains(SaveRestore.SaveFileName))
            {
                Puts(lang.GetMessage("loadoverridecancel", this));
                return;
            }
            if (filename != null && filename.Count == 2)
            {
                if (filename[1] == "custom")
                {
                    loadReload = true;
                    if (SaveRestore.Load(filename[0], allowOutOfDateSaves))
                    {
                        Puts(lang.GetMessage("loadoverride", this));
                    }
                }
            }
        }
Exemplo n.º 3
0
 public void Initialize(
     bool loadSave            = true,
     string saveFile          = "",
     bool allowOutOfDateSaves = false,
     bool skipInitialSpawn    = false)
 {
     if (!ConVar.Server.official)
     {
         ExceptionReporter.set_Disabled(true);
     }
     this.persistance = new UserPersistance(ConVar.Server.rootFolder);
     this.SpawnMapEntities();
     if (Object.op_Implicit((Object)SingletonComponent <SpawnHandler> .Instance))
     {
         using (TimeWarning.New("SpawnHandler.UpdateDistributions", 0.1f))
             ((SpawnHandler)SingletonComponent <SpawnHandler> .Instance).UpdateDistributions();
     }
     if (loadSave)
     {
         skipInitialSpawn = SaveRestore.Load(saveFile, allowOutOfDateSaves);
     }
     if (Object.op_Implicit((Object)SingletonComponent <SpawnHandler> .Instance))
     {
         if (!skipInitialSpawn)
         {
             using (TimeWarning.New("SpawnHandler.InitialSpawn", 200L))
                 ((SpawnHandler)SingletonComponent <SpawnHandler> .Instance).InitialSpawn();
         }
         using (TimeWarning.New("SpawnHandler.StartSpawnTick", 200L))
             ((SpawnHandler)SingletonComponent <SpawnHandler> .Instance).StartSpawnTick();
     }
     this.CreateImportantEntities();
     this.auth = (ConnectionAuth)((Component)this).GetComponent <ConnectionAuth>();
 }
Exemplo n.º 4
0
 public void Initialize(bool loadSave = true, string saveFile = "", bool allowOutOfDateSaves = false, bool skipInitialSpawn = false)
 {
     this.persistance = new UserPersistance(ConVar.Server.rootFolder);
     this.SpawnMapEntities();
     if (SingletonComponent <SpawnHandler> .Instance)
     {
         using (TimeWarning timeWarning = TimeWarning.New("SpawnHandler.UpdateDistributions", 0.1f))
         {
             SingletonComponent <SpawnHandler> .Instance.UpdateDistributions();
         }
     }
     if (loadSave)
     {
         skipInitialSpawn = SaveRestore.Load(saveFile, allowOutOfDateSaves);
     }
     if (SingletonComponent <SpawnHandler> .Instance)
     {
         if (!skipInitialSpawn)
         {
             using (timeWarning = TimeWarning.New("SpawnHandler.InitialSpawn", (long)200))
             {
                 SingletonComponent <SpawnHandler> .Instance.InitialSpawn();
             }
         }
         using (timeWarning = TimeWarning.New("SpawnHandler.StartSpawnTick", (long)200))
         {
             SingletonComponent <SpawnHandler> .Instance.StartSpawnTick();
         }
     }
     this.CreateImportantEntities();
     this.auth = base.GetComponent <ConnectionAuth>();
 }
Exemplo n.º 5
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.º 6
0
 void cLoadMap(ConsoleSystem.Arg arg)
 {
     if (arg.connection != null && arg.connection.authLevel < 2)
     {
         return;
     }
     if (arg.Args == null || arg.Args.Length != 1 || arg.Args[0] != "force")
     {
         SendReply(arg, lang.GetMessage("needconfirm", this, arg.connection != null ? arg.connection.userid.ToString() : null));
         return;
     }
     foreach (var player in BasePlayer.activePlayerList.ToList())
     {
         player.Kick(lang.GetMessage("kickreason", this, player.UserIDString));
     }
     SaveRestore.Load(ConVar.Server.rootFolder + "/" + SaveRestore.SaveFileName, allowOutOfDateSaves);
 }
Exemplo n.º 7
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;
     }
 }