Exemplo n.º 1
0
        static void ReadMVER(BinaryReader fileReader, WDT wdt)
        {
            var type = fileReader.ReadUInt32();
            var size = fileReader.ReadUInt32();

            wdt.Version = fileReader.ReadInt32();
        }
Exemplo n.º 2
0
        public static ADT ExtractWMOOnly(WDT wdt)
        {
            var tileId = new TileIdentifier
            {
                MapId   = wdt.Entry.Id,
                MapName = wdt.Name,
                TileX   = 0,
                TileY   = 0
            };
            var adt = new ADT(tileId);

            adt.ObjectDefinitions.Capacity = wdt.WmoDefinitions.Count;
            foreach (var wmoDefinition in wdt.WmoDefinitions)
            {
                adt.ObjectDefinitions.Add(wmoDefinition);
            }

            adt.ObjectFiles.Capacity = wdt.WmoFiles.Count;
            foreach (var wmoFile in wdt.WmoFiles)
            {
                adt.ObjectFiles.Add(wmoFile);
            }

            foreach (var def in adt.ObjectDefinitions)
            {
                LoadWMO(wdt.Manager, def);
            }

            adt.IsWMOOnly = true;

            return(adt);
        }
Exemplo n.º 3
0
        private bool LoadTile(int tileX, int tileY)
        {
            if (!WDT.HasTile(tileX, tileY))
            {
                return(false);
            }

            if (IsTileLoaded(tileX, tileY))
            {
                return(false);
            }

            // Generate tile
            var tile = new ADT(Continent, tileX, tileY, WDT);

            tile.Read();
            tile.Generate();

            // Generate renderer
            var renderer = new ADTRenderer(Controller, tile);

            renderer.Generate();
            renderer.Bind(Controller.Shader);
            ADTRenderer.Renderers.Add(renderer);

            return(true);
        }
Exemplo n.º 4
0
        static void ReadMODF(BinaryReader fileReader, WDT wdt)
        {
            var type = fileReader.ReadUInt32();
            var size = fileReader.ReadUInt32();

            var endPos = fileReader.BaseStream.Position + size;

            while (fileReader.BaseStream.Position < endPos)
            {
                var objectDef = new MapObjectDefinition();
                var nameIndex = fileReader.ReadInt32();                // 4 bytes
                objectDef.FilePath     = wdt.WmoFiles[nameIndex];
                objectDef.UniqueId     = fileReader.ReadUInt32();      // 4 bytes
                objectDef.Position     = fileReader.ReadVector3();     // 12 bytes
                objectDef.OrientationA = fileReader.ReadSingle();      // 4 Bytes
                objectDef.OrientationB = fileReader.ReadSingle();      // 4 Bytes
                objectDef.OrientationC = fileReader.ReadSingle();      // 4 Bytes
                objectDef.Extents      = fileReader.ReadBoundingBox(); // 12*2 bytes
                objectDef.Flags        = fileReader.ReadUInt16();      // 2 bytes
                objectDef.DoodadSetId  = fileReader.ReadUInt16();      // 2 bytes
                objectDef.NameSet      = fileReader.ReadUInt16();      // 2 bytes
                fileReader.ReadUInt16();                               // padding

                wdt.WmoDefinitions.Add(objectDef);
            }
        }
Exemplo n.º 5
0
 public void AddWDTGlobalmodel(WDT s)
 {
     if (s.ModelScene != null)
     {
         AddWMOScene(s.ModelScene);
     }
 }
