feat(Core/Battlegrounds) Reworked enhanced bg system for modules (#2521)
This commit is contained in:
@@ -268,7 +268,9 @@ void BattlegroundMgr::BuildPvpLogDataPacket(WorldPacket* data, Battleground* bg)
|
||||
}
|
||||
*data << uint32(itr2->second->DamageDone); // damage done
|
||||
*data << uint32(itr2->second->HealingDone); // healing done
|
||||
switch (bg->GetBgTypeID()) // battleground specific things
|
||||
|
||||
BattlegroundTypeId bgTypeId = bg->GetBgTypeID();
|
||||
switch (bgTypeId) // battleground specific things
|
||||
{
|
||||
case BATTLEGROUND_RB:
|
||||
switch (bg->GetMapId())
|
||||
@@ -305,7 +307,10 @@ void BattlegroundMgr::BuildPvpLogDataPacket(WorldPacket* data, Battleground* bg)
|
||||
*data << uint32(((BattlegroundICScore*)itr2->second)->BasesAssaulted); // bases asssulted
|
||||
*data << uint32(((BattlegroundICScore*)itr2->second)->BasesDefended); // bases defended
|
||||
default:
|
||||
*data << uint32(0);
|
||||
if (BattlegroundMgr::getBgFromMap.find(bg->GetMapId()) != BattlegroundMgr::getBgFromMap.end())
|
||||
BattlegroundMgr::getBgFromMap[bg->GetMapId()](data, itr2);
|
||||
else
|
||||
*data << uint32(0);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
@@ -350,13 +355,16 @@ void BattlegroundMgr::BuildPvpLogDataPacket(WorldPacket* data, Battleground* bg)
|
||||
*data << uint32(0);
|
||||
break;
|
||||
default:
|
||||
*data << uint32(0);
|
||||
if (BattlegroundMgr::getBgFromTypeID.find(bgTypeId) != BattlegroundMgr::getBgFromTypeID.end())
|
||||
BattlegroundMgr::getBgFromTypeID[bgTypeId](data, itr2, bg);
|
||||
else
|
||||
*data << uint32(0);
|
||||
break;
|
||||
}
|
||||
// should never happen
|
||||
if (++scoreCount >= bg->GetMaxPlayersPerTeam()*2 && itr != bg->GetPlayerScoresEnd())
|
||||
{
|
||||
sLog->outMisc("Battleground %u scoreboard has more entries (%u) than allowed players in this bg (%u)", bg->GetBgTypeID(), bg->GetPlayerScoresSize(), bg->GetMaxPlayersPerTeam()*2);
|
||||
sLog->outMisc("Battleground %u scoreboard has more entries (%u) than allowed players in this bg (%u)", bgTypeId, bg->GetPlayerScoresSize(), bg->GetMaxPlayersPerTeam()*2);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1091,3 +1099,22 @@ std::unordered_map<int, bgRef> BattlegroundMgr::bgTypeToTemplate = {
|
||||
{ BATTLEGROUND_RB, [](Battleground *bg_t) -> Battleground*{ return new Battleground(*bg_t); }, },
|
||||
{ BATTLEGROUND_AA, [](Battleground *bg_t) -> Battleground*{ return new Battleground(*bg_t); }, },
|
||||
};
|
||||
|
||||
std::unordered_map<int, bgMapRef> BattlegroundMgr::getBgFromMap = {};
|
||||
|
||||
std::unordered_map<int, bgTypeRef> BattlegroundMgr::getBgFromTypeID = {
|
||||
{
|
||||
BATTLEGROUND_RB,
|
||||
[](WorldPacket* data, Battleground::BattlegroundScoreMap::const_iterator itr2, Battleground* bg)
|
||||
{
|
||||
if (BattlegroundMgr::getBgFromMap.find(bg->GetMapId()) == BattlegroundMgr::getBgFromMap.end()) // this should not happen
|
||||
{
|
||||
*data << uint32(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
BattlegroundMgr::getBgFromMap[bg->GetMapId()](data, itr2);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -18,6 +18,9 @@ typedef std::map<uint32, Battleground*> BattlegroundContainer;
|
||||
typedef std::unordered_map<uint32, BattlegroundTypeId> BattleMastersMap;
|
||||
typedef Battleground*(*bgRef)(Battleground*);
|
||||
|
||||
typedef void(*bgMapRef)(WorldPacket*, Battleground::BattlegroundScoreMap::const_iterator);
|
||||
typedef void(*bgTypeRef)(WorldPacket*, Battleground::BattlegroundScoreMap::const_iterator, Battleground*);
|
||||
|
||||
#define BATTLEGROUND_ARENA_POINT_DISTRIBUTION_DAY 86400 // how many seconds in day
|
||||
|
||||
struct CreateBattlegroundData
|
||||
@@ -118,10 +121,12 @@ class BattlegroundMgr
|
||||
|
||||
const BattlegroundContainer& GetBattlegroundList() { return m_Battlegrounds; } // pussywizard
|
||||
|
||||
static std::unordered_map<int, BattlegroundQueueTypeId> bgToQueue; // BattlegroundTypeId -> BattlegroundQueueTypeId
|
||||
static std::unordered_map<int, BattlegroundTypeId> queueToBg; // BattlegroundQueueTypeId -> BattlegroundTypeId
|
||||
static std::unordered_map<int, Battleground*> bgtypeToBattleground; // BattlegroundTypeId -> Battleground*
|
||||
static std::unordered_map<int, bgRef> bgTypeToTemplate; // BattlegroundTypeId -> bgRef
|
||||
static std::unordered_map<int, BattlegroundQueueTypeId> bgToQueue; // BattlegroundTypeId -> BattlegroundQueueTypeId
|
||||
static std::unordered_map<int, BattlegroundTypeId> queueToBg; // BattlegroundQueueTypeId -> BattlegroundTypeId
|
||||
static std::unordered_map<int, Battleground*> bgtypeToBattleground; // BattlegroundTypeId -> Battleground*
|
||||
static std::unordered_map<int, bgRef> bgTypeToTemplate; // BattlegroundTypeId -> bgRef
|
||||
static std::unordered_map<int, bgMapRef> getBgFromMap; // BattlegroundMapID -> bgMapRef
|
||||
static std::unordered_map<int, bgTypeRef> getBgFromTypeID; // BattlegroundTypeID -> bgTypeRef
|
||||
|
||||
private:
|
||||
bool CreateBattleground(CreateBattlegroundData& data);
|
||||
|
||||
@@ -1780,17 +1780,24 @@ void GameObject::Use(Unit* user)
|
||||
GameObjectTemplate const* info = GetGOInfo();
|
||||
if (info)
|
||||
{
|
||||
switch (info->entry)
|
||||
if (GameObject::gameObjectToEventFlag.find(info->entry) != GameObject::gameObjectToEventFlag.end())
|
||||
{
|
||||
case 179785: // Silverwing Flag
|
||||
case 179786: // Warsong Flag
|
||||
if (bg->GetBgTypeID(true) == BATTLEGROUND_WS)
|
||||
bg->EventPlayerClickedOnFlag(player, this);
|
||||
break;
|
||||
case 184142: // Netherstorm Flag
|
||||
if (bg->GetBgTypeID(true) == BATTLEGROUND_EY)
|
||||
bg->EventPlayerClickedOnFlag(player, this);
|
||||
break;
|
||||
GameObject::gameObjectToEventFlag[info->entry](player, this, bg);
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (info->entry)
|
||||
{
|
||||
case 179785: // Silverwing Flag
|
||||
case 179786: // Warsong Flag
|
||||
if (bg->GetBgTypeID(true) == BATTLEGROUND_WS)
|
||||
bg->EventPlayerClickedOnFlag(player, this);
|
||||
break;
|
||||
case 184142: // Netherstorm Flag
|
||||
if (bg->GetBgTypeID(true) == BATTLEGROUND_EY)
|
||||
bg->EventPlayerClickedOnFlag(player, this);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
//this cause to call return, all flags must be deleted here!!
|
||||
@@ -2490,3 +2497,5 @@ void GameObject::UpdateModelPosition()
|
||||
GetMap()->InsertGameObjectModel(*m_model);
|
||||
}
|
||||
}
|
||||
|
||||
std::unordered_map<int, goEventFlag> GameObject::gameObjectToEventFlag = {};
|
||||
|
||||
@@ -20,6 +20,8 @@ class Transport;
|
||||
class StaticTransport;
|
||||
class MotionTransport;
|
||||
|
||||
typedef void(*goEventFlag)(Player*, GameObject*, Battleground*);
|
||||
|
||||
#define MAX_GAMEOBJECT_QUEST_ITEMS 6
|
||||
|
||||
// from `gameobject_template`
|
||||
@@ -879,6 +881,8 @@ class GameObject : public WorldObject, public GridObject<GameObject>, public Mov
|
||||
|
||||
void UpdateModelPosition();
|
||||
|
||||
static std::unordered_map<int, goEventFlag> gameObjectToEventFlag; // Gameobject -> event flag
|
||||
|
||||
protected:
|
||||
bool AIM_Initialize();
|
||||
void UpdateModel(); // updates model in case displayId were changed
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -45,6 +45,7 @@ class SpellCastTargets;
|
||||
class UpdateMask;
|
||||
|
||||
typedef std::deque<Mail*> PlayerMails;
|
||||
typedef void(*bgZoneRef)(Battleground*, WorldPacket&);
|
||||
|
||||
#define PLAYER_MAX_SKILLS 127
|
||||
#define PLAYER_MAX_DAILY_QUESTS 25
|
||||
@@ -2628,6 +2629,8 @@ class Player : public Unit, public GridObject<Player>
|
||||
uint32 GetNextSave() const { return m_nextSave; }
|
||||
SpellModList const& GetSpellModList(uint32 type) const { return m_spellMods[type]; }
|
||||
|
||||
static std::unordered_map<int, bgZoneRef> bgZoneIdToFillWorldStates; // zoneId -> FillInitialWorldStates
|
||||
|
||||
protected:
|
||||
// Gamemaster whisper whitelist
|
||||
WhisperListContainer WhisperList;
|
||||
|
||||
Reference in New Issue
Block a user