aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Maps/Map.cpp
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2023-01-06 16:54:16 +0100
committerShauren <shauren.trinity@gmail.com>2023-01-06 16:54:16 +0100
commite8e330addd55dffa8e34716c7e1969ad243d65b3 (patch)
tree2e5cd08a6d1758d9867cc5c4b8aca4591d0e931d /src/server/game/Maps/Map.cpp
parentb65c3f5f4a4edbc953c405bfacd33f186f3a1931 (diff)
Core/Misc: Remove boost::heap::fibonacci_heap from header files
Diffstat (limited to 'src/server/game/Maps/Map.cpp')
-rw-r--r--src/server/game/Maps/Map.cpp38
1 files changed, 25 insertions, 13 deletions
diff --git a/src/server/game/Maps/Map.cpp b/src/server/game/Maps/Map.cpp
index 31c5193e7d8..fdec078db36 100644
--- a/src/server/game/Maps/Map.cpp
+++ b/src/server/game/Maps/Map.cpp
@@ -62,6 +62,7 @@
#include "WorldSession.h"
#include "WorldStateMgr.h"
#include "WorldStatePackets.h"
+#include <boost/heap/fibonacci_heap.hpp>
#include <sstream>
#include "Hacks/boost_1_74_fibonacci_heap.h"
@@ -76,6 +77,17 @@ 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>>
+{
+};
+struct RespawnInfoWithHandle : RespawnInfo
+{
+ explicit RespawnInfoWithHandle(RespawnInfo const& other) : RespawnInfo(other) { }
+
+ RespawnListContainer::handle_type handle;
+};
+
Map::~Map()
{
// UnloadAll must be called before deleting the map
@@ -134,7 +146,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), m_terrain(sTerrainMgr.LoadTerrain(id)),
-i_scriptLock(false), _respawnCheckTimer(0)
+i_scriptLock(false), _respawnTimes(std::make_unique<RespawnListContainer>()), _respawnCheckTimer(0)
{
for (uint32 x = 0; x < MAX_NUMBER_OF_GRIDS; ++x)
{
@@ -2011,7 +2023,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);
}
@@ -2067,8 +2079,8 @@ bool Map::AddRespawnInfo(RespawnInfo const& info)
else
ABORT_MSG("Invalid respawn info for spawn id (%u," UI64FMTD ") 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;
}
@@ -2101,9 +2113,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();
}
@@ -2124,7 +2136,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);
@@ -2175,16 +2187,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();
ASSERT_NOTNULL(GetRespawnMapForType(next->type))->erase(next->spawnId);
// step 2: tell pooling logic to do its thing
@@ -2197,7 +2209,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();
ASSERT_NOTNULL(GetRespawnMapForType(next->type))->erase(next->spawnId);
// step 2: do the respawn, which involves external logic
@@ -2209,7 +2221,7 @@ void Map::ProcessRespawns()
}
else if (!next->respawnTime)
{ // just remove this respawn entry without rescheduling
- _respawnTimes.pop();
+ _respawnTimes->pop();
ASSERT_NOTNULL(GetRespawnMapForType(next->type))->erase(next->spawnId);
RemoveRespawnTime(next->type, next->spawnId, nullptr, true);
delete next;
@@ -2217,7 +2229,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);
}
}