diff options
Diffstat (limited to 'src/server/game/Battlegrounds/Battleground.cpp')
-rw-r--r-- | src/server/game/Battlegrounds/Battleground.cpp | 48 |
1 files changed, 36 insertions, 12 deletions
diff --git a/src/server/game/Battlegrounds/Battleground.cpp b/src/server/game/Battlegrounds/Battleground.cpp index 56788c7d520..910026e325f 100644 --- a/src/server/game/Battlegrounds/Battleground.cpp +++ b/src/server/game/Battlegrounds/Battleground.cpp @@ -35,6 +35,7 @@ #include "Language.h" #include "Log.h" #include "Map.h" +#include "MapUtils.h" #include "MiscPackets.h" #include "ObjectAccessor.h" #include "ObjectMgr.h" @@ -55,7 +56,7 @@ void Battleground::BroadcastWorker(Do& _do) _do(player); } -Battleground::Battleground(BattlegroundTemplate const* battlegroundTemplate) : _battlegroundTemplate(battlegroundTemplate), _pvpDifficultyEntry(nullptr) +Battleground::Battleground(BattlegroundTemplate const* battlegroundTemplate) : _battlegroundTemplate(battlegroundTemplate), _pvpDifficultyEntry(nullptr), _pvpStatIds(nullptr) { ASSERT(_battlegroundTemplate, "Nonexisting Battleground Template passed to battleground ctor!"); @@ -742,11 +743,11 @@ void Battleground::EndBattleground(uint32 winner) stmt->setUInt32(6, score->second->GetBonusHonor()); stmt->setUInt32(7, score->second->GetDamageDone()); stmt->setUInt32(8, score->second->GetHealingDone()); - stmt->setUInt32(9, score->second->GetAttr1()); - stmt->setUInt32(10, score->second->GetAttr2()); - stmt->setUInt32(11, score->second->GetAttr3()); - stmt->setUInt32(12, score->second->GetAttr4()); - stmt->setUInt32(13, score->second->GetAttr5()); + stmt->setUInt32(9, score->second->GetAttr(0)); + stmt->setUInt32(10, score->second->GetAttr(1)); + stmt->setUInt32(11, score->second->GetAttr(2)); + stmt->setUInt32(12, score->second->GetAttr(3)); + stmt->setUInt32(13, score->second->GetAttr(4)); CharacterDatabase.Execute(stmt); } @@ -1013,7 +1014,10 @@ void Battleground::AddPlayer(Player* player, BattlegroundQueueTypeId queueId) m_Players[player->GetGUID()] = bp; if (!isInBattleground) + { UpdatePlayersCountByTeam(team, false); // +1 player + PlayerScores[player->GetGUID()] = new BattlegroundScore(player->GetGUID(), player->GetBGTeam(), _pvpStatIds); + } WorldPackets::Battleground::BattlegroundPlayerJoined playerJoined; playerJoined.Guid = player->GetGUID(); @@ -1285,26 +1289,31 @@ void Battleground::BuildPvPLogDataPacket(WorldPackets::Battleground::PVPMatchSta pvpLogData.Statistics.reserve(GetPlayerScoresSize()); for (auto const& score : PlayerScores) { - WorldPackets::Battleground::PVPMatchStatistics::PVPMatchPlayerStatistics playerData; - score.second->BuildPvPLogPlayerDataPacket(playerData); - - if (Player* player = ObjectAccessor::GetPlayer(GetBgMap(), playerData.PlayerGUID)) + if (Player* player = ObjectAccessor::GetPlayer(GetBgMap(), score.first)) { + WorldPackets::Battleground::PVPMatchStatistics::PVPMatchPlayerStatistics playerData; + score.second->BuildPvPLogPlayerDataPacket(playerData); + playerData.IsInWorld = true; playerData.PrimaryTalentTree = AsUnderlyingType(player->GetPrimarySpecialization()); playerData.Sex = player->GetGender(); playerData.Race = player->GetRace(); playerData.Class = player->GetClass(); playerData.HonorLevel = player->GetHonorLevel(); - } - pvpLogData.Statistics.push_back(playerData); + pvpLogData.Statistics.push_back(playerData); + } } pvpLogData.PlayerCount[PVP_TEAM_HORDE] = int8(GetPlayersCountByTeam(HORDE)); pvpLogData.PlayerCount[PVP_TEAM_ALLIANCE] = int8(GetPlayersCountByTeam(ALLIANCE)); } +BattlegroundScore const* Battleground::GetBattlegroundScore(Player* player) const +{ + return Trinity::Containers::MapGetValuePtr(PlayerScores, player->GetGUID()); +} + bool Battleground::UpdatePlayerScore(Player* player, uint32 type, uint32 value, bool doAddHonor) { BattlegroundScoreMap::const_iterator itr = PlayerScores.find(player->GetGUID()); @@ -1319,6 +1328,12 @@ bool Battleground::UpdatePlayerScore(Player* player, uint32 type, uint32 value, return true; } +void Battleground::UpdatePvpStat(Player* player, uint32 pvpStatId, uint32 value) +{ + if (BattlegroundScore* score = Trinity::Containers::MapGetValuePtr(PlayerScores, player->GetGUID())) + score->UpdatePvpStat(pvpStatId, value); +} + 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*/, GOState goState) { // If the assert is called, means that BgObjects must be resized! @@ -1451,6 +1466,15 @@ uint32 Battleground::GetMapId() const return _battlegroundTemplate->BattlemasterEntry->MapID[0]; } +void Battleground::SetBgMap(BattlegroundMap* map) +{ + m_Map = map; + if (map) + _pvpStatIds = sDB2Manager.GetPVPStatIDsForMap(map->GetId()); + else + _pvpStatIds = nullptr; +} + void Battleground::SpawnBGObject(uint32 type, uint32 respawntime) { if (Map* map = FindBgMap()) |