refactor(Core): apply clang-tidy modernize-* (#9975)

Co-authored-by: Kitzunu <24550914+Kitzunu@users.noreply.github.com>
This commit is contained in:
Francesco Borzì
2022-01-17 14:35:07 +01:00
committed by GitHub
parent fe4899202d
commit 9dc88def35
71 changed files with 533 additions and 534 deletions

View File

@@ -2144,7 +2144,7 @@ struct WorldStateUI
// Structures not used for casting to loaded DBC data and not required then packing
struct MapDifficulty
{
MapDifficulty() {}
MapDifficulty() = default;
MapDifficulty(uint32 _resetTime, uint32 _maxPlayers, bool _hasErrorMessage) : resetTime(_resetTime), maxPlayers(_maxPlayers), hasErrorMessage(_hasErrorMessage) {}
uint32 resetTime{0};
@@ -2154,7 +2154,7 @@ struct MapDifficulty
struct TalentSpellPos
{
TalentSpellPos() {}
TalentSpellPos() = default;
TalentSpellPos(uint16 _talent_id, uint8 _rank) : talent_id(_talent_id), rank(_rank) {}
uint16 talent_id{0};
@@ -2165,7 +2165,7 @@ typedef std::map<uint32, TalentSpellPos> TalentSpellPosMap;
struct TaxiPathBySourceAndDestination
{
TaxiPathBySourceAndDestination() {}
TaxiPathBySourceAndDestination() = default;
TaxiPathBySourceAndDestination(uint32 _id, uint32 _price) : ID(_id), price(_price) {}
uint32 ID{0};

View File

@@ -31,9 +31,9 @@ class MessageBuffer;
class AC_SHARED_API ByteBufferException : public std::exception
{
public:
~ByteBufferException() noexcept = default;
~ByteBufferException() noexcept override = default;
char const* what() const noexcept override { return msg_.c_str(); }
[[nodiscard]] char const* what() const noexcept override { return msg_.c_str(); }
protected:
std::string & message() noexcept { return msg_; }
@@ -47,7 +47,7 @@ class AC_SHARED_API ByteBufferPositionException : public ByteBufferException
public:
ByteBufferPositionException(bool add, size_t pos, size_t size, size_t valueSize);
~ByteBufferPositionException() noexcept = default;
~ByteBufferPositionException() noexcept override = default;
};
class AC_SHARED_API ByteBufferSourceException : public ByteBufferException
@@ -55,7 +55,7 @@ class AC_SHARED_API ByteBufferSourceException : public ByteBufferException
public:
ByteBufferSourceException(size_t pos, size_t size, size_t valueSize);
~ByteBufferSourceException() noexcept = default;
~ByteBufferSourceException() noexcept override = default;
};
class AC_SHARED_API ByteBufferInvalidValueException : public ByteBufferException
@@ -63,7 +63,7 @@ class AC_SHARED_API ByteBufferInvalidValueException : public ByteBufferException
public:
ByteBufferInvalidValueException(char const* type, char const* value);
~ByteBufferInvalidValueException() noexcept = default;
~ByteBufferInvalidValueException() noexcept override = default;
};
class AC_SHARED_API ByteBuffer
@@ -72,7 +72,7 @@ public:
constexpr static size_t DEFAULT_SIZE = 0x1000;
// constructor
ByteBuffer() : _rpos(0), _wpos(0)
ByteBuffer()
{
_storage.reserve(DEFAULT_SIZE);
}
@@ -355,7 +355,7 @@ public:
return r;
}
template <typename T> T read(size_t pos) const
template <typename T> [[nodiscard]] T read(size_t pos) const
{
if (pos + sizeof(T) > size())
{
@@ -528,7 +528,7 @@ public:
void hexlike() const;
protected:
size_t _rpos, _wpos;
size_t _rpos{0}, _wpos{0};
std::vector<uint8> _storage;
};

View File

@@ -36,10 +36,10 @@ enum RealmFlags
struct AC_SHARED_API RealmHandle
{
RealmHandle() : Realm(0) { }
RealmHandle() = default;
RealmHandle(uint32 index) : Realm(index) { }
uint32 Realm; // primary key in `realmlist` table
uint32 Realm{0}; // primary key in `realmlist` table
bool operator<(RealmHandle const& r) const
{
@@ -78,7 +78,7 @@ struct AC_SHARED_API Realm
AccountTypes AllowedSecurityLevel;
float PopulationLevel;
boost::asio::ip::tcp_endpoint GetAddressForClient(boost::asio::ip::address const& clientAddr) const;
[[nodiscard]] boost::asio::ip::tcp_endpoint GetAddressForClient(boost::asio::ip::address const& clientAddr) const;
};
#endif // Realm_h__

View File

@@ -24,8 +24,7 @@
#include "Util.h"
#include <boost/asio/ip/tcp.hpp>
RealmList::RealmList() :
_updateInterval(0) { }
RealmList::RealmList() : _updateInterval(0) { }
RealmList* RealmList::Instance()
{

View File

@@ -52,10 +52,10 @@ public:
void Initialize(Acore::Asio::IoContext& ioContext, uint32 updateInterval);
void Close();
RealmMap const& GetRealms() const { return _realms; }
Realm const* GetRealm(RealmHandle const& id) const;
[[nodiscard]] RealmMap const& GetRealms() const { return _realms; }
[[nodiscard]] Realm const* GetRealm(RealmHandle const& id) const;
RealmBuildInfo const* GetBuildInfo(uint32 build) const;
[[nodiscard]] RealmBuildInfo const* GetBuildInfo(uint32 build) const;
private:
RealmList();
@@ -69,7 +69,7 @@ private:
std::vector<RealmBuildInfo> _builds;
RealmMap _realms;
uint32 _updateInterval;
uint32 _updateInterval{0};
std::unique_ptr<Acore::Asio::DeadlineTimer> _updateTimer;
std::unique_ptr<Acore::Asio::Resolver> _resolver;
};

View File

@@ -42,7 +42,7 @@ struct SecretInfo
int bits;
ServerProcessTypes owner;
uint64 _flags;
uint16 flags() const { return static_cast<uint16>(_flags >> (16*THIS_SERVER_PROCESS)); }
[[nodiscard]] uint16 flags() const { return static_cast<uint16>(_flags >> (16*THIS_SERVER_PROCESS)); }
};
static constexpr SecretInfo secret_info[NUM_SECRETS] =

View File

@@ -37,8 +37,8 @@ enum Secrets : uint32
class AC_SHARED_API SecretMgr
{
private:
SecretMgr() {}
~SecretMgr() {}
SecretMgr() = default;
~SecretMgr() = default;
public:
SecretMgr(SecretMgr const&) = delete;
@@ -50,7 +50,7 @@ public:
explicit operator bool() const { return (state == PRESENT); }
BigNumber const& operator*() const { return value; }
BigNumber const* operator->() const { return &value; }
bool IsAvailable() const { return (state != NOT_LOADED_YET) && (state != LOAD_FAILED); }
[[nodiscard]] bool IsAvailable() const { return (state != NOT_LOADED_YET) && (state != LOAD_FAILED); }
private:
std::mutex lock;
@@ -65,7 +65,7 @@ public:
private:
void AttemptLoad(Secrets i, LogLevel errorLevel, std::unique_lock<std::mutex> const&);
Optional<std::string> AttemptTransition(Secrets i, Optional<BigNumber> const& newSecret, Optional<BigNumber> const& oldSecret, bool hadOldSecret) const;
[[nodiscard]] Optional<std::string> AttemptTransition(Secrets i, Optional<BigNumber> const& newSecret, Optional<BigNumber> const& oldSecret, bool hadOldSecret) const;
std::array<Secret, NUM_SECRETS> _secrets;
};

View File

@@ -159,7 +159,7 @@ AC_API_EXPORT EnumText EnumUtils<SpellAttr0>::ToString(SpellAttr0 value)
{
case SPELL_ATTR0_PROC_FAILURE_BURNS_CHARGE: return { "SPELL_ATTR0_PROC_FAILURE_BURNS_CHARGE", "Unknown attribute 0@Attr0", "" };
case SPELL_ATTR0_USES_RANGED_SLOT: return { "SPELL_ATTR0_USES_RANGED_SLOT", "Treat as ranged attack", "Use ammo, ranged attack range modifiers, ranged haste, etc." };
case SPELL_ATTR0_ON_NEXT_SWING_NO_DAMAGE: return { "SPELL_ATTR0_ON_NEXT_SWING_NO_DAMAGE", "On next melee (type 1)", "Both \042on next swing\042 attributes have identical handling in server & client" };
case SPELL_ATTR0_ON_NEXT_SWING_NO_DAMAGE: return { "SPELL_ATTR0_ON_NEXT_SWING_NO_DAMAGE", "On next melee (type 1)", R"(Both "on next swing" attributes have identical handling in server & client)" };
case SPELL_ATTR0_DO_NOT_LOG_IMMUNE_MISSES: return { "SPELL_ATTR0_DO_NOT_LOG_IMMUNE_MISSES", "Replenishment (client only)", "" };
case SPELL_ATTR0_IS_ABILITY: return { "SPELL_ATTR0_IS_ABILITY", "Treat as ability", "Cannot be reflected, not affected by cast speed modifiers, etc." };
case SPELL_ATTR0_IS_TRADESKILL: return { "SPELL_ATTR0_IS_TRADESKILL", "Trade skill recipe", "Displayed in recipe list, not affected by cast speed modifiers" };
@@ -167,7 +167,7 @@ AC_API_EXPORT EnumText EnumUtils<SpellAttr0>::ToString(SpellAttr0 value)
case SPELL_ATTR0_DO_NOT_DISPLAY: return { "SPELL_ATTR0_DO_NOT_DISPLAY", "Hidden in UI (client only)", "Not visible in spellbook or aura bar (Spellbook, Aura Icon, Combat Log)" };
case SPELL_ATTR0_DO_NOT_LOG: return { "SPELL_ATTR0_DO_NOT_LOG", "Hidden in combat log (client only)", "Spell will not appear in combat logs" };
case SPELL_ATTR0_HELD_ITEM_ONLY: return { "SPELL_ATTR0_HELD_ITEM_ONLY", "Auto-target mainhand item (client only)", "Client will automatically select main-hand item as cast target" };
case SPELL_ATTR0_ON_NEXT_SWING: return { "SPELL_ATTR0_ON_NEXT_SWING", "On next melee (type 2)", "Both \042on next swing\042 attributes have identical handling in server & client" };
case SPELL_ATTR0_ON_NEXT_SWING: return { "SPELL_ATTR0_ON_NEXT_SWING", "On next melee (type 2)", R"(Both "on next swing" attributes have identical handling in server & client)" };
case SPELL_ATTR0_WEARER_CASTS_PROC_TRIGGER: return { "SPELL_ATTR0_WEARER_CASTS_PROC_TRIGGER", "Unknown attribute 11@Attr0", "" };
case SPELL_ATTR0_SERVER_ONLY: return { "SPELL_ATTR0_SERVER_ONLY", "Only usable during daytime (unused)", "" };
case SPELL_ATTR0_ALLOW_ITEM_SPELL_IN_PVP: return { "SPELL_ATTR0_ALLOW_ITEM_SPELL_IN_PVP", "Only usable during nighttime (unused)", "" };
@@ -288,11 +288,11 @@ AC_API_EXPORT EnumText EnumUtils<SpellAttr1>::ToString(SpellAttr1 value)
{
case SPELL_ATTR1_DISMISS_PET_FIRST: return { "SPELL_ATTR1_DISMISS_PET_FIRST", "Dismiss Pet on cast", "Without this attribute, summoning spells will fail if caster already has a pet" };
case SPELL_ATTR1_USE_ALL_MANA: return { "SPELL_ATTR1_USE_ALL_MANA", "Drain all power", "Ignores listed power cost and drains entire pool instead" };
case SPELL_ATTR1_IS_CHANNELED: return { "SPELL_ATTR1_IS_CHANNELED", "Channeled (type 1)", "Both \042channeled\042 attributes have identical handling in server & client" };
case SPELL_ATTR1_IS_CHANNELED: return { "SPELL_ATTR1_IS_CHANNELED", "Channeled (type 1)", R"(Both "channeled" attributes have identical handling in server & client)" };
case SPELL_ATTR1_NO_REDIRECTION: return { "SPELL_ATTR1_NO_REDIRECTION", "Ignore redirection effects", "Spell will not be attracted by SPELL_MAGNET auras (Grounding Totem)" };
case SPELL_ATTR1_NO_SKILL_INCREASE: return { "SPELL_ATTR1_NO_SKILL_INCREASE", "Unknown attribute 4@Attr1", "stealth and whirlwind" };
case SPELL_ATTR1_ALLOW_WHILE_STEALTHED: return { "SPELL_ATTR1_ALLOW_WHILE_STEALTHED", "Does not break stealth", "" };
case SPELL_ATTR1_IS_SELF_CHANNELED: return { "SPELL_ATTR1_IS_SELF_CHANNELED", "Channeled (type 2)", "Both \042channeled\042 attributes have identical handling in server & client" };
case SPELL_ATTR1_IS_SELF_CHANNELED: return { "SPELL_ATTR1_IS_SELF_CHANNELED", "Channeled (type 2)", R"(Both "channeled" attributes have identical handling in server & client)" };
case SPELL_ATTR1_NO_REFLECTION: return { "SPELL_ATTR1_NO_REFLECTION", "Ignore reflection effects", "Spell will pierce through Spell Reflection and similar" };
case SPELL_ATTR1_ONLY_PEACEFUL_TARGETS: return { "SPELL_ATTR1_ONLY_PEACEFUL_TARGETS", "Target cannot be in combat", "" };
case SPELL_ATTR1_INITIATE_COMBAT: return { "SPELL_ATTR1_INITIATE_COMBAT", "Enables Auto-Attack (client only)", "Caster will begin auto-attacking the target on cast" };