TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Battleground Class Reference

#include <Battleground.h>

Public Types

typedef std::map< ObjectGuid,
BattlegroundPlayer
BattlegroundPlayerMap
 
typedef std::map< ObjectGuid,
BattlegroundScore * > 
BattlegroundScoreMap
 

Public Member Functions

 Battleground ()
 
virtual ~Battleground ()
 
void Update (uint32 diff)
 
virtual bool SetupBattleground ()
 
virtual void Reset ()
 
virtual void StartingEventCloseDoors ()
 
virtual void StartingEventOpenDoors ()
 
virtual void ResetBGSubclass ()
 
virtual void DestroyGate (Player *, GameObject *)
 
virtual bool IsAllNodesControlledByTeam (uint32) const
 
void StartTimedAchievement (AchievementCriteriaTimedTypes type, uint32 entry)
 
virtual bool CheckAchievementCriteriaMeet (uint32, Player const *, Unit const *=NULL, uint32=0)
 
std::string constGetName () const
 
uint64 GetQueueId () const
 
BattlegroundTypeId GetTypeID (bool GetRandom=false) const
 
BattlegroundBracketId GetBracketId () const
 
uint32 GetInstanceID () const
 
BattlegroundStatus GetStatus () const
 
uint32 GetClientInstanceID () const
 
uint32 GetElapsedTime () const
 
uint32 GetRemainingTime () const
 
uint32 GetLastResurrectTime () const
 
uint32 GetMaxPlayers () const
 
uint32 GetMinPlayers () const
 
uint32 GetMinLevel () const
 
uint32 GetMaxLevel () const
 
uint32 GetMaxPlayersPerTeam () const
 
uint32 GetMinPlayersPerTeam () const
 
int32 GetStartDelayTime () const
 
uint8 GetArenaType () const
 
BattlegroundTeamId GetWinner () const
 
uint32 GetScriptId () const
 
uint32 GetBonusHonorFromKill (uint32 kills) const
 
bool IsRandom () const
 
void SetQueueId (uint64 queueId)
 
void SetName (std::string const &name)
 
void SetTypeID (BattlegroundTypeId TypeID)
 
void SetRandomTypeID (BattlegroundTypeId TypeID)
 
void SetBracket (PvPDifficultyEntry const *bracketEntry)
 
void SetInstanceID (uint32 InstanceID)
 
void SetStatus (BattlegroundStatus Status)
 
void SetClientInstanceID (uint32 InstanceID)
 
void SetElapsedTime (uint32 Time)
 
void SetRemainingTime (uint32 Time)
 
void SetLastResurrectTime (uint32 Time)
 
void SetMaxPlayers (uint32 MaxPlayers)
 
void SetMinPlayers (uint32 MinPlayers)
 
void SetLevelRange (uint32 min, uint32 max)
 
void SetRated (bool state)
 
void SetArenaType (uint8 type)
 
void SetArenaorBGType (bool _isArena)
 
void SetWinner (BattlegroundTeamId winnerTeamId)
 
void SetScriptId (uint32 scriptId)
 
void ModifyStartDelayTime (int diff)
 
void SetStartDelayTime (int Time)
 
void SetMaxPlayersPerTeam (uint32 MaxPlayers)
 
void SetMinPlayersPerTeam (uint32 MinPlayers)
 
void AddToBGFreeSlotQueue ()
 
void RemoveFromBGFreeSlotQueue ()
 
void DecreaseInvitedCount (uint32 team)
 
void IncreaseInvitedCount (uint32 team)
 
void SetRandom (bool isRandom)
 
uint32 GetInvitedCount (uint32 team) const
 
bool HasFreeSlots () const
 
uint32 GetFreeSlotsForTeam (uint32 Team) const
 
bool isArena () const
 
bool isBattleground () const
 
bool isRated () const
 
BattlegroundPlayerMap constGetPlayers () const
 
uint32 GetPlayersSize () const
 
uint32 GetPlayerScoresSize () const
 
uint32 GetReviveQueueSize () const
 
void AddPlayerToResurrectQueue (ObjectGuid npc_guid, ObjectGuid player_guid)
 
void RemovePlayerFromResurrectQueue (ObjectGuid player_guid)
 
void RelocateDeadPlayers (ObjectGuid guideGuid)
 Relocate all players in ReviveQueue to the closest graveyard. More...
 
void StartBattleground ()
 
GameObjectGetBGObject (uint32 type, bool logError=true)
 
CreatureGetBGCreature (uint32 type, bool logError=true)
 
void SetMapId (uint32 MapID)
 
uint32 GetMapId () const
 
void SetBgMap (BattlegroundMap *map)
 
BattlegroundMapGetBgMap () const
 
BattlegroundMapFindBgMap () const
 
void SetTeamStartPosition (TeamId teamId, Position const &pos)
 
Position constGetTeamStartPosition (TeamId teamId) const
 
void SetStartMaxDist (float startMaxDist)
 
float GetStartMaxDist () const
 
virtual void FillInitialWorldStates (WorldPackets::WorldState::InitWorldStates &)
 
void SendPacketToTeam (uint32 TeamID, WorldPacket const *packet, Player *sender=NULL, bool self=true) const
 
void SendPacketToAll (WorldPacket const *packet) const
 
void SendChatMessage (Creature *source, uint8 textId, WorldObject *target=NULL)
 
template<class Do >
void BroadcastWorker (Do &_do)
 
void PlaySoundToTeam (uint32 SoundID, uint32 TeamID)
 
void PlaySoundToAll (uint32 SoundID)
 
void CastSpellOnTeam (uint32 SpellID, uint32 TeamID)
 
void RemoveAuraOnTeam (uint32 SpellID, uint32 TeamID)
 
void RewardHonorToTeam (uint32 Honor, uint32 TeamID)
 
void RewardReputationToTeam (uint32 faction_id, uint32 Reputation, uint32 TeamID)
 
void UpdateWorldState (uint32 variable, uint32 value, bool hidden=false)
 
virtual void EndBattleground (uint32 winner)
 
void BlockMovement (Player *player)
 
void SendMessageToAll (uint32 entry, ChatMsg type, Player const *source=NULL)
 
void PSendMessageToAll (uint32 entry, ChatMsg type, Player const *source,...)
 
void SendMessage2ToAll (uint32 entry, ChatMsg type, Player const *source, uint32 strId1=0, uint32 strId2=0)
 
GroupGetBgRaid (uint32 TeamID) const
 
void SetBgRaid (uint32 TeamID, Group *bg_raid)
 
void BuildPvPLogDataPacket (WorldPackets::Battleground::PVPLogData &pvpLogData)
 
virtual bool UpdatePlayerScore (Player *player, uint32 type, uint32 value, bool doAddHonor=true)
 
uint32 GetPlayersCountByTeam (uint32 Team) const
 
uint32 GetAlivePlayersCountByTeam (uint32 Team) const
 
void UpdatePlayersCountByTeam (uint32 Team, bool remove)
 
virtual void CheckWinConditions ()
 
void SetArenaTeamIdForTeam (uint32 Team, uint32 ArenaTeamId)
 
uint32 GetArenaTeamIdForTeam (uint32 Team) const
 
uint32 GetArenaTeamIdByIndex (uint32 index) const
 
void SetArenaMatchmakerRating (uint32 Team, uint32 MMR)
 
uint32 GetArenaMatchmakerRating (uint32 Team) const
 
virtual void HandleAreaTrigger (Player *, uint32, bool)
 
virtual void HandleKillPlayer (Player *player, Player *killer)
 
virtual void HandleKillUnit (Creature *, Player *)
 
virtual void EventPlayerDroppedFlag (Player *)
 
virtual void EventPlayerClickedOnFlag (Player *, GameObject *)
 
void EventPlayerLoggedIn (Player *player)
 
void EventPlayerLoggedOut (Player *player)
 
virtual void ProcessEvent (WorldObject *, uint32, WorldObject *=NULL)
 
virtual void DoAction (uint32, ObjectGuid)
 
virtual void HandlePlayerResurrect (Player *)
 
virtual WorldSafeLocsEntry constGetClosestGraveYard (Player *player)
 
virtual void AddPlayer (Player *player)
 
void AddOrSetPlayerToCorrectBgGroup (Player *player, uint32 team)
 
virtual void RemovePlayerAtLeave (ObjectGuid guid, bool Transport, bool SendPacket)
 
void HandleTriggerBuff (ObjectGuid go_guid)
 
void SetHoliday (bool is_holiday)
 
void SpawnBGObject (uint32 type, uint32 respawntime)
 
virtual bool AddObject (uint32 type, uint32 entry, float x, float y, float z, float o, float rotation0, float rotation1, float rotation2, float rotation3, uint32 respawnTime=0, GOState goState=GO_STATE_READY)
 
bool AddObject (uint32 type, uint32 entry, Position const &pos, float rotation0, float rotation1, float rotation2, float rotation3, uint32 respawnTime=0, GOState goState=GO_STATE_READY)
 
virtual CreatureAddCreature (uint32 entry, uint32 type, float x, float y, float z, float o, TeamId teamId=TEAM_NEUTRAL, uint32 respawntime=0, Transport *transport=NULL)
 
CreatureAddCreature (uint32 entry, uint32 type, Position const &pos, TeamId teamId=TEAM_NEUTRAL, uint32 respawntime=0, Transport *transport=NULL)
 
bool DelCreature (uint32 type)
 
bool DelObject (uint32 type)
 
virtual bool AddSpiritGuide (uint32 type, float x, float y, float z, float o, TeamId teamId=TEAM_NEUTRAL)
 
bool AddSpiritGuide (uint32 type, Position const &pos, TeamId teamId=TEAM_NEUTRAL)
 
int32 GetObjectType (ObjectGuid guid)
 
void DoorOpen (uint32 type)
 
void DoorClose (uint32 type)
 
virtual bool HandlePlayerUnderMap (Player *)
 
uint32 GetPlayerTeam (ObjectGuid guid) const
 
uint32 GetOtherTeam (uint32 teamId) const
 
bool IsPlayerInBattleground (ObjectGuid guid) const
 
bool ToBeDeleted () const
 
void SetDeleteThis ()
 
void RewardXPAtKill (Player *killer, Player *victim)
 
bool CanAwardArenaPoints () const
 
virtual ObjectGuid GetFlagPickerGUID (int32=-1) const
 
virtual void SetDroppedFlagGUID (ObjectGuid, int32=-1)
 
virtual void HandleQuestComplete (uint32, Player *)
 
virtual bool CanActivateGO (int32, uint32) const
 
virtual bool IsSpellAllowed (uint32, Player const *) const
 
uint32 GetTeamScore (uint32 TeamID) const
 
virtual uint32 GetPrematureWinner ()
 
uint8 GetUniqueBracketId () const
 

Static Public Member Functions

static TeamId GetTeamIndexByTeamId (uint32 Team)
 

Public Attributes

GuidVector BgObjects
 
GuidVector BgCreatures
 

Protected Member Functions

void EndNow ()
 
void PlayerAddedToBGCheckIfBGIsRunning (Player *player)
 
Player_GetPlayer (ObjectGuid guid, bool offlineRemove, const char *context) const
 
Player_GetPlayer (BattlegroundPlayerMap::iterator itr, const char *context)
 
Player_GetPlayer (BattlegroundPlayerMap::const_iterator itr, const char *context) const
 
Player_GetPlayerForTeam (uint32 teamId, BattlegroundPlayerMap::const_iterator itr, const char *context) const
 
virtual bool PreUpdateImpl (uint32)
 Pre-update hook. More...
 
virtual void PostUpdateImpl (uint32)
 Post-update hook. More...
 
void _ProcessOfflineQueue ()
 
void _ProcessResurrect (uint32 diff)
 
void _ProcessProgress (uint32 diff)
 
void _ProcessLeave (uint32 diff)
 
void _ProcessJoin (uint32 diff)
 
void _CheckSafePositions (uint32 diff)
 
void _ProcessPlayerPositionBroadcast (uint32 diff)
 
virtual void GetPlayerPositionData (std::vector< WorldPackets::Battleground::BattlegroundPlayerPosition > *) const
 
virtual void RemovePlayer (Player *, ObjectGuid, uint32)
 

Protected Attributes

BattlegroundScoreMap PlayerScores
 
BattlegroundPlayerMap m_Players
 
std::map< ObjectGuid, GuidVectorm_ReviveQueue
 
uint8 m_Events
 
BattlegroundStartTimeIntervals StartDelayTimes [BG_STARTING_EVENT_COUNT]
 
uint32 StartMessageIds [BG_STARTING_EVENT_COUNT]
 
bool m_BuffChange
 
bool m_IsRandom
 
BGHonorMode m_HonorMode
 
int32 m_TeamScores [BG_TEAMS_COUNT]
 
ArenaTeamScore _arenaTeamScores [BG_TEAMS_COUNT]
 

Private Attributes

BattlegroundTypeId m_TypeID
 
BattlegroundTypeId m_RandomTypeID
 
uint32 m_InstanceID
 
BattlegroundStatus m_Status
 
uint32 m_ClientInstanceID
 
uint32 m_StartTime
 
uint32 m_CountdownTimer
 
uint32 m_ResetStatTimer
 
uint32 m_ValidStartPositionTimer
 
int32 m_EndTime
 
uint32 m_LastResurrectTime
 
BattlegroundBracketId m_BracketId
 
uint8 m_ArenaType
 
bool m_InBGFreeSlotQueue
 
bool m_SetDeleteThis
 
bool m_IsArena
 
BattlegroundTeamId _winnerTeamId
 
int32 m_StartDelayTime
 
bool m_IsRated
 
bool m_PrematureCountDown
 
uint32 m_PrematureCountDownTimer
 
std::string m_Name
 
uint64 m_queueId
 
uint32 m_LastPlayerPositionBroadcast
 
GuidVector m_ResurrectQueue
 
GuidDeque m_OfflineQueue
 
uint32 m_InvitedAlliance
 
uint32 m_InvitedHorde
 
Groupm_BgRaids [BG_TEAMS_COUNT]
 
uint32 m_PlayersCount [BG_TEAMS_COUNT]
 
uint32 m_ArenaTeamIds [BG_TEAMS_COUNT]
 
uint32 m_ArenaTeamMMR [BG_TEAMS_COUNT]
 
uint32 m_LevelMin
 
uint32 m_LevelMax
 
uint32 m_MaxPlayersPerTeam
 
uint32 m_MaxPlayers
 
uint32 m_MinPlayersPerTeam
 
uint32 m_MinPlayers
 
uint32 m_MapId
 
BattlegroundMapm_Map
 
Position StartPosition [BG_TEAMS_COUNT]
 
float m_StartMaxDist
 
uint32 ScriptId
 

Member Typedef Documentation

Constructor & Destructor Documentation

Battleground::Battleground ( )
119 {
122  m_InstanceID = 0;
124  m_ClientInstanceID = 0;
125  m_EndTime = 0;
128  m_InvitedAlliance = 0;
129  m_InvitedHorde = 0;
130  m_ArenaType = 0;
131  m_IsArena = false;
133  m_StartTime = 0;
134  m_CountdownTimer = 0;
135  m_ResetStatTimer = 0;
137  m_Events = 0;
138  m_StartDelayTime = 0;
139  m_IsRated = false;
140  m_BuffChange = false;
141  m_IsRandom = false;
142  m_LevelMin = 0;
143  m_LevelMax = 0;
144  m_InBGFreeSlotQueue = false;
145  m_SetDeleteThis = false;
146 
148  m_MaxPlayers = 0;
150  m_MinPlayers = 0;
151 
152  m_MapId = 0;
153  m_Map = NULL;
154  m_StartMaxDist = 0.0f;
155  ScriptId = 0;
156 
159 
162 
165 
168 
171 
172  m_PrematureCountDown = false;
174 
175  m_queueId = 0;
176 
178 
180 
185  //we must set to some default existing values
190 }
uint32 m_MinPlayersPerTeam
Definition: Battleground.h:619
int32 m_StartDelayTime
Definition: Battleground.h:585
int32 m_TeamScores[BG_TEAMS_COUNT]
Definition: Battleground.h:562
Definition: Battleground.h:199
bool m_BuffChange
Definition: Battleground.h:558
uint32 m_ResetStatTimer
Definition: Battleground.h:575
BattlegroundTypeId m_RandomTypeID
Definition: Battleground.h:569
uint32 ScriptId
Definition: Battleground.h:627
Definition: Battleground.h:142
Definition: Battleground.h:200
Definition: DBCEnums.h:59
uint32 m_ValidStartPositionTimer
Definition: Battleground.h:576
uint32 m_CountdownTimer
Definition: Battleground.h:574
BattlegroundStartTimeIntervals StartDelayTimes[BG_STARTING_EVENT_COUNT]
Definition: Battleground.h:554
BattlegroundStatus m_Status
Definition: Battleground.h:571
uint32 m_PrematureCountDownTimer
Definition: Battleground.h:588
Definition: Language.h:636
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: Language.h:638
bool m_PrematureCountDown
Definition: Battleground.h:587
uint32 m_LevelMin
Definition: Battleground.h:615
uint32 m_InvitedHorde
Definition: Battleground.h:601
uint32 m_MaxPlayersPerTeam
Definition: Battleground.h:617
BattlegroundTeamId _winnerTeamId
Definition: Battleground.h:584
uint32 m_StartTime
Definition: Battleground.h:573
int32 m_EndTime
Definition: Battleground.h:577
Definition: Battleground.h:198
uint32 m_MapId
Definition: Battleground.h:623
bool m_IsRated
Definition: Battleground.h:586
Group * m_BgRaids[BG_TEAMS_COUNT]
Definition: Battleground.h:604
uint32 m_InstanceID
Definition: Battleground.h:570
Definition: Language.h:639
uint32 m_MinPlayers
Definition: Battleground.h:620
uint32 m_MaxPlayers
Definition: Battleground.h:618
uint32 m_LastResurrectTime
Definition: Battleground.h:578
uint8 m_ArenaType
Definition: Battleground.h:580
uint64 m_queueId
Definition: Battleground.h:590
uint32 StartMessageIds[BG_STARTING_EVENT_COUNT]
Definition: Battleground.h:556
uint32 m_LastPlayerPositionBroadcast
Definition: Battleground.h:591
uint32 m_ClientInstanceID
Definition: Battleground.h:572
Definition: SharedDefines.h:992
uint32 m_PlayersCount[BG_TEAMS_COUNT]
Definition: Battleground.h:607
bool m_IsRandom
Definition: Battleground.h:559
Definition: Language.h:637
bool m_IsArena
Definition: Battleground.h:583
uint8 m_Events
Definition: Battleground.h:553
uint32 m_InvitedAlliance
Definition: Battleground.h:600
Definition: SharedDefines.h:4552
Definition: Battleground.h:139
BattlegroundMap * m_Map
Definition: Battleground.h:624
BattlegroundBracketId m_BracketId
Definition: Battleground.h:579
Definition: Battleground.h:206
bool m_SetDeleteThis
Definition: Battleground.h:582
uint32 m_ArenaTeamMMR[BG_TEAMS_COUNT]
Definition: Battleground.h:612
BattlegroundTypeId m_TypeID
Definition: Battleground.h:568
Definition: Battleground.h:140
bool m_InBGFreeSlotQueue
Definition: Battleground.h:581
uint32 m_LevelMax
Definition: Battleground.h:616
Definition: Battleground.h:156
Definition: SharedDefines.h:4560
uint32 m_ArenaTeamIds[BG_TEAMS_COUNT]
Definition: Battleground.h:610
Definition: SharedDefines.h:993
Definition: Battleground.h:138
Definition: Battleground.h:197
float m_StartMaxDist
Definition: Battleground.h:626
BGHonorMode m_HonorMode
Definition: Battleground.h:561
Battleground::~Battleground ( )
virtual
193 {
194  // remove objects and creatures
195  // (this is done automatically in mapmanager update, when the instance is reset after the reset time)
196  uint32 size = uint32(BgCreatures.size());
197  for (uint32 i = 0; i < size; ++i)
198  DelCreature(i);
199 
200  size = uint32(BgObjects.size());
201  for (uint32 i = 0; i < size; ++i)
202  DelObject(i);
203 
204  sBattlegroundMgr->RemoveBattleground(GetTypeID(), GetInstanceID());
205  // unload map
206  if (m_Map)
207  {
208  m_Map->SetUnload();
209  //unlink to prevent crash, always unlink all pointer reference before destruction
210  m_Map->SetBG(NULL);
211  m_Map = NULL;
212  }
213  // remove from bg free slot queue
215 
216  for (BattlegroundScoreMap::const_iterator itr = PlayerScores.begin(); itr != PlayerScores.end(); ++itr)
217  delete itr->second;
218 }
void SetBG(Battleground *bg)
Definition: Map.h:805
arena_t NULL
Definition: jemalloc_internal.h:624
bool DelObject(uint32 type)
Definition: Battleground.cpp:1658
GuidVector BgObjects
Definition: Battleground.h:452
GuidVector BgCreatures
Definition: Battleground.h:453
uint32_t uint32
Definition: Define.h:150
void RemoveFromBGFreeSlotQueue()
Definition: Battleground.cpp:1241
uint32 GetInstanceID() const
Definition: Battleground.h:265
BattlegroundMap * m_Map
Definition: Battleground.h:624
bool DelCreature(uint32 type)
Definition: Battleground.cpp:1640
void SetUnload()
Definition: Map.cpp:3511
#define sBattlegroundMgr
Definition: BattlegroundMgr.h:181
BattlegroundTypeId GetTypeID(bool GetRandom=false) const
Definition: Battleground.h:263
uint32_t uint32
Definition: g3dmath.h:168
BattlegroundScoreMap PlayerScores
Definition: Battleground.h:543

