mirror of
https://github.com/araxiaonline/TrinityCore2.git
synced 2026-06-13 03:22:40 -04:00
Update Queue initialization and implement basic support for joining queue for battleground
This commit is contained in:
@@ -139,6 +139,9 @@ class BattlegroundMgr
|
||||
typedef std::map<BattlegroundTypeId, BattlegroundTemplate> BattlegroundTemplateMap;
|
||||
typedef std::map<uint32, BattlegroundMap*> BattlegroundMaps;
|
||||
|
||||
friend class BattlegroundQueue;
|
||||
friend class BattlegroundQueueMgr;
|
||||
|
||||
BattlegroundTemplate const* GetBattlegroundTemplate(BattlegroundTypeId id)
|
||||
{
|
||||
BattlegroundTemplateMap::const_iterator itr = _battlegroundTemplates.find(id);
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
#include "BattlegroundQueue.h"
|
||||
#include "BattlegroundMgr.h"
|
||||
#include "DBCStores.h"
|
||||
#include "Log.h"
|
||||
|
||||
/*
|
||||
@@ -25,8 +26,8 @@ Battleground Queue System
|
||||
============================================================================================
|
||||
*/
|
||||
|
||||
namespace Battleground
|
||||
{
|
||||
//namespace Battleground
|
||||
//{
|
||||
/**********************************************************************************************//**
|
||||
* \fn void BattlegroundQueue::Insert( BattlegroundQueueElement* element )
|
||||
*
|
||||
@@ -90,10 +91,21 @@ void BattlegroundQueue::Insert( BattlegroundQueueElement* element )
|
||||
//! Prevent these teams from being re-scheduled for a different match
|
||||
//! whenever a new team queues.
|
||||
element->InviteScheduled = true;
|
||||
front->InviteScheduled = true;
|
||||
(*itr)->InviteScheduled = true;
|
||||
|
||||
}
|
||||
else //! Battleground
|
||||
{
|
||||
element->Data.Faction == ALLIANCE ?
|
||||
_variables._ahCount.AllianceCount += element->Players.size() :
|
||||
_variables._ahCount.HordeCount += element->Players.size();
|
||||
|
||||
} // isArena
|
||||
if (_variables._ahCount.AllianceCount >= _bgTemplate->MinPlayersPerTeam &&
|
||||
_variables._ahCount.HordeCount >= _bgTemplate->MaxPlayersPerTeam)
|
||||
{
|
||||
//! Invite every player to the battleground
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void BattlegroundQueue::Erase( BattlegroundQueueElement* element )
|
||||
@@ -149,6 +161,19 @@ BattlegroundQueue::~BattlegroundQueue()
|
||||
}
|
||||
}
|
||||
|
||||
BattlegroundQueue::BattlegroundQueue( BattlegroundQueueIndex hash, PvPDifficultyEntry const* entry )
|
||||
: _hash(hash), _pvpDifficultyEntry(entry)
|
||||
{
|
||||
//! Complicated relations between DBCs and SQL tables.
|
||||
for (uint32 i = 0; i < sBattlemasterListStore.GetNumRows(); ++i)
|
||||
if (BattlemasterListEntry const* bl = sBattlemasterListStore.LookupEntry(i))
|
||||
if (bl->mapid[0] == entry->mapId)
|
||||
_bgTemplate = sBattlegroundMgr->GetBattlegroundTemplate(BattlegroundTypeId(bl->id));
|
||||
|
||||
memset(&_variables, 0, sizeof(_variables));
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************************************//**
|
||||
* \fn void BattlegroundQueueMgr::Initialize()
|
||||
*
|
||||
@@ -163,7 +188,7 @@ void BattlegroundQueueMgr::Initialize()
|
||||
{
|
||||
for (uint8 rated = 0; rated <= 1; ++rated)
|
||||
{
|
||||
for (uint8 arenaType = 2; arenaType <= 5; ++arenaType)
|
||||
for (uint8 arenaType = ARENA_TYPE_2v2; arenaType <= ARENA_TYPE_5v5; ++arenaType)
|
||||
{
|
||||
if (arenaType == 4) // There's no such thing as ARENA_TYPE_4V4
|
||||
continue;
|
||||
@@ -171,7 +196,7 @@ void BattlegroundQueueMgr::Initialize()
|
||||
for (uint8 pvpDifficultyEntry = 1; pvpDifficultyEntry <= MAX_PVPDIFFICULTY_ENTRY; ++pvpDifficultyEntry)
|
||||
{
|
||||
BattlegroundQueueIndex index(rated, arenaType, pvpDifficultyEntry);
|
||||
Queues[index] = new BattlegroundQueue(index);
|
||||
Queues[index] = new BattlegroundQueue(index, sPvPDifficultyStore.LookupEntry(pvpDifficultyEntry));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -237,4 +262,4 @@ bool BattlegroundQueue::ArenaInviteEvent::Execute( uint64 /*e_time*/, uint32 /*p
|
||||
//! TODO: Invite both arena teams to a match
|
||||
}
|
||||
|
||||
} // Namespace Battleground
|
||||
//} // Namespace Battleground
|
||||
@@ -24,31 +24,8 @@
|
||||
#include "BattlegroundMap.h"
|
||||
#include "EventProcessor.h"
|
||||
|
||||
/*
|
||||
BattlegroundQueueMgr shall hold a collection of queues
|
||||
|
||||
Client join packet looks like:
|
||||
uint64 guid;
|
||||
uint32 bgTypeId;
|
||||
uint32 instanceId;
|
||||
uint8 joinAsGroup;
|
||||
|
||||
bgTypeId will give us access to a unique bracketId that respects level ranges,
|
||||
and holds min/maxlevels.
|
||||
|
||||
The index used for queues is a uint16 composed of:
|
||||
uint16 index = ( (bool(rated) << 16) | ( uint8(arenaType) << 8 ) | ( uint8(bracketId) ));
|
||||
|
||||
|
||||
bracketId: Id in PVPDifficultiy.dbc, has access to mapId and level restrictions
|
||||
|
||||
arenaType: See enum
|
||||
|
||||
rated: rated match or not
|
||||
*/
|
||||
|
||||
namespace Battleground
|
||||
{
|
||||
//namespace Battleground
|
||||
//{
|
||||
|
||||
#define MAX_PVPDIFFICULTY_ENTRY 108
|
||||
|
||||
@@ -68,11 +45,20 @@ struct BattlegroundQueueElement
|
||||
|
||||
///< The (collection of) player(s) per LowGUID
|
||||
std::vector<uint32> Players;
|
||||
///< The arena matchmaker rating (if applicable)
|
||||
uint32 ArenaMMR;
|
||||
|
||||
///< Union of data specific to arena's or battlegrounds
|
||||
union
|
||||
{
|
||||
///< The faction (A/H)
|
||||
Team Faction;
|
||||
|
||||
///< The arena matchmaker rating (if applicable)
|
||||
uint32 ArenaMMR;
|
||||
} Data;
|
||||
|
||||
///< Determines if this element was already scheduled for a delayed invite.
|
||||
// If set to true, the element can still be scheduled for a MMR-selected match
|
||||
// and will be ignored for delayed invites.
|
||||
//< If set to true, the element can still be scheduled for a MMR-selected match
|
||||
//< and will be ignored for delayed invites.
|
||||
bool InviteScheduled;
|
||||
};
|
||||
|
||||
@@ -101,15 +87,14 @@ class BattlegroundQueueMgr
|
||||
BattlegroundQueueMgr() { Initialize(); }
|
||||
virtual ~BattlegroundQueueMgr() {}
|
||||
|
||||
///> Generate queue types with a hashed index, because we don't like nested arrays
|
||||
void Initialize();
|
||||
|
||||
///> Called from World::Update.
|
||||
void Update(uint32 const& diff);
|
||||
|
||||
///> Called from WorldSession handler(s)
|
||||
void Insert(BattlegroundQueueElement* element, uint8 rated, ArenaType arenaType, uint8 difficultyEntryId);
|
||||
|
||||
///< uint32 index = ( (bool(rated) << 16) | ( uint8(arenaType) << 8 ) | ( uint8(bracketId) ));
|
||||
///< bracketId: Id in PVPDifficultiy.dbc, has access to mapId and level restrictions
|
||||
///< arenaType: See enum
|
||||
///< rated: rated match or not
|
||||
typedef std::map<uint32 /*queueId*/, BattlegroundQueue*> QueueMap;
|
||||
|
||||
protected:
|
||||
@@ -123,7 +108,6 @@ class BattlegroundQueue : public std::set<BattlegroundQueueElement*>
|
||||
|
||||
typedef std::set<BattlegroundQueueElement*> Base;
|
||||
|
||||
|
||||
class ArenaInviteEvent : public BasicEvent
|
||||
{
|
||||
public:
|
||||
@@ -137,22 +121,43 @@ class BattlegroundQueue : public std::set<BattlegroundQueueElement*>
|
||||
};
|
||||
|
||||
protected:
|
||||
BattlegroundQueue(BattlegroundQueueIndex hash) : _hash(hash) {}
|
||||
BattlegroundQueue(BattlegroundQueueIndex hash, PvPDifficultyEntry const* entry);
|
||||
|
||||
~BattlegroundQueue();
|
||||
|
||||
void Insert(BattlegroundQueueElement* element);
|
||||
|
||||
void Erase(BattlegroundQueueElement* element);
|
||||
|
||||
/// Will execute events asynchronously
|
||||
void Update(uint32 const& diff);
|
||||
|
||||
private:
|
||||
|
||||
char const* OutDebug();
|
||||
|
||||
BattlegroundQueueIndex _hash; // Hash index BattlegroundQueueMgr uses to access pointer to this object.
|
||||
EventProcessor _events; // Asynchronous events
|
||||
///< Counter variables dependant on type (BG/Arena)
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
uint8 AllianceCount;
|
||||
uint8 HordeCount;
|
||||
} _ahCount;
|
||||
|
||||
} _variables;
|
||||
|
||||
///< Hash index BattlegroundQueueMgr uses to access pointer to this object.
|
||||
BattlegroundQueueIndex _hash;
|
||||
|
||||
///< Entry from PvPDifficultyEntry.dbc
|
||||
PvPDifficultyEntry const* _pvpDifficultyEntry;
|
||||
|
||||
///< Entry from BattleMasterListEntry.dbc
|
||||
BattlemasterListEntry const* _battleMasterListEntry;
|
||||
|
||||
///< The battleground_template
|
||||
BattlegroundTemplate const* _bgTemplate;
|
||||
|
||||
///< Asynchronous events
|
||||
EventProcessor _events;
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -202,6 +207,6 @@ class BGQueueRemoveEvent : public BasicEvent
|
||||
BattlegroundQueueTypeId _bgQueueTypeId;
|
||||
};
|
||||
|
||||
} // namespace Battleground
|
||||
//} // namespace Battleground
|
||||
|
||||
#endif
|
||||
|
||||
@@ -125,6 +125,7 @@ extern DBCStorage <MapEntry> sMapStore;
|
||||
extern MapDifficultyMap sMapDifficultyMap;
|
||||
extern DBCStorage <MovieEntry> sMovieStore;
|
||||
extern DBCStorage <OverrideSpellDataEntry> sOverrideSpellDataStore;
|
||||
extern DBCStorage <PvPDifficultyEntry> sPvPDifficultyStore;
|
||||
extern DBCStorage <QuestSortEntry> sQuestSortStore;
|
||||
extern DBCStorage <QuestXPEntry> sQuestXPStore;
|
||||
extern DBCStorage <QuestFactionRewEntry> sQuestFactionRewardStore;
|
||||
|
||||
Reference in New Issue
Block a user