diff options
Diffstat (limited to 'src/server/game/Maps/Map.h')
| -rw-r--r-- | src/server/game/Maps/Map.h | 55 |
1 files changed, 37 insertions, 18 deletions
diff --git a/src/server/game/Maps/Map.h b/src/server/game/Maps/Map.h index c875e4eaa9..21226c54a9 100644 --- a/src/server/game/Maps/Map.h +++ b/src/server/game/Maps/Map.h @@ -1,14 +1,14 @@ /* * This file is part of the AzerothCore Project. See AUTHORS file for Copyright information * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU Affero General Public License as published by the - * Free Software Foundation; either version 3 of the License, or (at your - * option) any later version. + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * * You should have received a copy of the GNU General Public License along @@ -23,6 +23,7 @@ #include "DataMap.h" #include "Define.h" #include "DynamicTree.h" +#include "EventProcessor.h" #include "GameObjectModel.h" #include "GridDefines.h" #include "GridRefMgr.h" @@ -33,7 +34,6 @@ #include "PathGenerator.h" #include "Position.h" #include "SharedDefines.h" -#include "TaskScheduler.h" #include "Timer.h" #include "GridTerrainData.h" #include <bitset> @@ -47,6 +47,7 @@ class InstanceScript; class Group; class InstanceSave; class Object; +class Weather; class WorldObject; class TempSummon; class Player; @@ -62,6 +63,7 @@ class Transport; class StaticTransport; class MotionTransport; class PathGenerator; +class WorldSession; enum WeatherState : uint32; @@ -132,6 +134,7 @@ struct ZoneDynamicInfo ZoneDynamicInfo(); uint32 MusicId; + std::unique_ptr<Weather> DefaultWeather; WeatherState WeatherId; float WeatherGrade; uint32 OverrideLightId; @@ -169,7 +172,7 @@ public: // currently unused for normal maps bool CanUnload(uint32 diff) { - if (!m_unloadTimer) + if (!m_unloadTimer || Events.HasEvents()) return false; if (m_unloadTimer <= diff) @@ -240,8 +243,8 @@ public: [[nodiscard]] float GetMinHeight(float x, float y) const; Transport* GetTransportForPos(uint32 phase, float x, float y, float z, WorldObject* worldobject = nullptr); - void GetFullTerrainStatusForPosition(uint32 phaseMask, float x, float y, float z, float collisionHeight, PositionFullTerrainStatus& data, uint8 reqLiquidType = MAP_ALL_LIQUIDS); - LiquidData const GetLiquidData(uint32 phaseMask, float x, float y, float z, float collisionHeight, uint8 ReqLiquidType); + void GetFullTerrainStatusForPosition(uint32 phaseMask, float x, float y, float z, float collisionHeight, PositionFullTerrainStatus& data, Optional<uint8> reqLiquidType = {}); + LiquidData const GetLiquidData(uint32 phaseMask, float x, float y, float z, float collisionHeight, Optional<uint8> ReqLiquidType); [[nodiscard]] bool GetAreaInfo(uint32 phaseMask, float x, float y, float z, uint32& mogpflags, int32& adtId, int32& rootId, int32& groupId) const; [[nodiscard]] uint32 GetAreaId(uint32 phaseMask, float x, float y, float z) const; @@ -335,12 +338,12 @@ public: GameObject* SummonGameObject(uint32 entry, Position const& pos, float rotation0 = 0.0f, float rotation1 = 0.0f, float rotation2 = 0.0f, float rotation3 = 0.0f, uint32 respawnTime = 100, bool checkTransport = true); void SummonCreatureGroup(uint8 group, std::list<TempSummon*>* list = nullptr); - Corpse* GetCorpse(ObjectGuid const guid); - Creature* GetCreature(ObjectGuid const guid); - GameObject* GetGameObject(ObjectGuid const guid); - Transport* GetTransport(ObjectGuid const guid); - DynamicObject* GetDynamicObject(ObjectGuid const guid); - Pet* GetPet(ObjectGuid const guid); + Corpse* GetCorpse(ObjectGuid const& guid); + Creature* GetCreature(ObjectGuid const& guid); + GameObject* GetGameObject(ObjectGuid const& guid); + Transport* GetTransport(ObjectGuid const& guid); + DynamicObject* GetDynamicObject(ObjectGuid const& guid); + Pet* GetPet(ObjectGuid const& guid); MapStoredObjectTypesContainer& GetObjectsStore() { return _objectsStore; } @@ -427,7 +430,7 @@ public: void UpdatePlayerZoneStats(uint32 oldZone, uint32 newZone); [[nodiscard]] uint32 ApplyDynamicModeRespawnScaling(WorldObject const* obj, uint32 respawnDelay) const; - TaskScheduler _creatureRespawnScheduler; + EventProcessor Events; void ScheduleCreatureRespawn(ObjectGuid /*creatureGuid*/, Milliseconds /*respawnTimer*/, Position pos = Position()); @@ -435,20 +438,27 @@ public: void DeleteCorpseData(); void AddCorpse(Corpse* corpse); void RemoveCorpse(Corpse* corpse); - Corpse* ConvertCorpseToBones(ObjectGuid const ownerGuid, bool insignia = false); + Corpse* ConvertCorpseToBones(ObjectGuid const& ownerGuid, bool insignia = false); void RemoveOldCorpses(); static void DeleteRespawnTimesInDB(uint16 mapId, uint32 instanceId); + bool SendZoneMessage(uint32 zone, WorldPacket const* packet, WorldSession const* self = nullptr, TeamId teamId = TEAM_NEUTRAL) const; + void SendZoneText(uint32 zoneId, char const* text, WorldSession const* self = nullptr, TeamId teamId = TEAM_NEUTRAL) const; + void SendInitTransports(Player* player); void SendRemoveTransports(Player* player); - void SendZoneDynamicInfo(Player* player); + void SendZoneDynamicInfo(uint32 zoneId, Player* player) const; + void SendZoneWeather(uint32 zoneId, Player* player) const; + void SendZoneWeather(ZoneDynamicInfo const& zoneDynamicInfo, Player* player) const; void SendInitSelf(Player* player); + void UpdateWeather(uint32 const diff); void UpdateExpiredCorpses(uint32 const diff); void PlayDirectSoundToMap(uint32 soundId, uint32 zoneId = 0); void SetZoneMusic(uint32 zoneId, uint32 musicId); + Weather* GetOrGenerateZoneDefaultWeather(uint32 zoneId); void SetZoneWeather(uint32 zoneId, WeatherState weatherId, float weatherGrade); void SetZoneOverrideLight(uint32 zoneId, uint32 lightId, Milliseconds fadeInTime); @@ -504,6 +514,14 @@ public: void RemoveWorldObjectFromZoneWideVisibleMap(uint32 zoneId, WorldObject* obj); ZoneWideVisibleWorldObjectsSet const* GetZoneWideVisibleWorldObjectsForZone(uint32 zoneId) const; + [[nodiscard]] uint32 GetPlayerCountInZone(uint32 zoneId) const + { + if (auto const& it = _zonePlayerCountMap.find(zoneId); it != _zonePlayerCountMap.end()) + return it->second; + + return 0; + }; + private: template<class T> void InitializeObject(T* obj); @@ -584,6 +602,7 @@ private: std::unordered_map<uint32, uint32> _zonePlayerCountMap; ZoneDynamicInfoMap _zoneDynamicInfo; + IntervalTimer _weatherUpdateTimer; uint32 _defaultLight; IntervalTimer _corpseUpdateTimer; |
