mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-24 22:26:22 +00:00
Merge branch 'master' into Playerbot
This commit is contained in:
@@ -18,6 +18,8 @@
|
||||
#ifndef DBCENUMS_H
|
||||
#define DBCENUMS_H
|
||||
|
||||
#include "Define.h"
|
||||
|
||||
#pragma pack(push, 1)
|
||||
|
||||
struct DBCPosition2D
|
||||
@@ -48,7 +50,7 @@ struct DBCPosition3D
|
||||
// also see MAX_LEVEL and GT_MAX_LEVEL define
|
||||
#define STRONG_MAX_LEVEL 255
|
||||
|
||||
enum BattlegroundBracketId // bracketId for level ranges
|
||||
enum BattlegroundBracketId : uint8 // bracketId for level ranges
|
||||
{
|
||||
BG_BRACKET_ID_FIRST = 0,
|
||||
BG_BRACKET_ID_LAST = 15
|
||||
@@ -268,7 +270,7 @@ enum AreaFlags
|
||||
AREA_FLAG_NO_FLY_ZONE = 0x20000000 // Marks zones where you cannot fly
|
||||
};
|
||||
|
||||
enum Difficulty
|
||||
enum Difficulty : uint8
|
||||
{
|
||||
REGULAR_DIFFICULTY = 0,
|
||||
|
||||
|
||||
@@ -38,8 +38,8 @@ template<class SocketType>
|
||||
class NetworkThread
|
||||
{
|
||||
public:
|
||||
NetworkThread() : _connections(0), _stopped(false), _thread(nullptr), _ioContext(1),
|
||||
_acceptSocket(_ioContext), _updateTimer(_ioContext) { }
|
||||
NetworkThread() :
|
||||
_ioContext(1), _acceptSocket(_ioContext), _updateTimer(_ioContext) { }
|
||||
|
||||
virtual ~NetworkThread()
|
||||
{
|
||||
@@ -48,7 +48,6 @@ public:
|
||||
if (_thread)
|
||||
{
|
||||
Wait();
|
||||
delete _thread;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,7 +62,7 @@ public:
|
||||
if (_thread)
|
||||
return false;
|
||||
|
||||
_thread = new std::thread(&NetworkThread::Run, this);
|
||||
_thread = std::make_unique<std::thread>([this]() { NetworkThread::Run(); });
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -71,12 +70,15 @@ public:
|
||||
{
|
||||
ASSERT(_thread);
|
||||
|
||||
_thread->join();
|
||||
delete _thread;
|
||||
_thread = nullptr;
|
||||
if (_thread->joinable())
|
||||
{
|
||||
_thread->join();
|
||||
}
|
||||
|
||||
_thread.reset();
|
||||
}
|
||||
|
||||
int32 GetConnectionCount() const
|
||||
[[nodiscard]] int32 GetConnectionCount() const
|
||||
{
|
||||
return _connections;
|
||||
}
|
||||
@@ -86,7 +88,7 @@ public:
|
||||
std::lock_guard<std::mutex> lock(_newSocketsLock);
|
||||
|
||||
++_connections;
|
||||
_newSockets.push_back(sock);
|
||||
_newSockets.emplace_back(sock);
|
||||
SocketAdded(sock);
|
||||
}
|
||||
|
||||
@@ -111,7 +113,9 @@ protected:
|
||||
--_connections;
|
||||
}
|
||||
else
|
||||
_sockets.push_back(sock);
|
||||
{
|
||||
_sockets.emplace_back(sock);
|
||||
}
|
||||
}
|
||||
|
||||
_newSockets.clear();
|
||||
@@ -158,12 +162,12 @@ protected:
|
||||
}
|
||||
|
||||
private:
|
||||
typedef std::vector<std::shared_ptr<SocketType>> SocketContainer;
|
||||
using SocketContainer = std::vector<std::shared_ptr<SocketType>>;
|
||||
|
||||
std::atomic<int32> _connections;
|
||||
std::atomic<bool> _stopped;
|
||||
std::atomic<int32> _connections{};
|
||||
std::atomic<bool> _stopped{};
|
||||
|
||||
std::thread* _thread;
|
||||
std::unique_ptr<std::thread> _thread;
|
||||
|
||||
SocketContainer _sockets;
|
||||
|
||||
|
||||
@@ -39,10 +39,10 @@ public:
|
||||
{
|
||||
ASSERT(threadCount > 0);
|
||||
|
||||
AsyncAcceptor* acceptor = nullptr;
|
||||
std::unique_ptr<AsyncAcceptor> acceptor;
|
||||
try
|
||||
{
|
||||
acceptor = new AsyncAcceptor(ioContext, bindIp, port);
|
||||
acceptor = std::make_unique<AsyncAcceptor>(ioContext, bindIp, port);
|
||||
}
|
||||
catch (boost::system::system_error const& err)
|
||||
{
|
||||
@@ -53,13 +53,12 @@ public:
|
||||
if (!acceptor->Bind())
|
||||
{
|
||||
LOG_ERROR("network", "StartNetwork failed to bind socket acceptor");
|
||||
delete acceptor;
|
||||
return false;
|
||||
}
|
||||
|
||||
_acceptor = acceptor;
|
||||
_acceptor = std::move(acceptor);
|
||||
_threadCount = threadCount;
|
||||
_threads = CreateThreads();
|
||||
_threads = std::unique_ptr<NetworkThread<SocketType>[]>(CreateThreads());
|
||||
|
||||
ASSERT(_threads);
|
||||
|
||||
@@ -67,7 +66,6 @@ public:
|
||||
_threads[i].Start();
|
||||
|
||||
_acceptor->SetSocketFactory([this]() { return GetSocketForAccept(); });
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -75,24 +73,20 @@ public:
|
||||
{
|
||||
_acceptor->Close();
|
||||
|
||||
if (_threadCount != 0)
|
||||
for (int32 i = 0; i < _threadCount; ++i)
|
||||
_threads[i].Stop();
|
||||
for (int32 i = 0; i < _threadCount; ++i)
|
||||
_threads[i].Stop();
|
||||
|
||||
Wait();
|
||||
|
||||
delete _acceptor;
|
||||
_acceptor = nullptr;
|
||||
delete[] _threads;
|
||||
_threads = nullptr;
|
||||
_acceptor.reset();
|
||||
_threads.reset();
|
||||
_threadCount = 0;
|
||||
}
|
||||
|
||||
void Wait()
|
||||
{
|
||||
if (_threadCount != 0)
|
||||
for (int32 i = 0; i < _threadCount; ++i)
|
||||
_threads[i].Wait();
|
||||
for (int32 i = 0; i < _threadCount; ++i)
|
||||
_threads[i].Wait();
|
||||
}
|
||||
|
||||
virtual void OnSocketOpen(tcp::socket&& sock, uint32 threadIndex)
|
||||
@@ -126,18 +120,17 @@ public:
|
||||
std::pair<tcp::socket*, uint32> GetSocketForAccept()
|
||||
{
|
||||
uint32 threadIndex = SelectThreadWithMinConnections();
|
||||
return std::make_pair(_threads[threadIndex].GetSocketForAccept(), threadIndex);
|
||||
return { _threads[threadIndex].GetSocketForAccept(), threadIndex };
|
||||
}
|
||||
|
||||
protected:
|
||||
SocketMgr() :
|
||||
_acceptor(nullptr), _threads(nullptr), _threadCount(0) { }
|
||||
SocketMgr() = default;
|
||||
|
||||
virtual NetworkThread<SocketType>* CreateThreads() const = 0;
|
||||
|
||||
AsyncAcceptor* _acceptor;
|
||||
NetworkThread<SocketType>* _threads;
|
||||
int32 _threadCount;
|
||||
std::unique_ptr<AsyncAcceptor> _acceptor;
|
||||
std::unique_ptr<NetworkThread<SocketType>[]> _threads;
|
||||
int32 _threadCount{};
|
||||
};
|
||||
|
||||
#endif // SocketMgr_h__
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#ifndef ACORE_SHAREDDEFINES_H
|
||||
#define ACORE_SHAREDDEFINES_H
|
||||
|
||||
#include "DBCEnums.h"
|
||||
#include "Define.h"
|
||||
#include "EnumFlag.h"
|
||||
#include <cassert>
|
||||
@@ -25,7 +26,7 @@
|
||||
float const GROUND_HEIGHT_TOLERANCE = 0.05f; // Extra tolerance to z position to check if it is in air or on ground.
|
||||
constexpr float Z_OFFSET_FIND_HEIGHT = 2.0f;
|
||||
|
||||
enum SpellEffIndex
|
||||
enum SpellEffIndex : uint8
|
||||
{
|
||||
EFFECT_0 = 0,
|
||||
EFFECT_1 = 1,
|
||||
@@ -105,6 +106,33 @@ enum Races
|
||||
|
||||
#define RACEMASK_HORDE RACEMASK_ALL_PLAYABLE & ~RACEMASK_ALLIANCE
|
||||
|
||||
// DisplayRace values from CreatureDisplayInfoExtra.dbc
|
||||
enum class DisplayRace : uint8
|
||||
{
|
||||
None = 0,
|
||||
Human = 1,
|
||||
Orc = 2,
|
||||
Dwarf = 3,
|
||||
NightElf = 4,
|
||||
Undead = 5,
|
||||
Tauren = 6,
|
||||
Gnome = 7,
|
||||
Troll = 8,
|
||||
Goblin = 9,
|
||||
BloodElf = 10,
|
||||
Draenei = 11,
|
||||
FelOrc = 12,
|
||||
Naga = 13,
|
||||
Broken = 14,
|
||||
Skeleton = 15,
|
||||
Vrykul = 16,
|
||||
Tuskarr = 17,
|
||||
ForestTroll = 18,
|
||||
Taunka = 19,
|
||||
NorthrendSkeleton = 20,
|
||||
IceTroll = 21
|
||||
};
|
||||
|
||||
// Class value is index in ChrClasses.dbc
|
||||
// EnumUtils: DESCRIBE THIS
|
||||
enum Classes
|
||||
@@ -147,7 +175,7 @@ enum UnitClass
|
||||
|
||||
#define PLAYER_MAX_BATTLEGROUND_QUEUES 2
|
||||
|
||||
enum ReputationRank
|
||||
enum ReputationRank : uint8
|
||||
{
|
||||
REP_HATED = 0,
|
||||
REP_HOSTILE = 1,
|
||||
@@ -727,7 +755,7 @@ enum Language
|
||||
|
||||
#define LANGUAGES_COUNT 19
|
||||
|
||||
enum TeamId
|
||||
enum TeamId : uint8
|
||||
{
|
||||
TEAM_ALLIANCE = 0,
|
||||
TEAM_HORDE,
|
||||
@@ -3545,7 +3573,7 @@ enum TradeStatus
|
||||
TRADE_STATUS_NOT_ELIGIBLE = 23 // Related to trading soulbound loot items
|
||||
};
|
||||
|
||||
enum XPColorChar
|
||||
enum XPColorChar : uint8
|
||||
{
|
||||
XP_RED,
|
||||
XP_ORANGE,
|
||||
@@ -3554,7 +3582,7 @@ enum XPColorChar
|
||||
XP_GRAY
|
||||
};
|
||||
|
||||
enum RemoveMethod
|
||||
enum RemoveMethod : uint8
|
||||
{
|
||||
GROUP_REMOVEMETHOD_DEFAULT = 0,
|
||||
GROUP_REMOVEMETHOD_KICK = 1,
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "SharedDefines.h"
|
||||
#include "Define.h"
|
||||
#include "SharedDefines.h"
|
||||
#include "SmartEnum.h"
|
||||
#include <stdexcept>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user