feat(Core): enable C++17 (#2234)

Co-authored-by: Winfidonarleyan <dowlandtop@yandex.com>
This commit is contained in:
Francesco Borzì
2019-09-02 08:54:10 +02:00
committed by Kargatum
parent cae91f1650
commit 3a43e8c415
28 changed files with 61 additions and 46 deletions

View File

@@ -28,7 +28,7 @@ enum SelectAggroTarget
};
// default predicate function to select target based on distance, player and/or aura criteria
struct DefaultTargetSelector : public std::unary_function<Unit*, bool>
struct DefaultTargetSelector : public ACORE::unary_function<Unit*, bool>
{
const Unit* me;
float m_dist;
@@ -78,7 +78,7 @@ struct DefaultTargetSelector : public std::unary_function<Unit*, bool>
// Target selector for spell casts checking range, auras and attributes
// TODO: Add more checks from Spell::CheckCast
struct SpellTargetSelector : public std::unary_function<Unit*, bool>
struct SpellTargetSelector : public ACORE::unary_function<Unit*, bool>
{
public:
SpellTargetSelector(Unit* caster, uint32 spellId);
@@ -92,7 +92,7 @@ struct SpellTargetSelector : public std::unary_function<Unit*, bool>
// Very simple target selector, will just skip main target
// NOTE: When passing to UnitAI::SelectTarget remember to use 0 as position for random selection
// because tank will not be in the temporary list
struct NonTankTargetSelector : public std::unary_function<Unit*, bool>
struct NonTankTargetSelector : public ACORE::unary_function<Unit*, bool>
{
public:
NonTankTargetSelector(Creature* source, bool playerOnly = true) : _source(source), _playerOnly(playerOnly) { }
@@ -104,7 +104,7 @@ struct NonTankTargetSelector : public std::unary_function<Unit*, bool>
};
// Simple selector for units using mana
struct PowerUsersSelector : public std::unary_function<Unit*, bool>
struct PowerUsersSelector : public ACORE::unary_function<Unit*, bool>
{
Unit const* _me;
Powers const _power;
@@ -135,7 +135,7 @@ struct PowerUsersSelector : public std::unary_function<Unit*, bool>
}
};
struct FarthestTargetSelector : public std::unary_function<Unit*, bool>
struct FarthestTargetSelector : public ACORE::unary_function<Unit*, bool>
{
FarthestTargetSelector(Unit const* unit, float dist, bool playerOnly, bool inLos) : _me(unit), _dist(dist), _playerOnly(playerOnly), _inLos(inLos) {}
@@ -191,7 +191,7 @@ class UnitAI
Unit* SelectTarget(SelectAggroTarget targetType, uint32 position = 0, float dist = 0.0f, bool playerOnly = false, int32 aura = 0);
// Select the targets satifying the predicate.
// predicate shall extend std::unary_function<Unit*, bool>
// predicate shall extend ACORE::unary_function<Unit*, bool>
template <class PREDICATE> Unit* SelectTarget(SelectAggroTarget targetType, uint32 position, PREDICATE const& predicate)
{
ThreatContainer::StorageType const& threatlist = me->getThreatManager().getThreatList();
@@ -241,7 +241,7 @@ class UnitAI
void SelectTargetList(std::list<Unit*>& targetList, uint32 num, SelectAggroTarget targetType, float dist = 0.0f, bool playerOnly = false, int32 aura = 0);
// Select the targets satifying the predicate.
// predicate shall extend std::unary_function<Unit*, bool>
// predicate shall extend ACORE::unary_function<Unit*, bool>
template <class PREDICATE> void SelectTargetList(std::list<Unit*>& targetList, PREDICATE const& predicate, uint32 maxTargets, SelectAggroTarget targetType)
{
ThreatContainer::StorageType const& threatlist = me->getThreatManager().getThreatList();

View File

@@ -36,6 +36,8 @@
#include "BattlegroundQueue.h"
#include "GameGraveyard.h"
#include <unordered_map>
#include <random>
#ifdef ELUNA
#include "LuaEngine.h"
#endif
@@ -998,8 +1000,10 @@ void RandomBattlegroundSystem::Update(uint32 diff)
small.push_back(BATTLEGROUND_AB);
small.push_back(BATTLEGROUND_SA);
std::random_shuffle(big.begin(), big.end());
std::random_shuffle(small.begin(), small.end());
auto rng = std::default_random_engine{};
std::shuffle(big.begin(), big.end(), rng);
std::shuffle(small.begin(), small.end(), rng);
m_BgOrder.push_back(small.back()); small.pop_back();
m_BgOrder.push_back(small.back()); small.pop_back();

View File

@@ -42,7 +42,7 @@ LootStore LootTemplates_Skinning("skinning_loot_template", "creature s
LootStore LootTemplates_Spell("spell_loot_template", "spell id (random item creating)", false);
// Selects invalid loot items to be removed from group possible entries (before rolling)
struct LootGroupInvalidSelector : public std::unary_function<LootStoreItem*, bool>
struct LootGroupInvalidSelector : public ACORE::unary_function<LootStoreItem*, bool>
{
explicit LootGroupInvalidSelector(Loot const& loot, uint16 lootMode) : _loot(loot), _lootMode(lootMode) { }

View File

@@ -9,6 +9,7 @@
#include "icecrown_citadel.h"
#include "SpellInfo.h"
#include "Player.h"
#include <random>
enum ScriptTexts
{
@@ -387,7 +388,7 @@ class boss_lady_deathwhisper : public CreatureScript
}
std::vector<Player*>::iterator begin=validPlayers.begin(), end=validPlayers.end();
std::random_shuffle(begin, end);
std::shuffle(begin, end, std::default_random_engine{});
for (uint8 i = 0; i < RAID_MODE<uint8>(0, 1, 1, 3) && i < validPlayers.size(); i++)
{

View File

@@ -11,6 +11,7 @@
#include "PassiveAI.h"
#include "Player.h"
#include "Vehicle.h"
#include <random>
enum ScriptTexts
{
@@ -58,7 +59,7 @@ enum Events
uint32 const boneSpikeSummonId[3] = {69062, 72669, 72670};
struct BoneStormMoveTargetSelector : public std::unary_function<Unit*, bool>
struct BoneStormMoveTargetSelector : public ACORE::unary_function<Unit*, bool>
{
public:
BoneStormMoveTargetSelector(Creature* source) : _source(source) { }
@@ -549,7 +550,7 @@ public:
validPlayers.push_back(plr);
std::vector<Player*>::iterator begin=validPlayers.begin(), end=validPlayers.end();
std::random_shuffle(begin, end);
std::shuffle(begin, end, std::default_random_engine{});
for (uint8 i = 0; i < boneSpikeCount && i < validPlayers.size(); ++i)
{

View File

@@ -188,7 +188,7 @@ private:
};
// xinef: malleable goo selector, check for target validity
struct MalleableGooSelector : public std::unary_function<Unit*, bool>
struct MalleableGooSelector : public ACORE::unary_function<Unit*, bool>
{
const Unit* me;
MalleableGooSelector(Unit const* unit) : me(unit) {}

View File

@@ -227,7 +227,7 @@ class IceTombSummonEvent : public BasicEvent
uint64 _sindragosaGUID;
};
struct LastPhaseIceTombTargetSelector : public std::unary_function<Unit*, bool>
struct LastPhaseIceTombTargetSelector : public ACORE::unary_function<Unit*, bool>
{
public:
LastPhaseIceTombTargetSelector(Creature* source) : _source(source) { }

View File

@@ -359,7 +359,7 @@ void SendPacketToPlayers(WorldPacket const* data, Unit* source)
}
struct NonTankLKTargetSelector : public std::unary_function<Unit*, bool>
struct NonTankLKTargetSelector : public ACORE::unary_function<Unit*, bool>
{
public:
NonTankLKTargetSelector(Creature* source, bool playerOnly = true, bool reqLOS = false, float maxDist = 0.0f, uint32 exclude1 = 0, uint32 exclude2 = 0) : _source(source), _playerOnly(playerOnly), _reqLOS(reqLOS), _maxDist(maxDist), _exclude1(exclude1), _exclude2(exclude2) { }
@@ -394,7 +394,7 @@ private:
};
struct DefileTargetSelector : public std::unary_function<Unit*, bool>
struct DefileTargetSelector : public ACORE::unary_function<Unit*, bool>
{
public:
DefileTargetSelector(Creature* source) : _source(source) { }
@@ -551,7 +551,7 @@ private:
Creature& _owner;
};
class NecroticPlagueTargetCheck : public std::unary_function<Unit*, bool>
class NecroticPlagueTargetCheck : public ACORE::unary_function<Unit*, bool>
{
public:
NecroticPlagueTargetCheck(Unit const* obj, uint32 notAura1, uint32 notAura2) : _sourceObj(obj), _notAura1(notAura1), _notAura2(notAura2) {}

View File

@@ -144,7 +144,7 @@ class RisenArchmageCheck
}
};
struct ManaVoidSelector : public std::unary_function<Unit*, bool>
struct ManaVoidSelector : public ACORE::unary_function<Unit*, bool>
{
explicit ManaVoidSelector(WorldObject const* source) : _source(source) { }

View File

@@ -166,7 +166,7 @@ const Position PosPlatform = {2640.5f, -3360.6f, 285.26f, 0.0f};
#define IN_LIVE_SIDE(who) (who->GetPositionY() < POS_Y_GATE)
// Predicate function to check that the r efzr unit is NOT on the same side as the source.
struct NotOnSameSide : public std::unary_function<Unit *, bool>
struct NotOnSameSide : public ACORE::unary_function<Unit *, bool>
{
bool m_inLiveSide;
explicit NotOnSameSide(Unit *pSource) : m_inLiveSide(IN_LIVE_SIDE(pSource)) {}

View File

@@ -639,7 +639,7 @@ public:
// predicate function to select non main tank target
class StoneGripTargetSelector : public std::unary_function<Unit*, bool>
class StoneGripTargetSelector : public ACORE::unary_function<Unit*, bool>
{
public:
StoneGripTargetSelector(Creature* me, Unit const* victim) : _me(me), _victim(victim) {}

View File

@@ -49,7 +49,7 @@ enum Misc
EVENT_TALK_KILL = 10
};
struct ShadowOfDeathSelector : public std::unary_function<Unit*, bool>
struct ShadowOfDeathSelector : public ACORE::unary_function<Unit*, bool>
{
bool operator()(Unit const* target) const
{

View File

@@ -86,7 +86,7 @@ enum Misc
EVENT_KILL_TALK = 100
};
struct HammerOfJusticeSelector : public std::unary_function<Unit*, bool>
struct HammerOfJusticeSelector : public ACORE::unary_function<Unit*, bool>
{
Unit const* _me;
HammerOfJusticeSelector(Unit* me) : _me(me) { }