예제 #1
0
파일: MST.cs 프로젝트: Knuxfan24/HedgeLib
        // Methods
        public override void Load(Stream fileStream)
        {
            // Header
            var reader = new BINAReader(fileStream);

            Header = reader.ReadHeader();

            string sig = reader.ReadSignature(4);

            if (sig != Signature)
            {
                throw new InvalidSignatureException(Signature, sig);
            }

            uint messageTableOffset = reader.ReadUInt32();
            uint messageCount       = reader.ReadUInt32();

            long namePos = reader.BaseStream.Position;

            reader.JumpTo(messageTableOffset, false);
            Name = reader.ReadNullTerminatedString();
            reader.JumpTo(namePos, true);

            for (uint i = 0; i < messageCount; i++)
            {
                string name        = string.Empty;
                string text        = string.Empty;
                string placeholder = string.Empty;

                uint nameOffset        = reader.ReadUInt32();
                uint textOffset        = reader.ReadUInt32();
                uint placeholderOffset = reader.ReadUInt32();

                long pos = reader.BaseStream.Position;

                reader.JumpTo(nameOffset, false);
                name = reader.ReadNullTerminatedString();
                reader.JumpTo(textOffset, false);
                text = reader.ReadNullTerminatedStringUTF16();
                if (placeholderOffset != 0)
                {
                    reader.JumpTo(placeholderOffset, false);
                    placeholder = reader.ReadNullTerminatedString();
                }

                MSTEntries entry = new MSTEntries(name, text, placeholder);
                entries.Add(entry);

                reader.JumpTo(pos, true);
            }
        }