+ Here is the call graph for this function:

Member Function Documentation

void Battleground::_CheckSafePositions ( uint32  diff)
inlineprotected
291 {
292  float maxDist = GetStartMaxDist();
293  if (!maxDist)
294  return;
295 
298  {
300 
301  for (BattlegroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr)
302  if (Player* player = ObjectAccessor::FindPlayer(itr->first))
303  {
304  Position pos = player->GetPosition();
305  Position const* startPos = GetTeamStartPosition(Battleground::GetTeamIndexByTeamId(player->GetBGTeam()));
306  if (pos.GetExactDistSq(startPos) > maxDist)
307  {
308  TC_LOG_DEBUG("bg.battleground", "BATTLEGROUND: Sending %s back to start location (map: %u) (possible exploit)", player->GetName().c_str(), GetMapId());
309  player->TeleportTo(GetMapId(), startPos->GetPositionX(), startPos->GetPositionY(), startPos->GetPositionZ(), startPos->GetOrientation());
310  }
311  }
312  }
313 }
Definition: Battleground.h:121
uint32 m_ValidStartPositionTimer
Definition: Battleground.h:576
float GetStartMaxDist() const
Definition: Battleground.h:363
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
BattlegroundPlayerMap const & GetPlayers() const
Definition: Battleground.h:331
Position const * GetTeamStartPosition(TeamId teamId) const
Definition: Battleground.cpp:651
static TeamId GetTeamIndexByTeamId(uint32 Team)
Definition: Battleground.h:399
TC_GAME_API Player * FindPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:209
float GetOrientation() const
Definition: Position.h:107
float GetPositionY() const
Definition: Position.h:105
void GetPosition(float &x, float &y) const
Definition: Position.h:109
float GetExactDistSq(float x, float y, float z) const
Definition: Position.h:152
float GetPositionZ() const
Definition: Position.h:106
Definition: Position.h:27
uint32 GetMapId() const
Definition: Battleground.h:352
float GetPositionX() const
Definition: Position.h:104

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Player * Battleground::_GetPlayer ( ObjectGuid  guid,
bool  offlineRemove,
const char *  context 
) const
protected
618 {
619  Player* player = NULL;
620  if (!offlineRemove)
621  {
622  // should this be ObjectAccessor::FindConnectedPlayer() to return players teleporting ?
623  player = ObjectAccessor::FindPlayer(guid);
624  if (!player)
625  TC_LOG_ERROR("bg.battleground", "Battleground::%s: player (%s) not found for BG (map: %u, instance id: %u)!",
626  context, guid.ToString().c_str(), m_MapId, m_InstanceID);
627  }
628  return player;
629 }
arena_t NULL
Definition: jemalloc_internal.h:624
uint32 m_MapId
Definition: Battleground.h:623
TC_GAME_API Player * FindPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:209
uint32 m_InstanceID
Definition: Battleground.h:570
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Player* Battleground::_GetPlayer ( BattlegroundPlayerMap::iterator  itr,
const char *  context 
)
inlineprotected
499 { return _GetPlayer(itr->first, itr->second.OfflineRemoveTime != 0, context); }
Player * _GetPlayer(ObjectGuid guid, bool offlineRemove, const char *context) const
Definition: Battleground.cpp:617

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Player* Battleground::_GetPlayer ( BattlegroundPlayerMap::const_iterator  itr,
const char *  context 
) const
inlineprotected
500 { return _GetPlayer(itr->first, itr->second.OfflineRemoveTime != 0, context); }
Player * _GetPlayer(ObjectGuid guid, bool offlineRemove, const char *context) const
Definition: Battleground.cpp:617

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Player * Battleground::_GetPlayerForTeam ( uint32  teamId,
BattlegroundPlayerMap::const_iterator  itr,
const char *  context 
) const
protected
632 {
633  Player* player = _GetPlayer(itr, context);
634  if (player)
635  {
636  uint32 team = itr->second.Team;
637  if (!team)
638  team = player->GetTeam();
639  if (team != teamId)
640  player = NULL;
641  }
642  return player;
643 }
arena_t NULL
Definition: jemalloc_internal.h:624
uint32_t uint32
Definition: Define.h:150
Player * _GetPlayer(ObjectGuid guid, bool offlineRemove, const char *context) const
Definition: Battleground.cpp:617

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Battleground::_ProcessJoin ( uint32  diff)
inlineprotected
Todo:
add arena sound PlaySoundToAll(SOUND_ARENA_START);
453 {
454  // *********************************************************
455  // *** BATTLEGROUND STARTING SYSTEM ***
456  // *********************************************************
457  ModifyStartDelayTime(diff);
458 
459  if (!isArena())
460  SetRemainingTime(300000);
461 
462  if (m_ResetStatTimer > 5000)
463  {
464  m_ResetStatTimer = 0;
465  for (BattlegroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr)
466  if (Player* player = ObjectAccessor::FindPlayer(itr->first))
467  player->ResetAllPowers();
468  }
469 
470  // Send packet every 10 seconds until the 2nd field reach 0
471  if (m_CountdownTimer >= 10000)
472  {
473  uint32 countdownMaxForBGType = isArena() ? ARENA_COUNTDOWN_MAX : BATTLEGROUND_COUNTDOWN_MAX;
474 
475  WorldPacket data(SMSG_START_TIMER, 4+4+4);
476  data << uint32(0); // unk
477  data << uint32(countdownMaxForBGType - (GetElapsedTime() / 1000));
478  data << uint32(countdownMaxForBGType);
479 
480  for (BattlegroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr)
481  if (Player* player = ObjectAccessor::FindPlayer(itr->first))
482  player->GetSession()->SendPacket(&data);
483 
484  m_CountdownTimer = 0;
485  }
486 
487  if (!(m_Events & BG_STARTING_EVENT_1))
488  {
490 
491  if (!FindBgMap())
492  {
493  TC_LOG_ERROR("bg.battleground", "Battleground::_ProcessJoin: map (map id: %u, instance id: %u) is not created!", m_MapId, m_InstanceID);
494  EndNow();
495  return;
496  }
497 
498  // Setup here, only when at least one player has ported to the map
499  if (!SetupBattleground())
500  {
501  EndNow();
502  return;
503  }
504 
507  // First start warning - 2 or 1 minute
509  }
510  // After 1 minute or 30 seconds, warning is signaled
512  {
515  }
516  // After 30 or 15 seconds, warning is signaled
518  {
521  }
522  // Delay expired (after 2 or 1 minute)
523  else if (GetStartDelayTime() <= 0 && !(m_Events & BG_STARTING_EVENT_4))
524  {
526 
528 
532 
533  // Remove preparation
534  if (isArena())
535  {
537  for (BattlegroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr)
538  if (Player* player = ObjectAccessor::FindPlayer(itr->first))
539  {
540  // BG Status packet
542  uint32 queueSlot = player->GetBattlegroundQueueIndex(bgQueueTypeId);
543 
545  sBattlegroundMgr->BuildBattlegroundStatusActive(&battlefieldStatus, this, player, queueSlot, player->GetBattlegroundQueueJoinTime(bgQueueTypeId), GetArenaType());
546  player->SendDirectMessage(battlefieldStatus.Write());
547 
548  // Correctly display EnemyUnitFrame
549  player->SetByteValue(PLAYER_BYTES_3, PLAYER_BYTES_3_OFFSET_ARENA_FACTION, player->GetBGTeam());
550 
551  player->RemoveAurasDueToSpell(SPELL_ARENA_PREPARATION);
552  player->ResetAllPowers();
553  if (!player->IsGameMaster())
554  {
555  // remove auras with duration lower than 30s
556  Unit::AuraApplicationMap & auraMap = player->GetAppliedAuras();
557  for (Unit::AuraApplicationMap::iterator iter = auraMap.begin(); iter != auraMap.end();)
558  {
559  AuraApplication * aurApp = iter->second;
560  Aura* aura = aurApp->GetBase();
561  if (!aura->IsPermanent()
562  && aura->GetDuration() <= 30*IN_MILLISECONDS
563  && aurApp->IsPositive()
566  player->RemoveAura(iter);
567  else
568  ++iter;
569  }
570  }
571  }
572 
574  }
575  else
576  {
578 
579  for (BattlegroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr)
580  if (Player* player = ObjectAccessor::FindPlayer(itr->first))
581  {
582  player->RemoveAurasDueToSpell(SPELL_PREPARATION);
583  player->ResetAllPowers();
584  }
585  // Announce BG starting
587  sWorld->SendWorldText(LANG_BG_STARTED_ANNOUNCE_WORLD, GetName().c_str(), GetMinLevel(), GetMaxLevel());
588  }
589  }
590 
591  if (GetRemainingTime() > 0 && (m_EndTime -= diff) > 0)
593 }
SpellInfo const * GetSpellInfo() const
Definition: SpellAuras.h:130
Definition: Battleground.h:159
Definition: Battleground.h:199
WorldPacket const * Write() override
Definition: BattlegroundPackets.cpp:165
uint32 m_ResetStatTimer
Definition: Battleground.h:575
BattlegroundMap * FindBgMap() const
Definition: Battleground.h:357
void SetStartDelayTime(int Time)
Definition: Battleground.h:310
Definition: Battleground.h:200
uint32 m_CountdownTimer
Definition: Battleground.h:574
bool IsPermanent() const
Definition: SpellAuras.h:168
Aura * GetBase() const
Definition: SpellAuras.h:75
void SetRemainingTime(uint32 Time)
Definition: Battleground.h:298
BattlegroundStartTimeIntervals StartDelayTimes[BG_STARTING_EVENT_COUNT]
Definition: Battleground.h:554
Definition: SpellAuras.h:50
static BattlegroundQueueTypeId BGQueueTypeId(BattlegroundTypeId bgTypeId, uint8 arenaType)
Definition: BattlegroundMgr.cpp:623
uint32 Attributes
Definition: SpellInfo.h:333
BattlegroundPlayerMap const & GetPlayers() const
Definition: Battleground.h:331
#define sWorld
Definition: World.h:887
int32 m_EndTime
Definition: Battleground.h:577
Definition: Battleground.h:198
uint32 m_MapId
Definition: Battleground.h:623
Definition: UpdateFields.h:198
bool isArena() const
Definition: Battleground.h:326
virtual void StartingEventOpenDoors()
Definition: Battleground.h:249
virtual bool SetupBattleground()
Definition: Battleground.h:243
TC_GAME_API Player * FindPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:209
bool IsPositive() const
Definition: SpellAuras.h:81
void SendMessageToAll(uint32 entry, ChatMsg type, Player const *source=NULL)
Definition: Battleground.cpp:1706
virtual void CheckWinConditions()
Definition: Battleground.h:410
uint32 m_InstanceID
Definition: Battleground.h:570
uint8 GetArenaType() const
Definition: Battleground.h:281
void PlaySoundToAll(uint32 SoundID)
Definition: Battleground.cpp:681
Definition: SharedDefines.h:4267
Definition: Battleground.h:189
Definition: Battleground.h:59
virtual void StartingEventCloseDoors()
Definition: Battleground.h:248
std::string const & GetName() const
Definition: Battleground.h:261
uint32 StartMessageIds[BG_STARTING_EVENT_COUNT]
Definition: Battleground.h:556
uint32_t uint32
Definition: Define.h:150
Definition: Opcodes.h:1555
uint8 m_Events
Definition: Battleground.h:553
uint32 GetMaxLevel() const
Definition: Battleground.h:275
int32 GetDuration() const
Definition: SpellAuras.h:163
Definition: Player.h:590
Definition: Battleground.h:192
bool HasEffectType(AuraType type) const
Definition: SpellAuras.cpp:1186
int32 GetStartDelayTime() const
Definition: Battleground.h:280
BattlegroundQueueTypeId
Definition: SharedDefines.h:4732
uint32 GetRemainingTime() const
Definition: Battleground.h:269
Definition: Battleground.h:191
BattlegroundTypeId m_TypeID
Definition: Battleground.h:568
Definition: Common.h:103
Definition: BattlegroundPackets.h:170
#define sBattlegroundMgr
Definition: BattlegroundMgr.h:181
Definition: SpellAuraDefines.h:78
Definition: Battleground.h:132
Definition: Battleground.h:131
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
uint32_t uint32
Definition: g3dmath.h:168
Definition: SharedDefines.h:385
std::multimap< uint32, AuraApplication * > AuraApplicationMap
Definition: Unit.h:1315
Definition: SharedDefines.h:4272
uint32 GetMinLevel() const
Definition: Battleground.h:274
Definition: SpellAuras.h:116
Definition: Battleground.h:111
void EndNow()
Definition: Battleground.cpp:1738
void ModifyStartDelayTime(int diff)
Definition: Battleground.h:309
Definition: Battleground.h:190
Definition: Battleground.h:110
uint32 GetElapsedTime() const
Definition: Battleground.h:268
Definition: WorldPacket.h:26
void SetStatus(BattlegroundStatus Status)
Definition: Battleground.h:295
Definition: Language.h:719
Definition: Battleground.h:197

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Battleground::_ProcessLeave ( uint32  diff)
inlineprotected
596 {
597  // *********************************************************
598  // *** BATTLEGROUND ENDING SYSTEM ***
599  // *********************************************************
600  // remove all players from battleground after 2 minutes
602  if (GetRemainingTime() <= 0)
603  {
604  SetRemainingTime(0);
605  BattlegroundPlayerMap::iterator itr, next;
606  for (itr = m_Players.begin(); itr != m_Players.end(); itr = next)
607  {
608  next = itr;
609  ++next;
610  //itr is erased here!
611  RemovePlayerAtLeave(itr->first, true, true);// remove player from BG
612  // do not change any battleground's private variables
613  }
614  }
615 }
void SetRemainingTime(uint32 Time)
Definition: Battleground.h:298
int next(int i, int n)
Definition: RecastContour.cpp:469
BattlegroundPlayerMap m_Players
Definition: Battleground.h:548
uint32 GetRemainingTime() const
Definition: Battleground.h:269
virtual void RemovePlayerAtLeave(ObjectGuid guid, bool Transport, bool SendPacket)
Definition: Battleground.cpp:919

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Battleground::_ProcessOfflineQueue ( )
inlineprotected
329 {
330  // remove offline players from bg after 5 minutes
331  if (!m_OfflineQueue.empty())
332  {
333  BattlegroundPlayerMap::iterator itr = m_Players.find(*(m_OfflineQueue.begin()));
334  if (itr != m_Players.end())
335  {
336  if (itr->second.OfflineRemoveTime <= sWorld->GetGameTime())
337  {
338  RemovePlayerAtLeave(itr->first, true, true);// remove player from BG
339  m_OfflineQueue.pop_front(); // remove from offline queue
340  //do not use itr for anything, because it is erased in RemovePlayerAtLeave()
341  }
342  }
343  }
344 }
BattlegroundPlayerMap m_Players
Definition: Battleground.h:548
#define sWorld
Definition: World.h:887
GuidDeque m_OfflineQueue
Definition: Battleground.h:595
virtual void RemovePlayerAtLeave(ObjectGuid guid, bool Transport, bool SendPacket)
Definition: Battleground.cpp:919

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Battleground::_ProcessPlayerPositionBroadcast ( uint32  diff)
protected
316 {
319  {
321 
323  GetPlayerPositionData(&playerPositions.FlagCarriers);
324  SendPacketToAll(playerPositions.Write());
325  }
326 }
uint32 m_LastPlayerPositionBroadcast
Definition: Battleground.h:591
std::vector< BattlegroundPlayerPosition > FlagCarriers
Definition: BattlegroundPackets.h:360
void SendPacketToAll(WorldPacket const *packet) const
Definition: Battleground.cpp:657
Definition: Battleground.h:133
WorldPacket const * Write() override
Definition: BattlegroundPackets.cpp:262
Definition: BattlegroundPackets.h:353
virtual void GetPlayerPositionData(std::vector< WorldPackets::Battleground::BattlegroundPlayerPosition > *) const
Definition: Battleground.h:540

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Battleground::_ProcessProgress ( uint32  diff)
inlineprotected
417 {
418  // *********************************************************
419  // *** BATTLEGROUND BALLANCE SYSTEM ***
420  // *********************************************************
421  // if less then minimum players are in on one side, then start premature finish timer
423  {
424  m_PrematureCountDown = true;
425  m_PrematureCountDownTimer = sBattlegroundMgr->GetPrematureFinishTime();
426  }
427  else if (m_PrematureCountDownTimer < diff)
428  {
429  // time's up!
431  m_PrematureCountDown = false;
432  }
433  else if (!sBattlegroundMgr->isTesting())
434  {
435  uint32 newtime = m_PrematureCountDownTimer - diff;
436  // announce every minute
437  if (newtime > (MINUTE * IN_MILLISECONDS))
438  {
439  if (newtime / (MINUTE * IN_MILLISECONDS) != m_PrematureCountDownTimer / (MINUTE * IN_MILLISECONDS))
441  }
442  else
443  {
444  //announce every 15 seconds
445  if (newtime / (15 * IN_MILLISECONDS) != m_PrematureCountDownTimer / (15 * IN_MILLISECONDS))
447  }
448  m_PrematureCountDownTimer = newtime;
449  }
450 }
virtual uint32 GetPrematureWinner()
Definition: Battleground.cpp:405
uint32 m_PrematureCountDownTimer
Definition: Battleground.h:588
arena_t NULL
Definition: jemalloc_internal.h:624
bool m_PrematureCountDown
Definition: Battleground.h:587
Definition: Common.h:97
uint32_t uint32
Definition: Define.h:150
Definition: SharedDefines.h:4231
Definition: Common.h:103
#define sBattlegroundMgr
Definition: BattlegroundMgr.h:181
void PSendMessageToAll(uint32 entry, ChatMsg type, Player const *source,...)
Definition: Battleground.cpp:1716
virtual void EndBattleground(uint32 winner)
Definition: Battleground.cpp:744

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Battleground::_ProcessResurrect ( uint32  diff)
inlineprotected
347 {
348  // *********************************************************
349  // *** BATTLEGROUND RESURRECTION SYSTEM ***
350  // *********************************************************
351  // this should be handled by spell system
352  m_LastResurrectTime += diff;
354  {
355  if (GetReviveQueueSize())
356  {
357  for (std::map<ObjectGuid, GuidVector>::iterator itr = m_ReviveQueue.begin(); itr != m_ReviveQueue.end(); ++itr)
358  {
359  Creature* sh = NULL;
360  for (GuidVector::const_iterator itr2 = (itr->second).begin(); itr2 != (itr->second).end(); ++itr2)
361  {
362  Player* player = ObjectAccessor::FindPlayer(*itr2);
363  if (!player)
364  continue;
365 
366  if (!sh && player->IsInWorld())
367  {
368  sh = player->GetMap()->GetCreature(itr->first);
369  // only for visual effect
370  if (sh)
371  // Spirit Heal, effect 117
372  sh->CastSpell(sh, SPELL_SPIRIT_HEAL, true);
373  }
374 
375  // Resurrection visual
376  player->CastSpell(player, SPELL_RESURRECTION_VISUAL, true);
377  m_ResurrectQueue.push_back(*itr2);
378  }
379  (itr->second).clear();
380  }
381 
382  m_ReviveQueue.clear();
384  }
385  else
386  // queue is clear and time passed, just update last resurrection time
388  }
389  else if (m_LastResurrectTime > 500) // Resurrect players only half a second later, to see spirit heal effect on NPC
390  {
391  for (GuidVector::const_iterator itr = m_ResurrectQueue.begin(); itr != m_ResurrectQueue.end(); ++itr)
392  {
393  Player* player = ObjectAccessor::FindPlayer(*itr);
394  if (!player)
395  continue;
396  player->ResurrectPlayer(1.0f);
397  player->CastSpell(player, 6962, true);
398  player->CastSpell(player, SPELL_SPIRIT_HEAL_MANA, true);
399  player->SpawnCorpseBones(false);
400  }
401  m_ResurrectQueue.clear();
402  }
403 }
Definition: Battleground.h:112
Definition: Battleground.h:122
Map * GetMap() const
Definition: Object.h:543
Definition: Battleground.h:109
arena_t NULL
Definition: jemalloc_internal.h:624
std::map< ObjectGuid, GuidVector > m_ReviveQueue
Definition: Battleground.h:550
Definition: Creature.h:467
uint32 GetReviveQueueSize() const
Definition: Battleground.h:337
TC_GAME_API Player * FindPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:209
Definition: Battleground.h:108
uint32 m_LastResurrectTime
Definition: Battleground.h:578
Creature * GetCreature(ObjectGuid const &guid)
Definition: Map.cpp:3535
GuidVector m_ResurrectQueue
Definition: Battleground.h:594
bool IsInWorld() const
Definition: Object.h:100
void CastSpell(SpellCastTargets const &targets, SpellInfo const *spellInfo, CustomSpellValues const *value, TriggerCastFlags triggerFlags=TRIGGERED_NONE, Item *castItem=NULL, AuraEffect const *triggeredByAura=NULL, ObjectGuid originalCaster=ObjectGuid::Empty)
Definition: Unit.cpp:869

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Creature * Battleground::AddCreature ( uint32  entry,
uint32  type,
float  x,
float  y,
float  z,
float  o,
TeamId  teamId = TEAM_NEUTRAL,
uint32  respawntime = 0,
Transport transport = NULL 
)
virtual
1581 {
1582  // If the assert is called, means that BgCreatures must be resized!
1583  ASSERT(type < BgCreatures.size());
1584 
1585  Map* map = FindBgMap();
1586  if (!map)
1587  return NULL;
1588 
1589  if (transport)
1590  {
1591  if (Creature* creature = transport->SummonPassenger(entry, { x, y, z, o }, TEMPSUMMON_MANUAL_DESPAWN))
1592  {
1593  BgCreatures[type] = creature->GetGUID();
1594  return creature;
1595  }
1596 
1597  return NULL;
1598  }
1599 
1600  Creature* creature = new Creature();
1601 
1602  if (!creature->Create(map->GenerateLowGuid<HighGuid::Creature>(), map, PHASEMASK_NORMAL, entry, x, y, z, o))
1603  {
1604  TC_LOG_ERROR("bg.battleground", "Battleground::AddCreature: cannot create creature (entry: %u) for BG (map: %u, instance id: %u)!",
1605  entry, m_MapId, m_InstanceID);
1606  delete creature;
1607  return NULL;
1608  }
1609 
1610  creature->SetHomePosition(x, y, z, o);
1611 
1612  CreatureTemplate const* cinfo = sObjectMgr->GetCreatureTemplate(entry);
1613  if (!cinfo)
1614  {
1615  TC_LOG_ERROR("bg.battleground", "Battleground::AddCreature: creature template (entry: %u) does not exist for BG (map: %u, instance id: %u)!",
1616  entry, m_MapId, m_InstanceID);
1617  delete creature;
1618  return NULL;
1619  }
1620 
1621  if (!map->AddToMap(creature))
1622  {
1623  delete creature;
1624  return NULL;
1625  }
1626 
1627  BgCreatures[type] = creature->GetGUID();
1628 
1629  if (respawntime)
1630  creature->SetRespawnDelay(respawntime);
1631 
1632  return creature;
1633 }
Definition: Object.h:61
BattlegroundMap * FindBgMap() const
Definition: Battleground.h:357
TempSummon * SummonPassenger(uint32 entry, Position const &pos, TempSummonType summonType, SummonPropertiesEntry const *properties=NULL, uint32 duration=0, Unit *summoner=NULL, uint32 spellId=0, uint32 vehId=0)
Temporarily summons a creature as passenger on this transport.
Definition: Transport.cpp:380
bool Create(ObjectGuid::LowType guidlow, Map *map, uint32 phaseMask, uint32 entry, float x, float y, float z, float ang, CreatureData const *data=nullptr, uint32 vehId=0)
Definition: Creature.cpp:834
arena_t NULL
Definition: jemalloc_internal.h:624
void SetHomePosition(float x, float y, float z, float o)
Definition: Creature.h:670
Definition: Creature.h:467
#define sObjectMgr
Definition: ObjectMgr.h:1567
uint32 m_MapId
Definition: Battleground.h:623
uint32 m_InstanceID
Definition: Battleground.h:570
GuidVector BgCreatures
Definition: Battleground.h:453
Definition: Object.h:66
G3D::int16 z
Definition: Vector3int16.h:46
G3D::int16 y
Definition: Vector2int16.h:38
Definition: Map.h:259
ObjectGuid const & GetGUID() const
Definition: Object.h:105
#define ASSERT
Definition: Errors.h:55
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
G3D::int16 x
Definition: Vector2int16.h:37
void SetRespawnDelay(uint32 delay)
Definition: Creature.h:638
Definition: Creature.h:79

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Creature * Battleground::AddCreature ( uint32  entry,
uint32  type,
Position const pos,
TeamId  teamId = TEAM_NEUTRAL,
uint32  respawntime = 0,
Transport transport = NULL 
)
1636 {
1637  return AddCreature(entry, type, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation(), teamId, respawntime, transport);
1638 }
virtual Creature * AddCreature(uint32 entry, uint32 type, float x, float y, float z, float o, TeamId teamId=TEAM_NEUTRAL, uint32 respawntime=0, Transport *transport=NULL)
Definition: Battleground.cpp:1580

+ Here is the call graph for this function:

bool Battleground::AddObject ( uint32  type,
uint32  entry,
float  x,
float  y,
float  z,
float  o,
float  rotation0,
float  rotation1,
float  rotation2,
float  rotation3,
uint32  respawnTime = 0,
GOState  goState = GO_STATE_READY 
)
virtual
1447 {
1448  // If the assert is called, means that BgObjects must be resized!
1449  ASSERT(type < BgObjects.size());
1450 
1451  Map* map = FindBgMap();
1452  if (!map)
1453  return false;
1454  // Must be created this way, adding to godatamap would add it to the base map of the instance
1455  // and when loading it (in go::LoadFromDB()), a new guid would be assigned to the object, and a new object would be created
1456  // So we must create it specific for this instance
1457  GameObject* go = new GameObject;
1458  if (!go->Create(GetBgMap()->GenerateLowGuid<HighGuid::GameObject>(), entry, GetBgMap(),
1459  PHASEMASK_NORMAL, x, y, z, o, rotation0, rotation1, rotation2, rotation3, 100, goState))
1460  {
1461  TC_LOG_ERROR("bg.battleground", "Battleground::AddObject: cannot create gameobject (entry: %u) for BG (map: %u, instance id: %u)!",
1462  entry, m_MapId, m_InstanceID);
1463  delete go;
1464  return false;
1465  }
1466 
1467 /*
1468  uint32 guid = go->GetGUIDLow();
1469 
1470  // without this, UseButtonOrDoor caused the crash, since it tried to get go info from godata
1471  // iirc that was changed, so adding to go data map is no longer required if that was the only function using godata from GameObject without checking if it existed
1472  GameObjectData& data = sObjectMgr->NewGOData(guid);
1473 
1474  data.id = entry;
1475  data.mapid = GetMapId();
1476  data.posX = x;
1477  data.posY = y;
1478  data.posZ = z;
1479  data.orientation = o;
1480  data.rotation0 = rotation0;
1481  data.rotation1 = rotation1;
1482  data.rotation2 = rotation2;
1483  data.rotation3 = rotation3;
1484  data.spawntimesecs = respawnTime;
1485  data.spawnMask = 1;
1486  data.animprogress = 100;
1487  data.go_state = 1;
1488 */
1489  // Add to world, so it can be later looked up from HashMapHolder
1490  if (!map->AddToMap(go))
1491  {
1492  delete go;
1493  return false;
1494  }
1495  BgObjects[type] = go->GetGUID();
1496  return true;
1497 }
BattlegroundMap * FindBgMap() const
Definition: Battleground.h:357
BattlegroundMap * GetBgMap() const
Definition: Battleground.h:356
uint32 m_MapId
Definition: Battleground.h:623
uint32 m_InstanceID
Definition: Battleground.h:570
GuidVector BgObjects
Definition: Battleground.h:452
Definition: Object.h:66
G3D::int16 z
Definition: Vector3int16.h:46
G3D::int16 y
Definition: Vector2int16.h:38
Definition: GameObject.h:880
Definition: Map.h:259
ObjectGuid const & GetGUID() const
Definition: Object.h:105
bool Create(ObjectGuid::LowType guidlow, uint32 name_id, Map *map, uint32 phaseMask, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint32 animprogress, GOState go_state, uint32 artKit=0)
Definition: GameObject.cpp:173
#define ASSERT
Definition: Errors.h:55
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
G3D::int16 x
Definition: Vector2int16.h:37

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Battleground::AddObject ( uint32  type,
uint32  entry,
Position const pos,
float  rotation0,
float  rotation1,
float  rotation2,
float  rotation3,
uint32  respawnTime = 0,
GOState  goState = GO_STATE_READY 
)
1500 {
1501  return AddObject(type, entry, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation(), rotation0, rotation1, rotation2, rotation3, respawnTime, goState);
1502 }
virtual bool AddObject(uint32 type, uint32 entry, float x, float y, float z, float o, float rotation0, float rotation1, float rotation2, float rotation3, uint32 respawnTime=0, GOState goState=GO_STATE_READY)
Definition: Battleground.cpp:1446

+ Here is the call graph for this function:

void Battleground::AddOrSetPlayerToCorrectBgGroup ( Player player,
uint32  team 
)
1160 {
1161  ObjectGuid playerGuid = player->GetGUID();
1162  Group* group = GetBgRaid(team);
1163  if (!group) // first player joined
1164  {
1165  group = new Group;
1166  SetBgRaid(team, group);
1167  group->Create(player);
1168  }
1169  else // raid already exist
1170  {
1171  if (group->IsMember(playerGuid))
1172  {
1173  uint8 subgroup = group->GetMemberGroup(playerGuid);
1174  player->SetBattlegroundOrBattlefieldRaid(group, subgroup);
1175  }
1176  else
1177  {
1178  group->AddMember(player);
1179  if (Group* originalGroup = player->GetOriginalGroup())
1180  if (originalGroup->IsLeader(playerGuid))
1181  {
1182  group->ChangeLeader(playerGuid);
1183  group->SendUpdate();
1184  }
1185  }
1186  }
1187 }
void SetBgRaid(uint32 TeamID, Group *bg_raid)
Definition: Battleground.cpp:1890
bool Create(Player *leader)
Definition: Group.cpp:98
bool AddMember(Player *player)
Definition: Group.cpp:368
static Summons Group[]
Definition: boss_urom.cpp:77
bool IsMember(ObjectGuid guid) const
Definition: Group.cpp:2566
uint8 GetMemberGroup(ObjectGuid guid) const
Definition: Group.cpp:2613
uint8_t uint8
Definition: Define.h:152
Definition: ObjectGuid.h:189
void SendUpdate()
Definition: Group.cpp:1567
Group * GetBgRaid(uint32 TeamID) const
Definition: Battleground.h:393
Definition: Group.h:191
void ChangeLeader(ObjectGuid guid, int8 partyIndex=0)
Definition: Group.cpp:651

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Battleground::AddPlayer ( Player player)
virtual

Reimplemented in BattlegroundAV, BattlegroundIC, BattlegroundSA, BattlegroundEY, BattlegroundAB, BattlegroundWS, and Arena.

1080 {
1081  // remove afk from player
1082  if (player->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_AFK))
1083  player->ToggleAFK();
1084 
1085  // score struct must be created in inherited class
1086 
1087  uint32 team = player->GetBGTeam();
1088 
1089  BattlegroundPlayer bp;
1090  bp.OfflineRemoveTime = 0;
1091  bp.Team = team;
1092  bp.ActiveSpec = player->GetSpecId(player->GetActiveTalentGroup());
1093 
1094  // Add to list/maps
1095  m_Players[player->GetGUID()] = bp;
1096 
1097  UpdatePlayersCountByTeam(team, false); // +1 player
1098 
1100  playerJoined.Guid = player->GetGUID();
1101  SendPacketToTeam(team, playerJoined.Write(), player, false);
1102 
1103  // BG Status packet
1104  BattlegroundQueueTypeId bgQueueTypeId = sBattlegroundMgr->BGQueueTypeId(m_TypeID, GetArenaType());
1105  uint32 queueSlot = player->GetBattlegroundQueueIndex(bgQueueTypeId);
1106 
1108  sBattlegroundMgr->BuildBattlegroundStatusActive(&battlefieldStatus, this, player, queueSlot, player->GetBattlegroundQueueJoinTime(bgQueueTypeId), GetArenaType());
1109  player->SendDirectMessage(battlefieldStatus.Write());
1110 
1111  player->RemoveAurasByType(SPELL_AURA_MOUNTED);
1112 
1113  // add arena specific auras
1114  if (isArena())
1115  {
1116  player->RemoveArenaEnchantments(TEMP_ENCHANTMENT_SLOT);
1117  player->DestroyConjuredItems(true);
1118  player->UnsummonPetTemporaryIfAny();
1119 
1120  if (GetStatus() == STATUS_WAIT_JOIN) // not started yet
1121  {
1122  player->CastSpell(player, SPELL_ARENA_PREPARATION, true);
1123  player->ResetAllPowers();
1124  }
1125  }
1126  else
1127  {
1128  if (GetStatus() == STATUS_WAIT_JOIN) // not started yet
1129  {
1130  player->CastSpell(player, SPELL_PREPARATION, true); // reduces all mana cost of spells.
1131 
1132  int32 countdownMaxForBGType = isArena() ? ARENA_COUNTDOWN_MAX : BATTLEGROUND_COUNTDOWN_MAX;
1133  WorldPacket data(SMSG_START_TIMER, 4+4+4);
1134  data << uint32(0); // unk
1135  data << uint32(countdownMaxForBGType - (GetElapsedTime() / 1000));
1136  data << uint32(countdownMaxForBGType);
1137  player->GetSession()->SendPacket(&data);
1138  }
1139  }
1140 
1142  player->ResetAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_WIN_BG, ACHIEVEMENT_CRITERIA_CONDITION_BG_MAP, GetMapId(), true);
1143  player->ResetAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_DAMAGE_DONE, ACHIEVEMENT_CRITERIA_CONDITION_BG_MAP, GetMapId(), true);
1145  player->ResetAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL, ACHIEVEMENT_CRITERIA_CONDITION_BG_MAP, GetMapId(), true);
1152 
1153  // setup BG group membership
1155  AddOrSetPlayerToCorrectBgGroup(player, team);
1156 }
WorldPacket const * Write() override
Definition: BattlegroundPackets.cpp:165
Definition: Player.h:518
void PlayerAddedToBGCheckIfBGIsRunning(Player *player)
Definition: Battleground.cpp:1842
Definition: DBCEnums.h:221
Definition: DBCEnums.h:208
Definition: DBCEnums.h:108
void AddOrSetPlayerToCorrectBgGroup(Player *player, uint32 team)
Definition: Battleground.cpp:1159
BattlegroundStatus GetStatus() const
Definition: Battleground.h:266
Definition: DBCEnums.h:199
BattlegroundPlayerMap m_Players
Definition: Battleground.h:548
Definition: DBCEnums.h:198
int32 ActiveSpec
Definition: Battleground.h:167
void SendPacketToTeam(uint32 TeamID, WorldPacket const *packet, Player *sender=NULL, bool self=true) const
Definition: Battleground.cpp:664
bool isArena() const
Definition: Battleground.h:326
Definition: Battleground.h:158
Definition: Item.h:175
uint8 GetArenaType() const
Definition: Battleground.h:281
uint32 Team
Definition: Battleground.h:166
int32_t int32
Definition: Define.h:146
uint32_t uint32
Definition: Define.h:150
WorldPacket const * Write() override
Definition: BattlegroundPackets.cpp:271
Definition: Opcodes.h:1555
Definition: DBCEnums.h:247
BattlegroundQueueTypeId
Definition: SharedDefines.h:4732
ObjectGuid Guid
Definition: BattlegroundPackets.h:370
BattlegroundTypeId m_TypeID
Definition: Battleground.h:568
time_t OfflineRemoveTime
Definition: Battleground.h:165
Definition: BattlegroundPackets.h:170
#define sBattlegroundMgr
Definition: BattlegroundMgr.h:181
Definition: BattlegroundPackets.h:363
Definition: Battleground.h:132
uint32 GetMapId() const
Definition: Battleground.h:352
Definition: Battleground.h:131
Definition: UpdateFields.h:191
uint32_t uint32
Definition: g3dmath.h:168
Definition: Battleground.h:111
Definition: Battleground.h:163
Definition: Battleground.h:110
uint32 GetElapsedTime() const
Definition: Battleground.h:268
Definition: WorldPacket.h:26
void UpdatePlayersCountByTeam(uint32 Team, bool remove)
Definition: Battleground.h:402
Definition: SpellAuraDefines.h:138

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Battleground::AddPlayerToResurrectQueue ( ObjectGuid  npc_guid,
ObjectGuid  player_guid 
)
1396 {
1397  m_ReviveQueue[npc_guid].push_back(player_guid);
1398 
1399  Player* player = ObjectAccessor::FindPlayer(player_guid);
1400  if (!player)
1401  return;
1402 
1403  player->CastSpell(player, SPELL_WAITING_FOR_RESURRECT, true);
1404 }
std::map< ObjectGuid, GuidVector > m_ReviveQueue
Definition: Battleground.h:550
TC_GAME_API Player * FindPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:209
Definition: Battleground.h:106

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Battleground::AddSpiritGuide ( uint32  type,
float  x,
float  y,
float  z,
float  o,
TeamId  teamId = TEAM_NEUTRAL 
)
virtual
Todo:
Fix display here
1677 {
1679 
1680  if (Creature* creature = AddCreature(entry, type, x, y, z, o, teamId))
1681  {
1682  creature->setDeathState(DEAD);
1683  creature->SetChannelObjectGuid(creature->GetGUID());
1684  // aura
1686  // creature->SetVisibleAura(0, SPELL_SPIRIT_HEAL_CHANNEL);
1687  // casting visual effect
1688  creature->SetUInt32Value(UNIT_CHANNEL_SPELL, SPELL_SPIRIT_HEAL_CHANNEL);
1689  // correct cast speed
1690  creature->SetFloatValue(UNIT_MOD_CAST_SPEED, 1.0f);
1691  creature->SetFloatValue(UNIT_MOD_CAST_HASTE, 1.0f);
1692  //creature->CastSpell(creature, SPELL_SPIRIT_HEAL_CHANNEL, true);
1693  return true;
1694  }
1695  TC_LOG_ERROR("bg.battleground", "Battleground::AddSpiritGuide: cannot create spirit guide (type: %u, entry: %u) for BG (map: %u, instance id: %u)!",
1696  type, entry, m_MapId, m_InstanceID);
1697  EndNow();
1698  return false;
1699 }
Definition: Unit.h:544
Definition: Battleground.h:101
virtual Creature * AddCreature(uint32 entry, uint32 type, float x, float y, float z, float o, TeamId teamId=TEAM_NEUTRAL, uint32 respawntime=0, Transport *transport=NULL)
Definition: Battleground.cpp:1580
Definition: UpdateFields.h:129
Definition: Creature.h:467
Definition: Battleground.h:107
uint32 m_MapId
Definition: Battleground.h:623
uint32 m_InstanceID
Definition: Battleground.h:570
G3D::int16 z
Definition: Vector3int16.h:46
Definition: UpdateFields.h:130
uint32_t uint32
Definition: Define.h:150
G3D::int16 y
Definition: Vector2int16.h:38
Definition: SharedDefines.h:992
Definition: Battleground.h:100
Definition: UpdateFields.h:93
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
G3D::int16 x
Definition: Vector2int16.h:37
void EndNow()
Definition: Battleground.cpp:1738

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Battleground::AddSpiritGuide ( uint32  type,
Position const pos,
TeamId  teamId = TEAM_NEUTRAL 
)
1702 {
1703  return AddSpiritGuide(type, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation(), teamId);
1704 }
virtual bool AddSpiritGuide(uint32 type, float x, float y, float z, float o, TeamId teamId=TEAM_NEUTRAL)
Definition: Battleground.cpp:1676

