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:
Kargatum
2021-05-17 02:53:21 +07:00
committed by GitHub
parent 0d699222de
commit 13f71c9c4d
33 changed files with 2933 additions and 651 deletions

View File

@@ -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);
}
}