public void WriteHeader(LocrTextFile file)
 {
     if (file.HeaderValue != null)
     {
         Write(file.HeaderValue.Value);
     }
 }
Пример #2
0
        public GlacierLocrBinaryReader(FileStream fileStream, HitmanVersion version, LocrTextFile file)
            : base(fileStream)
        {
            switch (version)
            {
            case HitmanVersion.Version1:
            case HitmanVersion.Version1Epic:
            {
                int initialOffset = ReadInt32();
                NumberOfLanguages = initialOffset / 4;
                SetDefaultStrategy();
                fileStream.Seek(0, SeekOrigin.Begin);
            }
            break;

            case HitmanVersion.Version2:
            {
                file.HeaderValue = ReadByte();
                int initialOffset = ReadInt32();
                NumberOfLanguages = (initialOffset - 1) / 4;
                CypherStrategy    = new CypherStrategyTEA();
                fileStream.Seek(1, SeekOrigin.Begin);
            }
            break;
            }
        }
        public LocrTextFile LoadLocrFile(string path, string category)
        {
            var file = new LocrTextFile();

            using (var openFile = File.Open(path, FileMode.Open))
                using (var reader = new GlacierLocrBinaryReader(openFile, _version, file))
                {
                    var languageSections = new List <LanguageSection>();

                    for (var i = 0; i < reader.NumberOfLanguages; i++)
                    {
                        var section = new LanguageSection();
                        section.StartingOffset = reader.ReadUInt32();

                        languageSections.Add(section);
                    }

                    for (var i = 0; i < reader.NumberOfLanguages; i++)
                    {
                        var section = languageSections[i];
                        if (section.StartingOffset != uint.MaxValue)
                        {
                            var numberOfEntries = reader.ReadInt32();

                            for (int y = 0; y < numberOfEntries; y++)
                            {
                                var entry = new TextEntry();
                                entry.Hash  = reader.ReadUInt32();
                                entry.Entry = reader.ReadString();
                                section.Entries.Add(entry);
                            }
                        }
                    }

                    file.Name             = Path.GetFileName(path);
                    file.Category         = category;
                    file.LanguageSections = languageSections;
                    file.CypherStrategy   = reader.CypherStrategy;
                }

            return(file);
        }