Core/Misc: Simplify LinkedListHead::isEmpty and rename to empty to fit standard container naming

This commit is contained in:
Shauren
2025-07-11 17:47:14 +02:00
parent cbb532e4be
commit fbbcc31670
17 changed files with 34 additions and 38 deletions

View File

@@ -712,11 +712,7 @@ void Transport::UpdatePassengerPositions(PassengerSet const& passengers)
void Transport::BuildUpdate(UpdateDataMapType& data_map)
{
Map::PlayerList const& players = GetMap()->GetPlayers();
if (players.isEmpty())
return;
for (MapReference const& playerReference : players)
for (MapReference const& playerReference : GetMap()->GetPlayers())
if (playerReference.GetSource()->InSamePhase(this))
BuildFieldsUpdate(playerReference.GetSource(), data_map);

View File

@@ -232,7 +232,7 @@ void PersonalPhaseGridLoader::Load(uint32 phaseId)
template<class T>
void ObjectGridUnloader::Visit(GridRefManager<T> &m)
{
while (!m.isEmpty())
while (!m.empty())
{
T *obj = m.getFirst()->GetSource();
//Some creatures may summon other temp summons in CleanupsBeforeDelete()

View File

@@ -811,7 +811,7 @@ void Map::Update(uint32 t_diff)
MoveAllGameObjectsInMoveList();
MoveAllAreaTriggersInMoveList();
if (!m_mapRefManager.isEmpty() || !m_activeNonPlayers.empty())
if (!m_mapRefManager.empty() || !m_activeNonPlayers.empty())
ProcessRelocationNotifies(t_diff);
sScriptMgr->OnMapUpdate(this, t_diff);
@@ -3946,7 +3946,7 @@ void Map::SetZoneMusic(uint32 zoneId, uint32 musicId)
_zoneDynamicInfo[zoneId].MusicId = musicId;
Map::PlayerList const& players = GetPlayers();
if (!players.isEmpty())
if (!players.empty())
{
WorldPackets::Misc::PlayMusic playMusic(musicId);
playMusic.Write();
@@ -3997,7 +3997,7 @@ void Map::SetZoneWeather(uint32 zoneId, WeatherState weatherId, float intensity)
info.Intensity = intensity;
Map::PlayerList const& players = GetPlayers();
if (!players.isEmpty())
if (!players.empty())
{
WorldPackets::Misc::Weather weather(weatherId, intensity);
weather.Write();
@@ -4028,7 +4028,7 @@ void Map::SetZoneOverrideLight(uint32 zoneId, uint32 areaLightId, uint32 overrid
}
Map::PlayerList const& players = GetPlayers();
if (!players.isEmpty())
if (!players.empty())
{
WorldPackets::Misc::OverrideLight overrideLight;
overrideLight.AreaLightID = areaLightId;

View File

@@ -388,7 +388,7 @@ class TC_GAME_API Map : public GridRefManager<NGridType>
bool isCellMarked(uint32 pCellId) { return marked_cells.test(pCellId); }
void markCell(uint32 pCellId) { marked_cells.set(pCellId); }
bool HavePlayers() const { return !m_mapRefManager.isEmpty(); }
bool HavePlayers() const { return !m_mapRefManager.empty(); }
uint32 GetPlayersCountExceptGMs() const;
bool ActiveObjectsNearGrid(NGridType const& ngrid) const;

View File

@@ -207,7 +207,7 @@ struct boss_coren_direbrew : public BossAI
_JustDied();
Map::PlayerList const& players = me->GetMap()->GetPlayers();
if (!players.isEmpty())
if (!players.empty())
{
if (Group* group = players.begin()->GetSource()->GetGroup())
if (group->isLFGGroup())

View File

@@ -310,7 +310,7 @@ public:
if (WipeTimer <= diff)
{
Map::PlayerList const& PlayerList = me->GetMap()->GetPlayers();
if (PlayerList.isEmpty())
if (PlayerList.empty())
return;
RaidWiped = true;

View File

@@ -1263,7 +1263,7 @@ public:
{
// search players with in 50 yards for quest credit
Map::PlayerList const& PlayerList = me->GetMap()->GetPlayers();
if (!PlayerList.isEmpty())
if (!PlayerList.empty())
{
for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
if (me->IsWithinDistInMap(i->GetSource(), 500))

View File

@@ -174,7 +174,7 @@ struct boss_apothecary_hummel : public BossAI
instance->SetBossState(BOSS_APOTHECARY_HUMMEL, DONE);
Map::PlayerList const& players = me->GetMap()->GetPlayers();
if (!players.isEmpty())
if (!players.empty())
{
if (Group* group = players.begin()->GetSource()->GetGroup())
if (group->isLFGGroup())

View File

@@ -97,7 +97,7 @@ class instance_sunwell_plateau : public InstanceMapScript
{
Map::PlayerList const& players = instance->GetPlayers();
if (!players.isEmpty())
if (!players.empty())
{
for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
{

View File

@@ -125,7 +125,7 @@ public:
//what other conditions to check?
bool CanProgressEvent()
{
if (instance->GetPlayers().isEmpty())
if (instance->GetPlayers().empty())
return false;
return true;
@@ -188,7 +188,7 @@ public:
TC_LOG_DEBUG("scripts", "Instance The Black Morass: Event completed.");
Map::PlayerList const& players = instance->GetPlayers();
if (!players.isEmpty())
if (!players.empty())
{
for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
{

View File

@@ -98,7 +98,7 @@ void AggroAllPlayers(Creature* temp)
{
Map::PlayerList const& PlList = temp->GetMap()->GetPlayers();
if (PlList.isEmpty())
if (PlList.empty())
return;
for (Map::PlayerList::const_iterator i = PlList.begin(); i != PlList.end(); ++i)
@@ -254,7 +254,7 @@ public:
if (uiChargeTimer <= uiDiff)
{
Map::PlayerList const& players = me->GetMap()->GetPlayers();
if (!players.isEmpty())
if (!players.empty())
{
for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
{
@@ -281,7 +281,7 @@ public:
if (Unit* pPassenger = pVehicle->GetPassenger(SEAT_ID_0))
{
Map::PlayerList const& players = me->GetMap()->GetPlayers();
if (!players.isEmpty())
if (!players.empty())
{
for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
{
@@ -399,7 +399,7 @@ public:
if (uiInterceptTimer <= uiDiff)
{
Map::PlayerList const& players = me->GetMap()->GetPlayers();
if (!players.isEmpty())
if (!players.empty())
{
for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
{
@@ -863,7 +863,7 @@ public:
else
{
Map::PlayerList const& players = me->GetMap()->GetPlayers();
if (!players.isEmpty())
if (!players.empty())
{
for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
{

View File

@@ -374,7 +374,7 @@ public:
void AggroAllPlayers(Creature* temp)
{
Map::PlayerList const& PlList = me->GetMap()->GetPlayers();
if (PlList.isEmpty())
if (PlList.empty())
return;
for (Map::PlayerList::const_iterator i = PlList.begin(); i != PlList.end(); ++i)

View File

@@ -216,7 +216,7 @@ struct boss_four_horsemen_baseAI : public BossAI
}
instance->SetBossState(BOSS_HORSEMEN, IN_PROGRESS);
Map::PlayerList const& players = me->GetMap()->GetPlayers();
if (players.isEmpty()) // sanity check
if (players.empty()) // sanity check
ResetEncounter();
for (Horseman boss : horsemen)

View File

@@ -249,7 +249,7 @@ struct boss_the_lurker_below : public BossAI
{
InRange = false;
Map::PlayerList const& PlayerList = me->GetMap()->GetPlayers();
if (!PlayerList.isEmpty())
if (!PlayerList.empty())
{
for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
{

View File

@@ -133,7 +133,7 @@ class instance_serpent_shrine : public InstanceMapScript
Water = WATERSTATE_FRENZY;
Map::PlayerList const& PlayerList = instance->GetPlayers();
if (PlayerList.isEmpty())
if (PlayerList.empty())
return;
for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
{

View File

@@ -203,7 +203,7 @@ struct boss_ahune : public BossAI
Unit::Kill(me, frozenCore);
Map::PlayerList const& players = me->GetMap()->GetPlayers();
if (!players.isEmpty())
if (!players.empty())
{
if (Group* group = players.begin()->GetSource()->GetGroup())
if (group->isLFGGroup())

View File

@@ -83,7 +83,7 @@ class LinkedListElement
LinkedListElement& operator=(LinkedListElement&&) = delete;
protected:
virtual ~LinkedListElement()
~LinkedListElement()
{
delink();
}
@@ -107,13 +107,13 @@ class LinkedListHead
iLast.iPrev = &iFirst;
}
bool isEmpty() const { return(!iFirst.iNext->isInList()); }
bool empty() const { return iFirst.iNext == &iLast; }
LinkedListElement * getFirst() { return (isEmpty() ? nullptr : iFirst.iNext); }
LinkedListElement const* getFirst() const { return (isEmpty() ? nullptr : iFirst.iNext); }
LinkedListElement * getFirst() { return (empty() ? nullptr : iFirst.iNext); }
LinkedListElement const* getFirst() const { return (empty() ? nullptr : iFirst.iNext); }
LinkedListElement * getLast() { return(isEmpty() ? nullptr : iLast.iPrev); }
LinkedListElement const* getLast() const { return(isEmpty() ? nullptr : iLast.iPrev); }
LinkedListElement * getLast() { return (empty() ? nullptr : iLast.iPrev); }
LinkedListElement const* getLast() const { return (empty() ? nullptr : iLast.iPrev); }
void insertFirst(LinkedListElement* pElem)
{
@@ -166,18 +166,18 @@ class LinkedListHead
{ // construct with node pointer _Pnode
}
Iterator& operator=(const_pointer const& _Right)
Iterator& operator=(const_pointer _Right)
{
_Ptr = pointer(_Right);
_Ptr = const_cast<pointer>(_Right);
return *this;
}
reference operator*()
reference operator*() const
{ // return designated value
return *_Ptr;
}
pointer operator->()
pointer operator->() const
{ // return pointer to class object
return _Ptr;
}