Ejemplo n.º 1
0
 public static void EraseWorld()
 {
     if (UI.main.HasPlayerStorage())
     {
         Main.ShowSaveIcon();
         try
         {
             using (StorageContainer storageContainer = UI.main.OpenPlayerStorage("Worlds"))
             {
                 worldPathName = "world" + selectedWorld + ".wld";
                 storageContainer.DeleteFile(worldPathName);
             }
         }
         catch (IOException)
         {
             UI.main.WriteError();
         }
         catch (Exception)
         {
         }
         Main.HideSaveIcon();
         worldNames[selectedWorld] = null;
     }
 }
Ejemplo n.º 2
0
        public static bool LoadWorlds()
        {
            if (!UI.main.HasPlayerStorage())
            {
                worldPathName = null;
                for (int i = 0; i < 8; i++)
                {
                    worldNames[i] = null;
                }
                return(true);
            }
            bool result = true;

            try
            {
                using (StorageContainer storageContainer = UI.main.OpenPlayerStorage("Worlds"))
                {
                    for (int j = 0; j < 8; j++)
                    {
                        string file = "world" + j.ToStringLookup() + ".wld";
                        if (storageContainer.FileExists(file))
                        {
                            try
                            {
                                using (Stream input = storageContainer.OpenFile(file, FileMode.Open))
                                {
                                    using (BinaryReader binaryReader = new BinaryReader(input))
                                    {
                                        int num = binaryReader.ReadInt32();
                                        _ = 46;
                                        if (num > 46)
                                        {
                                            binaryReader.ReadUInt32();
                                        }
                                        worldNames[j] = binaryReader.ReadString();
                                        binaryReader.Close();
                                    }
                                }
                            }
                            catch
                            {
                                Main.ShowSaveIcon();
                                storageContainer.DeleteFile(file);
                                Main.HideSaveIcon();
                                worldNames[j] = null;
                                result        = false;
                            }
                        }
                        else
                        {
                            worldNames[j] = null;
                        }
                    }
                    return(result);
                }
            }
            catch (IOException)
            {
                UI.main.ReadError();
                for (int k = 0; k < 8; k++)
                {
                    worldNames[k] = null;
                }
                return(true);
            }
            catch (Exception)
            {
                return(true);
            }
        }