Exemplo n.º 6
0
        public static void ExtractAndWriteAll()
        {
            foreach (MapId mapId in Enum.GetValues(typeof(MapId)))
            {
                var name = TileIdentifier.GetName(mapId);
                if (string.IsNullOrEmpty(name))
                {
                    Console.WriteLine(@"No ADT for map {0}.", mapId);
                    continue;
                }

                var terrain = new SimpleTerrain(mapId);

                for (var tileX = 0; tileX < 64; tileX++)
                {
                    for (var tileY = 0; tileY < 64; tileY++)
                    {
                        string       filePath;
                        MpqLibrarian mpqFinder;
                        if (!ADTReader.TryGetADTPath(mapId, tileX, tileY, out filePath, out mpqFinder))
                        {
                            continue;
                        }
                        // try to extract from MPQ
                        //var adt = ADTReader.ReadADT(terrain, tileX, tileY);
                        //Console.WriteLine(@"EXPORTING: Tile ({0}, {1}) in Map {2} ...", tileX, tileY, mapId);
                        //Console.WriteLine(@"Extraction will take a while, please have patience...");

                        try
                        {
                            var adt = WDT.LoadTile(mapId, tileX, tileY);
                            if (adt != null)
                            {
                                Console.WriteLine(@"Tile ({0}, {1}) in Map {2} has been imported...", tileX, tileY, mapId);
                                Console.WriteLine(@"Writing to file...");

                                // export to file
                                SimpleTileWriter.WriteADT(adt);

                                // try loading again
                                Console.WriteLine(@"Loading extracted tile and generating Navigation mesh...");
                                terrain.ForceLoadTile(tileX, tileY);

                                if (terrain.IsAvailable(tileX, tileY))
                                {
                                    Console.WriteLine(@"Done. Tile ({0}, {1}) in Map {2} has been loaded successfully.", tileX, tileY, mapId);
                                    continue;
                                }
                            }
                        }
                        catch (ArgumentException)
                        {
                        }

                        Console.WriteLine(@"Loading FAILED: Tile ({0}, {1}) in Map {2} could not be loaded", tileX, tileY, mapId);
                    }
                }
            }
        }
Exemplo n.º 7
0
        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", "Map.dbc");
            DBC     maps = new DBC();
            DBCFile mf   = new DBCFile("Map.dbc", maps);


            for (int i = 0; i < maps.recordCount; i++)
            {
                int mapID = maps.GetInt(i, 0);
                // Console.WriteLine("   ID:" + maps.GetInt(i, 0));
                // Console.WriteLine(" File: " + maps.GetString(i, 1));
                // Console.WriteLine(" Name: " + maps.GetString(i, 4)); // the file!!!

                if (mapID == continentID) // file == continentFile)
                {
                    //  Console.WriteLine(String.Format("{0,4} {1}", mapID, maps.GetString(i, 1)));
                    string file = maps.GetString(i, 1);
                    continentFile = file;



                    wdt = new WDT();

                    wdtf = new WDTFile(archive, continentFile, wdt, wmomanager, modelmanager);
                    if (!wdtf.loaded)
                    {
                        wdt = null; // bad
                    }
                    else
                    {
                        // Console.WriteLine("  global Objects " + wdt.gwmois.Count + " Models " + wdt.gwmois.Count);
                        //global_triangles.color = new float[3] { 0.8f, 0.8f, 1.0f };
                    }
                    return(continentFile);
                }
            }
            if (wdt == null)
            {
                return("Failed to open file files for continent ID" + continentID);
            }
            return(null);
        }
Exemplo n.º 8
0
 public void TestWorldModelContinent()
 {
     var wdt = new WDT(@"World\maps\OrgrimmarInstance\OrgrimmarInstance.wdt");
     Assert.IsTrue(wdt.IsValid);
     Assert.IsTrue(wdt.IsGlobalModel);
     Assert.IsNotNullOrEmpty(wdt.ModelFile);
     Assert.IsNotNull(wdt.ModelDefinition);
 }
Exemplo n.º 9
0
        public MCAL(MapChunk chunk, WDT wdt, Chunk c) : base(c, false)
        {
            Debug.Assert(wdt != null, "WDT Cannot be null in order to read MCAL!");

            _mapChunk = chunk;
            _wdt      = wdt;

            Read();
        }
