Example #1
0
        public MPQTriangleSupplier(Logger logger)
        {
            this.logger = logger;

            string[] archiveNames = GetArchiveNames(s => logger.WriteLine(s));

            archive = new StormDll.ArchiveSet(this.logger);
            archive.AddArchives(archiveNames);
            modelmanager = new ModelManager(archive, 80);
            wmomanager   = new WMOManager(archive, modelmanager, 30);

            archive.ExtractFile("..\\PathingAPI\\DBFilesClient\\AreaTable.dbc", "..\\PathingAPI\\PPather\\AreaTable.dbc");
            DBC     areas = new DBC();
            DBCFile af    = new DBCFile("..\\PathingAPI\\PPather\\AreaTable.dbc", areas, this.logger);

            for (int i = 0; i < areas.recordCount; i++)
            {
                int    AreaID  = (int)areas.GetUint(i, 0); //0   uint    AreaID
                int    WorldID = (int)areas.GetUint(i, 1); //1  uint    Continent (refers to a WorldID)
                int    Parent  = (int)areas.GetUint(i, 2); //2  uint    Region (refers to an AreaID)
                string Name    = areas.GetString(i, 11);

                areaIdToName.Add(AreaID, Name);
            }

            for (int i = 0; i < areas.recordCount; i++)
            {
                int    AreaID  = (int)areas.GetUint(i, 0);
                int    WorldID = (int)areas.GetUint(i, 1);
                int    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;
                }
                try
                {
                    zoneToMapId.Add(TotalName, WorldID);
                    //logger.WriteLine(TotalName + " => " + WorldID);
                }
                catch
                {
                    int id;
                    zoneToMapId.TryGetValue(TotalName, out id);
                    ////  logger.WriteLine("Duplicate: " + TotalName + " " + WorldID +" " + id);
                }
                //0      uint    AreaID
                //1     uint    Continent (refers to a WorldID)
                //2     uint    Region (refers to an AreaID)
            }
        }
Example #2
0
        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;

            archive = new StormDll.ArchiveSet();
            string regGameDir = archive.SetGameDirFromReg();
            //string gameDir = "F:\\World of Warcraft\\Data\\";
            //archive.SetGameDir(gameDir);

            Console.WriteLine("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");
            DBC areas = new DBC();
            DBCFile af = new DBCFile("PPather\\AreaTable.dbc", areas);
            for (int i = 0; i < areas.recordCount; i++)
            {
                int AreaID = (int)areas.GetUint(i, 0);
                int WorldID = (int)areas.GetUint(i, 1);
                int Parent = (int)areas.GetUint(i, 2);
                string Name = areas.GetString(i, 11);

                areaIdToName.Add(AreaID, Name);

                if (WorldID != 0 && WorldID != 1 && WorldID != 530)
                {
                    ////   Console.WriteLine(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++)
            {
                int AreaID = (int)areas.GetUint(i, 0);
                int WorldID = (int)areas.GetUint(i, 1);
                int 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;
                try
                {
                    zoneToMapId.Add(TotalName, WorldID);
                    //Console.WriteLine(TotalName + " => " + WorldID);
                }
                catch
                {
                    int id;
                    zoneToMapId.TryGetValue(TotalName, out id);
                    ////  Console.WriteLine("Duplicate: " + TotalName + " " + WorldID +" " + id);
                }
                //0 	 uint 	 AreaID
                //1 	uint 	Continent (refers to a WorldID)
                //2 	uint 	Region (refers to an AreaID)
            }
        }