Skip to content

Commit

Permalink
-Travel nod gen: Added some map/grid loading to make node generation …
Browse files Browse the repository at this point in the history
…work again (tbc)
  • Loading branch information
mostlikely4r committed Oct 14, 2024
1 parent 440b8d4 commit 8aa5c3a
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 5 deletions.
2 changes: 1 addition & 1 deletion playerbot/TravelMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -969,7 +969,7 @@ void TravelMgr::SetMobAvoidArea()

void TravelMgr::SetMobAvoidAreaMap(uint32 mapId)
{
PathFinder path;
PathFinder path(mapId, 0);
FactionTemplateEntry const* humanFaction = sFactionTemplateStore.LookupEntry(1);
FactionTemplateEntry const* orcFaction = sFactionTemplateStore.LookupEntry(2);

Expand Down
24 changes: 24 additions & 0 deletions playerbot/TravelNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "Entities/Transports.h"
#include "strategy/values/BudgetValues.h"
#include "playerbot/ServerFacade.h"
#include "MotionGenerators/MoveMap.h"

using namespace ai;
using namespace MaNGOS;
Expand Down Expand Up @@ -1766,6 +1767,24 @@ void TravelNodeMap::manageNodes(Unit* bot, bool mapFull)
m_nMapMtx.unlock_shared();
}

void TravelNodeMap::LoadMaps()
{
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);
}
}
}

void TravelNodeMap::generateNpcNodes()
{
Expand Down Expand Up @@ -2605,6 +2624,8 @@ void TravelNodeMap::calculatePathCosts()

void TravelNodeMap::generatePaths(bool helpers)
{
sTravelMgr.SetMobAvoidArea();

sLog.outString("-Calculating walkable paths");
generateWalkPaths();

Expand All @@ -2629,6 +2650,9 @@ void TravelNodeMap::generatePaths(bool helpers)

void TravelNodeMap::generateAll()
{
if (hasToGen || hasToFullGen)
LoadMaps();

if (hasToFullGen)
generateNodes();

Expand Down
2 changes: 2 additions & 0 deletions playerbot/TravelNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,8 @@ namespace ai
void setHasToGen() { hasToGen = true; }
bool gethasToGen() { return hasToGen || hasToFullGen; }

void LoadMaps();

//Below are the steps to creating the content stored in the node, link and path tables.
//Nodes are placed based on key locations based on objects/creatures in the world and paths are generated using the standardpathfinder.

Expand Down
14 changes: 11 additions & 3 deletions playerbot/WorldPosition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -607,15 +607,23 @@ bool WorldPosition::loadMapAndVMap(uint32 mapId, uint32 instanceId, int x, int y
if (MMAP::MMapFactory::createOrGetMMapManager()->IsMMapTileLoaded(mapId, instanceId, x, y))
return true;
#endif

if (sTravelMgr.isBadMmap(mapId, x, y))
return false;

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

bool isLoaded = false;

#ifndef MANGOSBOT_TWO
//TerrainInfoAccess* terrain = reinterpret_cast<TerrainInfoAccess*>(const_cast<TerrainInfo*>(sTerrainMgr.LoadTerrain(mapId)));
//isLoaded = terrain->Load(x, y);
//TerrainInfo* terrain = sTerrainMgr.LoadTerrain(mapId);
//isLoaded = terrain->GetTerrainType(x, y);
isLoaded = true;
#else
//Fix to ignore bad mmap files.
Expand Down
2 changes: 1 addition & 1 deletion playerbot/WorldPosition.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ namespace ai
//Map functions. Player independent.
const MapEntry* getMapEntry() const { return sMapStore.LookupEntry(mapid); }
uint32 getFirstInstanceId() const { for (auto& map : sMapMgr.Maps()) { if (map.second->GetId() == getMapId()) return map.second->GetInstanceId(); }; return 0; }
Map* getMap(uint32 instanceId) const { return sMapMgr.FindMap(mapid, instanceId ? instanceId : (getMapEntry()->Instanceable() ? getFirstInstanceId() : 0)); }
Map* getMap(uint32 instanceId) const { loadMapAndVMap(instanceId); return sMapMgr.FindMap(mapid, instanceId ? instanceId : (getMapEntry()->Instanceable() ? getFirstInstanceId() : 0)); }
const TerrainInfo* getTerrain() const { return getMap(getFirstInstanceId()) ? getMap(getFirstInstanceId())->GetTerrain() : sTerrainMgr.LoadTerrain(getMapId()); }
bool isDungeon() { return getMapEntry()->IsDungeon(); }
float getVisibilityDistance() { return getMap(0) ? getMap(0)->GetVisibilityDistance() : (isOverworld() ? World::GetMaxVisibleDistanceOnContinents() : World::GetMaxVisibleDistanceInInstances()); }
Expand Down

0 comments on commit 8aa5c3a

Please sign in to comment.