Ejemplo n.º 1
0
        private SaveFileMetaData GetFileMetaData(BinaryReader br, string sgType)
        {
            SaveFileMetaData saveFileMetaData = new SaveFileMetaData();

            // if we have a GSAV but it isn't a OakSaveGame...return unassigned SaveFileMetaData. Covers case of profile.sav
            if (!sgType.Equals("OakSaveGame"))
            {
                return(saveFileMetaData);
            }

            int remainingDataLength = br.ReadInt32();

            byte[] buf = br.ReadBytes(remainingDataLength);
            SaveBogoCrypt.Decrypt(buf, 0, remainingDataLength);
            Character characterSave = Serializer.Deserialize <Character>(new MemoryStream(buf));

            saveFileMetaData.PlayerLevel = CalculateLevel(characterSave);
            saveFileMetaData.NickName    = characterSave.PreferredCharacterName;
            //characterSave.GameStatsDatas.ForEach(a => Console.WriteLine(a.StatPath + " " + a.StatValue));
            switch (characterSave.PlayerClassData.PlayerClassPath)
            {
            case @"/Game/PlayerCharacters/Operative/PlayerClassId_Operative.PlayerClassId_Operative":
                saveFileMetaData.ClassName = "Operative";
                break;

            case @"/Game/PlayerCharacters/Beastmaster/PlayerClassId_Beastmaster.PlayerClassId_Beastmaster":
                saveFileMetaData.ClassName = "Beastmaster";
                break;

            case @"/Game/PlayerCharacters/SirenBrawler/PlayerClassId_Siren.PlayerClassId_Siren":
                saveFileMetaData.ClassName = "Siren";
                break;

            case @"/Game/PlayerCharacters/Gunner/PlayerClassId_Gunner.PlayerClassId_Gunner":
                saveFileMetaData.ClassName = "Gunner";
                break;

            default:
                break;
            }

            return(saveFileMetaData);
        }
Ejemplo n.º 2
0
        // Loop because some times the file is in use by other applications and we can't read
        private void ReadFileLoop()
        {
            int      retryTimes = 3;
            TimeSpan sleepyTime = TimeSpan.FromSeconds(.25);

            for (int i = 0; i < retryTimes; i++)
            {
                try
                {
                    // Use reader to parse information
                    using (BinaryReader br = new BinaryReader(File.OpenRead(_fileInfo.FullName)))
                    {
                        ASCIIEncoding ascii      = new ASCIIEncoding();
                        string        fileHeader = ascii.GetString(br.ReadBytes(4));

                        if (fileHeader.Equals("GVAS"))
                        {
                            IsGSAVFile = true;
                        }
                        else
                        {
                            return; // no need to parse any further
                        }
                        SkipSomeMetaDataWeDontCareAbout(br);

                        string saveGameType = ReadUEString(br); // Hopefully of type OakSaveGame or maybe OakProfile
                        _metaData = GetFileMetaData(br, saveGameType);
                    }
                    break;
                }
                catch (Exception)
                {
                    Console.WriteLine("sleepyTime");
                    Thread.Sleep(sleepyTime);
                }
            }
        }