static void Process(DBCMapEntry entry) { if (Parsed == null) { throw new Exception("WDTParser.Parsed must be set before calling WDTParser.Process"); } var dir = entry.MapDirName; var wdtDir = Path.Combine(baseDir, dir); var wdtName = dir; var wdtFilePath = Path.Combine(wdtDir, wdtName + Extension); if (!MpqManager.FileExists(wdtFilePath)) return; var wdt = new WDTFile { Manager = MpqManager, Entry = entry, Name = wdtName, Path = wdtDir }; using (var fileReader = new BinaryReader(MpqManager.OpenFile(wdtFilePath))) { ReadMVER(fileReader, wdt); ReadMPHD(fileReader, wdt); ReadMAIN(fileReader, wdt); if (wdt.Header.IsWMOMap) { // No terrain, the map is a "global" wmo // MWMO and MODF chunks follow wdt.IsWMOOnly = true; ReadMWMO(fileReader, wdt); ReadMODF(fileReader, wdt); } } Parsed(wdt); }
public static ADT Process(MpqManager mpqManager, DBCMapEntry mapId, int tileX, int tileY) { var fileName = string.Format("{0}\\{0}_{1}_{2}{3}", mapId.MapDirName, tileY, tileX, Extension); var filePath = Path.Combine(baseDir, fileName); var adt = new ADT(fileName); if (!mpqManager.FileExists(filePath)) { log.Error("ADT file does not exist: ", filePath); } var fileReader = new BinaryReader(mpqManager.OpenFile(filePath)); ReadMVER(fileReader, adt); ReadMHDR(fileReader, adt); if (adt.Header.offsInfo != 0) { fileReader.BaseStream.Position = adt.Header.Base + adt.Header.offsInfo; ReadMCIN(fileReader, adt); } if (adt.Header.offsTex != 0) { fileReader.BaseStream.Position = adt.Header.Base + adt.Header.offsTex; ReadMTEX(fileReader, adt); } if (adt.Header.offsModels != 0) { fileReader.BaseStream.Position = adt.Header.Base + adt.Header.offsModels; ReadMMDX(fileReader, adt); } if (adt.Header.offsModelIds != 0) { fileReader.BaseStream.Position = adt.Header.Base + adt.Header.offsModelIds; ReadMMID(fileReader, adt); } if (adt.Header.offsMapObjects != 0) { fileReader.BaseStream.Position = adt.Header.Base + adt.Header.offsMapObjects; ReadMWMO(fileReader, adt); } if (adt.Header.offsMapObjectIds != 0) { fileReader.BaseStream.Position = adt.Header.Base + adt.Header.offsMapObjectIds; ReadMWID(fileReader, adt); } if (adt.Header.offsDoodadDefinitions != 0) { fileReader.BaseStream.Position = adt.Header.Base + adt.Header.offsDoodadDefinitions; ReadMDDF(fileReader, adt); } if (adt.Header.offsObjectDefinitions != 0) { fileReader.BaseStream.Position = adt.Header.Base + adt.Header.offsObjectDefinitions; ReadMODF(fileReader, adt); } if (adt.Header.offsFlightBoundary != 0) { fileReader.BaseStream.Position = adt.Header.Base + adt.Header.offsFlightBoundary; ReadMFBO(fileReader, adt); } if (adt.Header.offsMH2O != 0) { fileReader.BaseStream.Position = adt.Header.Base + adt.Header.offsMH2O; ReadMH2O(fileReader, adt); } ReadMCNK(fileReader, adt); fileReader.Close(); return adt; }