Пример #1
0
        public static void GetTileSets(WDT wdt)
        {
            if (!wdt.IsWMOOnly)
            {
                var tileSet = new ZoneTileSet();
                Tiles[(int)wdt.MapId] = tileSet;

                ZoneGrid grid;

                // Rows are along the x-axis
                for (var x = 0; x < 64; x++)
                {
                    // Columns are along the y-axis
                    for (var y = 0; y < 64; y++)
                    {
                        if (!wdt.TileProfile[y, x])
                        {
                            continue;
                        }
                        ++count;
                        var adt = ADTReader.ReadADT(wdt, x, y);
                        if (adt == null)
                        {
                            continue;
                        }

                        tileSet.ZoneGrids[y, x] = grid = new ZoneGrid(new uint[TerrainConstants.ChunksPerTileSide, TerrainConstants.ChunksPerTileSide]);

                        // Rows along the x-axis
                        for (var chunkX = 0; chunkX < 16; chunkX++)
                        {
                            // Columns along the y-axis
                            for (var chunkY = 0; chunkY < 16; chunkY++)
                            {
                                var areaId = adt.GetADTChunk(chunkY, chunkX).Header.AreaId;
                                if (Enum.IsDefined(typeof(ZoneId), areaId))
                                {
                                    grid.ZoneIds[chunkY, chunkX] = (uint)areaId;
                                }
                                else
                                {
                                    grid.ZoneIds[chunkY, chunkX] = 0;
                                }
                            }
                        }
                        //return tiles;
                    }
                }
            }
            else
            {
                log.Info("Could not read Zones from WMO: " + wdt.MapId);
            }
        }
Пример #2
0
        public static ZoneTileSet[] GetZoneTileSets()
        {
            var wowRootDir = DBCTool.FindWowDir(null);

            manager = new MpqManager(wowRootDir);

            var entryList = GetMapEntries();

            if (entryList == null)
            {
                Console.WriteLine("Error retrieving Map Entries.");
                return(null);
            }

            var tiles = new ZoneTileSet[(int)MapId.End];
            var count = 0;

            foreach (var dbcMapEntry in entryList)
            {
                var dir     = dbcMapEntry.MapDirName;
                var wdtDir  = Path.Combine(baseDir, dir);
                var wdtName = dir;

                var wdt = RegionBoundaries.Process(manager, wdtDir, wdtName + ".wdt");
                if (wdt == null)
                {
                    continue;
                }

                if ((wdt.Header.Header1 & WDTFlags.GlobalWMO) == 0)
                {
                    var tileSet = new ZoneTileSet();

                    // Read in the Tiles
                    for (var y = 0; y < 64; y++)
                    {
                        for (var x = 0; x < 64; x++)
                        {
                            if (!wdt.TileProfile[x, y])
                            {
                                continue;
                            }
                            ++count;
                            var adtName = string.Format("{0}_{1:00}_{2:00}", wdtName, x, y);
                            var adt     = Process(manager, wdtDir, adtName);
                            if (adt == null)
                            {
                                continue;
                            }

                            // Read in the TileChunks
                            for (var j = 0; j < 16; j++)
                            {
                                for (var i = 0; i < 16; i++)
                                {
                                    var areaId = adt.MapChunks[i, j].AreaId;
                                    tileSet.ZoneGrids[x, y].ZoneIds[i, j] = (ZoneId)areaId;
                                }
                            }
                        }
                    }

                    tiles[dbcMapEntry.Id] = tileSet;
                }
                else
                {
                    log.Info("Could not read Zones from WMO: " + (MapId)dbcMapEntry.Id);
                }
            }

            log.Info("Exported {0} ZoneTileSets.", count);

            return(tiles);
        }