Пример #1
0
    public void WriteObjectSave(ref SavedObject.Builder saveobj)
    {
        NetEntityID netEntityID;

        using (Recycler <objectDeployable, objectDeployable.Builder> recycler = objectDeployable.Recycler())
        {
            objectDeployable.Builder builder = recycler.OpenBuilder();
            builder.SetCreatorID(this.creatorID);
            builder.SetOwnerID(this.ownerID);
            saveobj.SetDeployable(builder);
        }
        using (Recycler <objectICarriableTrans, objectICarriableTrans.Builder> recycler1 = objectICarriableTrans.Recycler())
        {
            objectICarriableTrans.Builder builder1 = recycler1.OpenBuilder();
            if (!this._carrier || (int)NetEntityID.Of(this._carrier, out netEntityID) == 0)
            {
                builder1.ClearTransCarrierID();
            }
            else
            {
                builder1.SetTransCarrierID(netEntityID.id);
            }
            saveobj.SetCarriableTrans(builder1);
        }
    }
Пример #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();
        }
Пример #3
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();
            });
        }
Пример #4
0
 public void WriteObjectSave(ref SavedObject.Builder saveobj)
 {
     using (Recycler <objectFireBarrel, objectFireBarrel.Builder> recycler = objectFireBarrel.Recycler())
     {
         objectFireBarrel.Builder builder = recycler.OpenBuilder();
         builder.SetOnFire(this.isOn);
         saveobj.SetFireBarrel(builder);
     }
 }
Пример #5
0
        private void SaveInstances(ref WorldSave.Builder save)
        {
            using (Recycler <SavedObject, SavedObject.Builder> recycler = SavedObject.Recycler())
            {
                if (recycler == null)
                {
                    Logger.LogError("[Fougerite WorldSave] Recycler is null, what the hell?");
                    return;
                }
                SavedObject.Builder builder = recycler.OpenBuilder();
                int num = -2147483648;
                List <ServerSave> CopiedList = new List <ServerSave>();

                int count = ServerSaveManager.Instances.All.Count;
                for (int i = 0; i < count; i++)
                {
                    // Ensure check, since the list can change during save.
                    if (ServerSaveManager.Instances.All.Count <= i)
                    {
                        break;
                    }

                    ServerSave save2 = ServerSaveManager.Instances.All[i];
                    if (save2 != null)
                    {
                        CopiedList.Add(save2);
                    }
                }

                foreach (ServerSave save2 in CopiedList)
                {
                    if (save2 != null)
                    {
                        bool flag;
                        builder.Clear();
                        if ((flag = ((int)save2.REGED) == 1) || (((int)save2.REGED) == 2))
                        {
                            num++;
                            int sortOrder = num;
                            if (flag)
                            {
                                save2.SaveInstance_NetworkView(ref builder, sortOrder);
                            }
                            else
                            {
                                save2.SaveInstance_NGC(ref builder, sortOrder);
                            }
                        }

                        save.AddInstanceObject(builder);
                    }
                }
            }
        }
Пример #6
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();
        }
Пример #7
0
 private void SaveScene(ref WorldSave.Builder save)
 {
     if (s.keys != null)
     {
         using (Recycler <SavedObject, SavedObject.Builder> recycler = SavedObject.Recycler())
         {
             SavedObject.Builder saveobj = recycler.OpenBuilder();
             for (int i = 0; i < s.keys.Length; i++)
             {
                 int        num2  = s.keys[i];
                 ServerSave save2 = s.values[i];
                 if (save2 != null)
                 {
                     saveobj.Clear();
                     saveobj.SetId(num2);
                     save2.SaveServerSaveables(ref saveobj);
                     save.AddSceneObject(saveobj);
                 }
             }
         }
     }
 }
