chore(core): cleanup code p3 (#16073)

* Update MMapMgr.cpp

* Update UpdateFetcher.cpp

* Update AuctionHouseMgr.cpp

* Update AuctionHouseMgr.h

* Update BattlegroundAV.cpp

* Update ChannelMgr.cpp

* Update ThreatMgr.h

* Update Player.h

* Update PlayerSettings.cpp

* Update ObjectMgr.cpp

* Update Guild.cpp

* Update Guild.h

* Update Map.cpp

* Update World.cpp

* Update boss_nefarian.cpp

* Update boss_prince_malchezaar.cpp

* Update boss_venoxis.cpp

* Update zone_elwynn_forest.cpp

* Update zulfarrak.cpp

* Update boss_novos.cpp
This commit is contained in:
天鹿
2023-04-24 19:13:07 +08:00
committed by GitHub
parent 5dc6f9cf78
commit df77b5f4f7
20 changed files with 26 additions and 26 deletions

View File

@@ -253,7 +253,7 @@ namespace MMAP
// unload all tiles from given map // unload all tiles from given map
MMapData* mmap = itr->second; MMapData* mmap = itr->second;
for (auto i : mmap->loadedTileRefs) for (auto& i : mmap->loadedTileRefs)
{ {
uint32 x = (i.first >> 16); uint32 x = (i.first >> 16);
uint32 y = (i.first & 0x0000FFFF); uint32 y = (i.first & 0x0000FFFF);

View File

@@ -252,7 +252,7 @@ UpdateResult UpdateFetcher::Update(bool const redundancyChecks,
// Fill hash to name cache // Fill hash to name cache
HashToFileNameStorage hashToName; HashToFileNameStorage hashToName;
for (auto entry : applied) for (auto& entry : applied)
hashToName.insert(std::make_pair(entry.second.hash, entry.first)); hashToName.insert(std::make_pair(entry.second.hash, entry.first));
size_t importedUpdates = 0; size_t importedUpdates = 0;

View File

@@ -37,7 +37,7 @@ constexpr auto AH_MINIMUM_DEPOSIT = 100;
// Proof of concept, we should shift the info we're obtaining in here into AuctionEntry probably // Proof of concept, we should shift the info we're obtaining in here into AuctionEntry probably
static bool SortAuction(AuctionEntry* left, AuctionEntry* right, AuctionSortOrderVector& sortOrder, Player* player, bool checkMinBidBuyout) static bool SortAuction(AuctionEntry* left, AuctionEntry* right, AuctionSortOrderVector& sortOrder, Player* player, bool checkMinBidBuyout)
{ {
for (auto thisOrder : sortOrder) for (auto& thisOrder : sortOrder)
{ {
switch (thisOrder.sortOrder) switch (thisOrder.sortOrder)
{ {
@@ -908,7 +908,7 @@ bool AuctionHouseObject::BuildListAuctionItems(WorldPacket& data, Player* player
} }
} }
for (auto auction : auctionShortlist) for (auto& auction : auctionShortlist)
{ {
// Add the item if no search term or if entered search term was found // Add the item if no search term or if entered search term was found
if (count < 50 && totalcount >= listfrom) if (count < 50 && totalcount >= listfrom)

View File

@@ -133,7 +133,7 @@ public:
AuctionHouseObject() { _next = _auctionsMap.begin(); } AuctionHouseObject() { _next = _auctionsMap.begin(); }
~AuctionHouseObject() ~AuctionHouseObject()
{ {
for (auto & itr : _auctionsMap) for (auto& itr : _auctionsMap)
delete itr.second; delete itr.second;
} }

View File

@@ -1579,7 +1579,7 @@ void BattlegroundAV::ResetBGSubclass()
bool BattlegroundAV::IsBothMinesControlledByTeam(TeamId teamId) const bool BattlegroundAV::IsBothMinesControlledByTeam(TeamId teamId) const
{ {
for (auto mine : m_Mine_Owner) for (auto& mine : m_Mine_Owner)
if (mine != teamId) if (mine != teamId)
return false; return false;

View File

@@ -106,7 +106,7 @@ void ChannelMgr::LoadChannels()
++count; ++count;
} while (result->NextRow()); } while (result->NextRow());
for (auto pair : toDelete) for (auto& pair : toDelete)
{ {
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHANNEL); CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHANNEL);
stmt->SetData(0, pair.first); stmt->SetData(0, pair.first);

View File

@@ -259,7 +259,7 @@ public:
if (threatList.empty()) if (threatList.empty())
return; return;
for (auto ref : threatList) for (auto& ref : threatList)
{ {
if (predicate(ref->getTarget())) if (predicate(ref->getTarget()))
{ {

View File

@@ -1801,7 +1801,7 @@ public:
{ {
Unit::SetPvP(state); Unit::SetPvP(state);
if (!m_Controlled.empty()) if (!m_Controlled.empty())
for (auto itr : m_Controlled) for (auto& itr : m_Controlled)
itr->SetPvP(state); itr->SetPvP(state);
} }
void UpdatePvP(bool state, bool _override = false); void UpdatePvP(bool state, bool _override = false);

View File

@@ -48,7 +48,7 @@ void Player::_LoadCharacterSettings(PreparedQueryResult result)
uint32 count = 0; uint32 count = 0;
for (auto token : tokens) for (auto& token : tokens)
{ {
if (token.empty()) if (token.empty())
{ {
@@ -95,11 +95,11 @@ void Player::_SavePlayerSettings(CharacterDatabaseTransaction trans)
return; return;
} }
for (auto itr : m_charSettingsMap) for (auto& itr : m_charSettingsMap)
{ {
std::ostringstream data; std::ostringstream data;
for (auto setting : itr.second) for (auto& setting : itr.second)
{ {
data << setting.value << ' '; data << setting.value << ' ';
} }

View File

@@ -948,7 +948,7 @@ void ObjectMgr::LoadCreatureCustomIDs()
std::string stringCreatureIds = sConfigMgr->GetOption<std::string>("Creatures.CustomIDs", ""); std::string stringCreatureIds = sConfigMgr->GetOption<std::string>("Creatures.CustomIDs", "");
std::vector<std::string_view> CustomCreatures = Acore::Tokenize(stringCreatureIds, ',', false); std::vector<std::string_view> CustomCreatures = Acore::Tokenize(stringCreatureIds, ',', false);
for (auto itr : CustomCreatures) for (auto& itr : CustomCreatures)
{ {
_creatureCustomIDsStore.push_back(Acore::StringTo<uint32>(itr).value()); _creatureCustomIDsStore.push_back(Acore::StringTo<uint32>(itr).value());
} }
@@ -1296,7 +1296,7 @@ void ObjectMgr::CheckCreatureTemplate(CreatureTemplate const* cInfo)
const_cast<CreatureTemplate*>(cInfo)->DamageModifier *= Creature::_GetDamageMod(cInfo->rank); const_cast<CreatureTemplate*>(cInfo)->DamageModifier *= Creature::_GetDamageMod(cInfo->rank);
// Hack for modules // Hack for modules
for (auto itr : _creatureCustomIDsStore) for (auto& itr : _creatureCustomIDsStore)
{ {
if (cInfo->Entry == itr) if (cInfo->Entry == itr)
return; return;

View File

@@ -1388,7 +1388,7 @@ void Guild::HandleSetRankInfo(WorldSession* session, uint8 rankId, std::string_v
rankInfo->SetRights(rights); rankInfo->SetRights(rights);
_SetRankBankMoneyPerDay(rankId, moneyPerDay); _SetRankBankMoneyPerDay(rankId, moneyPerDay);
for (auto rightsAndSlot : rightsAndSlots) for (auto& rightsAndSlot : rightsAndSlots)
_SetRankBankTabRightsAndSlots(rankId, rightsAndSlot); _SetRankBankTabRightsAndSlots(rankId, rightsAndSlot);
_BroadcastEvent(GE_RANK_UPDATED, ObjectGuid::Empty, std::to_string(rankId), rankInfo->GetName(), std::to_string(m_ranks.size())); _BroadcastEvent(GE_RANK_UPDATED, ObjectGuid::Empty, std::to_string(rankId), rankInfo->GetName(), std::to_string(m_ranks.size()));
@@ -2382,7 +2382,7 @@ void Guild::_CreateNewBankTab()
trans->Append(stmt); trans->Append(stmt);
++tabId; ++tabId;
for (auto & m_rank : m_ranks) for (auto& m_rank : m_ranks)
m_rank.CreateMissingTabsIfNeeded(tabId, trans, false); m_rank.CreateMissingTabsIfNeeded(tabId, trans, false);
CharacterDatabase.CommitTransaction(trans); CharacterDatabase.CommitTransaction(trans);

View File

@@ -393,7 +393,7 @@ public: // pussywizard: public class Member
} }
inline Member* GetMember(std::string_view name) inline Member* GetMember(std::string_view name)
{ {
for (auto & m_member : m_members) for (auto& m_member : m_members)
if (m_member.second.GetName() == name) if (m_member.second.GetName() == name)
return &m_member.second; return &m_member.second;

View File

@@ -3820,7 +3820,7 @@ void Map::DoForAllPlayers(std::function<void(Player*)> exec)
bool Map::CanReachPositionAndGetValidCoords(WorldObject const* source, PathGenerator *path, float &destX, float &destY, float &destZ, bool failOnCollision, bool failOnSlopes) const bool Map::CanReachPositionAndGetValidCoords(WorldObject const* source, PathGenerator *path, float &destX, float &destY, float &destZ, bool failOnCollision, bool failOnSlopes) const
{ {
G3D::Vector3 prevPath = path->GetStartPosition(); G3D::Vector3 prevPath = path->GetStartPosition();
for (auto & vector : path->GetPath()) for (auto& vector : path->GetPath())
{ {
float x = vector.x; float x = vector.x;
float y = vector.y; float y = vector.y;

View File

@@ -1560,7 +1560,7 @@ void World::SetInitialWorldSettings()
sIPLocation->Load(); sIPLocation->Load();
std::vector<uint32> mapIds; std::vector<uint32> mapIds;
for (auto const map : sMapStore) for (auto const& map : sMapStore)
{ {
mapIds.emplace_back(map->MapID); mapIds.emplace_back(map->MapID);
} }

View File

@@ -1243,7 +1243,7 @@ class spell_shadowblink : public SpellScript
return; return;
} }
for (auto itr : spellPos) for (auto& itr : spellPos)
{ {
float distTarget = target->GetDistance2d(itr.second.m_positionX, itr.second.m_positionY); float distTarget = target->GetDistance2d(itr.second.m_positionX, itr.second.m_positionY);
if (distTarget <= 30.f) if (distTarget <= 30.f)

View File

@@ -248,7 +248,7 @@ struct boss_malchezaar : public BossAI
void EnfeebleResetHealth() void EnfeebleResetHealth()
{ {
for (auto targets : _enfeebleTargets) for (auto& targets : _enfeebleTargets)
{ {
if (Unit* target = ObjectAccessor::GetUnit(*me, targets.first)) if (Unit* target = ObjectAccessor::GetUnit(*me, targets.first))
{ {

View File

@@ -131,7 +131,7 @@ public:
if (!cobraList.empty()) if (!cobraList.empty())
{ {
for (auto cobras : cobraList) for (auto& cobras : cobraList)
{ {
cobras->SetInCombatWithZone(); cobras->SetInCombatWithZone();
} }

View File

@@ -101,7 +101,7 @@ struct npc_cameron : public ScriptedAI
Acore::Containers::RandomShuffle(MovePosPositions); Acore::Containers::RandomShuffle(MovePosPositions);
// first we break formation because children will need to move on their own now // first we break formation because children will need to move on their own now
for (auto guid : _childrenGUIDs) for (auto& guid : _childrenGUIDs)
if (Creature* child = ObjectAccessor::GetCreature(*me, guid)) if (Creature* child = ObjectAccessor::GetCreature(*me, guid))
if (child->GetFormation()) if (child->GetFormation())
child->GetFormation()->RemoveMember(child); child->GetFormation()->RemoveMember(child);
@@ -228,7 +228,7 @@ struct npc_cameron : public ScriptedAI
// If Formation was disbanded, remake. // If Formation was disbanded, remake.
if (!me->GetFormation()->IsFormed()) if (!me->GetFormation()->IsFormed())
for (auto guid : _childrenGUIDs) for (auto& guid : _childrenGUIDs)
if (Creature* child = ObjectAccessor::GetCreature(*me, guid)) if (Creature* child = ObjectAccessor::GetCreature(*me, guid))
child->SearchFormation(); child->SearchFormation();

View File

@@ -573,7 +573,7 @@ public:
if (_summonAddsTimer <= diff) if (_summonAddsTimer <= diff)
{ {
for (auto itr : shadowpriestSezzizAdds[_summmonAddsCount]) for (auto& itr : shadowpriestSezzizAdds[_summmonAddsCount])
{ {
if (Creature* add = me->SummonCreature(itr.first, itr.second, TEMPSUMMON_DEAD_DESPAWN, 10 * IN_MILLISECONDS)) if (Creature* add = me->SummonCreature(itr.first, itr.second, TEMPSUMMON_DEAD_DESPAWN, 10 * IN_MILLISECONDS))
{ {

View File

@@ -132,7 +132,7 @@ public:
me->CastSpell(me, SPELL_ARCANE_FIELD, true); me->CastSpell(me, SPELL_ARCANE_FIELD, true);
me->CastSpell(me, SPELL_DESPAWN_CRYSTAL_HANDLER, true); me->CastSpell(me, SPELL_DESPAWN_CRYSTAL_HANDLER, true);
for (auto itr : npcSummon) for (auto& itr : npcSummon)
{ {
uint32 summonEntry; uint32 summonEntry;
Position summonPos; Position summonPos;