Core/MMaps: Implemented a way to enable/disable certain terrain types for movement on the entire map

This commit is contained in:
Shauren
2023-10-16 11:57:24 +02:00
parent 348e29c79f
commit da0ba86694
3 changed files with 17 additions and 1 deletions

View File

@@ -143,7 +143,7 @@ i_mapEntry(sMapStore.LookupEntry(id)), i_spawnMode(SpawnMode), i_InstanceId(Inst
m_unloadTimer(0), m_VisibleDistance(DEFAULT_VISIBILITY_DISTANCE),
m_VisibilityNotifyPeriod(DEFAULT_VISIBILITY_NOTIFY_PERIOD),
m_activeNonPlayersIter(m_activeNonPlayers.end()), _transportsUpdateIter(_transports.end()),
i_gridExpiry(expiry), m_terrain(sTerrainMgr.LoadTerrain(id)),
i_gridExpiry(expiry), m_terrain(sTerrainMgr.LoadTerrain(id)), m_forceEnabledNavMeshFilterFlags(0), m_forceDisabledNavMeshFilterFlags(0),
i_scriptLock(false), _respawnTimes(std::make_unique<RespawnListContainer>()), _respawnCheckTimer(0)
{
for (uint32 x = 0; x < MAX_NUMBER_OF_GRIDS; ++x)

View File

@@ -260,6 +260,17 @@ class TC_GAME_API Map : public GridRefManager<NGridType>
TerrainInfo* GetTerrain() const { return m_terrain.get(); }
// custom PathGenerator include and exclude filter flags
// these modify what kind of terrain types are available in current instance
// for example this can be used to mark offmesh connections as enabled/disabled
uint16 GetForceEnabledNavMeshFilterFlags() const { return m_forceEnabledNavMeshFilterFlags; }
void SetForceEnabledNavMeshFilterFlag(uint16 flag) { m_forceEnabledNavMeshFilterFlags |= flag; }
void RemoveForceEnabledNavMeshFilterFlag(uint16 flag) { m_forceEnabledNavMeshFilterFlags &= ~flag; }
uint16 GetForceDisabledNavMeshFilterFlags() const { return m_forceDisabledNavMeshFilterFlags; }
void SetForceDisabledNavMeshFilterFlag(uint16 flag) { m_forceDisabledNavMeshFilterFlags |= flag; }
void RemoveForceDisabledNavMeshFilterFlag(uint16 flag) { m_forceDisabledNavMeshFilterFlags &= ~flag; }
void GetFullTerrainStatusForPosition(PhaseShift const& phaseShift, float x, float y, float z, PositionFullTerrainStatus& data, map_liquidHeaderTypeFlags reqLiquidType = map_liquidHeaderTypeFlags::AllLiquids, float collisionHeight = 2.03128f); // DEFAULT_COLLISION_HEIGHT in Object.h
ZLiquidStatus GetLiquidStatus(PhaseShift const& phaseShift, float x, float y, float z, map_liquidHeaderTypeFlags ReqLiquidType, LiquidData* data = nullptr, float collisionHeight = 2.03128f); // DEFAULT_COLLISION_HEIGHT in Object.h
@@ -618,6 +629,8 @@ class TC_GAME_API Map : public GridRefManager<NGridType>
time_t i_gridExpiry;
std::shared_ptr<TerrainInfo> m_terrain;
uint16 m_forceEnabledNavMeshFilterFlags;
uint16 m_forceDisabledNavMeshFilterFlags;
NGridType* i_grids[MAX_NUMBER_OF_GRIDS][MAX_NUMBER_OF_GRIDS];
std::bitset<TOTAL_NUMBER_OF_CELLS_PER_MAP*TOTAL_NUMBER_OF_CELLS_PER_MAP> marked_cells;

View File

@@ -674,6 +674,9 @@ void PathGenerator::CreateFilter()
void PathGenerator::UpdateFilter()
{
_filter.setIncludeFlags(_filter.getIncludeFlags() | _source->GetMap()->GetForceEnabledNavMeshFilterFlags());
_filter.setExcludeFlags(_filter.getExcludeFlags() | _source->GetMap()->GetForceDisabledNavMeshFilterFlags());
// allow creatures to cheat and use different movement types if they are moved
// forcefully into terrain they can't normally move in
if (Unit const* _sourceUnit = _source->ToUnit())