public static OtbmInfo Load(ByteArrayFileTreeStream stream, ByteArrayStreamReader reader) { OtbmInfo otbmInfo = new OtbmInfo(); stream.Seek(Origin.Current, 6); otbmInfo.OtbmVersion = (OtbmVersion)reader.ReadUInt(); otbmInfo.Width = reader.ReadUShort(); otbmInfo.Height = reader.ReadUShort(); otbmInfo.MajorVersion = (OtbVersion)reader.ReadUInt(); otbmInfo.MinorVersion = (TibiaVersion)reader.ReadUInt(); return(otbmInfo); }
public static OtbmFile Load(string path) { using (ByteArrayFileTreeStream stream = new ByteArrayFileTreeStream(path)) { ByteArrayStreamReader reader = new ByteArrayStreamReader(stream); OtbmFile file = new OtbmFile(); file.otbmInfo = OtbmInfo.Load(stream, reader); if (stream.Child()) { file.mapInfo = MapInfo.Load(stream, reader); if (stream.Child()) { file.areas = new List <Area>(); while (true) { switch ((OtbmType)reader.ReadByte()) { case OtbmType.Area: file.areas.Add(Area.Load(stream, reader)); break; case OtbmType.Towns: if (stream.Child()) { file.towns = new List <Town>(); while (true) { file.towns.Add(Town.Load(stream, reader)); if (!stream.Next()) { break; } } } break; case OtbmType.Waypoints: if (stream.Child()) { file.waypoints = new List <Waypoint>(); while (true) { file.waypoints.Add(Waypoint.Load(stream, reader)); if (!stream.Next()) { break; } } } break; } if (!stream.Next()) { break; } } } } return(file); } }