TrinityCore
TerrainInfo Class Reference

#include <TerrainMgr.h>

Public Member Functions

 TerrainInfo (uint32 mapId)
 
 TerrainInfo (TerrainInfo const &)=delete
 
 TerrainInfo (TerrainInfo &&)=delete
 
TerrainInfooperator= (TerrainInfo const &)=delete
 
TerrainInfooperator= (TerrainInfo &&)=delete
 
 ~TerrainInfo ()
 
uint32 GetId () const
 
char const * GetMapName () const
 
void DiscoverGridMapFiles ()
 
bool HasChildTerrainGridFile (uint32 mapId, int32 gx, int32 gy) const
 
void AddChildTerrain (std::shared_ptr< TerrainInfo > childTerrain)
 
void LoadMapAndVMap (int32 gx, int32 gy)
 
void LoadMMapInstance (uint32 mapId, uint32 instanceId)
 
void UnloadMap (int32 gx, int32 gy)
 
void UnloadMMapInstance (uint32 mapId, uint32 instanceId)
 
void CleanUpGrids (uint32 diff)
 
void GetFullTerrainStatusForPosition (PhaseShift const &phaseShift, uint32 mapId, float x, float y, float z, PositionFullTerrainStatus &data, Optional< map_liquidHeaderTypeFlags > reqLiquidType={}, float collisionHeight=2.03128f, DynamicMapTree const *dynamicMapTree=nullptr)
 
ZLiquidStatus GetLiquidStatus (PhaseShift const &phaseShift, uint32 mapId, float x, float y, float z, Optional< map_liquidHeaderTypeFlags > ReqLiquidType={}, LiquidData *data=nullptr, float collisionHeight=2.03128f)
 
bool GetAreaInfo (PhaseShift const &phaseShift, uint32 mapId, float x, float y, float z, uint32 &mogpflags, int32 &adtId, int32 &rootId, int32 &groupId, DynamicMapTree const *dynamicMapTree=nullptr)
 
uint32 GetAreaId (PhaseShift const &phaseShift, uint32 mapId, float x, float y, float z, DynamicMapTree const *dynamicMapTree=nullptr)
 
uint32 GetAreaId (PhaseShift const &phaseShift, uint32 mapId, Position const &pos, DynamicMapTree const *dynamicMapTree=nullptr)
 
uint32 GetZoneId (PhaseShift const &phaseShift, uint32 mapId, float x, float y, float z, DynamicMapTree const *dynamicMapTree=nullptr)
 
uint32 GetZoneId (PhaseShift const &phaseShift, uint32 mapId, Position const &pos, DynamicMapTree const *dynamicMapTree=nullptr)
 
void GetZoneAndAreaId (PhaseShift const &phaseShift, uint32 mapId, uint32 &zoneid, uint32 &areaid, float x, float y, float z, DynamicMapTree const *dynamicMapTree=nullptr)
 
void GetZoneAndAreaId (PhaseShift const &phaseShift, uint32 mapId, uint32 &zoneid, uint32 &areaid, Position const &pos, DynamicMapTree const *dynamicMapTree=nullptr)
 
float GetMinHeight (PhaseShift const &phaseShift, uint32 mapId, float x, float y)
 
float GetGridHeight (PhaseShift const &phaseShift, uint32 mapId, float x, float y)
 
float GetStaticHeight (PhaseShift const &phaseShift, uint32 mapId, float x, float y, float z, bool checkVMap=true, float maxSearchDist=DEFAULT_HEIGHT_SEARCH)
 
float GetStaticHeight (PhaseShift const &phaseShift, uint32 mapId, Position const &pos, bool checkVMap=true, float maxSearchDist=DEFAULT_HEIGHT_SEARCH)
 
float GetWaterLevel (PhaseShift const &phaseShift, uint32 mapId, float x, float y)
 
bool IsInWater (PhaseShift const &phaseShift, uint32 mapId, float x, float y, float z, LiquidData *data=nullptr)
 
bool IsUnderWater (PhaseShift const &phaseShift, uint32 mapId, float x, float y, float z)
 
float GetWaterOrGroundLevel (PhaseShift const &phaseShift, uint32 mapId, float x, float y, float z, float *ground=nullptr, bool swim=false, float collisionHeight=2.03128f, DynamicMapTree const *dynamicMapTree=nullptr)
 

Static Public Member Functions

static bool ExistMap (uint32 mapid, int32 gx, int32 gy, bool log=true)
 
static bool ExistVMap (uint32 mapid, int32 gx, int32 gy)
 

Private Member Functions

void LoadMapAndVMapImpl (int32 gx, int32 gy)
 
void LoadMMapInstanceImpl (uint32 mapId, uint32 instanceId)
 