Exemplo n.º 10
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == string.Empty)
            {
                return;
            }

            try
            {
                var wdt = new WDT("World\\maps\\" + textBox1.Text + "\\" + textBox1.Text + ".wdt");
                if (!wdt.IsValid)
                {
                    return;
                }

                if (wdt.IsGlobalModel)
                {
                    _dungeonBuilder             = new DungeonBuilder(textBox1.Text);
                    _dungeonBuilder.OnProgress += OnProgress;
                    _builder       = null;
                    _lastProgressX = 0;
                }
                else
                {
                    int startX = startXBox.Text.Length > 0 ? int.Parse(startXBox.Text) : 0;
                    int startY = startYBox.Text.Length > 0 ? int.Parse(startYBox.Text) : 0;
                    int countX = countXBox.Text.Length > 0 ? int.Parse(countXBox.Text) : (64 - startX);
                    int countY = countYBox.Text.Length > 0 ? int.Parse(countYBox.Text) : (64 - startY);

                    startXBox.Text     = startX.ToString();
                    startXBox.ReadOnly = true;
                    startYBox.Text     = startY.ToString();
                    startYBox.ReadOnly = true;
                    countXBox.Text     = countX.ToString();
                    countXBox.ReadOnly = true;
                    countYBox.Text     = countY.ToString();
                    countYBox.ReadOnly = true;

                    _builder              = new ContinentBuilder(textBox1.Text, startX, startY, countX, countY);
                    _builder.OnTileEvent += OnTileEvent;
                    _dungeonBuilder       = null;
                }
            }
            catch (Exception)
            {
                return;
            }

            textBox1.ReadOnly = true;
            button1.Enabled   = false;
            button1.Text      = "Building...";
            _buildThread      = new Thread(RunBuild)
            {
                IsBackground = true
            };
            _buildThread.Start();
        }
Exemplo n.º 11
0
        public ContinentRenderer(RenderView controller, string continent, WDT wdt)
        {
            Controller  = controller;
            Continent   = continent;
            WDT         = wdt;
            ADTRenderer = new GenericCollectionRenderer <ADTRenderer>(Controller);

            InitializeView();
        }
Exemplo n.º 12
0
    public void MapSelected(string mapName)
    {
        UIManager.GetComponent <MinimapHandler>().ClearMinimaps();
        string mapPath     = null;
        string minimapPath = null;

        // Parse WDT //
        if (!WDT.Flags.ContainsKey(mapName))
        {
            string wdtPath = @"world\maps\" + mapName + @"\";
            WDT.Load(wdtPath, mapName);
        }

        if (Settings.Data[2] == "2") // extracted //
        {
            mapPath     = Settings.Data[8] + @"\" + @"world\maps\" + mapName + @"\";
            minimapPath = Settings.Data[8] + @"\" + @"world\minimaps\" + mapName + @"\";
        }
        else if (Settings.Data[2] == "0") // game //
        {
            mapPath     = @"world\maps\" + mapName;
            minimapPath = @"world\minimaps\" + mapName;
        }
        bool MinimapsExist = CheckForMinimaps(minimapPath);

        if (CheckForADTs(mapPath))
        {
            if (CheckForMinimaps(minimapPath))
            {
                PanelErrorMessage.SetActive(false);
                // load minimaps //
                UIManager.GetComponent <MinimapHandler>().LoadMinimaps(minimapPath, mapName);
            }
            else
            {
                PanelErrorMessage.SetActive(true);
                ErrorMessageText.text = "No minimaps available.";
                // load blank minimaps //
                UIManager.GetComponent <MinimapHandler>().LoadBlankMinimaps(mapPath, mapName);
            }
        }
        else
        {
            if (CheckForMinimaps(minimapPath))
            {
                PanelErrorMessage.SetActive(true);
                ErrorMessageText.text = "WMO Only Zone.";
                // load minimaps //
                UIManager.GetComponent <MinimapHandler>().LoadMinimaps(minimapPath, mapName);
            }
            else
            {
                PanelErrorMessage.SetActive(true);
                ErrorMessageText.text = "WMO Only Zone." + "\n" + "No minimaps available.";
            }
        }
    }
Exemplo n.º 13
0
        public GlobalModelRenderer(RenderView controller, WDT wdt)
        {
            Controller = controller;

            MeshRenderers = new GenericCollectionRenderer <MeshRenderer>(Controller);

            InitializeView(wdt);
            Generate(wdt);
            MeshRenderers.Bind(Controller.Shader);
        }
