OregonCore  revision fb2a440-git
Your Favourite TBC server
Battleground Class Reference

#include <Battleground.h>

+ Inheritance diagram for Battleground:

Public Types

typedef std::map< uint64, BattlegroundPlayerBattlegroundPlayerMap
 
typedef std::map< uint64, BattlegroundScore * > BattlegroundScoreMap
 
typedef std::vector< uint64BGObjects
 
typedef std::vector< uint64BGCreatures
 

Public Member Functions

 Battleground ()
 
virtual ~Battleground ()
 
virtual void Update (uint32 diff)
 
virtual bool SetupBattleground ()
 
void Reset ()
 
virtual void StartingEventCloseDoors ()
 
virtual void StartingEventOpenDoors ()
 
virtual void ResetBGSubclass ()
 
char const * GetName () const
 
uint32 GetTypeID () const
 
uint32 GetQueueType () const
 
uint32 GetInstanceID () const
 
uint32 GetStatus () const
 
uint32 GetStartTime () const
 
uint32 GetEndTime () const
 
uint32 GetLastResurrectTime () const
 
uint32 GetMaxPlayers () const
 
uint32 GetMinPlayers () const
 
uint32 GetMinLevel () const
 
uint32 GetMaxLevel () const
 
uint32 GetMaxPlayersPerTeam () const
 
uint32 GetMinPlayersPerTeam () const
 
int GetStartDelayTime () const
 
uint8 GetArenaType () const
 
uint8 GetWinner () const
 
uint32 GetBattlemasterEntry () const
 
void SetName (char const *Name)
 
void SetTypeID (uint32 TypeID)
 
void SetQueueType (uint32 ID)
 
void SetInstanceID (uint32 InstanceID)
 
void SetStatus (uint32 Status)
 
void SetStartTime (uint32 Time)
 
void SetEndTime (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 (uint8 winner)
 
void ModifyStartDelayTime (int diff)
 
void SetStartDelayTime (int Time)
 
void SetMaxPlayersPerTeam (uint32 MaxPlayers)
 
void SetMinPlayersPerTeam (uint32 MinPlayers)
 
void AddToBGFreeSlotQueue ()
 
void RemoveFromBGFreeSlotQueue ()
 
void _CheckSafePositions (uint32 diff)
 
void SetStartMaxDist (float startMaxDist)
 
float GetStartMaxDist () const
 
void DecreaseInvitedCount (uint32 team)
 
void IncreaseInvitedCount (uint32 team)
 
uint32 GetInvitedCount (uint32 team) const
 
bool HasFreeSlotsForTeam (uint32 Team) const
 
bool HasFreeSlots () const
 
uint32 GetFreeSlotsForTeam (uint32 Team) const
 
bool isArena () const
 
bool isBattleground () const
 
bool isRated () const
 
BattlegroundPlayerMap const & GetPlayers () const
 
uint32 GetPlayersSize () const
 
uint32 GetRemovedPlayersSize () const
 
BattlegroundScoreMap::const_iterator GetPlayerScoresBegin () const
 
BattlegroundScoreMap::const_iterator GetPlayerScoresEnd () const
 
uint32 GetPlayerScoresSize () const
 
uint32 GetReviveQueueSize () const
 
void AddPlayerToResurrectQueue (uint64 npc_guid, uint64 player_guid)
 
void RemovePlayerFromResurrectQueue (uint64 player_guid)
 
void StartBattleground ()
 
GameObjectGetBGObject (uint32 type)
 
CreatureGetBGCreature (uint32 type)
 
void SetMapId (uint32 MapID)
 
uint32 GetMapId () const
 
void SetBgMap (BattlegroundMap *map)
 
BattlegroundMapGetBgMap ()
 
void SetTeamStartLoc (uint32 TeamID, float X, float Y, float Z, float O)
 
void GetTeamStartLoc (uint32 TeamID, float &X, float &Y, float &Z, float &O) const
 
virtual void FillInitialWorldStates (WorldPacket &)
 
void SendPacketToTeam (uint32 TeamID, WorldPacket *packet, Player *sender=NULL, bool self=true)
 
void SendPacketToAll (WorldPacket *packet)
 
void YellToAll (Creature *creature, const char *text, uint32 language)
 
template<class Do >
void BroadcastWorker (Do &_do)
 
void PlaySoundToTeam (uint32 SoundID, uint32 TeamID)
 
void PlaySoundToAll (uint32 SoundID)
 
void CastSpellOnTeam (uint32 SpellID, uint32 TeamID)
 
void RewardHonorToTeam (uint32 Honor, uint32 TeamID)
 
void RewardReputationToTeam (uint32 faction_id, uint32 Reputation, uint32 TeamID)
 
void RewardMark (Player *plr, uint32 count)
 
void SendRewardMarkByMail (Player *plr, uint32 mark, uint32 count)
 
void RewardQuest (Player *plr)
 
void UpdateWorldState (uint32 Field, uint32 Value)
 
void UpdateWorldStateForPlayer (uint32 Field, uint32 Value, Player *Source)
 
void EndBattleground (uint32 winner)
 
void BlockMovement (Player *plr)
 
void SendMessageToAll (int32 entry, ChatMsg type, Player const *source=NULL)
 
void PSendMessageToAll (int32 entry, ChatMsg type, Player const *source,...)
 
void SendMessage2ToAll (int32 entry, ChatMsg type, Player const *source, int32 strId1=0, int32 strId2=0)
 
GroupGetBgRaid (uint32 TeamID) const
 
void SetBgRaid (uint32 TeamID, Group *bg_raid)
 
virtual void UpdatePlayerScore (Player *Source, uint32 type, uint32 value)
 
uint8 GetTeamIndexByTeamId (uint32 Team) const
 
uint32 GetPlayersCountByTeam (uint32 Team) const
 
uint32 GetAlivePlayersCountByTeam (uint32 Team) const
 
void UpdatePlayersCountByTeam (uint32 Team, bool remove)
 
void SetArenaTeamIdForTeam (uint32 Team, uint32 ArenaTeamId)
 
uint32 GetArenaTeamIdForTeam (uint32 Team) const
 
void SetArenaTeamRatingChangeForTeam (uint32 Team, int32 RatingChange)
 
int32 GetArenaTeamRatingChangeForTeam (uint32 Team) const
 
void CheckArenaWinConditions ()
 
virtual void HandleAreaTrigger (Player *, uint32)
 
virtual void HandleKillPlayer (Player *player, Player *killer)
 
virtual void HandleKillUnit (Creature *, Player *)
 
virtual void EventPlayerDroppedFlag (Player *)
 
virtual void EventPlayerClickedOnFlag (Player *, GameObject *)
 
virtual void EventPlayerCapturedFlag (Player *)
 
void EventPlayerLoggedOut (Player *player)
 
virtual WorldSafeLocsEntry const * GetClosestGraveYard (Player *player)
 
virtual void AddPlayer (Player *plr)
 
virtual void RemovePlayerAtLeave (uint64 guid, bool Transport, bool SendPacket)
 
void HandleTriggerBuff (uint64 const &go_guid)
 
void SetHoliday (bool is_holiday)
 
void SpawnBGObject (uint32 type, uint32 respawntime)
 
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)
 
CreatureAddCreature (uint32 entry, uint32 type, uint32 teamval, float x, float y, float z, float o, uint32 respawntime=0)
 
bool DelCreature (uint32 type)
 
bool DelObject (uint32 type)
 
bool AddSpiritGuide (uint32 type, float x, float y, float z, float o, uint32 team)
 
int32 GetObjectType (uint64 guid)
 
void DoorOpen (uint32 type)
 
void DoorClose (uint32 type)
 
const char * GetOregonString (int32 entry)
 
virtual bool HandlePlayerUnderMap (Player *)
 
uint32 GetPlayerTeam (uint64 guid)
 
uint32 GetOtherTeam (uint32 teamId)
 
bool IsPlayerInBattleground (uint64 guid)
 
void PlayerRelogin (uint64 guid)
 
void SetDeleteThis ()
 
void Announce ()
 

Public Attributes

BGObjects m_BgObjects
 
BGCreatures m_BgCreatures
 
int32 m_TeamScores [BG_TEAMS_COUNT]
 

Protected Member Functions

void EndNow ()
 
virtual void RemovePlayer (Player *, uint64)
 

Protected Attributes

BattlegroundScoreMap m_PlayerScores
 
BattlegroundPlayerMap m_Players
 
std::map< uint64, std::vector< uint64 > > m_ReviveQueue
 
uint8 m_Events
 
BattlegroundStartTimeIntervals m_StartDelayTimes [BG_STARTING_EVENT_COUNT]
 
uint32 m_StartMessageIds [BG_STARTING_EVENT_COUNT]
 
bool m_BuffChange
 
uint32 m_score [2]
 
BGHonorMode m_HonorMode
 

Private Attributes

uint32 m_TypeID
 
uint32 m_InstanceID
 
uint32 m_Status
 
uint32 m_StartTime
 
uint32 m_ValidStartPositionTimer
 
uint32 m_EndTime
 
uint32 m_LastResurrectTime
 
uint32 m_Queue_type
 
uint8 m_ArenaType
 
bool m_InBGFreeSlotQueue
 
bool m_SetDeleteThis
 
bool m_IsArena
 
uint8 m_Winner
 
int32 m_StartDelayTime
 
bool m_IsRated
 
bool m_PrematureCountDown
 
uint32 m_PrematureCountDownTimer
 
char const * m_Name
 
std::vector< uint64m_ResurrectQueue
 
std::map< uint64, uint8m_RemovedPlayers
 
uint32 m_InvitedAlliance
 
uint32 m_InvitedHorde
 
Groupm_BgRaids [BG_TEAMS_COUNT]
 
uint32 m_PlayersCount [BG_TEAMS_COUNT]
 
uint32 m_ArenaTeamIds [BG_TEAMS_COUNT]
 
int32 m_ArenaTeamRatingChanges [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
 
float m_TeamStartLocX [BG_TEAMS_COUNT]
 
float m_TeamStartLocY [BG_TEAMS_COUNT]
 
float m_TeamStartLocZ [BG_TEAMS_COUNT]
 
float m_TeamStartLocO [BG_TEAMS_COUNT]
 
float m_StartMaxDist
 

Friends

class BattlegroundMgr
 

Detailed Description

Definition at line 278 of file Battleground.h.

Member Typedef Documentation

Definition at line 494 of file Battleground.h.

Definition at line 508 of file Battleground.h.

typedef std::vector<uint64> Battleground::BGCreatures

Definition at line 671 of file Battleground.h.

typedef std::vector<uint64> Battleground::BGObjects

Definition at line 670 of file Battleground.h.

Constructor & Destructor Documentation

Battleground::Battleground ( )

Definition at line 119 of file Battleground.cpp.

References BG_NORMAL, BG_START_DELAY_1M, BG_START_DELAY_2M, BG_START_DELAY_30S, BG_START_DELAY_NONE, BG_STARTING_EVENT_FIRST, BG_STARTING_EVENT_FOURTH, BG_STARTING_EVENT_SECOND, BG_STARTING_EVENT_THIRD, BG_TEAM_ALLIANCE, BG_TEAM_HORDE, LANG_BG_WS_HAS_BEGUN, LANG_BG_WS_START_HALF_MINUTE, LANG_BG_WS_START_ONE_MINUTE, LANG_BG_WS_START_TWO_MINUTES, and MAX_BATTLEGROUND_QUEUES.

120 {
121  m_TypeID = 0;
122  m_InstanceID = 0;
123  m_Status = 0;
124  m_EndTime = 0;
127  m_InvitedAlliance = 0;
128  m_InvitedHorde = 0;
129  m_ArenaType = 0;
130  m_IsArena = false;
131  m_Winner = 2;
132  m_StartTime = 0;
134  m_Events = 0;
135  m_StartDelayTime = 0;
136  m_IsRated = false;
137  m_BuffChange = false;
138  m_Name = "";
139  m_LevelMin = 0;
140  m_LevelMax = 0;
141  m_InBGFreeSlotQueue = false;
142  m_SetDeleteThis = false;
143 
145  m_MaxPlayers = 0;
147  m_MinPlayers = 0;
148 
149  m_MapId = 0;
150  m_Map = NULL;
151  m_StartMaxDist = 0.0f;
152 
155 
158 
161 
164 
167 
170 
171  m_BgRaids[BG_TEAM_ALLIANCE] = NULL;
172  m_BgRaids[BG_TEAM_HORDE] = NULL;
173 
176 
179 
182 
183  m_PrematureCountDown = false;
185 
187 
192  //we must set to some default existing values
197 }
uint32 m_MinPlayersPerTeam
Definition: Battleground.h:784
int32 m_StartDelayTime
Definition: Battleground.h:752
uint32 m_StartMessageIds[BG_STARTING_EVENT_COUNT]
Definition: Battleground.h:728
int32 m_TeamScores[BG_TEAMS_COUNT]
Definition: Battleground.h:704
uint32 m_EndTime
Definition: Battleground.h:741
uint32 m_ValidStartPositionTimer
Definition: Battleground.h:740
char const * m_Name
Definition: Battleground.h:756
#define MAX_BATTLEGROUND_QUEUES
uint32 m_PrematureCountDownTimer
Definition: Battleground.h:755
int32 m_ArenaTeamRatingChanges[BG_TEAMS_COUNT]
Definition: Battleground.h:777
bool m_PrematureCountDown
Definition: Battleground.h:754
uint32 m_LevelMin
Definition: Battleground.h:780
uint32 m_InvitedHorde
Definition: Battleground.h:766
uint32 m_MaxPlayersPerTeam
Definition: Battleground.h:782
float m_TeamStartLocZ[BG_TEAMS_COUNT]
Definition: Battleground.h:792
uint32 m_StartTime
Definition: Battleground.h:739
BattlegroundStartTimeIntervals m_StartDelayTimes[BG_STARTING_EVENT_COUNT]
Definition: Battleground.h:726
uint32 m_MapId
Definition: Battleground.h:788
uint32 m_TypeID
Definition: Battleground.h:736
Group * m_BgRaids[BG_TEAMS_COUNT]
Definition: Battleground.h:769
float m_TeamStartLocY[BG_TEAMS_COUNT]
Definition: Battleground.h:791
float m_TeamStartLocO[BG_TEAMS_COUNT]
Definition: Battleground.h:793
uint32 m_Queue_type
Definition: Battleground.h:743
uint32 m_InstanceID
Definition: Battleground.h:737
uint32 m_MinPlayers
Definition: Battleground.h:785
uint32 m_MaxPlayers
Definition: Battleground.h:783
uint32 m_LastResurrectTime
Definition: Battleground.h:742
uint8 m_ArenaType
Definition: Battleground.h:744
uint32 m_PlayersCount[BG_TEAMS_COUNT]
Definition: Battleground.h:772
uint32 m_InvitedAlliance
Definition: Battleground.h:765
BattlegroundMap * m_Map
Definition: Battleground.h:789
bool m_SetDeleteThis
Definition: Battleground.h:746
bool m_InBGFreeSlotQueue
Definition: Battleground.h:745
uint32 m_Status
Definition: Battleground.h:738
uint32 m_LevelMax
Definition: Battleground.h:781
uint32 m_score[2]
Definition: Battleground.h:731
uint32 m_ArenaTeamIds[BG_TEAMS_COUNT]
Definition: Battleground.h:775
float m_TeamStartLocX[BG_TEAMS_COUNT]
Definition: Battleground.h:790
float m_StartMaxDist
Definition: Battleground.h:794
BGHonorMode m_HonorMode
Definition: Battleground.h:733
Battleground::~Battleground ( )
virtual

Definition at line 199 of file Battleground.cpp.

References CharacterDatabase, Database::PExecute(), sBattlegroundMgr, and WorldDatabase.

200 {
201  // remove objects and creatures
202  // (this is done automatically in mapmanager update, when the instance is reset after the reset time)
203  int size = m_BgCreatures.size();
204  for (int i = 0; i < size; ++i)
205  DelCreature(i);
206 
207  size = m_BgObjects.size();
208  for (int i = 0; i < size; ++i)
209  DelObject(i);
210 
211  if (GetInstanceID()) // not spam by useless queries in case BG templates
212  {
213  // delete creature and go respawn times
214  WorldDatabase.PExecute("DELETE FROM creature_respawn WHERE instance = '%u'", GetInstanceID());
215  WorldDatabase.PExecute("DELETE FROM gameobject_respawn WHERE instance = '%u'", GetInstanceID());
216  // delete instance from db
217  CharacterDatabase.PExecute("DELETE FROM instance WHERE id = '%u'", GetInstanceID());
218  // remove from battlegrounds
219  }
220 
221  sBattlegroundMgr.RemoveBattleground(GetInstanceID());
222  // unload map
223  if (m_Map)
224  m_Map->SetUnload();
225  // remove from bg free slot queue
227 
228  for (BattlegroundScoreMap::const_iterator itr = m_PlayerScores.begin(); itr != m_PlayerScores.end(); ++itr)
229  delete itr->second;
230 }
DatabaseType WorldDatabase
Accessor to the world database.
Definition: Main.cpp:53
bool DelObject(uint32 type)
BattlegroundScoreMap m_PlayerScores
Definition: Battleground.h:713
BGCreatures m_BgCreatures
Definition: Battleground.h:673
BGObjects m_BgObjects
Definition: Battleground.h:672
void RemoveFromBGFreeSlotQueue()
bool PExecute(const char *format,...) ATTR_PRINTF(2
Definition: Database.cpp:441
uint32 GetInstanceID() const
Definition: Battleground.h:313
BattlegroundMap * m_Map
Definition: Battleground.h:789
bool DelCreature(uint32 type)
void SetUnload()
Definition: Map.cpp:2614
#define sBattlegroundMgr
DatabaseType CharacterDatabase
Accessor to the character database.
Definition: Main.cpp:54

Member Function Documentation

void Battleground::_CheckSafePositions ( uint32  diff)
inline

Definition at line 1922 of file Battleground.cpp.

References CHECK_PLAYER_POSITION_INVERVAL, ObjectAccessor::FindPlayer(), Position::GetPosition(), Position::IsInDist2d(), and sLog.

1923 {
1924  float maxDist = GetStartMaxDist();
1925  if (!maxDist)
1926  return;
1927 
1928  m_ValidStartPositionTimer += diff;
1930  {
1932 
1933  Position pos;
1934  float x, y, z, o;
1935  for (BattlegroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr)
1936  if (Player* player = ObjectAccessor::FindPlayer(itr->first))
1937  {
1938  pos = player->GetPosition();
1939  GetTeamStartLoc(player->GetBGTeam(), x, y, z, o);
1940  if (!pos.IsInDist2d(x, y, maxDist))
1941  {
1942  sLog.outDebug("BATTLEGROUND: Sending %s back to start location (map: %u) (possible exploit)", player->GetName(), GetMapId());
1943  player->TeleportTo(GetMapId(), x, y, z, o);
1944  }
1945  }
1946  }
1947 }
uint32 m_ValidStartPositionTimer
Definition: Battleground.h:740
#define sLog
Log class singleton.
Definition: Log.h:187
float GetStartMaxDist() const
Definition: Battleground.h:460
BattlegroundPlayerMap const & GetPlayers() const
Definition: Battleground.h:495
void GetPosition(float &x, float &y) const
Definition: Position.h:102
static Player * FindPlayer(uint64, bool force=false)
bool IsInDist2d(float x, float y, float dist) const
Definition: Position.h:178
void GetTeamStartLoc(uint32 TeamID, float &X, float &Y, float &Z, float &O) const
Definition: Battleground.h:556
uint32 GetMapId() const
Definition: Battleground.h:539
Definition: Player.h:922
Creature * Battleground::AddCreature ( uint32  entry,
uint32  type,
uint32  teamval,
float  x,
float  y,
float  z,
float  o,
uint32  respawntime = 0 
)

Definition at line 1559 of file Battleground.cpp.

References Map::AddToMap(), Creature::Create(), Object::GetGUID(), HIGHGUID_UNIT, PHASEMASK_NORMAL, Creature::SetHomePosition(), sLog, and sObjectMgr.

Referenced by BattlegroundAV::AddAVCreature().

1560 {
1561  Map* map = GetBgMap();
1562  if (!map)
1563  return NULL;
1564 
1565  Creature* creature = new Creature;
1566  if (!creature->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_UNIT), map, PHASEMASK_NORMAL, entry, teamval, x, y, z, o))
1567  {
1568  sLog.outError("Can't create creature entry: %u", entry);
1569  delete creature;
1570  return NULL;
1571  }
1572 
1573  creature->SetHomePosition(x, y, z, o);
1574 
1575  //creature->SetDungeonDifficulty(0);
1576 
1577  if (!map->AddToMap(creature))
1578  {
1579  delete creature;
1580  return NULL;
1581  }
1582 
1583  m_BgCreatures[type] = creature->GetGUID();
1584 
1585  return creature;
1586 }
bool AddToMap(T *)
Definition: Map.cpp:424
#define sLog
Log class singleton.
Definition: Log.h:187
void SetHomePosition(float x, float y, float z, float o)
Definition: Creature.h:719
#define sObjectMgr
Definition: ObjectMgr.h:1285
BGCreatures m_BgCreatures
Definition: Battleground.h:673
BattlegroundMap * GetBgMap()
Definition: Battleground.h:549
bool Create(uint32 guidlow, Map *map, uint32 phaseMask, uint32 Entry, uint32 team, float x, float y, float z, float ang, const CreatureData *data=NULL)
Definition: Creature.cpp:764
Definition: Map.h:266
const uint64 & GetGUID() const
Definition: Object.h:162
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 
)