void LoadMap (int32 gx, int32 gy)
 
void LoadVMap (int32 gx, int32 gy)
 
void LoadMMap (int32 gx, int32 gy)
 
void UnloadMapImpl (int32 gx, int32 gy)
 
void UnloadMMapInstanceImpl (uint32 mapId, uint32 instanceId)
 
GridMapGetGrid (uint32 mapId, float x, float y, bool loadIfMissing=true)
 

Static Private Member Functions

static constexpr int32 GetBitsetIndex (int32 gx, int32 gy)
 

Private Attributes

uint32 _mapId
 
TerrainInfo_parentTerrain
 
std::vector< std::shared_ptr< TerrainInfo > > _childTerrain
 
std::mutex _loadMutex
 
std::unique_ptr< GridMap_gridMap [MAX_NUMBER_OF_GRIDS][MAX_NUMBER_OF_GRIDS]
 
std::atomic< uint16_referenceCountFromMap [MAX_NUMBER_OF_GRIDS][MAX_NUMBER_OF_GRIDS]
 
std::bitset< MAX_NUMBER_OF_GRIDS *MAX_NUMBER_OF_GRIDS_loadedGrids
 
std::bitset< MAX_NUMBER_OF_GRIDS *MAX_NUMBER_OF_GRIDS_gridFileExists
 
TimeTracker _cleanupTimer
 

Static Private Attributes

static constexpr Milliseconds CleanupInterval = 1min
 

Detailed Description

Definition at line 37 of file TerrainMgr.h.

Constructor & Destructor Documentation

◆ TerrainInfo() [1/3]

TerrainInfo::TerrainInfo ( uint32  mapId)
explicit

Definition at line 35 of file TerrainMgr.cpp.

◆ TerrainInfo() [2/3]

TerrainInfo::TerrainInfo ( TerrainInfo const &  )
delete

◆ TerrainInfo() [3/3]

TerrainInfo::TerrainInfo ( TerrainInfo &&  )
delete

◆ ~TerrainInfo()

TerrainInfo::~TerrainInfo ( )

Definition at line 39 of file TerrainMgr.cpp.

+ Here is the call graph for this function:

Member Function Documentation

◆ AddChildTerrain()

void TerrainInfo::AddChildTerrain ( std::shared_ptr< TerrainInfo childTerrain)

Definition at line 151 of file TerrainMgr.cpp.

◆ CleanUpGrids()

void TerrainInfo::CleanUpGrids ( uint32  diff)

Definition at line 305 of file TerrainMgr.cpp.

+ Here is the call graph for this function:

◆ DiscoverGridMapFiles()

void TerrainInfo::DiscoverGridMapFiles ( )

Definition at line 50 of file TerrainMgr.cpp.

+ Here is the call graph for this function:

◆ ExistMap()

bool TerrainInfo::ExistMap ( uint32  mapid,
int32  gx,
int32  gy,
bool  log = true 
)
static

Definition at line 77 of file TerrainMgr.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ExistVMap()

bool TerrainInfo::ExistVMap ( uint32  mapid,
int32  gx,
int32  gy 
)
static

Definition at line 110 of file TerrainMgr.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetAreaId() [1/2]

uint32 TerrainInfo::GetAreaId ( PhaseShift const &  phaseShift,
uint32  mapId,
float  x,
float  y,
float  z,
DynamicMapTree const *  dynamicMapTree = nullptr 
)

Definition at line 615 of file TerrainMgr.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetAreaId() [2/2]

uint32 TerrainInfo::GetAreaId ( PhaseShift const &  phaseShift,
uint32  mapId,
Position const &  pos,
DynamicMapTree const *  dynamicMapTree = nullptr 
)
inline

Definition at line 86 of file TerrainMgr.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetAreaInfo()

bool TerrainInfo::GetAreaInfo ( PhaseShift const &  phaseShift,
uint32  mapId,
float  x,
float  y,
float  z,
uint32 mogpflags,
int32 adtId,
int32 rootId,
int32 groupId,
DynamicMapTree const *  dynamicMapTree = nullptr 
)

Definition at line 575 of file TerrainMgr.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetBitsetIndex()

static constexpr int32 TerrainInfo::GetBitsetIndex ( int32  gx,
int32  gy 
)
inlinestaticconstexprprivate

Definition at line 104 of file TerrainMgr.h.

+ Here is the caller graph for this function:

◆ GetFullTerrainStatusForPosition()

void TerrainInfo::GetFullTerrainStatusForPosition ( PhaseShift const &  phaseShift,
uint32  mapId,
float  x,
float  y,
float  z,
PositionFullTerrainStatus data,
Optional< map_liquidHeaderTypeFlags reqLiquidType = {},
float  collisionHeight = 2.03128f,
DynamicMapTree const *  dynamicMapTree = nullptr 
)