Exemplo n.º 14
0
        public ContinentBuilder(string continent, int startX, int startY, int countX, int countY)
        {
            StartX = startX;
            StartY = startY;
            CountX = countX;
            CountY = countY;

            Continent = continent;
            TileMap   = new WDT("World\\Maps\\" + continent + "\\" + continent + ".wdt");
        }
Exemplo n.º 15
0
        /// <summary>
        /// Writes all height maps to the default MapDir
        /// </summary>
        public static void ExportMapTiles(WDT wdt)
        {
            // Map data should only be stored per map
            ClearObjectData();
            var path = Path.Combine(TerrainDisplayConfig.MapDir, wdt.Entry.Id.ToString());

            if (wdt.IsWMOOnly)
            {
                // This Map has no Tiles, but the MODF still needs to be written
                // These maps will be considered to have one tile at {0, 0} with only one MODF written therein
                var adt = ExtractWMOOnly(wdt);
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }
                using (var file = File.Create(Path.Combine(path, TerrainConstants.GetMapFilename(0, 0))))
                {
                    WriteTileInfo(file, adt);
                }
                return;
            }

            // Read in the ADT data - this includes height and liquid maps, WMO information and M2 information
            TerrainInfo = ExtractMapTiles(wdt);

            // Write the processed data to files
            var count = 0;

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }

            for (var tileX = 0; tileX < TerrainConstants.TilesPerMapSide; tileX++)
            {
                for (var tileY = 0; tileY < TerrainConstants.TilesPerMapSide; tileY++)
                {
                    var adt = TerrainInfo[tileY, tileX];
                    if (adt == null)
                    {
                        continue;
                    }

                    var filePath = Path.Combine(path, TerrainConstants.GetMapFilename(tileX, tileY));
                    using (var file = File.Create(filePath))
                    {
                        WriteTileInfo(file, adt);
                        file.Close();
                    }
                    count++;
                }
            }

            log.Info("Extracted {0} tiles for {1}.", count, wdt.Entry.Id);
        }
Exemplo n.º 16
0
    public void Button_LoadTestMap(string id)
    {
        CASCHandler = CASC.GetComponent <CascHandler>().cascHandler;
        //World.ClearAllTerrain();
        uint    WdtFileDataId = 0;
        Vector2 currentSelectedPlayerSpawn = Vector2.zero;

        switch (id)
        {
        case "BC":
        {
            WdtFileDataId = 828395;
            currentSelectedPlayerSpawn = new Vector2(32, 27);
        }
        break;

        case "Wrath":
        {
            WdtFileDataId = 822688;
            currentSelectedPlayerSpawn = new Vector2(18, 24);
        }
        break;

        case "Cata":
        {
            WdtFileDataId = 782779;
            currentSelectedPlayerSpawn = new Vector2(33, 35);
        }
        break;

        case "MoP":
        {
            WdtFileDataId = 805681;
            currentSelectedPlayerSpawn = new Vector2(32, 31);
        }
        break;

        default:
            Debug.Log("Unknown Map");
            break;
        }

        WDT.WDTEntries.Clear();
        if (WDT.ParseWDT(WdtFileDataId))
        {
            //World.LoadSingleADT(WdtFileDataId, currentSelectedPlayerSpawn);
            //world2.LoadWorld(WdtFileDataId, currentSelectedPlayerSpawn);
            world.LoadWorld(WdtFileDataId, currentSelectedPlayerSpawn);
        }
        else
        {
            Debug.Log("Error");
        }
    }
Exemplo n.º 17
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);
            }
        }
Exemplo n.º 18
0
        public void AddInstance(string path)
        {
            var wdt = new WDT(path);

            if (!wdt.IsValid || !wdt.IsGlobalModel)
            {
                return;
            }

            Components.Add(new WmoDrawer(this, wdt.ModelFile, wdt.ModelDefinition));
        }
Exemplo n.º 19
0
        static void ReadWDT()
        {
            const string path = @"PVPZone01.wdt";
            var          wdt  = new WDT(path);
            var          sw   = Stopwatch.StartNew();

            wdt.Read();
            sw.Stop();

            Console.WriteLine("Loaded {0} chunks from '{1}' in {2}ms", wdt.Data.Chunks.Count, System.IO.Path.GetFileName(path), sw.ElapsedMilliseconds);
        }
Exemplo n.º 20
0
        private void btnAbout_Click(object sender, EventArgs e)
        {
            IFormatter formatter = new BinaryFormatter();
            Stream     stream    = new FileStream("azeroth.wdt", FileMode.Open, FileAccess.Read, FileShare.Read);
            WDT        obj       = (WDT)formatter.Deserialize(stream);

            stream.Close();

            Console.WriteLine("n1: {0}", obj.magic);
            Console.WriteLine("n2: {0}", obj.size);
            Console.WriteLine("str: {0}", obj.version);
        }
Exemplo n.º 21
0
 public void TestDungeonWithWater()
 {
     //MpqManager.Initialize("S:\\World of Warcraft");
     var wdt = new WDT("world\\maps\\orgrimmarinstance\\orgrimmarinstance.wdt");
     Assert.IsTrue(wdt.IsValid && wdt.IsGlobalModel);
     var file = wdt.ModelFile;
     var model = new WorldModelRoot(file);
     var verts = new System.Collections.Generic.List<Vector3>();
     var tris = new System.Collections.Generic.List<Triangle<uint>>();
     WorldModelHandler.InsertModelGeometry(verts, tris, wdt.ModelDefinition, model);
     Assert.IsFalse(verts.Any(v => float.IsNaN(v.X) || float.IsNaN(v.Y) || float.IsNaN(v.Z)));
 }
Exemplo n.º 22
0
        public static void CreateAndWriteAllMeshes()
        {
            GC.AddMemoryPressure(1 * 1024 * 1024 * 1024);
            foreach (MapId mapId in Enum.GetValues(typeof(MapId)))
            {
                var name = TileIdentifier.GetName(mapId);
                if (string.IsNullOrEmpty(name))
                {
                    Console.WriteLine(@"No ADT for map {0}.", mapId);
                    continue;
                }

                var terrain = new SimpleTerrain(mapId);

                for (var tileX = 0; tileX < 64; tileX++)
                {
                    for (var tileY = 0; tileY < 64; tileY++)
                    {
                        string       filePath;
                        MpqLibrarian mpqFinder;
                        if (!ADTReader.TryGetADTPath(mapId, tileX, tileY, out filePath, out mpqFinder))
                        {
                            continue;
                        }

                        try
                        {
                            var adt = WDT.LoadTile(mapId, tileX, tileY);
                            if (adt != null)
                            {
                                // try loading
                                Console.WriteLine(@"Loading extracted tile and generating Navigation mesh...");
                                terrain.ForceLoadTile(tileX, tileY);

                                if (terrain.IsAvailable(tileX, tileY))
                                {
                                    Console.WriteLine(@"Done. Tile ({0}, {1}) in Map {2} has been loaded successfully.", tileX, tileY, mapId);
                                    terrain.Tiles[tileX, tileY] = null;
                                    continue;
                                }
                            }
                        }
                        catch (ArgumentException)
                        {
                        }

                        Console.WriteLine(@"Extracting FAILED: Tile ({0}, {1}) in Map {2} could not be loaded", tileX, tileY, mapId);
                    }
                }
            }
            GC.RemoveMemoryPressure(1 * 1024 * 1024 * 1024);
        }
 public override void Close()
 {
     archive.Close();
     wdt          = null;
     wdtf         = null;
     modelmanager = null;
     wmomanager   = null;
     zoneToMapId  = null;
     mapIdToFile  = null;
     areaIdToName = null;
     archive      = null;
     base.Close();
 }