+ Here is the call graph for this function:

void Battleground::AddToBGFreeSlotQueue ( )
1232 {
1234  {
1235  sBattlegroundMgr->AddToBGFreeSlotQueue(m_TypeID, this);
1236  m_InBGFreeSlotQueue = true;
1237  }
1238 }
bool isBattleground() const
Definition: Battleground.h:327
BattlegroundTypeId m_TypeID
Definition: Battleground.h:568
bool m_InBGFreeSlotQueue
Definition: Battleground.h:581
#define sBattlegroundMgr
Definition: BattlegroundMgr.h:181

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Battleground::BlockMovement ( Player player)
915 {
916  player->SetClientControl(player, 0); // movement disabled NOTE: the effect will be automatically removed by client when the player is teleported from the battleground, so no need to send with uint8(1) in RemovePlayerAtLeave()
917 }

+ Here is the caller graph for this function:

template<class Do >
void Battleground::BroadcastWorker ( Do &  _do)
112 {
113  for (BattlegroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
114  if (Player* player = _GetPlayer(itr, "BroadcastWorker"))
115  _do(player);
116 }
BattlegroundPlayerMap m_Players
Definition: Battleground.h:548
Player * _GetPlayer(ObjectGuid guid, bool offlineRemove, const char *context) const
Definition: Battleground.cpp:617

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Battleground::BuildPvPLogDataPacket ( WorldPackets::Battleground::PVPLogData pvpLogData)
1323 {
1324  if (GetStatus() == STATUS_WAIT_LEAVE)
1325  pvpLogData.Winner = GetWinner();
1326 
1327  pvpLogData.Players.reserve(GetPlayerScoresSize());
1328  for (auto const& score : PlayerScores)
1329  {
1331 
1332  playerData.PlayerGUID = score.second->PlayerGuid;
1333  playerData.Kills = score.second->KillingBlows;
1334  playerData.Faction = score.second->TeamId;
1335  if (score.second->HonorableKills || score.second->Deaths || score.second->BonusHonor)
1336  {
1337  playerData.Honor = boost::in_place();
1338  playerData.Honor->HonorKills = score.second->HonorableKills;
1339  playerData.Honor->Deaths = score.second->Deaths;
1340  playerData.Honor->ContributionPoints = score.second->BonusHonor;
1341  }
1342 
1343  playerData.DamageDone = score.second->DamageDone;
1344  playerData.HealingDone = score.second->HealingDone;
1345  score.second->BuildObjectivesBlock(playerData.Stats);
1346 
1347  if (Player* player = ObjectAccessor::GetPlayer(GetBgMap(), playerData.PlayerGUID))
1348  {
1349  playerData.IsInWorld = true;
1350  playerData.PrimaryTalentTree = player->GetUInt32Value(PLAYER_FIELD_CURRENT_SPEC_ID);
1351  playerData.Race = player->getRace();
1352  }
1353 
1354  //if (isRated())
1355  //{
1356  // playerData.PreMatchRating;
1357  // playerData.RatingChange;
1358  // playerData.PreMatchMMR;
1359  // playerData.MmrChange;
1360  //}
1361 
1362  pvpLogData.Players.push_back(playerData);
1363  }
1364 
1365  if (isRated())
1366  {
1367  pvpLogData.Ratings = boost::in_place();
1368 
1369  for (uint8 i = 0; i < BG_TEAMS_COUNT; ++i)
1370  {
1371  pvpLogData.Ratings->Postmatch[i] = _arenaTeamScores[i].NewRating;
1372  pvpLogData.Ratings->Prematch[i] = _arenaTeamScores[i].OldRating;
1373  pvpLogData.Ratings->PrematchMMR[i] = _arenaTeamScores[i].MatchmakerRating;
1374  }
1375  }
1376 
1377  pvpLogData.PlayerCount[0] = int8(GetPlayersCountByTeam(HORDE));
1378  pvpLogData.PlayerCount[1] = int8(GetPlayersCountByTeam(ALLIANCE));
1379 }
std::vector< int32 > Stats
Definition: BattlegroundPackets.h:123
uint32 Kills
Definition: BattlegroundPackets.h:113
Optional< uint8 > Winner
Definition: BattlegroundPackets.h:129
uint8 Faction
Definition: BattlegroundPackets.h:114
BattlegroundStatus GetStatus() const
Definition: Battleground.h:266
Optional< RatingData > Ratings
Definition: BattlegroundPackets.h:131
int8_t int8
Definition: g3dmath.h:163
uint32 MatchmakerRating
Definition: ArenaScore.h:72
uint32 Race
Definition: BattlegroundPackets.h:126
BattlegroundMap * GetBgMap() const
Definition: Battleground.h:356
uint32 DamageDone
Definition: BattlegroundPackets.h:117
Definition: UpdateFields.h:206
uint32 GetPlayerScoresSize() const
Definition: Battleground.h:335
Definition: BattlegroundPackets.h:110
Optional< HonorData > Honor
Definition: BattlegroundPackets.h:116
ArenaTeamScore _arenaTeamScores[BG_TEAMS_COUNT]
Definition: Battleground.h:564
#define BG_TEAMS_COUNT
Definition: SharedDefines.h:4555
int8 PlayerCount[2]
Definition: BattlegroundPackets.h:132
Definition: SharedDefines.h:1000
bool isRated() const
Definition: Battleground.h:328
uint32 HealingDone
Definition: BattlegroundPackets.h:118
TC_GAME_API Player * GetPlayer(Map const *, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:184
Definition: SharedDefines.h:999
ObjectGuid PlayerGUID
Definition: BattlegroundPackets.h:112
int32 NewRating
Definition: ArenaScore.h:71
BattlegroundTeamId GetWinner() const
Definition: Battleground.h:282
Definition: Battleground.h:160
uint8_t uint8
Definition: Define.h:152
int32 OldRating
Definition: ArenaScore.h:70
uint32 GetPlayersCountByTeam(uint32 Team) const
Definition: Battleground.h:400
std::vector< PlayerData > Players
Definition: BattlegroundPackets.h:130
bool IsInWorld
Definition: BattlegroundPackets.h:115
int32 PrimaryTalentTree
Definition: BattlegroundPackets.h:124
BattlegroundScoreMap PlayerScores
Definition: Battleground.h:543

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

virtual bool Battleground::CanActivateGO ( int32  ,
uint32   
) const
inlinevirtual

Reimplemented in BattlegroundAV.

484 { return true; }
bool Battleground::CanAwardArenaPoints ( ) const
inline
uint32 m_LevelMin
Definition: Battleground.h:615
#define BG_AWARD_ARENA_POINTS_MIN_LEVEL
Definition: Battleground.h:211
void Battleground::CastSpellOnTeam ( uint32  SpellID,
uint32  TeamID 
)
696 {
697  for (BattlegroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
698  if (Player* player = _GetPlayerForTeam(TeamID, itr, "CastSpellOnTeam"))
699  player->CastSpell(player, SpellID, true);
700 }
BattlegroundPlayerMap m_Players
Definition: Battleground.h:548
Player * _GetPlayerForTeam(uint32 teamId, BattlegroundPlayerMap::const_iterator itr, const char *context) const
Definition: Battleground.cpp:631

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Battleground::CheckAchievementCriteriaMeet ( uint32  criteriaId,
Player const ,
Unit const = NULL,
uint32  = 0 
)
virtual

Reimplemented in BattlegroundAV, BattlegroundSA, BattlegroundAB, and BattlegroundWS.

1940 {
1941  TC_LOG_ERROR("bg.battleground", "Battleground::CheckAchievementCriteriaMeet: No implementation for criteria %u", criteriaId);
1942  return false;
1943 }
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207

+ Here is the caller graph for this function:

virtual void Battleground::CheckWinConditions ( )
inlinevirtual

Reimplemented in Arena.

410 { }

+ Here is the caller graph for this function:

void Battleground::DecreaseInvitedCount ( uint32  team)
inline
318 { (team == ALLIANCE) ? --m_InvitedAlliance : --m_InvitedHorde; }
uint32 m_InvitedHorde
Definition: Battleground.h:601
Definition: SharedDefines.h:1000
uint32 m_InvitedAlliance
Definition: Battleground.h:600

+ Here is the caller graph for this function:

bool Battleground::DelCreature ( uint32  type)
1641 {
1642  if (!BgCreatures[type])
1643  return true;
1644 
1645  if (Creature* creature = GetBgMap()->GetCreature(BgCreatures[type]))
1646  {
1647  creature->AddObjectToRemoveList();
1648  BgCreatures[type].Clear();
1649  return true;
1650  }
1651 
1652  TC_LOG_ERROR("bg.battleground", "Battleground::DelCreature: creature (type: %u, %s) not found for BG (map: %u, instance id: %u)!",
1653  type, BgCreatures[type].ToString().c_str(), m_MapId, m_InstanceID);
1654  BgCreatures[type].Clear();
1655  return false;
1656 }
BattlegroundMap * GetBgMap() const
Definition: Battleground.h:356
Definition: Creature.h:467
uint32 m_MapId
Definition: Battleground.h:623
uint32 m_InstanceID
Definition: Battleground.h:570
string ToString(int i)
Definition: strutil.h:491
GuidVector BgCreatures
Definition: Battleground.h:453
TC_GAME_API Creature * GetCreature(WorldObject const &u, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:174
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Battleground::DelObject ( uint32  type)
1659 {
1660  if (!BgObjects[type])
1661  return true;
1662 
1663  if (GameObject* obj = GetBgMap()->GetGameObject(BgObjects[type]))
1664  {
1665  obj->SetRespawnTime(0); // not save respawn time
1666  obj->Delete();
1667  BgObjects[type].Clear();
1668  return true;
1669  }
1670  TC_LOG_ERROR("bg.battleground", "Battleground::DelObject: gameobject (type: %u, %s) not found for BG (map: %u, instance id: %u)!",
1671  type, BgObjects[type].ToString().c_str(), m_MapId, m_InstanceID);
1672  BgObjects[type].Clear();
1673  return false;
1674 }
BattlegroundMap * GetBgMap() const
Definition: Battleground.h:356
uint32 m_MapId
Definition: Battleground.h:623
uint32 m_InstanceID
Definition: Battleground.h:570
string ToString(int i)
Definition: strutil.h:491
GuidVector BgObjects
Definition: Battleground.h:452
Definition: GameObject.h:880
TC_GAME_API GameObject * GetGameObject(WorldObject const &u, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:143
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

virtual void Battleground::DestroyGate ( Player ,
GameObject  
)
inlinevirtual

Reimplemented in BattlegroundIC, and BattlegroundSA.

252 { }
virtual void Battleground::DoAction ( uint32  ,
ObjectGuid   
)
inlinevirtual
434 { }
void Battleground::DoorClose ( uint32  type)
1507 {
1508  if (GameObject* obj = GetBgMap()->GetGameObject(BgObjects[type]))
1509  {
1510  // If doors are open, close it
1511  if (obj->getLootState() == GO_ACTIVATED && obj->GetGoState() != GO_STATE_READY)
1512  {
1513  obj->SetLootState(GO_READY);
1514  obj->SetGoState(GO_STATE_READY);
1515  }
1516  }
1517  else
1518  TC_LOG_ERROR("bg.battleground", "Battleground::DoorClose: door gameobject (type: %u, %s) not found for BG (map: %u, instance id: %u)!",
1519  type, BgObjects[type].ToString().c_str(), m_MapId, m_InstanceID);
1520 }
Definition: GameObject.h:870
BattlegroundMap * GetBgMap() const
Definition: Battleground.h:356
uint32 m_MapId
Definition: Battleground.h:623
uint32 m_InstanceID
Definition: Battleground.h:570
string ToString(int i)
Definition: strutil.h:491
GuidVector BgObjects
Definition: Battleground.h:452
Definition: GameObject.h:880
Definition: GameObject.h:823
TC_GAME_API GameObject * GetGameObject(WorldObject const &u, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:143
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
Definition: GameObject.h:869

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Battleground::DoorOpen ( uint32  type)
1523 {
1524  if (GameObject* obj = GetBgMap()->GetGameObject(BgObjects[type]))
1525  {
1526  obj->SetLootState(GO_ACTIVATED);
1527  obj->SetGoState(GO_STATE_ACTIVE);
1528  }
1529  else
1530  TC_LOG_ERROR("bg.battleground", "Battleground::DoorOpen: door gameobject (type: %u, %s) not found for BG (map: %u, instance id: %u)!",
1531  type, BgObjects[type].ToString().c_str(), m_MapId, m_InstanceID);
1532 }
Definition: GameObject.h:870
BattlegroundMap * GetBgMap() const
Definition: Battleground.h:356
uint32 m_MapId
Definition: Battleground.h:623
uint32 m_InstanceID
Definition: Battleground.h:570
string ToString(int i)
Definition: strutil.h:491
GuidVector BgObjects
Definition: Battleground.h:452
Definition: GameObject.h:880
Definition: GameObject.h:822
TC_GAME_API GameObject * GetGameObject(WorldObject const &u, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:143
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Battleground::EndBattleground ( uint32  winner)
virtual

Reimplemented in BattlegroundAV, BattlegroundIC, BattlegroundSA, BattlegroundEY, BattlegroundAB, BattlegroundWS, and Arena.

745 {
747 
748  int32 winmsg_id = 0;
749  bool guildAwarded = false;
750 
751  if (winner == ALLIANCE)
752  {
754 
755  PlaySoundToAll(SOUND_ALLIANCE_WINS); // alliance wins sound
756 
758  }
759  else if (winner == HORDE)
760  {
762 
763  PlaySoundToAll(SOUND_HORDE_WINS); // horde wins sound
764 
766  }
767  else
768  {
770  }
771 
772  PreparedStatement* stmt = nullptr;
773  uint64 battlegroundId = 1;
775  {
778 
779  if (result)
780  {
781  Field* fields = result->Fetch();
782  battlegroundId = fields[0].GetUInt64() + 1;
783  }
784 
786  stmt->setUInt64(0, battlegroundId);
787  stmt->setUInt8(1, GetWinner());
788  stmt->setUInt8(2, GetUniqueBracketId());
789  stmt->setUInt8(3, GetTypeID(true));
791  }
792 
794  //we must set it this way, because end time is sent in packet!
796 
798  BuildPvPLogDataPacket(pvpLogData);
799 
801 
802  for (BattlegroundPlayerMap::iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
803  {
804  uint32 team = itr->second.Team;
805 
806  Player* player = _GetPlayer(itr, "EndBattleground");
807  if (!player)
808  continue;
809 
810  // should remove spirit of redemption
811  if (player->HasAuraType(SPELL_AURA_SPIRIT_OF_REDEMPTION))
812  player->RemoveAurasByType(SPELL_AURA_MOD_SHAPESHIFT);
813 
814  if (!player->IsAlive())
815  {
816  player->ResurrectPlayer(1.0f);
817  player->SpawnCorpseBones();
818  }
819  else
820  {
821  //needed cause else in av some creatures will kill the players at the end
822  player->CombatStop();
823  player->getHostileRefManager().deleteReferences();
824  }
825 
826  // remove temporary currency bonus auras before rewarding player
827  player->RemoveAura(SPELL_HONORABLE_DEFENDER_25Y);
828  player->RemoveAura(SPELL_HONORABLE_DEFENDER_60Y);
829 
830  uint32 winnerKills = player->GetRandomWinner() ? sWorld->getIntConfig(CONFIG_BG_REWARD_WINNER_HONOR_LAST) : sWorld->getIntConfig(CONFIG_BG_REWARD_WINNER_HONOR_FIRST);
831  uint32 loserKills = player->GetRandomWinner() ? sWorld->getIntConfig(CONFIG_BG_REWARD_LOSER_HONOR_LAST) : sWorld->getIntConfig(CONFIG_BG_REWARD_LOSER_HONOR_FIRST);
832 
834  {
836  BattlegroundScoreMap::const_iterator score = PlayerScores.find(player->GetGUID());
837 
838  stmt->setUInt32(0, battlegroundId);
839  stmt->setUInt64(1, player->GetGUID().GetCounter());
840  stmt->setBool (2, team == winner);
841  stmt->setUInt32(3, score->second->GetKillingBlows());
842  stmt->setUInt32(4, score->second->GetDeaths());
843  stmt->setUInt32(5, score->second->GetHonorableKills());
844  stmt->setUInt32(6, score->second->GetBonusHonor());
845  stmt->setUInt32(7, score->second->GetDamageDone());
846  stmt->setUInt32(8, score->second->GetHealingDone());
847  stmt->setUInt32(9, score->second->GetAttr1());
848  stmt->setUInt32(10, score->second->GetAttr2());
849  stmt->setUInt32(11, score->second->GetAttr3());
850  stmt->setUInt32(12, score->second->GetAttr4());
851  stmt->setUInt32(13, score->second->GetAttr5());
852 
854  }
855 
856  // Reward winner team
857  if (team == winner)
858  {
860  {
862  if (!player->GetRandomWinner())
863  {
864  // 100cp awarded for the first random battleground won each day
866  player->SetRandomWinner(true);
867  }
868  }
869  else // 50cp awarded for each non-rated battleground won
871 
872  player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_WIN_BG, 1);
873  if (!guildAwarded)
874  {
875  guildAwarded = true;
876  if (ObjectGuid::LowType guildId = GetBgMap()->GetOwnerGuildId(player->GetBGTeam()))
877  {
878  if (Guild* guild = sGuildMgr->GetGuildById(guildId))
879  guild->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_WIN_BG, 1, 0, 0, NULL, player);
880  }
881  }
882  }
883  else
884  {
887  }
888 
889  player->ResetAllPowers();
890  player->CombatStopWithPets(true);
891 
892  BlockMovement(player);
893 
894  player->SendDirectMessage(pvpLogData.Write());
895 
897  sBattlegroundMgr->BuildBattlegroundStatusActive(&battlefieldStatus, this, player, player->GetBattlegroundQueueIndex(bgQueueTypeId), player->GetBattlegroundQueueJoinTime(bgQueueTypeId), GetArenaType());
898  player->SendDirectMessage(battlefieldStatus.Write());
899 
900  player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_BATTLEGROUND, 1);
901  }
902 
903  if (winmsg_id)
905 }
void Execute(const char *sql)
Definition: DatabaseWorkerPool.h:87
virtual bool UpdatePlayerScore(Player *player, uint32 type, uint32 value, bool doAddHonor=true)
Definition: Battleground.cpp:1381
WorldPacket const * Write() override
Definition: BattlegroundPackets.cpp:165
std::shared_ptr< PreparedResultSet > PreparedQueryResult
Definition: QueryResult.h:107
uint64 GetUInt64() const
Definition: Field.h:184
uint8 GetUniqueBracketId() const
Definition: Battleground.cpp:1945
uint32 GetBonusHonorFromKill(uint32 kills) const
Definition: Battleground.cpp:907
Definition: World.h:363
Definition: Battleground.h:58
void SetRemainingTime(uint32 Time)
Definition: Battleground.h:298
#define sGuildMgr
Definition: GuildMgr.h:61
Class used to access individual fields of database query result.
Definition: Field.h:56
void setUInt8(const uint8 index, const uint8 value)
Definition: PreparedStatement.cpp:97
static BattlegroundQueueTypeId BGQueueTypeId(BattlegroundTypeId bgTypeId, uint8 arenaType)
Definition: BattlegroundMgr.cpp:623
Definition: DBCEnums.h:199
BattlegroundPlayerMap m_Players
Definition: Battleground.h:548
arena_t NULL
Definition: jemalloc_internal.h:624
BattlegroundMap * GetBgMap() const
Definition: Battleground.h:356
Definition: DBCEnums.h:762
#define sWorld
Definition: World.h:887
Definition: World.h:364
uint64 LowType
Definition: ObjectGuid.h:199
Definition: PreparedStatement.h:74
Definition: CharacterDatabase.h:572
Definition: Language.h:727
Definition: BattlegroundPackets.h:89
Definition: SharedDefines.h:1000
Definition: Language.h:633
void setBool(const uint8 index, const bool value)
Definition: PreparedStatement.cpp:88
bool IsRandom() const
Definition: Battleground.h:285
Definition: Battleground.h:126
void SendMessageToAll(uint32 entry, ChatMsg type, Player const *source=NULL)
Definition: Battleground.cpp:1706
uint8 GetArenaType() const
Definition: Battleground.h:281
void PlaySoundToAll(uint32 SoundID)
Definition: Battleground.cpp:681
Definition: SharedDefines.h:4267
Definition: SpellAuraDefines.h:236
WorldPacket const * Write() override
Definition: BattlegroundPackets.cpp:102
Definition: Language.h:634
int32_t int32
Definition: Define.h:146
uint32_t uint32
Definition: Define.h:150
uint64_t uint64
Definition: Define.h:149
void BuildPvPLogDataPacket(WorldPackets::Battleground::PVPLogData &pvpLogData)
Definition: Battleground.cpp:1322
bool isBattleground() const
Definition: Battleground.h:327
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
void RemoveFromBGFreeSlotQueue()
Definition: Battleground.cpp:1241
Definition: World.h:365
Definition: Language.h:728
Definition: SharedDefines.h:4552
void BlockMovement(Player *player)
Definition: Battleground.cpp:914
Definition: Battleground.h:115
void setUInt32(const uint8 index, const uint32 value)
Definition: PreparedStatement.cpp:115
Definition: SharedDefines.h:999
static bool IsBGWeekend(BattlegroundTypeId bgTypeId)
Definition: BattlegroundMgr.cpp:856
void SetWinner(BattlegroundTeamId winnerTeamId)
Definition: Battleground.h:306
Definition: BattlegroundScore.h:30
Definition: SharedDefines.h:4551
Definition: Battleground.h:116
BattlegroundQueueTypeId
Definition: SharedDefines.h:4732
QueryResult Query(const char *sql, T *connection=nullptr)
Definition: DatabaseWorkerPool.cpp:113
Player * _GetPlayer(ObjectGuid guid, bool offlineRemove, const char *context) const
Definition: Battleground.cpp:617
BattlegroundTeamId GetWinner() const
Definition: Battleground.h:282
Definition: Battleground.h:160
Definition: BattlegroundPackets.h:170
void setUInt64(const uint8 index, const uint64 value)
Definition: PreparedStatement.cpp:124
Definition: SpellAuraDefines.h:96
#define sBattlegroundMgr
Definition: BattlegroundMgr.h:181
BattlegroundTypeId GetTypeID(bool GetRandom=false) const
Definition: Battleground.h:263
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
Definition: CharacterDatabase.h:573
Definition: SharedDefines.h:4550
Definition: Battleground.h:57
Definition: Guild.h:320
void SetStatus(BattlegroundStatus Status)
Definition: Battleground.h:295
Definition: CharacterDatabase.h:571
BattlegroundScoreMap PlayerScores
Definition: Battleground.h:543

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Battleground::EndNow ( )
protected
1739 {
1742  SetRemainingTime(0);
1743 }
void SetRemainingTime(uint32 Time)
Definition: Battleground.h:298
void RemoveFromBGFreeSlotQueue()
Definition: Battleground.cpp:1241
Definition: Battleground.h:160
void SetStatus(BattlegroundStatus Status)
Definition: Battleground.h:295

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

virtual void Battleground::EventPlayerClickedOnFlag ( Player ,
GameObject  
)
inlinevirtual

Reimplemented in BattlegroundAV, BattlegroundIC, BattlegroundSA, BattlegroundEY, BattlegroundAB, and BattlegroundWS.

428 { }

+ Here is the caller graph for this function:

virtual void Battleground::EventPlayerDroppedFlag ( Player )
inlinevirtual

Reimplemented in BattlegroundEY, and BattlegroundWS.

427 { }
void Battleground::EventPlayerLoggedIn ( Player player)
1191 {
1192  ObjectGuid guid = player->GetGUID();
1193  // player is correct pointer
1194  for (GuidDeque::iterator itr = m_OfflineQueue.begin(); itr != m_OfflineQueue.end(); ++itr)
1195  {
1196  if (*itr == guid)
1197  {
1198  m_OfflineQueue.erase(itr);
1199  break;
1200  }
1201  }
1202  m_Players[guid].OfflineRemoveTime = 0;
1204  // if battleground is starting, then add preparation aura
1205  // we don't have to do that, because preparation aura isn't removed when player logs out
1206 }
void PlayerAddedToBGCheckIfBGIsRunning(Player *player)
Definition: Battleground.cpp:1842
BattlegroundPlayerMap m_Players
Definition: Battleground.h:548
GuidDeque m_OfflineQueue
Definition: Battleground.h:595
Definition: ObjectGuid.h:189

+ Here is the call graph for this function:

void Battleground::EventPlayerLoggedOut ( Player player)
1210 {
1211  ObjectGuid guid = player->GetGUID();
1212  if (!IsPlayerInBattleground(guid)) // Check if this player really is in battleground (might be a GM who teleported inside)
1213  return;
1214 
1215  // player is correct pointer, it is checked in WorldSession::LogoutPlayer()
1216  m_OfflineQueue.push_back(player->GetGUID());
1217  m_Players[guid].OfflineRemoveTime = sWorld->GetGameTime() + MAX_OFFLINE_TIME;
1218  if (GetStatus() == STATUS_IN_PROGRESS)
1219  {
1220  // drop flag and handle other cleanups
1221  RemovePlayer(player, guid, GetPlayerTeam(guid));
1222 
1223  // 1 player is logging out, if it is the last, then end arena!
1224  if (isArena())
1225  if (GetAlivePlayersCountByTeam(player->GetBGTeam()) <= 1 && GetPlayersCountByTeam(GetOtherTeam(player->GetBGTeam())))
1226  EndBattleground(GetOtherTeam(player->GetBGTeam()));
1227  }
1228 }
Definition: Battleground.h:159
Definition: Battleground.h:127
virtual void RemovePlayer(Player *, ObjectGuid, uint32)
Definition: Battleground.h:545
uint32 GetOtherTeam(uint32 teamId) const
Definition: Battleground.cpp:1829
BattlegroundStatus GetStatus() const
Definition: Battleground.h:266
uint32 GetPlayerTeam(ObjectGuid guid) const
Definition: Battleground.cpp:1821
BattlegroundPlayerMap m_Players
Definition: Battleground.h:548
#define sWorld
Definition: World.h:887
uint32 GetAlivePlayersCountByTeam(uint32 Team) const
Definition: Battleground.cpp:1860
bool isArena() const
Definition: Battleground.h:326
bool IsPlayerInBattleground(ObjectGuid guid) const
Definition: Battleground.cpp:1834
GuidDeque m_OfflineQueue
Definition: Battleground.h:595
Definition: ObjectGuid.h:189
virtual void EndBattleground(uint32 winner)
Definition: Battleground.cpp:744
uint32 GetPlayersCountByTeam(uint32 Team) const
Definition: Battleground.h:400

+ Here is the call graph for this function:

BattlegroundMap* Battleground::FindBgMap ( ) const
inline
357 { return m_Map; }
BattlegroundMap * m_Map
Definition: Battleground.h:624

+ Here is the caller graph for this function:

uint32 Battleground::GetAlivePlayersCountByTeam ( uint32  Team) const
1861 {
1862  int count = 0;
1863  for (BattlegroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
1864  {
1865  if (itr->second.Team == Team)
1866  {
1867  Player* player = ObjectAccessor::FindPlayer(itr->first);
1868  if (player && player->IsAlive() && !player->HasByteFlag(UNIT_FIELD_BYTES_2, 3, FORM_SPIRITOFREDEMPTION))
1869  ++count;
1870  }
1871  }
1872  return count;
1873 }
Definition: Unit.h:292
Definition: UpdateFields.h:146
BattlegroundPlayerMap m_Players
Definition: Battleground.h:548
TC_GAME_API Player * FindPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:209
Team
Definition: SharedDefines.h:997

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uint32 Battleground::GetArenaMatchmakerRating ( uint32  Team) const
inline
static TeamId GetTeamIndexByTeamId(uint32 Team)
Definition: Battleground.h:399
Team
Definition: SharedDefines.h:997
uint32 m_ArenaTeamMMR[BG_TEAMS_COUNT]
Definition: Battleground.h:612

+ Here is the caller graph for this function:

uint32 Battleground::GetArenaTeamIdByIndex ( uint32  index) const
inline
415 { return m_ArenaTeamIds[index]; }
uint32 m_ArenaTeamIds[BG_TEAMS_COUNT]
Definition: Battleground.h:610

+ Here is the caller graph for this function:

uint32 Battleground::GetArenaTeamIdForTeam ( uint32  Team) const
inline
static TeamId GetTeamIndexByTeamId(uint32 Team)
Definition: Battleground.h:399
Team
Definition: SharedDefines.h:997
uint32 m_ArenaTeamIds[BG_TEAMS_COUNT]
Definition: Battleground.h:610

+ Here is the caller graph for this function:

uint8 Battleground::GetArenaType ( ) const
inline
281 { return m_ArenaType; }
uint8 m_ArenaType
Definition: Battleground.h:580

+ Here is the caller graph for this function:

Creature * Battleground::GetBGCreature ( uint32  type,
bool  logError = true 
)
1550 {
1551  Creature* creature = GetBgMap()->GetCreature(BgCreatures[type]);
1552  if (!creature)
1553  {
1554  if (logError)
1555  TC_LOG_ERROR("bg.battleground", "Battleground::GetBGCreature: creature (type: %u, %s) not found for BG (map: %u, instance id: %u)!",
1556  type, BgCreatures[type].ToString().c_str(), m_MapId, m_InstanceID);
1557  else
1558  TC_LOG_INFO("bg.battleground", "Battleground::GetBGCreature: creature (type: %u, %s) not found for BG (map: %u, instance id: %u)!",
1559  type, BgCreatures[type].ToString().c_str(), m_MapId, m_InstanceID);
1560  }
1561  return creature;
1562 }
BattlegroundMap * GetBgMap() const
Definition: Battleground.h:356
Definition: Creature.h:467
uint32 m_MapId
Definition: Battleground.h:623
uint32 m_InstanceID
Definition: Battleground.h:570
string ToString(int i)
Definition: strutil.h:491
GuidVector BgCreatures
Definition: Battleground.h:453
Creature * GetCreature(ObjectGuid const &guid)
Definition: Map.cpp:3535
#define TC_LOG_INFO(filterType__,...)
Definition: Log.h:201
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

BattlegroundMap* Battleground::GetBgMap ( ) const
inline
356 { ASSERT(m_Map); return m_Map; }
BattlegroundMap * m_Map
Definition: Battleground.h:624
#define ASSERT
Definition: Errors.h:55

+ Here is the caller graph for this function:

GameObject * Battleground::GetBGObject ( uint32  type,
bool  logError = true 
)
1535 {
1536  GameObject* obj = GetBgMap()->GetGameObject(BgObjects[type]);
1537  if (!obj)
1538  {
1539  if (logError)
1540  TC_LOG_ERROR("bg.battleground", "Battleground::GetBGObject: gameobject (type: %u, %s) not found for BG (map: %u, instance id: %u)!",
1541  type, BgObjects[type].ToString().c_str(), m_MapId, m_InstanceID);
1542  else
1543  TC_LOG_INFO("bg.battleground", "Battleground::GetBGObject: gameobject (type: %u, %s) not found for BG (map: %u, instance id: %u)!",
1544  type, BgObjects[type].ToString().c_str(), m_MapId, m_InstanceID);
1545  }
1546  return obj;
1547 }
BattlegroundMap * GetBgMap() const
Definition: Battleground.h:356
uint32 m_MapId
Definition: Battleground.h:623
uint32 m_InstanceID
Definition: Battleground.h:570
string ToString(int i)
Definition: strutil.h:491
GuidVector BgObjects
Definition: Battleground.h:452
Definition: GameObject.h:880
#define TC_LOG_INFO(filterType__,...)
Definition: Log.h:201
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
GameObject * GetGameObject(ObjectGuid const &guid)
Definition: Map.cpp:3545

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Group* Battleground::GetBgRaid ( uint32  TeamID) const
inline
393 { return TeamID == ALLIANCE ? m_BgRaids[TEAM_ALLIANCE] : m_BgRaids[TEAM_HORDE]; }
Definition: SharedDefines.h:1000
Group * m_BgRaids[BG_TEAMS_COUNT]
Definition: Battleground.h:604
Definition: SharedDefines.h:992
Definition: SharedDefines.h:993

+ Here is the caller graph for this function:

uint32 Battleground::GetBonusHonorFromKill ( uint32  kills) const
908 {
909  //variable kills means how many honorable kills you scored (so we need kills * honor_for_one_kill)
910  uint32 maxLevel = std::min<uint32>(GetMaxLevel(), 80U);
911  return Trinity::Honor::hk_honor_at_level(maxLevel, float(kills));
912 }
uint32_t uint32
Definition: Define.h:150
uint32 GetMaxLevel() const
Definition: Battleground.h:275
uint32 hk_honor_at_level(uint8 level, float multiplier=1.0f)
Definition: Formulas.h:38

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

BattlegroundBracketId Battleground::GetBracketId ( ) const
inline
264 { return m_BracketId; }
BattlegroundBracketId m_BracketId
Definition: Battleground.h:579

+ Here is the caller graph for this function:

uint32 Battleground::GetClientInstanceID ( ) const
inline
267 { return m_ClientInstanceID; }
uint32 m_ClientInstanceID
Definition: Battleground.h:572

+ Here is the caller graph for this function:

WorldSafeLocsEntry const * Battleground::GetClosestGraveYard ( Player player)
virtual

Reimplemented in BattlegroundAV, BattlegroundIC, BattlegroundSA, BattlegroundEY, BattlegroundAB, and BattlegroundWS.

1901 {
1902  return sObjectMgr->GetClosestGraveYard(player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetMapId(), player->GetTeam());
1903 }
#define sObjectMgr
Definition: ObjectMgr.h:1567

+ Here is the caller graph for this function:

uint32 Battleground::GetElapsedTime ( ) const
inline
268 { return m_StartTime; }
uint32 m_StartTime
Definition: Battleground.h:573

+ Here is the caller graph for this function:

virtual ObjectGuid Battleground::GetFlagPickerGUID ( int32  = -1) const
inlinevirtual

Reimplemented in BattlegroundEY, and BattlegroundWS.

481 { return ObjectGuid::Empty; }
static ObjectGuid const Empty
Definition: ObjectGuid.h:196
uint32 Battleground::GetFreeSlotsForTeam ( uint32  Team) const
1253 {
1254  // if BG is starting and CONFIG_BATTLEGROUND_INVITATION_TYPE == BG_QUEUE_INVITATION_TYPE_NO_BALANCE, invite anyone
1257 
1258  // if BG is already started or CONFIG_BATTLEGROUND_INVITATION_TYPE != BG_QUEUE_INVITATION_TYPE_NO_BALANCE, do not allow to join too much players of one faction
1259  uint32 otherTeamInvitedCount;
1260  uint32 thisTeamInvitedCount;
1261  uint32 otherTeamPlayersCount;
1262  uint32 thisTeamPlayersCount;
1263 
1264  if (Team == ALLIANCE)
1265  {
1266  thisTeamInvitedCount = GetInvitedCount(ALLIANCE);
1267  otherTeamInvitedCount = GetInvitedCount(HORDE);
1268  thisTeamPlayersCount = GetPlayersCountByTeam(ALLIANCE);
1269  otherTeamPlayersCount = GetPlayersCountByTeam(HORDE);
1270  }
1271  else
1272  {
1273  thisTeamInvitedCount = GetInvitedCount(HORDE);
1274  otherTeamInvitedCount = GetInvitedCount(ALLIANCE);
1275  thisTeamPlayersCount = GetPlayersCountByTeam(HORDE);
1276  otherTeamPlayersCount = GetPlayersCountByTeam(ALLIANCE);
1277  }
1279  {
1280  // difference based on ppl invited (not necessarily entered battle)
1281  // default: allow 0
1282  uint32 diff = 0;
1283 
1284  // allow join one person if the sides are equal (to fill up bg to minPlayerPerTeam)
1285  if (otherTeamInvitedCount == thisTeamInvitedCount)
1286  diff = 1;
1287  // allow join more ppl if the other side has more players
1288  else if (otherTeamInvitedCount > thisTeamInvitedCount)
1289  diff = otherTeamInvitedCount - thisTeamInvitedCount;
1290 
1291  // difference based on max players per team (don't allow inviting more)
1292  uint32 diff2 = (thisTeamInvitedCount < GetMaxPlayersPerTeam()) ? GetMaxPlayersPerTeam() - thisTeamInvitedCount : 0;
1293 
1294  // difference based on players who already entered
1295  // default: allow 0
1296  uint32 diff3 = 0;
1297  // allow join one person if the sides are equal (to fill up bg minPlayerPerTeam)
1298  if (otherTeamPlayersCount == thisTeamPlayersCount)
1299  diff3 = 1;
1300  // allow join more ppl if the other side has more players
1301  else if (otherTeamPlayersCount > thisTeamPlayersCount)
1302  diff3 = otherTeamPlayersCount - thisTeamPlayersCount;
1303  // or other side has less than minPlayersPerTeam
1304  else if (thisTeamInvitedCount <= GetMinPlayersPerTeam())
1305  diff3 = GetMinPlayersPerTeam() - thisTeamInvitedCount + 1;
1306 
1307  // return the minimum of the 3 differences
1308 
1309  // min of diff and diff 2
1310  diff = std::min(diff, diff2);
1311  // min of diff, diff2 and diff3
1312  return std::min(diff, diff3);
1313  }
1314  return 0;
1315 }
Definition: Battleground.h:159
uint32 GetMinPlayersPerTeam() const
Definition: Battleground.h:278
BattlegroundStatus GetStatus() const
Definition: Battleground.h:266
#define sWorld
Definition: World.h:887
Definition: SharedDefines.h:1000
uint32 GetInvitedCount(uint32 team) const
Definition: Battleground.h:322
Definition: Battleground.h:158
Team
Definition: SharedDefines.h:997
T min(const T &x, const T &y)
Definition: g3dmath.h:305
uint32_t uint32
Definition: Define.h:150
Definition: SharedDefines.h:999
uint32 GetMaxPlayersPerTeam() const
Definition: Battleground.h:277
Definition: BattlegroundQueue.h:69
uint32 GetPlayersCountByTeam(uint32 Team) const
Definition: Battleground.h:400

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uint32 Battleground::GetInstanceID ( ) const
inline
265 { return m_InstanceID; }
uint32 m_InstanceID
Definition: Battleground.h:570

+ Here is the caller graph for this function:

uint32 Battleground::GetInvitedCount ( uint32  team) const
inline
322 { return (team == ALLIANCE) ? m_InvitedAlliance : m_InvitedHorde; }
uint32 m_InvitedHorde
Definition: Battleground.h:601
Definition: SharedDefines.h:1000
uint32 m_InvitedAlliance
Definition: Battleground.h:600

+ Here is the caller graph for this function:

uint32 Battleground::GetLastResurrectTime ( ) const
inline
270 { return m_LastResurrectTime; }
uint32 m_LastResurrectTime
Definition: Battleground.h:578

+ Here is the caller graph for this function:

uint32 Battleground::GetMapId ( ) const
inline
352 { return m_MapId; }
uint32 m_MapId
Definition: Battleground.h:623

+ Here is the caller graph for this function:

uint32 Battleground::GetMaxLevel ( ) const
inline
275 { return m_LevelMax; }
uint32 m_LevelMax
Definition: Battleground.h:616

+ Here is the caller graph for this function:

uint32 Battleground::GetMaxPlayers ( ) const
inline
271 { return m_MaxPlayers; }
uint32 m_MaxPlayers
Definition: Battleground.h:618

+ Here is the caller graph for this function:

uint32 Battleground::GetMaxPlayersPerTeam ( ) const
inline
277 { return m_MaxPlayersPerTeam; }
uint32 m_MaxPlayersPerTeam
Definition: Battleground.h:617

+ Here is the caller graph for this function:

uint32 Battleground::GetMinLevel ( ) const
inline
274 { return m_LevelMin; }
uint32 m_LevelMin
Definition: Battleground.h:615

+ Here is the caller graph for this function:

uint32 Battleground::GetMinPlayers ( ) const
inline
272 { return m_MinPlayers; }
uint32 m_MinPlayers
Definition: Battleground.h:620
uint32 Battleground::GetMinPlayersPerTeam ( ) const
inline
278 { return m_MinPlayersPerTeam; }
uint32 m_MinPlayersPerTeam
Definition: Battleground.h:619

+ Here is the caller graph for this function:

std::string const& Battleground::GetName ( ) const
inline
261 { return m_Name; }
std::string m_Name
Definition: Battleground.h:589

+ Here is the caller graph for this function:

int32 Battleground::GetObjectType ( ObjectGuid  guid)
1881 {
1882  for (uint32 i = 0; i < BgObjects.size(); ++i)
1883  if (BgObjects[i] == guid)
1884  return i;
1885  TC_LOG_ERROR("bg.battleground", "Battleground::GetObjectType: player used gameobject (%s) which is not in internal data for BG (map: %u, instance id: %u), cheating?",
1886  guid.ToString().c_str(), m_MapId, m_InstanceID);
1887  return -1;
1888 }
uint32 m_MapId
Definition: Battleground.h:623
uint32 m_InstanceID
Definition: Battleground.h:570
GuidVector BgObjects
Definition: Battleground.h:452
uint32_t uint32
Definition: Define.h:150
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uint32 Battleground::GetOtherTeam ( uint32  teamId) const
1830 {
1831  return teamId ? ((teamId == ALLIANCE) ? HORDE : ALLIANCE) : 0;
1832 }
Definition: SharedDefines.h:1000
Definition: SharedDefines.h:999

+ Here is the caller graph for this function:

virtual void Battleground::GetPlayerPositionData ( std::vector< WorldPackets::Battleground::BattlegroundPlayerPosition > *  ) const
inlineprotectedvirtual

Reimplemented in BattlegroundEY, and BattlegroundWS.

540 { }

+ Here is the caller graph for this function:

BattlegroundPlayerMap const& Battleground::GetPlayers ( ) const
inline
331 { return m_Players; }
BattlegroundPlayerMap m_Players
Definition: Battleground.h:548

+ Here is the caller graph for this function:

uint32 Battleground::GetPlayerScoresSize ( ) const
inline
335 { return uint32(PlayerScores.size()); }
uint32_t uint32
Definition: g3dmath.h:168
BattlegroundScoreMap PlayerScores
Definition: Battleground.h:543

+ Here is the caller graph for this function:

uint32 Battleground::GetPlayersCountByTeam ( uint32  Team) const
inline
static TeamId GetTeamIndexByTeamId(uint32 Team)
Definition: Battleground.h:399
Team
Definition: SharedDefines.h:997
uint32 m_PlayersCount[BG_TEAMS_COUNT]
Definition: Battleground.h:607

+ Here is the caller graph for this function:

uint32 Battleground::GetPlayersSize ( ) const
inline
332 { return uint32(m_Players.size()); }
BattlegroundPlayerMap m_Players
Definition: Battleground.h:548
uint32_t uint32
Definition: g3dmath.h:168

+ Here is the caller graph for this function:

uint32 Battleground::GetPlayerTeam ( ObjectGuid  guid) const
1822 {
1823  BattlegroundPlayerMap::const_iterator itr = m_Players.find(guid);
1824  if (itr != m_Players.end())
1825  return itr->second.Team;
1826  return 0;
1827 }
BattlegroundPlayerMap m_Players
Definition: Battleground.h:548

+ Here is the caller graph for this function:

uint32 Battleground::GetPrematureWinner ( )
virtual

Reimplemented in BattlegroundAV, BattlegroundEY, BattlegroundAB, and BattlegroundWS.

406 {
407  uint32 winner = 0;
409  winner = ALLIANCE;
411  winner = HORDE;
412 
413  return winner;
414 }
uint32 GetMinPlayersPerTeam() const
Definition: Battleground.h:278
Definition: SharedDefines.h:1000
uint32_t uint32
Definition: Define.h:150
Definition: SharedDefines.h:999
uint32 GetPlayersCountByTeam(uint32 Team) const
Definition: Battleground.h:400

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uint64 Battleground::GetQueueId ( ) const
inline
262 { return m_queueId; }
uint64 m_queueId
Definition: Battleground.h:590

+ Here is the caller graph for this function:

uint32 Battleground::GetRemainingTime ( ) const
inline
269 { return m_EndTime; }
int32 m_EndTime
Definition: Battleground.h:577

+ Here is the caller graph for this function:

uint32 Battleground::GetReviveQueueSize ( ) const
inline
337 { return uint32(m_ReviveQueue.size()); }
std::map< ObjectGuid, GuidVector > m_ReviveQueue
Definition: Battleground.h:550
uint32_t uint32
Definition: g3dmath.h:168

+ Here is the caller graph for this function:

uint32 Battleground::GetScriptId ( ) const
inline
283 { return ScriptId; }
uint32 ScriptId
Definition: Battleground.h:627
int32 Battleground::GetStartDelayTime ( ) const
inline
280 { return m_StartDelayTime; }
int32 m_StartDelayTime
Definition: Battleground.h:585

+ Here is the caller graph for this function:

float Battleground::GetStartMaxDist ( ) const
inline
363 { return m_StartMaxDist; }
float m_StartMaxDist
Definition: Battleground.h:626

+ Here is the caller graph for this function:

BattlegroundStatus Battleground::GetStatus ( ) const
inline
266 { return m_Status; }
BattlegroundStatus m_Status
Definition: Battleground.h:571
static TeamId Battleground::GetTeamIndexByTeamId ( uint32  Team)
inlinestatic
399 { return Team == ALLIANCE ? TEAM_ALLIANCE : TEAM_HORDE; }
Definition: SharedDefines.h:1000
Team
Definition: SharedDefines.h:997
Definition: SharedDefines.h:992
Definition: SharedDefines.h:993

+ Here is the caller graph for this function:

uint32 Battleground::GetTeamScore ( uint32  TeamID) const
1925 {
1926  if (teamId == TEAM_ALLIANCE || teamId == TEAM_HORDE)
1927  return m_TeamScores[teamId];
1928 
1929  TC_LOG_ERROR("bg.battleground", "GetTeamScore with wrong Team %u for BG %u", teamId, GetTypeID());
1930  return 0;
1931 }
int32 m_TeamScores[BG_TEAMS_COUNT]
Definition: Battleground.h:562
Definition: SharedDefines.h:992
BattlegroundTypeId GetTypeID(bool GetRandom=false) const
Definition: Battleground.h:263
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
Definition: SharedDefines.h:993

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Position const * Battleground::GetTeamStartPosition ( TeamId  teamId) const
652 {
653  ASSERT(teamId < TEAM_NEUTRAL);
654  return &StartPosition[teamId];
655 }
Definition: SharedDefines.h:994
Position StartPosition[BG_TEAMS_COUNT]
Definition: Battleground.h:625
#define ASSERT
Definition: Errors.h:55

+ Here is the caller graph for this function:

BattlegroundTypeId Battleground::GetTypeID ( bool  GetRandom = false) const
inline
263 { return GetRandom ? m_RandomTypeID : m_TypeID; }
BattlegroundTypeId m_RandomTypeID
Definition: Battleground.h:569
BattlegroundTypeId m_TypeID
Definition: Battleground.h:568

+ Here is the caller graph for this function:

uint8 Battleground::GetUniqueBracketId ( ) const
1946 {
1947  return uint8(GetMinLevel() / 5) - 1; // 10 - 1, 15 - 2, 20 - 3, etc.
1948 }
uint8_t uint8
Definition: g3dmath.h:164
uint32 GetMinLevel() const
Definition: Battleground.h:274

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

BattlegroundTeamId Battleground::GetWinner ( ) const
inline
282 { return _winnerTeamId; }
BattlegroundTeamId _winnerTeamId
Definition: Battleground.h:584

+ Here is the caller graph for this function:

void Battleground::HandleAreaTrigger ( Player player,
uint32  trigger,
bool   
)
virtual

Reimplemented in BattlegroundAV, BattlegroundIC, BattlegroundSA, BattlegroundEY, BattlegroundAB, BattlegroundWS, BattlegroundRV, BattlegroundDS, BattlegroundBE, BattlegroundNA, and BattlegroundRL.

1934 {
1935  TC_LOG_DEBUG("bg.battleground", "Unhandled AreaTrigger %u in Battleground %u. Player coords (x: %f, y: %f, z: %f)",
1936  trigger, player->GetMapId(), player->GetPositionX(), player->GetPositionY(), player->GetPositionZ());
1937 }
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198

+ Here is the caller graph for this function:

void Battleground::HandleKillPlayer ( Player player,
Player killer 
)
virtual

Reimplemented in BattlegroundAV, BattlegroundIC, BattlegroundEY, BattlegroundWS, and Arena.

1785 {
1786  // Keep in mind that for arena this will have to be changed a bit
1787 
1788  // Add +1 deaths
1789  UpdatePlayerScore(victim, SCORE_DEATHS, 1);
1790  // Add +1 kills to group and +1 killing_blows to killer
1791  if (killer)
1792  {
1793  // Don't reward credit for killing ourselves, like fall damage of hellfire (warlock)
1794  if (killer == victim)
1795  return;
1796 
1799 
1800  for (BattlegroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
1801  {
1802  Player* creditedPlayer = ObjectAccessor::FindPlayer(itr->first);
1803  if (!creditedPlayer || creditedPlayer == killer)
1804  continue;
1805 
1806  if (creditedPlayer->GetTeam() == killer->GetTeam() && creditedPlayer->IsAtGroupRewardDistance(victim))
1807  UpdatePlayerScore(creditedPlayer, SCORE_HONORABLE_KILLS, 1);
1808  }
1809  }
1810 
1811  if (!isArena())
1812  {
1813  // To be able to remove insignia -- ONLY IN Battlegrounds
1814  victim->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SKINNABLE);
1815  RewardXPAtKill(killer, victim);
1816  }
1817 }
virtual bool UpdatePlayerScore(Player *player, uint32 type, uint32 value, bool doAddHonor=true)
Definition: Battleground.cpp:1381
Definition: Unit.h:699
BattlegroundPlayerMap m_Players
Definition: Battleground.h:548
void RewardXPAtKill(Player *killer, Player *victim)
Definition: Battleground.cpp:1918
Definition: BattlegroundScore.h:29
bool isArena() const
Definition: Battleground.h:326
TC_GAME_API Player * FindPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:209
Definition: BattlegroundScore.h:27
Definition: UpdateFields.h:109
Definition: BattlegroundScore.h:28

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

virtual void Battleground::HandleKillUnit ( Creature ,
Player  
)
inlinevirtual

Reimplemented in BattlegroundAV, BattlegroundIC, and BattlegroundSA.

424 { }
virtual void Battleground::HandlePlayerResurrect ( Player )
inlinevirtual

Reimplemented in BattlegroundIC.

436 { }
virtual bool Battleground::HandlePlayerUnderMap ( Player )
inlinevirtual
468 { return false; }
virtual void Battleground::HandleQuestComplete ( uint32  ,
Player  
)
inlinevirtual

Reimplemented in BattlegroundAV.

483 { }
void Battleground::HandleTriggerBuff ( ObjectGuid  go_guid)
1749 {
1750  GameObject* obj = GetBgMap()->GetGameObject(go_guid);
1751  if (!obj || obj->GetGoType() != GAMEOBJECT_TYPE_TRAP || !obj->isSpawned())
1752  return;
1753 
1754  // Change buff type, when buff is used:
1755  int32 index = BgObjects.size() - 1;
1756  while (index >= 0 && BgObjects[index] != go_guid)
1757  index--;
1758  if (index < 0)
1759  {
1760  TC_LOG_ERROR("bg.battleground", "Battleground::HandleTriggerBuff: cannot find buff gameobject (%s, entry: %u, type: %u) in internal data for BG (map: %u, instance id: %u)!",
1761  go_guid.ToString().c_str(), obj->GetEntry(), obj->GetGoType(), m_MapId, m_InstanceID);
1762  return;
1763  }
1764 
1765  // Randomly select new buff
1766  uint8 buff = urand(0, 2);
1767  uint32 entry = obj->GetEntry();
1768  if (m_BuffChange && entry != Buff_Entries[buff])
1769  {
1770  // Despawn current buff
1772  // Set index for new one
1773  for (uint8 currBuffTypeIndex = 0; currBuffTypeIndex < 3; ++currBuffTypeIndex)
1774  if (entry == Buff_Entries[currBuffTypeIndex])
1775  {
1776  index -= currBuffTypeIndex;
1777  index += buff;
1778  }
1779  }
1780 
1782 }
bool m_BuffChange
Definition: Battleground.h:558
BattlegroundMap * GetBgMap() const
Definition: Battleground.h:356
void SpawnBGObject(uint32 type, uint32 respawntime)
Definition: Battleground.cpp:1564
uint32 m_MapId
Definition: Battleground.h:623
uint32 m_InstanceID
Definition: Battleground.h:570
GuidVector BgObjects
Definition: Battleground.h:452
uint32 urand(uint32 min, uint32 max)
Definition: Random.cpp:45
int32_t int32
Definition: Define.h:146
uint32_t uint32
Definition: Define.h:150
Definition: GameObject.h:880
Definition: Battleground.h:128
Definition: Battleground.h:130
bool isSpawned() const
Definition: GameObject.h:951
GameobjectTypes GetGoType() const
Definition: GameObject.h:964
uint8_t uint8
Definition: Define.h:152
uint32 const Buff_Entries[3]
Definition: Battleground.h:152
uint32 GetEntry() const
Definition: Object.h:107
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
GameObject * GetGameObject(ObjectGuid const &guid)
Definition: Map.cpp:3545
Definition: SharedDefines.h:2071
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

bool Battleground::HasFreeSlots ( ) const
1318 {
1319  return GetPlayersSize() < GetMaxPlayers();
1320 }
uint32 GetPlayersSize() const
Definition: Battleground.h:332
uint32 GetMaxPlayers() const
Definition: Battleground.h:271

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Battleground::IncreaseInvitedCount ( uint32  team)
inline
319 { (team == ALLIANCE) ? ++m_InvitedAlliance : ++m_InvitedHorde; }
uint32 m_InvitedHorde
Definition: Battleground.h:601
Definition: SharedDefines.h:1000
uint32 m_InvitedAlliance
Definition: Battleground.h:600

+ Here is the caller graph for this function:

virtual bool Battleground::IsAllNodesControlledByTeam ( uint32  ) const
inlinevirtual

Reimplemented in BattlegroundIC, BattlegroundEY, and BattlegroundAB.

255 { return false; }
bool Battleground::isArena ( ) const
inline
326 { return m_IsArena; }
bool m_IsArena
Definition: Battleground.h:583

+ Here is the caller graph for this function:

bool Battleground::isBattleground ( ) const
inline
327 { return !m_IsArena; }
bool m_IsArena
Definition: Battleground.h:583

+ Here is the caller graph for this function:

bool Battleground::IsPlayerInBattleground ( ObjectGuid  guid) const
1835 {
1836  BattlegroundPlayerMap::const_iterator itr = m_Players.find(guid);
1837  if (itr != m_Players.end())
1838  return true;
1839  return false;
1840 }
BattlegroundPlayerMap m_Players
Definition: Battleground.h:548

+ Here is the caller graph for this function:

bool Battleground::IsRandom ( ) const
inline
285 { return m_IsRandom; }
bool m_IsRandom
Definition: Battleground.h:559

+ Here is the caller graph for this function:

bool Battleground::isRated ( ) const
inline
328 { return m_IsRated; }
bool m_IsRated
Definition: Battleground.h:586

+ Here is the caller graph for this function:

virtual bool Battleground::IsSpellAllowed ( uint32  ,
Player const  
) const
inlinevirtual

Reimplemented in BattlegroundIC, and BattlegroundSA.

485 { return true; }
void Battleground::ModifyStartDelayTime ( int  diff)
inline
309 { m_StartDelayTime -= diff; }
int32 m_StartDelayTime
Definition: Battleground.h:585

+ Here is the caller graph for this function:

void Battleground::PlayerAddedToBGCheckIfBGIsRunning ( Player player)
protected
1843 {
1844  if (GetStatus() != STATUS_WAIT_LEAVE)
1845  return;
1846 
1849 
1850  BlockMovement(player);
1851 
1852  BuildPvPLogDataPacket(pvpLogData);
1853  player->SendDirectMessage(pvpLogData.Write());
1854 
1856  sBattlegroundMgr->BuildBattlegroundStatusActive(&battlefieldStatus, this, player, player->GetBattlegroundQueueIndex(bgQueueTypeId), player->GetBattlegroundQueueJoinTime(bgQueueTypeId), GetArenaType());
1857  player->SendDirectMessage(battlefieldStatus.Write());
1858 }
WorldPacket const * Write() override
Definition: BattlegroundPackets.cpp:165
BattlegroundStatus GetStatus() const
Definition: Battleground.h:266
static BattlegroundQueueTypeId BGQueueTypeId(BattlegroundTypeId bgTypeId, uint8 arenaType)
Definition: BattlegroundMgr.cpp:623
Definition: BattlegroundPackets.h:89
uint8 GetArenaType() const
Definition: Battleground.h:281
WorldPacket const * Write() override
Definition: BattlegroundPackets.cpp:102
void BuildPvPLogDataPacket(WorldPackets::Battleground::PVPLogData &pvpLogData)
Definition: Battleground.cpp:1322
void BlockMovement(Player *player)
Definition: Battleground.cpp:914
BattlegroundQueueTypeId
Definition: SharedDefines.h:4732
Definition: Battleground.h:160
Definition: BattlegroundPackets.h:170
#define sBattlegroundMgr
Definition: BattlegroundMgr.h:181
BattlegroundTypeId GetTypeID(bool GetRandom=false) const
Definition: Battleground.h:263

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Battleground::PlaySoundToAll ( uint32  SoundID)
682 {
684 }
static ObjectGuid const Empty
Definition: ObjectGuid.h:196
Definition: MiscPackets.h:601
void SendPacketToAll(WorldPacket const *packet) const
Definition: Battleground.cpp:657

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Battleground::PlaySoundToTeam ( uint32  SoundID,
uint32  TeamID 
)
687 {
688  for (BattlegroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
689  {
690  if (Player* player = _GetPlayerForTeam(teamID, itr, "PlaySoundToTeam"))
691  player->SendDirectMessage(WorldPackets::Misc::PlaySound(ObjectGuid::Empty, soundID).Write());
692  }
693 }
static ObjectGuid const Empty
Definition: ObjectGuid.h:196
BattlegroundPlayerMap m_Players
Definition: Battleground.h:548
WorldPacket const * Write() override
Definition: MiscPackets.cpp:438
Definition: MiscPackets.h:601
Player * _GetPlayerForTeam(uint32 teamId, BattlegroundPlayerMap::const_iterator itr, const char *context) const
Definition: Battleground.cpp:631

+ Here is the call graph for this function:

virtual void Battleground::PostUpdateImpl ( uint32  )
inlineprotectedvirtual

Post-update hook.

Will be called after battleground update has passed. May be used to implement custom update effects in subclasses.

Parameters
diffa time difference between two worldserver update loops in milliseconds.
See also
Update(), PreUpdateImpl().

Reimplemented in BattlegroundAV, BattlegroundIC, BattlegroundSA, BattlegroundEY, BattlegroundAB, BattlegroundWS, BattlegroundRV, and BattlegroundDS.

531 { }

+ Here is the caller graph for this function:

virtual bool Battleground::PreUpdateImpl ( uint32  )
inlineprotectedvirtual

Pre-update hook.

Will be called before battleground update is started. Depending on the result of this call actual update body may be skipped.

Parameters
diffa time difference between two worldserver update loops in milliseconds.
Returns
true if update must be performed, false otherwise.
See also
Update(), PostUpdateImpl().
518 { return true; }

+ Here is the caller graph for this function:

virtual void Battleground::ProcessEvent ( WorldObject ,
uint32  ,
WorldObject = NULL 
)
inlinevirtual

Reimplemented in BattlegroundSA.

431 { }
void Battleground::PSendMessageToAll ( uint32  entry,
ChatMsg  type,
Player const source,
  ... 
)
1717 {
1718  if (!entry)
1719  return;
1720 
1721  va_list ap;
1722  va_start(ap, source);
1723 
1724  Trinity::BattlegroundChatBuilder bg_builder(type, entry, source, &ap);
1726  BroadcastWorker(bg_do);
1727 
1728  va_end(ap);
1729 }
Definition: Battleground.cpp:42
Definition: GridNotifiers.h:1400
void BroadcastWorker(Do &_do)
Definition: Battleground.cpp:111

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Battleground::RelocateDeadPlayers ( ObjectGuid  guideGuid)

Relocate all players in ReviveQueue to the closest graveyard.

1424 {
1425  // Those who are waiting to resurrect at this node are taken to the closest own node's graveyard
1426  GuidVector& ghostList = m_ReviveQueue[guideGuid];
1427  if (!ghostList.empty())
1428  {
1429  WorldSafeLocsEntry const* closestGrave = NULL;
1430  for (GuidVector::const_iterator itr = ghostList.begin(); itr != ghostList.end(); ++itr)
1431  {
1432  Player* player = ObjectAccessor::FindPlayer(*itr);
1433  if (!player)
1434  continue;
1435 
1436  if (!closestGrave)
1437  closestGrave = GetClosestGraveYard(player);
1438 
1439  if (closestGrave)
1440  player->TeleportTo(GetMapId(), closestGrave->Loc.X, closestGrave->Loc.Y, closestGrave->Loc.Z, player->GetOrientation());
1441  }
1442  ghostList.clear();
1443  }
1444 }
float Z
Definition: DBCEnums.h:36
float Y
Definition: DBCEnums.h:35
virtual WorldSafeLocsEntry const * GetClosestGraveYard(Player *player)
Definition: Battleground.cpp:1900
Definition: DBCStructure.h:1434
arena_t NULL
Definition: jemalloc_internal.h:624
std::map< ObjectGuid, GuidVector > m_ReviveQueue
Definition: Battleground.h:550
std::vector< ObjectGuid > GuidVector
Definition: ObjectGuid.h:335
TC_GAME_API Player * FindPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:209
float X
Definition: DBCEnums.h:34
DBCPosition3D Loc
Definition: DBCStructure.h:1438
uint32 GetMapId() const
Definition: Battleground.h:352

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Battleground::RemoveAuraOnTeam ( uint32  SpellID,
uint32  TeamID 
)
703 {
704  for (BattlegroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
705  if (Player* player = _GetPlayerForTeam(TeamID, itr, "RemoveAuraOnTeam"))
706  player->RemoveAura(SpellID);
707 }
BattlegroundPlayerMap m_Players
Definition: Battleground.h:548
Player * _GetPlayerForTeam(uint32 teamId, BattlegroundPlayerMap::const_iterator itr, const char *context) const
Definition: Battleground.cpp:631

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Battleground::RemoveFromBGFreeSlotQueue ( )
1242 {
1243  if (m_InBGFreeSlotQueue)
1244  {
1245  sBattlegroundMgr->RemoveFromBGFreeSlotQueue(m_TypeID, m_InstanceID);
1246  m_InBGFreeSlotQueue = false;
1247  }
1248 }
uint32 m_InstanceID
Definition: Battleground.h:570
BattlegroundTypeId m_TypeID
Definition: Battleground.h:568
bool m_InBGFreeSlotQueue
Definition: Battleground.h:581
#define sBattlegroundMgr
Definition: BattlegroundMgr.h:181

+ Here is the caller graph for this function:

virtual void Battleground::RemovePlayer ( Player ,
ObjectGuid  ,
uint32   
)
inlineprotectedvirtual

Reimplemented in BattlegroundAV, BattlegroundIC, BattlegroundSA, BattlegroundEY, BattlegroundAB, BattlegroundWS, and Arena.

545 { }

+ Here is the caller graph for this function:

void Battleground::RemovePlayerAtLeave ( ObjectGuid  guid,
bool  Transport,
bool  SendPacket 
)
virtual

Reimplemented in Arena.

920 {
921  uint32 team = GetPlayerTeam(guid);
922  bool participant = false;
923  // Remove from lists/maps
924  BattlegroundPlayerMap::iterator itr = m_Players.find(guid);
925  if (itr != m_Players.end())
926  {
927  UpdatePlayersCountByTeam(team, true); // -1 player
928  m_Players.erase(itr);
929  // check if the player was a participant of the match, or only entered through gm command (goname)
930  participant = true;
931  }
932 
933  BattlegroundScoreMap::iterator itr2 = PlayerScores.find(guid);
934  if (itr2 != PlayerScores.end())
935  {
936  delete itr2->second; // delete player's score
937  PlayerScores.erase(itr2);
938  }
939 
941 
942  Player* player = ObjectAccessor::FindPlayer(guid);
943 
944  if (player)
945  {
946  // should remove spirit of redemption
947  if (player->HasAuraType(SPELL_AURA_SPIRIT_OF_REDEMPTION))
948  player->RemoveAurasByType(SPELL_AURA_MOD_SHAPESHIFT);
949 
950  player->RemoveAurasByType(SPELL_AURA_MOUNTED);
951 
952  if (!player->IsAlive()) // resurrect on exit
953  {
954  player->ResurrectPlayer(1.0f);
955  player->SpawnCorpseBones();
956  }
957  }
958  else
959  {
960  SQLTransaction trans(nullptr);
961  Player::OfflineResurrect(guid, trans);
962  }
963 
964  RemovePlayer(player, guid, team); // BG subclass specific code
965 
966  BattlegroundTypeId bgTypeId = GetTypeID();
968 
969  if (participant) // if the player was a match participant, remove auras, calc rating, update queue
970  {
971  if (player)
972  {
973  player->ClearAfkReports();
974 
975  // if arena, remove the specific arena auras
976  if (isArena())
977  {
978  bgTypeId = BATTLEGROUND_AA; // set the bg type to all arenas (it will be used for queue refreshing)
979 
980  // unsummon current and summon old pet if there was one and there isn't a current pet
981  player->RemovePet(NULL, PET_SAVE_NOT_IN_SLOT);
982  player->ResummonPetTemporaryUnSummonedIfAny();
983  }
984 
985  if (SendPacket)
986  {
988  sBattlegroundMgr->BuildBattlegroundStatusNone(&battlefieldStatus, player, player->GetBattlegroundQueueIndex(bgQueueTypeId), player->GetBattlegroundQueueJoinTime(bgQueueTypeId), m_ArenaType);
989  player->SendDirectMessage(battlefieldStatus.Write());
990  }
991 
992  // this call is important, because player, when joins to battleground, this method is not called, so it must be called when leaving bg
993  player->RemoveBattlegroundQueueId(bgQueueTypeId);
994  }
995 
996  // remove from raid group if player is member
997  if (Group* group = GetBgRaid(team))
998  {
999  if (!group->RemoveMember(guid)) // group was disbanded
1000  SetBgRaid(team, NULL);
1001  }
1002  DecreaseInvitedCount(team);
1003  //we should update battleground queue, but only if bg isn't ending
1005  {
1006  // a player has left the battleground, so there are free slots -> add to queue
1008  sBattlegroundMgr->ScheduleQueueUpdate(0, 0, bgQueueTypeId, bgTypeId, GetBracketId());
1009  }
1010 
1011  // Let others know
1013  playerLeft.Guid = guid;
1014  SendPacketToTeam(team, playerLeft.Write(), player, false);
1015  }
1016 
1017  if (player)
1018  {
1019  // Do next only if found in battleground
1020  player->SetBattlegroundId(0, BATTLEGROUND_TYPE_NONE); // We're not in BG.
1021  // reset destination bg team
1022  player->SetBGTeam(0);
1023 
1024  if (Transport)
1025  player->TeleportToBGEntryPoint();
1026 
1027  TC_LOG_DEBUG("bg.battleground", "Removed player %s from Battleground.", player->GetName().c_str());
1028  }
1029 
1030  //battleground object will be deleted next Battleground::Update() call
1031 }
Definition: BattlegroundPackets.h:147
BattlegroundTypeId
Definition: SharedDefines.h:4558
WorldPacket const * Write() override
Definition: BattlegroundPackets.cpp:277
void DecreaseInvitedCount(uint32 team)
Definition: Battleground.h:318
virtual void RemovePlayer(Player *, ObjectGuid, uint32)
Definition: Battleground.h:545
Definition: SharedDefines.h:4566
WorldPacket const * Write() override
Definition: BattlegroundPackets.cpp:150
BattlegroundStatus GetStatus() const
Definition: Battleground.h:266
void SetBgRaid(uint32 TeamID, Group *bg_raid)
Definition: Battleground.cpp:1890
uint32 GetPlayerTeam(ObjectGuid guid) const
Definition: Battleground.cpp:1821
static BattlegroundQueueTypeId BGQueueTypeId(BattlegroundTypeId bgTypeId, uint8 arenaType)
Definition: BattlegroundMgr.cpp:623
BattlegroundPlayerMap m_Players
Definition: Battleground.h:548
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: Transport.h:28
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
void RemovePlayerFromResurrectQueue(ObjectGuid player_guid)
Definition: Battleground.cpp:1406
void SendPacketToTeam(uint32 TeamID, WorldPacket const *packet, Player *sender=NULL, bool self=true) const
Definition: Battleground.cpp:664
bool isArena() const
Definition: Battleground.h:326
TC_GAME_API Player * FindPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:209
Definition: BattlegroundPackets.h:373
uint8 GetArenaType() const
Definition: Battleground.h:281
Definition: SpellAuraDefines.h:236
uint8 m_ArenaType
Definition: Battleground.h:580
uint32_t uint32
Definition: Define.h:150
bool isBattleground() const
Definition: Battleground.h:327
void AddToBGFreeSlotQueue()
Definition: Battleground.cpp:1231
BattlegroundBracketId GetBracketId() const
Definition: Battleground.h:264
BattlegroundQueueTypeId
Definition: SharedDefines.h:4732
Definition: Battleground.h:160
Definition: PetDefines.h:38
Definition: SpellAuraDefines.h:96
#define sBattlegroundMgr
Definition: BattlegroundMgr.h:181
BattlegroundTypeId GetTypeID(bool GetRandom=false) const
Definition: Battleground.h:263
Definition: SharedDefines.h:4560
ObjectGuid Guid
Definition: BattlegroundPackets.h:380
void UpdatePlayersCountByTeam(uint32 Team, bool remove)
Definition: Battleground.h:402
Group * GetBgRaid(uint32 TeamID) const
Definition: Battleground.h:393
Definition: Group.h:191
Definition: SpellAuraDefines.h:138
BattlegroundScoreMap PlayerScores
Definition: Battleground.h:543
std::shared_ptr< Transaction > SQLTransaction
Definition: Transaction.h:58

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Battleground::RemovePlayerFromResurrectQueue ( ObjectGuid  player_guid)
1407 {
1408  for (std::map<ObjectGuid, GuidVector>::iterator itr = m_ReviveQueue.begin(); itr != m_ReviveQueue.end(); ++itr)
1409  {
1410  for (GuidVector::iterator itr2 = itr->second.begin(); itr2 != itr->second.end(); ++itr2)
1411  {
1412  if (*itr2 == player_guid)
1413  {
1414  itr->second.erase(itr2);
1415  if (Player* player = ObjectAccessor::FindPlayer(player_guid))
1416  player->RemoveAurasDueToSpell(SPELL_WAITING_FOR_RESURRECT);
1417  return;
1418  }
1419  }
1420  }
1421 }
std::map< ObjectGuid, GuidVector > m_ReviveQueue
Definition: Battleground.h:550
TC_GAME_API Player * FindPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:209
Definition: Battleground.h:106

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Battleground::Reset ( )
virtual

Reimplemented in BattlegroundSA, BattlegroundEY, BattlegroundAB, and BattlegroundWS.

1035 {
1038  SetElapsedTime(0);
1039  SetRemainingTime(0);
1041  m_Events = 0;
1042 
1043  if (m_InvitedAlliance > 0 || m_InvitedHorde > 0)
1044  TC_LOG_ERROR("bg.battleground", "Battleground::Reset: one of the counters is not 0 (alliance: %u, horde: %u) for BG (map: %u, instance id: %u)!",
1046 
1047  m_InvitedAlliance = 0;
1048  m_InvitedHorde = 0;
1049  m_InBGFreeSlotQueue = false;
1050 
1051  m_Players.clear();
1052 
1053  for (BattlegroundScoreMap::const_iterator itr = PlayerScores.begin(); itr != PlayerScores.end(); ++itr)
1054  delete itr->second;
1055  PlayerScores.clear();
1056 
1057  for (uint8 i = 0; i < BG_TEAMS_COUNT; ++i)
1058  _arenaTeamScores[i].Reset();
1059 
1060  ResetBGSubclass();
1061 }
virtual void ResetBGSubclass()
Definition: Battleground.h:250
void SetRemainingTime(uint32 Time)
Definition: Battleground.h:298
BattlegroundPlayerMap m_Players
Definition: Battleground.h:548
void SetElapsedTime(uint32 Time)
Definition: Battleground.h:297
uint32 m_InvitedHorde
Definition: Battleground.h:601
Definition: Battleground.h:157
void SetLastResurrectTime(uint32 Time)
Definition: Battleground.h:299
uint32 m_MapId
Definition: Battleground.h:623
ArenaTeamScore _arenaTeamScores[BG_TEAMS_COUNT]
Definition: Battleground.h:564
#define BG_TEAMS_COUNT
Definition: SharedDefines.h:4555
uint32 m_InstanceID
Definition: Battleground.h:570
virtual void Reset()
Definition: Battleground.cpp:1034
uint8 m_Events
Definition: Battleground.h:553
uint32 m_InvitedAlliance
Definition: Battleground.h:600
Definition: SharedDefines.h:4552
void SetWinner(BattlegroundTeamId winnerTeamId)
Definition: Battleground.h:306
bool m_InBGFreeSlotQueue
Definition: Battleground.h:581
uint8_t uint8
Definition: Define.h:152
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
void SetStatus(BattlegroundStatus Status)
Definition: Battleground.h:295
BattlegroundScoreMap PlayerScores
Definition: Battleground.h:543

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

virtual void Battleground::ResetBGSubclass ( )
inlinevirtual

Reimplemented in BattlegroundAV.

250 { } // must be implemented in BG subclass

+ Here is the caller graph for this function:

void Battleground::RewardHonorToTeam ( uint32  Honor,
uint32  TeamID 
)
710 {
711  for (BattlegroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
712  if (Player* player = _GetPlayerForTeam(TeamID, itr, "RewardHonorToTeam"))
713  UpdatePlayerScore(player, SCORE_BONUS_HONOR, Honor);
714 }
virtual bool UpdatePlayerScore(Player *player, uint32 type, uint32 value, bool doAddHonor=true)
Definition: Battleground.cpp:1381
BattlegroundPlayerMap m_Players
Definition: Battleground.h:548
Definition: BattlegroundScore.h:30
Player * _GetPlayerForTeam(uint32 teamId, BattlegroundPlayerMap::const_iterator itr, const char *context) const
Definition: Battleground.cpp:631

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Battleground::RewardReputationToTeam ( uint32  faction_id,
uint32  Reputation,
uint32  TeamID 
)
717 {
718  FactionEntry const* factionEntry = sFactionStore.LookupEntry(faction_id);
719  if (!factionEntry)
720  return;
721 
722  for (BattlegroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
723  {
724  Player* player = _GetPlayerForTeam(TeamID, itr, "RewardReputationToTeam");
725  if (!player)
726  continue;
727 
728  uint32 repGain = Reputation;
729  AddPct(repGain, player->GetTotalAuraModifier(SPELL_AURA_MOD_REPUTATION_GAIN));
730  AddPct(repGain, player->GetTotalAuraModifierByMiscValue(SPELL_AURA_MOD_FACTION_REPUTATION_GAIN, faction_id));
731  player->GetReputationMgr().ModifyReputation(factionEntry, repGain);
732  }
733 }
BattlegroundPlayerMap m_Players
Definition: Battleground.h:548
Definition: SpellAuraDefines.h:216
uint32_t uint32
Definition: Define.h:150
Definition: DBCStructure.h:405
T AddPct(T &base, U pct)
Definition: Util.h:98
DBCStorage< FactionEntry > sFactionStore(Factionfmt)
Definition: SpellAuraDefines.h:250
Player * _GetPlayerForTeam(uint32 teamId, BattlegroundPlayerMap::const_iterator itr, const char *context) const
Definition: Battleground.cpp:631

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Battleground::RewardXPAtKill ( Player killer,
Player victim 
)
1919 {
1920  if (sWorld->getBoolConfig(CONFIG_BG_XP_FOR_KILL) && killer && victim)
1921  killer->RewardPlayerAndGroupAtKill(victim, true);
1922 }
Definition: World.h:138
#define sWorld
Definition: World.h:887

+ Here is the caller graph for this function:

void Battleground::SendChatMessage ( Creature source,
uint8  textId,
WorldObject target = NULL 
)
677 {
678  sCreatureTextMgr->SendChat(source, textId, target);
679 }
#define sCreatureTextMgr
Definition: CreatureTextMgr.h:113

+ Here is the caller graph for this function:

void Battleground::SendMessage2ToAll ( uint32  entry,
ChatMsg  type,
Player const source,
uint32  strId1 = 0,
uint32  strId2 = 0 
)
1732 {
1733  Trinity::Battleground2ChatBuilder bg_builder(type, entry, source, arg1, arg2);
1735  BroadcastWorker(bg_do);
1736 }
Definition: GridNotifiers.h:1400
void BroadcastWorker(Do &_do)
Definition: Battleground.cpp:111
Definition: Battleground.cpp:81

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Battleground::SendMessageToAll ( uint32  entry,
ChatMsg  type,
Player const source = NULL 
)
1707 {
1708  if (!entry)
1709  return;
1710 
1711  Trinity::BattlegroundChatBuilder bg_builder(type, entry, source);
1713  BroadcastWorker(bg_do);
1714 }
Definition: Battleground.cpp:42
Definition: GridNotifiers.h:1400
void BroadcastWorker(Do &_do)
Definition: Battleground.cpp:111

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Battleground::SendPacketToAll ( WorldPacket const packet) const
658 {
659  for (BattlegroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
660  if (Player* player = _GetPlayer(itr, "SendPacketToAll"))
661  player->SendDirectMessage(packet);
662 }
BattlegroundPlayerMap m_Players
Definition: Battleground.h:548
Player * _GetPlayer(ObjectGuid guid, bool offlineRemove, const char *context) const
Definition: Battleground.cpp:617

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Battleground::SendPacketToTeam ( uint32  TeamID,
WorldPacket const packet,
Player sender = NULL,
bool  self = true 
) const
665 {
666  for (BattlegroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
667  {
668  if (Player* player = _GetPlayerForTeam(TeamID, itr, "SendPacketToTeam"))
669  {
670  if (self || sender != player)
671  player->SendDirectMessage(packet);
672  }
673  }
674 }
BattlegroundPlayerMap m_Players
Definition: Battleground.h:548
Player * _GetPlayerForTeam(uint32 teamId, BattlegroundPlayerMap::const_iterator itr, const char *context) const
Definition: Battleground.cpp:631

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Battleground::SetArenaMatchmakerRating ( uint32  Team,
uint32  MMR 
)
inline
static TeamId GetTeamIndexByTeamId(uint32 Team)
Definition: Battleground.h:399
Team
Definition: SharedDefines.h:997
uint32 m_ArenaTeamMMR[BG_TEAMS_COUNT]
Definition: Battleground.h:612

+ Here is the caller graph for this function:

void Battleground::SetArenaorBGType ( bool  _isArena)
inline
305 { m_IsArena = _isArena; }
bool m_IsArena
Definition: Battleground.h:583

+ Here is the caller graph for this function:

void Battleground::SetArenaTeamIdForTeam ( uint32  Team,
uint32  ArenaTeamId 
)
inline
413 { m_ArenaTeamIds[GetTeamIndexByTeamId(Team)] = ArenaTeamId; }
static TeamId GetTeamIndexByTeamId(uint32 Team)
Definition: Battleground.h:399
Team
Definition: SharedDefines.h:997
uint32 m_ArenaTeamIds[BG_TEAMS_COUNT]
Definition: Battleground.h:610

+ Here is the caller graph for this function:

void Battleground::SetArenaType ( uint8  type)
inline
304 { m_ArenaType = type; }
uint8 m_ArenaType
Definition: Battleground.h:580

+ Here is the caller graph for this function:

void Battleground::SetBgMap ( BattlegroundMap map)
inline
355 { m_Map = map; }
BattlegroundMap * m_Map
Definition: Battleground.h:624

+ Here is the caller graph for this function:

void Battleground::SetBgRaid ( uint32  TeamID,
Group bg_raid 
)
1891 {
1892  Group*& old_raid = TeamID == ALLIANCE ? m_BgRaids[TEAM_ALLIANCE] : m_BgRaids[TEAM_HORDE];
1893  if (old_raid)
1894  old_raid->SetBattlegroundGroup(NULL);
1895  if (bg_raid)
1896  bg_raid->SetBattlegroundGroup(this);
1897  old_raid = bg_raid;
1898 }
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: SharedDefines.h:1000
Group * m_BgRaids[BG_TEAMS_COUNT]
Definition: Battleground.h:604
Definition: SharedDefines.h:992
void SetBattlegroundGroup(Battleground *bg)
Definition: Group.cpp:2621
Definition: SharedDefines.h:993
Definition: Group.h:191

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Battleground::SetBracket ( PvPDifficultyEntry const bracketEntry)
1913 {
1914  m_BracketId = bracketEntry->GetBracketId();
1915  SetLevelRange(bracketEntry->MinLevel, bracketEntry->MaxLevel);
1916 }
void SetLevelRange(uint32 min, uint32 max)
Definition: Battleground.h:302
BattlegroundBracketId m_BracketId
Definition: Battleground.h:579

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Battleground::SetClientInstanceID ( uint32  InstanceID)
inline
296 { m_ClientInstanceID = InstanceID; }
uint32 m_ClientInstanceID
Definition: Battleground.h:572

+ Here is the caller graph for this function:

void Battleground::SetDeleteThis ( )
inline
476 { m_SetDeleteThis = true; }
bool m_SetDeleteThis
Definition: Battleground.h:582
virtual void Battleground::SetDroppedFlagGUID ( ObjectGuid  ,
int32  = -1 
)
inlinevirtual

Reimplemented in BattlegroundEY, and BattlegroundWS.

482 { }
void Battleground::SetElapsedTime ( uint32  Time)
inline
297 { m_StartTime = Time; }
uint32 m_StartTime
Definition: Battleground.h:573

+ Here is the caller graph for this function:

void Battleground::SetHoliday ( bool  is_holiday)
1876 {
1877  m_HonorMode = is_holiday ? BG_HOLIDAY : BG_NORMAL;
1878 }
Definition: Battleground.h:206
Definition: Battleground.h:207
BGHonorMode m_HonorMode
Definition: Battleground.h:561
void Battleground::SetInstanceID ( uint32  InstanceID)
inline
294 { m_InstanceID = InstanceID; }
uint32 m_InstanceID
Definition: Battleground.h:570

+ Here is the caller graph for this function:

void Battleground::SetLastResurrectTime ( uint32  Time)
inline
299 { m_LastResurrectTime = Time; }
uint32 m_LastResurrectTime
Definition: Battleground.h:578

+ Here is the caller graph for this function:

void Battleground::SetLevelRange ( uint32  min,
uint32  max 
)
inline
302 { m_LevelMin = min; m_LevelMax = max; }
uint32 m_LevelMin
Definition: Battleground.h:615
T max(const T &x, const T &y)
Definition: g3dmath.h:320
T min(const T &x, const T &y)
Definition: g3dmath.h:305
uint32 m_LevelMax
Definition: Battleground.h:616

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Battleground::SetMapId ( uint32  MapID)
inline
351 { m_MapId = MapID; }
uint32 m_MapId
Definition: Battleground.h:623

+ Here is the caller graph for this function:

void Battleground::SetMaxPlayers ( uint32  MaxPlayers)
inline
300 { m_MaxPlayers = MaxPlayers; }
uint32 m_MaxPlayers
Definition: Battleground.h:618

+ Here is the caller graph for this function:

void Battleground::SetMaxPlayersPerTeam ( uint32  MaxPlayers)
inline
312 { m_MaxPlayersPerTeam = MaxPlayers; }
uint32 m_MaxPlayersPerTeam
Definition: Battleground.h:617

+ Here is the caller graph for this function:

void Battleground::SetMinPlayers ( uint32  MinPlayers)
inline
301 { m_MinPlayers = MinPlayers; }
uint32 m_MinPlayers
Definition: Battleground.h:620

+ Here is the caller graph for this function:

void Battleground::SetMinPlayersPerTeam ( uint32  MinPlayers)
inline
313 { m_MinPlayersPerTeam = MinPlayers; }
uint32 m_MinPlayersPerTeam
Definition: Battleground.h:619

+ Here is the caller graph for this function:

void Battleground::SetName ( std::string const name)
inline
289 { m_Name = name; }
std::string m_Name
Definition: Battleground.h:589

+ Here is the caller graph for this function:

void Battleground::SetQueueId ( uint64  queueId)
inline
288 { m_queueId = queueId; }
uint64 m_queueId
Definition: Battleground.h:590

+ Here is the caller graph for this function:

void Battleground::SetRandom ( bool  isRandom)
inline
321 { m_IsRandom = isRandom; }
bool m_IsRandom
Definition: Battleground.h:559

+ Here is the caller graph for this function:

void Battleground::SetRandomTypeID ( BattlegroundTypeId  TypeID)
inline
291 { m_RandomTypeID = TypeID; }
BattlegroundTypeId m_RandomTypeID
Definition: Battleground.h:569
TypeID
Definition: ObjectGuid.h:27

+ Here is the caller graph for this function:

void Battleground::SetRated ( bool  state)
inline
303 { m_IsRated = state; }
bool m_IsRated
Definition: Battleground.h:586

+ Here is the caller graph for this function:

void Battleground::SetRemainingTime ( uint32  Time)
inline
298 { m_EndTime = Time; }
int32 m_EndTime
Definition: Battleground.h:577

+ Here is the caller graph for this function:

void Battleground::SetScriptId ( uint32  scriptId)
inline
307 { ScriptId = scriptId; }
uint32 ScriptId
Definition: Battleground.h:627

+ Here is the caller graph for this function:

void Battleground::SetStartDelayTime ( int  Time)
inline
310 { m_StartDelayTime = Time; }
int32 m_StartDelayTime
Definition: Battleground.h:585

+ Here is the caller graph for this function:

void Battleground::SetStartMaxDist ( float  startMaxDist)
inline
362 { m_StartMaxDist = startMaxDist; }
float m_StartMaxDist
Definition: Battleground.h:626

+ Here is the caller graph for this function:

void Battleground::SetStatus ( BattlegroundStatus  Status)
inline
295 { m_Status = Status; }
BattlegroundStatus m_Status
Definition: Battleground.h:571

+ Here is the caller graph for this function:

void Battleground::SetTeamStartPosition ( TeamId  teamId,
Position const pos 
)
646 {
647  ASSERT(teamId < TEAM_NEUTRAL);
648  StartPosition[teamId] = pos;
649 }
Definition: SharedDefines.h:994
Position StartPosition[BG_TEAMS_COUNT]
Definition: Battleground.h:625
#define ASSERT
Definition: Errors.h:55

+ Here is the caller graph for this function:

void Battleground::SetTypeID ( BattlegroundTypeId  TypeID)
inline
290 { m_TypeID = TypeID; }
TypeID
Definition: ObjectGuid.h:27
BattlegroundTypeId m_TypeID
Definition: Battleground.h:568

+ Here is the caller graph for this function:

virtual bool Battleground::SetupBattleground ( )
inlinevirtual

Reimplemented in BattlegroundAV, BattlegroundIC, BattlegroundSA, BattlegroundEY, BattlegroundAB, BattlegroundWS, BattlegroundRV, BattlegroundDS, BattlegroundBE, BattlegroundNA, and BattlegroundRL.

244  {
245  return true;
246  }

+ Here is the caller graph for this function:

void Battleground::SetWinner ( BattlegroundTeamId  winnerTeamId)
inline
306 { _winnerTeamId = winnerTeamId; }
BattlegroundTeamId _winnerTeamId
Definition: Battleground.h:584

+ Here is the caller graph for this function:

void Battleground::SpawnBGObject ( uint32  type,
uint32  respawntime 
)
1565 {
1566  if (Map* map = FindBgMap())
1567  if (GameObject* obj = map->GetGameObject(BgObjects[type]))
1568  {
1569  if (respawntime)
1570  obj->SetLootState(GO_JUST_DEACTIVATED);
1571  else
1572  if (obj->getLootState() == GO_JUST_DEACTIVATED)
1573  // Change state from GO_JUST_DEACTIVATED to GO_READY in case battleground is starting again
1574  obj->SetLootState(GO_READY);
1575  obj->SetRespawnTime(respawntime);
1576  map->AddToMap(obj);
1577  }
1578 }
BattlegroundMap * FindBgMap() const
Definition: Battleground.h:357
Definition: GameObject.h:871
GuidVector BgObjects
Definition: Battleground.h:452
Definition: GameObject.h:880
Definition: Map.h:259
Definition: GameObject.h:869

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Battleground::StartBattleground ( )
1064 {
1065  SetElapsedTime(0);
1067  // add BG to free slot queue
1069 
1070  // add bg to update list
1071  // This must be done here, because we need to have already invited some players when first BG::Update() method is executed
1072  // and it doesn't matter if we call StartBattleground() more times, because m_Battlegrounds is a map and instance id never changes
1073  sBattlegroundMgr->AddBattleground(this);
1074 
1075  if (m_IsRated)
1076  TC_LOG_DEBUG("bg.arena", "Arena match type: %u for Team1Id: %u - Team2Id: %u started.", m_ArenaType, m_ArenaTeamIds[TEAM_ALLIANCE], m_ArenaTeamIds[TEAM_HORDE]);
1077 }
void SetElapsedTime(uint32 Time)
Definition: Battleground.h:297
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
void SetLastResurrectTime(uint32 Time)
Definition: Battleground.h:299
bool m_IsRated
Definition: Battleground.h:586
uint8 m_ArenaType
Definition: Battleground.h:580
Definition: SharedDefines.h:992
void AddToBGFreeSlotQueue()
Definition: Battleground.cpp:1231
#define sBattlegroundMgr
Definition: BattlegroundMgr.h:181
uint32 m_ArenaTeamIds[BG_TEAMS_COUNT]
Definition: Battleground.h:610
Definition: SharedDefines.h:993

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

virtual void Battleground::StartingEventCloseDoors ( )
inlinevirtual

Reimplemented in BattlegroundAV, BattlegroundIC, BattlegroundSA, BattlegroundEY, BattlegroundAB, BattlegroundWS, BattlegroundDS, BattlegroundBE, BattlegroundNA, and BattlegroundRL.

248 { }

+ Here is the caller graph for this function:

virtual void Battleground::StartingEventOpenDoors ( )
inlinevirtual
void Battleground::StartTimedAchievement ( AchievementCriteriaTimedTypes  type,
uint32  entry 
)
1906 {
1907  for (BattlegroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr)
1908  if (Player* player = ObjectAccessor::FindPlayer(itr->first))
1909  player->StartTimedAchievement(type, entry);
1910 }
BattlegroundPlayerMap const & GetPlayers() const
Definition: Battleground.h:331
TC_GAME_API Player * FindPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:209

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Battleground::ToBeDeleted ( ) const
inline
475 { return m_SetDeleteThis; }
bool m_SetDeleteThis
Definition: Battleground.h:582

+ Here is the caller graph for this function:

void Battleground::Update ( uint32  diff)
221 {
222  if (!PreUpdateImpl(diff))
223  return;
224 
225  if (!GetPlayersSize())
226  {
227  //BG is empty
228  // if there are no players invited, delete BG
229  // this will delete arena or bg object, where any player entered
230  // [[ but if you use battleground object again (more battles possible to be played on 1 instance)
231  // then this condition should be removed and code:
232  // if (!GetInvitedCount(HORDE) && !GetInvitedCount(ALLIANCE))
233  // this->AddToFreeBGObjectsQueue(); // not yet implemented
234  // should be used instead of current
235  // ]]
236  // Battleground Template instance cannot be updated, because it would be deleted
238  m_SetDeleteThis = true;
239  return;
240  }
241 
242  switch (GetStatus())
243  {
244  case STATUS_WAIT_JOIN:
245  if (GetPlayersSize())
246  {
247  _ProcessJoin(diff);
248  _CheckSafePositions(diff);
249  }
250  break;
251  case STATUS_IN_PROGRESS:
254  // after 47 minutes without one team losing, the arena closes with no winner and no rating change
255  if (isArena())
256  {
257  if (GetElapsedTime() >= 47 * MINUTE*IN_MILLISECONDS)
258  {
259  EndBattleground(0);
260  return;
261  }
262  }
263  else
264  {
265  _ProcessResurrect(diff);
267  _ProcessProgress(diff);
268  else if (m_PrematureCountDown)
269  m_PrematureCountDown = false;
270  }
271  break;
272  case STATUS_WAIT_LEAVE:
273  _ProcessLeave(diff);
274  break;
275  default:
276  break;
277  }
278 
279  // Update start time and reset stats timer
280  SetElapsedTime(GetElapsedTime() + diff);
281  if (GetStatus() == STATUS_WAIT_JOIN)
282  {
283  m_ResetStatTimer += diff;
284  m_CountdownTimer += diff;
285  }
286 
287  PostUpdateImpl(diff);
288 }
virtual bool PreUpdateImpl(uint32)
Pre-update hook.
Definition: Battleground.h:518
Definition: Battleground.h:159
uint32 GetMinPlayersPerTeam() const
Definition: Battleground.h:278
void _ProcessJoin(uint32 diff)
Definition: Battleground.cpp:452
uint32 GetPlayersSize() const
Definition: Battleground.h:332
uint32 m_ResetStatTimer
Definition: Battleground.h:575
void _ProcessProgress(uint32 diff)
Definition: Battleground.cpp:416
uint32 m_CountdownTimer
Definition: Battleground.h:574
BattlegroundStatus GetStatus() const
Definition: Battleground.h:266
void _CheckSafePositions(uint32 diff)
Definition: Battleground.cpp:290
void _ProcessLeave(uint32 diff)
Definition: Battleground.cpp:595
void _ProcessPlayerPositionBroadcast(uint32 diff)
Definition: Battleground.cpp:315
bool m_PrematureCountDown
Definition: Battleground.h:587
void SetElapsedTime(uint32 Time)
Definition: Battleground.h:297
void _ProcessOfflineQueue()
Definition: Battleground.cpp:328
Definition: Common.h:97
Definition: SharedDefines.h:1000
uint32 GetInvitedCount(uint32 team) const
Definition: Battleground.h:322
bool isArena() const
Definition: Battleground.h:326
Definition: Battleground.h:158
Definition: SharedDefines.h:999
bool m_SetDeleteThis
Definition: Battleground.h:582
Definition: Common.h:103
Definition: Battleground.h:160
#define sBattlegroundMgr
Definition: BattlegroundMgr.h:181
virtual void EndBattleground(uint32 winner)
Definition: Battleground.cpp:744
uint32 GetPlayersCountByTeam(uint32 Team) const
Definition: Battleground.h:400
uint32 GetElapsedTime() const
Definition: Battleground.h:268
void _ProcessResurrect(uint32 diff)
Definition: Battleground.cpp:346
virtual void PostUpdateImpl(uint32)
Post-update hook.
Definition: Battleground.h:531

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Battleground::UpdatePlayerScore ( Player player,
uint32  type,
uint32  value,
bool  doAddHonor = true 
)
virtual

Reimplemented in BattlegroundAV, BattlegroundEY, BattlegroundAB, and BattlegroundWS.

1382 {
1383  BattlegroundScoreMap::const_iterator itr = PlayerScores.find(player->GetGUID());
1384  if (itr == PlayerScores.end()) // player not found...
1385  return false;
1386 
1387  if (type == SCORE_BONUS_HONOR && doAddHonor && isBattleground())
1388  player->RewardHonor(NULL, 1, value); // RewardHonor calls UpdatePlayerScore with doAddHonor = false
1389  else
1390  itr->second->UpdateScore(type, value);
1391 
1392  return true;
1393 }
arena_t NULL
Definition: jemalloc_internal.h:624
bool isBattleground() const
Definition: Battleground.h:327
Definition: BattlegroundScore.h:30
const FieldDescriptor value
Definition: descriptor.h:1522
BattlegroundScoreMap PlayerScores
Definition: Battleground.h:543

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Battleground::UpdatePlayersCountByTeam ( uint32  Team,
bool  remove 
)
inline
403  {
404  if (remove)
406  else
408  }
static TeamId GetTeamIndexByTeamId(uint32 Team)
Definition: Battleground.h:399
Team
Definition: SharedDefines.h:997
uint32 m_PlayersCount[BG_TEAMS_COUNT]
Definition: Battleground.h:607

+ Here is the caller graph for this function:

void Battleground::UpdateWorldState ( uint32  variable,
uint32  value,
bool  hidden = false 
)
736 {
738  worldstate.VariableID = variable;
739  worldstate.Value = value;
740  worldstate.Hidden = hidden;
741  SendPacketToAll(worldstate.Write());
742 }
uint32 VariableID
Definition: WorldStatePackets.h:59
Definition: WorldStatePackets.h:50
int32 Value
Definition: WorldStatePackets.h:57
void SendPacketToAll(WorldPacket const *packet) const
Definition: Battleground.cpp:657
const FieldDescriptor value
Definition: descriptor.h:1522
bool Hidden
Definition: WorldStatePackets.h:58
WorldPacket const * Write() override
Definition: WorldStatePackets.cpp:44

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Member Data Documentation

ArenaTeamScore Battleground::_arenaTeamScores[BG_TEAMS_COUNT]
protected
BattlegroundTeamId Battleground::_winnerTeamId
private
GuidVector Battleground::BgCreatures
GuidVector Battleground::BgObjects
Todo:
make this protected:
uint32 Battleground::m_ArenaTeamIds[BG_TEAMS_COUNT]
private
uint32 Battleground::m_ArenaTeamMMR[BG_TEAMS_COUNT]
private
uint8 Battleground::m_ArenaType
private
Group* Battleground::m_BgRaids[BG_TEAMS_COUNT]
private
BattlegroundBracketId Battleground::m_BracketId
private
bool Battleground::m_BuffChange
protected
uint32 Battleground::m_ClientInstanceID
private
uint32 Battleground::m_CountdownTimer
private
int32 Battleground::m_EndTime
private
uint8 Battleground::m_Events
protected
BGHonorMode Battleground::m_HonorMode
protected
bool Battleground::m_InBGFreeSlotQueue
private
uint32 Battleground::m_InstanceID
private
uint32 Battleground::m_InvitedAlliance
private
uint32 Battleground::m_InvitedHorde
private
bool Battleground::m_IsArena
private
bool Battleground::m_IsRandom
protected
bool Battleground::m_IsRated
private
uint32 Battleground::m_LastPlayerPositionBroadcast
private
uint32 Battleground::m_LastResurrectTime
private
uint32 Battleground::m_LevelMax
private
uint32 Battleground::m_LevelMin
private
BattlegroundMap* Battleground::m_Map
private
uint32 Battleground::m_MapId
private
uint32 Battleground::m_MaxPlayers
private
uint32 Battleground::m_MaxPlayersPerTeam
private
uint32 Battleground::m_MinPlayers
private
uint32 Battleground::m_MinPlayersPerTeam
private
std::string Battleground::m_Name
private
GuidDeque Battleground::m_OfflineQueue
private
BattlegroundPlayerMap Battleground::m_Players
protected
uint32 Battleground::m_PlayersCount[BG_TEAMS_COUNT]
private
bool Battleground::m_PrematureCountDown
private
uint32 Battleground::m_PrematureCountDownTimer
private
uint64 Battleground::m_queueId
private
BattlegroundTypeId Battleground::m_RandomTypeID
private
uint32 Battleground::m_ResetStatTimer
private
GuidVector Battleground::m_ResurrectQueue
private
std::map<ObjectGuid, GuidVector> Battleground::m_ReviveQueue
protected
bool Battleground::m_SetDeleteThis
private
int32 Battleground::m_StartDelayTime
private
float Battleground::m_StartMaxDist
private
uint32 Battleground::m_StartTime
private
BattlegroundStatus Battleground::m_Status
private
int32 Battleground::m_TeamScores[BG_TEAMS_COUNT]
protected
BattlegroundTypeId Battleground::m_TypeID
private
uint32 Battleground::m_ValidStartPositionTimer
private
BattlegroundScoreMap Battleground::PlayerScores
protected
uint32 Battleground::ScriptId
private
BattlegroundStartTimeIntervals Battleground::StartDelayTimes[BG_STARTING_EVENT_COUNT]
protected
uint32 Battleground::StartMessageIds[BG_STARTING_EVENT_COUNT]
protected
Position Battleground::StartPosition[BG_TEAMS_COUNT]
private

The documentation for this class was generated from the following files: