aboutsummaryrefslogtreecommitdiff
path: root/src/game/BattleGround.cpp
diff options
context:
space:
mode:
authormaximius <none@none>2009-10-17 15:35:07 -0700
committermaximius <none@none>2009-10-17 15:35:07 -0700
commit26b5e033ffde3d161382fc9addbfa99738379641 (patch)
treea344f369ca32945f787a02dee35c3dbe342bed7e /src/game/BattleGround.cpp
parentf21f47005dcb6b76e1abc9f35fbcd03eed191bff (diff)
*Massive cleanup (\n\n -> \n, *\n -> \n, cleanup for(...) to for (...), and some other cleanups by hand)
*Fix a possible crash in Spell::DoAllEffectOnTarget --HG-- branch : trunk
Diffstat (limited to 'src/game/BattleGround.cpp')
-rw-r--r--src/game/BattleGround.cpp258
1 files changed, 0 insertions, 258 deletions
diff --git a/src/game/BattleGround.cpp b/src/game/BattleGround.cpp
index 3eb699472d8..92c82f620f5 100644
--- a/src/game/BattleGround.cpp
+++ b/src/game/BattleGround.cpp
@@ -17,12 +17,10 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-
#include "Player.h"
#include "ObjectMgr.h"
#include "World.h"
#include "WorldPacket.h"
-
#include "ArenaTeam.h"
#include "BattleGround.h"
#include "BattleGroundMgr.h"
@@ -36,7 +34,6 @@
#include "SpellAuras.h"
#include "Util.h"
-
namespace MaNGOS
{
class BattleGroundChatBuilder
@@ -47,17 +44,14 @@ namespace MaNGOS
void operator()(WorldPacket& data, int32 loc_idx)
{
char const* text = objmgr.GetMangosString(i_textId,loc_idx);
-
if (i_args)
{
// we need copy va_list before use or original va_list will corrupted
va_list ap;
va_copy(ap,*i_args);
-
char str [2048];
vsnprintf(str,2048,text, ap );
va_end(ap);
-
do_helper(data,&str[0]);
}
else
@@ -67,7 +61,6 @@ namespace MaNGOS
void do_helper(WorldPacket& data, char const* text)
{
uint64 target_guid = i_source ? i_source ->GetGUID() : 0;
-
data << uint8(i_msgtype);
data << uint32(LANG_UNIVERSAL);
data << uint64(target_guid); // there 0 for BG messages
@@ -77,13 +70,11 @@ namespace MaNGOS
data << text;
data << uint8(i_source ? i_source->chatTag() : uint8(0));
}
-
ChatMsg i_msgtype;
int32 i_textId;
Player const* i_source;
va_list* i_args;
};
-
class BattleGround2ChatBuilder
{
public:
@@ -94,12 +85,9 @@ namespace MaNGOS
char const* text = objmgr.GetMangosString(i_textId,loc_idx);
char const* arg1str = i_arg1 ? objmgr.GetMangosString(i_arg1,loc_idx) : "";
char const* arg2str = i_arg2 ? objmgr.GetMangosString(i_arg2,loc_idx) : "";
-
char str [2048];
snprintf(str,2048,text, arg1str, arg2str );
-
uint64 target_guid = i_source ? i_source ->GetGUID() : 0;
-
data << uint8(i_msgtype);
data << uint32(LANG_UNIVERSAL);
data << uint64(target_guid); // there 0 for BG messages
@@ -110,7 +98,6 @@ namespace MaNGOS
data << uint8(i_source ? i_source->chatTag() : uint8(0));
}
private:
-
ChatMsg i_msgtype;
int32 i_textId;
Player const* i_source;
@@ -118,7 +105,6 @@ namespace MaNGOS
int32 i_arg2;
};
} // namespace MaNGOS
-
template<class Do>
void BattleGround::BroadcastWorker(Do& _do)
{
@@ -126,7 +112,6 @@ void BattleGround::BroadcastWorker(Do& _do)
if (Player *plr = ObjectAccessor::FindPlayer(MAKE_NEW_GUID(itr->first, 0, HIGHGUID_PLAYER)))
_do(plr);
}
-
BattleGround::BattleGround()
{
m_TypeID = BattleGroundTypeId(0);
@@ -150,46 +135,32 @@ BattleGround::BattleGround()
m_LevelMax = 0;
m_InBGFreeSlotQueue = false;
m_SetDeleteThis = false;
-
m_MaxPlayersPerTeam = 0;
m_MaxPlayers = 0;
m_MinPlayersPerTeam = 0;
m_MinPlayers = 0;
-
m_MapId = 0;
-
m_TeamStartLocX[BG_TEAM_ALLIANCE] = 0;
m_TeamStartLocX[BG_TEAM_HORDE] = 0;
-
m_TeamStartLocY[BG_TEAM_ALLIANCE] = 0;
m_TeamStartLocY[BG_TEAM_HORDE] = 0;
-
m_TeamStartLocZ[BG_TEAM_ALLIANCE] = 0;
m_TeamStartLocZ[BG_TEAM_HORDE] = 0;
-
m_TeamStartLocO[BG_TEAM_ALLIANCE] = 0;
m_TeamStartLocO[BG_TEAM_HORDE] = 0;
-
m_ArenaTeamIds[BG_TEAM_ALLIANCE] = 0;
m_ArenaTeamIds[BG_TEAM_HORDE] = 0;
-
m_ArenaTeamRatingChanges[BG_TEAM_ALLIANCE] = 0;
m_ArenaTeamRatingChanges[BG_TEAM_HORDE] = 0;
-
m_BgRaids[BG_TEAM_ALLIANCE] = NULL;
m_BgRaids[BG_TEAM_HORDE] = NULL;
-
m_PlayersCount[BG_TEAM_ALLIANCE] = 0;
m_PlayersCount[BG_TEAM_HORDE] = 0;
-
m_TeamScores[BG_TEAM_ALLIANCE] = 0;
m_TeamScores[BG_TEAM_HORDE] = 0;
-
m_PrematureCountDown = false;
m_PrematureCountDown = 0;
-
m_HonorMode = BG_NORMAL;
-
m_StartDelayTimes[BG_STARTING_EVENT_FIRST] = BG_START_DELAY_2M;
m_StartDelayTimes[BG_STARTING_EVENT_SECOND] = BG_START_DELAY_1M;
m_StartDelayTimes[BG_STARTING_EVENT_THIRD] = BG_START_DELAY_30S;
@@ -200,7 +171,6 @@ BattleGround::BattleGround()
m_StartMessageIds[BG_STARTING_EVENT_THIRD] = LANG_BG_WS_START_HALF_MINUTE;
m_StartMessageIds[BG_STARTING_EVENT_FOURTH] = LANG_BG_WS_HAS_BEGUN;
}
-
BattleGround::~BattleGround()
{
// remove objects and creatures
@@ -208,11 +178,9 @@ BattleGround::~BattleGround()
int size = m_BgCreatures.size();
for(int i = 0; i < size; ++i)
DelCreature(i);
-
size = m_BgObjects.size();
for(int i = 0; i < size; ++i)
DelObject(i);
-
if (GetInstanceID()) // not spam by useless queries in case BG templates
{
// delete creature and go respawn times
@@ -222,7 +190,6 @@ BattleGround::~BattleGround()
CharacterDatabase.PExecute("DELETE FROM instance WHERE id = '%u'",GetInstanceID());
// remove from battlegrounds
}
-
sBattleGroundMgr.RemoveBattleGround(GetInstanceID(), GetTypeID());
// unload map
if (Map * map = MapManager::Instance().FindMap(GetMapId(), GetInstanceID()))
@@ -230,11 +197,9 @@ BattleGround::~BattleGround()
((BattleGroundMap*)map)->SetUnload();
// remove from bg free slot queue
this->RemoveFromBGFreeSlotQueue();
-
for(BattleGroundScoreMap::const_iterator itr = m_PlayerScores.begin(); itr != m_PlayerScores.end(); ++itr)
delete itr->second;
}
-
void BattleGround::Update(uint32 diff)
{
if (!GetPlayersSize())
@@ -253,7 +218,6 @@ void BattleGround::Update(uint32 diff)
m_SetDeleteThis = true;
return;
}
-
// remove offline players from bg after 5 minutes
if (!m_OfflineQueue.empty())
{
@@ -268,11 +232,9 @@ void BattleGround::Update(uint32 diff)
}
}
}
-
/*********************************************************/
/*** BATTLEGROUND RESSURECTION SYSTEM ***/
/*********************************************************/
-
//this should be handled by spell system
m_LastResurrectTime += diff;
if (m_LastResurrectTime >= RESURRECTION_INTERVAL)
@@ -287,7 +249,6 @@ void BattleGround::Update(uint32 diff)
Player *plr = objmgr.GetPlayer(*itr2);
if (!plr)
continue;
-
if (!sh && plr->IsInWorld())
{
sh = plr->GetMap()->GetCreature(itr->first);
@@ -296,14 +257,12 @@ void BattleGround::Update(uint32 diff)
// Spirit Heal, effect 117
sh->CastSpell(sh, SPELL_SPIRIT_HEAL, true);
}
-
// Resurrection visual
plr->CastSpell(plr, SPELL_RESURRECTION_VISUAL, true);
m_ResurrectQueue.push_back(*itr2);
}
(itr->second).clear();
}
-
m_ReviveQueue.clear();
m_LastResurrectTime = 0;
}
@@ -325,11 +284,9 @@ void BattleGround::Update(uint32 diff)
}
m_ResurrectQueue.clear();
}
-
/*********************************************************/
/*** BATTLEGROUND BALLANCE SYSTEM ***/
/*********************************************************/
-
// if less then minimum players are in on one side, then start premature finish timer
if (GetStatus() == STATUS_IN_PROGRESS && !isArena() && sBattleGroundMgr.GetPrematureFinishTime() && (GetPlayersCountByTeam(ALLIANCE) < GetMinPlayersPerTeam() || GetPlayersCountByTeam(HORDE) < GetMinPlayersPerTeam()))
{
@@ -346,7 +303,6 @@ void BattleGround::Update(uint32 diff)
winner = ALLIANCE;
else if (GetPlayersCountByTeam(HORDE) >= GetMinPlayersPerTeam())
winner = HORDE;
-
EndBattleGround(winner);
m_PrematureCountDown = false;
}
@@ -370,26 +326,21 @@ void BattleGround::Update(uint32 diff)
}
else if (m_PrematureCountDown)
m_PrematureCountDown = false;
-
/*********************************************************/
/*** BATTLEGROUND STARTING SYSTEM ***/
/*********************************************************/
-
if (GetStatus() == STATUS_WAIT_JOIN && GetPlayersSize())
{
ModifyStartDelayTime(diff);
-
if (!(m_Events & BG_STARTING_EVENT_1))
{
m_Events |= BG_STARTING_EVENT_1;
-
// setup here, only when at least one player has ported to the map
if (!SetupBattleGround())
{
EndNow();
return;
}
-
StartingEventCloseDoors();
SetStartDelayTime(m_StartDelayTimes[BG_STARTING_EVENT_FIRST]);
//first start warning - 2 or 1 minute
@@ -411,18 +362,14 @@ void BattleGround::Update(uint32 diff)
else if (GetStartDelayTime() <= 0 && !(m_Events & BG_STARTING_EVENT_4))
{
m_Events |= BG_STARTING_EVENT_4;
-
StartingEventOpenDoors();
-
SendMessageToAll(m_StartMessageIds[BG_STARTING_EVENT_FOURTH], CHAT_MSG_BG_SYSTEM_NEUTRAL);
SetStatus(STATUS_IN_PROGRESS);
SetStartDelayTime(m_StartDelayTimes[BG_STARTING_EVENT_FOURTH]);
-
//remove preparation
if (isArena())
{
//TODO : add arena sound PlaySoundToAll(SOUND_ARENA_START);
-
for(BattleGroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr)
if (Player *plr = objmgr.GetPlayer(itr->first))
{
@@ -443,14 +390,11 @@ void BattleGround::Update(uint32 diff)
++iter;
}
}
-
CheckArenaWinConditions();
}
else
{
-
PlaySoundToAll(SOUND_BG_START);
-
for(BattleGroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr)
if (Player* plr = objmgr.GetPlayer(itr->first))
plr->RemoveAurasDueToSpell(SPELL_PREPARATION);
@@ -462,11 +406,9 @@ void BattleGround::Update(uint32 diff)
}
}
}
-
/*********************************************************/
/*** BATTLEGROUND ENDING SYSTEM ***/
/*********************************************************/
-
if (GetStatus() == STATUS_WAIT_LEAVE)
{
// remove all players from battleground after 2 minutes
@@ -485,11 +427,9 @@ void BattleGround::Update(uint32 diff)
}
}
}
-
//update start time
m_StartTime += diff;
}
-
void BattleGround::SetTeamStartLoc(uint32 TeamID, float X, float Y, float Z, float O)
{
BattleGroundTeamId idx = GetTeamIndexByTeamId(TeamID);
@@ -498,7 +438,6 @@ void BattleGround::SetTeamStartLoc(uint32 TeamID, float X, float Y, float Z, flo
m_TeamStartLocZ[idx] = Z;
m_TeamStartLocO[idx] = O;
}
-
void BattleGround::SendPacketToAll(WorldPacket *packet)
{
for(BattleGroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
@@ -510,54 +449,43 @@ void BattleGround::SendPacketToAll(WorldPacket *packet)
sLog.outError("BattleGround: Player (GUID: %u) not found!", GUID_LOPART(itr->first));
}
}
-
void BattleGround::SendPacketToTeam(uint32 TeamID, WorldPacket *packet, Player *sender, bool self)
{
for(BattleGroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
{
Player *plr = objmgr.GetPlayer(itr->first);
-
if (!plr)
{
sLog.outError("BattleGround: Player (GUID: %u) not found!", GUID_LOPART(itr->first));
continue;
}
-
if (!self && sender == plr)
continue;
-
uint32 team = itr->second.Team;
if(!team) team = plr->GetTeam();
-
if (team == TeamID)
plr->GetSession()->SendPacket(packet);
}
}
-
void BattleGround::PlaySoundToAll(uint32 SoundID)
{
WorldPacket data;
sBattleGroundMgr.BuildPlaySoundPacket(&data, SoundID);
SendPacketToAll(&data);
}
-
void BattleGround::PlaySoundToTeam(uint32 SoundID, uint32 TeamID)
{
WorldPacket data;
-
for(BattleGroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
{
Player *plr = objmgr.GetPlayer(itr->first);
-
if (!plr)
{
sLog.outError("BattleGround: Player (GUID: %u) not found!", GUID_LOPART(itr->first));
continue;
}
-
uint32 team = itr->second.Team;
if(!team) team = plr->GetTeam();
-
if (team == TeamID)
{
sBattleGroundMgr.BuildPlaySoundPacket(&data, SoundID);
@@ -565,27 +493,22 @@ void BattleGround::PlaySoundToTeam(uint32 SoundID, uint32 TeamID)
}
}
}
-
void BattleGround::CastSpellOnTeam(uint32 SpellID, uint32 TeamID)
{
for(BattleGroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
{
Player *plr = objmgr.GetPlayer(itr->first);
-
if (!plr)
{
sLog.outError("BattleGround: Player (GUID: %u) not found!", GUID_LOPART(itr->first));
continue;
}
-
uint32 team = itr->second.Team;
if(!team) team = plr->GetTeam();
-
if (team == TeamID)
plr->CastSpell(plr, SpellID, true);
}
}
-
void BattleGround::YellToAll(Creature* creature, const char* text, uint32 language)
{
for(std::map<uint64, BattleGroundPlayer>::iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
@@ -602,102 +525,81 @@ void BattleGround::YellToAll(Creature* creature, const char* text, uint32 langua
}
}
-
void BattleGround::RewardHonorToTeam(uint32 Honor, uint32 TeamID)
{
for(BattleGroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
{
Player *plr = objmgr.GetPlayer(itr->first);
-
if (!plr)
{
sLog.outError("BattleGround: Player (GUID: %u) not found!", GUID_LOPART(itr->first));
continue;
}
-
uint32 team = itr->second.Team;
if(!team) team = plr->GetTeam();
-
if (team == TeamID)
UpdatePlayerScore(plr, SCORE_BONUS_HONOR, Honor);
}
}
-
void BattleGround::RewardReputationToTeam(uint32 faction_id, uint32 Reputation, uint32 TeamID)
{
FactionEntry const* factionEntry = sFactionStore.LookupEntry(faction_id);
-
if (!factionEntry)
return;
-
for(BattleGroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
{
Player *plr = objmgr.GetPlayer(itr->first);
-
if (!plr)
{
sLog.outError("BattleGround: Player (GUID: %u) not found!", GUID_LOPART(itr->first));
continue;
}
-
uint32 team = itr->second.Team;
if(!team) team = plr->GetTeam();
-
if (team == TeamID)
plr->GetReputationMgr().ModifyReputation(factionEntry, Reputation);
}
}
-
void BattleGround::UpdateWorldState(uint32 Field, uint32 Value)
{
WorldPacket data;
sBattleGroundMgr.BuildUpdateWorldStatePacket(&data, Field, Value);
SendPacketToAll(&data);
}
-
void BattleGround::UpdateWorldStateForPlayer(uint32 Field, uint32 Value, Player *Source)
{
WorldPacket data;
sBattleGroundMgr.BuildUpdateWorldStatePacket(&data, Field, Value);
Source->GetSession()->SendPacket(&data);
}
-
void BattleGround::EndBattleGround(uint32 winner)
{
this->RemoveFromBGFreeSlotQueue();
-
ArenaTeam * winner_arena_team = NULL;
ArenaTeam * loser_arena_team = NULL;
uint32 loser_rating = 0;
uint32 winner_rating = 0;
WorldPacket data;
int32 winmsg_id = 0;
-
if (winner == ALLIANCE)
{
winmsg_id = isBattleGround() ? LANG_BG_A_WINS : LANG_ARENA_GOLD_WINS;
-
PlaySoundToAll(SOUND_ALLIANCE_WINS); // alliance wins sound
-
SetWinner(WINNER_ALLIANCE);
}
else if (winner == HORDE)
{
winmsg_id = isBattleGround() ? LANG_BG_H_WINS : LANG_ARENA_GREEN_WINS;
-
PlaySoundToAll(SOUND_HORDE_WINS); // horde wins sound
-
SetWinner(WINNER_HORDE);
}
else
{
SetWinner(3);
}
-
SetStatus(STATUS_WAIT_LEAVE);
//we must set it this way, because end time is sent in packet!
m_EndTime = TIME_TO_AUTOREMOVE;
-
// arena rating calculation
if (isArena() && isRated())
{
@@ -720,12 +622,10 @@ void BattleGround::EndBattleGround(uint32 winner)
SetArenaTeamRatingChangeForTeam(HORDE, 0);
}
}
-
for(BattleGroundPlayerMap::iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
{
Player *plr = objmgr.GetPlayer(itr->first);
uint32 team = itr->second.Team;
-
if (!plr)
{
//if rated arena match - make member lost!
@@ -739,11 +639,9 @@ void BattleGround::EndBattleGround(uint32 winner)
sLog.outError("BattleGround: Player (GUID: %u) not found!", GUID_LOPART(itr->first));
continue;
}
-
// should remove spirit of redemption
if(plr->HasAuraType(SPELL_AURA_SPIRIT_OF_REDEMPTION))
plr->RemoveAurasByType(SPELL_AURA_MOD_SHAPESHIFT);
-
if (!plr->isAlive())
{
plr->ResurrectPlayer(1.0f);
@@ -754,10 +652,8 @@ void BattleGround::EndBattleGround(uint32 winner)
plr->CombatStop();
plr->getHostilRefManager().deleteReferences();
}
-
//this line is obsolete - team is set ALWAYS
//if(!team) team = plr->GetTeam();
-
// per player calculation
if (isArena() && isRated() && winner_arena_team && loser_arena_team && winner_arena_team != loser_arena_team)
{
@@ -767,18 +663,15 @@ void BattleGround::EndBattleGround(uint32 winner)
ArenaTeamMember* member = winner_arena_team->GetMember(plr->GetGUID());
if (member)
plr->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_WIN_RATED_ARENA, member->personal_rating);
-
winner_arena_team->MemberWon(plr,loser_rating);
}
else
{
loser_arena_team->MemberLost(plr,winner_rating);
-
// Arena lost => reset the win_rated_arena having the "no_loose" condition
plr->GetAchievementMgr().ResetAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_WIN_RATED_ARENA, ACHIEVEMENT_CRITERIA_CONDITION_NO_LOOSE);
}
}
-
if (team == winner)
{
RewardMark(plr,ITEM_WINNER_COUNT);
@@ -787,20 +680,15 @@ void BattleGround::EndBattleGround(uint32 winner)
}
else if(winner)
RewardMark(plr,ITEM_LOSER_COUNT);
-
plr->CombatStopWithPets(true);
-
BlockMovement(plr);
-
sBattleGroundMgr.BuildPvpLogDataPacket(&data, this);
plr->GetSession()->SendPacket(&data);
-
BattleGroundQueueTypeId bgQueueTypeId = BattleGroundMgr::BGQueueTypeId(GetTypeID(), GetArenaType());
sBattleGroundMgr.BuildBattleGroundStatusPacket(&data, this, plr->GetBattleGroundQueueIndex(bgQueueTypeId), STATUS_IN_PROGRESS, TIME_TO_AUTOREMOVE, GetStartTime(), GetArenaType());
plr->GetSession()->SendPacket(&data);
plr->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_BATTLEGROUND, 1);
}
-
if (isArena() && isRated() && winner_arena_team && loser_arena_team && winner_arena_team != loser_arena_team)
{
// update arena points only after increasing the player's match count!
@@ -814,17 +702,14 @@ void BattleGround::EndBattleGround(uint32 winner)
winner_arena_team->NotifyStatsChanged();
loser_arena_team->NotifyStatsChanged();
}
-
if (winmsg_id)
SendMessageToAll(winmsg_id, CHAT_MSG_BG_SYSTEM_NEUTRAL);
}
-
uint32 BattleGround::GetBonusHonorFromKill(uint32 kills) const
{
//variable kills means how many honorable kills you scored (so we need kills * honor_for_one_kill)
return MaNGOS::Honor::hk_honor_at_level(GetMaxLevel(), kills);
}
-
uint32 BattleGround::GetBattlemasterEntry() const
{
switch(GetTypeID())
@@ -837,7 +722,6 @@ uint32 BattleGround::GetBattlemasterEntry() const
default: return 0;
}
}
-
void BattleGround::RewardMark(Player *plr,uint32 count)
{
BattleGroundMarks mark;
@@ -858,75 +742,60 @@ void BattleGround::RewardMark(Player *plr,uint32 count)
default:
return;
}
-
//if (IsSpell)
// RewardSpellCast(plr,mark);
//else
RewardItem(plr,mark,count);
}
-
void BattleGround::RewardSpellCast(Player *plr, uint32 spell_id)
{
// 'Inactive' this aura prevents the player from gaining honor points and battleground tokens
if (plr->HasAura(SPELL_AURA_PLAYER_INACTIVE))
return;
-
SpellEntry const *spellInfo = sSpellStore.LookupEntry(spell_id);
if(!spellInfo)
{
sLog.outError("Battleground reward casting spell %u not exist.",spell_id);
return;
}
-
plr->CastSpell(plr, spellInfo, true);
}
-
void BattleGround::RewardItem(Player *plr, uint32 item_id, uint32 count)
{
// 'Inactive' this aura prevents the player from gaining honor points and battleground tokens
if (plr->HasAura(SPELL_AURA_PLAYER_INACTIVE))
return;
-
ItemPosCountVec dest;
uint32 no_space_count = 0;
uint8 msg = plr->CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, item_id, count, &no_space_count );
-
if( msg == EQUIP_ERR_ITEM_NOT_FOUND)
{
sLog.outErrorDb("Battleground reward item (Entry %u) not exist in `item_template`.",item_id);
return;
}
-
if( msg != EQUIP_ERR_OK ) // convert to possible store amount
count -= no_space_count;
-
if( count != 0 && !dest.empty()) // can add some
if (Item* item = plr->StoreNewItem( dest, item_id, true, 0))
plr->SendNewItem(item,count,true,false);
-
if (no_space_count > 0)
SendRewardMarkByMail(plr,item_id,no_space_count);
}
-
void BattleGround::SendRewardMarkByMail(Player *plr,uint32 mark, uint32 count)
{
uint32 bmEntry = GetBattlemasterEntry();
if (!bmEntry)
return;
-
ItemPrototype const* markProto = objmgr.GetItemPrototype(mark);
if (!markProto)
return;
-
if (Item* markItem = Item::CreateItem(mark,count,plr))
{
// save new item before send
markItem->SaveToDB(); // save for prevent lost at next mail load, if send fail then item will deleted
-
// item
MailItemsInfo mi;
mi.AddItem(markItem->GetGUIDLow(), markItem->GetEntry(), markItem);
-
// subject: item name
std::string subject = markProto->Name1;
int loc_idx = plr->GetSession()->GetSessionDbLocaleIndex();
@@ -934,17 +803,14 @@ void BattleGround::SendRewardMarkByMail(Player *plr,uint32 mark, uint32 count)
if (ItemLocale const *il = objmgr.GetItemLocale(markProto->ItemId))
if (il->Name.size() > size_t(loc_idx) && !il->Name[loc_idx].empty())
subject = il->Name[loc_idx];
-
// text
std::string textFormat = plr->GetSession()->GetTrinityString(LANG_BG_MARK_BY_MAIL);
char textBuf[300];
snprintf(textBuf,300,textFormat.c_str(),GetName(),GetName());
uint32 itemTextId = objmgr.CreateItemText( textBuf );
-
WorldSession::SendMailTo(plr, MAIL_CREATURE, MAIL_STATIONERY_NORMAL, bmEntry, plr->GetGUIDLow(), subject, itemTextId , &mi, 0, 0, MAIL_CHECK_MASK_NONE);
}
}
-
void BattleGround::RewardQuestComplete(Player *plr)
{
uint32 quest;
@@ -965,15 +831,12 @@ void BattleGround::RewardQuestComplete(Player *plr)
default:
return;
}
-
RewardSpellCast(plr, quest);
}
-
void BattleGround::BlockMovement(Player *plr)
{
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()
}
-
void BattleGround::RemovePlayerAtLeave(uint64 guid, bool Transport, bool SendPacket)
{
uint32 team = GetPlayerTeam(guid);
@@ -987,30 +850,23 @@ void BattleGround::RemovePlayerAtLeave(uint64 guid, bool Transport, bool SendPac
// check if the player was a participant of the match, or only entered through gm command (goname)
participant = true;
}
-
BattleGroundScoreMap::iterator itr2 = m_PlayerScores.find(guid);
if (itr2 != m_PlayerScores.end())
{
delete itr2->second; // delete player's score
m_PlayerScores.erase(itr2);
}
-
RemovePlayerFromResurrectQueue(guid);
-
Player *plr = objmgr.GetPlayer(guid);
-
// should remove spirit of redemption
if(plr && plr->HasAuraType(SPELL_AURA_SPIRIT_OF_REDEMPTION))
plr->RemoveAurasByType(SPELL_AURA_MOD_SHAPESHIFT);
-
if(plr && !plr->isAlive()) // resurrect on exit
{
plr->ResurrectPlayer(1.0f);
plr->SpawnCorpseBones();
}
-
RemovePlayer(plr, guid); // BG subclass specific code
-
if(participant) // if the player was a match participant, remove auras, calc rating, update queue
{
BattleGroundTypeId bgTypeId = GetTypeID();
@@ -1018,19 +874,15 @@ void BattleGround::RemovePlayerAtLeave(uint64 guid, bool Transport, bool SendPac
if (plr)
{
plr->ClearAfkReports();
-
if(!team) team = plr->GetTeam();
-
// if arena, remove the specific arena auras
if (isArena())
{
plr->RemoveArenaAuras(true); // removes debuffs / dots etc., we don't want the player to die after porting out
bgTypeId=BATTLEGROUND_AA; // set the bg type to all arenas (it will be used for queue refreshing)
-
// unsummon current and summon old pet if there was one and there isn't a current pet
plr->RemovePet(NULL, PET_SAVE_NOT_IN_SLOT);
plr->ResummonPetTemporaryUnSummonedIfAny();
-
if (isRated() && GetStatus() == STATUS_IN_PROGRESS)
{
//left a rated match while the encounter was in progress, consider as loser
@@ -1046,7 +898,6 @@ void BattleGround::RemovePlayerAtLeave(uint64 guid, bool Transport, bool SendPac
sBattleGroundMgr.BuildBattleGroundStatusPacket(&data, this, plr->GetBattleGroundQueueIndex(bgQueueTypeId), STATUS_NONE, 0, 0, 0);
plr->GetSession()->SendPacket(&data);
}
-
// this call is important, because player, when joins to battleground, this method is not called, so it must be called when leaving bg
plr->RemoveBattleGroundQueueId(bgQueueTypeId);
}
@@ -1062,7 +913,6 @@ void BattleGround::RemovePlayerAtLeave(uint64 guid, bool Transport, bool SendPac
players_arena_team->OfflineMemberLost(guid, others_arena_team->GetRating());
}
}
-
// remove from raid group if player is member
if (Group *group = GetBgRaid(team))
{
@@ -1085,23 +935,18 @@ void BattleGround::RemovePlayerAtLeave(uint64 guid, bool Transport, bool SendPac
sBattleGroundMgr.BuildPlayerLeftBattleGroundPacket(&data, guid);
SendPacketToTeam(team, &data, plr, false);
}
-
if (plr)
{
// Do next only if found in battleground
plr->SetBattleGroundId(0, BATTLEGROUND_TYPE_NONE); // We're not in BG.
// reset destination bg team
plr->SetBGTeam(0);
-
if (Transport)
plr->TeleportToBGEntryPoint();
-
sLog.outDetail("BATTLEGROUND: Removed player %s from BattleGround.", plr->GetName());
}
-
//battleground object will be deleted next BattleGround::Update() call
}
-
// this method is called when no players remains in battleground
void BattleGround::Reset()
{
@@ -1113,32 +958,24 @@ void BattleGround::Reset()
SetLastResurrectTime(0);
SetArenaType(0);
SetRated(false);
-
m_Events = 0;
-
if (m_InvitedAlliance > 0 || m_InvitedHorde > 0)
sLog.outError("BattleGround system: bad counter, m_InvitedAlliance: %d, m_InvitedHorde: %d", m_InvitedAlliance, m_InvitedHorde);
-
m_InvitedAlliance = 0;
m_InvitedHorde = 0;
m_InBGFreeSlotQueue = false;
-
m_Players.clear();
-
for(BattleGroundScoreMap::const_iterator itr = m_PlayerScores.begin(); itr != m_PlayerScores.end(); ++itr)
delete itr->second;
m_PlayerScores.clear();
-
ResetBGSubclass();
}
-
void BattleGround::StartBattleGround()
{
SetStartTime(0);
SetLastResurrectTime(0);
// add BG to free slot queue
AddToBGFreeSlotQueue();
-
// add bg to update list
// This must be done here, because we need to have already invited some players when first BG::Update() method is executed
// and it doesn't matter if we call StartBattleGround() more times, because m_BattleGrounds is a map and instance id never changes
@@ -1146,31 +983,23 @@ void BattleGround::StartBattleGround()
if(m_IsRated)
sLog.outArena("Arena match type: %u for Team1Id: %u - Team2Id: %u started.", m_ArenaType, m_ArenaTeamIds[BG_TEAM_ALLIANCE], m_ArenaTeamIds[BG_TEAM_HORDE]);
}
-
void BattleGround::AddPlayer(Player *plr)
{
// remove afk from player
if (plr->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_AFK))
plr->ToggleAFK();
-
// score struct must be created in inherited class
-
uint64 guid = plr->GetGUID();
uint32 team = plr->GetBGTeam();
-
BattleGroundPlayer bp;
bp.OfflineRemoveTime = 0;
bp.Team = team;
-
// Add to list/maps
m_Players[guid] = bp;
-
UpdatePlayersCountByTeam(team, false); // +1 player
-
WorldPacket data;
sBattleGroundMgr.BuildPlayerJoinedBattleGroundPacket(&data, plr);
SendPacketToTeam(team, &data, plr, false);
-
// add arena specific auras
if (isArena())
{
@@ -1191,14 +1020,11 @@ void BattleGround::AddPlayer(Player *plr)
else
plr->CastSpell(plr, SPELL_ALLIANCE_GREEN_FLAG,true);
}
-
plr->DestroyConjuredItems(true);
plr->UnsummonPetTemporaryIfAny();
-
if(GetStatus() == STATUS_WAIT_JOIN) // not started yet
{
plr->CastSpell(plr, SPELL_ARENA_PREPARATION, true);
-
plr->SetHealth(plr->GetMaxHealth());
plr->SetPower(POWER_MANA, plr->GetMaxPower(POWER_MANA));
}
@@ -1208,18 +1034,14 @@ void BattleGround::AddPlayer(Player *plr)
if(GetStatus() == STATUS_WAIT_JOIN) // not started yet
plr->CastSpell(plr, SPELL_PREPARATION, true); // reduces all mana cost of spells.
}
-
plr->GetAchievementMgr().ResetAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HEALING_DONE, ACHIEVEMENT_CRITERIA_CONDITION_MAP, GetMapId());
plr->GetAchievementMgr().ResetAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_DAMAGE_DONE, ACHIEVEMENT_CRITERIA_CONDITION_MAP, GetMapId());
-
// setup BG group membership
PlayerAddedToBGCheckIfBGIsRunning(plr);
AddOrSetPlayerToCorrectBgGroup(plr, guid, team);
-
// Log
sLog.outDetail("BATTLEGROUND: Player %s joined the battle.", plr->GetName());
}
-
/* this method adds player to his team's bg group, or sets his correct group if player is already in bg group */
void BattleGround::AddOrSetPlayerToCorrectBgGroup(Player *plr, uint64 plr_guid, uint32 team)
{
@@ -1246,7 +1068,6 @@ void BattleGround::AddOrSetPlayerToCorrectBgGroup(Player *plr, uint64 plr_guid,
}
}
}
-
// This method should be called when player logs into running battleground
void BattleGround::EventPlayerLoggedIn(Player* player, uint64 plr_guid)
{
@@ -1264,7 +1085,6 @@ void BattleGround::EventPlayerLoggedIn(Player* player, uint64 plr_guid)
// if battleground is starting, then add preparation aura
// we don't have to do that, because preparation aura isn't removed when player logs out
}
-
// This method should be called when player logs out from running battleground
void BattleGround::EventPlayerLoggedOut(Player* player)
{
@@ -1283,7 +1103,6 @@ void BattleGround::EventPlayerLoggedOut(Player* player)
}
}
}
-
/* This method should be called only once ... it adds pointer to queue */
void BattleGround::AddToBGFreeSlotQueue()
{
@@ -1294,7 +1113,6 @@ void BattleGround::AddToBGFreeSlotQueue()
m_InBGFreeSlotQueue = true;
}
}
-
/* This method removes this battleground from free queue - it must be called when deleting battleground - not used now*/
void BattleGround::RemoveFromBGFreeSlotQueue()
{
@@ -1310,7 +1128,6 @@ void BattleGround::RemoveFromBGFreeSlotQueue()
}
}
}
-
// get the number of free slots for team
// returns the number how many players can join battleground to MaxPlayersPerTeam
uint32 BattleGround::GetFreeSlotsForTeam(uint32 Team) const
@@ -1342,7 +1159,6 @@ uint32 BattleGround::GetFreeSlotsForTeam(uint32 Team) const
// allow join more ppl if the other side has more players
else if(otherTeam > GetInvitedCount(Team))
diff = otherTeam - GetInvitedCount(Team);
-
// difference based on max players per team (don't allow inviting more)
uint32 diff2 = (GetInvitedCount(Team) < GetMaxPlayersPerTeam()) ? GetMaxPlayersPerTeam() - GetInvitedCount(Team) : 0;
// difference based on players who already entered
@@ -1357,9 +1173,7 @@ uint32 BattleGround::GetFreeSlotsForTeam(uint32 Team) const
// or other side has less than minPlayersPerTeam
else if (GetInvitedCount(Team) <= GetMinPlayersPerTeam())
diff3 = GetMinPlayersPerTeam() - GetInvitedCount(Team) + 1;
-
// return the minimum of the 3 differences
-
// min of diff and diff 2
diff = diff < diff2 ? diff : diff2;
// min of diff, diff2 and diff3
@@ -1367,20 +1181,16 @@ uint32 BattleGround::GetFreeSlotsForTeam(uint32 Team) const
}
return 0;
}
-
bool BattleGround::HasFreeSlots() const
{
return GetPlayersSize() < GetMaxPlayers();
}
-
void BattleGround::UpdatePlayerScore(Player *Source, uint32 type, uint32 value)
{
//this procedure is called from virtual function implemented in bg subclass
BattleGroundScoreMap::const_iterator itr = m_PlayerScores.find(Source->GetGUID());
-
if(itr == m_PlayerScores.end()) // player not found...
return;
-
switch(type)
{
case SCORE_KILLING_BLOWS: // Killing blows
@@ -1413,18 +1223,14 @@ void BattleGround::UpdatePlayerScore(Player *Source, uint32 type, uint32 value)
break;
}
}
-
void BattleGround::AddPlayerToResurrectQueue(uint64 npc_guid, uint64 player_guid)
{
m_ReviveQueue[npc_guid].push_back(player_guid);
-
Player *plr = objmgr.GetPlayer(player_guid);
if (!plr)
return;
-
plr->CastSpell(plr, SPELL_WAITING_FOR_RESURRECT, true);
}
-
void BattleGround::RemovePlayerFromResurrectQueue(uint64 player_guid)
{
for(std::map<uint64, std::vector<uint64> >::iterator itr = m_ReviveQueue.begin(); itr != m_ReviveQueue.end(); ++itr)
@@ -1434,25 +1240,20 @@ void BattleGround::RemovePlayerFromResurrectQueue(uint64 player_guid)
if (*itr2 == player_guid)
{
(itr->second).erase(itr2);
-
Player *plr = objmgr.GetPlayer(player_guid);
if (!plr)
return;
-
plr->RemoveAurasDueToSpell(SPELL_WAITING_FOR_RESURRECT);
-
return;
}
}
}
}
-
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)
{
Map * map = MapManager::Instance().FindMap(GetMapId(),GetInstanceID());
if (!map)
return false;
-
// must be created this way, adding to godatamap would add it to the base map of the instance
// and when loading it (in go::LoadFromDB()), a new guid would be assigned to the object, and a new object would be created
// so we must create it specific for this instance
@@ -1467,11 +1268,9 @@ bool BattleGround::AddObject(uint32 type, uint32 entry, float x, float y, float
}
/*
uint32 guid = go->GetGUIDLow();
-
// without this, UseButtonOrDoor caused the crash, since it tried to get go info from godata
// 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
GameObjectData& data = objmgr.NewGOData(guid);
-
data.id = entry;
data.mapid = GetMapId();
data.posX = x;
@@ -1492,7 +1291,6 @@ bool BattleGround::AddObject(uint32 type, uint32 entry, float x, float y, float
m_BgObjects[type] = go->GetGUID();
return true;
}
-
//some doors aren't despawned so we cannot handle their closing in gameobject::update()
//it would be nice to correctly implement GO_ACTIVATED state and open/close doors in gameobject code
void BattleGround::DoorClose(uint32 type)
@@ -1513,7 +1311,6 @@ void BattleGround::DoorClose(uint32 type)
sLog.outError("BattleGround: Door object not found (cannot close doors)");
}
}
-
void BattleGround::DoorOpen(uint32 type)
{
GameObject *obj = HashMapHolder<GameObject>::Find(m_BgObjects[type]);
@@ -1528,7 +1325,6 @@ void BattleGround::DoorOpen(uint32 type)
sLog.outError("BattleGround: Door object not found! - doors will be closed.");
}
}
-
GameObject* BattleGround::GetBGObject(uint32 type)
{
GameObject *obj = HashMapHolder<GameObject>::Find(m_BgObjects[type]);
@@ -1536,7 +1332,6 @@ GameObject* BattleGround::GetBGObject(uint32 type)
sLog.outError("couldn't get gameobject %i",type);
return obj;
}
-
Creature* BattleGround::GetBGCreature(uint32 type)
{
Creature *creature = HashMapHolder<Creature>::Find(m_BgCreatures[type]);
@@ -1544,7 +1339,6 @@ Creature* BattleGround::GetBGCreature(uint32 type)
sLog.outError("couldn't get creature %i",type);
return creature;
}
-
void BattleGround::SpawnBGObject(uint32 type, uint32 respawntime)
{
Map * map = MapManager::Instance().FindMap(GetMapId(),GetInstanceID());
@@ -1573,13 +1367,11 @@ void BattleGround::SpawnBGObject(uint32 type, uint32 respawntime)
}
}
}
-
Creature* BattleGround::AddCreature(uint32 entry, uint32 type, uint32 teamval, float x, float y, float z, float o, uint32 respawntime)
{
Map * map = MapManager::Instance().FindMap(GetMapId(),GetInstanceID());
if (!map)
return NULL;
-
Creature* pCreature = new Creature;
if (!pCreature->Create(objmgr.GenerateLowGuid(HIGHGUID_UNIT), map, PHASEMASK_NORMAL, entry, 0, teamval, x, y, z, o))
{
@@ -1587,14 +1379,10 @@ Creature* BattleGround::AddCreature(uint32 entry, uint32 type, uint32 teamval, f
delete pCreature;
return NULL;
}
-
pCreature->SetHomePosition(x, y, z, o);
-
//pCreature->SetDungeonDifficulty(0);
-
map->Add(pCreature);
m_BgCreatures[type] = pCreature->GetGUID();
-
return pCreature;
}
/*
@@ -1603,7 +1391,6 @@ void BattleGround::SpawnBGCreature(uint32 type, uint32 respawntime)
Map * map = MapManager::Instance().FindMap(GetMapId(),GetInstanceId());
if (!map)
return false;
-
if (respawntime == 0)
{
Creature *obj = HashMapHolder<Creature>::Find(m_BgCreatures[type]);
@@ -1631,7 +1418,6 @@ bool BattleGround::DelCreature(uint32 type)
{
if (!m_BgCreatures[type])
return true;
-
Creature *cr = HashMapHolder<Creature>::Find(m_BgCreatures[type]);
if (!cr)
{
@@ -1642,12 +1428,10 @@ bool BattleGround::DelCreature(uint32 type)
m_BgCreatures[type] = 0;
return true;
}
-
bool BattleGround::DelObject(uint32 type)
{
if (!m_BgObjects[type])
return true;
-
GameObject *obj = HashMapHolder<GameObject>::Find(m_BgObjects[type]);
if (!obj)
{
@@ -1659,16 +1443,13 @@ bool BattleGround::DelObject(uint32 type)
m_BgObjects[type] = 0;
return true;
}
-
bool BattleGround::AddSpiritGuide(uint32 type, float x, float y, float z, float o, uint32 team)
{
uint32 entry = 0;
-
if (team == ALLIANCE)
entry = BG_CREATURE_ENTRY_A_SPIRITGUIDE;
else
entry = BG_CREATURE_ENTRY_H_SPIRITGUIDE;
-
Creature* pCreature = AddCreature(entry,type,team,x,y,z,o);
if (!pCreature)
{
@@ -1676,14 +1457,11 @@ bool BattleGround::AddSpiritGuide(uint32 type, float x, float y, float z, float
EndNow();
return false;
}
-
pCreature->setDeathState(DEAD);
-
pCreature->SetUInt64Value(UNIT_FIELD_CHANNEL_OBJECT, pCreature->GetGUID());
// aura
//TODO: Fix display here
//pCreature->SetVisibleAura(0, SPELL_SPIRIT_HEAL_CHANNEL);
-
//pCreature->SetUInt32Value(UNIT_FIELD_AURAFLAGS, 0x00000009);
//pCreature->SetUInt32Value(UNIT_FIELD_AURALEVELS, 0x0000003C);
//pCreature->SetUInt32Value(UNIT_FIELD_AURAAPPLICATIONS, 0x000000FF);
@@ -1691,52 +1469,42 @@ bool BattleGround::AddSpiritGuide(uint32 type, float x, float y, float z, float
pCreature->SetUInt32Value(UNIT_CHANNEL_SPELL, SPELL_SPIRIT_HEAL_CHANNEL);
// correct cast speed
pCreature->SetFloatValue(UNIT_MOD_CAST_SPEED, 1.0f);
-
//pCreature->CastSpell(pCreature, SPELL_SPIRIT_HEAL_CHANNEL, true);
-
return true;
}
-
void BattleGround::SendMessageToAll(int32 entry, ChatMsg type, Player const* source)
{
MaNGOS::BattleGroundChatBuilder bg_builder(type, entry, source);
MaNGOS::LocalizedPacketDo<MaNGOS::BattleGroundChatBuilder> bg_do(bg_builder);
BroadcastWorker(bg_do);
}
-
void BattleGround::PSendMessageToAll(int32 entry, ChatMsg type, Player const* source, ...)
{
va_list ap;
va_start(ap, source);
-
MaNGOS::BattleGroundChatBuilder bg_builder(type, entry, source, &ap);
MaNGOS::LocalizedPacketDo<MaNGOS::BattleGroundChatBuilder> bg_do(bg_builder);
BroadcastWorker(bg_do);
-
va_end(ap);
}
-
void BattleGround::SendMessage2ToAll(int32 entry, ChatMsg type, Player const* source, int32 arg1, int32 arg2)
{
MaNGOS::BattleGround2ChatBuilder bg_builder(type, entry, source, arg1, arg2);
MaNGOS::LocalizedPacketDo<MaNGOS::BattleGround2ChatBuilder> bg_do(bg_builder);
BroadcastWorker(bg_do);
}
-
void BattleGround::EndNow()
{
RemoveFromBGFreeSlotQueue();
SetStatus(STATUS_WAIT_LEAVE);
SetEndTime(0);
}
-
//to be removed
const char *BattleGround::GetTrinityString(int32 entry)
{
// FIXME: now we have different DBC locales and need localized message for each target client
return objmgr.GetTrinityStringForDBCLocale(entry);
}
-
/*
important notice:
buffs aren't spawned/despawned when players captures anything
@@ -1747,7 +1515,6 @@ void BattleGround::HandleTriggerBuff(uint64 const& go_guid)
GameObject *obj = HashMapHolder<GameObject>::Find(go_guid);
if (!obj || obj->GetGoType() != GAMEOBJECT_TYPE_TRAP || !obj->isSpawned())
return;
-
//change buff type, when buff is used:
int32 index = m_BgObjects.size() - 1;
while (index >= 0 && m_BgObjects[index] != go_guid)
@@ -1757,7 +1524,6 @@ void BattleGround::HandleTriggerBuff(uint64 const& go_guid)
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());
return;
}
-
//randomly select new buff
uint8 buff = urand(0, 2);
uint32 entry = obj->GetEntry();
@@ -1773,40 +1539,31 @@ void BattleGround::HandleTriggerBuff(uint64 const& go_guid)
index += buff;
}
}
-
SpawnBGObject(index, BUFF_RESPAWN_TIME);
}
-
void BattleGround::HandleKillPlayer( Player *player, Player *killer )
{
//keep in mind that for arena this will have to be changed a bit
-
// add +1 deaths
UpdatePlayerScore(player, SCORE_DEATHS, 1);
-
// add +1 kills to group and +1 killing_blows to killer
if (killer)
{
UpdatePlayerScore(killer, SCORE_HONORABLE_KILLS, 1);
UpdatePlayerScore(killer, SCORE_KILLING_BLOWS, 1);
-
for(BattleGroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
{
Player *plr = objmgr.GetPlayer(itr->first);
-
if (!plr || plr == killer)
continue;
-
if (plr->GetTeam() == killer->GetTeam() && plr->IsAtGroupRewardDistance(player))
UpdatePlayerScore(plr, SCORE_HONORABLE_KILLS, 1);
}
}
-
// to be able to remove insignia -- ONLY IN BattleGrounds
if (!isArena())
player->SetFlag( UNIT_FIELD_FLAGS, UNIT_FLAG_SKINNABLE );
}
-
// return the player's team based on battlegroundplayer info
// used in same faction arena matches mainly
uint32 BattleGround::GetPlayerTeam(uint64 guid)
@@ -1816,12 +1573,10 @@ uint32 BattleGround::GetPlayerTeam(uint64 guid)
return itr->second.Team;
return 0;
}
-
uint32 BattleGround::GetOtherTeam(uint32 teamId)
{
return (teamId) ? ((teamId == ALLIANCE) ? HORDE : ALLIANCE) : 0;
}
-
bool BattleGround::IsPlayerInBattleGround(uint64 guid)
{
BattleGroundPlayerMap::const_iterator itr = m_Players.find(guid);
@@ -1829,24 +1584,18 @@ bool BattleGround::IsPlayerInBattleGround(uint64 guid)
return true;
return false;
}
-
void BattleGround::PlayerAddedToBGCheckIfBGIsRunning(Player* plr)
{
if (GetStatus() != STATUS_WAIT_LEAVE)
return;
-
WorldPacket data;
BattleGroundQueueTypeId bgQueueTypeId = BattleGroundMgr::BGQueueTypeId(GetTypeID(), GetArenaType());
-
BlockMovement(plr);
-
sBattleGroundMgr.BuildPvpLogDataPacket(&data, this);
plr->GetSession()->SendPacket(&data);
-
sBattleGroundMgr.BuildBattleGroundStatusPacket(&data, this, plr->GetBattleGroundQueueIndex(bgQueueTypeId), STATUS_IN_PROGRESS, GetEndTime(), GetStartTime(), GetArenaType());
plr->GetSession()->SendPacket(&data);
}
-
uint32 BattleGround::GetAlivePlayersCountByTeam(uint32 Team) const
{
int count = 0;
@@ -1861,7 +1610,6 @@ uint32 BattleGround::GetAlivePlayersCountByTeam(uint32 Team) const
}
return count;
}
-
void BattleGround::SetHoliday(bool is_holiday)
{
if(is_holiday)
@@ -1869,7 +1617,6 @@ void BattleGround::SetHoliday(bool is_holiday)
else
m_HonorMode = BG_NORMAL;
}
-
int32 BattleGround::GetObjectType(uint64 guid)
{
for(uint32 i = 0; i < m_BgObjects.size(); ++i)
@@ -1878,11 +1625,9 @@ int32 BattleGround::GetObjectType(uint64 guid)
sLog.outError("BattleGround: cheating? a player used a gameobject which isnt supposed to be a usable object!");
return -1;
}
-
void BattleGround::HandleKillUnit(Creature *creature, Player *killer)
{
}
-
void BattleGround::CheckArenaWinConditions()
{
if (!GetAlivePlayersCountByTeam(ALLIANCE) && GetPlayersCountByTeam(HORDE))
@@ -1890,7 +1635,6 @@ void BattleGround::CheckArenaWinConditions()
else if (GetPlayersCountByTeam(ALLIANCE) && !GetAlivePlayersCountByTeam(HORDE))
EndBattleGround(ALLIANCE);
}
-
void BattleGround::SetBgRaid( uint32 TeamID, Group *bg_raid )
{
Group* &old_raid = TeamID == ALLIANCE ? m_BgRaids[BG_TEAM_ALLIANCE] : m_BgRaids[BG_TEAM_HORDE];
@@ -1898,12 +1642,10 @@ void BattleGround::SetBgRaid( uint32 TeamID, Group *bg_raid )
if(bg_raid) bg_raid->SetBattlegroundGroup(this);
old_raid = bg_raid;
}
-
WorldSafeLocsEntry const* BattleGround::GetClosestGraveYard( Player* player )
{
return objmgr.GetClosestGraveYard( player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetMapId(), player->GetTeam() );
}
-
bool BattleGround::IsTeamScoreInRange(uint32 team, uint32 minScore, uint32 maxScore) const
{
BattleGroundTeamId team_idx = GetTeamIndexByTeamId(team);