Esempio n. 1
0
        public void CrossingTest()
        {
            MpqManager.Initialize("S:\\WoW");
            byte[] dataA, dataB;

            // Build tile A
            {
                var builder = new TileBuilder("Azeroth", 31, 49);
                dataA = builder.Build(new ConsoleLog());
                Assert.IsNotNull(dataA);
            }

            // Build tile B
            {
                var builder = new TileBuilder("Azeroth", 32, 49);
                dataB = builder.Build(new ConsoleLog());
                Assert.IsNotNull(dataB);
            }

            // Load into mesh
            var pather = new Pather("Azeroth");
            Assert.IsTrue(pather.LoadTile(dataA));
            Assert.IsTrue(pather.LoadTile(dataB));
            
            // and try pathing, coords from AzerothMeshTest -> TileCrossing which is a non-building version of this
            var start = new Vector3(-9467.8f, 64.2f, 55.9f);
            var end = new Vector3(-9248.9f, -93.35f, 70.3f);
            var path = pather.FindPath(start, end);

            // check result
            Assert.IsNotNull(path);
            Assert.Greater(path.Count, 0);
            Assert.Less((end - path[path.Count-1].Location).Length(), 3f);
        }
Esempio n. 2
0
        public void FlightmasterTest()
        {
            MpqManager.Initialize("S:\\WoW");

            var builder = new TileBuilder("Azeroth", 36, 49);
            builder.Build(new ConsoleLog());
        }
Esempio n. 3
0
        public void Build()
        {
            if (Directory.Exists(Continent))
            {
                Directory.Delete(Continent, true);
            }

            Directory.CreateDirectory(Continent);

            for (int y = StartY; y < (StartY + CountY); y++)
            {
                for (int x = StartX; x < (StartX + CountX); x++)
                {
                    if (!TileMap.HasTile(x, y))
                    {
                        continue;
                    }

                    if (File.Exists(GetTilePath(x, y)))
                    {
                        Report(x, y, TileEventType.CompletedBuild);
                        continue;
                    }

                    Report(x, y, TileEventType.StartedBuild);

                    var    builder = new TileBuilder(Continent, x, y);
                    byte[] data    = null;

                    try
                    {
                        data = builder.Build(new MemoryLog());
                    }
                    catch (Exception)
                    {
                    }

                    if (data == null)
                    {
                        Report(x, y, TileEventType.FailedBuild);
                    }
                    else
                    {
                        SaveTile(x, y, data);
                        Report(x, y, TileEventType.CompletedBuild);
                    }

                    if (builder.Log is MemoryLog)
                    {
                        (builder.Log as MemoryLog).WriteToFile(Continent + "\\" + Continent + "_" + x + "_" + y + ".log");
                    }
                }
            }
        }
Esempio n. 4
0
        public void Build()
        {
            if (!Directory.Exists(_meshDir + Continent))
            {
                Directory.CreateDirectory(_meshDir + Continent);
            }

            _timeStart = (int)Environment.TickCount;
            // Start mesh creation
            for (int y = StartY; y < (StartY + CountY); y++)
            {
                for (int x = StartX; x < (StartX + CountX); x++)
                {
                    _doneTiles[x, y] = 0;
                    // Get if tile is alreay Build
                    if (File.Exists(GetTileNameAndPath(x, y)) || File.Exists(GetTileLockAndPath(x, y)) || File.Exists(GetTileNoneAndPath(x, y)))
                    {
                        continue;
                    }
                    else
                    {
                        // If the tile does not exist in wow
                        if (!TileMap.HasTile(x, y))
                        {
                            continue;
                        }
                    }
                    try
                    {
                        string tlock = GetTileLockAndPath(x, y);
                        var    sw    = File.CreateText(tlock);
                        current = tlock;
                        sw.Close();
                    }
                    catch (Exception)
                    {
                        // In case 2 builder are trying to create the same file
                        continue;
                    }
                    ScanFolderAndReport();
                    Report(x, y, TileEventType.StartedBuild);
                    _currentTile = Continent + "_" + x + "_" + y;
                    Console.WriteLine(_currentTile);
                    var    builder = new TileBuilder(Continent, x, y);
                    byte[] data    = null;
                    bool   failed  = false;

                    try
                    {
                        builder.PrepareData(new MemoryLog());
                        for (int i = 0; i < Constant.Division; i++)
                        {
                            for (int j = 0; j < Constant.Division; j++)
                            {
                                data = null;
                                data = builder.Build(i, j);
                                if (data == null)
                                {
                                    failed = true;
                                    var none = File.CreateText(GetTileNoneAndPath(x, y));
                                    none.Close();
                                    break;
                                }
                                SaveTile(x, y, data, i, j);
                            }
                            if (failed)
                            {
                                break;
                            }
                        }
                    }
                    catch (Exception)
                    {
                        File.Delete(GetTileLockAndPath(x, y));
                        throw;
                    }

                    _meshBuild++;

                    if (failed)
                    {
                        Report(x, y, TileEventType.FailedBuild);
                    }
                    else
                    {
                        _doneTiles[x, y] = 1;
                        Report(x, y, TileEventType.CompletedBuild);
                    }
                    File.Delete(GetTileLockAndPath(x, y));
                }
            }
            ScanFolderAndReport();
            _currentTile = "Finish";
            MpqManager.Close();
        }
Esempio n. 5
0
        public void Build()
        {
            if (Directory.Exists(Continent))
                Directory.Delete(Continent, true);

            Directory.CreateDirectory(Continent);

            for (int y = StartY; y < (StartY+CountY); y++)
            {
                for (int x = StartX; x < (StartX+CountX); x++)
                {
                    if (!TileMap.HasTile(x, y))
                        continue;

                    if (File.Exists(GetTilePath(x, y)))
                    {
                        Report(x, y, TileEventType.CompletedBuild);
                        continue;
                    }

                    Report(x, y, TileEventType.StartedBuild);

                    var builder = new TileBuilder(Continent, x, y);
                    byte[] data = null;

                    try
                    {
                        data = builder.Build(new MemoryLog());
                    }
                    catch (Exception)
                    {
                    }

                    if (data == null)
                        Report(x, y, TileEventType.FailedBuild);
                    else
                    {
                        SaveTile(x, y, data);
                        Report(x, y, TileEventType.CompletedBuild);
                    }

                    if (builder.Log is MemoryLog)
                        (builder.Log as MemoryLog).WriteToFile(Continent + "\\" + Continent + "_" + x + "_" + y + ".log");
                }
            }
        }