25#include <boost/filesystem.hpp>
26#include <unordered_map>
30#include "Info/readme.txt"
37 std::unordered_map<uint32, uint8> _liquidTypes;
42 auto itr = _liquidTypes.find(liquidId);
43 return itr != _liquidTypes.end() ? (1 << itr->second) : 0;
48 std::vector<std::string> dirFiles;
52 printf(
"'maps' directory is empty or does not exist\n");
59 printf(
"'vmaps' directory is empty or does not exist\n");
65 return boost::filesystem::create_directory(
"mmaps");
72 printf(
"'meshes' directory does not exist (no place to put debugOutput files)\n");
80int finish(
char const* message,
int returnValue)
82 printf(
"%s", message);
96 bool &skipBattlegrounds,
100 char* &offMeshInputPath,
102 unsigned int& threads)
104 char* param =
nullptr;
105 [[maybe_unused]]
bool allowDebug =
false;
106 for (
int i = 1; i < argc; ++i)
108 if (strcmp(argv[i],
"--maxAngle") == 0)
114 float maxangle = atof(param);
115 if (maxangle <= 90.f && maxangle >= 0.f)
118 printf(
"invalid option for '--maxAngle', using default\n");
120 else if (strcmp(argv[i],
"--maxAngleNotSteep") == 0)
126 float maxangle = atof(param);
127 if (maxangle <= 90.f && maxangle >= 0.f)
128 maxAngleNotSteep = maxangle;
130 printf(
"invalid option for '--maxAngleNotSteep', using default\n");
132 else if (strcmp(argv[i],
"--threads") == 0)
137 threads =
static_cast<unsigned int>(std::max(0, atoi(param)));
139 else if (strcmp(argv[i],
"--file") == 0)
146 else if (strcmp(argv[i],
"--tile") == 0)
152 char* stileX = strtok(param,
",");
153 char* stileY = strtok(
nullptr,
",");
154 int tilex = atoi(stileX);
155 int tiley = atoi(stileY);
157 if ((tilex > 0 && tilex < 64) || (tilex == 0 && strcmp(stileX,
"0") == 0))
159 if ((tiley > 0 && tiley < 64) || (tiley == 0 && strcmp(stileY,
"0") == 0))
162 if (tileX < 0 || tileY < 0)
164 printf(
"invalid tile coords.\n");
168 else if (strcmp(argv[i],
"--skipLiquid") == 0)
174 if (strcmp(param,
"true") == 0)
176 else if (strcmp(param,
"false") == 0)
179 printf(
"invalid option for '--skipLiquid', using default\n");
181 else if (strcmp(argv[i],
"--skipContinents") == 0)
187 if (strcmp(param,
"true") == 0)
188 skipContinents =
true;
189 else if (strcmp(param,
"false") == 0)
190 skipContinents =
false;
192 printf(
"invalid option for '--skipContinents', using default\n");
194 else if (strcmp(argv[i],
"--skipJunkMaps") == 0)
200 if (strcmp(param,
"true") == 0)
202 else if (strcmp(param,
"false") == 0)
203 skipJunkMaps =
false;
205 printf(
"invalid option for '--skipJunkMaps', using default\n");
207 else if (strcmp(argv[i],
"--skipBattlegrounds") == 0)
213 if (strcmp(param,
"true") == 0)
214 skipBattlegrounds =
true;
215 else if (strcmp(param,
"false") == 0)
216 skipBattlegrounds =
false;
218 printf(
"invalid option for '--skipBattlegrounds', using default\n");
220 else if (strcmp(argv[i],
"--debugOutput") == 0)
226 if (strcmp(param,
"true") == 0)
228 else if (strcmp(param,
"false") == 0)
231 printf(
"invalid option for '--debugOutput', using default true\n");
233 else if (strcmp(argv[i],
"--silent") == 0)
237 else if (strcmp(argv[i],
"--bigBaseUnit") == 0)
243 if (strcmp(param,
"true") == 0)
245 else if (strcmp(param,
"false") == 0)
248 printf(
"invalid option for '--bigBaseUnit', using default false\n");
250 else if (strcmp(argv[i],
"--offMeshInput") == 0)
256 offMeshInputPath = param;
258 else if (strcmp(argv[i],
"--allowDebug") == 0)
262 else if (!strcmp(argv[i],
"--help") || !strcmp(argv[i],
"-?"))
270 int map = atoi(argv[i]);
271 if (map > 0 || (map == 0 && (strcmp(argv[i],
"0") == 0)))
275 printf(
"invalid map id\n");
284 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);
296 std::unordered_map<uint32, uint8> liquidData;
298 if (liquidDbc.
Load((boost::filesystem::path(
"dbc") /
"LiquidType.dbc").string().c_str(),
"nxxixixxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"))
318 unsigned int threads = std::thread::hardware_concurrency();
320 int tileX = -1, tileY = -1;
322 bool skipLiquid =
false,
323 skipContinents =
false,
325 skipBattlegrounds =
false,
329 char* offMeshInputPath =
nullptr;
330 char* file =
nullptr;
332 bool validParam =
handleArgs(argc, argv, mapnum,
333 tileX, tileY, maxAngle, maxAngleNotSteep,
334 skipLiquid, skipContinents, skipJunkMaps, skipBattlegrounds,
335 debugOutput, silent, bigBaseUnit, offMeshInputPath, file, threads);
338 return silent ? -1 :
finish(
"You have specified invalid parameters", -1);
340 if (mapnum == -1 && debugOutput)
345 printf(
"You have specifed debug output, but didn't specify a map to generate.\n");
346 printf(
"This will generate debug output for ALL maps.\n");
347 printf(
"Are you sure you want to continue? (y/n) ");
348 if (getchar() !=
'y')
353 return silent ? -3 :
finish(
"Press ENTER to close...", -3);
356 if (_liquidTypes.empty())
357 return silent ? -5 :
finish(
"Failed to load LiquidType.dbc", -5);
359 MapBuilder builder(maxAngle, maxAngleNotSteep, skipLiquid, skipContinents, skipJunkMaps,
360 skipBattlegrounds, debugOutput, bigBaseUnit, mapnum, offMeshInputPath, threads);
365 else if (tileX > -1 && tileY > -1 && mapnum >= 0)
367 else if (mapnum >= 0)
377#if TRINITY_PLATFORM == TRINITY_PLATFORM_WINDOWS
std::optional< T > Optional
Optional helper class to wrap optional values within.
uint32 GetMSTimeDiffToNow(uint32 oldMSTime)
std::string secsToTimeString(uint64 timeInSecs, TimeFormat timeFormat, bool hoursOnly)
uint32 getUInt(size_t field) const
Record getRecord(size_t id)
bool Load(const char *filename, const char *fmt)
uint32 GetNumRows() const
Get begin iterator over records.
void buildMaps(Optional< uint32 > mapID)
void buildMeshFromFile(char *name)
void buildSingleTile(uint32 mapID, uint32 tileX, uint32 tileY)
@ LISTFILE_DIRECTORY_NOT_FOUND
ListFilesResult getDirContents(std::vector< std::string > &fileList, std::string dirpath=".", std::string filter="*")
TC_COMMON_API void Show(char const *applicationName, void(*log)(char const *text), void(*logExtraInfo)())
TC_COMMON_API void Init()
TC_COMMON_API void VerifyOsVersion()