aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/game/BattleGround.cpp6
-rw-r--r--src/game/BattleGroundHandler.cpp10
-rw-r--r--src/game/BattleGroundMgr.cpp91
-rw-r--r--src/game/BattleGroundMgr.h32
-rw-r--r--src/game/Level1.cpp4
-rw-r--r--src/game/MovementHandler.cpp2
-rw-r--r--src/game/Player.cpp9
-rw-r--r--src/game/Player.h14
-rw-r--r--src/game/SharedDefines.h1
-rw-r--r--src/shared/revision_nr.h2
10 files changed, 99 insertions, 72 deletions
diff --git a/src/game/BattleGround.cpp b/src/game/BattleGround.cpp
index 66c44520745..3c73fab012c 100644
--- a/src/game/BattleGround.cpp
+++ b/src/game/BattleGround.cpp
@@ -119,7 +119,7 @@ BattleGround::~BattleGround()
// remove from battlegrounds
}
- sBattleGroundMgr.RemoveBattleGround(GetInstanceID());
+ sBattleGroundMgr.RemoveBattleGround(GetInstanceID(), GetTypeID());
// unload map
if(Map * map = MapManager::Instance().FindMap(GetMapId(), GetInstanceID()))
if(map->IsBattleGroundOrArena())
@@ -856,7 +856,7 @@ void BattleGround::RemovePlayerAtLeave(uint64 guid, bool Transport, bool SendPac
}
// Do next only if found in battleground
- plr->SetBattleGroundId(0); // We're not in BG.
+ plr->SetBattleGroundId(0, BATTLEGROUND_TYPE_NONE); // We're not in BG.
// reset destination bg team
plr->SetBGTeam(0);
@@ -1031,7 +1031,7 @@ void BattleGround::RemoveFromBGFreeSlotQueue()
// set to be able to re-add if needed
m_InBGFreeSlotQueue = false;
// uncomment this code when battlegrounds will work like instances
- for (std::deque<BattleGround*>::iterator itr = sBattleGroundMgr.BGFreeSlotQueue[m_TypeID].begin(); itr != sBattleGroundMgr.BGFreeSlotQueue[m_TypeID].end(); ++itr)
+ for (BGFreeSlotQueueType::iterator itr = sBattleGroundMgr.BGFreeSlotQueue[m_TypeID].begin(); itr != sBattleGroundMgr.BGFreeSlotQueue[m_TypeID].end(); ++itr)
{
if ((*itr)->GetInstanceID() == m_InstanceID)
{
diff --git a/src/game/BattleGroundHandler.cpp b/src/game/BattleGroundHandler.cpp
index 1f75bab4429..a3a3631e72d 100644
--- a/src/game/BattleGroundHandler.cpp
+++ b/src/game/BattleGroundHandler.cpp
@@ -115,7 +115,7 @@ void WorldSession::HandleBattleGroundJoinOpcode( WorldPacket & recv_data )
// get bg instance or bg template if instance not found
BattleGround * bg = 0;
if(instanceId)
- BattleGround *bg = sBattleGroundMgr.GetBattleGround(instanceId);
+ BattleGround *bg = sBattleGroundMgr.GetBattleGround(instanceId, bgTypeId);
if(!bg && !(bg = sBattleGroundMgr.GetBattleGroundTemplate(bgTypeId)))
{
@@ -347,7 +347,7 @@ void WorldSession::HandleBattleGroundPlayerPortOpcode( WorldPacket &recv_data )
else
{
// get the bg we're invited to
- BattleGround * bg = sBattleGroundMgr.GetBattleGround(itrPlayerStatus->second.GroupInfo->IsInvitedToBGInstanceGUID);
+ BattleGround * bg = sBattleGroundMgr.GetBattleGround(itrPlayerStatus->second.GroupInfo->IsInvitedToBGInstanceGUID, bgTypeId);
status = STATUS_WAIT_JOIN;
}
@@ -389,7 +389,7 @@ void WorldSession::HandleBattleGroundPlayerPortOpcode( WorldPacket &recv_data )
return;
}
- BattleGround *bg = sBattleGroundMgr.GetBattleGround(instanceId);
+ BattleGround *bg = sBattleGroundMgr.GetBattleGround(instanceId, bgTypeId);
// bg template might and must be used in case of leaving queue, when instance is not created yet
if(!bg && action == 0)
@@ -458,11 +458,11 @@ void WorldSession::HandleBattleGroundPlayerPortOpcode( WorldPacket &recv_data )
currentBg->RemovePlayerAtLeave(_player->GetGUID(), false, true);
// set the destination instance id
- _player->SetBattleGroundId(bg->GetInstanceID());
+ _player->SetBattleGroundId(bg->GetInstanceID(), bgTypeId);
// set the destination team
_player->SetBGTeam(team);
// bg->HandleBeforeTeleportToBattleGround(_player);
- sBattleGroundMgr.SendToBattleGround(_player, instanceId);
+ sBattleGroundMgr.SendToBattleGround(_player, instanceId, bgTypeId);
// add only in HandleMoveWorldPortAck()
// bg->AddPlayer(_player,team);
sLog.outDebug("Battleground: player %s (%u) joined battle for bg %u, bgtype %u, queue type %u.",_player->GetName(),_player->GetGUIDLow(),bg->GetInstanceID(),bg->GetTypeID(),bgQueueTypeId);
diff --git a/src/game/BattleGroundMgr.cpp b/src/game/BattleGroundMgr.cpp
index 7b557e5f5c8..ec5f04d6623 100644
--- a/src/game/BattleGroundMgr.cpp
+++ b/src/game/BattleGroundMgr.cpp
@@ -246,7 +246,7 @@ void BattleGroundQueue::RemovePlayer(const uint64& guid, bool decreaseInvitedCou
// if invited to bg, and should decrease invited count, then do it
if( decreaseInvitedCount && group->IsInvitedToBGInstanceGUID )
{
- BattleGround* bg = sBattleGroundMgr.GetBattleGround(group->IsInvitedToBGInstanceGUID);
+ BattleGround* bg = sBattleGroundMgr.GetBattleGround(group->IsInvitedToBGInstanceGUID, group->BgTypeId);
if( bg )
bg->DecreaseInvitedCount(group->Team);
}
@@ -370,7 +370,7 @@ bool BattleGroundQueue::InviteGroupToBG(GroupQueueInfo * ginfo, BattleGround * b
continue;
// invite the player
- sBattleGroundMgr.InvitePlayer(plr, bg->GetInstanceID(), ginfo->Team);
+ sBattleGroundMgr.InvitePlayer(plr, bg->GetInstanceID(), bg->GetTypeID(), ginfo->Team);
WorldPacket data;
@@ -918,7 +918,7 @@ bool BGQueueInviteEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/)
// Player can be in another BG queue and must be removed in normal way in any case
- BattleGround* bg = sBattleGroundMgr.GetBattleGround(m_BgInstanceGUID);
+ BattleGround* bg = sBattleGroundMgr.GetBattleGround(m_BgInstanceGUID, m_BgTypeId);
if (!bg)
return true;
@@ -952,7 +952,7 @@ bool BGQueueRemoveEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/)
// player logged off (we should do nothing, he is correctly removed from queue in another procedure)
return true;
- BattleGround* bg = sBattleGroundMgr.GetBattleGround(m_BgInstanceGUID);
+ BattleGround* bg = sBattleGroundMgr.GetBattleGround(m_BgInstanceGUID, m_BgTypeId);
if (!bg)
return true;
@@ -1004,7 +1004,8 @@ void BGQueueRemoveEvent::Abort(uint64 /*e_time*/)
BattleGroundMgr::BattleGroundMgr() : m_AutoDistributionTimeChecker(0), m_ArenaTesting(false)
{
- m_BattleGrounds.clear();
+ for(uint32 i = BATTLEGROUND_TYPE_NONE; i < MAX_BATTLEGROUND_TYPE_ID; i++)
+ m_BattleGrounds[i].clear();
m_NextRatingDiscardUpdate = sWorld.getConfig(CONFIG_ARENA_RATING_DISCARD_TIMER);
m_Testing=false;
}
@@ -1016,11 +1017,14 @@ BattleGroundMgr::~BattleGroundMgr()
void BattleGroundMgr::DeleteAlllBattleGrounds()
{
- for(BattleGroundSet::iterator itr = m_BattleGrounds.begin(); itr != m_BattleGrounds.end();)
+ for(uint32 i = BATTLEGROUND_TYPE_NONE; i < MAX_BATTLEGROUND_TYPE_ID; i++)
{
- BattleGround * bg = itr->second;
- m_BattleGrounds.erase(itr++);
- delete bg;
+ for(BattleGroundSet::iterator itr = m_BattleGrounds[i].begin(); itr != m_BattleGrounds[i].end();)
+ {
+ BattleGround * bg = itr->second;
+ m_BattleGrounds[i].erase(itr++);
+ delete bg;
+ }
}
// destroy template battlegrounds that listed only in queues (other already terminated)
@@ -1036,18 +1040,21 @@ void BattleGroundMgr::DeleteAlllBattleGrounds()
void BattleGroundMgr::Update(uint32 diff)
{
BattleGroundSet::iterator itr, next;
- for(itr = m_BattleGrounds.begin(); itr != m_BattleGrounds.end(); itr = next)
+ for(uint32 i = BATTLEGROUND_TYPE_NONE; i < MAX_BATTLEGROUND_TYPE_ID; i++)
{
- next = itr;
- ++next;
- itr->second->Update(diff);
- // use the SetDeleteThis variable
- // direct deletion caused crashes
- if(itr->second->m_SetDeleteThis)
+ for(itr = m_BattleGrounds[i].begin(); itr != m_BattleGrounds[i].end(); itr = next)
{
- BattleGround * bg = itr->second;
- m_BattleGrounds.erase(itr);
- delete bg;
+ next = itr;
+ ++next;
+ itr->second->Update(diff);
+ // use the SetDeleteThis variable
+ // direct deletion caused crashes
+ if(itr->second->m_SetDeleteThis)
+ {
+ BattleGround * bg = itr->second;
+ m_BattleGrounds[i].erase(itr);
+ delete bg;
+ }
}
}
// if rating difference counts, maybe force-update queues
@@ -1324,10 +1331,10 @@ void BattleGroundMgr::BuildPlayerJoinedBattleGroundPacket(WorldPacket *data, Pla
*data << uint64(plr->GetGUID());
}
-void BattleGroundMgr::InvitePlayer(Player* plr, uint32 bgInstanceGUID, uint32 team)
+void BattleGroundMgr::InvitePlayer(Player* plr, uint32 bgInstanceGUID, BattleGroundTypeId bgTypeId, uint32 team)
{
// set invited player counters:
- BattleGround* bg = GetBattleGround(bgInstanceGUID);
+ BattleGround* bg = GetBattleGround(bgInstanceGUID, bgTypeId);
if(!bg)
return;
bg->IncreaseInvitedCount(team);
@@ -1355,15 +1362,34 @@ void BattleGroundMgr::InvitePlayer(Player* plr, uint32 bgInstanceGUID, uint32 te
// create invite events:
//add events to player's counters ---- this is not good way - there should be something like global event processor, where we should add those events
- BGQueueInviteEvent* inviteEvent = new BGQueueInviteEvent(plr->GetGUID(), bgInstanceGUID);
+ BGQueueInviteEvent* inviteEvent = new BGQueueInviteEvent(plr->GetGUID(), bgInstanceGUID, bgTypeId);
plr->m_Events.AddEvent(inviteEvent, plr->m_Events.CalculateTime(INVITATION_REMIND_TIME));
- BGQueueRemoveEvent* removeEvent = new BGQueueRemoveEvent(plr->GetGUID(), bgInstanceGUID, team);
+ BGQueueRemoveEvent* removeEvent = new BGQueueRemoveEvent(plr->GetGUID(), bgInstanceGUID, bgTypeId, team);
plr->m_Events.AddEvent(removeEvent, plr->m_Events.CalculateTime(INVITE_ACCEPT_WAIT_TIME));
}
+BattleGround * BattleGroundMgr::GetBattleGround(uint32 InstanceID, BattleGroundTypeId bgTypeId)
+{
+ //search if needed
+ BattleGroundSet::iterator itr;
+ if( bgTypeId == BATTLEGROUND_TYPE_NONE)
+ {
+ for(uint32 i = BATTLEGROUND_AV; i < MAX_BATTLEGROUND_TYPE_ID; i++)
+ {
+ itr = m_BattleGrounds[i].find(InstanceID);
+ if( itr != m_BattleGrounds[i].end() )
+ return itr->second;
+ }
+ return NULL;
+ }
+ itr = m_BattleGrounds[bgTypeId].find(InstanceID);
+ return ( (itr != m_BattleGrounds[bgTypeId].end()) ? itr->second : NULL );
+}
+
BattleGround * BattleGroundMgr::GetBattleGroundTemplate(BattleGroundTypeId bgTypeId)
{
- return BGFreeSlotQueue[bgTypeId].empty() ? NULL : BGFreeSlotQueue[bgTypeId].back();
+ //map is sorted and we can be sure that lowest instance id has only BG template
+ return m_BattleGrounds[bgTypeId].empty() ? NULL : m_BattleGrounds[bgTypeId].begin()->second;
}
// create a new battleground that will really be used to play
@@ -1460,7 +1486,7 @@ BattleGround * BattleGroundMgr::CreateNewBattleGround(BattleGroundTypeId bgTypeI
bg->AddToBGFreeSlotQueue();
// add bg to update list
- AddBattleGround(bg->GetInstanceID(), bg);
+ AddBattleGround(bg->GetInstanceID(), bg->GetTypeID(), bg);
return bg;
}
@@ -1487,9 +1513,6 @@ uint32 BattleGroundMgr::CreateBattleGround(BattleGroundTypeId bgTypeId, bool IsA
}
bg->SetMapId(MapID);
-
- bg->Reset();
-
bg->SetTypeID(bgTypeId);
bg->SetInstanceID(0);
bg->SetArenaorBGType(IsArena);
@@ -1502,8 +1525,8 @@ uint32 BattleGroundMgr::CreateBattleGround(BattleGroundTypeId bgTypeId, bool IsA
bg->SetTeamStartLoc(HORDE, Team2StartLocX, Team2StartLocY, Team2StartLocZ, Team2StartLocO);
bg->SetLevelRange(LevelMin, LevelMax);
- //add BattleGround instance to FreeSlotQueue (.back() will return the template!)
- bg->AddToBGFreeSlotQueue();
+ //reset() and add to free slot queue are called only when needed!
+ //bg->AddToBGFreeSlotQueue();
// do NOT add to update list, since this is a template battleground!
@@ -1725,9 +1748,9 @@ void BattleGroundMgr::BuildBattleGroundListPacket(WorldPacket *data, const uint6
uint32 count = 0;
*data << uint32(0x00); // number of bg instances
- for(std::map<uint32, BattleGround*>::iterator itr = m_BattleGrounds.begin(); itr != m_BattleGrounds.end(); ++itr)
+ for(BattleGroundSet::iterator itr = m_BattleGrounds[bgTypeId].begin(); itr != m_BattleGrounds[bgTypeId].end(); ++itr)
{
- if(itr->second->GetTypeID() == bgTypeId && (PlayerLevel >= itr->second->GetMinLevel()) && (PlayerLevel <= itr->second->GetMaxLevel()))
+ if( PlayerLevel >= itr->second->GetMinLevel() && PlayerLevel <= itr->second->GetMaxLevel() )
{
*data << uint32(itr->second->GetInstanceID());
++count;
@@ -1737,9 +1760,9 @@ void BattleGroundMgr::BuildBattleGroundListPacket(WorldPacket *data, const uint6
}
}
-void BattleGroundMgr::SendToBattleGround(Player *pl, uint32 instanceId)
+void BattleGroundMgr::SendToBattleGround(Player *pl, uint32 instanceId, BattleGroundTypeId bgTypeId)
{
- BattleGround *bg = GetBattleGround(instanceId);
+ BattleGround *bg = GetBattleGround(instanceId, bgTypeId);
if(bg)
{
uint32 mapid = bg->GetMapId();
diff --git a/src/game/BattleGroundMgr.h b/src/game/BattleGroundMgr.h
index 1c2a1d8a093..6a26783cd2f 100644
--- a/src/game/BattleGroundMgr.h
+++ b/src/game/BattleGroundMgr.h
@@ -24,8 +24,6 @@
#include "Common.h"
#include "BattleGround.h"
-//TODO it is not possible to have this structure, because we should have BattlegroundSet for each queue
-//so i propose to change this type to array 1..MAX_BATTLEGROUND_TYPES of sets or maps..
typedef std::map<uint32, BattleGround*> BattleGroundSet;
typedef std::deque<BattleGround*> BGFreeSlotQueueType;
@@ -131,7 +129,10 @@ class BattleGroundQueue
class BGQueueInviteEvent : public BasicEvent
{
public:
- BGQueueInviteEvent(const uint64& pl_guid, uint32 BgInstanceGUID) : m_PlayerGuid(pl_guid), m_BgInstanceGUID(BgInstanceGUID) {};
+ BGQueueInviteEvent(const uint64& pl_guid, uint32 BgInstanceGUID, BattleGroundTypeId BgTypeId) :
+ m_PlayerGuid(pl_guid), m_BgInstanceGUID(BgInstanceGUID), m_BgTypeId(BgTypeId)
+ {
+ };
virtual ~BGQueueInviteEvent() {};
virtual bool Execute(uint64 e_time, uint32 p_time);
@@ -139,6 +140,7 @@ class BGQueueInviteEvent : public BasicEvent
private:
uint64 m_PlayerGuid;
uint32 m_BgInstanceGUID;
+ BattleGroundTypeId m_BgTypeId;
};
/*
@@ -147,8 +149,8 @@ class BGQueueInviteEvent : public BasicEvent
class BGQueueRemoveEvent : public BasicEvent
{
public:
- BGQueueRemoveEvent(const uint64& pl_guid, uint32 bgInstanceGUID, uint32 playersTeam) :
- m_PlayerGuid(pl_guid), m_BgInstanceGUID(bgInstanceGUID), m_PlayersTeam(playersTeam)
+ BGQueueRemoveEvent(const uint64& pl_guid, uint32 bgInstanceGUID, BattleGroundTypeId BgTypeId, uint32 playersTeam) :
+ m_PlayerGuid(pl_guid), m_BgInstanceGUID(bgInstanceGUID), m_BgTypeId(BgTypeId), m_PlayersTeam(playersTeam)
{
};
virtual ~BGQueueRemoveEvent() {};
@@ -159,6 +161,7 @@ class BGQueueRemoveEvent : public BasicEvent
uint64 m_PlayerGuid;
uint32 m_BgInstanceGUID;
uint32 m_PlayersTeam;
+ BattleGroundTypeId m_BgTypeId;
};
class BattleGroundMgr
@@ -182,30 +185,23 @@ class BattleGroundMgr
/* Player invitation */
// called from Queue update, or from Addplayer to queue
- void InvitePlayer(Player* plr, uint32 bgInstanceGUID, uint32 team);
+ void InvitePlayer(Player* plr, uint32 bgInstanceGUID, BattleGroundTypeId bgTypeId, uint32 team);
/* Battlegrounds */
- BattleGroundSet::iterator GetBattleGroundsBegin() { return m_BattleGrounds.begin(); };
- BattleGroundSet::iterator GetBattleGroundsEnd() { return m_BattleGrounds.end(); };
-
- BattleGround* GetBattleGround(uint32 InstanceID)
- {
- BattleGroundSet::iterator i = m_BattleGrounds.find(InstanceID);
- return ( (i != m_BattleGrounds.end()) ? i->second : NULL );
- };
+ BattleGround* GetBattleGround(uint32 InstanceID, BattleGroundTypeId bgTypeId); //there must be uint32 because MAX_BATTLEGROUND_TYPE_ID means unknown
BattleGround * GetBattleGroundTemplate(BattleGroundTypeId bgTypeId);
BattleGround * CreateNewBattleGround(BattleGroundTypeId bgTypeId, BGQueueIdBasedOnLevel queue_id, uint8 arenaType, bool isRated);
uint32 CreateBattleGround(BattleGroundTypeId bgTypeId, bool IsArena, uint32 MinPlayersPerTeam, uint32 MaxPlayersPerTeam, uint32 LevelMin, uint32 LevelMax, char* BattleGroundName, uint32 MapID, float Team1StartLocX, float Team1StartLocY, float Team1StartLocZ, float Team1StartLocO, float Team2StartLocX, float Team2StartLocY, float Team2StartLocZ, float Team2StartLocO);
- void AddBattleGround(uint32 InstanceID, BattleGround* BG) { m_BattleGrounds[InstanceID] = BG; };
- void RemoveBattleGround(uint32 instanceID) { m_BattleGrounds.erase(instanceID); }
+ void AddBattleGround(uint32 InstanceID, BattleGroundTypeId bgTypeId, BattleGround* BG) { m_BattleGrounds[bgTypeId][InstanceID] = BG; };
+ void RemoveBattleGround(uint32 instanceID, BattleGroundTypeId bgTypeId) { m_BattleGrounds[bgTypeId].erase(instanceID); }
void CreateInitialBattleGrounds();
void DeleteAlllBattleGrounds();
- void SendToBattleGround(Player *pl, uint32 InstanceID);
+ void SendToBattleGround(Player *pl, uint32 InstanceID, BattleGroundTypeId bgTypeId);
/* Battleground queues */
//these queues are instantiated when creating BattlegroundMrg
@@ -244,7 +240,7 @@ class BattleGroundMgr
BattleMastersMap mBattleMastersMap;
/* Battlegrounds */
- BattleGroundSet m_BattleGrounds;
+ BattleGroundSet m_BattleGrounds[MAX_BATTLEGROUND_TYPE_ID];
uint32 m_NextRatingDiscardUpdate;
uint64 m_NextAutoDistributionTime;
uint32 m_AutoDistributionTimeChecker;
diff --git a/src/game/Level1.cpp b/src/game/Level1.cpp
index 062f262a826..90b167b06f0 100644
--- a/src/game/Level1.cpp
+++ b/src/game/Level1.cpp
@@ -783,7 +783,7 @@ bool ChatHandler::HandleNamegoCommand(const char* args)
}
// all's well, set bg id
// when porting out from the bg, it will be reset to 0
- chr->SetBattleGroundId(m_session->GetPlayer()->GetBattleGroundId());
+ chr->SetBattleGroundId(m_session->GetPlayer()->GetBattleGroundId(), m_session->GetPlayer()->GetBattleGroundTypeId());
// remember current position as entry point for return at bg end teleportation
chr->SetBattleGroundEntryPoint(chr->GetMapId(),chr->GetPositionX(),chr->GetPositionY(),chr->GetPositionZ(),chr->GetOrientation());
}
@@ -901,7 +901,7 @@ bool ChatHandler::HandleGonameCommand(const char* args)
}
// all's well, set bg id
// when porting out from the bg, it will be reset to 0
- _player->SetBattleGroundId(chr->GetBattleGroundId());
+ _player->SetBattleGroundId(chr->GetBattleGroundId(), chr->GetBattleGroundTypeId());
// remember current position as entry point for return at bg end teleportation
_player->SetBattleGroundEntryPoint(_player->GetMapId(),_player->GetPositionX(),_player->GetPositionY(),_player->GetPositionZ(),_player->GetOrientation());
}
diff --git a/src/game/MovementHandler.cpp b/src/game/MovementHandler.cpp
index 83b024047d3..b41b04728da 100644
--- a/src/game/MovementHandler.cpp
+++ b/src/game/MovementHandler.cpp
@@ -96,7 +96,7 @@ void WorldSession::HandleMoveWorldportAckOpcode()
// cleanup seting if outdated
if(!mEntry->IsBattleGroundOrArena())
{
- _player->SetBattleGroundId(0); // We're not in BG.
+ _player->SetBattleGroundId(0, BATTLEGROUND_TYPE_NONE); // We're not in BG.
// reset destination bg team
_player->SetBGTeam(0);
}
diff --git a/src/game/Player.cpp b/src/game/Player.cpp
index eba15e63e40..850cdfdc0a9 100644
--- a/src/game/Player.cpp
+++ b/src/game/Player.cpp
@@ -370,6 +370,7 @@ Player::Player (WorldSession *session): Unit(), m_achievementMgr(this)
m_DetectInvTimer = 1000;
m_bgBattleGroundID = 0;
+ m_bgTypeID = BATTLEGROUND_TYPE_NONE;
for (int j=0; j < PLAYER_MAX_BATTLEGROUND_QUEUES; j++)
{
m_bgBattleGroundQueueID[j].bgQueueTypeId = BATTLEGROUND_QUEUE_NONE;
@@ -4347,7 +4348,7 @@ void Player::RepopAtGraveyard()
WorldSafeLocsEntry const *ClosestGrave = NULL;
// Special handle for battleground maps
- BattleGround *bg = sBattleGroundMgr.GetBattleGround(GetBattleGroundId());
+ BattleGround *bg = sBattleGroundMgr.GetBattleGround(GetBattleGroundId(), m_bgTypeID);
if(bg && (bg->GetTypeID() == BATTLEGROUND_AB || bg->GetTypeID() == BATTLEGROUND_EY || bg->GetTypeID() == BATTLEGROUND_AV))
ClosestGrave = bg->GetClosestGraveYard(GetPositionX(), GetPositionY(), GetPositionZ(), GetTeam());
@@ -14609,14 +14610,14 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
if(!mapEntry || mapEntry->Instanceable() || !MapManager::IsValidMapCoord(m_bgEntryPoint))
SetBattleGroundEntryPoint(m_homebindMapId,m_homebindX,m_homebindY,m_homebindZ,0.0f);
- BattleGround *currentBg = sBattleGroundMgr.GetBattleGround(bgid);
+ BattleGround *currentBg = sBattleGroundMgr.GetBattleGround(bgid, BATTLEGROUND_TYPE_NONE);
if(currentBg && currentBg->IsPlayerInBattleGround(GetGUID()))
{
BattleGroundQueueTypeId bgQueueTypeId = sBattleGroundMgr.BGQueueTypeId(currentBg->GetTypeID(), currentBg->GetArenaType());
uint32 queueSlot = AddBattleGroundQueueId(bgQueueTypeId);
- SetBattleGroundId(currentBg->GetInstanceID());
+ SetBattleGroundId(currentBg->GetInstanceID(), currentBg->GetTypeID());
SetBGTeam(bgteam);
//join player to battleground group
@@ -19050,7 +19051,7 @@ BattleGround* Player::GetBattleGround() const
if(GetBattleGroundId()==0)
return NULL;
- return sBattleGroundMgr.GetBattleGround(GetBattleGroundId());
+ return sBattleGroundMgr.GetBattleGround(GetBattleGroundId(), m_bgTypeID);
}
bool Player::InArena() const
diff --git a/src/game/Player.h b/src/game/Player.h
index 5a585d3fa51..12a2b5dff62 100644
--- a/src/game/Player.h
+++ b/src/game/Player.h
@@ -1864,9 +1864,10 @@ class TRINITY_DLL_SPEC Player : public Unit
/*** BATTLEGROUND SYSTEM ***/
/*********************************************************/
- bool InBattleGround() const { return m_bgBattleGroundID != 0; }
- bool InArena() const;
- uint32 GetBattleGroundId() const { return m_bgBattleGroundID; }
+ bool InBattleGround() const { return m_bgBattleGroundID != 0; }
+ bool InArena() const;
+ uint32 GetBattleGroundId() const { return m_bgBattleGroundID; }
+ BattleGroundTypeId GetBattleGroundTypeId() const { return m_bgTypeID; }
BattleGround* GetBattleGround() const;
@@ -1900,7 +1901,11 @@ class TRINITY_DLL_SPEC Player : public Unit
return GetBattleGroundQueueIndex(bgQueueTypeId) < PLAYER_MAX_BATTLEGROUND_QUEUES;
}
- void SetBattleGroundId(uint32 val) { m_bgBattleGroundID = val; }
+ void SetBattleGroundId(uint32 val, BattleGroundTypeId bgTypeId)
+ {
+ m_bgBattleGroundID = val;
+ m_bgTypeID = bgTypeId;
+ }
uint32 AddBattleGroundQueueId(BattleGroundQueueTypeId val)
{
for (int i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; i++)
@@ -2169,6 +2174,7 @@ class TRINITY_DLL_SPEC Player : public Unit
/* this variable is set to bg->m_InstanceID, when player is teleported to BG - (it is battleground's GUID)*/
uint32 m_bgBattleGroundID;
+ BattleGroundTypeId m_bgTypeID;
/*
this is an array of BG queues (BgTypeIDs) in which is player
*/
diff --git a/src/game/SharedDefines.h b/src/game/SharedDefines.h
index f359fab74f6..cc425083074 100644
--- a/src/game/SharedDefines.h
+++ b/src/game/SharedDefines.h
@@ -2296,6 +2296,7 @@ enum BanReturn
// indexes of BattlemasterList.dbc
enum BattleGroundTypeId
{
+ BATTLEGROUND_TYPE_NONE = 0,
BATTLEGROUND_AV = 1,
BATTLEGROUND_WS = 2,
BATTLEGROUND_AB = 3,
diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h
index 8e9b6a0b264..353577efd89 100644
--- a/src/shared/revision_nr.h
+++ b/src/shared/revision_nr.h
@@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
- #define REVISION_NR "7352"
+ #define REVISION_NR "7353"
#endif // __REVISION_NR_H__