Esempio n. 1
0
        private static void ReadFileHeaders(StreamReader sr, SaveGameFile savegame)
        {
            using (var br = new BinaryReader(sr.BaseStream))
            {
                if (br.ReadInt32() == 4)
                {
                    savegame.IsCompressed = true;
                }

                sr.BaseStream.Seek(4, SeekOrigin.Current);

                var blockCount = br.ReadInt32();
                for (int j = 0; j < blockCount; j++)
                {
                    byte[] fileHeader = new byte[ByteBlockSize];
                    br.Read(fileHeader, 0, ByteBlockSize);
                    var internalName = ByteHandler.GetStringFromBytes(fileHeader, 8);

                    savegame.DataBlockNameList.Add(new DataFile()
                    {
                        InternalName = internalName,
                        FileType     = DataFileFacts.GetDataFileFact(internalName).Type,
                        Position     = ByteHandler.GetIntFromBytes(fileHeader, 0),
                        Length       = ByteHandler.GetIntFromBytes(fileHeader, 4)
                    });
                }
            }
        }
Esempio n. 2
0
        private static Dictionary <int, string> GetDataFileStringsDictionary(SaveGameFile savegame, DataFileType type)
        {
            Dictionary <int, string> fileContents = new Dictionary <int, string>();
            var fileFacts = DataFileFacts.GetDataFileFacts().First(x => x.Type == type);
            var fileData  = DataFileLoaders.GetDataFileBytes(savegame, fileFacts.Type, fileFacts.DataSize);

            for (int i = 0; i < fileData.Count; i++)
            {
                fileContents.Add(i, ByteHandler.GetStringFromBytes(fileData[i], 0, fileFacts.StringLength));
            }

            return(fileContents);
        }