diff options
-rw-r--r-- | src/server/shared/DataStores/DBCDatabaseLoader.cpp | 2 | ||||
-rw-r--r-- | src/server/shared/DataStores/DBCEnums.h | 8 | ||||
-rw-r--r-- | src/server/shared/Network/AsyncAcceptor.h | 12 | ||||
-rw-r--r-- | src/server/shared/Network/Socket.h | 8 | ||||
-rw-r--r-- | src/server/shared/Network/SocketMgr.h | 4 | ||||
-rw-r--r-- | src/server/shared/Packets/ByteBuffer.cpp | 4 | ||||
-rw-r--r-- | src/server/shared/Packets/ByteBuffer.h | 6 | ||||
-rw-r--r-- | src/server/shared/Realms/Realm.cpp | 4 | ||||
-rw-r--r-- | src/server/shared/Realms/RealmList.cpp | 12 | ||||
-rw-r--r-- | src/server/shared/Realms/RealmList.h | 2 |
10 files changed, 25 insertions, 37 deletions
diff --git a/src/server/shared/DataStores/DBCDatabaseLoader.cpp b/src/server/shared/DataStores/DBCDatabaseLoader.cpp index e24fea2855..37e2884d64 100644 --- a/src/server/shared/DataStores/DBCDatabaseLoader.cpp +++ b/src/server/shared/DataStores/DBCDatabaseLoader.cpp @@ -39,7 +39,7 @@ char* DBCDatabaseLoader::Load(uint32& records, char**& indexTable) std::string query = Acore::StringFormat("SELECT * FROM `%s` ORDER BY `ID` DESC", _sqlTableName); // no error if empty set - QueryResult result = WorldDatabase.Query(query.c_str()); + QueryResult result = WorldDatabase.Query(query); if (!result) return nullptr; diff --git a/src/server/shared/DataStores/DBCEnums.h b/src/server/shared/DataStores/DBCEnums.h index 28874b0fe3..b0b6b45d65 100644 --- a/src/server/shared/DataStores/DBCEnums.h +++ b/src/server/shared/DataStores/DBCEnums.h @@ -21,20 +21,12 @@ #include "Define.h" #pragma pack(push, 1) - -struct DBCPosition2D -{ - float X; - float Y; -}; - struct DBCPosition3D { float X; float Y; float Z; }; - #pragma pack(pop) // Client expected level limitation, like as used in DBC item max levels for "until max player level" diff --git a/src/server/shared/Network/AsyncAcceptor.h b/src/server/shared/Network/AsyncAcceptor.h index bce5eb133d..803906ee6f 100644 --- a/src/server/shared/Network/AsyncAcceptor.h +++ b/src/server/shared/Network/AsyncAcceptor.h @@ -27,11 +27,7 @@ using boost::asio::ip::tcp; -#if BOOST_VERSION >= 106600 -#define ACORE_MAX_LISTEN_CONNECTIONS boost::asio::socket_base::max_listen_connections -#else -#define ACORE_MAX_LISTEN_CONNECTIONS boost::asio::socket_base::max_connections -#endif +constexpr auto ACORE_MAX_LISTEN_CONNECTIONS = boost::asio::socket_base::max_listen_connections; class AsyncAcceptor { @@ -40,7 +36,7 @@ public: AsyncAcceptor(Acore::Asio::IoContext& ioContext, std::string const& bindIp, uint16 port) : _acceptor(ioContext), _endpoint(Acore::Net::make_address(bindIp), port), - _socket(ioContext), _closed(false), _socketFactory(std::bind(&AsyncAcceptor::DefeaultSocketFactory, this)) + _socket(ioContext), _closed(false), _socketFactory([this](){ return DefaultSocketFactory(); }) { } @@ -122,7 +118,7 @@ public: void SetSocketFactory(std::function<std::pair<tcp::socket*, uint32>()> func) { _socketFactory = func; } private: - std::pair<tcp::socket*, uint32> DefeaultSocketFactory() { return std::make_pair(&_socket, 0); } + std::pair<tcp::socket*, uint32> DefaultSocketFactory() { return std::make_pair(&_socket, 0); } tcp::acceptor _acceptor; tcp::endpoint _endpoint; @@ -155,4 +151,4 @@ void AsyncAcceptor::AsyncAccept() }); } -#endif /* __ASYNCACCEPT_H_ */ +#endif /* __ASYNC ACCEPT_H_ */ diff --git a/src/server/shared/Network/Socket.h b/src/server/shared/Network/Socket.h index fc79a80dcb..0bf100b2a3 100644 --- a/src/server/shared/Network/Socket.h +++ b/src/server/shared/Network/Socket.h @@ -73,12 +73,12 @@ public: return true; } - boost::asio::ip::address GetRemoteIpAddress() const + [[nodiscard]] boost::asio::ip::address GetRemoteIpAddress() const { return _remoteAddress; } - uint16 GetRemotePort() const + [[nodiscard]] uint16 GetRemotePort() const { return _remotePort; } @@ -120,7 +120,7 @@ public: #endif } - bool IsOpen() const { return !_closed && !_closing; } + [[nodiscard]] bool IsOpen() const { return !_closed && !_closing; } void CloseSocket() { @@ -146,7 +146,7 @@ protected: virtual void OnClose() { } virtual void ReadHandler() = 0; - bool AsyncProcessQueue() + [[nodiscard]] bool AsyncProcessQueue() { if (_isWritingAsync) return false; diff --git a/src/server/shared/Network/SocketMgr.h b/src/server/shared/Network/SocketMgr.h index 19234fa715..02720b2055 100644 --- a/src/server/shared/Network/SocketMgr.h +++ b/src/server/shared/Network/SocketMgr.h @@ -104,9 +104,9 @@ public: } } - int32 GetNetworkThreadCount() const { return _threadCount; } + [[nodiscard]] int32 GetNetworkThreadCount() const { return _threadCount; } - uint32 SelectThreadWithMinConnections() const + [[nodiscard]] uint32 SelectThreadWithMinConnections() const { uint32 min = 0; diff --git a/src/server/shared/Packets/ByteBuffer.cpp b/src/server/shared/Packets/ByteBuffer.cpp index b3ae4b5330..ce0f85b3ac 100644 --- a/src/server/shared/Packets/ByteBuffer.cpp +++ b/src/server/shared/Packets/ByteBuffer.cpp @@ -78,7 +78,7 @@ std::string ByteBuffer::ReadCString(bool requireValidUtf8 /*= true*/) { std::string value; - while (rpos() < size()) // prevent crash at wrong string format in packet + while (rpos() < size()) // prevent crash the wrong string format in a packet { char c = read<char>(); if (c == 0) @@ -94,7 +94,7 @@ std::string ByteBuffer::ReadCString(bool requireValidUtf8 /*= true*/) uint32 ByteBuffer::ReadPackedTime() { - uint32 packedDate = read<uint32>(); + auto packedDate = read<uint32>(); tm lt = tm(); lt.tm_min = packedDate & 0x3F; diff --git a/src/server/shared/Packets/ByteBuffer.h b/src/server/shared/Packets/ByteBuffer.h index d1d2ef7d8d..82e8d6521f 100644 --- a/src/server/shared/Packets/ByteBuffer.h +++ b/src/server/shared/Packets/ByteBuffer.h @@ -69,7 +69,7 @@ public: class AC_SHARED_API ByteBuffer { public: - constexpr static size_t DEFAULT_SIZE = 0x1000; + constexpr static std::size_t DEFAULT_SIZE = 0x1000; // constructor ByteBuffer() @@ -77,7 +77,7 @@ public: _storage.reserve(DEFAULT_SIZE); } - ByteBuffer(size_t reserve) : _rpos(0), _wpos(0) + explicit ByteBuffer(std::size_t reserve) : _rpos(0), _wpos(0) { _storage.reserve(reserve); } @@ -90,7 +90,7 @@ public: } ByteBuffer(ByteBuffer const& right) = default; - ByteBuffer(MessageBuffer&& buffer); + explicit ByteBuffer(MessageBuffer&& buffer); virtual ~ByteBuffer() = default; ByteBuffer& operator=(ByteBuffer const& right) diff --git a/src/server/shared/Realms/Realm.cpp b/src/server/shared/Realms/Realm.cpp index 8c1355af29..f816379772 100644 --- a/src/server/shared/Realms/Realm.cpp +++ b/src/server/shared/Realms/Realm.cpp @@ -24,7 +24,7 @@ boost::asio::ip::tcp_endpoint Realm::GetAddressForClient(boost::asio::ip::addres { boost::asio::ip::address realmIp; - // Attempt to send best address for client + // Attempt to send best address for a client if (clientAddr.is_loopback()) { // Try guessing if realm is also connected locally @@ -52,5 +52,5 @@ boost::asio::ip::tcp_endpoint Realm::GetAddressForClient(boost::asio::ip::addres } // Return external IP - return boost::asio::ip::tcp_endpoint(realmIp, Port); + return { realmIp, Port }; } diff --git a/src/server/shared/Realms/RealmList.cpp b/src/server/shared/Realms/RealmList.cpp index 9b991d8645..5ab14b0166 100644 --- a/src/server/shared/Realms/RealmList.cpp +++ b/src/server/shared/Realms/RealmList.cpp @@ -92,7 +92,7 @@ void RealmList::LoadBuildInfo() void RealmList::UpdateRealm(RealmHandle const& id, uint32 build, std::string const& name, boost::asio::ip::address&& address, boost::asio::ip::address&& localAddr, boost::asio::ip::address&& localSubmask, - uint16 port, uint8 icon, RealmFlags flag, uint8 timezone, AccountTypes allowedSecurityLevel, float population) + uint16 port, uint8 icon, RealmFlags flag, uint8 realmTimezone, AccountTypes allowedSecurityLevel, float population) { // Create new if not exist or update existed Realm& realm = _realms[id]; @@ -102,7 +102,7 @@ void RealmList::UpdateRealm(RealmHandle const& id, uint32 build, std::string con realm.Name = name; realm.Type = icon; realm.Flags = flag; - realm.Timezone = timezone; + realm.Timezone = realmTimezone; realm.AllowedSecurityLevel = allowedSecurityLevel; realm.PopulationLevel = population; @@ -192,8 +192,8 @@ void RealmList::UpdateRealms(boost::system::error_code const& error) icon = REALM_TYPE_NORMAL; } - RealmFlags flag = RealmFlags(fields[7].Get<uint8>()); - uint8 timezone = fields[8].Get<uint8>(); + auto flag = RealmFlags(fields[7].Get<uint8>()); + uint8 realmTimezone = fields[8].Get<uint8>(); uint8 allowedSecurityLevel = fields[9].Get<uint8>(); float pop = fields[10].Get<float>(); uint32 build = fields[11].Get<uint32>(); @@ -201,7 +201,7 @@ void RealmList::UpdateRealms(boost::system::error_code const& error) RealmHandle id{ realmId }; UpdateRealm(id, build, name, externalAddress->address(), localAddress->address(), localSubmask->address(), port, icon, flag, - timezone, (allowedSecurityLevel <= SEC_ADMINISTRATOR ? AccountTypes(allowedSecurityLevel) : SEC_ADMINISTRATOR), pop); + realmTimezone, (allowedSecurityLevel <= SEC_ADMINISTRATOR ? AccountTypes(allowedSecurityLevel) : SEC_ADMINISTRATOR), pop); if (!existingRealms.count(id)) { @@ -228,7 +228,7 @@ void RealmList::UpdateRealms(boost::system::error_code const& error) if (_updateInterval) { _updateTimer->expires_from_now(boost::posix_time::seconds(_updateInterval)); - _updateTimer->async_wait(std::bind(&RealmList::UpdateRealms, this, std::placeholders::_1)); + _updateTimer->async_wait([this](boost::system::error_code const& errorCode){ UpdateRealms(errorCode); }); } } diff --git a/src/server/shared/Realms/RealmList.h b/src/server/shared/Realms/RealmList.h index c8b98caf2c..b82ed816b6 100644 --- a/src/server/shared/Realms/RealmList.h +++ b/src/server/shared/Realms/RealmList.h @@ -65,7 +65,7 @@ private: void UpdateRealms(boost::system::error_code const& error); void UpdateRealm(RealmHandle const& id, uint32 build, std::string const& name, boost::asio::ip::address&& address, boost::asio::ip::address&& localAddr, boost::asio::ip::address&& localSubmask, - uint16 port, uint8 icon, RealmFlags flag, uint8 timezone, AccountTypes allowedSecurityLevel, float population); + uint16 port, uint8 icon, RealmFlags flag, uint8 realmTimezone, AccountTypes allowedSecurityLevel, float population); std::vector<RealmBuildInfo> _builds; RealmMap _realms; |