Definition at line 325 of file TerrainMgr.cpp.

+ Here is the call graph for this function:

◆ GetGrid()

GridMap * TerrainInfo::GetGrid ( uint32  mapId,
float  x,
float  y,
bool  loadIfMissing = true 
)
private

Definition at line 281 of file TerrainMgr.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetGridHeight()

float TerrainInfo::GetGridHeight ( PhaseShift const &  phaseShift,
uint32  mapId,
float  x,
float  y 
)

Definition at line 677 of file TerrainMgr.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetId()

uint32 TerrainInfo::GetId ( ) const
inline

Definition at line 47 of file TerrainMgr.h.

+ Here is the caller graph for this function:

◆ GetLiquidStatus()

ZLiquidStatus TerrainInfo::GetLiquidStatus ( PhaseShift const &  phaseShift,
uint32  mapId,
float  x,
float  y,
float  z,
Optional< map_liquidHeaderTypeFlags ReqLiquidType = {},
LiquidData data = nullptr,
float  collisionHeight = 2.03128f 
)

Definition at line 475 of file TerrainMgr.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetMapName()

char const * TerrainInfo::GetMapName ( ) const

Definition at line 45 of file TerrainMgr.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetMinHeight()

float TerrainInfo::GetMinHeight ( PhaseShift const &  phaseShift,
uint32  mapId,
float  x,
float  y 
)

Definition at line 669 of file TerrainMgr.cpp.

+ Here is the call graph for this function:

◆ GetStaticHeight() [1/2]

float TerrainInfo::GetStaticHeight ( PhaseShift const &  phaseShift,
uint32  mapId,
float  x,
float  y,
float  z,
bool  checkVMap = true,
float  maxSearchDist = DEFAULT_HEIGHT_SEARCH 
)

Definition at line 685 of file TerrainMgr.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetStaticHeight() [2/2]

float TerrainInfo::GetStaticHeight ( PhaseShift const &  phaseShift,
uint32  mapId,
Position const &  pos,
bool  checkVMap = true,
float  maxSearchDist = DEFAULT_HEIGHT_SEARCH 
)
inline

Definition at line 95 of file TerrainMgr.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetWaterLevel()

float TerrainInfo::GetWaterLevel ( PhaseShift const &  phaseShift,
uint32  mapId,
float  x,
float  y 
)

Definition at line 724 of file TerrainMgr.cpp.

+ Here is the call graph for this function:

◆ GetWaterOrGroundLevel()

float TerrainInfo::GetWaterOrGroundLevel ( PhaseShift const &  phaseShift,
uint32  mapId,
float  x,
float  y,
float  z,
float *  ground = nullptr,
bool  swim = false,
float  collisionHeight = 2.03128f,
DynamicMapTree const *  dynamicMapTree = nullptr 
)

Definition at line 744 of file TerrainMgr.cpp.

+ Here is the call graph for this function:

◆ GetZoneAndAreaId() [1/2]

void TerrainInfo::GetZoneAndAreaId ( PhaseShift const &  phaseShift,
uint32  mapId,
uint32 zoneid,
uint32 areaid,
float  x,
float  y,
float  z,
DynamicMapTree const *  dynamicMapTree = nullptr 
)

Definition at line 661 of file TerrainMgr.cpp.

+ Here is the call graph for this function:

◆ GetZoneAndAreaId() [2/2]

void TerrainInfo::GetZoneAndAreaId ( PhaseShift const &  phaseShift,
uint32  mapId,
uint32 zoneid,
uint32 areaid,
Position const &  pos,
DynamicMapTree const *  dynamicMapTree = nullptr 
)
inline

Definition at line 90 of file TerrainMgr.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetZoneId() [1/2]

uint32 TerrainInfo::GetZoneId ( PhaseShift const &  phaseShift,
uint32  mapId,
float  x,
float  y,
float  z,
DynamicMapTree const *  dynamicMapTree = nullptr 
)

Definition at line 651 of file TerrainMgr.cpp.

+ Here is the call graph for this function:

◆ GetZoneId() [2/2]

uint32 TerrainInfo::GetZoneId ( PhaseShift const &  phaseShift,
uint32  mapId,
Position const &  pos,
DynamicMapTree const *  dynamicMapTree = nullptr 
)
inline

Definition at line 88 of file TerrainMgr.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ HasChildTerrainGridFile()

bool TerrainInfo::HasChildTerrainGridFile ( uint32  mapId,
int32  gx,
int32  gy 
) const

Definition at line 145 of file TerrainMgr.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ IsInWater()

bool TerrainInfo::IsInWater ( PhaseShift const &  phaseShift,
uint32  mapId,
float  x,
float  y,
float  z,
LiquidData data = nullptr 
)

