Skip to content

Commit

Permalink
-Nodegen: Some tweaks to enable vanilla generation and clean up the t…
Browse files Browse the repository at this point in the history
…erminal output.
  • Loading branch information
mostlikely4r committed Oct 16, 2024
1 parent 3c2ce4a commit 606338d
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 4 deletions.
2 changes: 1 addition & 1 deletion playerbot/TravelMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -941,7 +941,7 @@ void TravelMgr::logQuestError(uint32 errorNr, Quest* quest, uint32 objective, ui

void TravelMgr::SetMobAvoidArea()
{
sLog.outString("start mob avoidance maps");
sLog.outString("-Apply mob avoidance maps");

std::vector<std::future<void>> calculations;

Expand Down
34 changes: 31 additions & 3 deletions playerbot/TravelNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1769,6 +1769,35 @@ void TravelNodeMap::manageNodes(Unit* bot, bool mapFull)

void TravelNodeMap::LoadMaps()
{
#ifdef MANGOSBOT_ZERO
sLog.outError("Trying to load all maps and tiles for node generation. Please ignore any maps that could not be loaded.");
for (uint32 i = 0; i < sMapStore.GetNumRows(); ++i)
{
if (!sMapStore.LookupEntry(i))
continue;

uint32 mapId = sMapStore.LookupEntry(i)->MapID;

for (const auto& entry : boost::filesystem::directory_iterator(sWorld.GetDataPath() + "mmaps"))
{
if (entry.path().extension() == ".mmtile")
{
auto filename = entry.path().filename();
auto fileNameString = filename.c_str();
// trying to avoid string copy
uint32 fileMapId = (fileNameString[0] - '0') * 100 + (fileNameString[1] - '0') * 10 + (fileNameString[2] - '0');
if (fileMapId != mapId)
continue;

uint32 x = (fileNameString[3] - '0') * 10 + (fileNameString[4] - '0');
uint32 y = (fileNameString[5] - '0') * 10 + (fileNameString[6] - '0');
if (!MMAP::MMapFactory::createOrGetMMapManager()->IsMMapIsLoaded(mapId, x, y))
MMAP::MMapFactory::createOrGetMMapManager()->loadMap(mapId, x, y);

}
}
}
#endif
#ifdef MANGOSBOT_ONE
sLog.outError("Trying to load all maps and tiles for node generation. Please ignore any maps that could not be loaded.");
for (uint32 i = 0; i < sMapStore.GetNumRows(); ++i)
Expand All @@ -1787,6 +1816,7 @@ void TravelNodeMap::LoadMaps()
}
}
#endif

}

void TravelNodeMap::generateNpcNodes()
Expand Down Expand Up @@ -2486,12 +2516,10 @@ void TravelNodeMap::generateHelperNodes()

std::vector<std::future<void>> calculations;

BarGoLink bar(nodeMaps.size());
for (auto& map : nodeMaps)
{
uint32 mapId = map.first;
calculations.push_back(std::async([this, mapId] { generateHelperNodes(mapId); }));
bar.step();
}

for (uint32 i = 0; i < calculations.size(); i++)
Expand Down Expand Up @@ -2721,7 +2749,7 @@ void TravelNodeMap::generateAll()

if (hasToGen || hasToFullGen)
{
generatePaths(false);
generatePaths(true);
hasToGen = false;
hasToFullGen = false;
hasToSave = true;
Expand Down
3 changes: 3 additions & 0 deletions playerbot/WorldPosition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,9 @@ bool WorldPosition::loadMapAndVMap(uint32 mapId, uint32 instanceId, int x, int y
if (sTravelMgr.isBadMmap(mapId, x, y))
return false;

#ifdef MANGOSBOT_ZERO
MMAP::MMapFactory::createOrGetMMapManager()->loadMap(mapId, x, y);
#endif
#ifdef MANGOSBOT_ONE
if (mapId == 0 || mapId == 1 || mapId == 530 || mapId == 571)
MMAP::MMapFactory::createOrGetMMapManager()->loadMap(sWorld.GetDataPath(), mapId, x, y);
Expand Down

0 comments on commit 606338d

Please sign in to comment.