Definition at line 1433 of file Battleground.cpp.

References GameObject::Create(), Object::GetGUID(), GO_STATE_READY, HIGHGUID_GAMEOBJECT, sLog, and sObjectMgr.

Referenced by BattlegroundRL::SetupBattleground(), BattlegroundBE::SetupBattleground(), BattlegroundNA::SetupBattleground(), BattlegroundWS::SetupBattleground(), BattlegroundAB::SetupBattleground(), BattlegroundEY::SetupBattleground(), and BattlegroundAV::SetupBattleground().

1434 {
1435  Map* map = GetBgMap();
1436  if (!map)
1437  return false;
1438 
1439  // must be created this way, adding to godatamap would add it to the base map of the instance
1440  // and when loading it (in go::LoadFromDB()), a new guid would be assigned to the object, and a new object would be created
1441  // so we must create it specific for this instance
1442  GameObject* go = new GameObject;
1443  if (!go->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT), entry, map, 0x00000001, x, y, z, o, rotation0, rotation1, rotation2, rotation3, 100, GO_STATE_READY))
1444  {
1445  sLog.outErrorDb("Gameobject template %u not found in database! Battleground not created!", entry);
1446  sLog.outError("Cannot create gameobject template %u! Battleground not created!", entry);
1447  delete go;
1448  return false;
1449  }
1450  /*
1451  uint32 guid = go->GetGUIDLow();
1452 
1453  // without this, UseButtonOrDoor caused the crash, since it tried to get go info from godata
1454  // 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
1455  GameObjectData& data = sObjectMgr.NewGOData(guid);
1456 
1457  data.id = entry;
1458  data.mapid = GetMapId();
1459  data.posX = x;
1460  data.posY = y;
1461  data.posZ = z;
1462  data.orientation = o;
1463  data.rotation0 = rotation0;
1464  data.rotation1 = rotation1;
1465  data.rotation2 = rotation2;
1466  data.rotation3 = rotation3;
1467  data.spawntimesecs = respawnTime;
1468  data.spawnMask = 1;
1469  data.animprogress = 100;
1470  data.go_state = 1;
1471  */
1472  // add to world, so it can be later looked up from HashMapHolder
1473  if (!map->AddToMap(go))
1474  {
1475  delete go;
1476  return false;
1477  }
1478  m_BgObjects[type] = go->GetGUID();
1479  return true;
1480 }
#define sLog
Log class singleton.
Definition: Log.h:187
#define sObjectMgr
Definition: ObjectMgr.h:1285
BattlegroundMap * GetBgMap()
Definition: Battleground.h:549
BGObjects m_BgObjects
Definition: Battleground.h:672
Definition: Map.h:266
bool Create(uint32 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:166
const uint64 & GetGUID() const
Definition: Object.h:162
void Battleground::AddPlayer ( Player plr)
virtual

Reimplemented in BattlegroundAV, BattlegroundEY, BattlegroundAB, BattlegroundWS, BattlegroundNA, BattlegroundBE, BattlegroundRL, and BattlegroundAA.

Definition at line 1168 of file Battleground.cpp.

References ALLIANCE, Unit::CastSpell(), Unit::CombatStop(), HostileRefManager::deleteReferences(), Player::DestroyConjuredItems(), Player::GetBGTeam(), Unit::GetCharmInfo(), Object::GetGUID(), Unit::getHostileRefManager(), WorldObject::GetName(), Player::GetPet(), CharmInfo::GetPetNumber(), Pet::getPetType(), Player::GetTeam(), Object::GetUInt32Value(), Object::HasFlag(), HORDE, HUNTER_PET, BattlegroundPlayer::LastOnlineTime, PET_SAVE_NOT_IN_SLOT, PLAYER_FLAGS, PLAYER_FLAGS_AFK, Player::RemoveAllEnchantments(), Unit::RemoveArenaAuras(), Player::RemoveArenaSpellCooldowns(), Unit::RemoveSpellsCausingAura(), Player::ResetAllPowers(), sBattlegroundMgr, sLog, SPELL_ALLIANCE_GOLD_FLAG, SPELL_ALLIANCE_GREEN_FLAG, SPELL_ARENA_PREPARATION, SPELL_AURA_MOUNTED, SPELL_HORDE_GOLD_FLAG, SPELL_HORDE_GREEN_FLAG, SPELL_PREPARATION, STATUS_WAIT_JOIN, SUMMON_PET, BattlegroundPlayer::Team, TEMP_ENCHANTMENT_SLOT, Player::ToggleAFK(), and UNIT_CREATED_BY_SPELL.

Referenced by BattlegroundAA::AddPlayer(), BattlegroundRL::AddPlayer(), BattlegroundBE::AddPlayer(), BattlegroundNA::AddPlayer(), BattlegroundWS::AddPlayer(), BattlegroundAB::AddPlayer(), BattlegroundEY::AddPlayer(), and BattlegroundAV::AddPlayer().

1169 {
1170  // remove afk from player
1172  plr->ToggleAFK();
1173 
1174  // score struct must be created in inherited class
1175 
1176  uint64 guid = plr->GetGUID();
1177  uint32 team = plr->GetBGTeam();
1178 
1179  BattlegroundPlayer bp;
1180  bp.LastOnlineTime = 0;
1181  bp.Team = team;
1182 
1183  // Add to list/maps
1184  m_Players[guid] = bp;
1185 
1186  UpdatePlayersCountByTeam(team, false); // +1 player
1187 
1188  WorldPacket data;
1189  sBattlegroundMgr.BuildPlayerJoinedBattlegroundPacket(&data, plr);
1190  SendPacketToTeam(team, &data, plr, false);
1191 
1193  plr->CombatStop();
1195 
1196  // add arena specific auras
1197  if (isArena())
1198  {
1200  plr->RemoveArenaAuras();
1202  if (team == ALLIANCE) // gold
1203  {
1204  if (plr->GetTeam() == HORDE)
1205  plr->CastSpell(plr, SPELL_HORDE_GOLD_FLAG, true);
1206  else
1207  plr->CastSpell(plr, SPELL_ALLIANCE_GOLD_FLAG, true);
1208  }
1209  else // green
1210  {
1211  if (plr->GetTeam() == HORDE)
1212  plr->CastSpell(plr, SPELL_HORDE_GREEN_FLAG, true);
1213  else
1214  plr->CastSpell(plr, SPELL_ALLIANCE_GREEN_FLAG, true);
1215  }
1216 
1217  plr->DestroyConjuredItems(true);
1218 
1219  Pet* pet = plr->GetPet();
1220  if (pet)
1221  {
1222  if (pet->getPetType() == SUMMON_PET || pet->getPetType() == HUNTER_PET)
1223  {
1224  (plr)->SetTemporaryUnsummonedPetNumber(pet->GetCharmInfo()->GetPetNumber());
1225  (plr)->SetOldPetSpell(pet->GetUInt32Value(UNIT_CREATED_BY_SPELL));
1226  }
1227  (plr)->RemovePet(NULL, PET_SAVE_NOT_IN_SLOT);
1228  }
1229  else
1230  (plr)->SetTemporaryUnsummonedPetNumber(0);
1231 
1232  if (GetStatus() == STATUS_WAIT_JOIN) // not started yet
1233  {
1234  plr->CastSpell(plr, SPELL_ARENA_PREPARATION, true);
1235  plr->ResetAllPowers();
1236  }
1237  }
1238  else
1239  {
1240  if (GetStatus() == STATUS_WAIT_JOIN) // not started yet
1241  plr->CastSpell(plr, SPELL_PREPARATION, true); // reduces all mana cost of spells.
1242  }
1243 
1244  // Log
1245  sLog.outDetail("BATTLEGROUND: Player %s joined the battle.", plr->GetName());
1246 }
const uint32 & GetUInt32Value(uint16 index) const
Definition: Object.h:234
void SendPacketToTeam(uint32 TeamID, WorldPacket *packet, Player *sender=NULL, bool self=true)
void RemoveSpellsCausingAura(AuraType auraType)
Definition: Unit.cpp:697
#define sLog
Log class singleton.
Definition: Log.h:187
BattlegroundPlayerMap m_Players
Definition: Battleground.h:718
uint32 GetBGTeam() const
Definition: Player.h:2304
Definition: Pet.h:28
uint32 GetStatus() const
Definition: Battleground.h:317
CharmInfo * GetCharmInfo()
Definition: Unit.h:1458
void RemoveArenaSpellCooldowns()
Definition: Player.cpp:3317
void DestroyConjuredItems(bool update)
Definition: Player.cpp:10904
bool isArena() const
Definition: Battleground.h:481
Definition: Pet.h:27
HostileRefManager & getHostileRefManager()
Definition: Unit.h:1733
uint32 GetPetNumber() const
Definition: Unit.h:803
void CastSpell(Unit *Victim, uint32 spellId, bool triggered, Item *castItem=NULL, Aura *triggeredByAura=NULL, uint64 originalCaster=0)
Definition: Unit.cpp:1223
void CombatStop(bool cast=false)
Definition: Unit.cpp:7518
void ResetAllPowers()
Definition: Player.cpp:2093
const char * GetName() const
Definition: Object.h:704
ACE_UINT64 uint64
Definition: Define.h:70
void ToggleAFK()
Definition: Player.cpp:1454
void RemoveAllEnchantments(EnchantmentSlot slot, bool arena)
Definition: Player.cpp:11682
void RemoveArenaAuras()
Definition: Unit.cpp:4586
#define sBattlegroundMgr
uint32 GetTeam() const
Definition: Player.h:2063
bool HasFlag(uint16 index, uint32 flag) const
Definition: Object.h:305
ACE_UINT32 uint32
Definition: Define.h:71
Pet * GetPet() const
Definition: Player.cpp:17121
void UpdatePlayersCountByTeam(uint32 Team, bool remove)
Definition: Battleground.h:618
Definition: Pet.h:146
PetType getPetType() const
Definition: Pet.h:155
const uint64 & GetGUID() const
Definition: Object.h:162
void Battleground::AddPlayerToResurrectQueue ( uint64  npc_guid,
uint64  player_guid 
)

Definition at line 1394 of file Battleground.cpp.

References Unit::AddAura(), Unit::CastSpell(), CreateAura(), sObjectMgr, SPELL_WAITING_FOR_RESURRECT, and sSpellStore.

Referenced by WorldSession::HandleAreaSpiritHealerQueueOpcode(), and WorldSession::HandleGossipHelloOpcode().

1395 {
1396  m_ReviveQueue[npc_guid].push_back(player_guid);
1397 
1398  Player* plr = sObjectMgr.GetPlayer(player_guid);
1399  if (!plr)
1400  return;
1401 
1402  plr->CastSpell(plr, SPELL_WAITING_FOR_RESURRECT, true);
1403  SpellEntry const* spellInfo = sSpellStore.LookupEntry(SPELL_WAITING_FOR_RESURRECT);
1404  if (spellInfo)
1405  {
1406  Aura* Aur = CreateAura(spellInfo, 0, NULL, plr);
1407  plr->AddAura(Aur);
1408  }
1409 }
std::map< uint64, std::vector< uint64 > > m_ReviveQueue
Definition: Battleground.h:720
void AddAura(uint32 spellId, Unit *target)
Definition: Unit.cpp:13463
Aura * CreateAura(SpellEntry const *spellproto, uint32 eff, int32 *currentBasePoints, Unit *target, Unit *caster, Item *castItem)
Definition: SpellAuras.cpp:502
#define sObjectMgr
Definition: ObjectMgr.h:1285
DBCStorage< SpellEntry > sSpellStore(SpellEntryfmt)
void CastSpell(Unit *Victim, uint32 spellId, bool triggered, Item *castItem=NULL, Aura *triggeredByAura=NULL, uint64 originalCaster=0)
Definition: Unit.cpp:1223
Definition: Player.h:922
bool Battleground::AddSpiritGuide ( uint32  type,
float  x,
float  y,
float  z,
float  o,
uint32  team 
)

Definition at line 1652 of file Battleground.cpp.

References ALLIANCE, DEAD, Object::GetGUID(), Creature::setDeathState(), Object::SetFloatValue(), Object::SetUInt32Value(), Object::SetUInt64Value(), sLog, SPELL_SPIRIT_HEAL_CHANNEL, UNIT_CHANNEL_SPELL, UNIT_FIELD_AURA, UNIT_FIELD_AURAAPPLICATIONS, UNIT_FIELD_AURAFLAGS, UNIT_FIELD_AURALEVELS, UNIT_FIELD_CHANNEL_OBJECT, and UNIT_MOD_CAST_SPEED.

Referenced by BattlegroundAB::_NodeOccupied(), BattlegroundEY::EventTeamCapturedPoint(), BattlegroundAV::PopulateNode(), BattlegroundWS::SetupBattleground(), BattlegroundEY::SetupBattleground(), and BattlegroundAV::SetupBattleground().

1653 {
1654  uint32 entry = 0;
1655 
1656  if (team == ALLIANCE)
1657  entry = 13116;
1658  else
1659  entry = 13117;
1660 
1661  Creature* pCreature = AddCreature(entry, type, team, x, y, z, o);
1662  if (!pCreature)
1663  {
1664  sLog.outError("Can't create Spirit guide. Battleground not created!");
1665  EndNow();
1666  return false;
1667  }
1668 
1669  pCreature->setDeathState(DEAD);
1670 
1671  pCreature->SetUInt64Value(UNIT_FIELD_CHANNEL_OBJECT, pCreature->GetGUID());
1672  // aura
1674  pCreature->SetUInt32Value(UNIT_FIELD_AURAFLAGS, 0x00000009);
1675  pCreature->SetUInt32Value(UNIT_FIELD_AURALEVELS, 0x0000003C);
1676  pCreature->SetUInt32Value(UNIT_FIELD_AURAAPPLICATIONS, 0x000000FF);
1677  // casting visual effect
1679  // correct cast speed
1680  pCreature->SetFloatValue(UNIT_MOD_CAST_SPEED, 1.0f);
1681 
1682  //pCreature->CastSpell(pCreature, SPELL_SPIRIT_HEAL_CHANNEL, true);
1683 
1684  return true;
1685 }
Definition: Unit.h:440
#define sLog
Log class singleton.
Definition: Log.h:187
void SetUInt32Value(uint16 index, uint32 value)
Definition: Object.cpp:779
Creature * AddCreature(uint32 entry, uint32 type, uint32 teamval, float x, float y, float z, float o, uint32 respawntime=0)
void setDeathState(DeathState s) override
Definition: Creature.cpp:1575
void SetUInt64Value(uint16 index, const uint64 &value)
Definition: Object.cpp:798
void SetFloatValue(uint16 index, float value)
Definition: Object.cpp:859
ACE_UINT32 uint32
Definition: Define.h:71
const uint64 & GetGUID() const
Definition: Object.h:162
void Battleground::AddToBGFreeSlotQueue ( )

Definition at line 1262 of file Battleground.cpp.

References sBattlegroundMgr.

Referenced by BattlegroundMgr::CreateBattleground(), and BattlegroundMgr::CreateNewBattleground().

1263 {
1264  // make sure to add only once
1265  if (!m_InBGFreeSlotQueue)
1266  {
1267  sBattlegroundMgr.BGFreeSlotQueue[m_TypeID].push_front(this);
1268  m_InBGFreeSlotQueue = true;
1269  }
1270 }
uint32 m_TypeID
Definition: Battleground.h:736
bool m_InBGFreeSlotQueue
Definition: Battleground.h:745
#define sBattlegroundMgr
void Battleground::Announce ( )

Definition at line 1898 of file Battleground.cpp.

References CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_ENABLE, CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_ONSTART, CONFIG_MAX_PLAYER_LEVEL, Player::GetMaxLevelForBattlegroundQueueId(), Player::GetMinLevelForBattlegroundQueueId(), LANG_BG_QUEUE_ANNOUNCE_START, sObjectMgr, and sWorld.

1899 {
1900  //send world message
1902  {
1903  uint32 queue_id = 0;
1904 
1905  for (std::map<uint64, BattlegroundPlayer>::iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
1906  if (Player* plr = sObjectMgr.GetPlayer(itr->first))
1907  queue_id = plr->GetBattlegroundQueueIdFromLevel();
1908 
1909  char const* bgName = GetName();
1910 
1911  uint32 q_min_level = Player::GetMinLevelForBattlegroundQueueId(queue_id);
1912  uint32 q_max_level = Player::GetMaxLevelForBattlegroundQueueId(queue_id);
1913 
1914  // replace hardcoded max level by player max level for nice output
1915  if (q_max_level > sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL))
1916  q_max_level = sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL);
1917 
1918  sWorld.SendWorldText(LANG_BG_QUEUE_ANNOUNCE_START, bgName, q_min_level, q_max_level);
1919  }
1920 }
BattlegroundPlayerMap m_Players
Definition: Battleground.h:718
#define sObjectMgr
Definition: ObjectMgr.h:1285
static uint32 GetMinLevelForBattlegroundQueueId(uint32 queue_id)
Definition: Player.cpp:19443
static uint32 GetMaxLevelForBattlegroundQueueId(uint32 queue_id)
Definition: Player.cpp:19454
char const * GetName() const
Definition: Battleground.h:301
#define sWorld
Definition: World.h:860
ACE_UINT32 uint32
Definition: Define.h:71
Definition: Player.h:922
void Battleground::BlockMovement ( Player plr)

Definition at line 983 of file Battleground.cpp.

References Player::SetClientControl().

