Esempio n. 1
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);
                    }
                }
            }
        }
Esempio n. 2
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);
                 }
             }
         }
     }
 }
 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);
                     }
                 }
             }
         }
     }
 }
        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 ");
                        }
                    }
                }
            }
        }