mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-13 09:17:18 +00:00
feat(Core/Random): port random system from TrinityCore (#5454)
* feat(Core/Random): port random system from TrinityCore * lic * logic correct * MultimapErasePair move * whitespace 17:13:34 1. 'Containers.h'. Replace (1) 17:13:40 2. 'LootMgr.h'. Replace (1) 17:13:44 3. 'World.cpp'. Replace (1) 17:13:47 4. 'instance_scholomance.cpp'. Replace (1) * correct debug build
This commit is contained in:
@@ -100,24 +100,26 @@ public:
|
||||
}
|
||||
|
||||
template <class Predicate>
|
||||
void DoAction(int32 info, Predicate& predicate, uint16 max = 0)
|
||||
void DoAction(int32 info, Predicate&& predicate, uint16 max = 0)
|
||||
{
|
||||
if (max)
|
||||
RemoveNotExisting(); // pussywizard: when max is set, non existing can be chosen and nothing will happen
|
||||
|
||||
// We need to use a copy of SummonList here, otherwise original SummonList would be modified
|
||||
StorageType listCopy = storage_;
|
||||
acore::Containers::RandomResize(listCopy, predicate, max);
|
||||
for (StorageType::iterator i = listCopy.begin(); i != listCopy.end(); ++i)
|
||||
acore::Containers::RandomResize<StorageType, Predicate>(listCopy, std::forward<Predicate>(predicate), max);
|
||||
|
||||
for (auto const& guid : listCopy)
|
||||
{
|
||||
Creature* summon = ObjectAccessor::GetCreature(*me, *i);
|
||||
if (summon)
|
||||
Creature* summon = ObjectAccessor::GetCreature(*me, guid);
|
||||
if (summon && summon->IsAIEnabled)
|
||||
{
|
||||
if (summon->IsAIEnabled)
|
||||
summon->AI()->DoAction(info);
|
||||
summon->AI()->DoAction(info);
|
||||
}
|
||||
else if (!summon)
|
||||
{
|
||||
storage_.remove(guid);
|
||||
}
|
||||
else
|
||||
storage_.remove(*i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user