Example #1
0
        public void ModifySaveGame(int slot, string description)
        {
            Debug.Log("ModifySaveGame " + slot);
            SaveEntry saveInfoInSlot = saveManager.GetSaveInfoInSlot(slot);

            if (saveInfoInSlot != null)
            {
                byte[] array = File.ReadAllBytes(saveInfoInSlot.Path);
                MGHelper.KeyEncode(array);
                byte[]       buffer        = CLZF2.Decompress(array);
                MemoryStream memoryStream  = new MemoryStream(buffer);
                MemoryStream memoryStream2 = new MemoryStream();
                BinaryReader binaryReader  = new BinaryReader(memoryStream);
                BinaryWriter binaryWriter  = new BinaryWriter(memoryStream2);
                binaryWriter.Write(binaryReader.ReadBytes(16));
                binaryReader.ReadString();
                binaryWriter.Write(description);
                binaryWriter.Write(binaryReader.ReadBytes((int)(memoryStream.Length - memoryStream.Position)));
                byte[] inputBytes = memoryStream2.ToArray();
                memoryStream.Dispose();
                memoryStream2.Dispose();
                byte[] array2 = CLZF2.Compress(inputBytes);
                MGHelper.KeyEncode(array2);
                File.WriteAllBytes(saveInfoInSlot.Path, array2);
                saveManager.UpdateSaveSlot(slot);
            }
        }
Example #2
0
 private void GetSaveData(int slot, string path)
 {
     if (File.Exists(path))
     {
         try
         {
             SaveEntry saveEntry = new SaveEntry
             {
                 Path = path
             };
             byte[] array = File.ReadAllBytes(path);
             MGHelper.KeyEncode(array);
             using (MemoryStream input = new MemoryStream(CLZF2.Decompress(array)))
             {
                 using (BinaryReader binaryReader = new BinaryReader(input))
                 {
                     if (new string(binaryReader.ReadChars(4)) != "MGSV")
                     {
                         throw new FileLoadException("Save file does not appear to be valid! Invalid header.");
                     }
                     if (binaryReader.ReadInt32() != 1)
                     {
                         throw new FileLoadException("Save file does not appear to be valid! Invalid version number.");
                     }
                     saveEntry.Time = DateTime.FromBinary(binaryReader.ReadInt64());
                     string input2  = binaryReader.ReadString();
                     string input3  = binaryReader.ReadString();
                     string pattern = "[<](size)[=][+](.+)[<][/](size)[>]";
                     input2           = Regex.Replace(input2, pattern, string.Empty);
                     input3           = (saveEntry.Text = Regex.Replace(input3, pattern, string.Empty));
                     saveEntry.TextJp = input2;
                 }
             }
             if (saveList.ContainsKey(slot))
             {
                 saveList.Remove(slot);
             }
             saveList.Add(slot, saveEntry);
         }
         catch (Exception ex)
         {
             Logger.LogWarning("Could not read from save file " + path + "\nException: " + ex);
             throw;
         }
     }
 }
 private void GetSaveData(int slot, string path)
 {
     if (File.Exists(path))
     {
         try
         {
             SaveEntry saveEntry = new SaveEntry();
             saveEntry.Path = path;
             SaveEntry saveEntry2 = saveEntry;
             byte[]    array      = File.ReadAllBytes(path);
             MGHelper.KeyEncode(array);
             byte[] buffer = CLZF2.Decompress(array);
             using (MemoryStream input = new MemoryStream(buffer))
             {
                 using (BinaryReader binaryReader = new BinaryReader(input))
                 {
                     string a = new string(binaryReader.ReadChars(4));
                     if (a != "MGSV")
                     {
                         throw new FileLoadException("Save file does not appear to be valid! Invalid header.");
                     }
                     int num = binaryReader.ReadInt32();
                     if (num != 1)
                     {
                         throw new FileLoadException("Save file does not appear to be valid! Invalid version number.");
                     }
                     saveEntry2.Time = DateTime.FromBinary(binaryReader.ReadInt64());
                     string textJp = binaryReader.ReadString();
                     string text   = saveEntry2.Text = binaryReader.ReadString();
                     saveEntry2.TextJp = textJp;
                 }
             }
             if (saveList.ContainsKey(slot))
             {
                 saveList.Remove(slot);
             }
             saveList.Add(slot, saveEntry2);
         }
         catch (Exception ex)
         {
             Logger.LogWarning("Could not read from save file " + path + "\nException: " + ex);
             throw;
             IL_013f :;
         }
     }
 }