Definition at line 732 of file TerrainMgr.cpp.

+ Here is the call graph for this function:

◆ IsUnderWater()

bool TerrainInfo::IsUnderWater ( PhaseShift const &  phaseShift,
uint32  mapId,
float  x,
float  y,
float  z 
)

Definition at line 739 of file TerrainMgr.cpp.

+ Here is the call graph for this function:

◆ LoadMap()

void TerrainInfo::LoadMap ( int32  gx,
int32  gy 
)
private

Definition at line 191 of file TerrainMgr.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ LoadMapAndVMap()

void TerrainInfo::LoadMapAndVMap ( int32  gx,
int32  gy 
)

Definition at line 157 of file TerrainMgr.cpp.

+ Here is the call graph for this function:

◆ LoadMapAndVMapImpl()

void TerrainInfo::LoadMapAndVMapImpl ( int32  gx,
int32  gy 
)
private

Definition at line 174 of file TerrainMgr.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ LoadMMap()

void TerrainInfo::LoadMMap ( int32  gx,
int32  gy 
)
private

Definition at line 237 of file TerrainMgr.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ LoadMMapInstance()

void TerrainInfo::LoadMMapInstance ( uint32  mapId,
uint32  instanceId 
)

Definition at line 166 of file TerrainMgr.cpp.

+ Here is the call graph for this function:

◆ LoadMMapInstanceImpl()

void TerrainInfo::LoadMMapInstanceImpl ( uint32  mapId,
uint32  instanceId 
)
private

Definition at line 186 of file TerrainMgr.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ LoadVMap()

void TerrainInfo::LoadVMap ( int32  gx,
int32  gy 
)
private

Definition at line 214 of file TerrainMgr.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ operator=() [1/2]

TerrainInfo & TerrainInfo::operator= ( TerrainInfo &&  )
delete

◆ operator=() [2/2]

TerrainInfo & TerrainInfo::operator= ( TerrainInfo const &  )
delete

◆ UnloadMap()

void TerrainInfo::UnloadMap ( int32  gx,
int32  gy 
)

Definition at line 250 of file TerrainMgr.cpp.

◆ UnloadMapImpl()

void TerrainInfo::UnloadMapImpl ( int32  gx,
int32  gy 
)
private

Definition at line 264 of file TerrainMgr.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ UnloadMMapInstance()

void TerrainInfo::UnloadMMapInstance ( uint32  mapId,
uint32  instanceId 
)

Definition at line 256 of file TerrainMgr.cpp.

+ Here is the call graph for this function:

◆ UnloadMMapInstanceImpl()

void TerrainInfo::UnloadMMapInstanceImpl ( uint32  mapId,
uint32  instanceId 
)
private

Definition at line 276 of file TerrainMgr.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ _childTerrain

std::vector<std::shared_ptr<TerrainInfo> > TerrainInfo::_childTerrain
private

Definition at line 109 of file TerrainMgr.h.

◆ _cleanupTimer

TimeTracker TerrainInfo::_cleanupTimer
private

Definition at line 120 of file TerrainMgr.h.

◆ _gridFileExists

std::bitset<MAX_NUMBER_OF_GRIDS* MAX_NUMBER_OF_GRIDS> TerrainInfo::_gridFileExists
private

Definition at line 115 of file TerrainMgr.h.

◆ _gridMap

std::unique_ptr<GridMap> TerrainInfo::_gridMap[MAX_NUMBER_OF_GRIDS][MAX_NUMBER_OF_GRIDS]
private

Definition at line 112 of file TerrainMgr.h.

◆ _loadedGrids

std::bitset<MAX_NUMBER_OF_GRIDS* MAX_NUMBER_OF_GRIDS> TerrainInfo::_loadedGrids
private

Definition at line 114 of file TerrainMgr.h.

◆ _loadMutex

std::mutex TerrainInfo::_loadMutex
private

Definition at line 111 of file TerrainMgr.h.

◆ _mapId

uint32 TerrainInfo::_mapId
private

Definition at line 106 of file TerrainMgr.h.

◆ _parentTerrain

TerrainInfo* TerrainInfo::_parentTerrain
private

Definition at line 108 of file TerrainMgr.h.

◆ _referenceCountFromMap

std::atomic<uint16> TerrainInfo::_referenceCountFromMap[MAX_NUMBER_OF_GRIDS][MAX_NUMBER_OF_GRIDS]
private

Definition at line 113 of file TerrainMgr.h.

◆ CleanupInterval

constexpr Milliseconds TerrainInfo::CleanupInterval = 1min
staticconstexprprivate

Definition at line 117 of file TerrainMgr.h.


The documentation for this class was generated from the following files: