mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-15 23:20:36 +01:00
Tools/mmaps_generator: Switch to using Log instead of printf
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
*/
|
||||
|
||||
#include "IntermediateValues.h"
|
||||
#include "Log.h"
|
||||
#include "StringFormat.h"
|
||||
|
||||
namespace MMAP
|
||||
@@ -31,9 +32,7 @@ namespace MMAP
|
||||
|
||||
void IntermediateValues::writeIV(uint32 mapID, uint32 tileX, uint32 tileY)
|
||||
{
|
||||
std::string tileString = Trinity::StringFormat("[{:02},{:02}]: ", tileX, tileY);
|
||||
|
||||
printf("%sWriting debug output... \r", tileString.c_str());
|
||||
TC_LOG_INFO("maps.mmapgen.debug", "[Map {:04}] [{:02},{:02}]: Writing debug output intermediate values...", mapID, tileX, tileY);
|
||||
|
||||
auto debugWrite = [&](char const* extension, auto const* data)
|
||||
{
|
||||
@@ -44,7 +43,7 @@ namespace MMAP
|
||||
fclose(file);
|
||||
}
|
||||
else
|
||||
perror(Trinity::StringFormat("{}Failed to open {} for writing!\n", tileString, fileName).c_str());
|
||||
TC_LOG_ERROR("maps.mmapgen.debug", "{}: [{:04}-{:02},{:02}] Failed to open {} for writing!", strerror(errno), mapID, tileX, tileY, fileName);
|
||||
};
|
||||
|
||||
if (heightfield)
|
||||
@@ -197,7 +196,7 @@ namespace MMAP
|
||||
FILE* objFile = fopen(objFileName.c_str(), "wb");
|
||||
if (!objFile)
|
||||
{
|
||||
perror(Trinity::StringFormat("Failed to open {} for writing!\n", objFileName).c_str());
|
||||
TC_LOG_ERROR("maps.mmapgen.debug", "{}: Failed to open {} for writing!", strerror(errno), objFileName);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -222,14 +221,14 @@ namespace MMAP
|
||||
|
||||
fclose(objFile);
|
||||
|
||||
printf("[%02u,%02u]: Writing debug output... \r", tileY, tileX);
|
||||
TC_LOG_INFO("maps.mmapgen.debug", "[Map {:04}] [{:02},{:02}]: Writing debug output object file...", mapID, tileY, tileX);
|
||||
|
||||
objFileName = Trinity::StringFormat("meshes/map{:04}.map", mapID);
|
||||
|
||||
objFile = fopen(objFileName.c_str(), "wb");
|
||||
if (!objFile)
|
||||
{
|
||||
perror(Trinity::StringFormat("Failed to open {} for writing!\n", objFileName).c_str());
|
||||
TC_LOG_ERROR("maps.mmapgen.debug", "{}: Failed to open {} for writing!", strerror(errno), objFileName);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -241,7 +240,7 @@ namespace MMAP
|
||||
objFile = fopen(objFileName.c_str(), "wb");
|
||||
if (!objFile)
|
||||
{
|
||||
perror(Trinity::StringFormat("Failed to open {} for writing!\n", objFileName).c_str());
|
||||
TC_LOG_ERROR("maps.mmapgen.debug", "{}: Failed to open {} for writing!", strerror(errno), objFileName);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
#include "MapBuilder.h"
|
||||
#include "IntermediateValues.h"
|
||||
#include "Log.h"
|
||||
#include "MapDefines.h"
|
||||
#include "MapTree.h"
|
||||
#include "MapUtils.h"
|
||||
@@ -187,8 +188,8 @@ namespace MMAP
|
||||
}
|
||||
}
|
||||
|
||||
printf("Discovering maps... found %u.\n", uint32(m_tiles.size()));
|
||||
printf("Discovering tiles... found %u.\n\n", m_totalTiles);
|
||||
TC_LOG_INFO("maps.mmapgen", "Discovering maps... found {}.", m_tiles.size());
|
||||
TC_LOG_INFO("maps.mmapgen", "Discovering tiles... found {}.\n", m_totalTiles);
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
@@ -201,7 +202,7 @@ namespace MMAP
|
||||
auto fp = Trinity::make_unique_ptr_with_deleter<&::fclose>(fopen(offMeshFilePath, "rb"));
|
||||
if (!fp)
|
||||
{
|
||||
printf(" loadOffMeshConnections:: input file %s not found!\n", offMeshFilePath);
|
||||
TC_LOG_ERROR("maps.mmapgen", "MapBuilder::loadOffMeshConnections:: input file {} not found!", offMeshFilePath);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -251,7 +252,7 @@ namespace MMAP
|
||||
dtNavMesh* navMesh = dtAllocNavMesh();
|
||||
if (!navMesh->init(&tileInfo.m_navMeshParams))
|
||||
{
|
||||
printf("[Map %04i] Failed creating navmesh for tile %i,%i !\n", tileInfo.m_mapId, tileInfo.m_tileX, tileInfo.m_tileY);
|
||||
TC_LOG_ERROR("maps.mmapgen", "[Map {:04}] Failed creating navmesh for tile {},{} !", tileInfo.m_mapId, tileInfo.m_tileX, tileInfo.m_tileY);
|
||||
dtFreeNavMesh(navMesh);
|
||||
return;
|
||||
}
|
||||
@@ -264,7 +265,7 @@ namespace MMAP
|
||||
|
||||
void MapBuilder::buildMaps(Optional<uint32> mapID)
|
||||
{
|
||||
printf("Using %u threads to generate mmaps\n", m_threads);
|
||||
TC_LOG_INFO("maps.mmapgen", "Using {} threads to generate mmaps", m_threads);
|
||||
|
||||
for (unsigned int i = 0; i < m_threads; ++i)
|
||||
{
|
||||
@@ -304,7 +305,7 @@ namespace MMAP
|
||||
if (!file)
|
||||
return;
|
||||
|
||||
printf("Building mesh from file\n");
|
||||
TC_LOG_INFO("maps.mmapgen", "Building mesh from file");
|
||||
int tileX, tileY, mapId;
|
||||
if (fread(&mapId, sizeof(int), 1, file) != 1)
|
||||
{
|
||||
@@ -326,7 +327,7 @@ namespace MMAP
|
||||
buildNavMesh(mapId, navMesh);
|
||||
if (!navMesh)
|
||||
{
|
||||
printf("Failed creating navmesh! \n");
|
||||
TC_LOG_ERROR("maps.mmapgen", "Failed creating navmesh!");
|
||||
fclose(file);
|
||||
return;
|
||||
}
|
||||
@@ -390,7 +391,7 @@ namespace MMAP
|
||||
buildNavMesh(mapID, navMesh);
|
||||
if (!navMesh)
|
||||
{
|
||||
printf("Failed creating navmesh! \n");
|
||||
TC_LOG_ERROR("maps.mmapgen", "Failed creating navmesh!");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -417,13 +418,13 @@ namespace MMAP
|
||||
buildNavMesh(mapID, navMesh);
|
||||
if (!navMesh)
|
||||
{
|
||||
printf("[Map %04u] Failed creating navmesh!\n", mapID);
|
||||
TC_LOG_ERROR("maps.mmapgen", "[Map {:04}] Failed creating navmesh!", mapID);
|
||||
m_totalTilesProcessed += tiles.size();
|
||||
return;
|
||||
}
|
||||
|
||||
// now start building mmtiles for each tile
|
||||
printf("[Map %04u] We have %u tiles. \n", mapID, uint32(tiles.size()));
|
||||
TC_LOG_INFO("maps.mmapgen", "[Map {:04}] We have {} tiles.", mapID, tiles.size());
|
||||
for (uint32 packedTile : tiles)
|
||||
{
|
||||
uint32 tileX, tileY;
|
||||
@@ -452,7 +453,7 @@ namespace MMAP
|
||||
return;
|
||||
}
|
||||
|
||||
printf("%u%% [Map %04i] Building tile [%02u,%02u]\n", m_mapBuilder->currentPercentageDone(), mapID, tileX, tileY);
|
||||
TC_LOG_INFO("maps.mmapgen", "{}% [Map {:04}] Building tile [{:02},{:02}]", m_mapBuilder->currentPercentageDone(), mapID, tileX, tileY);
|
||||
|
||||
MeshData meshData;
|
||||
|
||||
@@ -555,10 +556,10 @@ namespace MMAP
|
||||
navMeshParams.maxPolys = maxPolysPerTile;
|
||||
|
||||
navMesh = dtAllocNavMesh();
|
||||
printf("[Map %04u] Creating navMesh...\n", mapID);
|
||||
TC_LOG_INFO("maps.mmapgen", "[Map {:04}] Creating navMesh...", mapID);
|
||||
if (!navMesh->init(&navMeshParams))
|
||||
{
|
||||
printf("[Map %04u] Failed creating navmesh! \n", mapID);
|
||||
TC_LOG_ERROR("maps.mmapgen", "[Map {:04}] Failed creating navmesh!", mapID);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -569,7 +570,7 @@ namespace MMAP
|
||||
{
|
||||
dtFreeNavMesh(navMesh);
|
||||
navMesh = nullptr;
|
||||
perror(Trinity::StringFormat("[Map {:04}] Failed to open {} for writing!\n", mapID, fileName).c_str());
|
||||
TC_LOG_ERROR("maps.mmapgen", "{}: [Map {:04}] Failed to open {} for writing!\n", strerror(errno), mapID, fileName);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -585,7 +586,7 @@ namespace MMAP
|
||||
{
|
||||
// console output
|
||||
std::string tileString = Trinity::StringFormat("[Map {:04}] [{:02},{:02}]: ", mapID, tileX, tileY);
|
||||
printf("%s Building movemap tiles...\n", tileString.c_str());
|
||||
TC_LOG_INFO("maps.mmapgen", "{} Building movemap tile...", tileString);
|
||||
|
||||
IntermediateValues iv;
|
||||
|
||||
@@ -642,7 +643,7 @@ namespace MMAP
|
||||
tile.solid = rcAllocHeightfield();
|
||||
if (!tile.solid || !rcCreateHeightfield(m_rcContext, *tile.solid, tileCfg.width, tileCfg.height, tileCfg.bmin, tileCfg.bmax, tileCfg.cs, tileCfg.ch))
|
||||
{
|
||||
printf("%s Failed building heightfield! \n", tileString.c_str());
|
||||
TC_LOG_ERROR("maps.mmapgen", "{} Failed building heightfield!", tileString);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -672,39 +673,39 @@ namespace MMAP
|
||||
tile.chf = rcAllocCompactHeightfield();
|
||||
if (!tile.chf || !rcBuildCompactHeightfield(m_rcContext, tileCfg.walkableHeight, tileCfg.walkableClimb, *tile.solid, *tile.chf))
|
||||
{
|
||||
printf("%s Failed compacting heightfield! \n", tileString.c_str());
|
||||
TC_LOG_ERROR("maps.mmapgen", "{} Failed compacting heightfield!", tileString);
|
||||
continue;
|
||||
}
|
||||
|
||||
// build polymesh intermediates
|
||||
if (!rcErodeWalkableArea(m_rcContext, config.walkableRadius, *tile.chf))
|
||||
{
|
||||
printf("%s Failed eroding area! \n", tileString.c_str());
|
||||
TC_LOG_ERROR("maps.mmapgen", "{} Failed eroding area!", tileString);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!rcMedianFilterWalkableArea(m_rcContext, *tile.chf))
|
||||
{
|
||||
printf("%s Failed filtering area! \n", tileString.c_str());
|
||||
TC_LOG_ERROR("maps.mmapgen", "{} Failed filtering area!", tileString);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!rcBuildDistanceField(m_rcContext, *tile.chf))
|
||||
{
|
||||
printf("%s Failed building distance field! \n", tileString.c_str());
|
||||
TC_LOG_ERROR("maps.mmapgen", "{} Failed building distance field!", tileString);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!rcBuildRegions(m_rcContext, *tile.chf, tileCfg.borderSize, tileCfg.minRegionArea, tileCfg.mergeRegionArea))
|
||||
{
|
||||
printf("%s Failed building regions! \n", tileString.c_str());
|
||||
TC_LOG_ERROR("maps.mmapgen", "{} Failed building regions!", tileString);
|
||||
continue;
|
||||
}
|
||||
|
||||
tile.cset = rcAllocContourSet();
|
||||
if (!tile.cset || !rcBuildContours(m_rcContext, *tile.chf, tileCfg.maxSimplificationError, tileCfg.maxEdgeLen, *tile.cset))
|
||||
{
|
||||
printf("%s Failed building contours! \n", tileString.c_str());
|
||||
TC_LOG_ERROR("maps.mmapgen", "{} Failed building contours!", tileString);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -712,14 +713,14 @@ namespace MMAP
|
||||
tile.pmesh = rcAllocPolyMesh();
|
||||
if (!tile.pmesh || !rcBuildPolyMesh(m_rcContext, *tile.cset, tileCfg.maxVertsPerPoly, *tile.pmesh))
|
||||
{
|
||||
printf("%s Failed building polymesh! \n", tileString.c_str());
|
||||
TC_LOG_ERROR("maps.mmapgen", "{} Failed building polymesh!", tileString);
|
||||
continue;
|
||||
}
|
||||
|
||||
tile.dmesh = rcAllocPolyMeshDetail();
|
||||
if (!tile.dmesh || !rcBuildPolyMeshDetail(m_rcContext, *tile.pmesh, *tile.chf, tileCfg.detailSampleDist, tileCfg.detailSampleMaxError, *tile.dmesh))
|
||||
{
|
||||
printf("%s Failed building polymesh detail! \n", tileString.c_str());
|
||||
TC_LOG_ERROR("maps.mmapgen", "{} Failed building polymesh detail!", tileString);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -742,7 +743,7 @@ namespace MMAP
|
||||
iv.polyMesh = rcAllocPolyMesh();
|
||||
if (!iv.polyMesh)
|
||||
{
|
||||
printf("%s alloc iv.polyMesh FAILED!\n", tileString.c_str());
|
||||
TC_LOG_ERROR("maps.mmapgen", "{} alloc iv.polyMesh FAILED!", tileString);
|
||||
delete[] pmmerge;
|
||||
delete[] dmmerge;
|
||||
delete[] tiles;
|
||||
@@ -753,7 +754,7 @@ namespace MMAP
|
||||
iv.polyMeshDetail = rcAllocPolyMeshDetail();
|
||||
if (!iv.polyMeshDetail)
|
||||
{
|
||||
printf("%s alloc m_dmesh FAILED!\n", tileString.c_str());
|
||||
TC_LOG_ERROR("maps.mmapgen", "{} alloc m_dmesh FAILED!", tileString);
|
||||
delete[] pmmerge;
|
||||
delete[] dmmerge;
|
||||
delete[] tiles;
|
||||
@@ -824,12 +825,12 @@ namespace MMAP
|
||||
// so we have a clear error message
|
||||
if (params.nvp > DT_VERTS_PER_POLYGON)
|
||||
{
|
||||
printf("%s Invalid verts-per-polygon value! \n", tileString.c_str());
|
||||
TC_LOG_ERROR("maps.mmapgen", "{} Invalid verts-per-polygon value!", tileString);
|
||||
break;
|
||||
}
|
||||
if (params.vertCount >= 0xffff)
|
||||
{
|
||||
printf("%s Too many vertices! \n", tileString.c_str());
|
||||
TC_LOG_ERROR("maps.mmapgen", "{} Too many vertices!", tileString);
|
||||
break;
|
||||
}
|
||||
if (!params.vertCount || !params.verts)
|
||||
@@ -838,37 +839,37 @@ namespace MMAP
|
||||
// loaded but those models don't span into this tile
|
||||
|
||||
// message is an annoyance
|
||||
//printf("%sNo vertices to build tile! \n", tileString.c_str());
|
||||
//TC_LOG_ERROR("maps.mmapgen", "{} No vertices to build tile!", tileString);
|
||||
break;
|
||||
}
|
||||
if (!params.polyCount || !params.polys)
|
||||
{
|
||||
// we have flat tiles with no actual geometry - don't build those, its useless
|
||||
// keep in mind that we do output those into debug info
|
||||
printf("%s No polygons to build on tile! \n", tileString.c_str());
|
||||
TC_LOG_ERROR("maps.mmapgen", "{} No polygons to build on tile!", tileString);
|
||||
break;
|
||||
}
|
||||
if (!params.detailMeshes || !params.detailVerts || !params.detailTris)
|
||||
{
|
||||
printf("%s No detail mesh to build tile! \n", tileString.c_str());
|
||||
TC_LOG_ERROR("maps.mmapgen", "{} No detail mesh to build tile!", tileString);
|
||||
break;
|
||||
}
|
||||
|
||||
printf("%s Building navmesh tile...\n", tileString.c_str());
|
||||
TC_LOG_DEBUG("maps.mmapgen", "{} Building navmesh tile...", tileString);
|
||||
if (!dtCreateNavMeshData(¶ms, &navData, &navDataSize))
|
||||
{
|
||||
printf("%s Failed building navmesh tile! \n", tileString.c_str());
|
||||
TC_LOG_ERROR("maps.mmapgen", "{} Failed building navmesh tile!", tileString);
|
||||
break;
|
||||
}
|
||||
|
||||
dtTileRef tileRef = 0;
|
||||
printf("%s Adding tile to navmesh...\n", tileString.c_str());
|
||||
TC_LOG_DEBUG("maps.mmapgen", "{} Adding tile to navmesh...", tileString);
|
||||
// DT_TILE_FREE_DATA tells detour to unallocate memory when the tile
|
||||
// is removed via removeTile()
|
||||
dtStatus dtResult = navMesh->addTile(navData, navDataSize, DT_TILE_FREE_DATA, 0, &tileRef);
|
||||
if (!tileRef || !dtStatusSucceed(dtResult))
|
||||
{
|
||||
printf("%s Failed adding tile to navmesh! \n", tileString.c_str());
|
||||
TC_LOG_ERROR("maps.mmapgen", "{} Failed adding tile to navmesh!", tileString);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -877,12 +878,12 @@ namespace MMAP
|
||||
FILE* file = fopen(fileName.c_str(), "wb");
|
||||
if (!file)
|
||||
{
|
||||
perror(Trinity::StringFormat("[Map {:04}] Failed to open {} for writing!\n", mapID, fileName).c_str());
|
||||
TC_LOG_ERROR("maps.mmapgen", "{}: [Map {:04}] Failed to open {} for writing!", strerror(errno), mapID, fileName);
|
||||
navMesh->removeTile(tileRef, nullptr, nullptr);
|
||||
break;
|
||||
}
|
||||
|
||||
printf("%s Writing to file...\n", tileString.c_str());
|
||||
TC_LOG_DEBUG("maps.mmapgen", "{} Writing to file...", tileString);
|
||||
|
||||
// write header
|
||||
MmapTileHeader header;
|
||||
@@ -890,11 +891,6 @@ namespace MMAP
|
||||
header.size = uint32(navDataSize);
|
||||
fwrite(&header, sizeof(MmapTileHeader), 1, file);
|
||||
|
||||
/*
|
||||
dtMeshHeader* navDataHeader = (dtMeshHeader*)navData;
|
||||
printf("Poly count: %d\n", navDataHeader->polyCount);
|
||||
*/
|
||||
|
||||
// write data
|
||||
fwrite(navData, sizeof(unsigned char), navDataSize, file);
|
||||
fclose(file);
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "DB2FileSystemSource.h"
|
||||
#include "ExtractorDB2LoadInfo.h"
|
||||
#include "Locales.h"
|
||||
#include "Log.h"
|
||||
#include "MapBuilder.h"
|
||||
#include "PathCommon.h"
|
||||
#include "Timer.h"
|
||||
@@ -60,11 +61,22 @@ namespace MMAP
|
||||
}
|
||||
}
|
||||
|
||||
void SetupLogging()
|
||||
{
|
||||
Log* log = sLog;
|
||||
|
||||
log->CreateAppenderFromConfigLine("Appender.Console", "1,2,0"); // APPENDER_CONSOLE | LOG_LEVEL_DEBUG | APPENDER_FLAGS_NONE
|
||||
log->CreateLoggerFromConfigLine("Logger.root", "2,Console"); // LOG_LEVEL_DEBUG | Console appender
|
||||
log->CreateLoggerFromConfigLine("Logger.tool.mmapgen", "2,Console"); // LOG_LEVEL_DEBUG | Console appender
|
||||
log->CreateLoggerFromConfigLine("Logger.maps", "3,Console"); // LOG_LEVEL_DEBUG | Console appender
|
||||
log->CreateLoggerFromConfigLine("Logger.maps.mmapgen", "2,Console"); // LOG_LEVEL_DEBUG | Console appender
|
||||
}
|
||||
|
||||
bool checkDirectories(bool debugOutput, std::vector<std::string>& dbcLocales)
|
||||
{
|
||||
if (MMAP::getDirContents(dbcLocales, "dbc") == MMAP::LISTFILE_DIRECTORY_NOT_FOUND || dbcLocales.empty())
|
||||
{
|
||||
printf("'dbc' directory is empty or does not exist\n");
|
||||
TC_LOG_ERROR("tool.mmapgen", "'dbc' directory is empty or does not exist");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -72,14 +84,14 @@ bool checkDirectories(bool debugOutput, std::vector<std::string>& dbcLocales)
|
||||
|
||||
if (MMAP::getDirContents(dirFiles, "maps") == MMAP::LISTFILE_DIRECTORY_NOT_FOUND || dirFiles.empty())
|
||||
{
|
||||
printf("'maps' directory is empty or does not exist\n");
|
||||
TC_LOG_ERROR("tool.mmapgen", "'maps' directory is empty or does not exist");
|
||||
return false;
|
||||
}
|
||||
|
||||
dirFiles.clear();
|
||||
if (MMAP::getDirContents(dirFiles, "vmaps/0000", "*.vmtree") == MMAP::LISTFILE_DIRECTORY_NOT_FOUND || dirFiles.empty())
|
||||
{
|
||||
printf("'vmaps' directory is empty or does not exist\n");
|
||||
TC_LOG_ERROR("tool.mmapgen", "'vmaps' directory is empty or does not exist");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -88,7 +100,7 @@ bool checkDirectories(bool debugOutput, std::vector<std::string>& dbcLocales)
|
||||
{
|
||||
if (!boost::filesystem::create_directory("mmaps"))
|
||||
{
|
||||
printf("'mmaps' directory does not exist and failed to create it\n");
|
||||
TC_LOG_ERROR("tool.mmapgen", "'mmaps' directory does not exist and failed to create it");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -100,7 +112,7 @@ bool checkDirectories(bool debugOutput, std::vector<std::string>& dbcLocales)
|
||||
{
|
||||
if (!boost::filesystem::create_directory("meshes"))
|
||||
{
|
||||
printf("'meshes' directory does not exist and failed to create it (no place to put debugOutput files)\n");
|
||||
TC_LOG_ERROR("tool.mmapgen", "'meshes' directory does not exist and failed to create it (no place to put debugOutput files)");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -111,7 +123,7 @@ bool checkDirectories(bool debugOutput, std::vector<std::string>& dbcLocales)
|
||||
|
||||
int finish(char const* message, int returnValue)
|
||||
{
|
||||
printf("%s", message);
|
||||
TC_LOG_FATAL("tool.mmapgen.commandline", "{}", message);
|
||||
getchar(); // Wait for user input
|
||||
return returnValue;
|
||||
}
|
||||
@@ -147,7 +159,7 @@ bool handleArgs(int argc, char** argv,
|
||||
if (maxangle <= 90.f && maxangle >= 0.f)
|
||||
maxAngle = maxangle;
|
||||
else
|
||||
printf("invalid option for '--maxAngle', using default\n");
|
||||
TC_LOG_ERROR("tool.mmapgen.commandline", "invalid option for '--maxAngle', using default");
|
||||
}
|
||||
else if (strcmp(argv[i], "--maxAngleNotSteep") == 0)
|
||||
{
|
||||
@@ -159,7 +171,7 @@ bool handleArgs(int argc, char** argv,
|
||||
if (maxangle <= 90.f && maxangle >= 0.f)
|
||||
maxAngleNotSteep = maxangle;
|
||||
else
|
||||
printf("invalid option for '--maxAngleNotSteep', using default\n");
|
||||
TC_LOG_ERROR("tool.mmapgen.commandline", "invalid option for '--maxAngleNotSteep', using default");
|
||||
}
|
||||
else if (strcmp(argv[i], "--threads") == 0)
|
||||
{
|
||||
@@ -193,7 +205,7 @@ bool handleArgs(int argc, char** argv,
|
||||
|
||||
if (tileX < 0 || tileY < 0)
|
||||
{
|
||||
printf("invalid tile coords.\n");
|
||||
TC_LOG_ERROR("tool.mmapgen.commandline", "invalid tile coords.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -208,7 +220,7 @@ bool handleArgs(int argc, char** argv,
|
||||
else if (strcmp(param, "false") == 0)
|
||||
skipLiquid = false;
|
||||
else
|
||||
printf("invalid option for '--skipLiquid', using default\n");
|
||||
TC_LOG_ERROR("tool.mmapgen.commandline", "invalid option for '--skipLiquid', using default");
|
||||
}
|
||||
else if (strcmp(argv[i], "--skipContinents") == 0)
|
||||
{
|
||||
@@ -221,7 +233,7 @@ bool handleArgs(int argc, char** argv,
|
||||
else if (strcmp(param, "false") == 0)
|
||||
skipContinents = false;
|
||||
else
|
||||
printf("invalid option for '--skipContinents', using default\n");
|
||||
TC_LOG_ERROR("tool.mmapgen.commandline", "invalid option for '--skipContinents', using default");
|
||||
}
|
||||
else if (strcmp(argv[i], "--skipJunkMaps") == 0)
|
||||
{
|
||||
@@ -234,7 +246,7 @@ bool handleArgs(int argc, char** argv,
|
||||
else if (strcmp(param, "false") == 0)
|
||||
skipJunkMaps = false;
|
||||
else
|
||||
printf("invalid option for '--skipJunkMaps', using default\n");
|
||||
TC_LOG_ERROR("tool.mmapgen.commandline", "invalid option for '--skipJunkMaps', using default");
|
||||
}
|
||||
else if (strcmp(argv[i], "--skipBattlegrounds") == 0)
|
||||
{
|
||||
@@ -247,7 +259,7 @@ bool handleArgs(int argc, char** argv,
|
||||
else if (strcmp(param, "false") == 0)
|
||||
skipBattlegrounds = false;
|
||||
else
|
||||
printf("invalid option for '--skipBattlegrounds', using default\n");
|
||||
TC_LOG_ERROR("tool.mmapgen.commandline", "invalid option for '--skipBattlegrounds', using default");
|
||||
}
|
||||
else if (strcmp(argv[i], "--debugOutput") == 0)
|
||||
{
|
||||
@@ -260,7 +272,7 @@ bool handleArgs(int argc, char** argv,
|
||||
else if (strcmp(param, "false") == 0)
|
||||
debugOutput = false;
|
||||
else
|
||||
printf("invalid option for '--debugOutput', using default true\n");
|
||||
TC_LOG_ERROR("tool.mmapgen.commandline", "invalid option for '--debugOutput', using default true");
|
||||
}
|
||||
else if (strcmp(argv[i], "--silent") == 0)
|
||||
{
|
||||
@@ -277,7 +289,7 @@ bool handleArgs(int argc, char** argv,
|
||||
else if (strcmp(param, "false") == 0)
|
||||
bigBaseUnit = false;
|
||||
else
|
||||
printf("invalid option for '--bigBaseUnit', using default false\n");
|
||||
TC_LOG_ERROR("tool.mmapgen.commandline", "invalid option for '--bigBaseUnit', using default false");
|
||||
}
|
||||
else if (strcmp(argv[i], "--offMeshInput") == 0)
|
||||
{
|
||||
@@ -293,7 +305,7 @@ bool handleArgs(int argc, char** argv,
|
||||
}
|
||||
else if (!strcmp(argv[i], "--help") || !strcmp(argv[i], "-?"))
|
||||
{
|
||||
printf("%s\n", Readme);
|
||||
TC_LOG_INFO("tool.mmapgen", "{}", Readme);
|
||||
silent = true;
|
||||
return false;
|
||||
}
|
||||
@@ -304,16 +316,16 @@ bool handleArgs(int argc, char** argv,
|
||||
mapnum = map;
|
||||
else
|
||||
{
|
||||
printf("invalid map id\n");
|
||||
TC_LOG_ERROR("tool.mmapgen.commandline", "invalid map id {}", map);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
#if !defined(NDEBUG)
|
||||
if (!allowDebug)
|
||||
{
|
||||
finish("Build mmaps_generator in RelWithDebInfo or Release mode or it will take hours to complete!!!\nUse '--allowDebug' argument if you really want to run this tool in Debug.\n", -2);
|
||||
finish("Build mmaps_generator in RelWithDebInfo or Release mode or it will take hours to complete!!!\nUse '--allowDebug' argument if you really want to run this tool in Debug.", -2);
|
||||
silent = true;
|
||||
return false;
|
||||
}
|
||||
@@ -395,7 +407,9 @@ int main(int argc, char** argv)
|
||||
|
||||
Trinity::Locale::Init();
|
||||
|
||||
Trinity::Banner::Show("MMAP generator", [](char const* text) { printf("%s\n", text); }, nullptr);
|
||||
SetupLogging();
|
||||
|
||||
Trinity::Banner::Show("MMAP generator", [](char const* text) { TC_LOG_INFO("tool.mmapgen", "{}", text); }, nullptr);
|
||||
|
||||
unsigned int threads = std::thread::hardware_concurrency();
|
||||
int mapnum = -1;
|
||||
@@ -424,9 +438,9 @@ int main(int argc, char** argv)
|
||||
if (silent)
|
||||
return -2;
|
||||
|
||||
printf("You have specifed debug output, but didn't specify a map to generate.\n");
|
||||
printf("This will generate debug output for ALL maps.\n");
|
||||
printf("Are you sure you want to continue? (y/n) ");
|
||||
TC_LOG_INFO("tool.mmapgen", "You have specifed debug output, but didn't specify a map to generate.");
|
||||
TC_LOG_INFO("tool.mmapgen", "This will generate debug output for ALL maps.");
|
||||
TC_LOG_INFO("tool.mmapgen", "Are you sure you want to continue? (y/n)");
|
||||
if (getchar() != 'y')
|
||||
return 0;
|
||||
}
|
||||
@@ -453,7 +467,7 @@ int main(int argc, char** argv)
|
||||
builder.buildMaps({});
|
||||
|
||||
if (!silent)
|
||||
printf("Finished. MMAPS were built in %s\n", secsToTimeString(GetMSTimeDiffToNow(start) / 1000).c_str());
|
||||
TC_LOG_INFO("tool.mmapgen", "Finished. MMAPS were built in {}", secsToTimeString(GetMSTimeDiffToNow(start) / 1000));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
*/
|
||||
|
||||
#include "TerrainBuilder.h"
|
||||
#include "Log.h"
|
||||
#include "MapDefines.h"
|
||||
#include "MapTree.h"
|
||||
#include "MMapDefines.h"
|
||||
@@ -100,7 +101,7 @@ namespace MMAP
|
||||
fheader.versionMagic != MapVersionMagic)
|
||||
{
|
||||
fclose(mapFile);
|
||||
printf("%s is the wrong version, please extract new .map files\n", mapFileName.c_str());
|
||||
TC_LOG_ERROR("maps.mmapgen", "{} is the wrong version, please extract new .map files", mapFileName);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -137,17 +138,17 @@ namespace MMAP
|
||||
{
|
||||
float heightMultiplier;
|
||||
float V9[V9_SIZE_SQ], V8[V8_SIZE_SQ];
|
||||
int expected = V9_SIZE_SQ + V8_SIZE_SQ;
|
||||
size_t expected = V9_SIZE_SQ + V8_SIZE_SQ;
|
||||
|
||||
if (hheader.flags.HasFlag(map_heightHeaderFlags::HeightAsInt8))
|
||||
{
|
||||
uint8 v9[V9_SIZE_SQ];
|
||||
uint8 v8[V8_SIZE_SQ];
|
||||
int count = 0;
|
||||
size_t count = 0;
|
||||
count += fread(v9, sizeof(uint8), V9_SIZE_SQ, mapFile);
|
||||
count += fread(v8, sizeof(uint8), V8_SIZE_SQ, mapFile);
|
||||
if (count != expected)
|
||||
printf("TerrainBuilder::loadMap: Failed to read some data expected %d, read %d\n", expected, count);
|
||||
TC_LOG_ERROR("maps.mmapgen", "TerrainBuilder::loadMap: Failed to read {} height data expected {}, read {}", mapFileName, expected, count);
|
||||
|
||||
heightMultiplier = (hheader.gridMaxHeight - hheader.gridHeight) / 255;
|
||||
|
||||
@@ -161,11 +162,11 @@ namespace MMAP
|
||||
{
|
||||
uint16 v9[V9_SIZE_SQ];
|
||||
uint16 v8[V8_SIZE_SQ];
|
||||
int count = 0;
|
||||
size_t count = 0;
|
||||
count += fread(v9, sizeof(uint16), V9_SIZE_SQ, mapFile);
|
||||
count += fread(v8, sizeof(uint16), V8_SIZE_SQ, mapFile);
|
||||
if (count != expected)
|
||||
printf("TerrainBuilder::loadMap: Failed to read some data expected %d, read %d\n", expected, count);
|
||||
TC_LOG_ERROR("maps.mmapgen", "TerrainBuilder::loadMap: Failed to read {} height data expected {}, read {}", mapFileName, expected, count);
|
||||
|
||||
heightMultiplier = (hheader.gridMaxHeight - hheader.gridHeight) / 65535;
|
||||
|
||||
@@ -177,11 +178,11 @@ namespace MMAP
|
||||
}
|
||||
else
|
||||
{
|
||||
int count = 0;
|
||||
size_t count = 0;
|
||||
count += fread(V9, sizeof(float), V9_SIZE_SQ, mapFile);
|
||||
count += fread(V8, sizeof(float), V8_SIZE_SQ, mapFile);
|
||||
if (count != expected)
|
||||
printf("TerrainBuilder::loadMap: Failed to read some data expected %d, read %d\n", expected, count);
|
||||
TC_LOG_ERROR("maps.mmapgen", "TerrainBuilder::loadMap: Failed to read {} height data expected {}, read {}", mapFileName, expected, count);
|
||||
}
|
||||
|
||||
// hole data
|
||||
@@ -190,7 +191,7 @@ namespace MMAP
|
||||
memset(holes, 0, fheader.holesSize);
|
||||
fseek(mapFile, fheader.holesOffset, SEEK_SET);
|
||||
if (fread(holes, fheader.holesSize, 1, mapFile) != 1)
|
||||
printf("TerrainBuilder::loadMap: Failed to read some data expected 1, read 0\n");
|
||||
TC_LOG_ERROR("maps.mmapgen", "TerrainBuilder::loadMap: Failed to read {} holes data expected {}, read {}", mapFileName, 1, 0);
|
||||
}
|
||||
|
||||
int count = meshData.solidVerts.size() / 3;
|
||||
@@ -234,16 +235,16 @@ namespace MMAP
|
||||
map_liquidHeader lheader;
|
||||
fseek(mapFile, fheader.liquidMapOffset, SEEK_SET);
|
||||
if (fread(&lheader, sizeof(map_liquidHeader), 1, mapFile) != 1)
|
||||
printf("TerrainBuilder::loadMap: Failed to read some data expected 1, read 0\n");
|
||||
TC_LOG_ERROR("maps.mmapgen", "TerrainBuilder::loadMap: Failed to read {} liquid header expected {}, read {}", mapFileName, 1, 0);
|
||||
|
||||
float* liquid_map = nullptr;
|
||||
|
||||
if (!lheader.flags.HasFlag(map_liquidHeaderFlags::NoType))
|
||||
{
|
||||
if (fread(liquid_entry, sizeof(liquid_entry), 1, mapFile) != 1)
|
||||
printf("TerrainBuilder::loadMap: Failed to read some data expected 1, read 0\n");
|
||||
TC_LOG_ERROR("maps.mmapgen", "TerrainBuilder::loadMap: Failed to read {} liquid id expected {}, read {}", mapFileName, 1, 0);
|
||||
if (fread(liquid_flags, sizeof(liquid_flags), 1, mapFile) != 1)
|
||||
printf("TerrainBuilder::loadMap: Failed to read some data expected 1, read 0\n");
|
||||
TC_LOG_ERROR("maps.mmapgen", "TerrainBuilder::loadMap: Failed to read {} liquid flags expected {}, read {}", mapFileName, 1, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -257,7 +258,7 @@ namespace MMAP
|
||||
liquid_map = new float [toRead];
|
||||
if (fread(liquid_map, sizeof(float), toRead, mapFile) != toRead)
|
||||
{
|
||||
printf("TerrainBuilder::loadMap: Failed to read some data expected 1, read 0\n");
|
||||
TC_LOG_ERROR("maps.mmapgen", "TerrainBuilder::loadMap: Failed to read {} liquid header expected {}, read {}", mapFileName, toRead, 0);
|
||||
delete[] liquid_map;
|
||||
liquid_map = nullptr;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user