Example #4
0
        public void LoadGame(int slotnum)
        {
            SaveEntry saveInfoInSlot = saveManager.GetSaveInfoInSlot(slotnum);

            if (saveInfoInSlot != null)
            {
                GameSystem.Instance.TextController.ClearText();
                GameSystem.Instance.MainUIController.FadeOut(0f, isBlocking: true);
                byte[] array = File.ReadAllBytes(saveInfoInSlot.Path);
                MGHelper.KeyEncode(array);
                byte[] buffer = tempSnapshotData = (snapshotData = CLZF2.Decompress(array));
                hasSnapshot = true;
                GameSystem.Instance.ClearAllWaits();
                GameSystem.Instance.ClearActions();
                using (MemoryStream memoryStream = new MemoryStream(buffer))
                {
                    using (BinaryReader binaryReader = new BinaryReader(memoryStream))
                    {
                        if (new string(binaryReader.ReadChars(4)) != "MGSV")
                        {
                            throw new FileLoadException("Save file does not appear to be valid! Invalid header.");
                        }
                        if (binaryReader.ReadInt32() != 1)
                        {
                            throw new FileLoadException("Save file does not appear to be valid! Invalid version number.");
                        }
                        binaryReader.ReadInt64();
                        string text  = binaryReader.ReadString();
                        string text2 = binaryReader.ReadString();
                        string text3 = binaryReader.ReadString();
                        string text4 = binaryReader.ReadString();
                        bool   num   = binaryReader.ReadBoolean();
                        GameSystem.Instance.TextController.SetPrevText(text3, 0);
                        GameSystem.Instance.TextController.SetPrevText(text4, 1);
                        if (num)
                        {
                            if (GameSystem.Instance.UseEnglishText)
                            {
                                GameSystem.Instance.TextController.TypeTextImmediately(text4);
                                GameSystem.Instance.TextController.SetFullText(text3, 0);
                            }
                            else
                            {
                                GameSystem.Instance.TextController.TypeTextImmediately(text3);
                                GameSystem.Instance.TextController.SetFullText(text4, 1);
                            }
                            tempSnapshotText[0] = text3;
                            tempSnapshotText[1] = text4;
                            GameSystem.Instance.TextController.SetAppendState(append: true);
                        }
                        else
                        {
                            GameSystem.Instance.TextController.SetFullText(text, 0);
                            GameSystem.Instance.TextController.SetFullText(text2, 1);
                            tempSnapshotText[0] = text;
                            tempSnapshotText[1] = text2;
                            GameSystem.Instance.TextController.SetAppendState(append: false);
                        }
                        callStack.Clear();
                        int num2 = binaryReader.ReadInt32();
                        for (int i = 0; i < num2; i++)
                        {
                            string           key     = binaryReader.ReadString();
                            int              linenum = binaryReader.ReadInt32();
                            BurikoScriptFile script  = scriptFiles[key];
                            callStack.Push(new BurikoStackEntry(script, 0, linenum));
                        }
                        string key2     = binaryReader.ReadString();
                        int    linenum2 = binaryReader.ReadInt32();
                        currentScript = scriptFiles[key2];
                        if (!currentScript.IsInitialized)
                        {
                            currentScript.InitializeScript();
                        }
                        currentScript.JumpToLineNum(linenum2);
                        memoryManager.LoadMemory(memoryStream);
                        AudioController.Instance.DeSerializeCurrentAudio(memoryStream);
                        GameSystem.Instance.SceneController.DeSerializeScene(memoryStream);
                        GameSystem.Instance.ForceReturnNormalState();
                        GameSystem.Instance.CloseChoiceIfExists();
                        GameSystem.Instance.TextHistory.ClearHistory();
                        GameSystem.Instance.IsSkipping = false;
                        GameSystem.Instance.IsAuto     = false;
                        GameSystem.Instance.CanSkip    = true;
                        GameSystem.Instance.CanInput   = true;
                        GameSystem.Instance.CanSave    = true;
                        int flag = GetFlag("LTextFade");
                        GameSystem.Instance.TextController.SetTextFade(flag == 1);
                        if (BurikoMemory.Instance.GetGlobalFlag("GADVMode").IntValue() == 1 && BurikoMemory.Instance.GetGlobalFlag("GLinemodeSp").IntValue() == 2 && BurikoMemory.Instance.GetFlag("NVL_in_ADV").IntValue() == 0)
                        {
                            GameSystem.Instance.MainUIController.MODdisableNVLModeINADVMode();
                        }
                        if (BurikoMemory.Instance.GetGlobalFlag("GADVMode").IntValue() == 1 && BurikoMemory.Instance.GetGlobalFlag("GLinemodeSp").IntValue() == 0 && BurikoMemory.Instance.GetFlag("NVL_in_ADV").IntValue() == 1)
                        {
                            GameSystem.Instance.MainUIController.MODenableNVLModeINADVMode();
                        }
                    }
                }
            }
        }