mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-22 21:26:23 +00:00
refactor(Core/Game): restyle game lib with astyle (#3466)
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -156,12 +156,14 @@ enum LineOfSightChecks
|
||||
class GridMap
|
||||
{
|
||||
uint32 _flags;
|
||||
union{
|
||||
union
|
||||
{
|
||||
float* m_V9;
|
||||
uint16* m_uint16_V9;
|
||||
uint8* m_uint8_V9;
|
||||
};
|
||||
union{
|
||||
union
|
||||
{
|
||||
float* m_V8;
|
||||
uint16* m_uint16_V8;
|
||||
uint8* m_uint8_V8;
|
||||
@@ -232,7 +234,7 @@ enum LevelRequirementVsMode
|
||||
{
|
||||
LEVELREQUIREMENT_HEROIC = 70
|
||||
};
|
||||
|
||||
|
||||
struct ZoneDynamicInfo
|
||||
{
|
||||
ZoneDynamicInfo() : MusicId(0), WeatherId(0), WeatherGrade(0.0f),
|
||||
@@ -270,394 +272,394 @@ enum EncounterCreditType
|
||||
class Map : public GridRefManager<NGridType>
|
||||
{
|
||||
friend class MapReference;
|
||||
public:
|
||||
Map(uint32 id, uint32 InstanceId, uint8 SpawnMode, Map* _parent = nullptr);
|
||||
virtual ~Map();
|
||||
public:
|
||||
Map(uint32 id, uint32 InstanceId, uint8 SpawnMode, Map* _parent = nullptr);
|
||||
virtual ~Map();
|
||||
|
||||
MapEntry const* GetEntry() const { return i_mapEntry; }
|
||||
MapEntry const* GetEntry() const { return i_mapEntry; }
|
||||
|
||||
// currently unused for normal maps
|
||||
bool CanUnload(uint32 diff)
|
||||
{
|
||||
if (!m_unloadTimer)
|
||||
return false;
|
||||
|
||||
if (m_unloadTimer <= diff)
|
||||
return true;
|
||||
|
||||
m_unloadTimer -= diff;
|
||||
// currently unused for normal maps
|
||||
bool CanUnload(uint32 diff)
|
||||
{
|
||||
if (!m_unloadTimer)
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual bool AddPlayerToMap(Player*);
|
||||
virtual void RemovePlayerFromMap(Player*, bool);
|
||||
virtual void AfterPlayerUnlinkFromMap();
|
||||
template<class T> bool AddToMap(T *, bool checkTransport = false);
|
||||
template<class T> void RemoveFromMap(T *, bool);
|
||||
if (m_unloadTimer <= diff)
|
||||
return true;
|
||||
|
||||
void VisitNearbyCellsOf(WorldObject* obj, TypeContainerVisitor<acore::ObjectUpdater, GridTypeMapContainer> &gridVisitor,
|
||||
TypeContainerVisitor<acore::ObjectUpdater, WorldTypeMapContainer> &worldVisitor,
|
||||
TypeContainerVisitor<acore::ObjectUpdater, GridTypeMapContainer> &largeGridVisitor,
|
||||
TypeContainerVisitor<acore::ObjectUpdater, WorldTypeMapContainer> &largeWorldVisitor);
|
||||
void VisitNearbyCellsOfPlayer(Player* player, TypeContainerVisitor<acore::ObjectUpdater, GridTypeMapContainer> &gridVisitor,
|
||||
TypeContainerVisitor<acore::ObjectUpdater, WorldTypeMapContainer> &worldVisitor,
|
||||
TypeContainerVisitor<acore::ObjectUpdater, GridTypeMapContainer> &largeGridVisitor,
|
||||
TypeContainerVisitor<acore::ObjectUpdater, WorldTypeMapContainer> &largeWorldVisitor);
|
||||
|
||||
virtual void Update(const uint32, const uint32, bool thread = true);
|
||||
m_unloadTimer -= diff;
|
||||
return false;
|
||||
}
|
||||
|
||||
float GetVisibilityRange() const { return m_VisibleDistance; }
|
||||
void SetVisibilityRange(float range) { m_VisibleDistance = range; }
|
||||
//function for setting up visibility distance for maps on per-type/per-Id basis
|
||||
virtual void InitVisibilityDistance();
|
||||
virtual bool AddPlayerToMap(Player*);
|
||||
virtual void RemovePlayerFromMap(Player*, bool);
|
||||
virtual void AfterPlayerUnlinkFromMap();
|
||||
template<class T> bool AddToMap(T*, bool checkTransport = false);
|
||||
template<class T> void RemoveFromMap(T*, bool);
|
||||
|
||||
void PlayerRelocation(Player*, float x, float y, float z, float o);
|
||||
void CreatureRelocation(Creature* creature, float x, float y, float z, float o);
|
||||
void GameObjectRelocation(GameObject* go, float x, float y, float z, float o);
|
||||
void DynamicObjectRelocation(DynamicObject* go, float x, float y, float z, float o);
|
||||
void VisitNearbyCellsOf(WorldObject* obj, TypeContainerVisitor<acore::ObjectUpdater, GridTypeMapContainer>& gridVisitor,
|
||||
TypeContainerVisitor<acore::ObjectUpdater, WorldTypeMapContainer>& worldVisitor,
|
||||
TypeContainerVisitor<acore::ObjectUpdater, GridTypeMapContainer>& largeGridVisitor,
|
||||
TypeContainerVisitor<acore::ObjectUpdater, WorldTypeMapContainer>& largeWorldVisitor);
|
||||
void VisitNearbyCellsOfPlayer(Player* player, TypeContainerVisitor<acore::ObjectUpdater, GridTypeMapContainer>& gridVisitor,
|
||||
TypeContainerVisitor<acore::ObjectUpdater, WorldTypeMapContainer>& worldVisitor,
|
||||
TypeContainerVisitor<acore::ObjectUpdater, GridTypeMapContainer>& largeGridVisitor,
|
||||
TypeContainerVisitor<acore::ObjectUpdater, WorldTypeMapContainer>& largeWorldVisitor);
|
||||
|
||||
template<class T, class CONTAINER> void Visit(const Cell& cell, TypeContainerVisitor<T, CONTAINER> &visitor);
|
||||
virtual void Update(const uint32, const uint32, bool thread = true);
|
||||
|
||||
bool IsRemovalGrid(float x, float y) const
|
||||
float GetVisibilityRange() const { return m_VisibleDistance; }
|
||||
void SetVisibilityRange(float range) { m_VisibleDistance = range; }
|
||||
//function for setting up visibility distance for maps on per-type/per-Id basis
|
||||
virtual void InitVisibilityDistance();
|
||||
|
||||
void PlayerRelocation(Player*, float x, float y, float z, float o);
|
||||
void CreatureRelocation(Creature* creature, float x, float y, float z, float o);
|
||||
void GameObjectRelocation(GameObject* go, float x, float y, float z, float o);
|
||||
void DynamicObjectRelocation(DynamicObject* go, float x, float y, float z, float o);
|
||||
|
||||
template<class T, class CONTAINER> void Visit(const Cell& cell, TypeContainerVisitor<T, CONTAINER>& visitor);
|
||||
|
||||
bool IsRemovalGrid(float x, float y) const
|
||||
{
|
||||
GridCoord p = acore::ComputeGridCoord(x, y);
|
||||
return !getNGrid(p.x_coord, p.y_coord);
|
||||
}
|
||||
|
||||
bool IsGridLoaded(float x, float y) const
|
||||
{
|
||||
return IsGridLoaded(acore::ComputeGridCoord(x, y));
|
||||
}
|
||||
|
||||
void LoadGrid(float x, float y);
|
||||
void LoadAllCells();
|
||||
bool UnloadGrid(NGridType& ngrid);
|
||||
virtual void UnloadAll();
|
||||
|
||||
uint32 GetId(void) const { return i_mapEntry->MapID; }
|
||||
|
||||
static bool ExistMap(uint32 mapid, int gx, int gy);
|
||||
static bool ExistVMap(uint32 mapid, int gx, int gy);
|
||||
|
||||
Map const* GetParent() const { return m_parentMap; }
|
||||
|
||||
// pussywizard: movemaps, mmaps
|
||||
ACE_RW_Thread_Mutex& GetMMapLock() const { return *(const_cast<ACE_RW_Thread_Mutex*>(&MMapLock)); }
|
||||
// pussywizard:
|
||||
std::unordered_set<Object*> i_objectsToUpdate;
|
||||
void BuildAndSendUpdateForObjects(); // definition in ObjectAccessor.cpp, below ObjectAccessor::Update, because it does the same for a map
|
||||
std::unordered_set<Unit*> i_objectsForDelayedVisibility;
|
||||
void HandleDelayedVisibility();
|
||||
|
||||
// some calls like isInWater should not use vmaps due to processor power
|
||||
// can return INVALID_HEIGHT if under z+2 z coord not found height
|
||||
float GetHeight(float x, float y, float z, bool checkVMap = true, float maxSearchDist = DEFAULT_HEIGHT_SEARCH) const;
|
||||
float GetMinHeight(float x, float y) const;
|
||||
Transport* GetTransportForPos(uint32 phase, float x, float y, float z, WorldObject* worldobject = nullptr);
|
||||
|
||||
ZLiquidStatus getLiquidStatus(float x, float y, float z, uint8 ReqLiquidType, LiquidData* data = 0) const;
|
||||
|
||||
uint32 GetAreaId(float x, float y, float z, bool* isOutdoors) const;
|
||||
bool GetAreaInfo(float x, float y, float z, uint32& mogpflags, int32& adtId, int32& rootId, int32& groupId) const;
|
||||
uint32 GetAreaId(float x, float y, float z) const;
|
||||
uint32 GetZoneId(float x, float y, float z) const;
|
||||
void GetZoneAndAreaId(uint32& zoneid, uint32& areaid, float x, float y, float z) const;
|
||||
|
||||
bool IsOutdoors(float x, float y, float z) const;
|
||||
|
||||
uint8 GetTerrainType(float x, float y) const;
|
||||
float GetWaterLevel(float x, float y) const;
|
||||
bool IsInWater(float x, float y, float z, LiquidData* data = 0) const;
|
||||
bool IsUnderWater(float x, float y, float z) const;
|
||||
|
||||
void MoveAllCreaturesInMoveList();
|
||||
void MoveAllGameObjectsInMoveList();
|
||||
void MoveAllDynamicObjectsInMoveList();
|
||||
void RemoveAllObjectsInRemoveList();
|
||||
virtual void RemoveAllPlayers();
|
||||
|
||||
uint32 GetInstanceId() const { return i_InstanceId; }
|
||||
uint8 GetSpawnMode() const { return (i_spawnMode); }
|
||||
virtual bool CanEnter(Player* /*player*/, bool /*loginCheck = false*/) { return true; }
|
||||
const char* GetMapName() const;
|
||||
|
||||
// have meaning only for instanced map (that have set real difficulty)
|
||||
Difficulty GetDifficulty() const { return Difficulty(GetSpawnMode()); }
|
||||
bool IsRegularDifficulty() const { return GetDifficulty() == REGULAR_DIFFICULTY; }
|
||||
MapDifficulty const* GetMapDifficulty() const;
|
||||
|
||||
bool Instanceable() const { return i_mapEntry && i_mapEntry->Instanceable(); }
|
||||
bool IsDungeon() const { return i_mapEntry && i_mapEntry->IsDungeon(); }
|
||||
bool IsNonRaidDungeon() const { return i_mapEntry && i_mapEntry->IsNonRaidDungeon(); }
|
||||
bool IsRaid() const { return i_mapEntry && i_mapEntry->IsRaid(); }
|
||||
bool IsRaidOrHeroicDungeon() const { return IsRaid() || i_spawnMode > DUNGEON_DIFFICULTY_NORMAL; }
|
||||
bool IsHeroic() const { return IsRaid() ? i_spawnMode >= RAID_DIFFICULTY_10MAN_HEROIC : i_spawnMode >= DUNGEON_DIFFICULTY_HEROIC; }
|
||||
bool Is25ManRaid() const { return IsRaid() && i_spawnMode & RAID_DIFFICULTY_MASK_25MAN; } // since 25man difficulties are 1 and 3, we can check them like that
|
||||
bool IsBattleground() const { return i_mapEntry && i_mapEntry->IsBattleground(); }
|
||||
bool IsBattleArena() const { return i_mapEntry && i_mapEntry->IsBattleArena(); }
|
||||
bool IsBattlegroundOrArena() const { return i_mapEntry && i_mapEntry->IsBattlegroundOrArena(); }
|
||||
bool GetEntrancePos(int32& mapid, float& x, float& y)
|
||||
{
|
||||
if (!i_mapEntry)
|
||||
return false;
|
||||
return i_mapEntry->GetEntrancePos(mapid, x, y);
|
||||
}
|
||||
|
||||
void AddObjectToRemoveList(WorldObject* obj);
|
||||
void AddObjectToSwitchList(WorldObject* obj, bool on);
|
||||
virtual void DelayedUpdate(const uint32 diff);
|
||||
|
||||
//void UpdateObjectVisibility(WorldObject* obj, Cell cell, CellCoord cellpair);
|
||||
//void UpdateObjectsVisibilityFor(Player* player, Cell cell, CellCoord cellpair);
|
||||
|
||||
void resetMarkedCells() { marked_cells.reset(); }
|
||||
bool isCellMarked(uint32 pCellId) { return marked_cells.test(pCellId); }
|
||||
void markCell(uint32 pCellId) { marked_cells.set(pCellId); }
|
||||
void resetMarkedCellsLarge() { marked_cells_large.reset(); }
|
||||
bool isCellMarkedLarge(uint32 pCellId) { return marked_cells_large.test(pCellId); }
|
||||
void markCellLarge(uint32 pCellId) { marked_cells_large.set(pCellId); }
|
||||
|
||||
bool HavePlayers() const { return !m_mapRefManager.isEmpty(); }
|
||||
uint32 GetPlayersCountExceptGMs() const;
|
||||
|
||||
void AddWorldObject(WorldObject* obj) { i_worldObjects.insert(obj); }
|
||||
void RemoveWorldObject(WorldObject* obj) { i_worldObjects.erase(obj); }
|
||||
|
||||
void SendToPlayers(WorldPacket const* data) const;
|
||||
|
||||
typedef MapRefManager PlayerList;
|
||||
PlayerList const& GetPlayers() const { return m_mapRefManager; }
|
||||
|
||||
//per-map script storage
|
||||
void ScriptsStart(std::map<uint32, std::multimap<uint32, ScriptInfo> > const& scripts, uint32 id, Object* source, Object* target);
|
||||
void ScriptCommandStart(ScriptInfo const& script, uint32 delay, Object* source, Object* target);
|
||||
|
||||
// must called with AddToWorld
|
||||
template<class T>
|
||||
void AddToActive(T* obj);
|
||||
|
||||
// must called with RemoveFromWorld
|
||||
template<class T>
|
||||
void RemoveFromActive(T* obj);
|
||||
|
||||
template<class T> void SwitchGridContainers(T* obj, bool on);
|
||||
template<class NOTIFIER> void VisitAll(const float& x, const float& y, float radius, NOTIFIER& notifier);
|
||||
template<class NOTIFIER> void VisitFirstFound(const float& x, const float& y, float radius, NOTIFIER& notifier);
|
||||
template<class NOTIFIER> void VisitWorld(const float& x, const float& y, float radius, NOTIFIER& notifier);
|
||||
template<class NOTIFIER> void VisitGrid(const float& x, const float& y, float radius, NOTIFIER& notifier);
|
||||
CreatureGroupHolderType CreatureGroupHolder;
|
||||
|
||||
void UpdateIteratorBack(Player* player);
|
||||
|
||||
TempSummon* SummonCreature(uint32 entry, Position const& pos, SummonPropertiesEntry const* properties = NULL, uint32 duration = 0, Unit* summoner = NULL, uint32 spellId = 0, uint32 vehId = 0);
|
||||
GameObject* SummonGameObject(uint32 entry, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint32 respawnTime, bool checkTransport = true);
|
||||
void SummonCreatureGroup(uint8 group, std::list<TempSummon*>* list = nullptr);
|
||||
Player* GetPlayer(uint64 guid);
|
||||
Creature* GetCreature(uint64 guid);
|
||||
GameObject* GetGameObject(uint64 guid);
|
||||
Transport* GetTransport(uint64 guid);
|
||||
DynamicObject* GetDynamicObject(uint64 guid);
|
||||
Pet* GetPet(uint64 guid);
|
||||
Corpse* GetCorpse(uint64 guid);
|
||||
|
||||
MapInstanced* ToMapInstanced() { if (Instanceable()) return reinterpret_cast<MapInstanced*>(this); else return nullptr; }
|
||||
const MapInstanced* ToMapInstanced() const { if (Instanceable()) return (const MapInstanced*)((MapInstanced*)this); else return nullptr; }
|
||||
|
||||
InstanceMap* ToInstanceMap() { if (IsDungeon()) return reinterpret_cast<InstanceMap*>(this); else return nullptr; }
|
||||
const InstanceMap* ToInstanceMap() const { if (IsDungeon()) return (const InstanceMap*)((InstanceMap*)this); else return nullptr; }
|
||||
|
||||
BattlegroundMap* ToBattlegroundMap() { if (IsBattlegroundOrArena()) return reinterpret_cast<BattlegroundMap*>(this); else return nullptr; }
|
||||
const BattlegroundMap* ToBattlegroundMap() const { if (IsBattlegroundOrArena()) return reinterpret_cast<BattlegroundMap const*>(this); return nullptr; }
|
||||
|
||||
float GetWaterOrGroundLevel(uint32 phasemask, float x, float y, float z, float* ground = NULL, bool swim = false, float maxSearchDist = 50.0f) const;
|
||||
float GetHeight(uint32 phasemask, float x, float y, float z, bool vmap = true, float maxSearchDist = DEFAULT_HEIGHT_SEARCH) const;
|
||||
bool isInLineOfSight(float x1, float y1, float z1, float x2, float y2, float z2, uint32 phasemask, LineOfSightChecks checks) const;
|
||||
void Balance() { _dynamicTree.balance(); }
|
||||
void RemoveGameObjectModel(const GameObjectModel& model) { _dynamicTree.remove(model); }
|
||||
void InsertGameObjectModel(const GameObjectModel& model) { _dynamicTree.insert(model); }
|
||||
bool ContainsGameObjectModel(const GameObjectModel& model) const { return _dynamicTree.contains(model);}
|
||||
DynamicMapTree const& GetDynamicMapTree() const { return _dynamicTree; }
|
||||
bool getObjectHitPos(uint32 phasemask, float x1, float y1, float z1, float x2, float y2, float z2, float& rx, float& ry, float& rz, float modifyDist);
|
||||
|
||||
/*
|
||||
RESPAWN TIMES
|
||||
*/
|
||||
time_t GetLinkedRespawnTime(uint64 guid) const;
|
||||
time_t GetCreatureRespawnTime(uint32 dbGuid) const
|
||||
{
|
||||
std::unordered_map<uint32 /*dbGUID*/, time_t>::const_iterator itr = _creatureRespawnTimes.find(dbGuid);
|
||||
if (itr != _creatureRespawnTimes.end())
|
||||
return itr->second;
|
||||
|
||||
return time_t(0);
|
||||
}
|
||||
|
||||
time_t GetGORespawnTime(uint32 dbGuid) const
|
||||
{
|
||||
std::unordered_map<uint32 /*dbGUID*/, time_t>::const_iterator itr = _goRespawnTimes.find(dbGuid);
|
||||
if (itr != _goRespawnTimes.end())
|
||||
return itr->second;
|
||||
|
||||
return time_t(0);
|
||||
}
|
||||
|
||||
void SaveCreatureRespawnTime(uint32 dbGuid, time_t& respawnTime);
|
||||
void RemoveCreatureRespawnTime(uint32 dbGuid);
|
||||
void SaveGORespawnTime(uint32 dbGuid, time_t& respawnTime);
|
||||
void RemoveGORespawnTime(uint32 dbGuid);
|
||||
void LoadRespawnTimes();
|
||||
void DeleteRespawnTimes();
|
||||
time_t GetInstanceResetPeriod() const { return _instanceResetPeriod; }
|
||||
|
||||
static void DeleteRespawnTimesInDB(uint16 mapId, uint32 instanceId);
|
||||
|
||||
void SendInitTransports(Player* player);
|
||||
void SendRemoveTransports(Player* player);
|
||||
void SendZoneDynamicInfo(Player* player);
|
||||
void SendInitSelf(Player* player);
|
||||
|
||||
void PlayDirectSoundToMap(uint32 soundId, uint32 zoneId = 0);
|
||||
void SetZoneMusic(uint32 zoneId, uint32 musicId);
|
||||
void SetZoneWeather(uint32 zoneId, uint32 weatherId, float weatherGrade);
|
||||
void SetZoneOverrideLight(uint32 zoneId, uint32 lightId, uint32 fadeInTime);
|
||||
|
||||
// Checks encounter state at kill/spellcast, originally in InstanceScript however not every map has instance script :(
|
||||
void UpdateEncounterState(EncounterCreditType type, uint32 creditEntry, Unit* source);
|
||||
void LogEncounterFinished(EncounterCreditType type, uint32 creditEntry);
|
||||
|
||||
GridMap* GetGrid(float x, float y);
|
||||
void EnsureGridCreated(const GridCoord&);
|
||||
bool AllTransportsEmpty() const; // pussywizard
|
||||
void AllTransportsRemovePassengers(); // pussywizard
|
||||
TransportsContainer const& GetAllTransports() const { return _transports; }
|
||||
|
||||
DataMap CustomData;
|
||||
|
||||
private:
|
||||
void LoadMapAndVMap(int gx, int gy);
|
||||
void LoadVMap(int gx, int gy);
|
||||
void LoadMap(int gx, int gy, bool reload = false);
|
||||
|
||||
// Load MMap Data
|
||||
void LoadMMap(int gx, int gy);
|
||||
|
||||
template<class T> void InitializeObject(T* obj);
|
||||
void AddCreatureToMoveList(Creature* c);
|
||||
void RemoveCreatureFromMoveList(Creature* c);
|
||||
void AddGameObjectToMoveList(GameObject* go);
|
||||
void RemoveGameObjectFromMoveList(GameObject* go);
|
||||
void AddDynamicObjectToMoveList(DynamicObject* go);
|
||||
void RemoveDynamicObjectFromMoveList(DynamicObject* go);
|
||||
|
||||
std::vector<Creature*> _creaturesToMove;
|
||||
std::vector<GameObject*> _gameObjectsToMove;
|
||||
std::vector<DynamicObject*> _dynamicObjectsToMove;
|
||||
|
||||
bool IsGridLoaded(const GridCoord&) const;
|
||||
void EnsureGridCreated_i(const GridCoord&);
|
||||
|
||||
void buildNGridLinkage(NGridType* pNGridType) { pNGridType->link(this); }
|
||||
|
||||
NGridType* getNGrid(uint32 x, uint32 y) const
|
||||
{
|
||||
ASSERT(x < MAX_NUMBER_OF_GRIDS && y < MAX_NUMBER_OF_GRIDS);
|
||||
return i_grids[x][y];
|
||||
}
|
||||
|
||||
bool EnsureGridLoaded(Cell const&);
|
||||
bool isGridObjectDataLoaded(uint32 x, uint32 y) const { return getNGrid(x, y)->isGridObjectDataLoaded(); }
|
||||
void setGridObjectDataLoaded(bool pLoaded, uint32 x, uint32 y) { getNGrid(x, y)->setGridObjectDataLoaded(pLoaded); }
|
||||
|
||||
void setNGrid(NGridType* grid, uint32 x, uint32 y);
|
||||
void ScriptsProcess();
|
||||
|
||||
void UpdateActiveCells(const float& x, const float& y, const uint32 t_diff);
|
||||
|
||||
protected:
|
||||
|
||||
ACE_Thread_Mutex Lock;
|
||||
ACE_Thread_Mutex GridLock;
|
||||
ACE_RW_Thread_Mutex MMapLock;
|
||||
|
||||
MapEntry const* i_mapEntry;
|
||||
uint8 i_spawnMode;
|
||||
uint32 i_InstanceId;
|
||||
uint32 m_unloadTimer;
|
||||
float m_VisibleDistance;
|
||||
DynamicMapTree _dynamicTree;
|
||||
time_t _instanceResetPeriod; // pussywizard
|
||||
|
||||
MapRefManager m_mapRefManager;
|
||||
MapRefManager::iterator m_mapRefIter;
|
||||
|
||||
typedef std::set<WorldObject*> ActiveNonPlayers;
|
||||
ActiveNonPlayers m_activeNonPlayers;
|
||||
ActiveNonPlayers::iterator m_activeNonPlayersIter;
|
||||
|
||||
// Objects that must update even in inactive grids without activating them
|
||||
TransportsContainer _transports;
|
||||
TransportsContainer::iterator _transportsUpdateIter;
|
||||
|
||||
private:
|
||||
Player* _GetScriptPlayerSourceOrTarget(Object* source, Object* target, const ScriptInfo* scriptInfo) const;
|
||||
Creature* _GetScriptCreatureSourceOrTarget(Object* source, Object* target, const ScriptInfo* scriptInfo, bool bReverse = false) const;
|
||||
Unit* _GetScriptUnit(Object* obj, bool isSource, const ScriptInfo* scriptInfo) const;
|
||||
Player* _GetScriptPlayer(Object* obj, bool isSource, const ScriptInfo* scriptInfo) const;
|
||||
Creature* _GetScriptCreature(Object* obj, bool isSource, const ScriptInfo* scriptInfo) const;
|
||||
WorldObject* _GetScriptWorldObject(Object* obj, bool isSource, const ScriptInfo* scriptInfo) const;
|
||||
void _ScriptProcessDoor(Object* source, Object* target, const ScriptInfo* scriptInfo) const;
|
||||
GameObject* _FindGameObject(WorldObject* pWorldObject, uint32 guid) const;
|
||||
|
||||
//used for fast base_map (e.g. MapInstanced class object) search for
|
||||
//InstanceMaps and BattlegroundMaps...
|
||||
Map* m_parentMap;
|
||||
|
||||
NGridType* i_grids[MAX_NUMBER_OF_GRIDS][MAX_NUMBER_OF_GRIDS];
|
||||
GridMap* GridMaps[MAX_NUMBER_OF_GRIDS][MAX_NUMBER_OF_GRIDS];
|
||||
std::bitset<TOTAL_NUMBER_OF_CELLS_PER_MAP* TOTAL_NUMBER_OF_CELLS_PER_MAP> marked_cells;
|
||||
std::bitset<TOTAL_NUMBER_OF_CELLS_PER_MAP* TOTAL_NUMBER_OF_CELLS_PER_MAP> marked_cells_large;
|
||||
|
||||
bool i_scriptLock;
|
||||
std::unordered_set<WorldObject*> i_objectsToRemove;
|
||||
std::map<WorldObject*, bool> i_objectsToSwitch;
|
||||
std::unordered_set<WorldObject*> i_worldObjects;
|
||||
|
||||
typedef std::multimap<time_t, ScriptAction> ScriptScheduleMap;
|
||||
ScriptScheduleMap m_scriptSchedule;
|
||||
|
||||
// Type specific code for add/remove to/from grid
|
||||
template<class T>
|
||||
void AddToGrid(T* object, Cell const& cell);
|
||||
|
||||
template<class T>
|
||||
void DeleteFromWorld(T*);
|
||||
|
||||
void AddToActiveHelper(WorldObject* obj)
|
||||
{
|
||||
m_activeNonPlayers.insert(obj);
|
||||
}
|
||||
|
||||
void RemoveFromActiveHelper(WorldObject* obj)
|
||||
{
|
||||
// Map::Update for active object in proccess
|
||||
if (m_activeNonPlayersIter != m_activeNonPlayers.end())
|
||||
{
|
||||
GridCoord p = acore::ComputeGridCoord(x, y);
|
||||
return !getNGrid(p.x_coord, p.y_coord);
|
||||
ActiveNonPlayers::iterator itr = m_activeNonPlayers.find(obj);
|
||||
if (itr == m_activeNonPlayers.end())
|
||||
return;
|
||||
if (itr == m_activeNonPlayersIter)
|
||||
++m_activeNonPlayersIter;
|
||||
m_activeNonPlayers.erase(itr);
|
||||
}
|
||||
else
|
||||
m_activeNonPlayers.erase(obj);
|
||||
}
|
||||
|
||||
bool IsGridLoaded(float x, float y) const
|
||||
{
|
||||
return IsGridLoaded(acore::ComputeGridCoord(x, y));
|
||||
}
|
||||
std::unordered_map<uint32 /*dbGUID*/, time_t> _creatureRespawnTimes;
|
||||
std::unordered_map<uint32 /*dbGUID*/, time_t> _goRespawnTimes;
|
||||
|
||||
void LoadGrid(float x, float y);
|
||||
void LoadAllCells();
|
||||
bool UnloadGrid(NGridType& ngrid);
|
||||
virtual void UnloadAll();
|
||||
|
||||
uint32 GetId(void) const { return i_mapEntry->MapID; }
|
||||
|
||||
static bool ExistMap(uint32 mapid, int gx, int gy);
|
||||
static bool ExistVMap(uint32 mapid, int gx, int gy);
|
||||
|
||||
Map const* GetParent() const { return m_parentMap; }
|
||||
|
||||
// pussywizard: movemaps, mmaps
|
||||
ACE_RW_Thread_Mutex& GetMMapLock() const { return *(const_cast<ACE_RW_Thread_Mutex*>(&MMapLock)); }
|
||||
// pussywizard:
|
||||
std::unordered_set<Object*> i_objectsToUpdate;
|
||||
void BuildAndSendUpdateForObjects(); // definition in ObjectAccessor.cpp, below ObjectAccessor::Update, because it does the same for a map
|
||||
std::unordered_set<Unit*> i_objectsForDelayedVisibility;
|
||||
void HandleDelayedVisibility();
|
||||
|
||||
// some calls like isInWater should not use vmaps due to processor power
|
||||
// can return INVALID_HEIGHT if under z+2 z coord not found height
|
||||
float GetHeight(float x, float y, float z, bool checkVMap = true, float maxSearchDist = DEFAULT_HEIGHT_SEARCH) const;
|
||||
float GetMinHeight(float x, float y) const;
|
||||
Transport* GetTransportForPos(uint32 phase, float x, float y, float z, WorldObject* worldobject = nullptr);
|
||||
|
||||
ZLiquidStatus getLiquidStatus(float x, float y, float z, uint8 ReqLiquidType, LiquidData* data = 0) const;
|
||||
|
||||
uint32 GetAreaId(float x, float y, float z, bool *isOutdoors) const;
|
||||
bool GetAreaInfo(float x, float y, float z, uint32& mogpflags, int32& adtId, int32& rootId, int32& groupId) const;
|
||||
uint32 GetAreaId(float x, float y, float z) const;
|
||||
uint32 GetZoneId(float x, float y, float z) const;
|
||||
void GetZoneAndAreaId(uint32& zoneid, uint32& areaid, float x, float y, float z) const;
|
||||
|
||||
bool IsOutdoors(float x, float y, float z) const;
|
||||
|
||||
uint8 GetTerrainType(float x, float y) const;
|
||||
float GetWaterLevel(float x, float y) const;
|
||||
bool IsInWater(float x, float y, float z, LiquidData* data = 0) const;
|
||||
bool IsUnderWater(float x, float y, float z) const;
|
||||
|
||||
void MoveAllCreaturesInMoveList();
|
||||
void MoveAllGameObjectsInMoveList();
|
||||
void MoveAllDynamicObjectsInMoveList();
|
||||
void RemoveAllObjectsInRemoveList();
|
||||
virtual void RemoveAllPlayers();
|
||||
|
||||
uint32 GetInstanceId() const { return i_InstanceId; }
|
||||
uint8 GetSpawnMode() const { return (i_spawnMode); }
|
||||
virtual bool CanEnter(Player* /*player*/, bool /*loginCheck = false*/) { return true; }
|
||||
const char* GetMapName() const;
|
||||
|
||||
// have meaning only for instanced map (that have set real difficulty)
|
||||
Difficulty GetDifficulty() const { return Difficulty(GetSpawnMode()); }
|
||||
bool IsRegularDifficulty() const { return GetDifficulty() == REGULAR_DIFFICULTY; }
|
||||
MapDifficulty const* GetMapDifficulty() const;
|
||||
|
||||
bool Instanceable() const { return i_mapEntry && i_mapEntry->Instanceable(); }
|
||||
bool IsDungeon() const { return i_mapEntry && i_mapEntry->IsDungeon(); }
|
||||
bool IsNonRaidDungeon() const { return i_mapEntry && i_mapEntry->IsNonRaidDungeon(); }
|
||||
bool IsRaid() const { return i_mapEntry && i_mapEntry->IsRaid(); }
|
||||
bool IsRaidOrHeroicDungeon() const { return IsRaid() || i_spawnMode > DUNGEON_DIFFICULTY_NORMAL; }
|
||||
bool IsHeroic() const { return IsRaid() ? i_spawnMode >= RAID_DIFFICULTY_10MAN_HEROIC : i_spawnMode >= DUNGEON_DIFFICULTY_HEROIC; }
|
||||
bool Is25ManRaid() const { return IsRaid() && i_spawnMode & RAID_DIFFICULTY_MASK_25MAN; } // since 25man difficulties are 1 and 3, we can check them like that
|
||||
bool IsBattleground() const { return i_mapEntry && i_mapEntry->IsBattleground(); }
|
||||
bool IsBattleArena() const { return i_mapEntry && i_mapEntry->IsBattleArena(); }
|
||||
bool IsBattlegroundOrArena() const { return i_mapEntry && i_mapEntry->IsBattlegroundOrArena(); }
|
||||
bool GetEntrancePos(int32 &mapid, float &x, float &y)
|
||||
{
|
||||
if (!i_mapEntry)
|
||||
return false;
|
||||
return i_mapEntry->GetEntrancePos(mapid, x, y);
|
||||
}
|
||||
|
||||
void AddObjectToRemoveList(WorldObject* obj);
|
||||
void AddObjectToSwitchList(WorldObject* obj, bool on);
|
||||
virtual void DelayedUpdate(const uint32 diff);
|
||||
|
||||
//void UpdateObjectVisibility(WorldObject* obj, Cell cell, CellCoord cellpair);
|
||||
//void UpdateObjectsVisibilityFor(Player* player, Cell cell, CellCoord cellpair);
|
||||
|
||||
void resetMarkedCells() { marked_cells.reset(); }
|
||||
bool isCellMarked(uint32 pCellId) { return marked_cells.test(pCellId); }
|
||||
void markCell(uint32 pCellId) { marked_cells.set(pCellId); }
|
||||
void resetMarkedCellsLarge() { marked_cells_large.reset(); }
|
||||
bool isCellMarkedLarge(uint32 pCellId) { return marked_cells_large.test(pCellId); }
|
||||
void markCellLarge(uint32 pCellId) { marked_cells_large.set(pCellId); }
|
||||
|
||||
bool HavePlayers() const { return !m_mapRefManager.isEmpty(); }
|
||||
uint32 GetPlayersCountExceptGMs() const;
|
||||
|
||||
void AddWorldObject(WorldObject* obj) { i_worldObjects.insert(obj); }
|
||||
void RemoveWorldObject(WorldObject* obj) { i_worldObjects.erase(obj); }
|
||||
|
||||
void SendToPlayers(WorldPacket const* data) const;
|
||||
|
||||
typedef MapRefManager PlayerList;
|
||||
PlayerList const& GetPlayers() const { return m_mapRefManager; }
|
||||
|
||||
//per-map script storage
|
||||
void ScriptsStart(std::map<uint32, std::multimap<uint32, ScriptInfo> > const& scripts, uint32 id, Object* source, Object* target);
|
||||
void ScriptCommandStart(ScriptInfo const& script, uint32 delay, Object* source, Object* target);
|
||||
|
||||
// must called with AddToWorld
|
||||
template<class T>
|
||||
void AddToActive(T* obj);
|
||||
|
||||
// must called with RemoveFromWorld
|
||||
template<class T>
|
||||
void RemoveFromActive(T* obj);
|
||||
|
||||
template<class T> void SwitchGridContainers(T* obj, bool on);
|
||||
template<class NOTIFIER> void VisitAll(const float &x, const float &y, float radius, NOTIFIER ¬ifier);
|
||||
template<class NOTIFIER> void VisitFirstFound(const float &x, const float &y, float radius, NOTIFIER ¬ifier);
|
||||
template<class NOTIFIER> void VisitWorld(const float &x, const float &y, float radius, NOTIFIER ¬ifier);
|
||||
template<class NOTIFIER> void VisitGrid(const float &x, const float &y, float radius, NOTIFIER ¬ifier);
|
||||
CreatureGroupHolderType CreatureGroupHolder;
|
||||
|
||||
void UpdateIteratorBack(Player* player);
|
||||
|
||||
TempSummon* SummonCreature(uint32 entry, Position const& pos, SummonPropertiesEntry const* properties = NULL, uint32 duration = 0, Unit* summoner = NULL, uint32 spellId = 0, uint32 vehId = 0);
|
||||
GameObject* SummonGameObject(uint32 entry, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint32 respawnTime, bool checkTransport = true);
|
||||
void SummonCreatureGroup(uint8 group, std::list<TempSummon*>* list = nullptr);
|
||||
Player* GetPlayer(uint64 guid);
|
||||
Creature* GetCreature(uint64 guid);
|
||||
GameObject* GetGameObject(uint64 guid);
|
||||
Transport* GetTransport(uint64 guid);
|
||||
DynamicObject* GetDynamicObject(uint64 guid);
|
||||
Pet* GetPet(uint64 guid);
|
||||
Corpse* GetCorpse(uint64 guid);
|
||||
|
||||
MapInstanced* ToMapInstanced(){ if (Instanceable()) return reinterpret_cast<MapInstanced*>(this); else return nullptr; }
|
||||
const MapInstanced* ToMapInstanced() const { if (Instanceable()) return (const MapInstanced*)((MapInstanced*)this); else return nullptr; }
|
||||
|
||||
InstanceMap* ToInstanceMap(){ if (IsDungeon()) return reinterpret_cast<InstanceMap*>(this); else return nullptr; }
|
||||
const InstanceMap* ToInstanceMap() const { if (IsDungeon()) return (const InstanceMap*)((InstanceMap*)this); else return nullptr; }
|
||||
|
||||
BattlegroundMap* ToBattlegroundMap() { if (IsBattlegroundOrArena()) return reinterpret_cast<BattlegroundMap*>(this); else return nullptr; }
|
||||
const BattlegroundMap* ToBattlegroundMap() const { if (IsBattlegroundOrArena()) return reinterpret_cast<BattlegroundMap const*>(this); return nullptr; }
|
||||
|
||||
float GetWaterOrGroundLevel(uint32 phasemask,float x, float y, float z, float* ground = NULL, bool swim = false, float maxSearchDist = 50.0f) const;
|
||||
float GetHeight(uint32 phasemask, float x, float y, float z, bool vmap = true, float maxSearchDist = DEFAULT_HEIGHT_SEARCH) const;
|
||||
bool isInLineOfSight(float x1, float y1, float z1, float x2, float y2, float z2, uint32 phasemask, LineOfSightChecks checks) const;
|
||||
void Balance() { _dynamicTree.balance(); }
|
||||
void RemoveGameObjectModel(const GameObjectModel& model) { _dynamicTree.remove(model); }
|
||||
void InsertGameObjectModel(const GameObjectModel& model) { _dynamicTree.insert(model); }
|
||||
bool ContainsGameObjectModel(const GameObjectModel& model) const { return _dynamicTree.contains(model);}
|
||||
DynamicMapTree const& GetDynamicMapTree() const { return _dynamicTree; }
|
||||
bool getObjectHitPos(uint32 phasemask, float x1, float y1, float z1, float x2, float y2, float z2, float& rx, float &ry, float& rz, float modifyDist);
|
||||
|
||||
/*
|
||||
RESPAWN TIMES
|
||||
*/
|
||||
time_t GetLinkedRespawnTime(uint64 guid) const;
|
||||
time_t GetCreatureRespawnTime(uint32 dbGuid) const
|
||||
{
|
||||
std::unordered_map<uint32 /*dbGUID*/, time_t>::const_iterator itr = _creatureRespawnTimes.find(dbGuid);
|
||||
if (itr != _creatureRespawnTimes.end())
|
||||
return itr->second;
|
||||
|
||||
return time_t(0);
|
||||
}
|
||||
|
||||
time_t GetGORespawnTime(uint32 dbGuid) const
|
||||
{
|
||||
std::unordered_map<uint32 /*dbGUID*/, time_t>::const_iterator itr = _goRespawnTimes.find(dbGuid);
|
||||
if (itr != _goRespawnTimes.end())
|
||||
return itr->second;
|
||||
|
||||
return time_t(0);
|
||||
}
|
||||
|
||||
void SaveCreatureRespawnTime(uint32 dbGuid, time_t& respawnTime);
|
||||
void RemoveCreatureRespawnTime(uint32 dbGuid);
|
||||
void SaveGORespawnTime(uint32 dbGuid, time_t& respawnTime);
|
||||
void RemoveGORespawnTime(uint32 dbGuid);
|
||||
void LoadRespawnTimes();
|
||||
void DeleteRespawnTimes();
|
||||
time_t GetInstanceResetPeriod() const { return _instanceResetPeriod; }
|
||||
|
||||
static void DeleteRespawnTimesInDB(uint16 mapId, uint32 instanceId);
|
||||
|
||||
void SendInitTransports(Player* player);
|
||||
void SendRemoveTransports(Player* player);
|
||||
void SendZoneDynamicInfo(Player* player);
|
||||
void SendInitSelf(Player* player);
|
||||
|
||||
void PlayDirectSoundToMap(uint32 soundId, uint32 zoneId = 0);
|
||||
void SetZoneMusic(uint32 zoneId, uint32 musicId);
|
||||
void SetZoneWeather(uint32 zoneId, uint32 weatherId, float weatherGrade);
|
||||
void SetZoneOverrideLight(uint32 zoneId, uint32 lightId, uint32 fadeInTime);
|
||||
|
||||
// Checks encounter state at kill/spellcast, originally in InstanceScript however not every map has instance script :(
|
||||
void UpdateEncounterState(EncounterCreditType type, uint32 creditEntry, Unit* source);
|
||||
void LogEncounterFinished(EncounterCreditType type, uint32 creditEntry);
|
||||
|
||||
GridMap* GetGrid(float x, float y);
|
||||
void EnsureGridCreated(const GridCoord &);
|
||||
bool AllTransportsEmpty() const; // pussywizard
|
||||
void AllTransportsRemovePassengers(); // pussywizard
|
||||
TransportsContainer const& GetAllTransports() const { return _transports; }
|
||||
|
||||
DataMap CustomData;
|
||||
|
||||
private:
|
||||
void LoadMapAndVMap(int gx, int gy);
|
||||
void LoadVMap(int gx, int gy);
|
||||
void LoadMap(int gx, int gy, bool reload = false);
|
||||
|
||||
// Load MMap Data
|
||||
void LoadMMap(int gx, int gy);
|
||||
|
||||
template<class T> void InitializeObject(T* obj);
|
||||
void AddCreatureToMoveList(Creature* c);
|
||||
void RemoveCreatureFromMoveList(Creature* c);
|
||||
void AddGameObjectToMoveList(GameObject* go);
|
||||
void RemoveGameObjectFromMoveList(GameObject* go);
|
||||
void AddDynamicObjectToMoveList(DynamicObject* go);
|
||||
void RemoveDynamicObjectFromMoveList(DynamicObject* go);
|
||||
|
||||
std::vector<Creature*> _creaturesToMove;
|
||||
std::vector<GameObject*> _gameObjectsToMove;
|
||||
std::vector<DynamicObject*> _dynamicObjectsToMove;
|
||||
|
||||
bool IsGridLoaded(const GridCoord &) const;
|
||||
void EnsureGridCreated_i(const GridCoord &);
|
||||
|
||||
void buildNGridLinkage(NGridType* pNGridType) { pNGridType->link(this); }
|
||||
|
||||
NGridType* getNGrid(uint32 x, uint32 y) const
|
||||
{
|
||||
ASSERT(x < MAX_NUMBER_OF_GRIDS && y < MAX_NUMBER_OF_GRIDS);
|
||||
return i_grids[x][y];
|
||||
}
|
||||
|
||||
bool EnsureGridLoaded(Cell const&);
|
||||
bool isGridObjectDataLoaded(uint32 x, uint32 y) const { return getNGrid(x, y)->isGridObjectDataLoaded(); }
|
||||
void setGridObjectDataLoaded(bool pLoaded, uint32 x, uint32 y) { getNGrid(x, y)->setGridObjectDataLoaded(pLoaded); }
|
||||
|
||||
void setNGrid(NGridType* grid, uint32 x, uint32 y);
|
||||
void ScriptsProcess();
|
||||
|
||||
void UpdateActiveCells(const float &x, const float &y, const uint32 t_diff);
|
||||
|
||||
protected:
|
||||
|
||||
ACE_Thread_Mutex Lock;
|
||||
ACE_Thread_Mutex GridLock;
|
||||
ACE_RW_Thread_Mutex MMapLock;
|
||||
|
||||
MapEntry const* i_mapEntry;
|
||||
uint8 i_spawnMode;
|
||||
uint32 i_InstanceId;
|
||||
uint32 m_unloadTimer;
|
||||
float m_VisibleDistance;
|
||||
DynamicMapTree _dynamicTree;
|
||||
time_t _instanceResetPeriod; // pussywizard
|
||||
|
||||
MapRefManager m_mapRefManager;
|
||||
MapRefManager::iterator m_mapRefIter;
|
||||
|
||||
typedef std::set<WorldObject*> ActiveNonPlayers;
|
||||
ActiveNonPlayers m_activeNonPlayers;
|
||||
ActiveNonPlayers::iterator m_activeNonPlayersIter;
|
||||
|
||||
// Objects that must update even in inactive grids without activating them
|
||||
TransportsContainer _transports;
|
||||
TransportsContainer::iterator _transportsUpdateIter;
|
||||
|
||||
private:
|
||||
Player* _GetScriptPlayerSourceOrTarget(Object* source, Object* target, const ScriptInfo* scriptInfo) const;
|
||||
Creature* _GetScriptCreatureSourceOrTarget(Object* source, Object* target, const ScriptInfo* scriptInfo, bool bReverse = false) const;
|
||||
Unit* _GetScriptUnit(Object* obj, bool isSource, const ScriptInfo* scriptInfo) const;
|
||||
Player* _GetScriptPlayer(Object* obj, bool isSource, const ScriptInfo* scriptInfo) const;
|
||||
Creature* _GetScriptCreature(Object* obj, bool isSource, const ScriptInfo* scriptInfo) const;
|
||||
WorldObject* _GetScriptWorldObject(Object* obj, bool isSource, const ScriptInfo* scriptInfo) const;
|
||||
void _ScriptProcessDoor(Object* source, Object* target, const ScriptInfo* scriptInfo) const;
|
||||
GameObject* _FindGameObject(WorldObject* pWorldObject, uint32 guid) const;
|
||||
|
||||
//used for fast base_map (e.g. MapInstanced class object) search for
|
||||
//InstanceMaps and BattlegroundMaps...
|
||||
Map* m_parentMap;
|
||||
|
||||
NGridType* i_grids[MAX_NUMBER_OF_GRIDS][MAX_NUMBER_OF_GRIDS];
|
||||
GridMap* GridMaps[MAX_NUMBER_OF_GRIDS][MAX_NUMBER_OF_GRIDS];
|
||||
std::bitset<TOTAL_NUMBER_OF_CELLS_PER_MAP*TOTAL_NUMBER_OF_CELLS_PER_MAP> marked_cells;
|
||||
std::bitset<TOTAL_NUMBER_OF_CELLS_PER_MAP*TOTAL_NUMBER_OF_CELLS_PER_MAP> marked_cells_large;
|
||||
|
||||
bool i_scriptLock;
|
||||
std::unordered_set<WorldObject*> i_objectsToRemove;
|
||||
std::map<WorldObject*, bool> i_objectsToSwitch;
|
||||
std::unordered_set<WorldObject*> i_worldObjects;
|
||||
|
||||
typedef std::multimap<time_t, ScriptAction> ScriptScheduleMap;
|
||||
ScriptScheduleMap m_scriptSchedule;
|
||||
|
||||
// Type specific code for add/remove to/from grid
|
||||
template<class T>
|
||||
void AddToGrid(T* object, Cell const& cell);
|
||||
|
||||
template<class T>
|
||||
void DeleteFromWorld(T*);
|
||||
|
||||
void AddToActiveHelper(WorldObject* obj)
|
||||
{
|
||||
m_activeNonPlayers.insert(obj);
|
||||
}
|
||||
|
||||
void RemoveFromActiveHelper(WorldObject* obj)
|
||||
{
|
||||
// Map::Update for active object in proccess
|
||||
if (m_activeNonPlayersIter != m_activeNonPlayers.end())
|
||||
{
|
||||
ActiveNonPlayers::iterator itr = m_activeNonPlayers.find(obj);
|
||||
if (itr == m_activeNonPlayers.end())
|
||||
return;
|
||||
if (itr == m_activeNonPlayersIter)
|
||||
++m_activeNonPlayersIter;
|
||||
m_activeNonPlayers.erase(itr);
|
||||
}
|
||||
else
|
||||
m_activeNonPlayers.erase(obj);
|
||||
}
|
||||
|
||||
std::unordered_map<uint32 /*dbGUID*/, time_t> _creatureRespawnTimes;
|
||||
std::unordered_map<uint32 /*dbGUID*/, time_t> _goRespawnTimes;
|
||||
|
||||
ZoneDynamicInfoMap _zoneDynamicInfo;
|
||||
uint32 _defaultLight;
|
||||
ZoneDynamicInfoMap _zoneDynamicInfo;
|
||||
uint32 _defaultLight;
|
||||
};
|
||||
|
||||
|
||||
@@ -672,56 +674,56 @@ enum InstanceResetMethod
|
||||
|
||||
class InstanceMap : public Map
|
||||
{
|
||||
public:
|
||||
InstanceMap(uint32 id, uint32 InstanceId, uint8 SpawnMode, Map* _parent);
|
||||
~InstanceMap();
|
||||
bool AddPlayerToMap(Player*);
|
||||
void RemovePlayerFromMap(Player*, bool);
|
||||
void AfterPlayerUnlinkFromMap();
|
||||
void Update(const uint32, const uint32, bool thread = true);
|
||||
void CreateInstanceScript(bool load, std::string data, uint32 completedEncounterMask);
|
||||
bool Reset(uint8 method, std::list<uint32>* globalSkipList = nullptr);
|
||||
uint32 GetScriptId() { return i_script_id; }
|
||||
InstanceScript* GetInstanceScript() { return instance_script; }
|
||||
void PermBindAllPlayers();
|
||||
void UnloadAll();
|
||||
bool CanEnter(Player* player, bool loginCheck = false);
|
||||
void SendResetWarnings(uint32 timeLeft) const;
|
||||
public:
|
||||
InstanceMap(uint32 id, uint32 InstanceId, uint8 SpawnMode, Map* _parent);
|
||||
~InstanceMap();
|
||||
bool AddPlayerToMap(Player*);
|
||||
void RemovePlayerFromMap(Player*, bool);
|
||||
void AfterPlayerUnlinkFromMap();
|
||||
void Update(const uint32, const uint32, bool thread = true);
|
||||
void CreateInstanceScript(bool load, std::string data, uint32 completedEncounterMask);
|
||||
bool Reset(uint8 method, std::list<uint32>* globalSkipList = nullptr);
|
||||
uint32 GetScriptId() { return i_script_id; }
|
||||
InstanceScript* GetInstanceScript() { return instance_script; }
|
||||
void PermBindAllPlayers();
|
||||
void UnloadAll();
|
||||
bool CanEnter(Player* player, bool loginCheck = false);
|
||||
void SendResetWarnings(uint32 timeLeft) const;
|
||||
|
||||
uint32 GetMaxPlayers() const;
|
||||
uint32 GetMaxResetDelay() const;
|
||||
uint32 GetMaxPlayers() const;
|
||||
uint32 GetMaxResetDelay() const;
|
||||
|
||||
virtual void InitVisibilityDistance();
|
||||
private:
|
||||
bool m_resetAfterUnload;
|
||||
bool m_unloadWhenEmpty;
|
||||
InstanceScript* instance_script;
|
||||
uint32 i_script_id;
|
||||
virtual void InitVisibilityDistance();
|
||||
private:
|
||||
bool m_resetAfterUnload;
|
||||
bool m_unloadWhenEmpty;
|
||||
InstanceScript* instance_script;
|
||||
uint32 i_script_id;
|
||||
};
|
||||
|
||||
class BattlegroundMap : public Map
|
||||
{
|
||||
public:
|
||||
BattlegroundMap(uint32 id, uint32 InstanceId, Map* _parent, uint8 spawnMode);
|
||||
~BattlegroundMap();
|
||||
public:
|
||||
BattlegroundMap(uint32 id, uint32 InstanceId, Map* _parent, uint8 spawnMode);
|
||||
~BattlegroundMap();
|
||||
|
||||
bool AddPlayerToMap(Player*);
|
||||
void RemovePlayerFromMap(Player*, bool);
|
||||
bool CanEnter(Player* player, bool loginCheck = false);
|
||||
void SetUnload();
|
||||
//void UnloadAll(bool pForce);
|
||||
void RemoveAllPlayers();
|
||||
bool AddPlayerToMap(Player*);
|
||||
void RemovePlayerFromMap(Player*, bool);
|
||||
bool CanEnter(Player* player, bool loginCheck = false);
|
||||
void SetUnload();
|
||||
//void UnloadAll(bool pForce);
|
||||
void RemoveAllPlayers();
|
||||
|
||||
virtual void InitVisibilityDistance();
|
||||
Battleground* GetBG() { return m_bg; }
|
||||
void SetBG(Battleground* bg) { m_bg = bg; }
|
||||
private:
|
||||
Battleground* m_bg;
|
||||
virtual void InitVisibilityDistance();
|
||||
Battleground* GetBG() { return m_bg; }
|
||||
void SetBG(Battleground* bg) { m_bg = bg; }
|
||||
private:
|
||||
Battleground* m_bg;
|
||||
};
|
||||
|
||||
template<class T, class CONTAINER>
|
||||
inline void Map::Visit(Cell const& cell, TypeContainerVisitor<T, CONTAINER>& visitor)
|
||||
{
|
||||
{
|
||||
const uint32 x = cell.GridX();
|
||||
const uint32 y = cell.GridY();
|
||||
const uint32 cell_x = cell.CellX();
|
||||
@@ -736,7 +738,7 @@ inline void Map::Visit(Cell const& cell, TypeContainerVisitor<T, CONTAINER>& vis
|
||||
|
||||
template<class NOTIFIER>
|
||||
inline void Map::VisitAll(float const& x, float const& y, float radius, NOTIFIER& notifier)
|
||||
{
|
||||
{
|
||||
CellCoord p(acore::ComputeCellCoord(x, y));
|
||||
Cell cell(p);
|
||||
cell.SetNoCreate();
|
||||
@@ -749,8 +751,8 @@ inline void Map::VisitAll(float const& x, float const& y, float radius, NOTIFIER
|
||||
|
||||
// should be used with Searcher notifiers, tries to search world if nothing found in grid
|
||||
template<class NOTIFIER>
|
||||
inline void Map::VisitFirstFound(const float &x, const float &y, float radius, NOTIFIER ¬ifier)
|
||||
{
|
||||
inline void Map::VisitFirstFound(const float& x, const float& y, float radius, NOTIFIER& notifier)
|
||||
{
|
||||
CellCoord p(acore::ComputeCellCoord(x, y));
|
||||
Cell cell(p);
|
||||
cell.SetNoCreate();
|
||||
@@ -765,8 +767,8 @@ inline void Map::VisitFirstFound(const float &x, const float &y, float radius, N
|
||||
}
|
||||
|
||||
template<class NOTIFIER>
|
||||
inline void Map::VisitWorld(const float &x, const float &y, float radius, NOTIFIER ¬ifier)
|
||||
{
|
||||
inline void Map::VisitWorld(const float& x, const float& y, float radius, NOTIFIER& notifier)
|
||||
{
|
||||
CellCoord p(acore::ComputeCellCoord(x, y));
|
||||
Cell cell(p);
|
||||
cell.SetNoCreate();
|
||||
@@ -776,8 +778,8 @@ inline void Map::VisitWorld(const float &x, const float &y, float radius, NOTIFI
|
||||
}
|
||||
|
||||
template<class NOTIFIER>
|
||||
inline void Map::VisitGrid(const float &x, const float &y, float radius, NOTIFIER ¬ifier)
|
||||
{
|
||||
inline void Map::VisitGrid(const float& x, const float& y, float radius, NOTIFIER& notifier)
|
||||
{
|
||||
CellCoord p(acore::ComputeCellCoord(x, y));
|
||||
Cell cell(p);
|
||||
cell.SetNoCreate();
|
||||
|
||||
@@ -26,7 +26,7 @@ MapInstanced::MapInstanced(uint32 id) : Map(id, 0, DUNGEON_DIFFICULTY_NORMAL)
|
||||
}
|
||||
|
||||
void MapInstanced::InitVisibilityDistance()
|
||||
{
|
||||
{
|
||||
if (m_InstancedMaps.empty())
|
||||
return;
|
||||
//initialize visibility distances for all instance copies
|
||||
@@ -66,7 +66,7 @@ void MapInstanced::Update(const uint32 t, const uint32 s_diff, bool /*thread*/)
|
||||
}
|
||||
|
||||
void MapInstanced::DelayedUpdate(const uint32 diff)
|
||||
{
|
||||
{
|
||||
for (InstancedMaps::iterator i = m_InstancedMaps.begin(); i != m_InstancedMaps.end(); ++i)
|
||||
i->second->DelayedUpdate(diff);
|
||||
|
||||
@@ -75,14 +75,14 @@ void MapInstanced::DelayedUpdate(const uint32 diff)
|
||||
|
||||
/*
|
||||
void MapInstanced::RelocationNotify()
|
||||
{
|
||||
{
|
||||
for (InstancedMaps::iterator i = m_InstancedMaps.begin(); i != m_InstancedMaps.end(); ++i)
|
||||
i->second->RelocationNotify();
|
||||
}
|
||||
*/
|
||||
|
||||
void MapInstanced::UnloadAll()
|
||||
{
|
||||
{
|
||||
// Unload instanced maps
|
||||
for (InstancedMaps::iterator i = m_InstancedMaps.begin(); i != m_InstancedMaps.end(); ++i)
|
||||
i->second->UnloadAll();
|
||||
@@ -103,7 +103,7 @@ void MapInstanced::UnloadAll()
|
||||
- the player is not actually added to the instance (only in InstanceMap::Add)
|
||||
*/
|
||||
Map* MapInstanced::CreateInstanceForPlayer(const uint32 mapId, Player* player)
|
||||
{
|
||||
{
|
||||
if (GetId() != mapId || !player)
|
||||
return nullptr;
|
||||
|
||||
@@ -173,7 +173,7 @@ Map* MapInstanced::CreateInstanceForPlayer(const uint32 mapId, Player* player)
|
||||
}
|
||||
|
||||
InstanceMap* MapInstanced::CreateInstance(uint32 InstanceId, InstanceSave* save, Difficulty difficulty)
|
||||
{
|
||||
{
|
||||
// load/create a map
|
||||
ACORE_GUARD(ACE_Thread_Mutex, Lock);
|
||||
|
||||
@@ -195,7 +195,7 @@ InstanceMap* MapInstanced::CreateInstance(uint32 InstanceId, InstanceSave* save,
|
||||
GetDownscaledMapDifficultyData(GetId(), difficulty);
|
||||
|
||||
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
|
||||
sLog->outDebug(LOG_FILTER_MAPS, "MapInstanced::CreateInstance: %s map instance %d for %d created with difficulty %s", save?"":"new ", InstanceId, GetId(), difficulty?"heroic":"normal");
|
||||
sLog->outDebug(LOG_FILTER_MAPS, "MapInstanced::CreateInstance: %s map instance %d for %d created with difficulty %s", save ? "" : "new ", InstanceId, GetId(), difficulty ? "heroic" : "normal");
|
||||
#endif
|
||||
|
||||
InstanceMap* map = new InstanceMap(GetId(), InstanceId, difficulty, this);
|
||||
@@ -216,7 +216,7 @@ InstanceMap* MapInstanced::CreateInstance(uint32 InstanceId, InstanceSave* save,
|
||||
}
|
||||
|
||||
BattlegroundMap* MapInstanced::CreateBattleground(uint32 InstanceId, Battleground* bg)
|
||||
{
|
||||
{
|
||||
// load/create a map
|
||||
ACORE_GUARD(ACE_Thread_Mutex, Lock);
|
||||
|
||||
@@ -243,8 +243,8 @@ BattlegroundMap* MapInstanced::CreateBattleground(uint32 InstanceId, Battlegroun
|
||||
}
|
||||
|
||||
// increments the iterator after erase
|
||||
bool MapInstanced::DestroyInstance(InstancedMaps::iterator &itr)
|
||||
{
|
||||
bool MapInstanced::DestroyInstance(InstancedMaps::iterator& itr)
|
||||
{
|
||||
itr->second->RemoveAllPlayers();
|
||||
if (itr->second->HavePlayers())
|
||||
{
|
||||
@@ -271,7 +271,7 @@ bool MapInstanced::DestroyInstance(InstancedMaps::iterator &itr)
|
||||
}
|
||||
|
||||
bool MapInstanced::CanEnter(Player* /*player*/, bool /*loginCheck*/)
|
||||
{
|
||||
{
|
||||
//ABORT();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -14,34 +14,34 @@
|
||||
class MapInstanced : public Map
|
||||
{
|
||||
friend class MapManager;
|
||||
public:
|
||||
typedef std::unordered_map< uint32, Map*> InstancedMaps;
|
||||
public:
|
||||
typedef std::unordered_map< uint32, Map*> InstancedMaps;
|
||||
|
||||
MapInstanced(uint32 id);
|
||||
~MapInstanced() {}
|
||||
MapInstanced(uint32 id);
|
||||
~MapInstanced() {}
|
||||
|
||||
// functions overwrite Map versions
|
||||
void Update(const uint32, const uint32, bool thread = true);
|
||||
void DelayedUpdate(const uint32 diff);
|
||||
//void RelocationNotify();
|
||||
void UnloadAll();
|
||||
bool CanEnter(Player* player, bool loginCheck = false);
|
||||
// functions overwrite Map versions
|
||||
void Update(const uint32, const uint32, bool thread = true);
|
||||
void DelayedUpdate(const uint32 diff);
|
||||
//void RelocationNotify();
|
||||
void UnloadAll();
|
||||
bool CanEnter(Player* player, bool loginCheck = false);
|
||||
|
||||
Map* CreateInstanceForPlayer(const uint32 mapId, Player* player);
|
||||
Map* FindInstanceMap(uint32 instanceId) const
|
||||
{
|
||||
InstancedMaps::const_iterator i = m_InstancedMaps.find(instanceId);
|
||||
return(i == m_InstancedMaps.end() ? NULL : i->second);
|
||||
}
|
||||
bool DestroyInstance(InstancedMaps::iterator &itr);
|
||||
Map* CreateInstanceForPlayer(const uint32 mapId, Player* player);
|
||||
Map* FindInstanceMap(uint32 instanceId) const
|
||||
{
|
||||
InstancedMaps::const_iterator i = m_InstancedMaps.find(instanceId);
|
||||
return(i == m_InstancedMaps.end() ? NULL : i->second);
|
||||
}
|
||||
bool DestroyInstance(InstancedMaps::iterator& itr);
|
||||
|
||||
InstancedMaps &GetInstancedMaps() { return m_InstancedMaps; }
|
||||
virtual void InitVisibilityDistance();
|
||||
InstancedMaps& GetInstancedMaps() { return m_InstancedMaps; }
|
||||
virtual void InitVisibilityDistance();
|
||||
|
||||
private:
|
||||
InstanceMap* CreateInstance(uint32 InstanceId, InstanceSave* save, Difficulty difficulty);
|
||||
BattlegroundMap* CreateBattleground(uint32 InstanceId, Battleground* bg);
|
||||
private:
|
||||
InstanceMap* CreateInstance(uint32 InstanceId, InstanceSave* save, Difficulty difficulty);
|
||||
BattlegroundMap* CreateBattleground(uint32 InstanceId, Battleground* bg);
|
||||
|
||||
InstancedMaps m_InstancedMaps;
|
||||
InstancedMaps m_InstancedMaps;
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -59,7 +59,7 @@ void MapManager::Initialize()
|
||||
|
||||
void MapManager::InitializeVisibilityDistanceInfo()
|
||||
{
|
||||
for (MapMapType::iterator iter=i_maps.begin(); iter != i_maps.end(); ++iter)
|
||||
for (MapMapType::iterator iter = i_maps.begin(); iter != i_maps.end(); ++iter)
|
||||
(*iter).second->InitVisibilityDistance();
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ bool MapManager::CanPlayerEnter(uint32 mapid, Player* player, bool loginCheck)
|
||||
{
|
||||
MapEntry const* entry = sMapStore.LookupEntry(mapid);
|
||||
if (!entry)
|
||||
return false;
|
||||
return false;
|
||||
|
||||
if (!entry->IsDungeon())
|
||||
return true;
|
||||
@@ -207,7 +207,8 @@ bool MapManager::CanPlayerEnter(uint32 mapid, Player* player, bool loginCheck)
|
||||
player->ResurrectPlayer(0.5f, false);
|
||||
player->SpawnCorpseBones();
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
|
||||
sLog->outDebug(LOG_FILTER_MAPS, "Map::CanPlayerEnter - player '%s' is dead but does not have a corpse!", player->GetName().c_str());
|
||||
#endif
|
||||
@@ -245,7 +246,7 @@ bool MapManager::CanPlayerEnter(uint32 mapid, Player* player, bool loginCheck)
|
||||
|
||||
void MapManager::Update(uint32 diff)
|
||||
{
|
||||
for (uint8 i=0; i<4; ++i)
|
||||
for (uint8 i = 0; i < 4; ++i)
|
||||
i_timer[i].Update(diff);
|
||||
|
||||
// pussywizard: lfg compatibles update, schedule before maps so it is processed from the very beginning
|
||||
@@ -258,14 +259,14 @@ void MapManager::Update(uint32 diff)
|
||||
uint32 startTime = getMSTime();
|
||||
sLFGMgr->Update(diff, 1);
|
||||
uint32 totalTime = getMSTimeDiff(startTime, getMSTime());
|
||||
lfgDiffTracker.Update(10000+totalTime); // +10k to mark it was NOT multithreaded
|
||||
lfgDiffTracker.Update(10000 + totalTime); // +10k to mark it was NOT multithreaded
|
||||
}
|
||||
}
|
||||
|
||||
MapMapType::iterator iter = i_maps.begin();
|
||||
for (; iter != i_maps.end(); ++iter)
|
||||
{
|
||||
bool full = mapUpdateStep<3 && ((mapUpdateStep==0 && !iter->second->IsBattlegroundOrArena() && !iter->second->IsDungeon()) || (mapUpdateStep==1 && iter->second->IsBattlegroundOrArena()) || (mapUpdateStep==2 && iter->second->IsDungeon()));
|
||||
bool full = mapUpdateStep < 3 && ((mapUpdateStep == 0 && !iter->second->IsBattlegroundOrArena() && !iter->second->IsDungeon()) || (mapUpdateStep == 1 && iter->second->IsBattlegroundOrArena()) || (mapUpdateStep == 2 && iter->second->IsDungeon()));
|
||||
if (m_updater.activated())
|
||||
m_updater.schedule_update(*iter->second, uint32(full ? i_timer[mapUpdateStep].GetCurrent() : 0), diff);
|
||||
else
|
||||
@@ -277,11 +278,11 @@ void MapManager::Update(uint32 diff)
|
||||
|
||||
sObjectAccessor->ProcessDelayedCorpseActions();
|
||||
|
||||
if (mapUpdateStep<3)
|
||||
if (mapUpdateStep < 3)
|
||||
{
|
||||
for (iter = i_maps.begin(); iter != i_maps.end(); ++iter)
|
||||
{
|
||||
bool full = ((mapUpdateStep==0 && !iter->second->IsBattlegroundOrArena() && !iter->second->IsDungeon()) || (mapUpdateStep==1 && iter->second->IsBattlegroundOrArena()) || (mapUpdateStep==2 && iter->second->IsDungeon()));
|
||||
bool full = ((mapUpdateStep == 0 && !iter->second->IsBattlegroundOrArena() && !iter->second->IsDungeon()) || (mapUpdateStep == 1 && iter->second->IsBattlegroundOrArena()) || (mapUpdateStep == 2 && iter->second->IsDungeon()));
|
||||
if (full)
|
||||
iter->second->DelayedUpdate(uint32(i_timer[mapUpdateStep].GetCurrent()));
|
||||
}
|
||||
@@ -307,8 +308,8 @@ bool MapManager::ExistMapAndVMap(uint32 mapid, float x, float y)
|
||||
{
|
||||
GridCoord p = acore::ComputeGridCoord(x, y);
|
||||
|
||||
int gx=63-p.x_coord;
|
||||
int gy=63-p.y_coord;
|
||||
int gx = 63 - p.x_coord;
|
||||
int gy = 63 - p.y_coord;
|
||||
|
||||
return Map::ExistMap(mapid, gx, gy) && Map::ExistVMap(mapid, gx, gy);
|
||||
}
|
||||
@@ -345,7 +346,7 @@ void MapManager::GetNumInstances(uint32& dungeons, uint32& battlegrounds, uint32
|
||||
Map* map = itr->second;
|
||||
if (!map->Instanceable())
|
||||
continue;
|
||||
MapInstanced::InstancedMaps &maps = ((MapInstanced*)map)->GetInstancedMaps();
|
||||
MapInstanced::InstancedMaps& maps = ((MapInstanced*)map)->GetInstancedMaps();
|
||||
for (MapInstanced::InstancedMaps::iterator mitr = maps.begin(); mitr != maps.end(); ++mitr)
|
||||
{
|
||||
if (mitr->second->IsDungeon()) dungeons++;
|
||||
@@ -362,7 +363,7 @@ void MapManager::GetNumPlayersInInstances(uint32& dungeons, uint32& battleground
|
||||
Map* map = itr->second;
|
||||
if (!map->Instanceable())
|
||||
continue;
|
||||
MapInstanced::InstancedMaps &maps = ((MapInstanced*)map)->GetInstancedMaps();
|
||||
MapInstanced::InstancedMaps& maps = ((MapInstanced*)map)->GetInstancedMaps();
|
||||
for (MapInstanced::InstancedMaps::iterator mitr = maps.begin(); mitr != maps.end(); ++mitr)
|
||||
{
|
||||
if (mitr->second->IsDungeon()) dungeons += ((InstanceMap*)mitr->second)->GetPlayers().getSize();
|
||||
@@ -389,7 +390,7 @@ void MapManager::InitInstanceIds()
|
||||
if (result)
|
||||
{
|
||||
uint32 maxId = (*result)[0].GetUInt32();
|
||||
_instanceIds.resize(maxId+1);
|
||||
_instanceIds.resize(maxId + 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,123 +21,123 @@ struct TransportCreatureProto;
|
||||
|
||||
class MapManager
|
||||
{
|
||||
public:
|
||||
static MapManager* instance();
|
||||
public:
|
||||
static MapManager* instance();
|
||||
|
||||
Map* CreateBaseMap(uint32 mapId);
|
||||
Map* FindBaseNonInstanceMap(uint32 mapId) const;
|
||||
Map* CreateMap(uint32 mapId, Player* player);
|
||||
Map* FindMap(uint32 mapId, uint32 instanceId) const;
|
||||
Map* CreateBaseMap(uint32 mapId);
|
||||
Map* FindBaseNonInstanceMap(uint32 mapId) const;
|
||||
Map* CreateMap(uint32 mapId, Player* player);
|
||||
Map* FindMap(uint32 mapId, uint32 instanceId) const;
|
||||
|
||||
Map* FindBaseMap(uint32 mapId) const // pussywizard: need this public for movemaps (mmaps)
|
||||
Map* FindBaseMap(uint32 mapId) const // pussywizard: need this public for movemaps (mmaps)
|
||||
{
|
||||
MapMapType::const_iterator iter = i_maps.find(mapId);
|
||||
return (iter == i_maps.end() ? NULL : iter->second);
|
||||
}
|
||||
|
||||
uint32 GetAreaId(uint32 mapid, float x, float y, float z) const
|
||||
{
|
||||
Map const* m = const_cast<MapManager*>(this)->CreateBaseMap(mapid);
|
||||
return m->GetAreaId(x, y, z);
|
||||
}
|
||||
uint32 GetZoneId(uint32 mapid, float x, float y, float z) const
|
||||
{
|
||||
Map const* m = const_cast<MapManager*>(this)->CreateBaseMap(mapid);
|
||||
return m->GetZoneId(x, y, z);
|
||||
}
|
||||
void GetZoneAndAreaId(uint32& zoneid, uint32& areaid, uint32 mapid, float x, float y, float z)
|
||||
{
|
||||
Map const* m = const_cast<MapManager*>(this)->CreateBaseMap(mapid);
|
||||
m->GetZoneAndAreaId(zoneid, areaid, x, y, z);
|
||||
}
|
||||
|
||||
void Initialize(void);
|
||||
void Update(uint32);
|
||||
|
||||
void SetMapUpdateInterval(uint32 t)
|
||||
{
|
||||
if (t < MIN_MAP_UPDATE_DELAY)
|
||||
t = MIN_MAP_UPDATE_DELAY;
|
||||
|
||||
i_timer[3].SetInterval(t);
|
||||
i_timer[3].Reset();
|
||||
}
|
||||
|
||||
//void LoadGrid(int mapid, int instId, float x, float y, const WorldObject* obj, bool no_unload = false);
|
||||
void UnloadAll();
|
||||
|
||||
static bool ExistMapAndVMap(uint32 mapid, float x, float y);
|
||||
static bool IsValidMAP(uint32 mapid, bool startUp);
|
||||
|
||||
static bool IsValidMapCoord(uint32 mapid, float x, float y)
|
||||
{
|
||||
return IsValidMAP(mapid, false) && acore::IsValidMapCoord(x, y);
|
||||
}
|
||||
|
||||
static bool IsValidMapCoord(uint32 mapid, float x, float y, float z)
|
||||
{
|
||||
return IsValidMAP(mapid, false) && acore::IsValidMapCoord(x, y, z);
|
||||
}
|
||||
|
||||
static bool IsValidMapCoord(uint32 mapid, float x, float y, float z, float o)
|
||||
{
|
||||
return IsValidMAP(mapid, false) && acore::IsValidMapCoord(x, y, z, o);
|
||||
}
|
||||
|
||||
static bool IsValidMapCoord(WorldLocation const& loc)
|
||||
{
|
||||
return IsValidMapCoord(loc.GetMapId(), loc.GetPositionX(), loc.GetPositionY(), loc.GetPositionZ(), loc.GetOrientation());
|
||||
}
|
||||
|
||||
// modulos a radian orientation to the range of 0..2PI
|
||||
static float NormalizeOrientation(float o)
|
||||
{
|
||||
// fmod only supports positive numbers. Thus we have
|
||||
// to emulate negative numbers
|
||||
if (o < 0)
|
||||
{
|
||||
MapMapType::const_iterator iter = i_maps.find(mapId);
|
||||
return (iter == i_maps.end() ? NULL : iter->second);
|
||||
float mod = o * -1;
|
||||
mod = fmod(mod, 2.0f * static_cast<float>(M_PI));
|
||||
mod = -mod + 2.0f * static_cast<float>(M_PI);
|
||||
return mod;
|
||||
}
|
||||
return fmod(o, 2.0f * static_cast<float>(M_PI));
|
||||
}
|
||||
|
||||
uint32 GetAreaId(uint32 mapid, float x, float y, float z) const
|
||||
{
|
||||
Map const* m = const_cast<MapManager*>(this)->CreateBaseMap(mapid);
|
||||
return m->GetAreaId(x, y, z);
|
||||
}
|
||||
uint32 GetZoneId(uint32 mapid, float x, float y, float z) const
|
||||
{
|
||||
Map const* m = const_cast<MapManager*>(this)->CreateBaseMap(mapid);
|
||||
return m->GetZoneId(x, y, z);
|
||||
}
|
||||
void GetZoneAndAreaId(uint32& zoneid, uint32& areaid, uint32 mapid, float x, float y, float z)
|
||||
{
|
||||
Map const* m = const_cast<MapManager*>(this)->CreateBaseMap(mapid);
|
||||
m->GetZoneAndAreaId(zoneid, areaid, x, y, z);
|
||||
}
|
||||
void DoDelayedMovesAndRemoves();
|
||||
|
||||
void Initialize(void);
|
||||
void Update(uint32);
|
||||
bool CanPlayerEnter(uint32 mapid, Player* player, bool loginCheck = false);
|
||||
void InitializeVisibilityDistanceInfo();
|
||||
|
||||
void SetMapUpdateInterval(uint32 t)
|
||||
{
|
||||
if (t < MIN_MAP_UPDATE_DELAY)
|
||||
t = MIN_MAP_UPDATE_DELAY;
|
||||
/* statistics */
|
||||
void GetNumInstances(uint32& dungeons, uint32& battlegrounds, uint32& arenas);
|
||||
void GetNumPlayersInInstances(uint32& dungeons, uint32& battlegrounds, uint32& arenas, uint32& spectators);
|
||||
|
||||
i_timer[3].SetInterval(t);
|
||||
i_timer[3].Reset();
|
||||
}
|
||||
// Instance ID management
|
||||
void InitInstanceIds();
|
||||
void RegisterInstanceId(uint32 instanceId);
|
||||
uint32 GenerateInstanceId();
|
||||
|
||||
//void LoadGrid(int mapid, int instId, float x, float y, const WorldObject* obj, bool no_unload = false);
|
||||
void UnloadAll();
|
||||
MapUpdater* GetMapUpdater() { return &m_updater; }
|
||||
|
||||
static bool ExistMapAndVMap(uint32 mapid, float x, float y);
|
||||
static bool IsValidMAP(uint32 mapid, bool startUp);
|
||||
private:
|
||||
typedef std::unordered_map<uint32, Map*> MapMapType;
|
||||
typedef std::vector<bool> InstanceIds;
|
||||
|
||||
static bool IsValidMapCoord(uint32 mapid, float x, float y)
|
||||
{
|
||||
return IsValidMAP(mapid, false) && acore::IsValidMapCoord(x, y);
|
||||
}
|
||||
MapManager();
|
||||
~MapManager();
|
||||
|
||||
static bool IsValidMapCoord(uint32 mapid, float x, float y, float z)
|
||||
{
|
||||
return IsValidMAP(mapid, false) && acore::IsValidMapCoord(x, y, z);
|
||||
}
|
||||
MapManager(const MapManager&);
|
||||
MapManager& operator=(const MapManager&);
|
||||
|
||||
static bool IsValidMapCoord(uint32 mapid, float x, float y, float z, float o)
|
||||
{
|
||||
return IsValidMAP(mapid, false) && acore::IsValidMapCoord(x, y, z, o);
|
||||
}
|
||||
ACE_Thread_Mutex Lock;
|
||||
MapMapType i_maps;
|
||||
IntervalTimer i_timer[4]; // continents, bgs/arenas, instances, total from the beginning
|
||||
uint8 mapUpdateStep;
|
||||
|
||||
static bool IsValidMapCoord(WorldLocation const& loc)
|
||||
{
|
||||
return IsValidMapCoord(loc.GetMapId(), loc.GetPositionX(), loc.GetPositionY(), loc.GetPositionZ(), loc.GetOrientation());
|
||||
}
|
||||
|
||||
// modulos a radian orientation to the range of 0..2PI
|
||||
static float NormalizeOrientation(float o)
|
||||
{
|
||||
// fmod only supports positive numbers. Thus we have
|
||||
// to emulate negative numbers
|
||||
if (o < 0)
|
||||
{
|
||||
float mod = o *-1;
|
||||
mod = fmod(mod, 2.0f * static_cast<float>(M_PI));
|
||||
mod = -mod + 2.0f * static_cast<float>(M_PI);
|
||||
return mod;
|
||||
}
|
||||
return fmod(o, 2.0f * static_cast<float>(M_PI));
|
||||
}
|
||||
|
||||
void DoDelayedMovesAndRemoves();
|
||||
|
||||
bool CanPlayerEnter(uint32 mapid, Player* player, bool loginCheck = false);
|
||||
void InitializeVisibilityDistanceInfo();
|
||||
|
||||
/* statistics */
|
||||
void GetNumInstances(uint32& dungeons, uint32& battlegrounds, uint32& arenas);
|
||||
void GetNumPlayersInInstances(uint32& dungeons, uint32& battlegrounds, uint32& arenas, uint32& spectators);
|
||||
|
||||
// Instance ID management
|
||||
void InitInstanceIds();
|
||||
void RegisterInstanceId(uint32 instanceId);
|
||||
uint32 GenerateInstanceId();
|
||||
|
||||
MapUpdater * GetMapUpdater() { return &m_updater; }
|
||||
|
||||
private:
|
||||
typedef std::unordered_map<uint32, Map*> MapMapType;
|
||||
typedef std::vector<bool> InstanceIds;
|
||||
|
||||
MapManager();
|
||||
~MapManager();
|
||||
|
||||
MapManager(const MapManager &);
|
||||
MapManager& operator=(const MapManager &);
|
||||
|
||||
ACE_Thread_Mutex Lock;
|
||||
MapMapType i_maps;
|
||||
IntervalTimer i_timer[4]; // continents, bgs/arenas, instances, total from the beginning
|
||||
uint8 mapUpdateStep;
|
||||
|
||||
InstanceIds _instanceIds;
|
||||
uint32 _nextInstanceId;
|
||||
MapUpdater m_updater;
|
||||
InstanceIds _instanceIds;
|
||||
uint32 _nextInstanceId;
|
||||
MapUpdater m_updater;
|
||||
};
|
||||
|
||||
#define sMapMgr MapManager::instance()
|
||||
|
||||
@@ -13,21 +13,21 @@ class MapReference;
|
||||
|
||||
class MapRefManager : public RefManager<Map, Player>
|
||||
{
|
||||
public:
|
||||
typedef LinkedListHead::Iterator< MapReference > iterator;
|
||||
typedef LinkedListHead::Iterator< MapReference const > const_iterator;
|
||||
public:
|
||||
typedef LinkedListHead::Iterator< MapReference > iterator;
|
||||
typedef LinkedListHead::Iterator< MapReference const > const_iterator;
|
||||
|
||||
MapReference* getFirst() { return (MapReference*)RefManager<Map, Player>::getFirst(); }
|
||||
MapReference const* getFirst() const { return (MapReference const*)RefManager<Map, Player>::getFirst(); }
|
||||
MapReference* getLast() { return (MapReference*)RefManager<Map, Player>::getLast(); }
|
||||
MapReference const* getLast() const { return (MapReference const*)RefManager<Map, Player>::getLast(); }
|
||||
MapReference* getFirst() { return (MapReference*)RefManager<Map, Player>::getFirst(); }
|
||||
MapReference const* getFirst() const { return (MapReference const*)RefManager<Map, Player>::getFirst(); }
|
||||
MapReference* getLast() { return (MapReference*)RefManager<Map, Player>::getLast(); }
|
||||
MapReference const* getLast() const { return (MapReference const*)RefManager<Map, Player>::getLast(); }
|
||||
|
||||
iterator begin() { return iterator(getFirst()); }
|
||||
iterator end() { return iterator(nullptr); }
|
||||
iterator rbegin() { return iterator(getLast()); }
|
||||
iterator rend() { return iterator(nullptr); }
|
||||
const_iterator begin() const { return const_iterator(getFirst()); }
|
||||
const_iterator end() const { return const_iterator(nullptr); }
|
||||
iterator begin() { return iterator(getFirst()); }
|
||||
iterator end() { return iterator(nullptr); }
|
||||
iterator rbegin() { return iterator(getLast()); }
|
||||
iterator rend() { return iterator(nullptr); }
|
||||
const_iterator begin() const { return const_iterator(getFirst()); }
|
||||
const_iterator end() const { return const_iterator(nullptr); }
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
@@ -12,30 +12,30 @@
|
||||
|
||||
class MapReference : public Reference<Map, Player>
|
||||
{
|
||||
protected:
|
||||
void targetObjectBuildLink()
|
||||
{
|
||||
// called from link()
|
||||
getTarget()->m_mapRefManager.insertFirst(this);
|
||||
getTarget()->m_mapRefManager.incSize();
|
||||
}
|
||||
void targetObjectDestroyLink()
|
||||
{
|
||||
// called from unlink()
|
||||
if (isValid()) getTarget()->m_mapRefManager.decSize();
|
||||
}
|
||||
void sourceObjectDestroyLink()
|
||||
{
|
||||
// called from invalidate()
|
||||
getTarget()->m_mapRefManager.decSize();
|
||||
}
|
||||
public:
|
||||
MapReference() : Reference<Map, Player>() {}
|
||||
~MapReference() { unlink(); }
|
||||
MapReference* next() { return (MapReference*)Reference<Map, Player>::next(); }
|
||||
MapReference const* next() const { return (MapReference const*)Reference<Map, Player>::next(); }
|
||||
MapReference* nockeck_prev() { return (MapReference*)Reference<Map, Player>::nocheck_prev(); }
|
||||
MapReference const* nocheck_prev() const { return (MapReference const*)Reference<Map, Player>::nocheck_prev(); }
|
||||
protected:
|
||||
void targetObjectBuildLink()
|
||||
{
|
||||
// called from link()
|
||||
getTarget()->m_mapRefManager.insertFirst(this);
|
||||
getTarget()->m_mapRefManager.incSize();
|
||||
}
|
||||
void targetObjectDestroyLink()
|
||||
{
|
||||
// called from unlink()
|
||||
if (isValid()) getTarget()->m_mapRefManager.decSize();
|
||||
}
|
||||
void sourceObjectDestroyLink()
|
||||
{
|
||||
// called from invalidate()
|
||||
getTarget()->m_mapRefManager.decSize();
|
||||
}
|
||||
public:
|
||||
MapReference() : Reference<Map, Player>() {}
|
||||
~MapReference() { unlink(); }
|
||||
MapReference* next() { return (MapReference*)Reference<Map, Player>::next(); }
|
||||
MapReference const* next() const { return (MapReference const*)Reference<Map, Player>::next(); }
|
||||
MapReference* nockeck_prev() { return (MapReference*)Reference<Map, Player>::nocheck_prev(); }
|
||||
MapReference const* nocheck_prev() const { return (MapReference const*)Reference<Map, Player>::nocheck_prev(); }
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
@@ -10,79 +10,79 @@
|
||||
|
||||
class WDBThreadStartReq1 : public ACE_Method_Request
|
||||
{
|
||||
public:
|
||||
public:
|
||||
|
||||
WDBThreadStartReq1()
|
||||
{
|
||||
}
|
||||
WDBThreadStartReq1()
|
||||
{
|
||||
}
|
||||
|
||||
virtual int call()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
virtual int call()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
class WDBThreadEndReq1 : public ACE_Method_Request
|
||||
{
|
||||
public:
|
||||
public:
|
||||
|
||||
WDBThreadEndReq1()
|
||||
{
|
||||
}
|
||||
WDBThreadEndReq1()
|
||||
{
|
||||
}
|
||||
|
||||
virtual int call()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
virtual int call()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
class MapUpdateRequest : public ACE_Method_Request
|
||||
{
|
||||
private:
|
||||
private:
|
||||
|
||||
Map& m_map;
|
||||
MapUpdater& m_updater;
|
||||
uint32 m_diff;
|
||||
uint32 s_diff;
|
||||
Map& m_map;
|
||||
MapUpdater& m_updater;
|
||||
uint32 m_diff;
|
||||
uint32 s_diff;
|
||||
|
||||
public:
|
||||
public:
|
||||
|
||||
MapUpdateRequest(Map& m, MapUpdater& u, uint32 d, uint32 sd)
|
||||
: m_map(m), m_updater(u), m_diff(d), s_diff(sd)
|
||||
{
|
||||
}
|
||||
MapUpdateRequest(Map& m, MapUpdater& u, uint32 d, uint32 sd)
|
||||
: m_map(m), m_updater(u), m_diff(d), s_diff(sd)
|
||||
{
|
||||
}
|
||||
|
||||
virtual int call()
|
||||
{
|
||||
m_map.Update (m_diff, s_diff);
|
||||
m_updater.update_finished();
|
||||
return 0;
|
||||
}
|
||||
virtual int call()
|
||||
{
|
||||
m_map.Update (m_diff, s_diff);
|
||||
m_updater.update_finished();
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
class LFGUpdateRequest : public ACE_Method_Request
|
||||
{
|
||||
private:
|
||||
private:
|
||||
|
||||
MapUpdater& m_updater;
|
||||
uint32 m_diff;
|
||||
MapUpdater& m_updater;
|
||||
uint32 m_diff;
|
||||
|
||||
public:
|
||||
LFGUpdateRequest(MapUpdater& u, uint32 d) : m_updater(u), m_diff(d) {}
|
||||
public:
|
||||
LFGUpdateRequest(MapUpdater& u, uint32 d) : m_updater(u), m_diff(d) {}
|
||||
|
||||
virtual int call()
|
||||
{
|
||||
uint32 startTime = getMSTime();
|
||||
sLFGMgr->Update(m_diff, 1);
|
||||
uint32 totalTime = getMSTimeDiff(startTime, getMSTime());
|
||||
lfgDiffTracker.Update(totalTime);
|
||||
m_updater.update_finished();
|
||||
return 0;
|
||||
}
|
||||
virtual int call()
|
||||
{
|
||||
uint32 startTime = getMSTime();
|
||||
sLFGMgr->Update(m_diff, 1);
|
||||
uint32 totalTime = getMSTimeDiff(startTime, getMSTime());
|
||||
lfgDiffTracker.Update(totalTime);
|
||||
m_updater.update_finished();
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
MapUpdater::MapUpdater():
|
||||
m_executor(), m_mutex(), m_condition(m_mutex), pending_requests(0)
|
||||
m_executor(), m_mutex(), m_condition(m_mutex), pending_requests(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -11,33 +11,33 @@ class Map;
|
||||
|
||||
class MapUpdater
|
||||
{
|
||||
public:
|
||||
public:
|
||||
|
||||
MapUpdater();
|
||||
virtual ~MapUpdater();
|
||||
MapUpdater();
|
||||
virtual ~MapUpdater();
|
||||
|
||||
friend class MapUpdateRequest;
|
||||
friend class LFGUpdateRequest;
|
||||
friend class MapUpdateRequest;
|
||||
friend class LFGUpdateRequest;
|
||||
|
||||
int schedule_update(Map& map, uint32 diff, uint32 s_diff);
|
||||
int schedule_lfg_update(uint32 diff);
|
||||
int schedule_update(Map& map, uint32 diff, uint32 s_diff);
|
||||
int schedule_lfg_update(uint32 diff);
|
||||
|
||||
int wait();
|
||||
int wait();
|
||||
|
||||
int activate(size_t num_threads);
|
||||
int activate(size_t num_threads);
|
||||
|
||||
int deactivate();
|
||||
int deactivate();
|
||||
|
||||
bool activated();
|
||||
bool activated();
|
||||
|
||||
private:
|
||||
private:
|
||||
|
||||
DelayExecutor m_executor;
|
||||
ACE_Thread_Mutex m_mutex;
|
||||
ACE_Condition_Thread_Mutex m_condition;
|
||||
size_t pending_requests;
|
||||
DelayExecutor m_executor;
|
||||
ACE_Thread_Mutex m_mutex;
|
||||
ACE_Condition_Thread_Mutex m_condition;
|
||||
size_t pending_requests;
|
||||
|
||||
void update_finished();
|
||||
void update_finished();
|
||||
};
|
||||
|
||||
#endif //_MAP_UPDATER_H_INCLUDED
|
||||
|
||||
@@ -478,7 +478,7 @@ void TransportMgr::CreateInstanceTransports(Map* map)
|
||||
CreateTransport(*itr, 0, map);
|
||||
}
|
||||
|
||||
bool TransportAnimation::GetAnimNode(uint32 time, TransportAnimationEntry const* &curr, TransportAnimationEntry const* &next, float &percPos) const
|
||||
bool TransportAnimation::GetAnimNode(uint32 time, TransportAnimationEntry const*& curr, TransportAnimationEntry const*& next, float& percPos) const
|
||||
{
|
||||
if (Path.empty())
|
||||
return false;
|
||||
@@ -497,7 +497,7 @@ bool TransportAnimation::GetAnimNode(uint32 time, TransportAnimationEntry const*
|
||||
return false;
|
||||
}
|
||||
|
||||
void TransportAnimation::GetAnimRotation(uint32 time, G3D::Quat &curr, G3D::Quat &next, float &percRot) const
|
||||
void TransportAnimation::GetAnimRotation(uint32 time, G3D::Quat& curr, G3D::Quat& next, float& percRot) const
|
||||
{
|
||||
if (Rotations.empty())
|
||||
{
|
||||
|
||||
@@ -80,8 +80,8 @@ struct TransportAnimation
|
||||
TransportPathRotationContainer Rotations;
|
||||
uint32 TotalTime;
|
||||
|
||||
bool GetAnimNode(uint32 time, TransportAnimationEntry const* &curr, TransportAnimationEntry const* &next, float &percPos) const;
|
||||
void GetAnimRotation(uint32 time, G3D::Quat &curr, G3D::Quat &next, float &percRot) const;
|
||||
bool GetAnimNode(uint32 time, TransportAnimationEntry const*& curr, TransportAnimationEntry const*& next, float& percPos) const;
|
||||
void GetAnimRotation(uint32 time, G3D::Quat& curr, G3D::Quat& next, float& percRot) const;
|
||||
};
|
||||
|
||||
typedef std::map<uint32, TransportAnimation> TransportAnimationContainer;
|
||||
@@ -89,7 +89,7 @@ typedef std::map<uint32, TransportAnimation> TransportAnimationContainer;
|
||||
class TransportMgr
|
||||
{
|
||||
friend void LoadDBCStores(std::string const&);
|
||||
|
||||
|
||||
public:
|
||||
static TransportMgr* instance();
|
||||
|
||||
|
||||
@@ -14,30 +14,30 @@ class GameObject;
|
||||
|
||||
class ZoneScript
|
||||
{
|
||||
public:
|
||||
ZoneScript() {}
|
||||
virtual ~ZoneScript() {}
|
||||
public:
|
||||
ZoneScript() {}
|
||||
virtual ~ZoneScript() {}
|
||||
|
||||
virtual uint32 GetCreatureEntry(uint32 /*guidlow*/, CreatureData const* data) { return data->id; }
|
||||
virtual uint32 GetGameObjectEntry(uint32 /*guidlow*/, uint32 entry) { return entry; }
|
||||
virtual uint32 GetCreatureEntry(uint32 /*guidlow*/, CreatureData const* data) { return data->id; }
|
||||
virtual uint32 GetGameObjectEntry(uint32 /*guidlow*/, uint32 entry) { return entry; }
|
||||
|
||||
virtual void OnCreatureCreate(Creature *) { }
|
||||
virtual void OnCreatureRemove(Creature *) { }
|
||||
virtual void OnCreatureCreate(Creature*) { }
|
||||
virtual void OnCreatureRemove(Creature*) { }
|
||||
|
||||
virtual void OnGameObjectCreate(GameObject *) { }
|
||||
virtual void OnGameObjectRemove(GameObject *) { }
|
||||
virtual void OnGameObjectCreate(GameObject*) { }
|
||||
virtual void OnGameObjectRemove(GameObject*) { }
|
||||
|
||||
virtual void OnUnitDeath(Unit*) { }
|
||||
virtual void OnUnitDeath(Unit*) { }
|
||||
|
||||
//All-purpose data storage 64 bit
|
||||
virtual uint64 GetData64(uint32 /*DataId*/) const { return 0; }
|
||||
virtual void SetData64(uint32 /*DataId*/, uint64 /*Value*/) {}
|
||||
//All-purpose data storage 64 bit
|
||||
virtual uint64 GetData64(uint32 /*DataId*/) const { return 0; }
|
||||
virtual void SetData64(uint32 /*DataId*/, uint64 /*Value*/) {}
|
||||
|
||||
//All-purpose data storage 32 bit
|
||||
virtual uint32 GetData(uint32 /*DataId*/) const { return 0; }
|
||||
virtual void SetData(uint32 /*DataId*/, uint32 /*Value*/) {}
|
||||
//All-purpose data storage 32 bit
|
||||
virtual uint32 GetData(uint32 /*DataId*/) const { return 0; }
|
||||
virtual void SetData(uint32 /*DataId*/, uint32 /*Value*/) {}
|
||||
|
||||
virtual void ProcessEvent(WorldObject* /*obj*/, uint32 /*eventId*/) {}
|
||||
virtual void ProcessEvent(WorldObject* /*obj*/, uint32 /*eventId*/) {}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user