diff options
| author | Shauren <shauren.trinity@gmail.com> | 2018-04-22 01:01:48 +0200 |
|---|---|---|
| committer | Shauren <shauren.trinity@gmail.com> | 2019-02-23 22:00:05 +0100 |
| commit | 7b561373a892c74870a21cf31687df4afd554495 (patch) | |
| tree | 2161514b5f1d1c8e4fdf2bc57b9c285ae8973d4e /src/tools | |
| parent | 8d19fcbc469e0b37a323c876a15097fbe848d884 (diff) | |
Tools/mmaps_generator: Give land priority during area merges over liquids
Closes #21700
(cherry picked from commit edb2b16f546d18bb66f1527dddb6189f617ec1b3)
Diffstat (limited to 'src/tools')
| -rw-r--r-- | src/tools/mmaps_generator/MapBuilder.cpp | 13 | ||||
| -rw-r--r-- | src/tools/mmaps_generator/PathCommon.h | 3 | ||||
| -rw-r--r-- | src/tools/mmaps_generator/PathGenerator.cpp | 41 | ||||
| -rw-r--r-- | src/tools/mmaps_generator/TerrainBuilder.cpp | 32 |
4 files changed, 61 insertions, 28 deletions
diff --git a/src/tools/mmaps_generator/MapBuilder.cpp b/src/tools/mmaps_generator/MapBuilder.cpp index 200c0b85917..b71199df508 100644 --- a/src/tools/mmaps_generator/MapBuilder.cpp +++ b/src/tools/mmaps_generator/MapBuilder.cpp @@ -590,7 +590,7 @@ namespace MMAP // mark all walkable tiles, both liquids and solids unsigned char* triFlags = new unsigned char[tTriCount]; - memset(triFlags, NAV_GROUND, tTriCount*sizeof(unsigned char)); + memset(triFlags, NAV_AREA_GROUND, tTriCount*sizeof(unsigned char)); rcClearUnwalkableTriangles(m_rcContext, tileCfg.walkableSlopeAngle, tVerts, tVertCount, tTris, tTriCount, triFlags); rcRasterizeTriangles(m_rcContext, tVerts, tVertCount, tTris, triFlags, tTriCount, *tile.solid, config.walkableClimb); delete[] triFlags; @@ -696,8 +696,15 @@ namespace MMAP // set polygons as walkable // TODO: special flags for DYNAMIC polygons, ie surfaces that can be turned on and off for (int i = 0; i < iv.polyMesh->npolys; ++i) - if (iv.polyMesh->areas[i] & RC_WALKABLE_AREA) - iv.polyMesh->flags[i] = iv.polyMesh->areas[i]; + { + if (uint8 area = iv.polyMesh->areas[i] & RC_WALKABLE_AREA) + { + if (area >= NAV_AREA_MAGMA_SLIME) + iv.polyMesh->flags[i] = 1 << (63 - area); + else + iv.polyMesh->flags[i] = NAV_GROUND; // TODO: these will be dynamic in future + } + } // setup mesh parameters dtNavMeshCreateParams params; diff --git a/src/tools/mmaps_generator/PathCommon.h b/src/tools/mmaps_generator/PathCommon.h index 26fa84c789c..3d34d28a9ed 100644 --- a/src/tools/mmaps_generator/PathCommon.h +++ b/src/tools/mmaps_generator/PathCommon.h @@ -25,6 +25,7 @@ #ifndef _WIN32 #include <cstddef> + #include <cstring> #include <dirent.h> #else #include <Windows.h> @@ -106,7 +107,7 @@ namespace MMAP errno = 0; if ((dp = readdir(dirp)) != nullptr) { - if (matchWildcardFilter(filter.c_str(), dp->d_name)) + if (strcmp(dp->d_name, ".") != 0 && strcmp(dp->d_name, "..") != 0 && matchWildcardFilter(filter.c_str(), dp->d_name)) fileList.push_back(std::string(dp->d_name)); } else diff --git a/src/tools/mmaps_generator/PathGenerator.cpp b/src/tools/mmaps_generator/PathGenerator.cpp index 8f17288e1f9..3f930042bd0 100644 --- a/src/tools/mmaps_generator/PathGenerator.cpp +++ b/src/tools/mmaps_generator/PathGenerator.cpp @@ -16,15 +16,27 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include <boost/filesystem.hpp> - -#include "PathCommon.h" +#include "Banner.h" +#include "DBCFileLoader.h" #include "MapBuilder.h" +#include "PathCommon.h" #include "Timer.h" -#include "Banner.h" +#include <boost/filesystem.hpp> +#include <unordered_map> using namespace MMAP; +namespace +{ + std::unordered_map<uint32, uint8> _liquidTypes; +} + +uint32 GetLiquidFlags(uint32 liquidId) +{ + auto itr = _liquidTypes.find(liquidId); + return itr != _liquidTypes.end() ? (1 << itr->second) : 0; +} + bool checkDirectories(bool debugOutput) { std::vector<std::string> dirFiles; @@ -239,6 +251,23 @@ int finish(char const* message, int returnValue) return returnValue; } +std::unordered_map<uint32, uint8> LoadLiquid() +{ + DBCFileLoader liquidDbc; + std::unordered_map<uint32, uint8> liquidData; + // format string doesnt matter as long as it has correct length (only used for mapping to structures in worldserver) + if (liquidDbc.Load((boost::filesystem::path("dbc") / "LiquidType.dbc").string().c_str(), "nxxixixxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")) + { + for (uint32 x = 0; x < liquidDbc.GetNumRows(); ++x) + { + DBCFileLoader::Record record = liquidDbc.getRecord(x); + liquidData[record.getUInt(0)] = record.getUInt(3); + } + } + + return liquidData; +} + int main(int argc, char** argv) { Trinity::Banner::Show("MMAP generator", [](char const* text) { printf("%s\n", text); }, nullptr); @@ -280,6 +309,10 @@ int main(int argc, char** argv) if (!checkDirectories(debugOutput)) return silent ? -3 : finish("Press ENTER to close...", -3); + _liquidTypes = LoadLiquid(); + if (_liquidTypes.empty()) + return silent ? -5 : finish("Failed to load LiquidType.dbc", -5); + MapBuilder builder(maxAngle, skipLiquid, skipContinents, skipJunkMaps, skipBattlegrounds, debugOutput, bigBaseUnit, mapnum, offMeshInputPath); diff --git a/src/tools/mmaps_generator/TerrainBuilder.cpp b/src/tools/mmaps_generator/TerrainBuilder.cpp index d86cf2738d2..ae73ffe9271 100644 --- a/src/tools/mmaps_generator/TerrainBuilder.cpp +++ b/src/tools/mmaps_generator/TerrainBuilder.cpp @@ -79,6 +79,8 @@ struct map_liquidHeader #define MAP_LIQUID_TYPE_SLIME 0x08 #define MAP_LIQUID_TYPE_DARK_WATER 0x10 +uint32 GetLiquidFlags(uint32 liquidId); + namespace MMAP { char const* MAP_VERSION_MAGIC = "v1.9"; @@ -418,11 +420,9 @@ namespace MMAP useLiquid = false; } else if ((liquidType & (MAP_LIQUID_TYPE_WATER | MAP_LIQUID_TYPE_OCEAN)) != 0) - liquidType = NAV_WATER; - else if (liquidType & MAP_LIQUID_TYPE_MAGMA) - liquidType = NAV_MAGMA; - else if (liquidType & MAP_LIQUID_TYPE_SLIME) - liquidType = NAV_SLIME; + liquidType = NAV_AREA_WATER; + else if ((liquidType & (MAP_LIQUID_TYPE_MAGMA | MAP_LIQUID_TYPE_SLIME)) != 0) + liquidType = NAV_AREA_MAGMA_SLIME; else useLiquid = false; } @@ -638,7 +638,7 @@ namespace MMAP /**************************************************************************/ bool TerrainBuilder::loadVMap(uint32 mapID, uint32 tileX, uint32 tileY, MeshData &meshData) { - IVMapManager* vmapManager = new VMapManager2(); + VMapManager2* vmapManager = new VMapManager2(); int result = vmapManager->loadMap("vmaps", mapID, tileX, tileY); bool retval = false; @@ -714,22 +714,14 @@ namespace MMAP vertsY = tilesY + 1; uint8* flags = liquid->GetFlagsStorage(); float* data = liquid->GetHeightStorage(); - uint8 type = NAV_EMPTY; + uint8 type = NAV_AREA_EMPTY; // convert liquid type to NavTerrain - switch (liquid->GetType() & 3) - { - case 0: - case 1: - type = NAV_WATER; - break; - case 2: - type = NAV_MAGMA; - break; - case 3: - type = NAV_SLIME; - break; - } + uint32 liquidFlags = GetLiquidFlags(liquid->GetType()); + if ((liquidFlags & (MAP_LIQUID_TYPE_WATER | MAP_LIQUID_TYPE_OCEAN)) != 0) + type = NAV_AREA_WATER; + else if ((liquidFlags & (MAP_LIQUID_TYPE_MAGMA | MAP_LIQUID_TYPE_SLIME)) != 0) + type = NAV_AREA_MAGMA_SLIME; // indexing is weird... // after a lot of trial and error, this is what works: |