Exemplo n.º 24
0
        static void ReadMPHD(BinaryReader fileReader, WDT wdt)
        {
            var type = fileReader.ReadUInt32();
            var size = fileReader.ReadUInt32();

            wdt.Header.Header1 = (WDTFlags)fileReader.ReadInt32();
            wdt.Header.Header2 = fileReader.ReadInt32();
            wdt.Header.Header3 = fileReader.ReadInt32();
            wdt.Header.Header4 = fileReader.ReadInt32();
            wdt.Header.Header5 = fileReader.ReadInt32();
            wdt.Header.Header6 = fileReader.ReadInt32();
            wdt.Header.Header7 = fileReader.ReadInt32();
            wdt.Header.Header8 = fileReader.ReadInt32();
        }
Exemplo n.º 25
0
        static void ReadWDT()
        {
            string path = string.Format(@"World\Maps\{0}\{0}.wdt", "WailingCaverns");
            var    sw   = Stopwatch.StartNew();
            var    wdt  = new WDT(path);

            Console.WriteLine("Loaded {0} chunks from '{1}' in {2}ms", wdt.Data.Chunks.Count, System.IO.Path.GetFileName(path), sw.ElapsedMilliseconds);
            wdt.GenerateGlobalModel();
            sw.Stop();
            var geom = new Geometry();

            geom.AddWDTGlobalmodel(wdt);
            geom.SaveWavefrontObject("WailingCaverns.obj");
        }
Exemplo n.º 26
0
        public WDTRenderer(RenderView controller, string mapName, WDT wdt)
        {
            Controller = controller;
            WDT        = wdt;

            if (wdt.IsGlobalModel)
            {
                Renderer = new GlobalModelRenderer(controller, wdt);
            }
            else
            {
                Renderer = new ContinentRenderer(controller, mapName, wdt);
            }
        }
Exemplo n.º 27
0
        public void Generate(WDT wdt)
        {
            if (!wdt.IsGlobalModel)
            {
                return;
            }
            wdt.GenerateGlobalModel();

            // Terrain
            AddMeshRenderer(wdt.ModelScene.Terrain);
            // Doodads
            AddMeshRenderer(wdt.ModelScene.Doodads);
            // Liquids
            AddMeshRenderer(wdt.ModelScene.Liquids);
        }
Exemplo n.º 28
0
        public static void ExtractAllADTs()
        {
            foreach (MapId mapId in Enum.GetValues(typeof(MapId)))
            {
                var name = TileIdentifier.GetName(mapId);
                if (string.IsNullOrEmpty(name))
                {
                    Console.WriteLine(@"No ADT for map {0}.", mapId);
                    continue;
                }

                var wdt = new WDT(mapId);

                for (var tileX = 0; tileX < 64; tileX++)
                {
                    for (var tileY = 0; tileY < 64; tileY++)
                    {
                        string       filePath;
                        MpqLibrarian mpqFinder;
                        if (!ADTReader.TryGetADTPath(mapId, tileX, tileY, out filePath, out mpqFinder))
                        {
                            continue;
                        }

                        try
                        {
                            wdt.TileProfile[tileX, tileY] = true;
                            var adt = ADTReader.ReadADT(wdt, tileX, tileY);
                            if (adt != null)
                            {
                                adt.GenerateMapWithNoSimplification();
                                Console.WriteLine(@"Tile ({0}, {1}) in Map {2} has been imported...", tileX, tileY, mapId);
                                Console.WriteLine(@"Writing to file...");

                                // export to file
                                SimpleTileWriter.WriteADT(adt);
                                continue;
                            }
                        }
                        catch (ArgumentException)
                        {
                        }

                        Console.WriteLine(@"Extracting FAILED: Tile ({0}, {1}) in Map {2} could not be loaded", tileX, tileY, mapId);
                    }
                }
            }
        }
Exemplo n.º 29
0
    ////////////////////

    ////////////////////
    #region UI Interaction

    // Map Selected in the Map List Panel //
    public void MapSelected(string mapName)
    {
        MiniMap.ClearMinimaps(minimapScrollPanel);

        if (miniMap.TryGetValue(mapName, out MapRecord record))
        {
            selectedWDTId = record.WdtFileDataID;

            WDTFileDataIDText.text = $"{selectedWDTId}";
            WDT.WDTEntries.Clear();
            if (WDT.ParseWDT(record.WdtFileDataID))
            {
                MiniMap.Load(record.WdtFileDataID, minimapScrollPanel);
            }
        }
    }
