Tools/mmaps_generator: Move TerrainBuilder to a shared project

This commit is contained in:
Shauren
2025-11-06 18:34:58 +01:00
parent 73c1a76ab5
commit f439120b1f
16 changed files with 73 additions and 15 deletions

View File

@@ -15,6 +15,7 @@ CollectSourceFiles(
${CMAKE_CURRENT_SOURCE_DIR}/Debugging/Windows
${CMAKE_CURRENT_SOURCE_DIR}/Platform
${CMAKE_CURRENT_SOURCE_DIR}/PrecompiledHeaders
${CMAKE_CURRENT_SOURCE_DIR}/mmaps_common
${CMAKE_CURRENT_SOURCE_DIR}/network)
if(WIN32)
@@ -47,6 +48,7 @@ CollectIncludeDirectories(
PUBLIC_INCLUDES
# Exclude
${CMAKE_CURRENT_SOURCE_DIR}/PrecompiledHeaders
${CMAKE_CURRENT_SOURCE_DIR}/mmaps_common
${CMAKE_CURRENT_SOURCE_DIR}/network)
target_include_directories(common
@@ -65,7 +67,6 @@ target_link_libraries(common
boost
fmt
g3dlib
Detour
sfmt
utf8cpp
openssl
@@ -104,4 +105,5 @@ unset(PRIVATE_SOURCES)
unset(PRIVATE_PCH_HEADER)
unset(PUBLIC_INCLUDES)
add_subdirectory(mmaps_common)
add_subdirectory(network)

View File

@@ -129,6 +129,12 @@
# define TC_GAME_API TC_API_IMPORT
#endif
#ifdef TRINITY_API_EXPORT_MMAPS_COMMON
# define TC_MMAPS_COMMON_API TC_API_EXPORT
#else
# define TC_MMAPS_COMMON_API TC_API_IMPORT
#endif
#define UI64FMTD "%" PRIu64
#define UI64LIT(N) UINT64_C(N)

View File

@@ -0,0 +1,52 @@
# This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
#
# This file is free software; as a special exception the author gives
# unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
CollectSourceFiles(
${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE_SOURCES)
GroupSources(${CMAKE_CURRENT_SOURCE_DIR})
CollectIncludeDirectories(
${CMAKE_CURRENT_SOURCE_DIR}
PUBLIC_INCLUDES
)
add_library(mmaps_common ${PRIVATE_SOURCES})
target_link_libraries(mmaps_common
PRIVATE
trinity-core-interface
PUBLIC
common
Recast
Detour)
target_include_directories(mmaps_common
PUBLIC
${PUBLIC_INCLUDES})
set_target_properties(mmaps_common
PROPERTIES
COMPILE_WARNING_AS_ERROR ${WITH_WARNINGS_AS_ERRORS}
DEFINE_SYMBOL TRINITY_API_EXPORT_MMAPS_COMMON
FOLDER "tools")
if(BUILD_SHARED_LIBS)
if(UNIX)
install(TARGETS mmaps_common
LIBRARY
DESTINATION lib)
elseif(WIN32)
install(TARGETS mmaps_common
RUNTIME
DESTINATION "${CMAKE_INSTALL_PREFIX}")
endif()
endif()

View File

@@ -29,6 +29,8 @@
namespace MMAP
{
std::unique_ptr<VMAP::VMapManager> (*CreateVMapManager)(uint32 mapId);
TerrainBuilder::TerrainBuilder(boost::filesystem::path const& inputDirectory, bool skipLiquid) :
m_inputDirectory(inputDirectory),
m_skipLiquid (skipLiquid)

View File

@@ -79,7 +79,7 @@ namespace MMAP
std::vector<unsigned short> offMeshConnectionsFlags;
};
class TerrainBuilder
class TC_MMAPS_COMMON_API TerrainBuilder
{
public:
explicit TerrainBuilder(boost::filesystem::path const& inputDirectory, bool skipLiquid);
@@ -125,6 +125,8 @@ namespace MMAP
/// Get the liquid type for a specific position
static map_liquidHeaderTypeFlags getLiquidType(int square, map_liquidHeaderTypeFlags const (&liquid_type)[16][16]);
};
TC_MMAPS_COMMON_API extern std::unique_ptr<VMAP::VMapManager> (*CreateVMapManager)(uint32 mapId);
}
#endif

View File

@@ -20,7 +20,6 @@
#include "Log.h"
#include "MMapDefines.h"
#include "Memory.h"
#include "PathCommon.h"
#include "StringFormat.h"
#include "VMapManager.h"
#include <DetourNavMeshBuilder.h>
@@ -98,7 +97,7 @@ namespace MMAP
MeshData meshData;
std::unique_ptr<VMAP::VMapManager> vmapManager = VMapFactory::CreateVMapManager(mapID);
std::unique_ptr<VMAP::VMapManager> vmapManager = CreateVMapManager(mapID);
// get heightmap data
m_terrainBuilder.loadMap(mapID, tileX, tileY, meshData, vmapManager.get());

View File

@@ -31,7 +31,7 @@ struct TileConfig;
using detour_unique_ptr = std::unique_ptr<unsigned char, decltype(Trinity::unique_ptr_deleter<unsigned char*, &::dtFree>())>;
class TileBuilder
class TC_MMAPS_COMMON_API TileBuilder
{
public:
TileBuilder(boost::filesystem::path const& inputDirectory,

View File

@@ -45,7 +45,7 @@ namespace MMAP
// singleton class
// holds all all access to mmap loading unloading and meshes
class TC_COMMON_API MMapManager
class TC_MMAPS_COMMON_API MMapManager
{
public:
MMapManager();

View File

@@ -37,7 +37,7 @@ target_include_directories(game-interface
target_link_libraries(game-interface
INTERFACE
shared
Detour)
mmaps_common)
add_library(game
${PRIVATE_SOURCES})

View File

@@ -17,10 +17,8 @@ add_executable(mmaps_generator ${PRIVATE_SOURCES})
target_link_libraries(mmaps_generator
PRIVATE
trinity-core-interface
PUBLIC
extractor_common
Recast
zlib)
mmaps_common)
CollectIncludeDirectories(
${CMAKE_CURRENT_SOURCE_DIR}

View File

@@ -98,11 +98,6 @@ namespace MMAP
};
extern std::unordered_map<uint32, MapEntry> sMapStore;
namespace VMapFactory
{
std::unique_ptr<VMAP::VMapManager> CreateVMapManager(uint32 mapId);
}
}
#endif

View File

@@ -488,6 +488,8 @@ int main(int argc, char** argv)
LoadMap(inputDirectory, dbcLocales[0], silent, -4);
MMAP::CreateVMapManager = &MMAP::VMapFactory::CreateVMapManager;
MMAP::MapBuilder builder(inputDirectory, outputDirectory, maxAngle, maxAngleNotSteep, skipLiquid, skipContinents, skipJunkMaps,
skipBattlegrounds, debugOutput, bigBaseUnit, mapnum, offMeshInputPath, threads);