public void Load(EndianBinaryReader stream) { // Store the position of the stream so we can reset back to it after we jump to read children. long streamPos = stream.BaseStream.Position; DisplayName = Encoding.GetEncoding("shift-jis").GetString(stream.ReadBytesUntil(0)); stream.BaseStream.Position = streamPos + 0x20; short entryCount = stream.ReadInt16(); Trace.Assert(stream.ReadInt16() == 0x00); // Padding int entryOffset = stream.ReadInt32(); stream.BaseStream.Position = entryOffset; for (int i = 0; i < entryCount; i++) { CategoryEntry entry = new CategoryEntry(); entry.Load(stream); Entries.Add(entry); } // Reset the stream to the start of the struct (+ size of struct) since reading the sub-options jumps us // around in the stream. stream.BaseStream.Position = streamPos + 0x28; }
private string ReadStringAtOffset(EndianBinaryReader reader, uint stringTableOffset, uint offset) { // Jump to the string table position, read the string and then restore the position. long curPos = reader.BaseStream.Position; uint stringOffset = offset + stringTableOffset; reader.BaseStream.Position = stringOffset; byte[] bytes = reader.ReadBytesUntil(0x00); string result = Encoding.GetEncoding("shift_jis").GetString(bytes); reader.BaseStream.Position = curPos; return result; }
public void Load(EndianBinaryReader stream) { long streamPos = stream.BaseStream.Position; DisplayName = Encoding.GetEncoding("shift-jis").GetString(stream.ReadBytesUntil(0)); stream.BaseStream.Position = streamPos + 0x21; MapName = Encoding.GetEncoding("shift-jis").GetString(stream.ReadBytesUntil(0)); stream.BaseStream.Position = streamPos + 0x29; RoomIndex = stream.ReadByte(); SpawnIndex = stream.ReadByte(); LayerIndex = (Layer)stream.ReadByte(); }