Exemplo n.º 30
0
    public IEnumerator LoadMap(CancellationToken cancel)
    {
        var fullName     = gameFiles.Wdt(gameContext.CurrentMap.Directory);
        var wdtBytesTask = gameFiles.ReadFile(fullName);

        yield return(wdtBytesTask);

        using var wdtBytes = wdtBytesTask.Result;
        if (wdtBytes == null)
        {
            Console.WriteLine("Couldn't load map " + fullName + ". This is quite fatal...");
            yield break;
        }

        ClearData();

        var wdt = new WDT(new MemoryBinaryReader(wdtBytes));

        Vector3 middlePosSum = Vector3.Zero;
        int     chunks       = 0;

        foreach (var chunk in wdt.Chunks)
        {
            presentChunks[chunk.Y, chunk.X] = chunk.HasAdt;
            if (chunk.HasAdt)
            {
                middlePosSum += chunk.MiddlePosition;
                chunks++;
            }
        }
        if (chunks > 0)
        {
            var avg = middlePosSum / chunks;
            if (gameContext.CurrentMap.Id == 1)
            {
                // this is just for debugging
                // since the beginning this was the initial position in Kalimdor
                // and it is quite nice starting position
                cameraManager.Relocate(new Vector3(285.396f, -4746.17f, 9.48428f + 20).ToOpenGlPosition());
            }
            else
            {
                cameraManager.Relocate(avg.ToOpenGlPosition().WithY(100));
            }
        }
    }
Exemplo n.º 31
0
 public static void Draw(WDT wdt)
 {
 }
Exemplo n.º 32
0
        public void SetContinent(string continent)
        {
            continentFile = continent;

            wdt = new WDT();

            wdtf = new WDTFile(archive, continentFile, wdt, wmomanager, modelmanager);
            if (!wdtf.loaded)
            {
                wdt = null; // bad
                throw new Exception("Failed to set continent to: " + continent);
            }
            else
            {

                // Console.WriteLine("  global Objects " + wdt.gwmois.Count + " Models " + wdt.gwmois.Count);
                //global_triangles.color = new float[3] { 0.8f, 0.8f, 1.0f };
            }
        }
Exemplo n.º 33
0
 public override void Close()
 {
     archive.Close();
     wdt = null;
     wdtf = null;
     modelmanager = null;
     wmomanager = null;
     zoneToMapId = null;
     mapIdToFile = null;
     areaIdToName = null;
     archive = null;
     base.Close();
 }
Exemplo n.º 34
0
        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", "Map.dbc");
            DBC maps = new DBC();
            DBCFile mf = new DBCFile("Map.dbc", maps);

            for (int i = 0; i < maps.recordCount; i++)
            {
                int mapID = maps.GetInt(i, 0);
               // Console.WriteLine("   ID:" + maps.GetInt(i, 0));
               // Console.WriteLine(" File: " + maps.GetString(i, 1));
               // Console.WriteLine(" Name: " + maps.GetString(i, 4)); // the file!!!

                if (mapID == continentID) // file == continentFile)
                {
                    //  Console.WriteLine(String.Format("{0,4} {1}", mapID, maps.GetString(i, 1)));
                    string file = maps.GetString(i, 1);
                    continentFile = file;

                    wdt = new WDT();

                    wdtf = new WDTFile(archive, continentFile, wdt, wmomanager, modelmanager);
                    if (!wdtf.loaded)
                        wdt = null; // bad
                    else
                    {

                       // Console.WriteLine("  global Objects " + wdt.gwmois.Count + " Models " + wdt.gwmois.Count);
                        //global_triangles.color = new float[3] { 0.8f, 0.8f, 1.0f };
                    }
                    return continentFile;
                }
            }
            if (wdt == null)
            {
                return "Failed to open file files for continent ID" + continentID;
            }
            return null;
        }