mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-18 16:38:42 +01:00
Tools/MMapsGenerator: Use system supported threads instead of hardcoded amount
- Use unsigned int for thread count - Use std::thread::hardware_concurrency() to try estimate available threads instead of hardcoded 3 threads by default - Print thread count always regardless of using --threads switch or not
This commit is contained in:
@@ -205,9 +205,11 @@ namespace MMAP
|
||||
}
|
||||
}
|
||||
|
||||
void MapBuilder::buildAllMaps(int threads)
|
||||
void MapBuilder::buildAllMaps(unsigned int threads)
|
||||
{
|
||||
for (int i = 0; i < threads; ++i)
|
||||
printf("Using %u threads to extract mmaps\n", threads);
|
||||
|
||||
for (unsigned int i = 0; i < threads; ++i)
|
||||
{
|
||||
_workerThreads.push_back(std::thread(&MapBuilder::WorkerThread, this));
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ namespace MMAP
|
||||
void buildSingleTile(uint32 mapID, uint32 tileX, uint32 tileY);
|
||||
|
||||
// builds list of maps, then builds all of mmap tiles (based on the skip settings)
|
||||
void buildAllMaps(int threads);
|
||||
void buildAllMaps(unsigned int threads);
|
||||
|
||||
void WorkerThread();
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ bool handleArgs(int argc, char** argv,
|
||||
bool &bigBaseUnit,
|
||||
char* &offMeshInputPath,
|
||||
char* &file,
|
||||
int& threads)
|
||||
unsigned int& threads)
|
||||
{
|
||||
char* param = NULL;
|
||||
for (int i = 1; i < argc; ++i)
|
||||
@@ -94,8 +94,7 @@ bool handleArgs(int argc, char** argv,
|
||||
param = argv[++i];
|
||||
if (!param)
|
||||
return false;
|
||||
threads = atoi(param);
|
||||
printf("Using %i threads to extract mmaps\n", threads);
|
||||
threads = static_cast<unsigned int>(std::max(0, atoi(param)));
|
||||
}
|
||||
else if (strcmp(argv[i], "--file") == 0)
|
||||
{
|
||||
@@ -241,7 +240,8 @@ int finish(const char* message, int returnValue)
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
int threads = 3, mapnum = -1;
|
||||
unsigned int threads = std::thread::hardware_concurrency();
|
||||
int mapnum = -1;
|
||||
float maxAngle = 70.0f;
|
||||
int tileX = -1, tileY = -1;
|
||||
bool skipLiquid = false,
|
||||
|
||||
Reference in New Issue
Block a user