Пример #8
0
 private void SaveScene(ref WorldSave.Builder save)
 {
     if (s.keys != null)
     {
         using (Recycler <SavedObject, SavedObject.Builder> recycler = SavedObject.Recycler())
         {
             SavedObject.Builder saveobj = recycler.OpenBuilder();
             for (int i = 0; i < s.keys.Length; i++)
             {
                 int        num2  = s.keys[i];
                 ServerSave save2 = s.values[i];
                 if (save2 != null)
                 {
                     try
                     {
                         saveobj.Clear();
                         saveobj.SetId(num2);
                         save2.SaveServerSaveables(ref saveobj);
                         save.AddSceneObject(saveobj);
                     }
                     catch (Exception ex)
                     {
                         string infoObj = "";
                         try
                         {
                             infoObj = "_OwnerID: " + saveobj.StructMaster.OwnerID.ToString() + " (" + saveobj.Coords.Pos.X + ", " + saveobj.Coords.Pos.Y + ", " + saveobj.Coords.Pos.Z + ")";
                         }
                         catch (Exception ex2)
                         {
                             Logger.LogError("[ServerSAveHandler] SaveServerSaveables _OwnerID Error");
                         }
                         Logger.LogError("[ServerSAveHandler] SaveServerSaveables Error " + infoObj);
                     }
                 }
             }
         }
     }
 }
Пример #9
0
 public void WriteObjectSave(ref SavedObject.Builder saveobj)
 {
     using (Recycler <objectDeployable, objectDeployable.Builder> recycler = objectDeployable.Recycler())
     {
         objectDeployable.Builder builderForValue = recycler.OpenBuilder();
         builderForValue.SetCreatorID(this.creatorID);
         builderForValue.SetOwnerID(this.ownerID);
         saveobj.SetDeployable(builderForValue);
     }
     using (Recycler <objectICarriableTrans, objectICarriableTrans.Builder> recycler2 = objectICarriableTrans.Recycler())
     {
         NetEntityID yid;
         objectICarriableTrans.Builder builder2 = recycler2.OpenBuilder();
         if ((this._carrier != null) && (((int)NetEntityID.Of((MonoBehaviour)this._carrier, out yid)) != 0))
         {
             builder2.SetTransCarrierID(yid.id);
         }
         else
         {
             builder2.ClearTransCarrierID();
         }
         saveobj.SetCarriableTrans(builder2);
     }
 }
Пример #10
0
        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);
            }
        }
Пример #11
0
        private void SaveInstances(ref WorldSave.Builder save)
        {
            using (Recycler <SavedObject, SavedObject.Builder> recycler = SavedObject.Recycler())
            {
                if (recycler == null)
                {
                    Logger.LogError("[Fougerite WorldSave] Recycler is null, what the hell?");
                    return;
                }
                SavedObject.Builder builder = recycler.OpenBuilder();
                int num = -2147483648;
                List <ServerSave> CopiedList = new List <ServerSave>();

                int count = ServerSaveManager.Instances.All.Count;
                for (int i = 0; i < count; i++)
                {
                    // Ensure check, since the list can change during save.
                    if (ServerSaveManager.Instances.All.Count <= i)
                    {
                        break;
                    }

                    ServerSave save2 = ServerSaveManager.Instances.All[i];

                    if (save2 != null && save2.gameObject != null)
                    {
                        //StructureMaster element = save2.gameObject.GetComponent<StructureMaster>();

                        //if (element)
                        //{
                        //    if (element._structureComponents != null && element._structureComponents.Count > 0) {
                        //        CopiedList.Add(save2);
                        //    } else
                        //    {
                        //        Logger.Log("[Save Error] item bugado removido =  ownerID:" + element.ownerID + " " + element.name + " " + element.transform.position.ToString());
                        //        element.OnDestroy();
                        //    }
                        //} else
                        //{
                        CopiedList.Add(save2);
                        //}
                    }
                }

                foreach (ServerSave save2 in CopiedList)
                {
                    if (save2 != null)
                    {
                        try
                        {
                            builder.Clear();

                            try
                            {
                                bool flag;
                                if ((flag = ((int)save2.REGED) == 1) || (((int)save2.REGED) == 2))
                                {
                                    num++;
                                    int sortOrder = num;
                                    if (flag)
                                    {
                                        save2.SaveInstance_NetworkView(ref builder, sortOrder);
                                    }
                                    else
                                    {
                                        save2.SaveInstance_NGC(ref builder, sortOrder);
                                    }
                                }
                            }
                            catch (Exception ex)
                            {
                                SuperLogError(save2);
                                Logger.LogError("[ServerSAveHandler] SaveInstances save2.REGED Error ");
                            }

                            save.AddInstanceObject(builder);
                        }
                        catch (Exception ex)
                        {
                            SuperLogError(save2);
                            Logger.LogError("[ServerSAveHandler] SaveInstances AddInstanceObject or Clear Error ");
                        }
                    }
                }
            }
        }
Пример #12
0
        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);
            }
        }