mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-02-05 20:13:48 +00:00
refactor(Core): apply clang-tidy modernize-* (#9975)
Co-authored-by: Kitzunu <24550914+Kitzunu@users.noreply.github.com>
This commit is contained in:
@@ -50,9 +50,9 @@ namespace MMAP
|
||||
|
||||
~MMapData()
|
||||
{
|
||||
for (NavMeshQuerySet::iterator i = navMeshQueries.begin(); i != navMeshQueries.end(); ++i)
|
||||
for (auto& navMeshQuerie : navMeshQueries)
|
||||
{
|
||||
dtFreeNavMeshQuery(i->second);
|
||||
dtFreeNavMeshQuery(navMeshQuerie.second);
|
||||
}
|
||||
|
||||
if (navMesh)
|
||||
@@ -74,7 +74,7 @@ namespace MMAP
|
||||
class MMapMgr
|
||||
{
|
||||
public:
|
||||
MMapMgr() : loadedTiles(0), thread_safe_environment(true) { }
|
||||
MMapMgr() = default;
|
||||
~MMapMgr();
|
||||
|
||||
void InitializeThreadUnsafe(const std::vector<uint32>& mapIds);
|
||||
@@ -87,17 +87,17 @@ namespace MMAP
|
||||
dtNavMeshQuery const* GetNavMeshQuery(uint32 mapId, uint32 instanceId);
|
||||
dtNavMesh const* GetNavMesh(uint32 mapId);
|
||||
|
||||
uint32 getLoadedTilesCount() const { return loadedTiles; }
|
||||
uint32 getLoadedMapsCount() const { return loadedMMaps.size(); }
|
||||
[[nodiscard]] uint32 getLoadedTilesCount() const { return loadedTiles; }
|
||||
[[nodiscard]] uint32 getLoadedMapsCount() const { return loadedMMaps.size(); }
|
||||
|
||||
private:
|
||||
bool loadMapData(uint32 mapId);
|
||||
uint32 packTileID(int32 x, int32 y);
|
||||
MMapDataSet::const_iterator GetMMapData(uint32 mapId) const;
|
||||
[[nodiscard]] MMapDataSet::const_iterator GetMMapData(uint32 mapId) const;
|
||||
|
||||
MMapDataSet loadedMMaps;
|
||||
uint32 loadedTiles;
|
||||
bool thread_safe_environment;
|
||||
uint32 loadedTiles{0};
|
||||
bool thread_safe_environment{true};
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -39,18 +39,18 @@ class GameObjectModelOwnerBase
|
||||
public:
|
||||
virtual ~GameObjectModelOwnerBase() = default;
|
||||
|
||||
virtual bool IsSpawned() const = 0;
|
||||
virtual uint32 GetDisplayId() const = 0;
|
||||
virtual uint32 GetPhaseMask() const = 0;
|
||||
virtual G3D::Vector3 GetPosition() const = 0;
|
||||
virtual float GetOrientation() const = 0;
|
||||
virtual float GetScale() const = 0;
|
||||
[[nodiscard]] virtual bool IsSpawned() const = 0;
|
||||
[[nodiscard]] virtual uint32 GetDisplayId() const = 0;
|
||||
[[nodiscard]] virtual uint32 GetPhaseMask() const = 0;
|
||||
[[nodiscard]] virtual G3D::Vector3 GetPosition() const = 0;
|
||||
[[nodiscard]] virtual float GetOrientation() const = 0;
|
||||
[[nodiscard]] virtual float GetScale() const = 0;
|
||||
virtual void DebugVisualizeCorner(G3D::Vector3 const& /*corner*/) const = 0;
|
||||
};
|
||||
|
||||
class GameObjectModel
|
||||
{
|
||||
GameObjectModel() : phasemask(0), iInvScale(0), iScale(0), iModel(nullptr), isWmo(false) { }
|
||||
GameObjectModel() = default;
|
||||
|
||||
public:
|
||||
std::string name;
|
||||
@@ -80,15 +80,15 @@ public:
|
||||
private:
|
||||
bool initialize(std::unique_ptr<GameObjectModelOwnerBase> modelOwner, std::string const& dataPath);
|
||||
|
||||
uint32 phasemask;
|
||||
uint32 phasemask{0};
|
||||
G3D::AABox iBound;
|
||||
G3D::Matrix3 iInvRot;
|
||||
G3D::Vector3 iPos;
|
||||
float iInvScale;
|
||||
float iScale;
|
||||
VMAP::WorldModel* iModel;
|
||||
float iInvScale{0};
|
||||
float iScale{0};
|
||||
VMAP::WorldModel* iModel{nullptr};
|
||||
std::unique_ptr<GameObjectModelOwnerBase> owner;
|
||||
bool isWmo;
|
||||
bool isWmo{false};
|
||||
};
|
||||
|
||||
void LoadGameObjectModelList(std::string const& dataPath);
|
||||
|
||||
@@ -41,7 +41,7 @@ public:
|
||||
|
||||
std::string const GetFilename();
|
||||
std::string const GetConfigPath();
|
||||
std::vector<std::string> const& GetArguments() const;
|
||||
[[nodiscard]] std::vector<std::string> const& GetArguments() const;
|
||||
std::vector<std::string> GetKeysByString(std::string const& name);
|
||||
|
||||
template<class T>
|
||||
|
||||
@@ -85,28 +85,28 @@ public:
|
||||
return t <<= n;
|
||||
}
|
||||
|
||||
int CompareTo(BigNumber const& bn) const;
|
||||
[[nodiscard]] int CompareTo(BigNumber const& bn) const;
|
||||
bool operator<=(BigNumber const& bn) const { return (CompareTo(bn) <= 0); }
|
||||
bool operator==(BigNumber const& bn) const { return (CompareTo(bn) == 0); }
|
||||
bool operator>=(BigNumber const& bn) const { return (CompareTo(bn) >= 0); }
|
||||
bool operator<(BigNumber const& bn) const { return (CompareTo(bn) < 0); }
|
||||
bool operator>(BigNumber const& bn) const { return (CompareTo(bn) > 0); }
|
||||
|
||||
bool IsZero() const;
|
||||
bool IsNegative() const;
|
||||
[[nodiscard]] bool IsZero() const;
|
||||
[[nodiscard]] bool IsNegative() const;
|
||||
|
||||
BigNumber ModExp(BigNumber const& bn1, BigNumber const& bn2) const;
|
||||
BigNumber Exp(BigNumber const&) const;
|
||||
[[nodiscard]] BigNumber ModExp(BigNumber const& bn1, BigNumber const& bn2) const;
|
||||
[[nodiscard]] BigNumber Exp(BigNumber const&) const;
|
||||
|
||||
int32 GetNumBytes() const;
|
||||
[[nodiscard]] int32 GetNumBytes() const;
|
||||
|
||||
struct bignum_st* BN() { return _bn; }
|
||||
struct bignum_st const* BN() const { return _bn; }
|
||||
[[nodiscard]] struct bignum_st const* BN() const { return _bn; }
|
||||
|
||||
uint32 AsDword() const;
|
||||
[[nodiscard]] uint32 AsDword() const;
|
||||
|
||||
void GetBytes(uint8* buf, size_t bufsize, bool littleEndian = true) const;
|
||||
std::vector<uint8> ToByteVector(int32 minSize = 0, bool littleEndian = true) const;
|
||||
[[nodiscard]] std::vector<uint8> ToByteVector(int32 minSize = 0, bool littleEndian = true) const;
|
||||
|
||||
template <std::size_t Size>
|
||||
std::array<uint8, Size> ToByteArray(bool littleEndian = true) const
|
||||
@@ -116,8 +116,8 @@ public:
|
||||
return buf;
|
||||
}
|
||||
|
||||
std::string AsHexStr() const;
|
||||
std::string AsDecStr() const;
|
||||
[[nodiscard]] std::string AsHexStr() const;
|
||||
[[nodiscard]] std::string AsDecStr() const;
|
||||
|
||||
private:
|
||||
struct bignum_st* _bn;
|
||||
|
||||
@@ -29,10 +29,10 @@ class LinkedListElement
|
||||
private:
|
||||
friend class LinkedListHead;
|
||||
|
||||
LinkedListElement* iNext;
|
||||
LinkedListElement* iPrev;
|
||||
LinkedListElement* iNext{nullptr};
|
||||
LinkedListElement* iPrev{nullptr};
|
||||
public:
|
||||
LinkedListElement(): iNext(nullptr), iPrev(nullptr) { }
|
||||
LinkedListElement() = default;
|
||||
~LinkedListElement() { delink(); }
|
||||
|
||||
[[nodiscard]] bool hasNext() const { return (iNext && iNext->iNext != nullptr); }
|
||||
|
||||
@@ -150,7 +150,7 @@ public:
|
||||
}
|
||||
|
||||
template<class SPECIFIC_TYPE>
|
||||
std::size_t Size() const
|
||||
[[nodiscard]] std::size_t Size() const
|
||||
{
|
||||
std::size_t size = 0;
|
||||
Acore::Size(_elements, &size, (SPECIFIC_TYPE*)nullptr);
|
||||
@@ -158,7 +158,7 @@ public:
|
||||
}
|
||||
|
||||
ContainerUnorderedMap<OBJECT_TYPES, KEY_TYPE>& GetElements() { return _elements; }
|
||||
ContainerUnorderedMap<OBJECT_TYPES, KEY_TYPE> const& GetElements() const { return _elements; }
|
||||
[[nodiscard]] ContainerUnorderedMap<OBJECT_TYPES, KEY_TYPE> const& GetElements() const { return _elements; }
|
||||
|
||||
private:
|
||||
ContainerUnorderedMap<OBJECT_TYPES, KEY_TYPE> _elements;
|
||||
|
||||
@@ -57,7 +57,7 @@ public:
|
||||
void Initialize();
|
||||
void LoadFromConfig();
|
||||
void Close();
|
||||
bool ShouldLog(std::string const& type, LogLevel level) const;
|
||||
[[nodiscard]] bool ShouldLog(std::string const& type, LogLevel level) const;
|
||||
bool SetLogLevel(std::string const& name, int32 level, bool isLogger = true);
|
||||
|
||||
template<typename Format, typename... Args>
|
||||
@@ -93,8 +93,8 @@ public:
|
||||
RegisterAppender(AppenderImpl::type, &CreateAppender<AppenderImpl>);
|
||||
}
|
||||
|
||||
std::string const& GetLogsDir() const { return m_logsDir; }
|
||||
std::string const& GetLogsTimestamp() const { return m_logsTimestamp; }
|
||||
[[nodiscard]] std::string const& GetLogsDir() const { return m_logsDir; }
|
||||
[[nodiscard]] std::string const& GetLogsTimestamp() const { return m_logsTimestamp; }
|
||||
|
||||
// Deprecated functions
|
||||
template<typename Format, typename... Args>
|
||||
@@ -185,7 +185,7 @@ private:
|
||||
static std::string GetTimestampStr();
|
||||
void write(std::unique_ptr<LogMessage>&& msg) const;
|
||||
|
||||
Logger const* GetLoggerByType(std::string const& type) const;
|
||||
[[nodiscard]] Logger const* GetLoggerByType(std::string const& type) const;
|
||||
Appender* GetAppenderByName(std::string_view name);
|
||||
uint8 NextAppenderId();
|
||||
void CreateAppenderFromConfig(std::string const& name);
|
||||
|
||||
@@ -31,20 +31,15 @@ class LockedQueue
|
||||
StorageType _queue;
|
||||
|
||||
//! Cancellation flag.
|
||||
volatile bool _canceled;
|
||||
volatile bool _canceled{false};
|
||||
|
||||
public:
|
||||
|
||||
//! Create a LockedQueue.
|
||||
LockedQueue()
|
||||
: _canceled(false)
|
||||
{
|
||||
}
|
||||
LockedQueue() = default;
|
||||
|
||||
//! Destroy a LockedQueue.
|
||||
virtual ~LockedQueue()
|
||||
{
|
||||
}
|
||||
virtual ~LockedQueue() = default;
|
||||
|
||||
//! Adds an item to the queue.
|
||||
void add(const T& item)
|
||||
|
||||
@@ -51,7 +51,7 @@ public:
|
||||
return _queue.empty();
|
||||
}
|
||||
|
||||
size_t Size() const
|
||||
[[nodiscard]] size_t Size() const
|
||||
{
|
||||
return _queue.size();
|
||||
}
|
||||
|
||||
@@ -40,24 +40,24 @@ public:
|
||||
full_ = head_ == tail_;
|
||||
}
|
||||
|
||||
bool empty() const
|
||||
[[nodiscard]] bool empty() const
|
||||
{
|
||||
//if head and tail are equal, we are empty
|
||||
return (!full_ && (head_ == tail_));
|
||||
}
|
||||
|
||||
bool full() const
|
||||
[[nodiscard]] bool full() const
|
||||
{
|
||||
//If tail is ahead the head by 1, we are full
|
||||
return full_;
|
||||
}
|
||||
|
||||
size_t capacity() const
|
||||
[[nodiscard]] size_t capacity() const
|
||||
{
|
||||
return max_size_;
|
||||
}
|
||||
|
||||
size_t size() const
|
||||
[[nodiscard]] size_t size() const
|
||||
{
|
||||
size_t size = max_size_;
|
||||
|
||||
@@ -98,6 +98,6 @@ private:
|
||||
size_t head_ = 0;
|
||||
size_t tail_ = 0;
|
||||
const size_t max_size_;
|
||||
bool full_ = 0;
|
||||
bool full_ = false;
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -43,9 +43,9 @@ class BasicEvent
|
||||
|
||||
public:
|
||||
BasicEvent()
|
||||
: m_abortState(AbortState::STATE_RUNNING), m_addTime(0), m_execTime(0) { }
|
||||
= default;
|
||||
|
||||
virtual ~BasicEvent() { } // override destructor to perform some actions on event removal
|
||||
virtual ~BasicEvent() = default; // override destructor to perform some actions on event removal
|
||||
|
||||
// this method executes when the event is triggered
|
||||
// return false if event does not want to be deleted
|
||||
@@ -61,15 +61,15 @@ class BasicEvent
|
||||
|
||||
private:
|
||||
void SetAborted();
|
||||
bool IsRunning() const { return (m_abortState == AbortState::STATE_RUNNING); }
|
||||
bool IsAbortScheduled() const { return (m_abortState == AbortState::STATE_ABORT_SCHEDULED); }
|
||||
bool IsAborted() const { return (m_abortState == AbortState::STATE_ABORTED); }
|
||||
[[nodiscard]] bool IsRunning() const { return (m_abortState == AbortState::STATE_RUNNING); }
|
||||
[[nodiscard]] bool IsAbortScheduled() const { return (m_abortState == AbortState::STATE_ABORT_SCHEDULED); }
|
||||
[[nodiscard]] bool IsAborted() const { return (m_abortState == AbortState::STATE_ABORTED); }
|
||||
|
||||
AbortState m_abortState; // set by externals when the event is aborted, aborted events don't execute
|
||||
AbortState m_abortState{AbortState::STATE_RUNNING}; // set by externals when the event is aborted, aborted events don't execute
|
||||
|
||||
// these can be used for time offset control
|
||||
uint64 m_addTime; // time when the event was added to queue, filled by event handler
|
||||
uint64 m_execTime; // planned time of next execution, filled by event handler
|
||||
uint64 m_addTime{0}; // time when the event was added to queue, filled by event handler
|
||||
uint64 m_execTime{0}; // planned time of next execution, filled by event handler
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
@@ -97,7 +97,7 @@ typedef std::multimap<uint64, BasicEvent*> EventList;
|
||||
class EventProcessor
|
||||
{
|
||||
public:
|
||||
EventProcessor() : m_time(0) { }
|
||||
EventProcessor() = default;
|
||||
~EventProcessor();
|
||||
|
||||
void Update(uint32 p_time);
|
||||
@@ -118,7 +118,7 @@ class EventProcessor
|
||||
[[nodiscard]] uint64 CalculateQueueTime(uint64 delay) const;
|
||||
|
||||
protected:
|
||||
uint64 m_time;
|
||||
uint64 m_time{0};
|
||||
EventList m_events;
|
||||
bool m_aborting;
|
||||
};
|
||||
|
||||
@@ -27,7 +27,7 @@ class MessageBuffer
|
||||
using size_type = std::vector<uint8>::size_type;
|
||||
|
||||
public:
|
||||
MessageBuffer() : _wpos(0), _rpos(0), _storage()
|
||||
MessageBuffer() : _storage()
|
||||
{
|
||||
_storage.resize(4096);
|
||||
}
|
||||
@@ -132,8 +132,8 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
size_type _wpos;
|
||||
size_type _rpos;
|
||||
size_type _wpos{0};
|
||||
size_type _rpos{0};
|
||||
std::vector<uint8> _storage;
|
||||
};
|
||||
|
||||
|
||||
@@ -68,8 +68,7 @@ struct IntervalTimer
|
||||
public:
|
||||
IntervalTimer()
|
||||
|
||||
{
|
||||
}
|
||||
= default;
|
||||
|
||||
void Update(time_t diff)
|
||||
{
|
||||
|
||||
@@ -653,7 +653,7 @@ class EventMap
|
||||
typedef std::multimap<uint32, uint32> EventStore;
|
||||
|
||||
public:
|
||||
EventMap() { }
|
||||
EventMap() = default;
|
||||
|
||||
/**
|
||||
* @name Reset
|
||||
|
||||
Reference in New Issue
Block a user