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: