diff options
| author | Shauren <shauren.trinity@gmail.com> | 2023-01-06 16:54:16 +0100 |
|---|---|---|
| committer | Shauren <shauren.trinity@gmail.com> | 2023-08-12 17:56:15 +0200 |
| commit | cccc062ea002ee63e0288d5a71356f45f7094287 (patch) | |
| tree | 4e4700e5a2b705844442bf920e0c8d65ac95111d /src/server/game/Maps | |
| parent | f5a2e2ae13e3f7b505b069c1cd98e3157c31c83a (diff) | |
Core/Misc: Remove boost::heap::fibonacci_heap from header files
(cherry picked from commit e8e330addd55dffa8e34716c7e1969ad243d65b3)
Diffstat (limited to 'src/server/game/Maps')
| -rw-r--r-- | src/server/game/Maps/Map.cpp | 42 | ||||
| -rw-r--r-- | src/server/game/Maps/Map.h | 7 |
2 files changed, 30 insertions, 19 deletions
diff --git a/src/server/game/Maps/Map.cpp b/src/server/game/Maps/Map.cpp index a206b6529d0..cf358105825 100644 --- a/src/server/game/Maps/Map.cpp +++ b/src/server/game/Maps/Map.cpp @@ -48,11 +48,11 @@ #include "Weather.h" #include "WeatherMgr.h" #include "World.h" +#include <boost/heap/fibonacci_heap.hpp> #include <unordered_set> #include <vector> #include "Hacks/boost_1_74_fibonacci_heap.h" -BOOST_1_74_FIBONACCI_HEAP_MSVC_COMPILE_FIX(RespawnListContainer::value_type) u_map_magic MapMagic = { {'M','A','P','S'} }; uint32 MapVersionMagic = 10; @@ -72,6 +72,20 @@ GridState* si_GridStates[MAX_GRID_STATE]; ZoneDynamicInfo::ZoneDynamicInfo() : MusicId(0), DefaultWeather(nullptr), WeatherId(WEATHER_STATE_FINE), Intensity(0.0f) { } +struct RespawnInfoWithHandle; +struct RespawnListContainer : boost::heap::fibonacci_heap<RespawnInfoWithHandle*, boost::heap::compare<CompareRespawnInfo>> +{ +}; + +BOOST_1_74_FIBONACCI_HEAP_MSVC_COMPILE_FIX(RespawnListContainer::value_type) + +struct RespawnInfoWithHandle : RespawnInfo +{ + explicit RespawnInfoWithHandle(RespawnInfo const& other) : RespawnInfo(other) { } + + RespawnListContainer::handle_type handle; +}; + Map::~Map() { // UnloadAll must be called before deleting the map @@ -274,7 +288,7 @@ m_unloadTimer(0), m_VisibleDistance(DEFAULT_VISIBILITY_DISTANCE), m_VisibilityNotifyPeriod(DEFAULT_VISIBILITY_NOTIFY_PERIOD), m_activeNonPlayersIter(m_activeNonPlayers.end()), _transportsUpdateIter(_transports.end()), i_gridExpiry(expiry), -i_scriptLock(false), _respawnCheckTimer(0) +i_scriptLock(false), _respawnTimes(std::make_unique<RespawnListContainer>()), _respawnCheckTimer(0) { m_parentMap = (_parent ? _parent : this); for (unsigned int idx=0; idx < MAX_NUMBER_OF_GRIDS; ++idx) @@ -3109,7 +3123,7 @@ void Map::Respawn(RespawnInfo* info, CharacterDatabaseTransaction dbTrans) if (info->respawnTime <= GameTime::GetGameTime()) return; info->respawnTime = GameTime::GetGameTime(); - _respawnTimes.increase(info->handle); + _respawnTimes->increase(static_cast<RespawnInfoWithHandle*>(info)->handle); SaveRespawnInfoDB(*info, dbTrans); } @@ -3163,8 +3177,8 @@ bool Map::AddRespawnInfo(RespawnInfo const& info) else ABORT_MSG("Invalid respawn info for spawn id (%u,%u) being inserted", uint32(info.type), info.spawnId); - RespawnInfo * ri = new RespawnInfo(info); - ri->handle = _respawnTimes.push(ri); + RespawnInfoWithHandle* ri = new RespawnInfoWithHandle(info); + ri->handle = _respawnTimes->push(ri); bySpawnIdMap.emplace(ri->spawnId, ri); return true; } @@ -3195,9 +3209,9 @@ RespawnInfo* Map::GetRespawnInfo(SpawnObjectType type, ObjectGuid::LowType spawn void Map::UnloadAllRespawnInfos() // delete everything from memory { - for (RespawnInfo* info : _respawnTimes) + for (RespawnInfo* info : *_respawnTimes) delete info; - _respawnTimes.clear(); + _respawnTimes->clear(); _creatureRespawnTimesBySpawnId.clear(); _gameObjectRespawnTimesBySpawnId.clear(); } @@ -3215,7 +3229,7 @@ void Map::DeleteRespawnInfo(RespawnInfo* info, CharacterDatabaseTransaction dbTr spawnMap.erase(it); // respawn heap - _respawnTimes.erase(info->handle); + _respawnTimes->erase(static_cast<RespawnInfoWithHandle*>(info)->handle); // database DeleteRespawnInfoFromDB(info->type, info->spawnId, dbTrans); @@ -3263,16 +3277,16 @@ void Map::DoRespawn(SpawnObjectType type, ObjectGuid::LowType spawnId, uint32 gr void Map::ProcessRespawns() { time_t now = GameTime::GetGameTime(); - while (!_respawnTimes.empty()) + while (!_respawnTimes->empty()) { - RespawnInfo* next = _respawnTimes.top(); + RespawnInfoWithHandle* next = _respawnTimes->top(); if (now < next->respawnTime) // done for this tick break; if (uint32 poolId = sPoolMgr->IsPartOfAPool(next->type, next->spawnId)) // is this part of a pool? { // if yes, respawn will be handled by (external) pooling logic, just delete the respawn time // step 1: remove entry from maps to avoid it being reachable by outside logic - _respawnTimes.pop(); + _respawnTimes->pop(); GetRespawnMapForType(next->type).erase(next->spawnId); // step 2: tell pooling logic to do its thing @@ -3285,7 +3299,7 @@ void Map::ProcessRespawns() else if (CheckRespawn(next)) // see if we're allowed to respawn { // ok, respawn // step 1: remove entry from maps to avoid it being reachable by outside logic - _respawnTimes.pop(); + _respawnTimes->pop(); GetRespawnMapForType(next->type).erase(next->spawnId); // step 2: do the respawn, which involves external logic @@ -3297,7 +3311,7 @@ void Map::ProcessRespawns() } else if (!next->respawnTime) { // just remove this respawn entry without rescheduling - _respawnTimes.pop(); + _respawnTimes->pop(); GetRespawnMapForType(next->type).erase(next->spawnId); RemoveRespawnTime(next->type, next->spawnId, nullptr, true); delete next; @@ -3305,7 +3319,7 @@ void Map::ProcessRespawns() else { // new respawn time, update heap position ASSERT(now < next->respawnTime); // infinite loop guard - _respawnTimes.decrease(next->handle); + _respawnTimes->decrease(next->handle); SaveRespawnInfoDB(*next); } } diff --git a/src/server/game/Maps/Map.h b/src/server/game/Maps/Map.h index 66c8e0c9059..bf013d0d6ad 100644 --- a/src/server/game/Maps/Map.h +++ b/src/server/game/Maps/Map.h @@ -32,7 +32,6 @@ #include "SpawnData.h" #include "Timer.h" #include "Transaction.h" -#include <boost/heap/fibonacci_heap.hpp> #include <bitset> #include <list> #include <memory> @@ -293,8 +292,7 @@ struct CompareRespawnInfo bool operator()(RespawnInfo const* a, RespawnInfo const* b) const; }; using ZoneDynamicInfoMap = std::unordered_map<uint32 /*zoneId*/, ZoneDynamicInfo>; -using RespawnListContainer = boost::heap::fibonacci_heap<RespawnInfo*, boost::heap::compare<CompareRespawnInfo>>; -using RespawnListHandle = RespawnListContainer::handle_type; +struct RespawnListContainer; using RespawnInfoMap = std::unordered_map<ObjectGuid::LowType, RespawnInfo*>; struct RespawnInfo { @@ -303,7 +301,6 @@ struct RespawnInfo uint32 entry; time_t respawnTime; uint32 gridId; - RespawnListHandle handle; }; inline bool CompareRespawnInfo::operator()(RespawnInfo const* a, RespawnInfo const* b) const { @@ -845,7 +842,7 @@ class TC_GAME_API Map : public GridRefManager<NGridType> m_activeNonPlayers.erase(obj); } - RespawnListContainer _respawnTimes; + std::unique_ptr<RespawnListContainer> _respawnTimes; RespawnInfoMap _creatureRespawnTimesBySpawnId; RespawnInfoMap _gameObjectRespawnTimesBySpawnId; RespawnInfoMap& GetRespawnMapForType(SpawnObjectType type) |
