refactor(Core/Instance): Modernize a few player iterations (#17717)
This commit is contained in:
@@ -591,81 +591,66 @@ void InstanceScript::DoUpdateWorldState(uint32 uiStateId, uint32 uiStateData)
|
|||||||
// Send Notify to all players in instance
|
// Send Notify to all players in instance
|
||||||
void InstanceScript::DoSendNotifyToInstance(char const* format, ...)
|
void InstanceScript::DoSendNotifyToInstance(char const* format, ...)
|
||||||
{
|
{
|
||||||
InstanceMap::PlayerList const& players = instance->GetPlayers();
|
if (!instance->GetPlayers().IsEmpty())
|
||||||
|
|
||||||
if (!players.IsEmpty())
|
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, format);
|
va_start(ap, format);
|
||||||
char buff[1024];
|
char buff[1024];
|
||||||
vsnprintf(buff, 1024, format, ap);
|
vsnprintf(buff, 1024, format, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
for (Map::PlayerList::const_iterator i = players.begin(); i != players.end(); ++i)
|
|
||||||
if (Player* player = i->GetSource())
|
instance->DoForAllPlayers([&, buff](Player* player)
|
||||||
player->GetSession()->SendNotification("%s", buff);
|
{
|
||||||
|
player->GetSession()->SendNotification("%s", buff);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update Achievement Criteria for all players in instance
|
// Update Achievement Criteria for all players in instance
|
||||||
void InstanceScript::DoUpdateAchievementCriteria(AchievementCriteriaTypes type, uint32 miscValue1 /*= 0*/, uint32 miscValue2 /*= 0*/, Unit* unit /*= nullptr*/)
|
void InstanceScript::DoUpdateAchievementCriteria(AchievementCriteriaTypes type, uint32 miscValue1 /*= 0*/, uint32 miscValue2 /*= 0*/, Unit* unit /*= nullptr*/)
|
||||||
{
|
{
|
||||||
Map::PlayerList const& PlayerList = instance->GetPlayers();
|
instance->DoForAllPlayers([&](Player* player)
|
||||||
|
{
|
||||||
if (!PlayerList.IsEmpty())
|
player->UpdateAchievementCriteria(type, miscValue1, miscValue2, unit);
|
||||||
for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
|
});
|
||||||
if (Player* player = i->GetSource())
|
|
||||||
player->UpdateAchievementCriteria(type, miscValue1, miscValue2, unit);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start timed achievement for all players in instance
|
// Start timed achievement for all players in instance
|
||||||
void InstanceScript::DoStartTimedAchievement(AchievementCriteriaTimedTypes type, uint32 entry)
|
void InstanceScript::DoStartTimedAchievement(AchievementCriteriaTimedTypes type, uint32 entry)
|
||||||
{
|
{
|
||||||
Map::PlayerList const& PlayerList = instance->GetPlayers();
|
instance->DoForAllPlayers([&](Player* player)
|
||||||
|
{
|
||||||
if (!PlayerList.IsEmpty())
|
player->StartTimedAchievement(type, entry);
|
||||||
for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
|
});
|
||||||
if (Player* player = i->GetSource())
|
|
||||||
player->StartTimedAchievement(type, entry);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Stop timed achievement for all players in instance
|
// Stop timed achievement for all players in instance
|
||||||
void InstanceScript::DoStopTimedAchievement(AchievementCriteriaTimedTypes type, uint32 entry)
|
void InstanceScript::DoStopTimedAchievement(AchievementCriteriaTimedTypes type, uint32 entry)
|
||||||
{
|
{
|
||||||
Map::PlayerList const& PlayerList = instance->GetPlayers();
|
instance->DoForAllPlayers([&](Player* player)
|
||||||
|
{
|
||||||
if (!PlayerList.IsEmpty())
|
player->RemoveTimedAchievement(type, entry);
|
||||||
for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
|
});
|
||||||
if (Player* player = i->GetSource())
|
|
||||||
player->RemoveTimedAchievement(type, entry);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove Auras due to Spell on all players in instance
|
// Remove Auras due to Spell on all players in instance
|
||||||
void InstanceScript::DoRemoveAurasDueToSpellOnPlayers(uint32 spell)
|
void InstanceScript::DoRemoveAurasDueToSpellOnPlayers(uint32 spell)
|
||||||
{
|
{
|
||||||
Map::PlayerList const& PlayerList = instance->GetPlayers();
|
instance->DoForAllPlayers([&](Player* player)
|
||||||
if (!PlayerList.IsEmpty())
|
|
||||||
{
|
{
|
||||||
for (Map::PlayerList::const_iterator itr = PlayerList.begin(); itr != PlayerList.end(); ++itr)
|
player->RemoveAurasDueToSpell(spell);
|
||||||
{
|
if (Pet* pet = player->GetPet())
|
||||||
if (Player* player = itr->GetSource())
|
pet->RemoveAurasDueToSpell(spell);
|
||||||
{
|
});
|
||||||
player->RemoveAurasDueToSpell(spell);
|
|
||||||
if (Pet* pet = player->GetPet())
|
|
||||||
pet->RemoveAurasDueToSpell(spell);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cast spell on all players in instance
|
// Cast spell on all players in instance
|
||||||
void InstanceScript::DoCastSpellOnPlayers(uint32 spell)
|
void InstanceScript::DoCastSpellOnPlayers(uint32 spell)
|
||||||
{
|
{
|
||||||
Map::PlayerList const& PlayerList = instance->GetPlayers();
|
instance->DoForAllPlayers([&](Player* player)
|
||||||
|
{
|
||||||
if (!PlayerList.IsEmpty())
|
player->CastSpell(player, spell, true);
|
||||||
for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
|
});
|
||||||
if (Player* player = i->GetSource())
|
|
||||||
player->CastSpell(player, spell, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void InstanceScript::DoCastSpellOnPlayer(Player* player, uint32 spell, bool includePets /*= false*/, bool includeControlled /*= false*/)
|
void InstanceScript::DoCastSpellOnPlayer(Player* player, uint32 spell, bool includePets /*= false*/, bool includeControlled /*= false*/)
|
||||||
|
|||||||
Reference in New Issue
Block a user