Core/Utilities: Rename RandomResizeList->RandomResize as it is no longer restricted to a list
This commit is contained in:
1 parent
38d1fc9ab3
commit
ac3dbcb880
27 files changed
+43
-43
No files matched your search
@@ -54,7 +54,7 @@ namespace Trinity
|
||||
}
|
||||
|
||||
template<class C>
|
||||
void RandomResizeList(C& container, std::size_t requestedSize)
|
||||
void RandomResize(C& container, std::size_t requestedSize)
|
||||
{
|
||||
uint32 currentSize = uint32(Size(container));
|
||||
while (currentSize > requestedSize)
|
||||
@@ -67,7 +67,7 @@ namespace Trinity
|
||||
}
|
||||
|
||||
template<class C, class Predicate>
|
||||
void RandomResizeList(C& container, Predicate&& predicate, std::size_t requestedSize)
|
||||
void RandomResize(C& container, Predicate&& predicate, std::size_t requestedSize)
|
||||
{
|
||||
//! First use predicate filter
|
||||
C containerCopy;
|
||||
@@ -75,7 +75,7 @@ namespace Trinity
|
||||
if (requestedSize)
|
||||
{
|
||||
std::copy_if(std::begin(container), std::end(container), std::inserter(containerCopy, std::end(containerCopy)), predicate);
|
||||
RandomResizeList(containerCopy, requestedSize);
|
||||
RandomResize(containerCopy, requestedSize);
|
||||
}
|
||||
|
||||
container = std::move(containerCopy);
|
||||
@@ -87,7 +87,7 @@ namespace Trinity
|
||||
* Note: container cannot be empty
|
||||
*/
|
||||
template<class C>
|
||||
inline auto SelectRandomContainerElement(C const& container) -> decltype(*std::begin(container)) const&
|
||||
inline auto SelectRandomContainerElement(C const& container) -> typename std::add_const<decltype(*std::begin(container))>::type&
|
||||
{
|
||||
auto it = std::begin(container);
|
||||
std::advance(it, urand(0, uint32(Size(container)) - 1));
|
||||
@@ -104,7 +104,7 @@ namespace Trinity
|
||||
* Note: container cannot be empty
|
||||
*/
|
||||
template<class C>
|
||||
auto SelectRandomWeightedContainerElement(C const& container, std::vector<double> weights) -> decltype(std::begin(container))
|
||||
inline auto SelectRandomWeightedContainerElement(C const& container, std::vector<double> weights) -> decltype(std::begin(container))
|
||||
{
|
||||
auto it = std::begin(container);
|
||||
std::advance(it, urandweighted(weights.size(), weights.data()));
|
||||
|
||||
@@ -255,7 +255,7 @@ class TC_GAME_API UnitAI
|
||||
targetList.reverse();
|
||||
|
||||
if (targetType == SELECT_TARGET_RANDOM)
|
||||
Trinity::Containers::RandomResizeList(targetList, maxTargets);
|
||||
Trinity::Containers::RandomResize(targetList, maxTargets);
|
||||
else
|
||||
targetList.resize(maxTargets);
|
||||
}
|
||||
|
||||
@@ -107,11 +107,11 @@ public:
|
||||
}
|
||||
|
||||
template <class Predicate>
|
||||
void DoAction(int32 info, Predicate& predicate, uint16 max = 0)
|
||||
void DoAction(int32 info, Predicate&& predicate, uint16 max = 0)
|
||||
{
|
||||
// We need to use a copy of SummonList here, otherwise original SummonList would be modified
|
||||
StorageType listCopy = storage_;
|
||||
Trinity::Containers::RandomResizeList<ObjectGuid, Predicate>(listCopy, predicate, max);
|
||||
Trinity::Containers::RandomResize<StorageType, Predicate>(listCopy, std::forward<Predicate>(predicate), max);
|
||||
for (StorageType::iterator i = listCopy.begin(); i != listCopy.end(); )
|
||||
{
|
||||
Creature* summon = ObjectAccessor::GetCreature(*me, *i++);
|
||||
|
||||
@@ -483,7 +483,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
break;
|
||||
|
||||
if (e.action.cast.targetsLimit > 0 && targets->size() > e.action.cast.targetsLimit)
|
||||
Trinity::Containers::RandomResizeList(*targets, e.action.cast.targetsLimit);
|
||||
Trinity::Containers::RandomResize(*targets, e.action.cast.targetsLimit);
|
||||
|
||||
for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr)
|
||||
{
|
||||
@@ -556,7 +556,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
break;
|
||||
|
||||
if (e.action.cast.targetsLimit > 0 && targets->size() > e.action.cast.targetsLimit)
|
||||
Trinity::Containers::RandomResizeList(*targets, e.action.cast.targetsLimit);
|
||||
Trinity::Containers::RandomResize(*targets, e.action.cast.targetsLimit);
|
||||
|
||||
for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr)
|
||||
{
|
||||
|
||||
@@ -1155,7 +1155,7 @@ void Spell::SelectImplicitConeTargets(SpellEffIndex effIndex, SpellImplicitTarge
|
||||
{
|
||||
// Other special target selection goes here
|
||||
if (uint32 maxTargets = m_spellValue->MaxAffectedTargets)
|
||||
Trinity::Containers::RandomResizeList(targets, maxTargets);
|
||||
Trinity::Containers::RandomResize(targets, maxTargets);
|
||||
|
||||
for (std::list<WorldObject*>::iterator itr = targets.begin(); itr != targets.end(); ++itr)
|
||||
{
|
||||
@@ -1237,7 +1237,7 @@ void Spell::SelectImplicitAreaTargets(SpellEffIndex effIndex, SpellImplicitTarge
|
||||
{
|
||||
// Other special target selection goes here
|
||||
if (uint32 maxTargets = m_spellValue->MaxAffectedTargets)
|
||||
Trinity::Containers::RandomResizeList(targets, maxTargets);
|
||||
Trinity::Containers::RandomResize(targets, maxTargets);
|
||||
|
||||
for (std::list<WorldObject*>::iterator itr = targets.begin(); itr != targets.end(); ++itr)
|
||||
{
|
||||
|
||||
@@ -158,7 +158,7 @@ class spell_argaloth_consuming_darkness : public SpellScriptLoader
|
||||
|
||||
void FilterTargets(std::list<WorldObject*>& targets)
|
||||
{
|
||||
Trinity::Containers::RandomResizeList(targets, GetCaster()->GetMap()->Is25ManRaid() ? 8 : 3);
|
||||
Trinity::Containers::RandomResize(targets, GetCaster()->GetMap()->Is25ManRaid() ? 8 : 3);
|
||||
}
|
||||
|
||||
void Register() override
|
||||
|
||||
@@ -190,7 +190,7 @@ public:
|
||||
for (uint8 i = 0; i < 6; ++i)
|
||||
AddList.push_back(Adds[i]);
|
||||
|
||||
Trinity::Containers::RandomResizeList(AddList, 4);
|
||||
Trinity::Containers::RandomResize(AddList, 4);
|
||||
|
||||
uint8 i = 0;
|
||||
for (std::list<uint32>::const_iterator itr = AddList.begin(); itr != AddList.end() && i < 4; ++itr, ++i)
|
||||
|
||||
@@ -184,7 +184,7 @@ class boss_mandokir : public CreatureScript
|
||||
GetCreatureListWithEntryInGrid(creatures, me, NPC_CHAINED_SPIRIT, 200.0f);
|
||||
creatures.remove_if(Trinity::AnyDeadUnitCheck());
|
||||
creatures.remove_if(Trinity::UnitAuraCheck(true, SPELL_OHGAN_ORDERS_TRIGGER));
|
||||
Trinity::Containers::RandomResizeList(creatures, 1);
|
||||
Trinity::Containers::RandomResize(creatures, 1);
|
||||
if (creatures.empty())
|
||||
return;
|
||||
|
||||
|
||||
@@ -436,7 +436,7 @@ class spell_countdown_p1 : public SpellScriptLoader
|
||||
return;
|
||||
}
|
||||
|
||||
Trinity::Containers::RandomResizeList(targets, 2);
|
||||
Trinity::Containers::RandomResize(targets, 2);
|
||||
target1 = targets.front();
|
||||
target2 = targets.back();
|
||||
}
|
||||
@@ -614,7 +614,7 @@ class spell_shards_of_torment : public SpellScriptLoader
|
||||
if ((targets.size() > numtargets) && GetCaster()->GetVictim())
|
||||
targets.remove(GetCaster()->ToCreature()->GetVictim()); //Safe to remove tank from list
|
||||
|
||||
Trinity::Containers::RandomResizeList(targets, numtargets);
|
||||
Trinity::Containers::RandomResize(targets, numtargets);
|
||||
}
|
||||
|
||||
void Register() override
|
||||
|
||||
@@ -141,7 +141,7 @@ public:
|
||||
GetCreatureListWithEntryInGrid(stalkers, me, NPC_BEETLE_STALKER, 100.0f);
|
||||
std::list<Creature*> beetlers = stalkers;
|
||||
|
||||
Trinity::Containers::RandomResizeList(beetlers, 9); // Holds the summoners of Jeweled Scarab
|
||||
Trinity::Containers::RandomResize(beetlers, 9); // Holds the summoners of Jeweled Scarab
|
||||
|
||||
for (std::list<Creature*>::iterator itr = beetlers.begin(); itr != beetlers.end(); ++itr)
|
||||
{
|
||||
@@ -151,7 +151,7 @@ public:
|
||||
(*itr)->m_Events.AddEvent(new SummonScarab((*itr), instance), (*itr)->m_Events.CalculateTime(5000));
|
||||
}
|
||||
|
||||
Trinity::Containers::RandomResizeList(stalkers, 2); // Holds the summoners of Dustbone Horror
|
||||
Trinity::Containers::RandomResize(stalkers, 2); // Holds the summoners of Dustbone Horror
|
||||
|
||||
for (std::list<Creature*>::iterator itr = stalkers.begin(); itr != stalkers.end(); ++itr)
|
||||
(*itr)->CastSpell((*itr), SPELL_SUMMON_DUSTBONE_HORROR);
|
||||
@@ -263,7 +263,7 @@ class spell_earthrager_ptah_flame_bolt : public SpellScriptLoader
|
||||
|
||||
void FilterTargets(std::list<WorldObject*>& targets)
|
||||
{
|
||||
Trinity::Containers::RandomResizeList(targets, GetCaster()->GetMap()->IsHeroic() ? 3 : 2);
|
||||
Trinity::Containers::RandomResize(targets, GetCaster()->GetMap()->IsHeroic() ? 3 : 2);
|
||||
}
|
||||
|
||||
void Register() override
|
||||
|
||||
@@ -154,7 +154,7 @@ class boss_moam : public CreatureScript
|
||||
targetList.push_back((*itr)->getTarget());
|
||||
}
|
||||
|
||||
Trinity::Containers::RandomResizeList(targetList, 5);
|
||||
Trinity::Containers::RandomResize(targetList, 5);
|
||||
|
||||
for (std::list<Unit*>::iterator itr = targetList.begin(); itr != targetList.end(); ++itr)
|
||||
DoCast(*itr, SPELL_DRAIN_MANA);
|
||||
|
||||
@@ -284,7 +284,7 @@ class spell_call_the_wind : public SpellScriptLoader
|
||||
return;
|
||||
|
||||
targets.remove_if(Trinity::UnitAuraCheck(true, SPELL_CALL_THE_WIND_AURA));
|
||||
Trinity::Containers::RandomResizeList(targets, 1);
|
||||
Trinity::Containers::RandomResize(targets, 1);
|
||||
}
|
||||
|
||||
void HandleDummy(SpellEffIndex /*effIndex*/)
|
||||
|
||||
@@ -599,7 +599,7 @@ public:
|
||||
|
||||
void SelectRandom(std::list<WorldObject*>& targets)
|
||||
{
|
||||
Trinity::Containers::RandomResizeList(targets, 1);
|
||||
Trinity::Containers::RandomResize(targets, 1);
|
||||
}
|
||||
|
||||
void HandleDummy(SpellEffIndex /*effIndex*/)
|
||||
|
||||
@@ -972,7 +972,7 @@ public:
|
||||
|
||||
void FilterTargets(std::list<WorldObject*>& targets)
|
||||
{
|
||||
Trinity::Containers::RandomResizeList(targets, 1);
|
||||
Trinity::Containers::RandomResize(targets, 1);
|
||||
}
|
||||
|
||||
void Register()
|
||||
|
||||
@@ -1856,7 +1856,7 @@ class spell_halion_spawn_living_embers : public SpellScriptLoader
|
||||
void SelectMeteorFlames(std::list<WorldObject*>& unitList)
|
||||
{
|
||||
if (!unitList.empty())
|
||||
Trinity::Containers::RandomResizeList(unitList, 10);
|
||||
Trinity::Containers::RandomResize(unitList, 10);
|
||||
}
|
||||
|
||||
void HandleScript(SpellEffIndex /* effIndex */)
|
||||
|
||||
@@ -240,7 +240,7 @@ class spell_saviana_conflagration_init : public SpellScriptLoader
|
||||
targets.remove_if(ConflagrationTargetSelector());
|
||||
uint8 maxSize = uint8(GetCaster()->GetMap()->GetSpawnMode() & 1 ? 6 : 3);
|
||||
if (targets.size() > maxSize)
|
||||
Trinity::Containers::RandomResizeList(targets, maxSize);
|
||||
Trinity::Containers::RandomResize(targets, maxSize);
|
||||
}
|
||||
|
||||
void HandleDummy(SpellEffIndex effIndex)
|
||||
|
||||
+2
-2
@@ -554,9 +554,9 @@ class instance_halls_of_reflection : public InstanceMapScript
|
||||
ObjectGuid bossGuid = i <= 3 ? FalricGUID : MarwynGUID;
|
||||
|
||||
if (!i)
|
||||
Trinity::Containers::RandomResizeList(tempList, 3);
|
||||
Trinity::Containers::RandomResize(tempList, 3);
|
||||
else if (i < 6 && i != 3)
|
||||
Trinity::Containers::RandomResizeList(tempList, 4);
|
||||
Trinity::Containers::RandomResize(tempList, 4);
|
||||
|
||||
for (uint32 entry : tempList)
|
||||
{
|
||||
|
||||
@@ -409,7 +409,7 @@ class boss_blood_queen_lana_thel : public CreatureScript
|
||||
{
|
||||
std::list<Player*> targets;
|
||||
SelectRandomTarget(false, &targets);
|
||||
Trinity::Containers::RandomResizeList(targets, Is25ManRaid() ? 3 : 2);
|
||||
Trinity::Containers::RandomResize(targets, Is25ManRaid() ? 3 : 2);
|
||||
if (targets.size() > 1)
|
||||
{
|
||||
Talk(SAY_PACT_OF_THE_DARKFALLEN);
|
||||
@@ -432,7 +432,7 @@ class boss_blood_queen_lana_thel : public CreatureScript
|
||||
{
|
||||
std::list<Player*> targets;
|
||||
SelectRandomTarget(false, &targets);
|
||||
Trinity::Containers::RandomResizeList<Player*>(targets, uint32(Is25ManRaid() ? 4 : 2));
|
||||
Trinity::Containers::RandomResize(targets, uint32(Is25ManRaid() ? 4 : 2));
|
||||
for (std::list<Player*>::iterator itr = targets.begin(); itr != targets.end(); ++itr)
|
||||
DoCast(*itr, SPELL_TWILIGHT_BLOODBOLT);
|
||||
DoCast(me, SPELL_TWILIGHT_BLOODBOLT_TARGET);
|
||||
@@ -685,7 +685,7 @@ class spell_blood_queen_bloodbolt : public SpellScriptLoader
|
||||
{
|
||||
uint32 targetCount = (targets.size() + 2) / 3;
|
||||
targets.remove_if(BloodboltHitCheck(static_cast<LanaThelAI*>(GetCaster()->GetAI())));
|
||||
Trinity::Containers::RandomResizeList(targets, targetCount);
|
||||
Trinity::Containers::RandomResize(targets, targetCount);
|
||||
// mark targets now, effect hook has missile travel time delay (might cast next in that time)
|
||||
for (std::list<WorldObject*>::const_iterator itr = targets.begin(); itr != targets.end(); ++itr)
|
||||
GetCaster()->GetAI()->SetGUID((*itr)->GetGUID(), GUID_BLOODBOLT);
|
||||
|
||||
@@ -221,7 +221,7 @@ class boss_festergut : public CreatureScript
|
||||
|
||||
if (!ranged.empty())
|
||||
{
|
||||
Trinity::Containers::RandomResizeList(ranged, RAID_MODE<uint32>(1, 3, 1, 3));
|
||||
Trinity::Containers::RandomResize(ranged, RAID_MODE<uint32>(1, 3, 1, 3));
|
||||
for (std::list<Unit*>::iterator itr = ranged.begin(); itr != ranged.end(); ++itr)
|
||||
DoCast(*itr, SPELL_VILE_GAS);
|
||||
}
|
||||
|
||||
@@ -1204,7 +1204,7 @@ class spell_putricide_unbound_plague : public SpellScriptLoader
|
||||
|
||||
|
||||
targets.remove_if(Trinity::UnitAuraCheck(true, sSpellMgr->GetSpellIdForDifficulty(SPELL_UNBOUND_PLAGUE, GetCaster())));
|
||||
Trinity::Containers::RandomResizeList(targets, 1);
|
||||
Trinity::Containers::RandomResize(targets, 1);
|
||||
}
|
||||
|
||||
void HandleScript(SpellEffIndex /*effIndex*/)
|
||||
|
||||
@@ -848,7 +848,7 @@ class spell_rotface_vile_gas_trigger : public SpellScriptLoader
|
||||
}
|
||||
|
||||
if (!ranged.empty())
|
||||
Trinity::Containers::RandomResizeList(ranged, GetCaster()->GetMap()->Is25ManRaid() ? 3 : 1);
|
||||
Trinity::Containers::RandomResize(ranged, GetCaster()->GetMap()->Is25ManRaid() ? 3 : 1);
|
||||
|
||||
targets.swap(ranged);
|
||||
}
|
||||
|
||||
@@ -1169,7 +1169,7 @@ class spell_sindragosa_unchained_magic : public SpellScriptLoader
|
||||
unitList.remove_if(UnchainedMagicTargetSelector());
|
||||
uint32 maxSize = uint32(GetCaster()->GetMap()->GetSpawnMode() & 1 ? 6 : 2);
|
||||
if (unitList.size() > maxSize)
|
||||
Trinity::Containers::RandomResizeList(unitList, maxSize);
|
||||
Trinity::Containers::RandomResize(unitList, maxSize);
|
||||
}
|
||||
|
||||
void Register() override
|
||||
|
||||
@@ -2009,7 +2009,7 @@ class spell_svalna_revive_champion : public SpellScriptLoader
|
||||
void RemoveAliveTarget(std::list<WorldObject*>& targets)
|
||||
{
|
||||
targets.remove_if(AliveCheck());
|
||||
Trinity::Containers::RandomResizeList(targets, 2);
|
||||
Trinity::Containers::RandomResize(targets, 2);
|
||||
}
|
||||
|
||||
void Land(SpellEffIndex /*effIndex*/)
|
||||
|
||||
@@ -1739,10 +1739,10 @@ class spell_malygos_arcane_storm : public SpellScriptLoader
|
||||
{
|
||||
// Resize list only to objects that are vehicles.
|
||||
IsCreatureVehicleCheck check(true);
|
||||
Trinity::Containers::RandomResizeList(targets, check, (malygos->GetMap()->GetDifficulty() == RAID_DIFFICULTY_10MAN_NORMAL ? 4 : 10));
|
||||
Trinity::Containers::RandomResize(targets, check, (malygos->GetMap()->GetDifficulty() == RAID_DIFFICULTY_10MAN_NORMAL ? 4 : 10));
|
||||
}
|
||||
else
|
||||
Trinity::Containers::RandomResizeList(targets, (malygos->GetMap()->GetDifficulty() == RAID_DIFFICULTY_10MAN_NORMAL ? 4 : 10));
|
||||
Trinity::Containers::RandomResize(targets, (malygos->GetMap()->GetDifficulty() == RAID_DIFFICULTY_10MAN_NORMAL ? 4 : 10));
|
||||
}
|
||||
|
||||
void HandleVisual(SpellEffIndex /*effIndex*/)
|
||||
@@ -2020,7 +2020,7 @@ class spell_scion_of_eternity_arcane_barrage : public SpellScriptLoader
|
||||
if (!targets.empty())
|
||||
{
|
||||
if (targets.size() > 1)
|
||||
Trinity::Containers::RandomResizeList(targets, 1);
|
||||
Trinity::Containers::RandomResize(targets, 1);
|
||||
|
||||
if (WorldObject* filteredTarget = targets.front())
|
||||
if (malygos)
|
||||
@@ -2270,7 +2270,7 @@ class spell_malygos_surge_of_power_warning_selector_25 : public SpellScriptLoade
|
||||
std::list<WorldObject*> selectedTargets = targets;
|
||||
|
||||
uint8 guidDataSlot = DATA_FIRST_SURGE_TARGET_GUID; // SetGuid in Malygos AI is reserved for 14th, 15th and 16th Id for the three targets
|
||||
Trinity::Containers::RandomResizeList(selectedTargets, 3);
|
||||
Trinity::Containers::RandomResize(selectedTargets, 3);
|
||||
for (std::list<WorldObject*>::const_iterator itr = selectedTargets.begin(); itr != selectedTargets.end(); ++itr)
|
||||
{
|
||||
Creature* target = (*itr)->ToCreature();
|
||||
|
||||
@@ -856,7 +856,7 @@ class boss_thorim : public CreatureScript
|
||||
triggerList.push_back(bunny);
|
||||
}
|
||||
else
|
||||
Trinity::Containers::RandomResizeList(triggerList, count);
|
||||
Trinity::Containers::RandomResize(triggerList, count);
|
||||
}
|
||||
|
||||
void SummonWave()
|
||||
|
||||
@@ -899,7 +899,7 @@ class spell_dru_starfall_dummy : public SpellScriptLoader
|
||||
|
||||
void FilterTargets(std::list<WorldObject*>& targets)
|
||||
{
|
||||
Trinity::Containers::RandomResizeList(targets, 2);
|
||||
Trinity::Containers::RandomResize(targets, 2);
|
||||
}
|
||||
|
||||
void HandleDummy(SpellEffIndex /*effIndex*/)
|
||||
|
||||
@@ -3954,7 +3954,7 @@ class spell_item_taunt_flag_targeting : public SpellScriptLoader
|
||||
return;
|
||||
}
|
||||
|
||||
Trinity::Containers::RandomResizeList(targets, 1);
|
||||
Trinity::Containers::RandomResize(targets, 1);
|
||||
}
|
||||
|
||||
void HandleDummy(SpellEffIndex /*effIndex*/)
|
||||
|
||||
Reference in new issue
Block a user