Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Core/Battlegrounds): Enhanced bg system for modules #2334

Closed
wants to merge 10 commits into from
450 changes: 278 additions & 172 deletions src/server/game/Battlegrounds/BattlegroundMgr.cpp

Large diffs are not rendered by default.

13 changes: 8 additions & 5 deletions src/server/game/Battlegrounds/BattlegroundMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
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

Expand Down Expand Up @@ -136,10 +137,12 @@ class BattlegroundMgr
const BattlegroundContainer& GetBattlegroundList() { return m_Battlegrounds; } // pussywizard
RandomBattlegroundSystem RandomSystem; // 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);
Expand Down
29 changes: 18 additions & 11 deletions src/server/game/Entities/GameObject/GameObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1780,17 +1780,22 @@ void GameObject::Use(Unit* user)
GameObjectTemplate const* info = GetGOInfo();
if (info)
{
switch (info->entry)
{
case 179785: // Silverwing Flag
case 179786: // Warsong Flag
if (bg->GetBgTypeID() == BATTLEGROUND_WS)
bg->EventPlayerClickedOnFlag(player, this);
break;
case 184142: // Netherstorm Flag
if (bg->GetBgTypeID() == BATTLEGROUND_EY)
bg->EventPlayerClickedOnFlag(player, this);
break;
if (GameObject::gameObjectToEventFlag.find(info->entry) != GameObject::gameObjectToEventFlag.end()) {
GameObject::gameObjectToEventFlag[info->entry](player, this, bg);
}
else {
switch (info->entry)
{
case 179785: // Silverwing Flag
case 179786: // Warsong Flag
if (bg->GetBgTypeID() == BATTLEGROUND_WS)
bg->EventPlayerClickedOnFlag(player, this);
break;
case 184142: // Netherstorm Flag
if (bg->GetBgTypeID() == BATTLEGROUND_EY)
bg->EventPlayerClickedOnFlag(player, this);
break;
}
}
}
//this cause to call return, all flags must be deleted here!!
Expand Down Expand Up @@ -2490,3 +2495,5 @@ void GameObject::UpdateModelPosition()
GetMap()->InsertGameObjectModel(*m_model);
}
}

std::unordered_map<int, goEventFlag> GameObject::gameObjectToEventFlag = {};
4 changes: 4 additions & 0 deletions src/server/game/Entities/GameObject/GameObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down Expand Up @@ -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
Expand Down
Loading