public string SetZone(string zone) { int continentID; if (!zoneToMapId.TryGetValue(zone, out continentID)) { int colon = zone.IndexOf(":"); if (colon == -1) { return(null); } zone = zone.Substring(colon); if (!zoneToMapId.TryGetValue(zone, out continentID)) { return(null); } } archive.ExtractFile("DBFilesClient\\Map.dbc", "PPather\\Map.dbc"); var maps = new DBC(); var mf = new DBCFile("PPather\\Map.dbc", maps); for (int i = 0; i < maps.recordCount; i++) { int mapID = maps.GetInt(i, 0); // PathGraph.Log(" ID:" + maps.GetInt(i, 0)); // PathGraph.Log(" File: " + maps.GetString(i, 1)); // PathGraph.Log(" Name: " + maps.GetString(i, 4)); // the file!!! if (mapID == continentID) // file == continentFile) { // PathGraph.Log(String.Format("{0,4} {1}", mapID, maps.GetString(i, 1))); string file = maps.GetString(i, 1); SetContinent(file); return(continentFile); } } if (wdt == null) { return("Failed to open file files for continent ID" + continentID); } return(null); }
public MPQTriangleSupplier() { string[] archiveNames = { "patch.MPQ", "enUS\\patch-enUS.MPQ", "enGB\\patch-enGB.MPQ", "lichking.MPQ", "common-2.MPQ", "common.MPQ", "expansion.MPQ", "enUS\\lichking-locale-enUS.MPQ","enUS\\locale-enUS.MPQ", "enUS\\expansion-locale-enUS.MPQ", "enGB\\lichking-locale-enGB.MPQ","enGB\\locale-enGB.MPQ", "enGB\\expansion-locale-enGB.MPQ", "enUS\\base-enUS.MPQ", "enGB\\base-enGB.MPQ", "enUS\\backup-enUS.MPQ", "enGB\\backup-enGB.MPQ" }; //StormDll.ArchiveSet archive = null; Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory); archive = new ArchiveSet(); string regGameDir = archive.SetGameDirFromReg(); //string gameDir = @"C:\WoW 335\Data\"; //archive.SetGameDir(gameDir); zoneToMapId = new Dictionary <string, int>(); mapIdToFile = new Dictionary <int, string>(); areaIdToName = new Dictionary <int, string>(); PathGraph.Log("Game dir is " + regGameDir); archive.AddArchives(archiveNames); modelmanager = new ModelManager(archive, 80); wmomanager = new WMOManager(archive, modelmanager, 30); archive.ExtractFile("DBFilesClient\\AreaTable.dbc", "PPather\\AreaTable.dbc"); var areas = new DBC(); var af = new DBCFile("PPather\\AreaTable.dbc", areas); for (int i = 0; i < areas.recordCount; i++) { var AreaID = (int)areas.GetUint(i, 0); var WorldID = (int)areas.GetUint(i, 1); var Parent = (int)areas.GetUint(i, 2); string Name = areas.GetString(i, 11); areaIdToName.Add(AreaID, Name); if (WorldID != 0 && WorldID != 1 && WorldID != 530) { //// PathGraph.Log(String.Format("{0,4} {1,3} {2,3} {3}", AreaID, WorldID, Parent, Name)); } //0 uint AreaID //1 uint Continent (refers to a WorldID) //2 uint Region (refers to an AreaID) } for (int i = 0; i < areas.recordCount; i++) { var AreaID = (int)areas.GetUint(i, 0); var WorldID = (int)areas.GetUint(i, 1); var Parent = (int)areas.GetUint(i, 2); string Name = areas.GetString(i, 11); string TotalName = ""; //areaIdToName.Add(AreaID, Name); //areaIdParent.Add(AreaID, Parent); string ParentName = ""; if (!areaIdToName.TryGetValue(Parent, out ParentName)) { TotalName = ":" + Name; } else { TotalName = Name + ":" + ParentName; } if (!zoneToMapId.ContainsKey(Name) && !zoneToMapId.ContainsKey(TotalName)) { zoneToMapId.Add(TotalName, WorldID); //PathGraph.Log(TotalName + " => " + WorldID); } else { int id; zoneToMapId.TryGetValue(TotalName, out id); //// PathGraph.Log("Duplicate: " + TotalName + " " + WorldID +" " + id); } //0 uint AreaID //1 uint Continent (refers to a WorldID) //2 uint Region (refers to an AreaID) } }