mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-25 14:46:24 +00:00
feat(Core/Warden): optimization + PQR detection (#3875)
* Update AuctionHouseHandler.cpp * feat(warden): block PQR * wip * Update Warden.cpp * Core/Warden: minor preperation * Core/Misc: implemented some needed container wrapper functions * Core/Warden: more preperations * Core/Warden: more rework * LUA checks now are splitted to seperate config * LUA checks are always in front of queue * Fixed "Other" checks * Fixed PQR detection * Core/Warden: adjusted and optimized * Core/Warden: optimization * Core/Warden: more optimization * Core/Warden: use warden comments in ban reason * Core/Warden: more warden work * Core/Warden: more optimizations * Core/Warden: more refactors * Core/Warden: some more refactors + use default SHA definitions * Core/Warden: more refactoring * Core/Warden: fixed PQR detection again * Core/Warden: improved detection logging * Core/Misc: removed SmartEnums - we do not need it here + maybe should go as seperate commit * Core/Warden: fixed some warnings * Core/Warden: codestyle * Core/Warden: include warden check comment to console logs * Core/Warden: minor adjustment for previous commit * Core/Warden: fixed static analysis warning * Core/Warden: compilers, you're drunk this time... function is not unused... * Core/Warden: minor correction for logs * Core/Warden: one more improvement for logs * Core/Warden: added missing overrides * Core/Warden: some codestyle * Core/Misc: more codestyle * Core/Misc: more codestyle! * Core/Warden: restored default config options... (if you change it, change in core source too) * Core/Warden: addition to previous commit * DB/Warden: added EWT and WOWPlus checks (provided by lineagedr) * DB/Warden: addition to previous commit * fix: codestyle * Core/Warden: fixed build when extra logs are enabled in cmake Co-authored-by: Stefano Borzì <stefanoborzi32@gmail.com> Co-authored-by: Francesco Borzì <borzifrancesco@gmail.com>
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
#include <utility>
|
||||
#include <list>
|
||||
#include <vector>
|
||||
#include <type_traits>
|
||||
|
||||
//! Because circular includes are bad
|
||||
extern uint32 urand(uint32 min, uint32 max);
|
||||
@@ -107,6 +108,40 @@ namespace acore
|
||||
std::advance(it, urandweighted(weights.size(), weights.data()));
|
||||
return *it;
|
||||
}
|
||||
|
||||
template <typename Container, typename Predicate>
|
||||
std::enable_if_t<std::is_move_assignable_v<decltype(*std::declval<Container>().begin())>, void> EraseIf(Container& c, Predicate p)
|
||||
{
|
||||
auto wpos = c.begin();
|
||||
for (auto rpos = c.begin(), end = c.end(); rpos != end; ++rpos)
|
||||
{
|
||||
if (!p(*rpos))
|
||||
{
|
||||
if (rpos != wpos)
|
||||
{
|
||||
std::swap(*rpos, *wpos);
|
||||
}
|
||||
++wpos;
|
||||
}
|
||||
}
|
||||
c.erase(wpos, c.end());
|
||||
}
|
||||
|
||||
template <typename Container, typename Predicate>
|
||||
std::enable_if_t<!std::is_move_assignable_v<decltype(*std::declval<Container>().begin())>, void> EraseIf(Container& c, Predicate p)
|
||||
{
|
||||
for (auto it = c.begin(); it != c.end();)
|
||||
{
|
||||
if (p(*it))
|
||||
{
|
||||
it = c.erase(it);
|
||||
}
|
||||
else
|
||||
{
|
||||
++it;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//! namespace Containers
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user