984 {
985  plr->SetClientControl(plr, 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()
986 }
void SetClientControl(Unit *target, bool allowMove)
Definition: Player.cpp:19995
template<class Do >
void Battleground::BroadcastWorker ( Do &  _do)

Definition at line 112 of file Battleground.cpp.

References ObjectAccessor::FindPlayer(), HIGHGUID_PLAYER, and MAKE_NEW_GUID.

113 {
114  for (std::map<uint64, BattlegroundPlayer>::iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
116  _do(plr);
117 }
BattlegroundPlayerMap m_Players
Definition: Battleground.h:718
#define MAKE_NEW_GUID(l, e, h)
Definition: ObjectGuid.h:80
static Player * FindPlayer(uint64, bool force=false)
Definition: Player.h:922
void Battleground::CastSpellOnTeam ( uint32  SpellID,
uint32  TeamID 
)

Definition at line 563 of file Battleground.cpp.

References Unit::CastSpell(), Player::GetTeam(), GUID_LOPART, sLog, and sObjectMgr.

Referenced by BattlegroundAB::_NodeOccupied(), BattlegroundAV::HandleKillUnit(), and BattlegroundAV::Update().

564 {
565  for (std::map<uint64, BattlegroundPlayer>::iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
566  {
567  if (itr->second.LastOnlineTime)
568  continue;
569 
570  Player* plr = sObjectMgr.GetPlayer(itr->first);
571 
572  if (!plr)
573  {
574  sLog.outError("Battleground: Player (GUID: %u) not found!", GUID_LOPART(itr->first));
575  continue;
576  }
577 
578  uint32 team = itr->second.Team;
579  if (!team) team = plr->GetTeam();
580 
581  if (team == TeamID)
582  plr->CastSpell(plr, SpellID, true);
583  }
584 }
#define GUID_LOPART(x)
Definition: ObjectGuid.h:110
#define sLog
Log class singleton.
Definition: Log.h:187
BattlegroundPlayerMap m_Players
Definition: Battleground.h:718
#define sObjectMgr
Definition: ObjectMgr.h:1285
void CastSpell(Unit *Victim, uint32 spellId, bool triggered, Item *castItem=NULL, Aura *triggeredByAura=NULL, uint64 originalCaster=0)
Definition: Unit.cpp:1223
uint32 GetTeam() const
Definition: Player.h:2063
ACE_UINT32 uint32
Definition: Define.h:71
Definition: Player.h:922
void Battleground::CheckArenaWinConditions ( )
void Battleground::DecreaseInvitedCount ( uint32  team)
inline

Definition at line 462 of file Battleground.h.

References ALLIANCE.

Referenced by BattlegroundQueue::RemovePlayer().

463  {
464  (team == ALLIANCE) ? --m_InvitedAlliance : --m_InvitedHorde;
465  }
uint32 m_InvitedHorde
Definition: Battleground.h:766
uint32 m_InvitedAlliance
Definition: Battleground.h:765
bool Battleground::DelCreature ( uint32  type)

Definition at line 1617 of file Battleground.cpp.

References WorldObject::AddObjectToRemoveList(), Unit::GetCreature(), GUID_LOPART, and sLog.

Referenced by BattlegroundAB::_NodeDeOccupied(), BattlegroundAV::ChangeMineOwner(), BattlegroundAV::DePopulateNode(), BattlegroundAV::EventPlayerDestroyedPoint(), BattlegroundEY::EventTeamCapturedPoint(), BattlegroundAV::PopulateNode(), BattlegroundAB::ResetBGSubclass(), and BattlegroundAV::ResetBGSubclass().

1618 {
1619  if (!m_BgCreatures[type])
1620  return true;
1621 
1622  Creature* cr = GetBgMap()->GetCreature(m_BgCreatures[type]);
1623  if (!cr)
1624  {
1625  sLog.outError("Can't find creature guid: %u", GUID_LOPART(m_BgCreatures[type]));
1626  return false;
1627  }
1628  //@todo only delete creature after not in combat
1629  cr->AddObjectToRemoveList();
1630  m_BgCreatures[type] = 0;
1631  return true;
1632 }
#define GUID_LOPART(x)
Definition: ObjectGuid.h:110
#define sLog
Log class singleton.
Definition: Log.h:187
BGCreatures m_BgCreatures
Definition: Battleground.h:673
BattlegroundMap * GetBgMap()
Definition: Battleground.h:549
Creature * GetCreature(uint64 guid)
Definition: Map.cpp:2630
void AddObjectToRemoveList()
Definition: Object.cpp:1990
bool Battleground::DelObject ( uint32  type)

Definition at line 1634 of file Battleground.cpp.

References GameObject::Delete(), GameObject::GetGameObject(), GUID_LOPART, GameObject::SetRespawnTime(), and sLog.

1635 {
1636  if (!m_BgObjects[type])
1637  return true;
1638 
1639  GameObject* obj = GetBgMap()->GetGameObject(m_BgObjects[type]);
1640  if (!obj)
1641  {
1642  sLog.outError("Can't find gobject guid: %u", GUID_LOPART(m_BgObjects[type]));
1643  return false;
1644  }
1645 
1646  obj->SetRespawnTime(0); // not save respawn time
1647  obj->Delete();
1648  m_BgObjects[type] = 0;
1649  return true;
1650 }
#define GUID_LOPART(x)
Definition: ObjectGuid.h:110
#define sLog
Log class singleton.
Definition: Log.h:187
void SetRespawnTime(int32 respawn)
Definition: GameObject.h:693
BattlegroundMap * GetBgMap()
Definition: Battleground.h:549
BGObjects m_BgObjects
Definition: Battleground.h:672
GameObject * GetGameObject(uint64 guid)
Definition: Map.cpp:2636
void Delete()
Definition: GameObject.cpp:564
void Battleground::DoorClose ( uint32  type)

Definition at line 1484 of file Battleground.cpp.

References GameObject::GetGameObject(), GameObject::GetGoState(), GameObject::getLootState(), GO_ACTIVATED, GO_READY, GO_STATE_READY, RESPAWN_ONE_DAY, GameObject::SetLootState(), sLog, and GameObject::UseDoorOrButton().

Referenced by BattlegroundWS::StartingEventCloseDoors(), BattlegroundAB::StartingEventCloseDoors(), and BattlegroundAV::StartingEventCloseDoors().

1485 {
1486  GameObject* obj = GetBgMap()->GetGameObject(m_BgObjects[type]);
1487  if (obj)
1488  {
1489  //if doors are open, close it
1490  if (obj->getLootState() == GO_ACTIVATED && obj->GetGoState() != GO_STATE_READY)
1491  {
1492  //change state to allow door to be closed
1493  obj->SetLootState(GO_READY);
1495  }
1496  }
1497  else
1498  sLog.outError("Battleground: Door object not found (cannot close doors)");
1499 }
GOState GetGoState() const
Definition: GameObject.h:728
LootState getLootState() const
Definition: GameObject.h:748
#define sLog
Log class singleton.
Definition: Log.h:187
BattlegroundMap * GetBgMap()
Definition: Battleground.h:549
void SetLootState(LootState s, Unit *unit=NULL)
BGObjects m_BgObjects
Definition: Battleground.h:672
void UseDoorOrButton(uint32 time_to_restore=0, bool alternative=false, Unit *user=NULL)
Definition: GameObject.cpp:955
GameObject * GetGameObject(uint64 guid)
Definition: Map.cpp:2636
void Battleground::DoorOpen ( uint32  type)

Definition at line 1501 of file Battleground.cpp.

References GameObject::GetGameObject(), GO_READY, RESPAWN_ONE_DAY, GameObject::SetLootState(), sLog, and GameObject::UseDoorOrButton().

Referenced by BattlegroundRL::StartingEventOpenDoors(), BattlegroundBE::StartingEventOpenDoors(), BattlegroundNA::StartingEventOpenDoors(), BattlegroundWS::StartingEventOpenDoors(), BattlegroundAB::StartingEventOpenDoors(), and BattlegroundAV::StartingEventOpenDoors().

1502 {
1503  GameObject* obj = GetBgMap()->GetGameObject(m_BgObjects[type]);
1504  if (obj)
1505  {
1506  //change state to be sure they will be opened
1507  obj->SetLootState(GO_READY);
1509  }
1510  else
1511  sLog.outError("Battleground: Door object not found! - doors will be closed.");
1512 }
#define sLog
Log class singleton.
Definition: Log.h:187
BattlegroundMap * GetBgMap()
Definition: Battleground.h:549
void SetLootState(LootState s, Unit *unit=NULL)
BGObjects m_BgObjects
Definition: Battleground.h:672
void UseDoorOrButton(uint32 time_to_restore=0, bool alternative=false, Unit *user=NULL)
Definition: GameObject.cpp:955
GameObject * GetGameObject(uint64 guid)
Definition: Map.cpp:2636
void Battleground::EndBattleground ( uint32  winner)

Definition at line 675 of file Battleground.cpp.

References ALLIANCE, BG_TEAM_ALLIANCE, BG_TEAM_HORDE, CHAT_MSG_BG_SYSTEM_NEUTRAL, Unit::CombatStopWithPets(), CONFIG_ARENA_LOG_EXTENDED_INFO, CONFIG_BATTLEGROUND_PREMATURE_REWARD, Player::GetBattlegroundQueueIndex(), ArenaTeam::GetId(), Unit::GetMaxHealth(), Unit::GetMaxPower(), Player::GetSession(), ArenaTeam::GetStats(), Player::GetTeam(), GUID_LOPART, Unit::HasAuraType(), HORDE, Unit::IsAlive(), ITEM_LOSER_COUNT, ITEM_WINNER_COUNT, LANG_ARENA_GOLD_WINS, LANG_ARENA_GREEN_WINS, LANG_BG_A_WINS, LANG_BG_H_WINS, ArenaTeam::LostAgainst(), ArenaTeam::MemberLost(), ArenaTeam::MemberWon(), ArenaTeam::NotifyStatsChanged(), ArenaTeam::OfflineMemberLost(), POWER_MANA, ArenaTeamStats::rating, Unit::RemoveSpellsCausingAura(), Player::ResurrectPlayer(), ArenaTeam::SaveToDB(), sBattlegroundMgr, SCORE_BONUS_HONOR, WorldSession::SendPacket(), Unit::SetHealth(), Unit::SetPower(), sLog, sObjectMgr, SOUND_ALLIANCE_WINS, SOUND_HORDE_WINS, Player::SpawnCorpseBones(), SPELL_AURA_MOD_SHAPESHIFT, SPELL_AURA_SPIRIT_OF_REDEMPTION, STATUS_IN_PROGRESS, STATUS_WAIT_LEAVE, sWorld, TIME_TO_AUTOREMOVE, UI64FMTD, WINNER_ALLIANCE, WINNER_HORDE, and ArenaTeam::WonAgainst().

Referenced by BattlegroundWS::EndBattleground(), BattlegroundAV::EndBattleground(), BattlegroundAB::Update(), and BattlegroundEY::UpdateTeamScore().

676 {
678  uint32 almost_winning_team = HORDE;
679  ArenaTeam* winner_arena_team = NULL;
680  ArenaTeam* loser_arena_team = NULL;
681  uint32 loser_rating = 0;
682  uint32 winner_rating = 0;
683  WorldPacket data;
684  int32 winmsg_id = 0;
685 
686  if (winner == ALLIANCE)
687  {
689 
690  PlaySoundToAll(SOUND_ALLIANCE_WINS); // alliance wins sound
691 
693  }
694  else if (winner == HORDE)
695  {
697 
698  PlaySoundToAll(SOUND_HORDE_WINS); // horde wins sound
699 
701  }
702  else
703  SetWinner(3);
704 
706  m_EndTime = 0;
707 
708  // arena rating calculation
709  if (isArena() && isRated())
710  {
711  if (winner == ALLIANCE)
712  {
713  winner_arena_team = sObjectMgr.GetArenaTeamById(GetArenaTeamIdForTeam(ALLIANCE));
714  loser_arena_team = sObjectMgr.GetArenaTeamById(GetArenaTeamIdForTeam(HORDE));
715  }
716  else if (winner == HORDE)
717  {
718  winner_arena_team = sObjectMgr.GetArenaTeamById(GetArenaTeamIdForTeam(HORDE));
719  loser_arena_team = sObjectMgr.GetArenaTeamById(GetArenaTeamIdForTeam(ALLIANCE));
720  }
721  if (winner_arena_team && loser_arena_team)
722  {
723  loser_rating = loser_arena_team->GetStats().rating;
724  winner_rating = winner_arena_team->GetStats().rating;
725  int32 winner_change = winner_arena_team->WonAgainst(loser_rating);
726  int32 loser_change = loser_arena_team->LostAgainst(winner_rating);
727  sLog.outDebug("--- Winner rating: %u, Loser rating: %u, Winner change: %u, Losser change: %u ---", winner_rating, loser_rating, winner_change, loser_change);
728  if (winner == ALLIANCE)
729  {
731  SetArenaTeamRatingChangeForTeam(HORDE, loser_change);
732  }
733  else
734  {
735  SetArenaTeamRatingChangeForTeam(HORDE, winner_change);
737  }
738  sLog.outArena("Arena match Type: %u for Team1Id: %u - Team2Id: %u ended. WinnerTeamId: %u. Winner rating: %u, Loser rating: %u. RatingChange: %i.", m_ArenaType, m_ArenaTeamIds[BG_TEAM_ALLIANCE], m_ArenaTeamIds[BG_TEAM_HORDE], winner_arena_team->GetId(), winner_rating, loser_rating, winner_change);
739  if (sWorld.getConfig(CONFIG_ARENA_LOG_EXTENDED_INFO))
740  for (Battleground::BattlegroundScoreMap::const_iterator itr = GetPlayerScoresBegin(); itr != GetPlayerScoresEnd(); ++itr)
741  if (Player* player = sObjectMgr.GetPlayer(itr->first))
742  sLog.outArena("Statistics for %s (GUID: " UI64FMTD ", Team: %d, IP: %s): %u damage, %u healing, %u killing blows", player->GetName(), itr->first, player->GetArenaTeamId(m_ArenaType == 5 ? 2 : m_ArenaType == 3), player->GetSession()->GetRemoteAddress().c_str(), itr->second->DamageDone, itr->second->HealingDone, itr->second->KillingBlows);
743  }
744  else
745  {
748  }
749  }
750 
751  if (!isArena())
752  {
753 
755  almost_winning_team = 0; //no real winner
757  almost_winning_team = ALLIANCE;
758 
759  }
760 
761  for (std::map<uint64, BattlegroundPlayer>::iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
762  {
763  Player* plr = sObjectMgr.GetPlayer(itr->first);
764  uint32 team = itr->second.Team;
765 
766  if (!plr)
767  {
768  //if rated arena match - make member lost!
769  if (isArena() && isRated() && winner_arena_team && loser_arena_team)
770  {
771  if (team == winner)
772  winner_arena_team->OfflineMemberLost(itr->first, loser_rating);
773  else
774  loser_arena_team->OfflineMemberLost(itr->first, winner_rating);
775  }
776  sLog.outError("Battleground: Player (GUID: %u) not found!", GUID_LOPART(itr->first));
777  continue;
778  }
779 
780  // should remove spirit of redemption
783 
784  if (!plr->IsAlive())
785  {
786  plr->ResurrectPlayer(1.0f);
787  plr->SpawnCorpseBones();
788  }
789 
790  //this line is obsolete - team is set ALWAYS
791  //if (!team) team = plr->GetTeam();
792 
793  // per player calculation
794  if (isArena() && isRated() && winner_arena_team && loser_arena_team)
795  {
796  if (team == winner)
797  winner_arena_team->MemberWon(plr, loser_rating);
798  else
799  loser_arena_team->MemberLost(plr, winner_rating);
800  }
801 
802  if (team == winner)
803  {
806  RewardQuest(plr);
807  }
808  else if (winner != 0)
810  else if (winner == 0)
811  {
813  {
814  if (almost_winning_team == team) // player's team had more points
816  else
817  RewardMark(plr, ITEM_LOSER_COUNT); // if scores were the same, each team gets 1 mark.
818  }
819  }
820 
821  plr->SetHealth(plr->GetMaxHealth());
823  plr->CombatStopWithPets(true);
824 
825  BlockMovement(plr);
826 
827  sBattlegroundMgr.BuildPvpLogDataPacket(&data, this);
828  plr->GetSession()->SendPacket(&data);
829 
830  uint32 bgQueueTypeId = sBattlegroundMgr.BGQueueTypeId(GetTypeID(), GetArenaType());
831  sBattlegroundMgr.BuildBattlegroundStatusPacket(&data, this, plr->GetTeam(), plr->GetBattlegroundQueueIndex(bgQueueTypeId), STATUS_IN_PROGRESS, TIME_TO_AUTOREMOVE, GetStartTime());
832  plr->GetSession()->SendPacket(&data);
833  }
834 
835  if (isArena() && isRated() && winner_arena_team && loser_arena_team)
836  {
837  // update arena points only after increasing the player's match count!
838  //obsolete: winner_arena_team->UpdateArenaPointsHelper();
839  //obsolete: loser_arena_team->UpdateArenaPointsHelper();
840  // save the stat changes
841  winner_arena_team->SaveToDB();
842  loser_arena_team->SaveToDB();
843  // send updated arena team stats to players
844  // this way all arena team members will get notified, not only the ones who participated in this match
845  winner_arena_team->NotifyStatsChanged();
846  loser_arena_team->NotifyStatsChanged();
847  }
848 
849  // inform invited players about the removal
850  sBattlegroundMgr.m_BattlegroundQueues[sBattlegroundMgr.BGQueueTypeId(GetTypeID(), GetArenaType())].BGEndedRemoveInvites(this);
851 
852  if (winmsg_id)
854 }
void OfflineMemberLost(uint64 guid, uint32 againstRating)
Definition: ArenaTeam.cpp:627
#define GUID_LOPART(x)
Definition: ObjectGuid.h:110
uint32 GetMaxHealth() const
Definition: Unit.h:1075
uint32 m_EndTime
Definition: Battleground.h:741
void RewardQuest(Player *plr)
void MemberLost(Player *plr, uint32 againstRating)
Definition: ArenaTeam.cpp:605
uint32 rating
Definition: ArenaTeam.h:103
void RemoveSpellsCausingAura(AuraType auraType)
Definition: Unit.cpp:697
void CombatStopWithPets(bool cast=false)
Definition: Unit.cpp:7535
#define sLog
Log class singleton.
Definition: Log.h:187
BattlegroundPlayerMap m_Players
Definition: Battleground.h:718
ACE_INT32 int32
Definition: Define.h:67
int32 LostAgainst(uint32 againstRating)
Definition: ArenaTeam.cpp:591
void SpawnCorpseBones()
Definition: Player.cpp:4322
#define sObjectMgr
Definition: ObjectMgr.h:1285
void SendPacket(WorldPacket const *packet)
uint8 GetTeamIndexByTeamId(uint32 Team) const
Definition: Battleground.h:609
const ArenaTeamStats & GetStats() const
Definition: ArenaTeam.h:145
bool isRated() const
Definition: Battleground.h:489
bool isArena() const
Definition: Battleground.h:481
BattlegroundScoreMap::const_iterator GetPlayerScoresBegin() const
Definition: Battleground.h:509
void SetArenaTeamRatingChangeForTeam(uint32 Team, int32 RatingChange)
Definition: Battleground.h:635
uint32 GetMaxPower(Powers power) const
Definition: Unit.h:1097
#define UI64FMTD
Definition: Common.h:149
uint8 GetArenaType() const
Definition: Battleground.h:364
void PlaySoundToAll(uint32 SoundID)
void NotifyStatsChanged()
Definition: ArenaTeam.cpp:387
uint32 GetBattlegroundQueueIndex(uint32 bgQueueType) const
Definition: Player.h:2222
uint8 m_ArenaType
Definition: Battleground.h:744
uint32 GetId() const
Definition: ArenaTeam.h:124
bool IsAlive() const
Definition: Unit.h:1336
uint32 GetArenaTeamIdForTeam(uint32 Team) const
Definition: Battleground.h:631
virtual void UpdatePlayerScore(Player *Source, uint32 type, uint32 value)
void ResurrectPlayer(float restore_percent, bool applySickness=false)
Definition: Player.cpp:4151
bool isBattleground() const
Definition: Battleground.h:485
void RemoveFromBGFreeSlotQueue()
BattlegroundScoreMap::const_iterator GetPlayerScoresEnd() const
Definition: Battleground.h:513
void SaveToDB()
Definition: ArenaTeam.cpp:702
uint32 GetTypeID() const
Definition: Battleground.h:305
void RewardMark(Player *plr, uint32 count)
void SetWinner(uint8 winner)
Definition: Battleground.h:432
uint32 GetStartTime() const
Definition: Battleground.h:321
void MemberWon(Player *plr, uint32 againstRating)
Definition: ArenaTeam.cpp:649
#define sBattlegroundMgr
uint32 GetTeam() const
Definition: Player.h:2063
void SetPower(Powers power, uint32 val)
Definition: Unit.cpp:10997
void SetStatus(uint32 Status)
Definition: Battleground.h:391
bool HasAuraType(AuraType auraType) const
Definition: Unit.cpp:832
WorldSession * GetSession() const
Definition: Player.h:1944
#define sWorld
Definition: World.h:860
uint32 m_score[2]
Definition: Battleground.h:731
void BlockMovement(Player *plr)
void SetHealth(uint32 val)
Definition: Unit.cpp:10905
ACE_UINT32 uint32
Definition: Define.h:71
uint32 m_ArenaTeamIds[BG_TEAMS_COUNT]
Definition: Battleground.h:775
int32 WonAgainst(uint32 againstRating)
Definition: ArenaTeam.cpp:575
Definition: Player.h:922
void SendMessageToAll(int32 entry, ChatMsg type, Player const *source=NULL)
void Battleground::EndNow ( )
protected

Definition at line 1713 of file Battleground.cpp.

References sBattlegroundMgr, STATUS_WAIT_LEAVE, and TIME_TO_AUTOREMOVE.

1714 {
1718  // inform invited players about the removal
1719  sBattlegroundMgr.m_BattlegroundQueues[sBattlegroundMgr.BGQueueTypeId(GetTypeID(), GetArenaType())].BGEndedRemoveInvites(this);
1720 }
void SetEndTime(uint32 Time)
Definition: Battleground.h:399
uint8 GetArenaType() const
Definition: Battleground.h:364
void RemoveFromBGFreeSlotQueue()
uint32 GetTypeID() const
Definition: Battleground.h:305
#define sBattlegroundMgr
void SetStatus(uint32 Status)
Definition: Battleground.h:391
virtual void Battleground::EventPlayerCapturedFlag ( Player )
inlinevirtual

Reimplemented in BattlegroundWS.

Definition at line 655 of file Battleground.h.

655 {}
virtual void Battleground::EventPlayerClickedOnFlag ( Player ,
GameObject  
)
inlinevirtual

Reimplemented in BattlegroundAV, BattlegroundEY, BattlegroundAB, and BattlegroundWS.

Definition at line 654 of file Battleground.h.

Referenced by GameObject::Use().

654 {}
virtual void Battleground::EventPlayerDroppedFlag ( Player )
inlinevirtual

Reimplemented in BattlegroundEY, and BattlegroundWS.

Definition at line 653 of file Battleground.h.

653 {}
void Battleground::EventPlayerLoggedOut ( Player player)

Definition at line 1249 of file Battleground.cpp.

References Player::LeaveBattleground(), and STATUS_IN_PROGRESS.

1250 {
1251  if (GetStatus() == STATUS_IN_PROGRESS)
1252  {
1253  if (isBattleground())
1254  EventPlayerDroppedFlag(player);
1255  }
1256 
1257  if (isArena())
1258  player->LeaveBattleground();
1259 }
uint32 GetStatus() const
Definition: Battleground.h:317
bool isArena() const
Definition: Battleground.h:481
void LeaveBattleground(bool teleportToEntryPoint=true)
Definition: Player.cpp:18624
bool isBattleground() const
Definition: Battleground.h:485
virtual void EventPlayerDroppedFlag(Player *)
Definition: Battleground.h:653
virtual void Battleground::FillInitialWorldStates ( WorldPacket )
inlinevirtual
uint32 Battleground::GetAlivePlayersCountByTeam ( uint32  Team) const

Definition at line 1849 of file Battleground.cpp.

References FORM_SPIRITOFREDEMPTION, Object::HasByteFlag(), Unit::IsAlive(), sObjectMgr, and UNIT_FIELD_BYTES_2.

Referenced by BattlegroundRL::AddPlayer(), BattlegroundBE::AddPlayer(), BattlegroundNA::AddPlayer(), BattlegroundRL::FillInitialWorldStates(), BattlegroundBE::FillInitialWorldStates(), BattlegroundNA::FillInitialWorldStates(), BattlegroundRL::HandleKillPlayer(), BattlegroundBE::HandleKillPlayer(), BattlegroundNA::HandleKillPlayer(), BattlegroundRL::RemovePlayer(), BattlegroundBE::RemovePlayer(), and BattlegroundNA::RemovePlayer().

1850 {
1851  int count = 0;
1852  for (std::map<uint64, BattlegroundPlayer>::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
1853  {
1854  if (itr->second.Team == Team)
1855  {
1856  Player* pl = sObjectMgr.GetPlayer(itr->first);
1857  if (pl && pl->IsAlive() && !pl->HasByteFlag(UNIT_FIELD_BYTES_2, 3, FORM_SPIRITOFREDEMPTION))
1858  ++count;
1859  }
1860  }
1861  return count;
1862 }
bool HasByteFlag(uint16 index, uint8 offset, uint8 flag) const
Definition: Object.h:322
BattlegroundPlayerMap m_Players
Definition: Battleground.h:718
#define sObjectMgr
Definition: ObjectMgr.h:1285
Team
bool IsAlive() const
Definition: Unit.h:1336
Definition: Player.h:922
uint32 Battleground::GetArenaTeamIdForTeam ( uint32  Team) const
inline

Definition at line 631 of file Battleground.h.

632  {
634  }
uint8 GetTeamIndexByTeamId(uint32 Team) const
Definition: Battleground.h:609
Team
uint32 m_ArenaTeamIds[BG_TEAMS_COUNT]
Definition: Battleground.h:775
int32 Battleground::GetArenaTeamRatingChangeForTeam ( uint32  Team) const
inline

Definition at line 639 of file Battleground.h.

640  {
642  }
int32 m_ArenaTeamRatingChanges[BG_TEAMS_COUNT]
Definition: Battleground.h:777
uint8 GetTeamIndexByTeamId(uint32 Team) const
Definition: Battleground.h:609
Team
uint32 Battleground::GetBattlemasterEntry ( ) const

Definition at line 856 of file Battleground.cpp.

References BATTLEGROUND_AB, BATTLEGROUND_AV, BATTLEGROUND_EY, BATTLEGROUND_NA, and BATTLEGROUND_WS.

857 {
858  switch (GetTypeID())
859  {
860  case BATTLEGROUND_AV:
861  return 15972;
862  case BATTLEGROUND_WS:
863  return 14623;
864  case BATTLEGROUND_AB:
865  return 14879;
866  case BATTLEGROUND_EY:
867  return 22516;
868  case BATTLEGROUND_NA:
869  return 20200;
870  default:
871  return 0;
872  }
873 }
uint32 GetTypeID() const
Definition: Battleground.h:305
Creature * Battleground::GetBGCreature ( uint32  type)

Definition at line 1522 of file Battleground.cpp.

References Unit::GetCreature(), and sLog.

Referenced by BattlegroundAV::ChangeMineOwner(), BattlegroundAV::EventPlayerAssaultsPoint(), BattlegroundAV::EventPlayerDefendsPoint(), BattlegroundAV::EventPlayerDestroyedPoint(), BattlegroundAV::HandleKillUnit(), and BattlegroundAV::Update().

1523 {
1524  Creature* creature = GetBgMap()->GetCreature(m_BgCreatures[type]);
1525  if (!creature)
1526  sLog.outError("couldn't get creature %i", type);
1527  return creature;
1528 }
#define sLog
Log class singleton.
Definition: Log.h:187
BGCreatures m_BgCreatures
Definition: Battleground.h:673
BattlegroundMap * GetBgMap()
Definition: Battleground.h:549
Creature * GetCreature(uint64 guid)
Definition: Map.cpp:2630
BattlegroundMap* Battleground::GetBgMap ( )
inline

Definition at line 549 of file Battleground.h.

References ASSERT.

Referenced by BattlegroundAB::EventPlayerClickedOnFlag(), and BattlegroundWS::RespawnFlagAfterDrop().

550  {
551  ASSERT(m_Map);
552  return m_Map;
553  }
BattlegroundMap * m_Map
Definition: Battleground.h:789
#define ASSERT
Definition: Errors.h:29
GameObject * Battleground::GetBGObject ( uint32  type)

Definition at line 1514 of file Battleground.cpp.

References GameObject::GetGameObject(), and sLog.

1515 {
1516  GameObject* obj = GetBgMap()->GetGameObject(m_BgObjects[type]);
1517  if (!obj)
1518  sLog.outError("couldn't get gameobject %i", type);
1519  return obj;
1520 }
#define sLog
Log class singleton.
Definition: Log.h:187
BattlegroundMap * GetBgMap()
Definition: Battleground.h:549
BGObjects m_BgObjects
Definition: Battleground.h:672
GameObject * GetGameObject(uint64 guid)
Definition: Map.cpp:2636
Group* Battleground::GetBgRaid ( uint32  TeamID) const
inline

Definition at line 595 of file Battleground.h.

References ALLIANCE, BG_TEAM_ALLIANCE, and BG_TEAM_HORDE.

Referenced by Group::~Group().

596  {
598  }
Group * m_BgRaids[BG_TEAMS_COUNT]
Definition: Battleground.h:769
WorldSafeLocsEntry const * Battleground::GetClosestGraveYard ( Player player)
virtual

Reimplemented in BattlegroundAV, BattlegroundEY, BattlegroundAB, and BattlegroundWS.

Definition at line 1893 of file Battleground.cpp.

References WorldLocation::GetMapId(), Position::GetPositionX(), Position::GetPositionY(), Position::GetPositionZ(), Player::GetTeam(), and sObjectMgr.

1894 {
1895  return sObjectMgr.GetClosestGraveYard(player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetMapId(), player->GetTeam());
1896 }
#define sObjectMgr
Definition: ObjectMgr.h:1285
float GetPositionY() const
Definition: Position.h:98
float GetPositionZ() const
Definition: Position.h:99
uint32 GetMapId() const
Definition: Object.h:591
uint32 GetTeam() const
Definition: Player.h:2063
float GetPositionX() const
Definition: Position.h:97
uint32 Battleground::GetEndTime ( ) const
inline

Definition at line 325 of file Battleground.h.

326  {
327  return m_EndTime;
328  }
uint32 m_EndTime
Definition: Battleground.h:741
uint32 Battleground::GetFreeSlotsForTeam ( uint32  Team) const

Definition at line 1290 of file Battleground.cpp.

References ALLIANCE, HORDE, STATUS_IN_PROGRESS, and STATUS_WAIT_JOIN.

Referenced by BattlegroundQueue::Update().

1291 {
1292  //if BG is starting ... invite anyone
1293  if (GetStatus() == STATUS_WAIT_JOIN)
1295  //if BG is already started .. do not allow to join too much players of one faction
1296  uint32 otherTeam;
1297  uint32 otherIn;
1298  if (Team == ALLIANCE)
1299  {
1300  otherTeam = GetInvitedCount(HORDE);
1301  otherIn = GetPlayersCountByTeam(HORDE);
1302  }
1303  else
1304  {
1305  otherTeam = GetInvitedCount(ALLIANCE);
1306  otherIn = GetPlayersCountByTeam(ALLIANCE);
1307  }
1308  if (GetStatus() == STATUS_IN_PROGRESS)
1309  {
1310  // difference based on ppl invited (not necessarily entered battle)
1311  // default: allow 0
1312  uint32 diff = 0;
1313  // allow join one person if the sides are equal (to fill up bg to minplayersperteam)
1314  if (otherTeam == GetInvitedCount(Team))
1315  diff = 1;
1316  // allow join more ppl if the other side has more players
1317  else if (otherTeam > GetInvitedCount(Team))
1318  diff = otherTeam - GetInvitedCount(Team);
1319 
1320  // difference based on max players per team (don't allow inviting more)
1322 
1323  // difference based on players who already entered
1324  // default: allow 0
1325  uint32 diff3 = 0;
1326  // allow join one person if the sides are equal (to fill up bg minplayersperteam)
1327  if (otherIn == GetPlayersCountByTeam(Team))
1328  diff3 = 1;
1329  // allow join more ppl if the other side has more players
1330  else if (otherIn > GetPlayersCountByTeam(Team))
1331  diff3 = otherIn - GetPlayersCountByTeam(Team);
1332  // or other side has less than minPlayersPerTeam
1333  else if (GetInvitedCount(Team) <= GetMinPlayersPerTeam())
1334  diff3 = GetMinPlayersPerTeam() - GetInvitedCount(Team) + 1;
1335 
1336  // return the minimum of the 3 differences
1337 
1338  // min of diff and diff 2
1339  diff = diff < diff2 ? diff : diff2;
1340 
1341  // min of diff, diff2 and diff3
1342  return diff < diff3 ? diff : diff3 ;
1343  }
1344 
1345  return 0;
1346 }
uint32 GetMinPlayersPerTeam() const
Definition: Battleground.h:355
uint32 GetStatus() const
Definition: Battleground.h:317
uint32 GetInvitedCount(uint32 team) const
Definition: Battleground.h:470
Team
uint32 GetMaxPlayersPerTeam() const
Definition: Battleground.h:351
ACE_UINT32 uint32
Definition: Define.h:71
uint32 GetPlayersCountByTeam(uint32 Team) const
Definition: Battleground.h:613
uint32 Battleground::GetInvitedCount ( uint32  team) const
inline

Definition at line 470 of file Battleground.h.

References ALLIANCE.

Referenced by BattlegroundQueue::RemovePlayer().

471  {
472  if (team == ALLIANCE)
473  return m_InvitedAlliance;
474  else
475  return m_InvitedHorde;
476  }
uint32 m_InvitedHorde
Definition: Battleground.h:766
uint32 m_InvitedAlliance
Definition: Battleground.h:765
uint32 Battleground::GetLastResurrectTime ( ) const
inline

Definition at line 329 of file Battleground.h.

Referenced by BattlegroundMgr::SendAreaSpiritHealerQueryOpcode().

330  {
331  return m_LastResurrectTime;
332  }
uint32 m_LastResurrectTime
Definition: Battleground.h:742
uint32 Battleground::GetMapId ( ) const
inline
uint32 Battleground::GetMaxLevel ( ) const
inline

Definition at line 346 of file Battleground.h.

Referenced by Player::GetBGAccessByLevel().

347  {
348  return m_LevelMax;
349  }
uint32 m_LevelMax
Definition: Battleground.h:781
uint32 Battleground::GetMaxPlayers ( ) const
inline

Definition at line 333 of file Battleground.h.

Referenced by BattlegroundMgr::BuildPvpLogDataPacket().

334  {
335  return m_MaxPlayers;
336  }
uint32 m_MaxPlayers
Definition: Battleground.h:783
uint32 Battleground::GetMaxPlayersPerTeam ( ) const
inline
uint32 Battleground::GetMinLevel ( ) const
inline

Definition at line 342 of file Battleground.h.

Referenced by Player::GetBGAccessByLevel().

343  {
344  return m_LevelMin;
345  }
uint32 m_LevelMin
Definition: Battleground.h:780
uint32 Battleground::GetMinPlayers ( ) const
inline

Definition at line 337 of file Battleground.h.

338  {
339  return m_MinPlayers;
340  }
uint32 m_MinPlayers
Definition: Battleground.h:785
uint32 Battleground::GetMinPlayersPerTeam ( ) const
inline

Definition at line 355 of file Battleground.h.

Referenced by BattlegroundQueue::AddPlayer(), and BattlegroundQueue::Update().

356  {
357  return m_MinPlayersPerTeam;
358  }
uint32 m_MinPlayersPerTeam
Definition: Battleground.h:784
char const* Battleground::GetName ( ) const
inline

Definition at line 301 of file Battleground.h.

Referenced by BattlegroundQueue::AddPlayer().

302  {
303  return m_Name;
304  }
char const * m_Name
Definition: Battleground.h:756
int32 Battleground::GetObjectType ( uint64  guid)

Definition at line 1872 of file Battleground.cpp.

References sLog.

Referenced by BattlegroundAV::EventPlayerClickedOnFlag().

1873 {
1874  for (uint32 i = 0; i < m_BgObjects.size(); ++i)
1875  if (m_BgObjects[i] == guid)
1876  return i;
1877  sLog.outError("Battleground: cheating? a player used a gameobject which isnt supposed to be a usable object!");
1878  return -1;
1879 }
#define sLog
Log class singleton.
Definition: Log.h:187
BGObjects m_BgObjects
Definition: Battleground.h:672
ACE_UINT32 uint32
Definition: Define.h:71
const char * Battleground::GetOregonString ( int32  entry)

Definition at line 1723 of file Battleground.cpp.

References sObjectMgr.

Referenced by BattlegroundAV::ChangeMineOwner(), BattlegroundAV::EventPlayerAssaultsPoint(), BattlegroundAV::EventPlayerDefendsPoint(), BattlegroundAV::EventPlayerDestroyedPoint(), BattlegroundAV::GetNodeName(), and BattlegroundAV::HandleKillUnit().

1724 {
1725  // FIXME: now we have different DBC locales and need localized message for each target client
1726  return sObjectMgr.GetOregonStringForDBCLocale(entry);
1727 }
#define sObjectMgr
Definition: ObjectMgr.h:1285
uint32 Battleground::GetOtherTeam ( uint32  teamId)

Definition at line 1812 of file Battleground.cpp.

References ALLIANCE, and HORDE.

1813 {
1814  return (teamId) ? ((teamId == ALLIANCE) ? HORDE : ALLIANCE) : 0;
1815 }
BattlegroundPlayerMap const& Battleground::GetPlayers ( ) const
inline

Definition at line 495 of file Battleground.h.

496  {
497  return m_Players;
498  }
BattlegroundPlayerMap m_Players
Definition: Battleground.h:718
BattlegroundScoreMap::const_iterator Battleground::GetPlayerScoresBegin ( ) const
inline

Definition at line 509 of file Battleground.h.

Referenced by BattlegroundMgr::BuildPvpLogDataPacket().

510  {
511  return m_PlayerScores.begin();
512  }
BattlegroundScoreMap m_PlayerScores
Definition: Battleground.h:713
BattlegroundScoreMap::const_iterator Battleground::GetPlayerScoresEnd ( ) const
inline

Definition at line 513 of file Battleground.h.

Referenced by BattlegroundMgr::BuildPvpLogDataPacket().

514  {
515  return m_PlayerScores.end();
516  }
BattlegroundScoreMap m_PlayerScores
Definition: Battleground.h:713
uint32 Battleground::GetPlayerScoresSize ( ) const
inline

Definition at line 517 of file Battleground.h.

Referenced by BattlegroundMgr::BuildPvpLogDataPacket().

518  {
519  return m_PlayerScores.size();
520  }
BattlegroundScoreMap m_PlayerScores
Definition: Battleground.h:713
uint32 Battleground::GetPlayersCountByTeam ( uint32  Team) const
inline

Definition at line 613 of file Battleground.h.

614  {
616  }
uint8 GetTeamIndexByTeamId(uint32 Team) const
Definition: Battleground.h:609
Team
uint32 m_PlayersCount[BG_TEAMS_COUNT]
Definition: Battleground.h:772
uint32 Battleground::GetPlayersSize ( ) const
inline

Definition at line 499 of file Battleground.h.

Referenced by BattlegroundQueue::RemovePlayer().

500  {
501  return m_Players.size();
502  }
BattlegroundPlayerMap m_Players
Definition: Battleground.h:718
uint32 Battleground::GetPlayerTeam ( uint64  guid)

Definition at line 1804 of file Battleground.cpp.

Referenced by BattlegroundMgr::BuildPvpLogDataPacket().

1805 {
1806  std::map<uint64, BattlegroundPlayer>::const_iterator itr = m_Players.find(guid);
1807  if (itr != m_Players.end())
1808  return itr->second.Team;
1809  return 0;
1810 }
BattlegroundPlayerMap m_Players
Definition: Battleground.h:718
uint32 Battleground::GetQueueType ( ) const
inline

Definition at line 309 of file Battleground.h.

Referenced by BattlegroundQueue::BGEndedRemoveInvites(), and BGQueueRemoveEvent::Execute().

310  {
311  return m_Queue_type;
312  }
uint32 m_Queue_type
Definition: Battleground.h:743
uint32 Battleground::GetRemovedPlayersSize ( ) const
inline

Definition at line 503 of file Battleground.h.

504  {
505  return m_RemovedPlayers.size();
506  }
std::map< uint64, uint8 > m_RemovedPlayers
Definition: Battleground.h:760
uint32 Battleground::GetReviveQueueSize ( ) const
inline

Definition at line 522 of file Battleground.h.

523  {
524  return m_ReviveQueue.size();
525  }
std::map< uint64, std::vector< uint64 > > m_ReviveQueue
Definition: Battleground.h:720
int Battleground::GetStartDelayTime ( ) const
inline

Definition at line 360 of file Battleground.h.

361  {
362  return m_StartDelayTime;
363  }
int32 m_StartDelayTime
Definition: Battleground.h:752
float Battleground::GetStartMaxDist ( ) const
inline

Definition at line 460 of file Battleground.h.

460 { return m_StartMaxDist; }
float m_StartMaxDist
Definition: Battleground.h:794
uint32 Battleground::GetStartTime ( ) const
inline
uint32 Battleground::GetStatus ( ) const
inline

Definition at line 317 of file Battleground.h.

Referenced by Spell::EffectSendEvent(), Spell::EffectSummonObjectWild(), BattlegroundAV::EventPlayerAssaultsPoint(), BattlegroundWS::EventPlayerCapturedFlag(), BattlegroundEY::EventPlayerCapturedFlag(), BattlegroundWS::EventPlayerClickedOnFlag(), BattlegroundAB::EventPlayerClickedOnFlag(), BattlegroundEY::EventPlayerClickedOnFlag(), BattlegroundAV::EventPlayerClickedOnFlag(), BattlegroundAV::EventPlayerDefendsPoint(), BattlegroundWS::EventPlayerDroppedFlag(), BattlegroundEY::EventPlayerDroppedFlag(), BattlegroundEY::EventTeamCapturedPoint(), BattlegroundEY::EventTeamLostPoint(), BattlegroundAV::FillInitialWorldStates(), BattlegroundWS::GetClosestGraveYard(), BattlegroundRL::HandleAreaTrigger(), BattlegroundBE::HandleAreaTrigger(), BattlegroundNA::HandleAreaTrigger(), BattlegroundWS::HandleAreaTrigger(), BattlegroundAB::HandleAreaTrigger(), BattlegroundEY::HandleAreaTrigger(), BattlegroundAV::HandleAreaTrigger(), WorldSession::HandleBattlefieldStatusOpcode(), BattlegroundRL::HandleKillPlayer(), BattlegroundBE::HandleKillPlayer(), BattlegroundNA::HandleKillPlayer(), BattlegroundWS::HandleKillPlayer(), BattlegroundEY::HandleKillPlayer(), BattlegroundAV::HandleKillPlayer(), BattlegroundAV::HandleKillUnit(), BattlegroundAV::HandleQuestComplete(), Player::LoadFromDB(), BattlegroundRL::RemovePlayer(), BattlegroundBE::RemovePlayer(), BattlegroundNA::RemovePlayer(), Player::ReportedAfkBy(), BattlegroundWS::RespawnFlagAfterDrop(), BattlegroundWS::Update(), BattlegroundAB::Update(), BattlegroundEY::Update(), and BattlegroundAV::Update().

318  {
319  return m_Status;
320  }
uint32 m_Status
Definition: Battleground.h:738
void Battleground::GetTeamStartLoc ( uint32  TeamID,
float &  X,
float &  Y,
float &  Z,
float &  O 
) const
inline

Definition at line 556 of file Battleground.h.

Referenced by BattlegroundMgr::SendToBattleground().

557  {
558  uint8 idx = GetTeamIndexByTeamId(TeamID);
559  X = m_TeamStartLocX[idx];
560  Y = m_TeamStartLocY[idx];
561  Z = m_TeamStartLocZ[idx];
562  O = m_TeamStartLocO[idx];
563  }
float m_TeamStartLocZ[BG_TEAMS_COUNT]
Definition: Battleground.h:792
uint8 GetTeamIndexByTeamId(uint32 Team) const
Definition: Battleground.h:609
float m_TeamStartLocY[BG_TEAMS_COUNT]
Definition: Battleground.h:791
float m_TeamStartLocO[BG_TEAMS_COUNT]
Definition: Battleground.h:793
ACE_UINT8 uint8
Definition: Define.h:73
float m_TeamStartLocX[BG_TEAMS_COUNT]
Definition: Battleground.h:790
uint8 Battleground::GetWinner ( ) const
inline

Definition at line 368 of file Battleground.h.

Referenced by BattlegroundMgr::BuildPvpLogDataPacket().

369  {
370  return m_Winner;
371  }
virtual void Battleground::HandleAreaTrigger ( Player ,
uint32   
)
inlinevirtual
void Battleground::HandleKillPlayer ( Player player,
Player killer 
)
virtual

Reimplemented in BattlegroundAV, BattlegroundEY, BattlegroundWS, BattlegroundNA, BattlegroundBE, BattlegroundRL, and BattlegroundAA.

Definition at line 1769 of file Battleground.cpp.

References Player::GetTeam(), Player::IsAtGroupRewardDistance(), SCORE_DEATHS, SCORE_HONORABLE_KILLS, SCORE_KILLING_BLOWS, Object::SetFlag(), sObjectMgr, UNIT_FIELD_FLAGS, and UNIT_FLAG_SKINNABLE.

Referenced by BattlegroundAA::HandleKillPlayer(), BattlegroundRL::HandleKillPlayer(), BattlegroundBE::HandleKillPlayer(), BattlegroundNA::HandleKillPlayer(), BattlegroundWS::HandleKillPlayer(), BattlegroundEY::HandleKillPlayer(), and BattlegroundAV::HandleKillPlayer().

1770 {
1771  // Keep in mind that for arena this will have to be changed a bit
1772 
1773  // Add +1 deaths
1774  UpdatePlayerScore(victim, SCORE_DEATHS, 1);
1775 
1776  // Add +1 kills to group and +1 killing_blows to killer
1777  if (killer)
1778  {
1779  // Don't reward credit for killing ourselves, like fall damage of hellfire (warlock)
1780  if (killer == victim)
1781  return;
1782 
1785 
1786  for (std::map<uint64, BattlegroundPlayer>::iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
1787  {
1788  Player* creditedPlayer = sObjectMgr.GetPlayer(itr->first);
1789  if (!creditedPlayer || creditedPlayer == killer)
1790  continue;
1791 
1792  if (creditedPlayer->GetTeam() == killer->GetTeam() && creditedPlayer->IsAtGroupRewardDistance(victim))
1793  UpdatePlayerScore(creditedPlayer, SCORE_HONORABLE_KILLS, 1);
1794  }
1795  }
1796 
1797  // To be able to remove insignia -- ONLY IN Battlegrounds
1798  if (!isArena())
1799  victim->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SKINNABLE);
1800 }
BattlegroundPlayerMap m_Players
Definition: Battleground.h:718
bool IsAtGroupRewardDistance(WorldObject const *pRewardSource) const
Definition: Player.cpp:19935
#define sObjectMgr
Definition: ObjectMgr.h:1285
bool isArena() const
Definition: Battleground.h:481
virtual void UpdatePlayerScore(Player *Source, uint32 type, uint32 value)
uint32 GetTeam() const
Definition: Player.h:2063
Definition: Player.h:922
void Battleground::HandleKillUnit ( Creature ,
Player  
)
virtual

Reimplemented in BattlegroundAV.

Definition at line 1881 of file Battleground.cpp.

1882 {
1883 }
virtual bool Battleground::HandlePlayerUnderMap ( Player )
inlinevirtual

Definition at line 687 of file Battleground.h.

688  {
689  return false;
690  }
void Battleground::HandleTriggerBuff ( uint64 const &  go_guid)

Definition at line 1734 of file Battleground.cpp.

References Buff_Entries, BUFF_RESPAWN_TIME, GAMEOBJECT_TYPE_TRAP, Object::GetEntry(), GameObject::GetGameObject(), GameObject::GetGoType(), GUID_LOPART, GameObject::isSpawned(), RESPAWN_ONE_DAY, sLog, and urand().

1735 {
1736  GameObject* obj = GetBgMap()->GetGameObject(go_guid);
1737  if (!obj || obj->GetGoType() != GAMEOBJECT_TYPE_TRAP || !obj->isSpawned())
1738  return;
1739 
1740  //change buff type, when buff is used:
1741  int32 index = m_BgObjects.size() - 1;
1742  while (index >= 0 && m_BgObjects[index] != go_guid)
1743  index--;
1744  if (index < 0)
1745  {
1746  sLog.outError("Battleground (Type: %u) has buff gameobject (Guid: %u Entry: %u Type:%u) but it hasn't that object in its internal data", GetTypeID(), GUID_LOPART(go_guid), obj->GetEntry(), obj->GetGoType());
1747  return;
1748  }
1749 
1750  //randomly select new buff
1751  uint8 buff = urand(0, 2);
1752  uint32 entry = obj->GetEntry();
1753  if (m_BuffChange && entry != Buff_Entries[buff])
1754  {
1755  //despawn current buff
1757  //set index for new one
1758  for (uint8 currBuffTypeIndex = 0; currBuffTypeIndex < 3; ++currBuffTypeIndex)
1759  if (entry == Buff_Entries[currBuffTypeIndex])
1760  {
1761  index -= currBuffTypeIndex;
1762  index += buff;
1763  }
1764  }
1765 
1767 }
#define GUID_LOPART(x)
Definition: ObjectGuid.h:110
#define sLog
Log class singleton.
Definition: Log.h:187
ACE_INT32 int32
Definition: Define.h:67
void SpawnBGObject(uint32 type, uint32 respawntime)
BattlegroundMap * GetBgMap()
Definition: Battleground.h:549
ACE_UINT8 uint8
Definition: Define.h:73
BGObjects m_BgObjects
Definition: Battleground.h:672
bool isSpawned() const
Definition: GameObject.h:699
uint32 GetTypeID() const
Definition: Battleground.h:305
GameobjectTypes GetGoType() const
Definition: GameObject.h:720
uint32 GetEntry() const
Definition: Object.h:192
ACE_UINT32 uint32
Definition: Define.h:71
const uint32 Buff_Entries[3]
Definition: Battleground.h:110
GameObject * GetGameObject(uint64 guid)
Definition: Map.cpp:2636
uint32 urand(uint32 min, uint32 max)
Definition: Util.cpp:33
bool Battleground::HasFreeSlots ( ) const

Definition at line 1348 of file Battleground.cpp.

Referenced by BattlegroundQueue::Update().

1349 {
1350  return GetPlayersSize() < GetMaxPlayers();
1351 }
uint32 GetPlayersSize() const
Definition: Battleground.h:499
uint32 GetMaxPlayers() const
Definition: Battleground.h:333
bool Battleground::HasFreeSlotsForTeam ( uint32  Team) const
void Battleground::IncreaseInvitedCount ( uint32  team)
inline

Definition at line 466 of file Battleground.h.

References ALLIANCE.

Referenced by BattlegroundMgr::InvitePlayer().

467  {
468  (team == ALLIANCE) ? ++m_InvitedAlliance : ++m_InvitedHorde;
469  }
uint32 m_InvitedHorde
Definition: Battleground.h:766
uint32 m_InvitedAlliance
Definition: Battleground.h:765
bool Battleground::isBattleground ( ) const
inline

Definition at line 485 of file Battleground.h.

486  {
487  return !m_IsArena;
488  }
bool Battleground::IsPlayerInBattleground ( uint64  guid)

Definition at line 1817 of file Battleground.cpp.

Referenced by BattlegroundMgr::BuildPvpLogDataPacket(), and Player::LoadFromDB().

1818 {
1819  std::map<uint64, BattlegroundPlayer>::const_iterator itr = m_Players.find(guid);
1820  if (itr != m_Players.end())
1821  return true;
1822  return false;
1823 }
BattlegroundPlayerMap m_Players
Definition: Battleground.h:718
bool Battleground::isRated ( ) const
inline

Definition at line 489 of file Battleground.h.

Referenced by BattlegroundMgr::BuildBattlegroundStatusPacket(), and BattlegroundMgr::InvitePlayer().

490  {
491  return m_IsRated;
492  }
void Battleground::ModifyStartDelayTime ( int  diff)
inline

Definition at line 437 of file Battleground.h.

438  {
439  m_StartDelayTime -= diff;
440  }
int32 m_StartDelayTime
Definition: Battleground.h:752
void Battleground::PlayerRelogin ( uint64  guid)

Definition at line 1825 of file Battleground.cpp.

References BattlegroundMgr::BGQueueTypeId(), Player::GetBattlegroundQueueIndex(), Player::GetSession(), Player::GetTeam(), GUID_LOPART, sBattlegroundMgr, WorldSession::SendPacket(), sLog, sObjectMgr, STATUS_IN_PROGRESS, STATUS_WAIT_LEAVE, and TIME_TO_AUTOREMOVE.

1826 {
1827  if (GetStatus() != STATUS_WAIT_LEAVE)
1828  return;
1829 
1830  Player* plr = sObjectMgr.GetPlayer(guid);
1831  if (!plr)
1832  {
1833  sLog.outError("Battleground: Player (GUID: %u) not found!", GUID_LOPART(guid));
1834  return;
1835  }
1836 
1837  WorldPacket data;
1839 
1840  BlockMovement(plr);
1841 
1842  sBattlegroundMgr.BuildPvpLogDataPacket(&data, this);
1843  plr->GetSession()->SendPacket(&data);
1844 
1845  sBattlegroundMgr.BuildBattlegroundStatusPacket(&data, this, plr->GetTeam(), plr->GetBattlegroundQueueIndex(bgQueueTypeId), STATUS_IN_PROGRESS, TIME_TO_AUTOREMOVE, GetStartTime());
1846  plr->GetSession()->SendPacket(&data);
1847 }
#define GUID_LOPART(x)
Definition: ObjectGuid.h:110
#define sLog
Log class singleton.
Definition: Log.h:187
uint32 GetStatus() const
Definition: Battleground.h:317
#define sObjectMgr
Definition: ObjectMgr.h:1285
void SendPacket(WorldPacket const *packet)
uint8 GetArenaType() const
Definition: Battleground.h:364
uint32 GetBattlegroundQueueIndex(uint32 bgQueueType) const
Definition: Player.h:2222
static uint32 BGQueueTypeId(uint32 bgTypeId, uint8 arenaType)
uint32 GetTypeID() const
Definition: Battleground.h:305
uint32 GetStartTime() const
Definition: Battleground.h:321
#define sBattlegroundMgr
uint32 GetTeam() const
Definition: Player.h:2063
WorldSession * GetSession() const
Definition: Player.h:1944
void BlockMovement(Player *plr)
ACE_UINT32 uint32
Definition: Define.h:71
Definition: Player.h:922
void Battleground::PlaySoundToTeam ( uint32  SoundID,
uint32  TeamID 
)

Definition at line 535 of file Battleground.cpp.

References Player::GetSession(), Player::GetTeam(), GUID_LOPART, sBattlegroundMgr, WorldSession::SendPacket(), sLog, and sObjectMgr.

536 {
537  WorldPacket data;
538 
539  for (std::map<uint64, BattlegroundPlayer>::iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
540  {
541  if (itr->second.LastOnlineTime)
542  continue;
543 
544  Player* plr = sObjectMgr.GetPlayer(itr->first);
545 
546  if (!plr)
547  {
548  sLog.outError("Battleground: Player (GUID: %u) not found!", GUID_LOPART(itr->first));
549  continue;
550  }
551 
552  uint32 team = itr->second.Team;
553  if (!team) team = plr->GetTeam();
554 
555  if (team == TeamID)
556  {
557  sBattlegroundMgr.BuildPlaySoundPacket(&data, SoundID);
558  plr->GetSession()->SendPacket(&data);
559  }
560  }
561 }
#define GUID_LOPART(x)
Definition: ObjectGuid.h:110
#define sLog
Log class singleton.
Definition: Log.h:187
BattlegroundPlayerMap m_Players
Definition: Battleground.h:718
#define sObjectMgr
Definition: ObjectMgr.h:1285
void SendPacket(WorldPacket const *packet)
#define sBattlegroundMgr
uint32 GetTeam() const
Definition: Player.h:2063
WorldSession * GetSession() const
Definition: Player.h:1944
ACE_UINT32 uint32
Definition: Define.h:71
Definition: Player.h:922
void Battleground::PSendMessageToAll ( int32  entry,
ChatMsg  type,
Player const *  source,
  ... 
)

Definition at line 1694 of file Battleground.cpp.

Referenced by BattlegroundEY::EventPlayerClickedOnFlag().

1695 {
1696  va_list ap;
1697  va_start(ap, source);
1698 
1699  Oregon::BattlegroundChatBuilder bg_builder(type, entry, source, &ap);
1701  BroadcastWorker(bg_do);
1702 
1703  va_end(ap);
1704 }
void BroadcastWorker(Do &_do)
void Battleground::RemoveFromBGFreeSlotQueue ( )

Definition at line 1273 of file Battleground.cpp.

References sBattlegroundMgr.

Referenced by BattlegroundQueue::Update().

1274 {
1275  // set to be able to re-add if needed
1276  m_InBGFreeSlotQueue = false;
1277  // uncomment this code when battlegrounds will work like instances
1278  for (std::list<Battleground*>::iterator itr = sBattlegroundMgr.BGFreeSlotQueue[m_TypeID].begin(); itr != sBattlegroundMgr.BGFreeSlotQueue[m_TypeID].end(); ++itr)
1279  {
1280  if ((*itr)->GetInstanceID() == m_InstanceID)
1281  {
1282  sBattlegroundMgr.BGFreeSlotQueue[m_TypeID].erase(itr);
1283  return;
1284  }
1285  }
1286 }
uint32 m_TypeID
Definition: Battleground.h:736
uint32 m_InstanceID
Definition: Battleground.h:737
bool m_InBGFreeSlotQueue
Definition: Battleground.h:745
#define sBattlegroundMgr
virtual void Battleground::RemovePlayer ( Player ,
uint64   
)
inlineprotectedvirtual
void Battleground::RemovePlayerAtLeave ( uint64  guid,
bool  Transport,
bool  SendPacket 
)
virtual

Definition at line 988 of file Battleground.cpp.

References ALLIANCE, Player::ClearAfkReports(), ObjectAccessor::ConvertCorpseForPlayer(), Player::GetBattlegroundQueueIndex(), Unit::GetGuardianPet(), WorldObject::GetName(), ArenaTeam::GetRating(), Player::GetSession(), Player::GetTeam(), Player::GetTemporaryUnsummonedPetNumber(), Unit::HasAuraType(), HORDE, Oregon::Singleton< ObjectAccessor, Oregon::ClassLevelLockable< ObjectAccessor, ACE_Thread_Mutex > >::Instance(), Unit::IsAlive(), Pet::LoadPetFromDB(), ArenaTeam::MemberLost(), ArenaTeam::OfflineMemberLost(), Unit::RemoveAurasByType(), Player::RemoveBattlegroundQueueId(), Unit::RemoveSpellsCausingAura(), Player::ResurrectPlayer(), sBattlegroundMgr, WorldSession::SendPacket(), Player::SetBattlegroundId(), Player::SetBGTeam(), sLog, sObjectMgr, Player::SpawnCorpseBones(), SPELL_AURA_MOD_SHAPESHIFT, SPELL_AURA_MOUNTED, SPELL_AURA_SPIRIT_OF_REDEMPTION, STATUS_IN_PROGRESS, STATUS_NONE, STATUS_WAIT_LEAVE, and Player::TeleportToBGEntryPoint().

Referenced by Player::LoadFromDB().

989 {
990  uint32 team = GetPlayerTeam(guid);
991  bool participant = false;
992  // Remove from lists/maps
993  std::map<uint64, BattlegroundPlayer>::iterator itr = m_Players.find(guid);
994  if (itr != m_Players.end())
995  {
996  UpdatePlayersCountByTeam(team, true); // -1 player
997  m_Players.erase(itr);
998  // check if the player was a participant of the match, or only entered through gm command (goname)
999  participant = true;
1000  }
1001 
1002  BattlegroundScoreMap::iterator itr2 = m_PlayerScores.find(guid);
1003  if (itr2 != m_PlayerScores.end())
1004  {
1005  delete itr2->second; // delete player's score
1006  m_PlayerScores.erase(itr2);
1007  }
1008 
1010 
1011  Player* player = sObjectMgr.GetPlayer(guid);
1012 
1013  if (player)
1014  {
1015  // should remove spirit of redemption
1018 
1020 
1021  if (!player->IsAlive()) // resurrect on exit
1022  {
1023  player->ResurrectPlayer(1.0f);
1024  player->SpawnCorpseBones();
1025  }
1026  } // try to resurrect the offline player. If he is alive, nothing will happen.
1028 
1029  RemovePlayer(player, guid); // BG subclass specific code
1030 
1031  if (participant)
1032  {
1033  if (player)
1034  {
1035  player->ClearAfkReports();
1036 
1037  if (!team) team = player->GetTeam();
1038 
1039  uint32 bgQueueTypeId = sBattlegroundMgr.BGQueueTypeId(GetTypeID(), GetArenaType());
1040  // if arena, remove the specific arena auras
1041  if (isArena())
1042  {
1043  // summon old pet if there was one and there isn't a current pet
1044  if (!player->GetGuardianPet() && player->GetTemporaryUnsummonedPetNumber())
1045  {
1046  Pet* NewPet = new Pet(player);
1047  if (!NewPet->LoadPetFromDB(player, 0, (player)->GetTemporaryUnsummonedPetNumber(), true))
1048  delete NewPet;
1049 
1050  (player)->SetTemporaryUnsummonedPetNumber(0);
1051  }
1052 
1053  if (isRated() && GetStatus() == STATUS_IN_PROGRESS)
1054  {
1055  // left a rated match while the encounter was in progress, consider as loser
1056  ArenaTeam* winner_arena_team = sObjectMgr.GetArenaTeamById(GetArenaTeamIdForTeam(GetOtherTeam(team)));
1057  ArenaTeam* loser_arena_team = sObjectMgr.GetArenaTeamById(GetArenaTeamIdForTeam(team));
1058  if (winner_arena_team && loser_arena_team)
1059  loser_arena_team->MemberLost(player, winner_arena_team->GetRating());
1060  }
1061  }
1062 
1063  WorldPacket data;
1064  if (SendPacket)
1065  {
1066  sBattlegroundMgr.BuildBattlegroundStatusPacket(&data, this, team, player->GetBattlegroundQueueIndex(bgQueueTypeId), STATUS_NONE, 0, 0);
1067  player->GetSession()->SendPacket(&data);
1068  }
1069 
1070  // this call is important, because player, when joins to battleground, this method is not called, so it must be called when leaving bg
1071  player->RemoveBattlegroundQueueId(bgQueueTypeId);
1072  }
1073  else
1074  {
1075  if (isRated() && GetStatus() == STATUS_IN_PROGRESS)
1076  {
1077  // left a rated match while the encounter was in progress, consider as loser
1078  ArenaTeam* others_arena_team = sObjectMgr.GetArenaTeamById(GetArenaTeamIdForTeam(GetOtherTeam(team)));
1079  ArenaTeam* players_arena_team = sObjectMgr.GetArenaTeamById(GetArenaTeamIdForTeam(team));
1080  if (others_arena_team && players_arena_team)
1081  players_arena_team->OfflineMemberLost(guid, others_arena_team->GetRating());
1082  }
1083  }
1084 
1085  // remove from raid group if player is member
1086  if (Group* group = GetBgRaid(team))
1087  {
1088  if (!group->RemoveMember(guid)) // group was disbanded
1089  {
1090  SetBgRaid(team, NULL);
1091  delete group;
1092  }
1093  }
1094  DecreaseInvitedCount(team);
1095  // we should update battleground queue, but only if bg isn't ending
1097  {
1098  // a player has left the battleground, so there are free slots -> add to queue
1100  }
1101  // Let others know
1102  WorldPacket data;
1103  sBattlegroundMgr.BuildPlayerLeftBattlegroundPacket(&data, guid);
1104  SendPacketToTeam(team, &data, player, false);
1105  }
1106 
1107  if (player)
1108  {
1109  // Do next only if found in battleground
1110  player->SetBattlegroundId(0); // We're not in BG.
1111  // reset destination bg team
1112  player->SetBGTeam(0);
1113 
1114  if (Transport)
1115  player->TeleportToBGEntryPoint();
1116 
1117  sLog.outDetail("BATTLEGROUND: Removed player %s from Battleground.", player->GetName());
1118  }
1119 
1121  {
1122  // if no players left AND no invitees left, set this bg to delete in next update
1123  // direct deletion could cause crashes
1124  m_SetDeleteThis = true;
1125  // return to prevent addition to freeslotqueue
1126  return;
1127  }
1128 }
void OfflineMemberLost(uint64 guid, uint32 againstRating)
Definition: ArenaTeam.cpp:627
uint32 GetPlayersSize() const
Definition: Battleground.h:499
Guardian * GetGuardianPet() const
Definition: Unit.cpp:7676
void DecreaseInvitedCount(uint32 team)
Definition: Battleground.h:462
uint32 GetTemporaryUnsummonedPetNumber() const
Definition: Player.h:2489
void RemovePlayerFromResurrectQueue(uint64 player_guid)
void SendPacketToTeam(uint32 TeamID, WorldPacket *packet, Player *sender=NULL, bool self=true)
void MemberLost(Player *plr, uint32 againstRating)
Definition: ArenaTeam.cpp:605
void SetBgRaid(uint32 TeamID, Group *bg_raid)
Definition: Battleground.h:599
void SetBGTeam(uint32 team)
Definition: Player.h:2300
void RemoveSpellsCausingAura(AuraType auraType)
Definition: Unit.cpp:697
#define sLog
Log class singleton.
Definition: Log.h:187
BattlegroundPlayerMap m_Players
Definition: Battleground.h:718
bool TeleportToBGEntryPoint()
Definition: Player.cpp:1763
uint32 GetPlayerTeam(uint64 guid)
void SpawnCorpseBones()
Definition: Player.cpp:4322
uint32 GetStatus() const
Definition: Battleground.h:317
BattlegroundScoreMap m_PlayerScores
Definition: Battleground.h:713
#define sObjectMgr
Definition: ObjectMgr.h:1285
void SendPacket(WorldPacket const *packet)
bool isRated() const
Definition: Battleground.h:489
uint32 GetInvitedCount(uint32 team) const
Definition: Battleground.h:470
uint32 GetRating() const
Definition: ArenaTeam.h:150
bool isArena() const
Definition: Battleground.h:481
uint32 GetOtherTeam(uint32 teamId)
uint8 GetArenaType() const
Definition: Battleground.h:364
uint32 GetBattlegroundQueueIndex(uint32 bgQueueType) const
Definition: Player.h:2222
bool IsAlive() const
Definition: Unit.h:1336
void RemoveAurasByType(AuraType auraType, uint64 casterGUID=0, Aura *except=NULL, bool negative=true, bool positive=true)
Definition: Unit.cpp:4395
uint32 GetArenaTeamIdForTeam(uint32 Team) const
Definition: Battleground.h:631
void ResurrectPlayer(float restore_percent, bool applySickness=false)
Definition: Player.cpp:4151
bool isBattleground() const
Definition: Battleground.h:485
virtual void RemovePlayer(Player *, uint64)
Definition: Battleground.h:715
void AddToBGFreeSlotQueue()
void SetBattlegroundId(uint32 val)
Definition: Player.h:2241
const char * GetName() const
Definition: Object.h:704
void ClearAfkReports()
Definition: Player.h:2313
bool m_SetDeleteThis
Definition: Battleground.h:746
uint32 GetTypeID() const
Definition: Battleground.h:305
bool LoadPetFromDB(Player *owner, uint32 petentry=0, uint32 petnumber=0, bool current=false)
Definition: Pet.cpp:131
#define sBattlegroundMgr
uint32 GetTeam() const
Definition: Player.h:2063
bool HasAuraType(AuraType auraType) const
Definition: Unit.cpp:832
WorldSession * GetSession() const
Definition: Player.h:1944
ACE_UINT32 uint32
Definition: Define.h:71
void RemoveBattlegroundQueueId(uint32 val)
Definition: Player.h:2265
Corpse * ConvertCorpseForPlayer(uint64 player_guid, bool insignia=false)
Definition: Player.h:922
void UpdatePlayersCountByTeam(uint32 Team, bool remove)
Definition: Battleground.h:618
Definition: Pet.h:146
Group * GetBgRaid(uint32 TeamID) const
Definition: Battleground.h:595
Definition: Group.h:154
void Battleground::RemovePlayerFromResurrectQueue ( uint64  player_guid)

Definition at line 1411 of file Battleground.cpp.

References Unit::RemoveAurasDueToSpell(), sObjectMgr, and SPELL_WAITING_FOR_RESURRECT.

1412 {
1413  for (std::map<uint64, std::vector<uint64> >::iterator itr = m_ReviveQueue.begin(); itr != m_ReviveQueue.end(); ++itr)
1414  {
1415  for (std::vector<uint64>::iterator itr2 = (itr->second).begin(); itr2 != (itr->second).end(); ++itr2)
1416  {
1417  if (*itr2 == player_guid)
1418  {
1419  (itr->second).erase(itr2);
1420 
1421  Player* plr = sObjectMgr.GetPlayer(player_guid);
1422  if (!plr)
1423  return;
1424 
1426 
1427  return;
1428  }
1429  }
1430  }
1431 }
std::map< uint64, std::vector< uint64 > > m_ReviveQueue
Definition: Battleground.h:720
#define sObjectMgr
Definition: ObjectMgr.h:1285
void RemoveAurasDueToSpell(uint32 spellId, Aura *except=NULL)
Definition: Unit.cpp:4371
ACE_UINT64 uint64
Definition: Define.h:70
Definition: Player.h:922
void Battleground::Reset ( )

Definition at line 1131 of file Battleground.cpp.

References MAX_BATTLEGROUND_QUEUES, sLog, STATUS_WAIT_QUEUE, and WINNER_NONE.

Referenced by BattlegroundMgr::CreateBattleground(), and BattlegroundMgr::CreateNewBattleground().

1132 {
1136  SetStartTime(0);
1137  SetEndTime(0);
1139  SetArenaType(0);
1140  SetRated(false);
1141 
1142  m_Events = 0;
1143 
1144  if (m_InvitedAlliance > 0 || m_InvitedHorde > 0)
1145  sLog.outError("Battleground system: bad counter, m_InvitedAlliance: %d, m_InvitedHorde: %d", m_InvitedAlliance, m_InvitedHorde);
1146 
1147  m_InvitedAlliance = 0;
1148  m_InvitedHorde = 0;
1149  m_InBGFreeSlotQueue = false;
1150 
1151  m_Players.clear();
1152 
1153  for (BattlegroundScoreMap::const_iterator itr = m_PlayerScores.begin(); itr != m_PlayerScores.end(); ++itr)
1154  delete itr->second;
1155  m_PlayerScores.clear();
1156 
1157  ResetBGSubclass();
1158 }
virtual void ResetBGSubclass()
Definition: Battleground.h:295
void SetQueueType(uint32 ID)
Definition: Battleground.h:383
#define MAX_BATTLEGROUND_QUEUES
void SetArenaType(uint8 type)
Definition: Battleground.h:424
#define sLog
Log class singleton.
Definition: Log.h:187
BattlegroundPlayerMap m_Players
Definition: Battleground.h:718
uint32 m_InvitedHorde
Definition: Battleground.h:766
BattlegroundScoreMap m_PlayerScores
Definition: Battleground.h:713
void SetLastResurrectTime(uint32 Time)
Definition: Battleground.h:403
void SetEndTime(uint32 Time)
Definition: Battleground.h:399
void SetRated(bool state)
Definition: Battleground.h:420
uint32 m_InvitedAlliance
Definition: Battleground.h:765
void SetWinner(uint8 winner)
Definition: Battleground.h:432
void SetStartTime(uint32 Time)
Definition: Battleground.h:395
bool m_InBGFreeSlotQueue
Definition: Battleground.h:745
void SetStatus(uint32 Status)
Definition: Battleground.h:391
virtual void Battleground::ResetBGSubclass ( )
inlinevirtual

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

Definition at line 295 of file Battleground.h.

296  {
297  }
void Battleground::RewardHonorToTeam ( uint32  Honor,
uint32  TeamID 
)

Definition at line 606 of file Battleground.cpp.

References Player::GetTeam(), GUID_LOPART, SCORE_BONUS_HONOR, sLog, and sObjectMgr.

Referenced by BattlegroundEY::AddPoints(), BattlegroundWS::EndBattleground(), BattlegroundAV::EndBattleground(), BattlegroundWS::EventPlayerCapturedFlag(), BattlegroundAV::EventPlayerDestroyedPoint(), BattlegroundAV::HandleKillUnit(), and BattlegroundAB::Update().

607 {
608  for (std::map<uint64, BattlegroundPlayer>::iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
609  {
610  if (itr->second.LastOnlineTime)
611  continue;
612 
613  Player* plr = sObjectMgr.GetPlayer(itr->first);
614 
615  if (!plr)
616  {
617  sLog.outError("Battleground: Player (GUID: %u) not found!", GUID_LOPART(itr->first));
618  continue;
619  }
620 
621  uint32 team = itr->second.Team;
622  if (!team) team = plr->GetTeam();
623 
624  if (team == TeamID)
626  }
627 }
#define GUID_LOPART(x)
Definition: ObjectGuid.h:110
#define sLog
Log class singleton.
Definition: Log.h:187
BattlegroundPlayerMap m_Players
Definition: Battleground.h:718
#define sObjectMgr
Definition: ObjectMgr.h:1285
virtual void UpdatePlayerScore(Player *Source, uint32 type, uint32 value)
uint32 GetTeam() const
Definition: Player.h:2063
ACE_UINT32 uint32
Definition: Define.h:71
Definition: Player.h:922
void Battleground::RewardMark ( Player plr,
uint32  count 
)

Definition at line 875 of file Battleground.cpp.

References BATTLEGROUND_AB, BATTLEGROUND_AV, BATTLEGROUND_EY, BATTLEGROUND_WS, Player::CanStoreNewItem(), EQUIP_ERR_OK, Unit::GetDummyAura(), ITEM_AB_MARK_OF_HONOR, ITEM_AV_MARK_OF_HONOR, ITEM_EY_MARK_OF_HONOR, ITEM_WS_MARK_OF_HONOR, NULL_BAG, NULL_SLOT, Player::SendNewItem(), sObjectMgr, SPELL_AURA_PLAYER_INACTIVE, and Player::StoreNewItem().

876 {
877  if (!plr || !count)
878  return;
879 
880  // 'Inactive' this aura prevents the player from gaining honor points and battleground tokens
882  return;
883 
884  BattlegroundMarks mark;
885  switch (GetTypeID())
886  {
887  case BATTLEGROUND_AV:
888  mark = ITEM_AV_MARK_OF_HONOR;
889  break;
890  case BATTLEGROUND_WS:
891  mark = ITEM_WS_MARK_OF_HONOR;
892  break;
893  case BATTLEGROUND_AB:
894  mark = ITEM_AB_MARK_OF_HONOR;
895  break;
896  case BATTLEGROUND_EY:
897  mark = ITEM_EY_MARK_OF_HONOR;
898  break;
899  default:
900  return;
901  }
902 
903  if (sObjectMgr.GetItemTemplate(mark))
904  {
905  ItemPosCountVec dest;
906  uint32 no_space_count = 0;
907  uint8 msg = plr->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, mark, count, &no_space_count);
908  if (msg != EQUIP_ERR_OK) // convert to possible store amount
909  count -= no_space_count;
910 
911  if (!dest.empty()) // can add some
912  if (Item* item = plr->StoreNewItem(dest, mark, true, 0))
913  plr->SendNewItem(item, count, false, true);
914 
915  if (no_space_count > 0)
916  SendRewardMarkByMail(plr, mark, no_space_count);
917  }
918 }
void SendNewItem(Item *item, uint32 count, bool received, bool created, bool broadcast=false)
Definition: Player.cpp:12088
Item * StoreNewItem(ItemPosCountVec const &pos, uint32 item, bool update, int32 randomPropertyId=0)
Definition: Player.cpp:10221
#define sObjectMgr
Definition: ObjectMgr.h:1285
uint8 CanStoreNewItem(uint8 bag, uint8 slot, ItemPosCountVec &dest, uint32 item, uint32 count, uint32 *no_space_count=NULL) const
Definition: Player.h:1149
Aura * GetDummyAura(uint32 spell_id) const
Definition: Unit.cpp:12289
ACE_UINT8 uint8
Definition: Define.h:73
Definition: Unit.h:321
Definition: Item.h:196
std::vector< ItemPosCount > ItemPosCountVec
Definition: Player.h:605
uint32 GetTypeID() const
Definition: Battleground.h:305
BattlegroundMarks
Definition: Battleground.h:48
void SendRewardMarkByMail(Player *plr, uint32 mark, uint32 count)
ACE_UINT32 uint32
Definition: Define.h:71
void Battleground::RewardQuest ( Player plr)

Definition at line 955 of file Battleground.cpp.

References BATTLEGROUND_AB, BATTLEGROUND_AV, BATTLEGROUND_EY, BATTLEGROUND_WS, Unit::CastSpell(), Unit::GetDummyAura(), SPELL_AB_QUEST_REWARD, SPELL_AURA_PLAYER_INACTIVE, SPELL_AV_QUEST_REWARD, SPELL_EY_QUEST_REWARD, and SPELL_WS_QUEST_REWARD.

956 {
957  // 'Inactive' this aura prevents the player from gaining honor points and battleground tokens
959  return;
960 
961  uint32 quest;
962  switch (GetTypeID())
963  {
964  case BATTLEGROUND_AV:
965  quest = SPELL_AV_QUEST_REWARD;
966  break;
967  case BATTLEGROUND_WS:
968  quest = SPELL_WS_QUEST_REWARD;
969  break;
970  case BATTLEGROUND_AB:
971  quest = SPELL_AB_QUEST_REWARD;
972  break;
973  case BATTLEGROUND_EY:
974  quest = SPELL_EY_QUEST_REWARD;
975  break;
976  default:
977  return;
978  }
979 
980  plr->CastSpell(plr, quest, true);
981 }
Aura * GetDummyAura(uint32 spell_id) const
Definition: Unit.cpp:12289
void CastSpell(Unit *Victim, uint32 spellId, bool triggered, Item *castItem=NULL, Aura *triggeredByAura=NULL, uint64 originalCaster=0)
Definition: Unit.cpp:1223
uint32 GetTypeID() const
Definition: Battleground.h:305
ACE_UINT32 uint32
Definition: Define.h:71
void Battleground::RewardReputationToTeam ( uint32  faction_id,
uint32  Reputation,
uint32  TeamID 
)

Definition at line 629 of file Battleground.cpp.

References AddPct(), Player::GetReputationMgr(), Player::GetTeam(), Unit::GetTotalAuraModifier(), Unit::GetTotalAuraModifierByMiscValue(), GUID_LOPART, ReputationMgr::ModifyReputation(), sFactionStore, sLog, sObjectMgr, SPELL_AURA_MOD_FACTION_REPUTATION_GAIN, and SPELL_AURA_MOD_REPUTATION_GAIN.

Referenced by BattlegroundAV::EndBattleground(), BattlegroundWS::EventPlayerCapturedFlag(), BattlegroundAV::EventPlayerDestroyedPoint(), BattlegroundAV::HandleKillUnit(), BattlegroundAV::HandleQuestComplete(), and BattlegroundAB::Update().

630 {
631  FactionEntry const* factionEntry = sFactionStore.LookupEntry(faction_id);
632  if (!factionEntry)
633  return;
634 
635  for (std::map<uint64, BattlegroundPlayer>::iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
636  {
637  if (itr->second.LastOnlineTime)
638  continue;
639 
640  Player* plr = sObjectMgr.GetPlayer(itr->first);
641 
642  if (!plr)
643  {
644  sLog.outError("Battleground: Player (GUID: %u) not found!", GUID_LOPART(itr->first));
645  continue;
646  }
647 
648  uint32 team = itr->second.Team;
649  if (!team) team = plr->GetTeam();
650 
651  if (team == TeamID)
652  {
653  uint32 repGain = Reputation;
656  plr->GetReputationMgr().ModifyReputation(factionEntry, Reputation);
657  }
658  }
659 }
int32 GetTotalAuraModifierByMiscValue(AuraType auratype, int32 misc_value) const
Definition: Unit.cpp:3781
#define GUID_LOPART(x)
Definition: ObjectGuid.h:110
int32 GetTotalAuraModifier(AuraType auratype) const
Definition: Unit.cpp:3669
#define sLog
Log class singleton.
Definition: Log.h:187
BattlegroundPlayerMap m_Players
Definition: Battleground.h:718
#define sObjectMgr
Definition: ObjectMgr.h:1285
ReputationMgr & GetReputationMgr()
Definition: Player.h:2079
DBCStorage< FactionEntry > sFactionStore(FactionEntryfmt)
T AddPct(T &base, U pct)
Definition: Util.h:103
uint32 GetTeam() const
Definition: Player.h:2063
bool ModifyReputation(FactionEntry const *factionEntry, int32 standing)
ACE_UINT32 uint32
Definition: Define.h:71
Definition: Player.h:922
void Battleground::SendMessage2ToAll ( int32  entry,
ChatMsg  type,
Player const *  source,
int32  strId1 = 0,
int32  strId2 = 0 
)

Definition at line 1706 of file Battleground.cpp.

Referenced by BattlegroundAB::EventPlayerClickedOnFlag(), and BattlegroundAB::Update().

1707 {
1708  Oregon::Battleground2ChatBuilder bg_builder(type, entry, source, arg1, arg2);
1710  BroadcastWorker(bg_do);
1711 }
void BroadcastWorker(Do &_do)
void Battleground::SendPacketToAll ( WorldPacket packet)

Definition at line 487 of file Battleground.cpp.

References Player::GetSession(), GUID_LOPART, WorldSession::SendPacket(), sLog, and sObjectMgr.

488 {
489  for (std::map<uint64, BattlegroundPlayer>::iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
490  {
491  if (itr->second.LastOnlineTime)
492  continue;
493 
494  Player* plr = sObjectMgr.GetPlayer(itr->first);
495  if (plr)
496  plr->GetSession()->SendPacket(packet);
497  else
498  sLog.outError("Battleground: Player (GUID: %u) not found!", GUID_LOPART(itr->first));
499  }
500 }
#define GUID_LOPART(x)
Definition: ObjectGuid.h:110
#define sLog
Log class singleton.
Definition: Log.h:187
BattlegroundPlayerMap m_Players
Definition: Battleground.h:718
#define sObjectMgr
Definition: ObjectMgr.h:1285
void SendPacket(WorldPacket const *packet)
WorldSession * GetSession() const
Definition: Player.h:1944
Definition: Player.h:922
void Battleground::SendPacketToTeam ( uint32  TeamID,
WorldPacket packet,
Player sender = NULL,
bool  self = true 
)

Definition at line 502 of file Battleground.cpp.

References Player::GetSession(), Player::GetTeam(), GUID_LOPART, WorldSession::SendPacket(), sLog, and sObjectMgr.

503 {
504  for (std::map<uint64, BattlegroundPlayer>::iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
505  {
506  if (itr->second.LastOnlineTime)
507  continue;
508 
509  Player* plr = sObjectMgr.GetPlayer(itr->first);
510 
511  if (!plr)
512  {
513  sLog.outError("Battleground: Player (GUID: %u) not found!", GUID_LOPART(itr->first));
514  continue;
515  }
516 
517  if (!self && sender == plr)
518  continue;
519 
520  uint32 team = itr->second.Team;
521  if (!team) team = plr->GetTeam();
522 
523  if (team == TeamID)
524  plr->GetSession()->SendPacket(packet);
525  }
526 }
#define GUID_LOPART(x)
Definition: ObjectGuid.h:110
#define sLog
Log class singleton.
Definition: Log.h:187
BattlegroundPlayerMap m_Players
Definition: Battleground.h:718
#define sObjectMgr
Definition: ObjectMgr.h:1285
void SendPacket(WorldPacket const *packet)
uint32 GetTeam() const
Definition: Player.h:2063
WorldSession * GetSession() const
Definition: Player.h:1944
ACE_UINT32 uint32
Definition: Define.h:71
Definition: Player.h:922
void Battleground::SendRewardMarkByMail ( Player plr,
uint32  mark,
uint32  count 
)

Definition at line 920 of file Battleground.cpp.

References MailDraft::AddItem(), Item::CreateItem(), WorldSession::GetOregonString(), Player::GetSession(), WorldSession::GetSessionDbLocaleIndex(), ItemTemplate::ItemId, LANG_BG_MARK_BY_MAIL, MAIL_CREATURE, ItemTemplate::Name1, MailDraft::SendMailTo(), snprintf, and sObjectMgr.

921 {
922  uint32 bmEntry = GetBattlemasterEntry();
923  if (!bmEntry)
924  return;
925 
926  ItemTemplate const* markProto = sObjectMgr.GetItemTemplate(mark);
927  if (!markProto)
928  return;
929 
930  if (Item* markItem = Item::CreateItem(mark, count, plr))
931  {
932  // save new item before send
933  markItem->SaveToDB(); // save for prevent lost at next mail load, if send fail then item will deleted
934 
935  // subject: item name
936  std::string subject = markProto->Name1;
937  int loc_idx = plr->GetSession()->GetSessionDbLocaleIndex();
938  if (loc_idx >= 0)
939  if (ItemLocale const* il = sObjectMgr.GetItemLocale(markProto->ItemId))
940  if (il->Name.size() > size_t(loc_idx) && !il->Name[loc_idx].empty())
941  subject = il->Name[loc_idx];
942 
943  // text
944  std::string textFormat = plr->GetSession()->GetOregonString(LANG_BG_MARK_BY_MAIL);
945  char textBuf[300];
946  snprintf(textBuf, 300, textFormat.c_str(), GetName(), GetName());
947  uint32 itemTextId = sObjectMgr.CreateItemText(textBuf);
948 
949  MailDraft(subject, itemTextId)
950  .AddItem(markItem)
951  .SendMailTo(plr, MailSender(MAIL_CREATURE, bmEntry));
952  }
953 }
#define snprintf
Definition: Common.h:129
#define sObjectMgr
Definition: ObjectMgr.h:1285
uint32 GetBattlemasterEntry() const
Definition: Item.h:196
static Item * CreateItem(uint32 item, uint32 count, Player const *player=NULL)
Definition: Item.cpp:936
void SendMailTo(MailReceiver const &receiver, MailSender const &sender, MailCheckMask checked=MAIL_CHECK_MASK_NONE, uint32 deliver_delay=0)
Definition: Mail.cpp:978
const char * GetOregonString(int32 entry) const
MailDraft & AddItem(Item *item)
Definition: Mail.cpp:869
int GetSessionDbLocaleIndex() const
Definition: WorldSession.h:237
char const * GetName() const
Definition: Battleground.h:301
WorldSession * GetSession() const
Definition: Player.h:1944
ACE_UINT32 uint32
Definition: Define.h:71
void Battleground::SetArenaorBGType ( bool  _isArena)
inline

Definition at line 428 of file Battleground.h.

Referenced by BattlegroundMgr::CreateBattleground().

429  {
430  m_IsArena = _isArena;
431  }
void Battleground::SetArenaTeamIdForTeam ( uint32  Team,
uint32  ArenaTeamId 
)
inline

Definition at line 627 of file Battleground.h.

Referenced by BattlegroundMgr::InvitePlayer().

628  {
629  m_ArenaTeamIds[GetTeamIndexByTeamId(Team)] = ArenaTeamId;
630  }
uint8 GetTeamIndexByTeamId(uint32 Team) const
Definition: Battleground.h:609
Team
uint32 m_ArenaTeamIds[BG_TEAMS_COUNT]
Definition: Battleground.h:775
void Battleground::SetArenaTeamRatingChangeForTeam ( uint32  Team,
int32  RatingChange 
)
inline

Definition at line 635 of file Battleground.h.

636  {
638  }
int32 m_ArenaTeamRatingChanges[BG_TEAMS_COUNT]
Definition: Battleground.h:777
uint8 GetTeamIndexByTeamId(uint32 Team) const
Definition: Battleground.h:609
Team
void Battleground::SetArenaType ( uint8  type)
inline

Definition at line 424 of file Battleground.h.

Referenced by BattlegroundMgr::CreateNewBattleground().

425  {
426  m_ArenaType = type;
427  }
uint8 m_ArenaType
Definition: Battleground.h:744
void Battleground::SetBgMap ( BattlegroundMap map)
inline

Definition at line 545 of file Battleground.h.

Referenced by MapInstanced::CreateBattleground().

546  {
547  m_Map = map;
548  }
BattlegroundMap * m_Map
Definition: Battleground.h:789
void Battleground::SetBgRaid ( uint32  TeamID,
Group bg_raid 
)
inline

Definition at line 599 of file Battleground.h.

References ALLIANCE, BG_TEAM_ALLIANCE, BG_TEAM_HORDE, Group::SetBattlegroundGroup(), and value.

Referenced by Group::~Group().

600  {
601  Group*& old_raid = TeamID == ALLIANCE ? m_BgRaids[BG_TEAM_ALLIANCE] : m_BgRaids[BG_TEAM_HORDE];
602  if (old_raid) old_raid->SetBattlegroundGroup(NULL);
603  if (bg_raid) bg_raid->SetBattlegroundGroup(this);
604  old_raid = bg_raid;
605  }
Group * m_BgRaids[BG_TEAMS_COUNT]
Definition: Battleground.h:769
void SetBattlegroundGroup(Battleground *bg)
Definition: Group.h:326
Definition: Group.h:154
void Battleground::SetDeleteThis ( )
inline

Definition at line 698 of file Battleground.h.

Referenced by BattlegroundQueue::RemovePlayer().

699  {
700  m_SetDeleteThis = true;
701  }
bool m_SetDeleteThis
Definition: Battleground.h:746
void Battleground::SetEndTime ( uint32  Time)
inline

Definition at line 399 of file Battleground.h.

400  {
401  m_EndTime = Time;
402  }
uint32 m_EndTime
Definition: Battleground.h:741
void Battleground::SetHoliday ( bool  is_holiday)

Definition at line 1864 of file Battleground.cpp.

References BG_HOLIDAY, and BG_NORMAL.

1865 {
1866  if (is_holiday)
1868  else
1870 }
BGHonorMode m_HonorMode
Definition: Battleground.h:733
void Battleground::SetInstanceID ( uint32  InstanceID)
inline

Definition at line 387 of file Battleground.h.

Referenced by BattlegroundMgr::CreateBattleground(), and BattlegroundMgr::CreateNewBattleground().

388  {
389  m_InstanceID = InstanceID;
390  }
uint32 m_InstanceID
Definition: Battleground.h:737
void Battleground::SetLastResurrectTime ( uint32  Time)
inline

Definition at line 403 of file Battleground.h.

404  {
405  m_LastResurrectTime = Time;
406  }
uint32 m_LastResurrectTime
Definition: Battleground.h:742
void Battleground::SetLevelRange ( uint32  min,
uint32  max 
)
inline

Definition at line 415 of file Battleground.h.

Referenced by BattlegroundMgr::CreateBattleground().

416  {
417  m_LevelMin = min;
418  m_LevelMax = max;
419  }
uint32 m_LevelMin
Definition: Battleground.h:780
uint32 m_LevelMax
Definition: Battleground.h:781
void Battleground::SetMapId ( uint32  MapID)
inline

Definition at line 535 of file Battleground.h.

Referenced by BattlegroundMgr::CreateBattleground().

536  {
537  m_MapId = MapID;
538  }
uint32 m_MapId
Definition: Battleground.h:788
void Battleground::SetMaxPlayers ( uint32  MaxPlayers)
inline

Definition at line 407 of file Battleground.h.

Referenced by BattlegroundMgr::CreateBattleground(), and BattlegroundQueue::Update().

408  {
409  m_MaxPlayers = MaxPlayers;
410  }
uint32 m_MaxPlayers
Definition: Battleground.h:783
void Battleground::SetMaxPlayersPerTeam ( uint32  MaxPlayers)
inline

Definition at line 446 of file Battleground.h.

Referenced by BattlegroundMgr::CreateBattleground(), and BattlegroundQueue::Update().

447  {
448  m_MaxPlayersPerTeam = MaxPlayers;
449  }
uint32 m_MaxPlayersPerTeam
Definition: Battleground.h:782
void Battleground::SetMinPlayers ( uint32  MinPlayers)
inline

Definition at line 411 of file Battleground.h.

Referenced by BattlegroundMgr::CreateBattleground().

412  {
413  m_MinPlayers = MinPlayers;
414  }
uint32 m_MinPlayers
Definition: Battleground.h:785
void Battleground::SetMinPlayersPerTeam ( uint32  MinPlayers)
inline

Definition at line 450 of file Battleground.h.

Referenced by BattlegroundMgr::CreateBattleground().

451  {
452  m_MinPlayersPerTeam = MinPlayers;
453  }
uint32 m_MinPlayersPerTeam
Definition: Battleground.h:784
void Battleground::SetName ( char const *  Name)
inline

Definition at line 375 of file Battleground.h.

Referenced by BattlegroundMgr::CreateBattleground().

376  {
377  m_Name = Name;
378  }
char const * m_Name
Definition: Battleground.h:756
void Battleground::SetQueueType ( uint32  ID)
inline

Definition at line 383 of file Battleground.h.

Referenced by BattlegroundQueue::Update().

384  {
385  m_Queue_type = ID;
386  }
uint32 m_Queue_type
Definition: Battleground.h:743
void Battleground::SetRated ( bool  state)
inline

Definition at line 420 of file Battleground.h.

Referenced by BattlegroundMgr::CreateNewBattleground().

421  {
422  m_IsRated = state;
423  }
void Battleground::SetStartDelayTime ( int  Time)
inline

Definition at line 441 of file Battleground.h.

442  {
443  m_StartDelayTime = Time;
444  }
int32 m_StartDelayTime
Definition: Battleground.h:752
void Battleground::SetStartMaxDist ( float  startMaxDist)
inline

Definition at line 459 of file Battleground.h.

Referenced by BattlegroundMgr::CreateBattleground().

459 { m_StartMaxDist = startMaxDist; }
float m_StartMaxDist
Definition: Battleground.h:794
void Battleground::SetStartTime ( uint32  Time)
inline

Definition at line 395 of file Battleground.h.

396  {
397  m_StartTime = Time;
398  }
uint32 m_StartTime
Definition: Battleground.h:739
void Battleground::SetStatus ( uint32  Status)
inline

Definition at line 391 of file Battleground.h.

Referenced by BattlegroundMgr::CreateNewBattleground().

392  {
393  m_Status = Status;
394  }
uint32 m_Status
Definition: Battleground.h:738
void Battleground::SetTeamStartLoc ( uint32  TeamID,
float  X,
float  Y,
float  Z,
float  O 
)

Definition at line 478 of file Battleground.cpp.

Referenced by BattlegroundMgr::CreateBattleground().

479 {
480  uint8 idx = GetTeamIndexByTeamId(TeamID);
481  m_TeamStartLocX[idx] = X;
482  m_TeamStartLocY[idx] = Y;
483  m_TeamStartLocZ[idx] = Z;
484  m_TeamStartLocO[idx] = O;
485 }
float m_TeamStartLocZ[BG_TEAMS_COUNT]
Definition: Battleground.h:792
uint8 GetTeamIndexByTeamId(uint32 Team) const
Definition: Battleground.h:609
float m_TeamStartLocY[BG_TEAMS_COUNT]
Definition: Battleground.h:791
float m_TeamStartLocO[BG_TEAMS_COUNT]
Definition: Battleground.h:793
ACE_UINT8 uint8
Definition: Define.h:73
float m_TeamStartLocX[BG_TEAMS_COUNT]
Definition: Battleground.h:790
void Battleground::SetTypeID ( uint32  TypeID)
inline

Definition at line 379 of file Battleground.h.

Referenced by BattlegroundMgr::CreateBattleground(), and BattlegroundMgr::CreateNewBattleground().

380  {
381  m_TypeID = TypeID;
382  }
uint32 m_TypeID
Definition: Battleground.h:736
TypeID
Definition: ObjectGuid.h:24
virtual bool Battleground::SetupBattleground ( )
inlinevirtual

Reimplemented in BattlegroundAV, BattlegroundEY, BattlegroundAB, BattlegroundWS, BattlegroundNA, BattlegroundBE, BattlegroundRL, and BattlegroundAA.

Definition at line 288 of file Battleground.h.

289  {
290  return true;
291  }
void Battleground::SetWinner ( uint8  winner)
inline

Definition at line 432 of file Battleground.h.

433  {
434  m_Winner = winner;
435  }
void Battleground::SpawnBGObject ( uint32  type,
uint32  respawntime 
)

Definition at line 1530 of file Battleground.cpp.

References Map::AddToMap(), Map::GetGameObject(), GameObject::getLootState(), GO_JUST_DEACTIVATED, GO_READY, GameObject::SetLootState(), and GameObject::SetRespawnTime().

Referenced by BattlegroundAB::_CreateBanner(), BattlegroundAB::_DelBanner(), BattlegroundAV::EventPlayerAssaultsPoint(), BattlegroundWS::EventPlayerCapturedFlag(), BattlegroundEY::EventPlayerCapturedFlag(), BattlegroundWS::EventPlayerClickedOnFlag(), BattlegroundEY::EventPlayerClickedOnFlag(), BattlegroundAV::EventPlayerDefendsPoint(), BattlegroundAV::EventPlayerDestroyedPoint(), BattlegroundEY::EventTeamCapturedPoint(), BattlegroundEY::EventTeamLostPoint(), BattlegroundAV::HandleKillUnit(), BattlegroundWS::RespawnFlag(), BattlegroundEY::RespawnFlag(), BattlegroundWS::RespawnFlagAfterDrop(), BattlegroundAV::SetupBattleground(), BattlegroundRL::StartingEventCloseDoors(), BattlegroundBE::StartingEventCloseDoors(), BattlegroundNA::StartingEventCloseDoors(), BattlegroundWS::StartingEventCloseDoors(), BattlegroundAB::StartingEventCloseDoors(), BattlegroundEY::StartingEventCloseDoors(), BattlegroundRL::StartingEventOpenDoors(), BattlegroundBE::StartingEventOpenDoors(), BattlegroundNA::StartingEventOpenDoors(), BattlegroundWS::StartingEventOpenDoors(), BattlegroundAB::StartingEventOpenDoors(), BattlegroundEY::StartingEventOpenDoors(), and BattlegroundAV::StartingEventOpenDoors().

1531 {
1532  Map* map = GetBgMap();
1533  if (!map)
1534  return;
1535  if (respawntime == 0)
1536  {
1537  GameObject* obj = map->GetGameObject(m_BgObjects[type]);
1538  if (obj)
1539  {
1540  //we need to change state from GO_JUST_DEACTIVATED to GO_READY in case battleground is starting again
1541  if (obj->getLootState() == GO_JUST_DEACTIVATED)
1542  obj->SetLootState(GO_READY);
1543  obj->SetRespawnTime(0);
1544  map->AddToMap(obj);
1545  }
1546  }
1547  else
1548  {
1549  GameObject* obj = map->GetGameObject(m_BgObjects[type]);
1550  if (obj)
1551  {
1552  map->AddToMap(obj);
1553  obj->SetRespawnTime(respawntime);
1555  }
1556  }
1557 }
bool AddToMap(T *)
Definition: Map.cpp:424
LootState getLootState() const
Definition: GameObject.h:748
void SetRespawnTime(int32 respawn)
Definition: GameObject.h:693
BattlegroundMap * GetBgMap()
Definition: Battleground.h:549
void SetLootState(LootState s, Unit *unit=NULL)
BGObjects m_BgObjects
Definition: Battleground.h:672
Definition: Map.h:266
GameObject * GetGameObject(uint64 guid)
Definition: Map.cpp:2636
void Battleground::StartBattleground ( )

Definition at line 1160 of file Battleground.cpp.

References BG_TEAM_ALLIANCE, BG_TEAM_HORDE, and sLog.

Referenced by BattlegroundQueue::Update().

1161 {
1162  SetStartTime(0);
1164  if (m_IsRated)
1165  sLog.outArena("Arena match type: %u for Team1Id: %u - Team2Id: %u started.", m_ArenaType, m_ArenaTeamIds[BG_TEAM_ALLIANCE], m_ArenaTeamIds[BG_TEAM_HORDE]);
1166 }
#define sLog
Log class singleton.
Definition: Log.h:187
void SetLastResurrectTime(uint32 Time)
Definition: Battleground.h:403
uint8 m_ArenaType
Definition: Battleground.h:744
void SetStartTime(uint32 Time)
Definition: Battleground.h:395
uint32 m_ArenaTeamIds[BG_TEAMS_COUNT]
Definition: Battleground.h:775
virtual void Battleground::StartingEventCloseDoors ( )
inlinevirtual
virtual void Battleground::StartingEventOpenDoors ( )
inlinevirtual
void Battleground::Update ( uint32  diff)
virtual

Reimplemented in BattlegroundAV, BattlegroundEY, BattlegroundAB, BattlegroundWS, BattlegroundNA, BattlegroundBE, BattlegroundRL, and BattlegroundAA.

Definition at line 232 of file Battleground.cpp.

References ALLIANCE, BG_STARTING_EVENT_1, BG_STARTING_EVENT_2, BG_STARTING_EVENT_3, BG_STARTING_EVENT_4, BG_STARTING_EVENT_FIRST, BG_STARTING_EVENT_FOURTH, BG_STARTING_EVENT_SECOND, BG_STARTING_EVENT_THIRD, Unit::CastSpell(), CHAT_MSG_BG_SYSTEM_NEUTRAL, CHAT_MSG_SYSTEM, ObjectAccessor::ConvertCorpseForPlayer(), Map::GetCreature(), WorldObject::GetMap(), HORDE, IN_MILLISECONDS, Oregon::Singleton< ObjectAccessor, Oregon::ClassLevelLockable< ObjectAccessor, ACE_Thread_Mutex > >::Instance(), Object::IsInWorld(), Unit::IsPvP(), LANG_BATTLEGROUND_PREMATURE_FINISH_WARNING, LANG_BATTLEGROUND_PREMATURE_FINISH_WARNING_SECS, MAX_OFFLINE_TIME, MINUTE, RESURRECTION_INTERVAL, Player::ResurrectPlayer(), sBattlegroundMgr, sLog, sObjectMgr, SOUND_BG_START, SPELL_ARENA_PREPARATION, SPELL_PREPARATION, SPELL_RESURRECTION_VISUAL, SPELL_SPIRIT_HEAL, SPELL_SPIRIT_HEAL_MANA, SPELL_SUMMON_PET, STATUS_IN_PROGRESS, STATUS_WAIT_JOIN, STATUS_WAIT_LEAVE, TIME_TO_AUTOREMOVE, and Player::UpdatePvP().

Referenced by BattlegroundAA::Update(), BattlegroundRL::Update(), BattlegroundBE::Update(), BattlegroundNA::Update(), BattlegroundWS::Update(), BattlegroundAB::Update(), BattlegroundEY::Update(), and BattlegroundAV::Update().

233 {
235  //BG is empty
236  return;
237 
238  m_StartTime += diff;
239 
240  // WorldPacket data;
241 
242  if (GetRemovedPlayersSize())
243  {
244  for (std::map<uint64, uint8>::iterator itr = m_RemovedPlayers.begin(); itr != m_RemovedPlayers.end(); ++itr)
245  {
246  Player* plr = sObjectMgr.GetPlayer(itr->first);
247  switch (itr->second)
248  {
249  //following code is handled by event:
250  /*case 0:
251  sBattlegroundMgr.m_BattlegroundQueues[GetTypeID()].RemovePlayer(itr->first);
252  //RemovePlayerFromQueue(itr->first);
253  if (plr)
254  {
255  sBattlegroundMgr.BuildBattlegroundStatusPacket(&data, this, plr->GetTeam(), plr->GetBattlegroundQueueIndex(m_TypeID), STATUS_NONE, 0, 0);
256  plr->GetSession()->SendPacket(&data);
257  }
258  break;*/
259  case 1: // currently in bg and was removed from bg
260  if (plr)
261  RemovePlayerAtLeave(itr->first, true, true);
262  else
263  RemovePlayerAtLeave(itr->first, false, false);
264  break;
265  case 2: // revive queue
266  RemovePlayerFromResurrectQueue(itr->first);
267  break;
268  default:
269  sLog.outError("Battleground: Unknown remove player case!");
270  }
271  }
272  m_RemovedPlayers.clear();
273  }
274 
275  // remove offline players from bg after 5 minutes
276  if (GetPlayersSize())
277  {
278  for (std::map<uint64, BattlegroundPlayer>::iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
279  {
280  Player* plr = sObjectMgr.GetPlayer(itr->first);
281  itr->second.LastOnlineTime += diff;
282 
283  if (plr)
284  {
285  itr->second.LastOnlineTime = 0; // update last online time
286  if (!plr->IsPvP()) // force all players PvP on
287  plr->UpdatePvP(true, true);
288  }
289  else if (itr->second.LastOnlineTime >= MAX_OFFLINE_TIME)
290  m_RemovedPlayers[itr->first] = 1; // add to remove list (BG)
291  }
292  }
293 
294  /*********************************************************/
295  /*** BATTLEGROUND RESSURECTION SYSTEM ***/
296  /*********************************************************/
297 
298  //this should be handled by spell system
299  m_LastResurrectTime += diff;
301  {
302  if (GetReviveQueueSize())
303  {
304  for (std::map<uint64, std::vector<uint64> >::iterator itr = m_ReviveQueue.begin(); itr != m_ReviveQueue.end(); ++itr)
305  {
306  Creature* sh = NULL;
307  for (std::vector<uint64>::iterator itr2 = (itr->second).begin(); itr2 != (itr->second).end(); ++itr2)
308  {
309  Player* plr = sObjectMgr.GetPlayer(*itr2);
310  if (!plr)
311  continue;
312 
313  if (!sh && plr->IsInWorld())
314  {
315  sh = plr->GetMap()->GetCreature(itr->first);
316  // only for visual effect
317  if (sh)
318  sh->CastSpell(sh, SPELL_SPIRIT_HEAL, true); // Spirit Heal, effect 117
319  }
320 
321  plr->CastSpell(plr, SPELL_RESURRECTION_VISUAL, true); // Resurrection visual
322  m_ResurrectQueue.push_back(*itr2);
323  }
324  (itr->second).clear();
325  }
326 
327  m_ReviveQueue.clear();
329  }
330  else
331  // queue is clear and time passed, just update last resurrection time
333  }
334  else if (m_LastResurrectTime > 500) // Resurrect players only half a second later, to see spirit heal effect on NPC
335  {
336  for (std::vector<uint64>::iterator itr = m_ResurrectQueue.begin(); itr != m_ResurrectQueue.end(); ++itr)
337  {
338  Player* player = sObjectMgr.GetPlayer(*itr);
339  if (!player)
340  continue;
341  player->ResurrectPlayer(1.0f);
342  player->CastSpell(player, SPELL_SUMMON_PET, true);
343  player->CastSpell(player, SPELL_SPIRIT_HEAL_MANA, true);
345  }
346  m_ResurrectQueue.clear();
347  }
348 
349  /*********************************************************/
350  /*** BATTLEGROUND BALLANCE SYSTEM ***/
351  /*********************************************************/
352 
353  // if less then minimum players are in on one side, then start premature finish timer
355  {
357  {
358  m_PrematureCountDown = true;
359  m_PrematureCountDownTimer = sBattlegroundMgr.GetPrematureFinishTime();
360  }
361  else if (m_PrematureCountDownTimer < diff)
362  {
363  // time's up!
364  EndBattleground(0); // noone wins
365  m_PrematureCountDown = false;
366  }
367  else if (!sBattlegroundMgr.isTesting())
368  {
369  uint32 newtime = m_PrematureCountDownTimer - diff;
370  // announce every minute
371  if (newtime > (MINUTE * IN_MILLISECONDS))
372  {
373  if (newtime / (MINUTE * IN_MILLISECONDS) != m_PrematureCountDownTimer / (MINUTE * IN_MILLISECONDS))
375  }
376  else
377  {
378  //announce every 15 seconds
379  if (newtime / (15 * IN_MILLISECONDS) != m_PrematureCountDownTimer / (15 * IN_MILLISECONDS))
381  }
382  m_PrematureCountDownTimer = newtime;
383  }
384  }
385  else if (m_PrematureCountDown)
386  m_PrematureCountDown = false;
387 
388  /*********************************************************/
389  /*** BATTLEGROUND STARTING SYSTEM ***/
390  /*********************************************************/
391 
393  {
394  ModifyStartDelayTime(diff);
395  _CheckSafePositions(diff);
396 
397  if (!(m_Events & BG_STARTING_EVENT_1))
398  {
400 
401  // setup here, only when at least one player has ported to the map
402  if (!SetupBattleground())
403  {
404  EndNow();
405  return;
406  }
407 
410  //first start warning - 2 or 1 minute
412  }
413  // After 1 minute or 30 seconds, warning is signalled
415  {
418  }
419  // After 30 or 15 seconds, warning is signalled
421  {
424  }
425  // delay expired (after 2 or 1 minute)
426  else if (GetStartDelayTime() <= 0 && !(m_Events & BG_STARTING_EVENT_4))
427  {
429 
431 
435 
436  //remove preparation
437  if (isArena())
438  {
439  for (BattlegroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr)
440  if (Player* plr = sObjectMgr.GetPlayer(itr->first))
442 
444  }
445  else
446  {
448 
449  for (BattlegroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr)
450  if (Player* plr = sObjectMgr.GetPlayer(itr->first))
452 
453  //Announce BG starting
454  Announce();
455  }
456  }
457  }
458 
459  /*********************************************************/
460  /*** BATTLEGROUND ENDING SYSTEM ***/
461  /*********************************************************/
462 
463  if (GetStatus() == STATUS_WAIT_LEAVE)
464  {
465  // remove all players from battleground after 2 minutes
466  m_EndTime += diff;
467  if (m_EndTime >= TIME_TO_AUTOREMOVE) // 2 minutes
468  {
469  for (std::map<uint64, BattlegroundPlayer>::iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
470  {
471  m_RemovedPlayers[itr->first] = 1; // add to remove list (BG)
472  }
473  // do not change any battleground's private variables
474  }
475  }
476 }
uint32 GetMinPlayersPerTeam() const
Definition: Battleground.h:355
uint32 GetPlayersSize() const
Definition: Battleground.h:499
uint32 m_StartMessageIds[BG_STARTING_EVENT_COUNT]
Definition: Battleground.h:728
void PSendMessageToAll(int32 entry, ChatMsg type, Player const *source,...)
void CheckArenaWinConditions()
std::map< uint64, std::vector< uint64 > > m_ReviveQueue
Definition: Battleground.h:720
Map * GetMap() const
Definition: Object.h:841
void SetStartDelayTime(int Time)
Definition: Battleground.h:441
void RemovePlayerFromResurrectQueue(uint64 player_guid)
uint32 m_EndTime
Definition: Battleground.h:741
void _CheckSafePositions(uint32 diff)
uint32 m_PrematureCountDownTimer
Definition: Battleground.h:755
bool IsPvP() const
Definition: Unit.h:1139
#define sLog
Log class singleton.
Definition: Log.h:187
void UpdatePvP(bool state, bool override=false)
Definition: Player.cpp:18373
virtual void RemovePlayerAtLeave(uint64 guid, bool Transport, bool SendPacket)
BattlegroundPlayerMap m_Players
Definition: Battleground.h:718
bool m_PrematureCountDown
Definition: Battleground.h:754
BattlegroundPlayerMap const & GetPlayers() const
Definition: Battleground.h:495
uint32 GetReviveQueueSize() const
Definition: Battleground.h:522
uint32 GetStatus() const
Definition: Battleground.h:317
uint32 m_StartTime
Definition: Battleground.h:739
#define sObjectMgr
Definition: ObjectMgr.h:1285
BattlegroundStartTimeIntervals m_StartDelayTimes[BG_STARTING_EVENT_COUNT]
Definition: Battleground.h:726
void RemoveAurasDueToSpell(uint32 spellId, Aura *except=NULL)
Definition: Unit.cpp:4371
bool isArena() const
Definition: Battleground.h:481
Definition: Common.h:179
virtual void StartingEventOpenDoors()
Definition: Battleground.h:294
virtual bool SetupBattleground()
Definition: Battleground.h:288
Creature * GetCreature(uint64 guid)
Definition: Map.cpp:2630
void PlaySoundToAll(uint32 SoundID)
const bool & IsInWorld() const
Definition: Object.h:135
uint32 m_LastResurrectTime
Definition: Battleground.h:742
virtual void StartingEventCloseDoors()
Definition: Battleground.h:293
void CastSpell(Unit *Victim, uint32 spellId, bool triggered, Item *castItem=NULL, Aura *triggeredByAura=NULL, uint64 originalCaster=0)
Definition: Unit.cpp:1223
void ResurrectPlayer(float restore_percent, bool applySickness=false)
Definition: Player.cpp:4151
uint32 GetRemovedPlayersSize() const
Definition: Battleground.h:503
ACE_UINT64 uint64
Definition: Define.h:70
#define sBattlegroundMgr
void SetStatus(uint32 Status)
Definition: Battleground.h:391
void EndBattleground(uint32 winner)
ACE_UINT32 uint32
Definition: Define.h:71
uint32 GetPlayersCountByTeam(uint32 Team) const
Definition: Battleground.h:613
void ModifyStartDelayTime(int diff)
Definition: Battleground.h:437
Corpse * ConvertCorpseForPlayer(uint64 player_guid, bool insignia=false)
Definition: Player.h:922
std::map< uint64, uint8 > m_RemovedPlayers
Definition: Battleground.h:760
std::vector< uint64 > m_ResurrectQueue
Definition: Battleground.h:759
void SendMessageToAll(int32 entry, ChatMsg type, Player const *source=NULL)
int GetStartDelayTime() const
Definition: Battleground.h:360
void Battleground::UpdatePlayerScore ( Player Source,
uint32  type,
uint32  value 
)
virtual

Reimplemented in BattlegroundAV, BattlegroundEY, BattlegroundAB, BattlegroundWS, and BattlegroundBE.

Definition at line 1353 of file Battleground.cpp.

References Object::GetGUID(), Player::RewardHonor(), SCORE_BONUS_HONOR, SCORE_DAMAGE_DONE, SCORE_DEATHS, SCORE_HEALING_DONE, SCORE_HONORABLE_KILLS, SCORE_KILLING_BLOWS, sLog, and value.

Referenced by BattlegroundBE::UpdatePlayerScore(), BattlegroundWS::UpdatePlayerScore(), BattlegroundAB::UpdatePlayerScore(), BattlegroundEY::UpdatePlayerScore(), and BattlegroundAV::UpdatePlayerScore().

1354 {
1355  //this procedure is called from virtual function implemented in bg subclass
1356  BattlegroundScoreMap::const_iterator itr = m_PlayerScores.find(Source->GetGUID());
1357 
1358  if (itr == m_PlayerScores.end()) // player not found...
1359  return;
1360 
1361  switch (type)
1362  {
1363  case SCORE_KILLING_BLOWS: // Killing blows
1364  itr->second->KillingBlows += value;
1365  break