Skip to content

Commit b13fd96

Browse files
committed
refactor: Use DoForAllPlayers() when awarding points
1 parent 13c7ceb commit b13fd96

File tree

1 file changed

+4
-17
lines changed

1 file changed

+4
-17
lines changed

src/mod_zone_difficulty_handler.cpp

+4-17
Original file line numberDiff line numberDiff line change
@@ -554,33 +554,20 @@ void ZoneDifficulty::AddMythicmodeScore(Map* map, uint32 type, uint32 score)
554554
LOG_ERROR("module", "MOD-ZONE-DIFFICULTY: Wrong value for type: {} in AddMythicmodeScore for map with id {}.", type, map->GetInstanceId());
555555
return;
556556
}
557-
//LOG_INFO("module", "MOD-ZONE-DIFFICULTY: Called AddMythicmodeScore for map id: {} and type: {}", map->GetId(), type);
558-
Map::PlayerList const& PlayerList = map->GetPlayers();
559-
for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
557+
558+
map->DoForAllPlayers([&](Player* player)
560559
{
561-
Player* player = i->GetSource();
562560
if (sZoneDifficulty->MythicmodeScore.find(player->GetGUID().GetCounter()) == sZoneDifficulty->MythicmodeScore.end())
563-
{
564561
sZoneDifficulty->MythicmodeScore[player->GetGUID().GetCounter()][type] = score;
565-
}
566562
else if (sZoneDifficulty->MythicmodeScore[player->GetGUID().GetCounter()].find(type) == sZoneDifficulty->MythicmodeScore[player->GetGUID().GetCounter()].end())
567-
{
568563
sZoneDifficulty->MythicmodeScore[player->GetGUID().GetCounter()][type] = score;
569-
}
570564
else
571-
{
572565
sZoneDifficulty->MythicmodeScore[player->GetGUID().GetCounter()][type] = sZoneDifficulty->MythicmodeScore[player->GetGUID().GetCounter()][type] + score;
573-
}
574-
575-
//if (sZoneDifficulty->IsDebugInfoEnabled)
576-
//{
577-
// LOG_INFO("module", "MOD-ZONE-DIFFICULTY: Player {} new score: {}", player->GetName(), sZoneDifficulty->MythicmodeScore[player->GetGUID().GetCounter()][type]);
578-
//}
579566

580567
std::string typestring = sZoneDifficulty->GetContentTypeString(type);
581568
ChatHandler(player->GetSession()).PSendSysMessage("You have received Mythicmode score {} New score: {}", typestring, sZoneDifficulty->MythicmodeScore[player->GetGUID().GetCounter()][type]);
582569
CharacterDatabase.Execute("REPLACE INTO zone_difficulty_mythicmode_score VALUES({}, {}, {})", player->GetGUID().GetCounter(), type, sZoneDifficulty->MythicmodeScore[player->GetGUID().GetCounter()][type]);
583-
}
570+
});
584571
}
585572

586573
/**
@@ -780,7 +767,7 @@ bool ZoneDifficulty::ShouldNerfInDuels(Unit* target)
780767
int32 ZoneDifficulty::GetLowestMatchingPhase(uint32 mapId, uint32 phaseMask)
781768
{
782769
// Check if there is an entry for the mapId at all
783-
if (sZoneDifficulty->NerfInfo.find(mapId) != sZoneDifficulty->NerfInfo.end())
770+
if (sZoneDifficulty->ShouldNerfMap(mapId))
784771
{
785772

786773
// Check if 0 is assigned as a phase to cover all phases

0 commit comments

Comments
 (0)