Skip to content

Commit

Permalink
Nodegen: Fixed some crashes during generation
Browse files Browse the repository at this point in the history
  • Loading branch information
mostlikely4r committed Jan 11, 2025
1 parent d2dd37d commit 1d254a6
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 30 deletions.
39 changes: 17 additions & 22 deletions playerbot/TravelNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ void TravelNodePath::calculateCost(bool distanceOnly)

if (lastPoint && point.getMapId() == lastPoint.getMapId())
{
if (!distanceOnly && (point.isInWater() || lastPoint.isInWater()))
if (!distanceOnly && (point.isVmapLoaded() && point.isInWater()) || (lastPoint.isVmapLoaded() && lastPoint.isInWater()))
swimDistance += point.distance(lastPoint);

distance += point.distance(lastPoint);
Expand Down Expand Up @@ -1843,8 +1843,23 @@ 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;
if (mapId == 0 || mapId == 1 || mapId == 530 || mapId == 571)
{
MMAP::MMapFactory::createOrGetMMapManager()->loadAllMapTiles(sWorld.GetDataPath(), mapId);
}
else
{
MMAP::MMapFactory::createOrGetMMapManager()->loadMapInstance(sWorld.GetDataPath(), mapId, 0);
}
}

for (uint32 i = 0; i < sMapStore.GetNumRows(); ++i)
{
if (!sMapStore.LookupEntry(i))
Expand All @@ -1871,26 +1886,6 @@ void TravelNodeMap::LoadMaps()
}
}
}
#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)
{
if (!sMapStore.LookupEntry(i))
continue;

uint32 mapId = sMapStore.LookupEntry(i)->MapID;
if (mapId == 0 || mapId == 1 || mapId == 530 || mapId == 571)
{
MMAP::MMapFactory::createOrGetMMapManager()->loadAllMapTiles(sWorld.GetDataPath(), mapId);
}
else
{
MMAP::MMapFactory::createOrGetMMapManager()->loadMapInstance(sWorld.GetDataPath(), mapId, 0);
}
}
#endif

}

void TravelNodeMap::generateNpcNodes()
Expand Down
16 changes: 8 additions & 8 deletions playerbot/WorldPosition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -686,10 +686,10 @@ bool WorldPosition::loadMapAndVMap(uint32 mapId, uint32 instanceId, int x, int y
{
std::string logName = "load_map_grid.csv";

bool hasVmap = isVmapLoaded(mapId, x, y);
//bool hasVmap = isVmapLoaded(mapId, x, y);
bool hasMmap = isMmapLoaded(mapId, instanceId, x, y);

if (hasVmap && hasMmap)
if (hasMmap)
return true;

if (sTravelMgr.IsBadMmap(mapId, x, y))
Expand Down Expand Up @@ -718,14 +718,14 @@ bool WorldPosition::loadMapAndVMap(uint32 mapId, uint32 instanceId, int x, int y
#endif


if (!isLoaded)
sTravelMgr.AddBadMmap(mapId, x, y);
//if (!isLoaded)
// sTravelMgr.AddBadMmap(mapId, x, y);
}

if (!hasVmap)
{
loadVMap(mapId, x, y);
}
//if (!hasVmap)
//{
// loadVMap(mapId, x, y);
//}

if (sPlayerbotAIConfig.hasLog(logName))
{
Expand Down

0 comments on commit 1d254a6

Please sign in to comment.