diff options
38 files changed, 1014 insertions, 784 deletions
diff --git a/sql/updates/world/2014_06_28_00_world_misc.sql b/sql/updates/world/2014_06_28_00_world_misc.sql new file mode 100644 index 00000000000..a960642b8fb --- /dev/null +++ b/sql/updates/world/2014_06_28_00_world_misc.sql @@ -0,0 +1,7 @@ +-- +SET @CGUID:= 43496; +DELETE FROM `game_graveyard_zone` WHERE `id`=2; +INSERT INTO `game_graveyard_zone` (`id`, `ghost_zone`, `faction`) VALUES (2, 44, 469); + +INSERT INTO `creature` (`guid`,`id`,`map`,`spawnMask`,`phaseMask`,`position_x`,`position_y`,`position_z`,`orientation`,`spawntimesecs`,`spawndist`,`currentwaypoint`) VALUES +(@CGUID, 6491, 0, 1, 1, -9190.865, -2308.829, 89.63705, 4.13643, 120, 0, 0); -- 6491 (Area: 44) diff --git a/sql/updates/world/2014_06_28_00_world_smart_scripts.sql b/sql/updates/world/2014_06_28_00_world_smart_scripts.sql new file mode 100644 index 00000000000..96ac504bc09 --- /dev/null +++ b/sql/updates/world/2014_06_28_00_world_smart_scripts.sql @@ -0,0 +1,3 @@ +-- +UPDATE `smart_scripts` SET `link`=0 WHERE `entryorguid`=27245 AND `source_type`=0 AND `id`=2 AND `link`=3; +UPDATE `smart_scripts` SET `link`=0 WHERE `entryorguid`=4987 AND `source_type`=2 AND `id`=0 AND `link`=1; diff --git a/sql/updates/world/2014_06_28_02_world_misc.sql b/sql/updates/world/2014_06_28_02_world_misc.sql new file mode 100644 index 00000000000..017116f41e3 --- /dev/null +++ b/sql/updates/world/2014_06_28_02_world_misc.sql @@ -0,0 +1,83 @@ +-- +SET @CGUID:= 78207; -- needs 8 + +DELETE FROM `vehicle_template_accessory` WHERE `entry` IN (31406,32513); +INSERT INTO `vehicle_template_accessory` (`entry`,`accessory_entry`,`seat_id`,`minion`,`description`,`summontype`,`summontimer`) VALUES +-- Alliance Bomber +(31406,31408,0,1,'Alliance Bomber Seat on Alliance Infra-green Bomber',8,0), +(31406,31407,1,1,'Alliance Turret Seat on Alliance Infra-green Bomber',8,0), +(31406,31409,2,1,'Alliance Engineering Seat on rides Alliance Infra-green Bomber',8,0), +(31406,32217,3,1,'Banner Bunny, Hanging, Alliance on Alliance Infra-green Bomber',8,0), +(31406,32221,4,1,'Banner Bunny, Side, Alliance on Alliance Infra-green Bomber',8,0), +(31406,32221,5,1,'Banner Bunny, Side, Alliance on Alliance Infra-green Bomber',8,0), +(31406,32256,6,1,'Shield Visual Loc Bunny on Alliance Infra-green Bomber',8,0), +(31406,32274,7,0,'Alliance Bomber Pilot rides Alliance Infra-green Bomber',6,300), +-- Horde Bomber +(32513,31856,0,1,'Horde Bomber Seat on Horde Infra-green Bomber',8,0), +(32513,31840,1,1,'Horde Turret Seat on Horde Infra-green Bomber',8,0), +(32513,32152,2,1,'Horde Engineering Seat on rides Horde Infra-green Bomber',8,0), +(32513,32214,3,1,'Banner Bunny, Hanging, Horde on Horde Infra-green Bomber',8,0), +(32513,32215,4,1,'Banner Bunny, Side, Horde on Horde Infra-green Bomber',8,0), +(32513,32215,5,1,'Banner Bunny, Side, Horde on Horde Infra-green Bomber',8,0), +(32513,32256,6,1,'Shield Visual Loc Bunny on Horde Infra-green Bomber',8,0), +(32513,32317,7,0,'Horde Bomber Pilot rides Horde Infra-green Bomber',6,300); + +DELETE FROM `npc_spellclick_spells` WHERE `npc_entry` IN (31406, 31408, 31407, 31409, 31856, 31840, 32152, 32513); +INSERT INTO `npc_spellclick_spells` (`npc_entry`,`spell_id`,`cast_flags`,`user_type`) VALUES +(31406,46598,1,0), +(31408,46598,1,0), +(31407,46598,1,0), +(31409,46598,1,0), +(31856,46598,1,0), +(31840,46598,1,0), +(32152,46598,1,0), +(32513,46598,1,0); + +DELETE FROM `gossip_menu_option` WHERE menu_id = 10120 AND id = 0; +DELETE FROM `gossip_menu_option` WHERE menu_id = 10119 AND id = 0; +INSERT INTO `gossip_menu_option` (`menu_id`,`id`,`option_icon`,`option_text`,`option_id`,`npc_option_npcflag`) VALUES +(10120,0,0,'Give me a bomber!',1,1), +(10119,0,0,'Give me a bomber!',1,1); + +DELETE FROM `conditions` WHERE `SourceTypeOrReferenceID`=15 AND `SourceGroup`=10120; +DELETE FROM `conditions` WHERE `SourceTypeOrReferenceID`=15 AND `SourceGroup`=10119; +INSERT INTO `conditions` (`SourceTypeOrReferenceId`,`SourceGroup`,`SourceEntry`,`ElseGroup`,`ConditionTypeOrReference`,`ConditionValue1`,`ConditionValue2`,`ConditionValue3`,`ErrorTextId`,`Comment`) VALUES +(15,10120,0,0,9,13373,0,0,0,'show gossip on quest 13373 taken'), +(15,10120,0,1,9,13374,0,0,0,'show gossip on quest 13374 taken'), +(15,10120,0,2,9,13376,0,0,0,'show gossip on quest 13376 taken'), +(15,10120,0,3,9,13406,0,0,0,'show gossip on quest 13406 taken'), +(15,10119,0,0,9,13381,0,0,0,'show gossip on quest 13381 taken'), +(15,10119,0,1,9,13404,0,0,0,'show gossip on quest 13404 taken'), +(15,10119,0,2,9,13380,0,0,0,'show gossip on quest 13380 taken'), +(15,10119,0,3,9,13382,0,0,0,'show gossip on quest 13382 taken'); + +UPDATE `creature_template` SET `AIName`= 'SmartAI' WHERE `entry` IN (31648,31839); +DELETE FROM `smart_scripts` WHERE `entryorguid` IN (31648,31839); +INSERT INTO `smart_scripts` (`entryorguid`, `source_type`, `id`, `link`, `event_type`, `event_phase_mask`, `event_chance`, `event_flags`, `event_param1`, `event_param2`, `event_param3`, `event_param4`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES +(31648, 0, 0, 0, 62, 0,100,0, 10119, 0, 0, 0, 11, 59563, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 'Karen No - Gossip select - Cast Waiting for Bomber'), +(31839, 0, 0, 0, 62, 0,100,0, 10120, 0, 0, 0, 11, 59779, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 'Rizzy Ratchwiggle - Gossip select - Cast Waiting for Bomber'); + +UPDATE creature_template SET `spell1`=59059, `spell4`=59194, `spell5`=59196, `spell6`=59193 WHERE `entry` IN (31408, 31856); +UPDATE creature_template SET `spell1`=64979, `spell2`=61313, `spell4`=59194, `spell5`=59196, `spell6`=59193 WHERE `entry` IN (31407, 31840); +UPDATE creature_template SET `spell1`=59061, `spell2`=61171, `spell4`=59194, `spell5`=59196, `spell6`=59193 WHERE `entry` IN (31409, 32152); + +UPDATE creature_template SET `VehicleId`=273 WHERE `entry`=31406; +UPDATE creature_template SET `VehicleId`=274 WHERE `entry` IN (31408,31856); +UPDATE creature_template SET `VehicleId`=277 WHERE `entry` IN (31407,31840); +UPDATE creature_template SET `VehicleId`=278 WHERE `entry` IN (31409,32152); +UPDATE creature_template SET `VehicleId`=287 WHERE `entry`=32513; +UPDATE creature_template SET `Unit_flags`= 33554432, `unit_class`=8 WHERE `entry` IN (31407,31408,31409,31840,31856,32152); +UPDATE creature_template SET `npcflag`=16777216, `minlevel`=80, `maxlevel`=80 WHERE `entry` IN (31406,31407,31408,31409,31840,31856,32152,32513); + +UPDATE creature_template SET `InhabitType`=4 WHERE `entry` IN (32513,31406); + +DELETE FROM `creature` WHERE `id` IN (31648,32523,32524,32526,32525,31839,32529,32528); +INSERT INTO `creature` (`guid`,`id`,`map`,`spawnMask`,`phaseMask`,`equipment_id`,`position_x`,`position_y`,`position_z`,`orientation`,`spawntimesecs`) VALUES +(@CGUID+0, 31648, 571, 1, 1, 0, 7624.19, 2059.96, 600.26, 3.18997,300), +(@CGUID+1, 32523, 571, 1, 1, 1, 7637.56, 2057.34, 600.26, 2.9082,300), +(@CGUID+2, 32524, 571, 1, 1, 1, 7632.78, 2052.75, 600.26, 2.07206,300), +(@CGUID+3, 32526, 571, 1, 1, 0, 7626.84, 2069.71, 600.26, 2.85573,300), +(@CGUID+4, 32525, 571, 1, 1, 0, 7622.21, 2071.61, 600.26, 2.01916,300), +(@CGUID+5, 31839, 571, 1, 1, 0, 7891.96, 2057.73, 600.26, 6.10727,300), +(@CGUID+6, 32529, 571, 1, 1, 0, 7888.79, 2066.53, 600.26, 0.333032,300), +(@CGUID+7, 32528, 571, 1, 1, 0, 7893.77, 2067.97, 600.26, 1.02339,300); diff --git a/sql/updates/world/2014_06_28_03_world_misc.sql b/sql/updates/world/2014_06_28_03_world_misc.sql new file mode 100644 index 00000000000..bc591852817 --- /dev/null +++ b/sql/updates/world/2014_06_28_03_world_misc.sql @@ -0,0 +1,5 @@ +-- +INSERT INTO `conditions` (`SourceTypeOrReferenceId`, `SourceGroup`, `SourceEntry`, `ConditionTypeOrReference`, `ConditionValue1`, `ConditionValue2`, `Comment`) VALUES +(23, 30431, 44150, 5, 1106, 192, 'Arcanum of the stalwart protector - when Argent Crusade revered/exalted'), +(23, 30431, 50369, 5, 1106, 63, 'Arcanum of the stalwart protector - when Argent Crusade not revered/exalted'); +UPDATE `gossip_menu_option` SET `OptionBroadcastTextID`='32344' WHERE `menu_id` IN (10119,10120); diff --git a/src/server/game/Battlegrounds/ArenaScore.h b/src/server/game/Battlegrounds/ArenaScore.h new file mode 100644 index 00000000000..2afb9b26814 --- /dev/null +++ b/src/server/game/Battlegrounds/ArenaScore.h @@ -0,0 +1,144 @@ +/* + * Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/> + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef TRINITY_ARENA_SCORE_H +#define TRINITY_ARENA_SCORE_H + +#include "BattlegroundScore.h" +#include "SharedDefines.h" + +struct ArenaScore : public BattlegroundScore +{ + friend class BattlegroundBE; + friend class BattlegroundDS; + friend class BattlegroundNA; + friend class BattlegroundRL; + friend class BattlegroundRV; + + protected: + ArenaScore(uint64 playerGuid, uint32 team) : BattlegroundScore(playerGuid, team), TeamId(team == ALLIANCE ? 1 : 0) { } + + void AppendToPacket(WorldPacket& data, ByteBuffer& content) final + { + int32 primaryTree; + if (Player* player = ObjectAccessor::FindPlayer(PlayerGuid)) + primaryTree = player->GetPrimaryTalentTree(player->GetActiveSpec()); + + data.WriteBit(0); // Unk 1 + data.WriteBit(0); // Unk 2 + data.WriteBit(PlayerGuid[2]); + data.WriteBit(/*!IsArena*/ 0); // IsArena + data.WriteBit(0); // Unk 4 + data.WriteBit(0); // Unk 5 + data.WriteBit(0); // Unk 6 + data.WriteBit(PlayerGuid[3]); + data.WriteBit(PlayerGuid[0]); + data.WriteBit(PlayerGuid[5]); + data.WriteBit(PlayerGuid[1]); + data.WriteBit(PlayerGuid[6]); + data.WriteBit(TeamId); + data.WriteBit(PlayerGuid[7]); + + content << uint32(HealingDone); // healing done + content << uint32(DamageDone); // damage done + + content.WriteByteSeq(PlayerGuid[4]); + content << uint32(KillingBlows); + + //if (unk5) + // content << int32(RatingChange); // RatingChange + + content.WriteByteSeq(PlayerGuid[5]); + + //if (unk 6) + // content << uint32(); + + //if (unk 2) + // content << uint32(); + + content.WriteByteSeq(PlayerGuid[1]); + content.WriteByteSeq(PlayerGuid[6]); + + content << int32(primaryTree); + + data.WriteBits(0, 24); // Objectives Count + + data.WriteBit(PlayerGuid[4]); + + content.WriteByteSeq(PlayerGuid[0]); + content.WriteByteSeq(PlayerGuid[3]); + + //if (unk 4) + // content << uint32() unk + + content.WriteByteSeq(PlayerGuid[7]); + content.WriteByteSeq(PlayerGuid[2]); + } + + // For Logging purpose + std::string ToString() const override + { + std::ostringstream stream; + stream << "Damage done: " << DamageDone << ", Healing done: " << HealingDone << ", Killing blows: " << KillingBlows; + return stream.str(); + } + + uint8 TeamId; // TEAM_ALLIANCE or TEAM_HORDE +}; + +struct ArenaTeamScore +{ + friend class Battleground; + + protected: + ArenaTeamScore() : RatingChange(0), MatchmakerRating(0) { } + + virtual ~ArenaTeamScore() { } + + void Assign(int32 ratingChange, uint32 matchMakerRating, std::string const& teamName) + { + RatingChange = ratingChange; + MatchmakerRating = matchMakerRating; + TeamName = teamName; + } + + void BuildRatingInfoBlock(WorldPacket& data) + { + uint32 ratingLost = std::abs(std::min(RatingChange, 0)); + uint32 ratingWon = std::max(RatingChange, 0); + + data << uint32(MatchmakerRating); + data << uint32(ratingLost); + data << uint32(ratingWon); + } + + void BuildTeamInfoLengthBlock(WorldPacket& data) + { + data.WriteBits(TeamName.length(), 8); + } + + void BuildTeamInfoBlock(WorldPacket& data) + { + data.WriteString(TeamName); + } + + int32 RatingChange; + uint32 MatchmakerRating; + std::string TeamName; +}; + +#endif // TRINITY_ARENA_SCORE_H diff --git a/src/server/game/Battlegrounds/Battleground.cpp b/src/server/game/Battlegrounds/Battleground.cpp index ba207c1ffc3..9089e75c1cd 100644 --- a/src/server/game/Battlegrounds/Battleground.cpp +++ b/src/server/game/Battlegrounds/Battleground.cpp @@ -16,10 +16,12 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include "ArenaScore.h" #include "ArenaTeam.h" #include "ArenaTeamMgr.h" #include "Battleground.h" #include "BattlegroundMgr.h" +#include "BattlegroundScore.h" #include "Creature.h" #include "CreatureTextMgr.h" #include "Chat.h" @@ -169,12 +171,13 @@ Battleground::Battleground() m_ArenaTeamIds[TEAM_ALLIANCE] = 0; m_ArenaTeamIds[TEAM_HORDE] = 0; - m_ArenaTeamRatingChanges[TEAM_ALLIANCE] = 0; - m_ArenaTeamRatingChanges[TEAM_HORDE] = 0; - m_ArenaTeamMMR[TEAM_ALLIANCE] = 0; m_ArenaTeamMMR[TEAM_HORDE] = 0; + // Iterate this way for consistency's sake - client expects it to be sent in this order + for (int8 i = WINNER_ALLIANCE; i >= WINNER_HORDE; --i) + _arenaTeamScores[i] = new ArenaTeamScore(); + m_BgRaids[TEAM_ALLIANCE] = NULL; m_BgRaids[TEAM_HORDE] = NULL; @@ -226,6 +229,10 @@ Battleground::~Battleground() for (BattlegroundScoreMap::const_iterator itr = PlayerScores.begin(); itr != PlayerScores.end(); ++itr) delete itr->second; + + // Iterate this way for consistency's sake - client expects it to be sent in this order + for (int8 i = WINNER_ALLIANCE; i >= WINNER_HORDE; --i) + delete _arenaTeamScores[i]; } void Battleground::Update(uint32 diff) @@ -806,50 +813,51 @@ void Battleground::EndBattleground(uint32 winner) if (winnerArenaTeam && loserArenaTeam && winnerArenaTeam != loserArenaTeam) { + loserTeamRating = loserArenaTeam->GetRating(); + loserMatchmakerRating = GetArenaMatchmakerRating(GetOtherTeam(winner)); + winnerTeamRating = winnerArenaTeam->GetRating(); + winnerMatchmakerRating = GetArenaMatchmakerRating(winner); + if (winner != WINNER_NONE) { - loserTeamRating = loserArenaTeam->GetRating(); - loserMatchmakerRating = GetArenaMatchmakerRating(GetOtherTeam(winner)); - winnerTeamRating = winnerArenaTeam->GetRating(); - winnerMatchmakerRating = GetArenaMatchmakerRating(winner); winnerMatchmakerChange = winnerArenaTeam->WonAgainst(winnerMatchmakerRating, loserMatchmakerRating, winnerChange); loserMatchmakerChange = loserArenaTeam->LostAgainst(loserMatchmakerRating, winnerMatchmakerRating, loserChange); TC_LOG_DEBUG("bg.arena", "match Type: %u --- Winner: old rating: %u, rating gain: %d, old MMR: %u, MMR gain: %d --- Loser: old rating: %u, rating loss: %d, old MMR: %u, MMR loss: %d ---", m_ArenaType, winnerTeamRating, winnerChange, winnerMatchmakerRating, winnerMatchmakerChange, loserTeamRating, loserChange, loserMatchmakerRating, loserMatchmakerChange); SetArenaMatchmakerRating(winner, winnerMatchmakerRating + winnerMatchmakerChange); SetArenaMatchmakerRating(GetOtherTeam(winner), loserMatchmakerRating + loserMatchmakerChange); - SetArenaTeamRatingChangeForTeam(winner, winnerChange); - SetArenaTeamRatingChangeForTeam(GetOtherTeam(winner), loserChange); + + uint8 winnerId = GetWinner(); + uint8 loserId = winnerId == WINNER_ALLIANCE ? uint8(WINNER_HORDE) : winnerId; + + _arenaTeamScores[winnerId]->Assign(winnerChange, winnerMatchmakerRating + winnerMatchmakerChange, winnerArenaTeam->GetName()); + _arenaTeamScores[loserId]->Assign(loserChange, loserMatchmakerRating + loserMatchmakerChange, loserArenaTeam->GetName()); + TC_LOG_DEBUG("bg.arena", "Arena match Type: %u for Team1Id: %u - Team2Id: %u ended. WinnerTeamId: %u. Winner rating: +%d, Loser rating: %d", m_ArenaType, m_ArenaTeamIds[TEAM_ALLIANCE], m_ArenaTeamIds[TEAM_HORDE], winnerArenaTeam->GetId(), winnerChange, loserChange); if (sWorld->getBoolConfig(CONFIG_ARENA_LOG_EXTENDED_INFO)) - for (Battleground::BattlegroundScoreMap::const_iterator itr = GetPlayerScoresBegin(); itr != GetPlayerScoresEnd(); ++itr) - if (Player* player = ObjectAccessor::FindPlayer(itr->first)) + for (auto const& score : PlayerScores) + if (Player* player = ObjectAccessor::FindPlayer(MAKE_NEW_GUID(score.first, 0, HIGHGUID_PLAYER))) { - TC_LOG_DEBUG("bg.arena", "Statistics match Type: %u for %s (GUID: " UI64FMTD ", Team: %d, IP: %s): %u damage, %u healing, %u killing blows", - m_ArenaType, player->GetName().c_str(), 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); + TC_LOG_DEBUG("bg.arena", "Statistics match Type: %u for %s (GUID: %u, Team: %d, IP: %s): %s", + m_ArenaType, player->GetName().c_str(), score.first, player->GetArenaTeamId(m_ArenaType == 5 ? 2 : m_ArenaType == 3), + player->GetSession()->GetRemoteAddress().c_str(), score.second->ToString().c_str()); } } // Deduct 16 points from each teams arena-rating if there are no winners after 45+2 minutes else { - SetArenaTeamRatingChangeForTeam(ALLIANCE, ARENA_TIMELIMIT_POINTS_LOSS); - SetArenaTeamRatingChangeForTeam(HORDE, ARENA_TIMELIMIT_POINTS_LOSS); + _arenaTeamScores[WINNER_ALLIANCE]->Assign(ARENA_TIMELIMIT_POINTS_LOSS, winnerMatchmakerRating + winnerMatchmakerChange, winnerArenaTeam->GetName()); + _arenaTeamScores[WINNER_HORDE]->Assign(ARENA_TIMELIMIT_POINTS_LOSS, loserMatchmakerRating + loserMatchmakerChange, loserArenaTeam->GetName()); + winnerArenaTeam->FinishGame(ARENA_TIMELIMIT_POINTS_LOSS); loserArenaTeam->FinishGame(ARENA_TIMELIMIT_POINTS_LOSS); } } - else - { - SetArenaTeamRatingChangeForTeam(ALLIANCE, 0); - SetArenaTeamRatingChangeForTeam(HORDE, 0); - } } bool guildAwarded = false; WorldPacket pvpLogData; - sBattlegroundMgr->BuildPvpLogDataPacket(&pvpLogData, this); + BuildPvPLogDataPacket(pvpLogData); BattlegroundQueueTypeId bgQueueTypeId = BattlegroundMgr::BGQueueTypeId(GetTypeID(), GetArenaType()); @@ -1014,7 +1022,7 @@ void Battleground::RemovePlayerAtLeave(uint64 guid, bool Transport, bool SendPac participant = true; } - BattlegroundScoreMap::iterator itr2 = PlayerScores.find(guid); + BattlegroundScoreMap::iterator itr2 = PlayerScores.find(GUID_LOPART(guid)); if (itr2 != PlayerScores.end()) { delete itr2->second; // delete player's score @@ -1425,47 +1433,68 @@ bool Battleground::HasFreeSlots() const return GetPlayersSize() < GetMaxPlayers(); } -void Battleground::UpdatePlayerScore(Player* Source, uint32 type, uint32 value, bool doAddHonor) +void Battleground::BuildPvPLogDataPacket(WorldPacket& data) { - //this procedure is called from virtual function implemented in bg subclass - BattlegroundScoreMap::const_iterator itr = PlayerScores.find(Source->GetGUID()); - if (itr == PlayerScores.end()) // player not found... - return; + ByteBuffer buff; - switch (type) + data.Initialize(SMSG_PVP_LOG_DATA, (1 + 1 + 4 + 40 * GetPlayerScoresSize())); + + data.WriteBit(isRated()); + data.WriteBit(isArena()); + + if (isArena()) { - case SCORE_KILLING_BLOWS: // Killing blows - itr->second->KillingBlows += value; - break; - case SCORE_DEATHS: // Deaths - itr->second->Deaths += value; - break; - case SCORE_HONORABLE_KILLS: // Honorable kills - itr->second->HonorableKills += value; - break; - case SCORE_BONUS_HONOR: // Honor bonus - // do not add honor in arenas - if (isBattleground()) - { - // reward honor instantly - if (doAddHonor) - Source->RewardHonor(NULL, 1, value); // RewardHonor calls UpdatePlayerScore with doAddHonor = false - else - itr->second->BonusHonor += value; - } - break; - // used only in EY, but in MSG_PVP_LOG_DATA opcode - case SCORE_DAMAGE_DONE: // Damage Done - itr->second->DamageDone += value; - break; - case SCORE_HEALING_DONE: // Healing Done - itr->second->HealingDone += value; - break; - default: - TC_LOG_ERROR("bg.battleground", "Battleground::UpdatePlayerScore: unknown score type (%u) for BG (map: %u, instance id: %u)!", - type, m_MapId, m_InstanceID); - break; + // it seems this must be according to BG_WINNER_A/H and _NOT_ TEAM_A/H + for (int8 i = WINNER_ALLIANCE; i >= WINNER_HORDE; --i) + _arenaTeamScores[i]->BuildTeamInfoLengthBlock(data); + } + + size_t countPos = data.bitwpos(); + data.WriteBits(0, 21); + uint32 count = 0; + for (auto const& score : PlayerScores) + score.second->AppendToPacket(data, buff); + + data.PutBits(countPos, GetPlayerScoresSize(), 21); + data.WriteBit(GetStatus() == STATUS_WAIT_LEAVE); // If Ended + + if (isRated()) + { + // it seems this must be according to BG_WINNER_A/H and _NOT_ BG_TEAM_A/H + for (int8 i = WINNER_ALLIANCE; i >= WINNER_HORDE; --i) + _arenaTeamScores[i]->BuildRatingInfoBlock(data); + } + + data.FlushBits(); + data.append(buff); + + if (isArena()) + { + // it seems this must be according to BG_WINNER_A/H and _NOT_ TEAM_A/H + for (int8 i = WINNER_ALLIANCE; i >= WINNER_HORDE; --i) + _arenaTeamScores[i]->BuildTeamInfoBlock(data); } + + data << uint8(GetPlayersCountByTeam(HORDE)); + + if (GetStatus() == STATUS_WAIT_LEAVE) + data << uint8(GetWinner()); + + data << uint8(GetPlayersCountByTeam(ALLIANCE)); +} + +bool Battleground::UpdatePlayerScore(Player* player, uint32 type, uint32 value, bool doAddHonor) +{ + BattlegroundScoreMap::const_iterator itr = PlayerScores.find(player->GetGUIDLow()); + if (itr == PlayerScores.end()) // player not found... + return false; + + itr->second->UpdateScore(type, value); + + if (type == SCORE_BONUS_HONOR && doAddHonor && isBattleground()) + player->RewardHonor(NULL, 1, value); // RewardHonor calls UpdatePlayerScore with doAddHonor = false + + return true; } void Battleground::AddPlayerToResurrectQueue(uint64 npc_guid, uint64 player_guid) @@ -1946,7 +1975,7 @@ void Battleground::PlayerAddedToBGCheckIfBGIsRunning(Player* player) BlockMovement(player); - sBattlegroundMgr->BuildPvpLogDataPacket(&data, this); + BuildPvPLogDataPacket(data); player->SendDirectMessage(&data); sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, this, player, player->GetBattlegroundQueueIndex(bgQueueTypeId), STATUS_IN_PROGRESS, player->GetBattlegroundQueueJoinTime(GetTypeID()), GetElapsedTime(), GetArenaType()); diff --git a/src/server/game/Battlegrounds/Battleground.h b/src/server/game/Battlegrounds/Battleground.h index 205d03c1e61..6845b0a8e92 100644 --- a/src/server/game/Battlegrounds/Battleground.h +++ b/src/server/game/Battlegrounds/Battleground.h @@ -32,6 +32,8 @@ class WorldObject; class WorldPacket; class BattlegroundMap; +struct ArenaTeamScore; +struct BattlegroundScore; struct Position; struct PvPDifficultyEntry; struct WorldSafeLocsEntry; @@ -174,34 +176,6 @@ struct BattlegroundObjectInfo uint32 spellid; }; -enum ScoreType -{ - SCORE_KILLING_BLOWS = 1, - SCORE_DEATHS = 2, - SCORE_HONORABLE_KILLS = 3, - SCORE_BONUS_HONOR = 4, - //EY, but in MSG_PVP_LOG_DATA opcode! - SCORE_DAMAGE_DONE = 5, - SCORE_HEALING_DONE = 6, - //WS - SCORE_FLAG_CAPTURES = 7, - SCORE_FLAG_RETURNS = 8, - //AB and IC - SCORE_BASES_ASSAULTED = 9, - SCORE_BASES_DEFENDED = 10, - //AV - SCORE_GRAVEYARDS_ASSAULTED = 11, - SCORE_GRAVEYARDS_DEFENDED = 12, - SCORE_TOWERS_ASSAULTED = 13, - SCORE_TOWERS_DEFENDED = 14, - SCORE_MINES_CAPTURED = 15, - SCORE_LEADERS_KILLED = 16, - SCORE_SECONDARY_OBJECTIVES = 17, - //SOTA - SCORE_DESTROYED_DEMOLISHER = 18, - SCORE_DESTROYED_WALL = 19 -}; - enum ArenaType { ARENA_TYPE_2v2 = 2, @@ -242,22 +216,6 @@ enum BattlegroundStartingEventsIds }; #define BG_STARTING_EVENT_COUNT 4 -struct BattlegroundScore -{ - BattlegroundScore() : KillingBlows(0), Deaths(0), HonorableKills(0), BonusHonor(0), - DamageDone(0), HealingDone(0) - { } - - virtual ~BattlegroundScore() { } //virtual destructor is used when deleting score from scores map - - uint32 KillingBlows; - uint32 Deaths; - uint32 HonorableKills; - uint32 BonusHonor; - uint32 DamageDone; - uint32 HealingDone; -}; - enum BGHonorMode { BG_NORMAL = 0, @@ -374,9 +332,7 @@ class Battleground BattlegroundPlayerMap const& GetPlayers() const { return m_Players; } uint32 GetPlayersSize() const { return m_Players.size(); } - typedef std::map<uint64, BattlegroundScore*> BattlegroundScoreMap; - BattlegroundScoreMap::const_iterator GetPlayerScoresBegin() const { return PlayerScores.begin(); } - BattlegroundScoreMap::const_iterator GetPlayerScoresEnd() const { return PlayerScores.end(); } + typedef std::map<uint32, BattlegroundScore*> BattlegroundScoreMap; uint32 GetPlayerScoresSize() const { return PlayerScores.size(); } uint32 GetReviveQueueSize() const { return m_ReviveQueue.size(); } @@ -448,7 +404,8 @@ class Battleground Group* GetBgRaid(uint32 TeamID) const { return TeamID == ALLIANCE ? m_BgRaids[TEAM_ALLIANCE] : m_BgRaids[TEAM_HORDE]; } void SetBgRaid(uint32 TeamID, Group* bg_raid); - virtual void UpdatePlayerScore(Player* player, uint32 type, uint32 value, bool doAddHonor = true); + void BuildPvPLogDataPacket(WorldPacket& data); + virtual bool UpdatePlayerScore(Player* player, uint32 type, uint32 value, bool doAddHonor = true); static TeamId GetTeamIndexByTeamId(uint32 Team) { return Team == ALLIANCE ? TEAM_ALLIANCE : TEAM_HORDE; } uint32 GetPlayersCountByTeam(uint32 Team) const { return m_PlayersCount[GetTeamIndexByTeamId(Team)]; } @@ -465,12 +422,8 @@ class Battleground void SetArenaTeamIdForTeam(uint32 Team, uint32 ArenaTeamId) { m_ArenaTeamIds[GetTeamIndexByTeamId(Team)] = ArenaTeamId; } uint32 GetArenaTeamIdForTeam(uint32 Team) const { return m_ArenaTeamIds[GetTeamIndexByTeamId(Team)]; } uint32 GetArenaTeamIdByIndex(uint32 index) const { return m_ArenaTeamIds[index]; } - void SetArenaTeamRatingChangeForTeam(uint32 Team, int32 RatingChange) { m_ArenaTeamRatingChanges[GetTeamIndexByTeamId(Team)] = RatingChange; } - int32 GetArenaTeamRatingChangeForTeam(uint32 Team) const { return m_ArenaTeamRatingChanges[GetTeamIndexByTeamId(Team)]; } - int32 GetArenaTeamRatingChangeByIndex(uint32 index) const { return m_ArenaTeamRatingChanges[index]; } void SetArenaMatchmakerRating(uint32 Team, uint32 MMR){ m_ArenaTeamMMR[GetTeamIndexByTeamId(Team)] = MMR; } uint32 GetArenaMatchmakerRating(uint32 Team) const { return m_ArenaTeamMMR[GetTeamIndexByTeamId(Team)]; } - uint32 GetArenaMatchmakerRatingByIndex(uint32 index) const { return m_ArenaTeamMMR[index]; } void CheckArenaAfterTimerConditions(); void CheckArenaWinConditions(); void UpdateArenaWorldState(); @@ -664,8 +617,8 @@ class Battleground // Arena team ids by team uint32 m_ArenaTeamIds[BG_TEAMS_COUNT]; - int32 m_ArenaTeamRatingChanges[BG_TEAMS_COUNT]; uint32 m_ArenaTeamMMR[BG_TEAMS_COUNT]; + ArenaTeamScore* _arenaTeamScores[BG_TEAMS_COUNT]; // Limits uint32 m_LevelMin; diff --git a/src/server/game/Battlegrounds/BattlegroundMgr.cpp b/src/server/game/Battlegrounds/BattlegroundMgr.cpp index 3f39f8e3715..d5154260ed2 100644 --- a/src/server/game/Battlegrounds/BattlegroundMgr.cpp +++ b/src/server/game/Battlegrounds/BattlegroundMgr.cpp @@ -355,254 +355,6 @@ void BattlegroundMgr::BuildBattlegroundStatusPacket(WorldPacket* data, Battlegro } } -void BattlegroundMgr::BuildPvpLogDataPacket(WorldPacket* data, Battleground* bg) -{ - ByteBuffer buff; - uint8 isRated = (bg->isRated() ? 1 : 0); // type (normal=0/rated=1) -- ATM arena or bg, RBG NYI - uint8 isArena = (bg->isArena() ? 1 : 0); // Arena names - - data->Initialize(SMSG_PVP_LOG_DATA, (1+1+4+40*bg->GetPlayerScoresSize())); - data->WriteBit(isArena); - data->WriteBit(isRated); - - if (isArena) - { - for (int8 i = 0; i < BG_TEAMS_COUNT; ++i) - { - if (ArenaTeam* at = sArenaTeamMgr->GetArenaTeamById(bg->GetArenaTeamIdByIndex(i))) - data->WriteBits(at->GetName().length(), 8); - else - data->WriteBits(0, 8); - } - } - - size_t count_pos = data->bitwpos(); - data->WriteBits(0, 21); - uint32 count = 0; - Battleground::BattlegroundPlayerMap const& bgPlayers = bg->GetPlayers(); - - for (Battleground::BattlegroundScoreMap::const_iterator itr = bg->GetPlayerScoresBegin(); itr != bg->GetPlayerScoresEnd(); ++itr) - { - if (!bg->IsPlayerInBattleground(itr->first)) - { - TC_LOG_ERROR("bg.battleground", "Player " UI64FMTD " has scoreboard entry for battleground %u but is not in battleground!", itr->first, bg->GetTypeID(true)); - continue; - } - - uint32 team; - int32 primaryTree; - if (Player* player = ObjectAccessor::FindPlayer(itr->first)) - { - team = player->GetBGTeam(); - primaryTree = player->GetPrimaryTalentTree(player->GetActiveSpec()); - } - else - { - Battleground::BattlegroundPlayerMap::const_iterator itr2 = bgPlayers.find(itr->first); - if (itr2 == bgPlayers.end()) - { - TC_LOG_ERROR("bg.battleground", "Player " UI64FMTD " has scoreboard entry for battleground %u but do not have battleground data!", itr->first, bg->GetTypeID(true)); - continue; - } - - team = itr2->second.Team; - primaryTree = itr2->second.PrimaryTree; - } - - ObjectGuid playerGUID = itr->first; - BattlegroundScore* score = itr->second; - - data->WriteBit(0); // Unk 1 - data->WriteBit(0); // Unk 2 - data->WriteBit(playerGUID[2]); - data->WriteBit(!isArena); - data->WriteBit(0); // Unk 4 - data->WriteBit(0); // Unk 5 - data->WriteBit(0); // Unk 6 - data->WriteBit(playerGUID[3]); - data->WriteBit(playerGUID[0]); - data->WriteBit(playerGUID[5]); - data->WriteBit(playerGUID[1]); - data->WriteBit(playerGUID[6]); - data->WriteBit(team == HORDE ? 0 : 1); - data->WriteBit(playerGUID[7]); - - buff << uint32(score->HealingDone); // healing done - buff << uint32(score->DamageDone); // damage done - - if (!isArena) - { - buff << uint32(score->BonusHonor / 100); - buff << uint32(score->Deaths); - buff << uint32(score->HonorableKills); - } - - buff.WriteByteSeq(playerGUID[4]); - buff << uint32(score->KillingBlows); - // if (unk 5) << uint32() unk - buff.WriteByteSeq(playerGUID[5]); - // if (unk 6) << uint32() unk - // if (unk 2) << uint32() unk - buff.WriteByteSeq(playerGUID[1]); - buff.WriteByteSeq(playerGUID[6]); - - buff << int32(primaryTree); - - switch (bg->GetTypeID(true)) // Custom values - { - case BATTLEGROUND_RB: - switch (bg->GetMapId()) - { - case 489: - data->WriteBits(0x00000002, 24); - buff << uint32(((BattlegroundWGScore*)score)->FlagCaptures); // flag captures - buff << uint32(((BattlegroundWGScore*)score)->FlagReturns); // flag returns - break; - case 566: - data->WriteBits(0x00000001, 24); - buff << uint32(((BattlegroundEYScore*)score)->FlagCaptures); // flag captures - break; - case 529: - data->WriteBits(0x00000002, 24); - buff << uint32(((BattlegroundABScore*)score)->BasesAssaulted); // bases assaulted - buff << uint32(((BattlegroundABScore*)score)->BasesDefended); // bases defended - break; - case 30: - data->WriteBits(0x00000005, 24); - buff << uint32(((BattlegroundAVScore*)score)->GraveyardsAssaulted); // GraveyardsAssaulted - buff << uint32(((BattlegroundAVScore*)score)->GraveyardsDefended); // GraveyardsDefended - buff << uint32(((BattlegroundAVScore*)score)->TowersAssaulted); // TowersAssaulted - buff << uint32(((BattlegroundAVScore*)score)->TowersDefended); // TowersDefended - buff << uint32(((BattlegroundAVScore*)score)->MinesCaptured); // MinesCaptured - break; - case 607: - data->WriteBits(0x00000002, 24); - buff << uint32(((BattlegroundSAScore*)score)->demolishers_destroyed); - buff << uint32(((BattlegroundSAScore*)score)->gates_destroyed); - break; - case 628: // IC - data->WriteBits(0x00000002, 24); - buff << uint32(((BattlegroundICScore*)score)->BasesAssaulted); // bases assaulted - buff << uint32(((BattlegroundICScore*)score)->BasesDefended); // bases defended - break; - case 726: - data->WriteBits(0x00000002, 24); - buff << uint32(((BattlegroundTPScore*)score)->FlagCaptures); // flag captures - buff << uint32(((BattlegroundTPScore*)score)->FlagReturns); // flag returns - break; - case 761: - data->WriteBits(0x00000002, 24); - buff << uint32(((BattlegroundBFGScore*)score)->BasesAssaulted); // bases assaulted - buff << uint32(((BattlegroundBFGScore*)score)->BasesDefended); // bases defended - break; - default: - data->WriteBits(0, 24); - break; - } - break; - case BATTLEGROUND_AV: - data->WriteBits(0x00000005, 24); - buff << uint32(((BattlegroundAVScore*)score)->GraveyardsAssaulted); // GraveyardsAssaulted - buff << uint32(((BattlegroundAVScore*)score)->GraveyardsDefended); // GraveyardsDefended - buff << uint32(((BattlegroundAVScore*)score)->TowersAssaulted); // TowersAssaulted - buff << uint32(((BattlegroundAVScore*)score)->TowersDefended); // TowersDefended - buff << uint32(((BattlegroundAVScore*)score)->MinesCaptured); // MinesCaptured - break; - case BATTLEGROUND_WS: - data->WriteBits(0x00000002, 24); - buff << uint32(((BattlegroundWGScore*)score)->FlagCaptures); // flag captures - buff << uint32(((BattlegroundWGScore*)score)->FlagReturns); // flag returns - break; - case BATTLEGROUND_AB: - data->WriteBits(0x00000002, 24); - buff << uint32(((BattlegroundABScore*)score)->BasesAssaulted); // bases assaulted - buff << uint32(((BattlegroundABScore*)score)->BasesDefended); // bases defended - break; - case BATTLEGROUND_EY: - data->WriteBits(0x00000001, 24); - buff << uint32(((BattlegroundEYScore*)score)->FlagCaptures); // flag captures - break; - case BATTLEGROUND_SA: - data->WriteBits(0x00000002, 24); - buff << uint32(((BattlegroundSAScore*)score)->demolishers_destroyed); - buff << uint32(((BattlegroundSAScore*)score)->gates_destroyed); - break; - case BATTLEGROUND_IC: - data->WriteBits(0x00000002, 24); - buff << uint32(((BattlegroundICScore*)score)->BasesAssaulted); // bases assaulted - buff << uint32(((BattlegroundICScore*)score)->BasesDefended); // bases defended - break; - case BATTLEGROUND_TP: - data->WriteBits(0x00000002, 24); - buff << uint32(((BattlegroundTPScore*)score)->FlagCaptures); // flag captures - buff << uint32(((BattlegroundTPScore*)score)->FlagReturns); // flag returns - break; - case BATTLEGROUND_BFG: - data->WriteBits(0x00000002, 24); - buff << uint32(((BattlegroundBFGScore*)score)->BasesAssaulted); // bases assaulted - buff << uint32(((BattlegroundBFGScore*)score)->BasesDefended); // bases defended - break; - case BATTLEGROUND_NA: - case BATTLEGROUND_BE: - case BATTLEGROUND_AA: - case BATTLEGROUND_RL: - case BATTLEGROUND_DS: - case BATTLEGROUND_RV: - data->WriteBits(0, 24); - break; - default: - data->WriteBits(0, 24); - break; - } - - data->WriteBit(playerGUID[4]); - - buff.WriteByteSeq(playerGUID[0]); - buff.WriteByteSeq(playerGUID[3]); - // if (unk 4) << uint32() unk - buff.WriteByteSeq(playerGUID[7]); - buff.WriteByteSeq(playerGUID[2]); - ++count; - } - - data->PutBits(count_pos, count, 21); - data->WriteBit(bg->GetStatus() == STATUS_WAIT_LEAVE); // If Ended - - if (isRated) // arena - { - // it seems this must be according to BG_WINNER_A/H and _NOT_ BG_TEAM_A/H - for (int8 i = 0; i < BG_TEAMS_COUNT; ++i) - { - int32 rating_change = bg->GetArenaTeamRatingChangeByIndex(i); - - uint32 pointsLost = rating_change < 0 ? -rating_change : 0; - uint32 pointsGained = rating_change > 0 ? rating_change : 0; - uint32 MatchmakerRating = bg->GetArenaMatchmakerRatingByIndex(i); - - *data << uint32(MatchmakerRating); // Matchmaking Value - *data << uint32(pointsLost); // Rating Lost - *data << uint32(pointsGained); // Rating gained - - TC_LOG_DEBUG("bg.battleground", "rating change: %d", rating_change); - } - } - - data->FlushBits(); - data->append(buff); - - if (isArena) - for (int8 i = 0; i < BG_TEAMS_COUNT; ++i) - if (ArenaTeam* at = sArenaTeamMgr->GetArenaTeamById(bg->GetArenaTeamIdByIndex(i))) - data->WriteString(at->GetName()); - - *data << uint8(bg->GetPlayersCountByTeam(HORDE)); - - if (bg->GetStatus() == STATUS_WAIT_LEAVE) - *data << uint8(bg->GetWinner()); - - *data << uint8(bg->GetPlayersCountByTeam(ALLIANCE)); -} - void BattlegroundMgr::BuildStatusFailedPacket(WorldPacket* data, Battleground* bg, Player* player, uint8 QueueSlot, GroupJoinBattlegroundResult result) { ObjectGuid guidBytes1 = player->GetGUID(); // player who caused the error diff --git a/src/server/game/Battlegrounds/BattlegroundMgr.h b/src/server/game/Battlegrounds/BattlegroundMgr.h index 45a2f671d81..28313b29deb 100644 --- a/src/server/game/Battlegrounds/BattlegroundMgr.h +++ b/src/server/game/Battlegrounds/BattlegroundMgr.h @@ -78,7 +78,6 @@ class BattlegroundMgr void BuildBattlegroundListPacket(WorldPacket* data, uint64 guid, Player* player, BattlegroundTypeId bgTypeId); void BuildStatusFailedPacket(WorldPacket* data, Battleground* bg, Player* pPlayer, uint8 QueueSlot, GroupJoinBattlegroundResult result); void BuildUpdateWorldStatePacket(WorldPacket* data, uint32 field, uint32 value); - void BuildPvpLogDataPacket(WorldPacket* data, Battleground* bg); void BuildBattlegroundStatusPacket(WorldPacket* data, Battleground* bg, Player* player, uint8 queueSlot, uint8 statusId, uint32 time1, uint32 time2, uint8 arenaType); void BuildPlaySoundPacket(WorldPacket* data, uint32 soundId); void SendAreaSpiritHealerQueryOpcode(Player* player, Battleground* bg, uint64 guid); diff --git a/src/server/game/Battlegrounds/BattlegroundScore.h b/src/server/game/Battlegrounds/BattlegroundScore.h new file mode 100644 index 00000000000..f92d91253ef --- /dev/null +++ b/src/server/game/Battlegrounds/BattlegroundScore.h @@ -0,0 +1,172 @@ +/* + * Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/> + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef TRINITY_BATTLEGROUND_SCORE_H +#define TRINITY_BATTLEGROUND_SCORE_H + +#include "WorldPacket.h" +#include "Player.h" + +enum ScoreType +{ + SCORE_KILLING_BLOWS = 1, + SCORE_DEATHS = 2, + SCORE_HONORABLE_KILLS = 3, + SCORE_BONUS_HONOR = 4, + SCORE_DAMAGE_DONE = 5, + SCORE_HEALING_DONE = 6, + + // WS and EY + SCORE_FLAG_CAPTURES = 7, + SCORE_FLAG_RETURNS = 8, + + // AB and IC + SCORE_BASES_ASSAULTED = 9, + SCORE_BASES_DEFENDED = 10, + + // AV + SCORE_GRAVEYARDS_ASSAULTED = 11, + SCORE_GRAVEYARDS_DEFENDED = 12, + SCORE_TOWERS_ASSAULTED = 13, + SCORE_TOWERS_DEFENDED = 14, + SCORE_MINES_CAPTURED = 15, + + // SOTA + SCORE_DESTROYED_DEMOLISHER = 16, + SCORE_DESTROYED_WALL = 17 +}; + +struct BattlegroundScore +{ + friend class Battleground; + + protected: + BattlegroundScore(uint64 playerGuid, uint8 team) : PlayerGuid(playerGuid), TeamId(team == ALLIANCE ? 1 : 0), + KillingBlows(0), Deaths(0), HonorableKills(0), BonusHonor(0), DamageDone(0), HealingDone(0) { } + + virtual ~BattlegroundScore() { } + + virtual void UpdateScore(uint32 type, uint32 value) + { + switch (type) + { + case SCORE_KILLING_BLOWS: // Killing blows + KillingBlows += value; + break; + case SCORE_DEATHS: // Deaths + Deaths += value; + break; + case SCORE_HONORABLE_KILLS: // Honorable kills + HonorableKills += value; + break; + case SCORE_BONUS_HONOR: // Honor bonus + BonusHonor += value; + break; + case SCORE_DAMAGE_DONE: // Damage Done + DamageDone += value; + break; + case SCORE_HEALING_DONE: // Healing Done + HealingDone += value; + break; + default: + ASSERT(false && "Not implemented Battleground score type!"); + break; + } + } + + virtual void AppendToPacket(WorldPacket& data, ByteBuffer& content) + { + int32 primaryTree; + if (Player* player = ObjectAccessor::FindPlayer(PlayerGuid)) + primaryTree = player->GetPrimaryTalentTree(player->GetActiveSpec()); + + data.WriteBit(0); // Unk 1 + data.WriteBit(0); // Unk 2 + data.WriteBit(PlayerGuid[2]); + data.WriteBit(/*!IsArena*/ 1); // IsArena + data.WriteBit(0); // Unk 4 + data.WriteBit(0); // Unk 5 + data.WriteBit(0); // Unk 6 + data.WriteBit(PlayerGuid[3]); + data.WriteBit(PlayerGuid[0]); + data.WriteBit(PlayerGuid[5]); + data.WriteBit(PlayerGuid[1]); + data.WriteBit(PlayerGuid[6]); + data.WriteBit(TeamId); + data.WriteBit(PlayerGuid[7]); + + content << uint32(HealingDone); // healing done + content << uint32(DamageDone); // damage done + + //if (!IsArena) + //{ + content << uint32(BonusHonor / 100); + content << uint32(Deaths); + content << uint32(HonorableKills); + //} + + content.WriteByteSeq(PlayerGuid[4]); + content << uint32(KillingBlows); + + //if (unk 5) + // data << uint32() unk + + content.WriteByteSeq(PlayerGuid[5]); + + //if (unk 6) + // data << uint32() unk + + //if (unk 2) + // data << uint32() unk + + content.WriteByteSeq(PlayerGuid[1]); + content.WriteByteSeq(PlayerGuid[6]); + + content << int32(primaryTree); + + BuildObjectivesBlock(data, content); + + data.WriteBit(PlayerGuid[4]); + + content.WriteByteSeq(PlayerGuid[0]); + content.WriteByteSeq(PlayerGuid[3]); + + //if (unk 4) + // data << uint32() unk + + content.WriteByteSeq(PlayerGuid[7]); + content.WriteByteSeq(PlayerGuid[2]); + } + + virtual void BuildObjectivesBlock(WorldPacket& /*data*/, ByteBuffer& /*content*/) { } + + // For Logging purpose + virtual std::string ToString() const { return ""; } + + ObjectGuid PlayerGuid; + uint8 TeamId; + + // Default score, present in every type + uint32 KillingBlows; + uint32 Deaths; + uint32 HonorableKills; + uint32 BonusHonor; + uint32 DamageDone; + uint32 HealingDone; +}; + +#endif // TRINITY_BATTLEGROUND_SCORE_H diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundAB.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundAB.cpp index 38b0e3e084b..91174682218 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundAB.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundAB.cpp @@ -224,15 +224,11 @@ void BattlegroundAB::StartingEventOpenDoors() void BattlegroundAB::AddPlayer(Player* player) { Battleground::AddPlayer(player); - //create score and add it to map, default values are set in the constructor - BattlegroundABScore* sc = new BattlegroundABScore; - - PlayerScores[player->GetGUID()] = sc; + PlayerScores[player->GetGUIDLow()] = new BattlegroundABScore(player->GetGUID(), player->GetBGTeam()); } void BattlegroundAB::RemovePlayer(Player* /*player*/, uint64 /*guid*/, uint32 /*team*/) { - } void BattlegroundAB::HandleAreaTrigger(Player* player, uint32 trigger) @@ -696,26 +692,23 @@ WorldSafeLocsEntry const* BattlegroundAB::GetClosestGraveYard(Player* player) return good_entry; } -void BattlegroundAB::UpdatePlayerScore(Player* Source, uint32 type, uint32 value, bool doAddHonor) +bool BattlegroundAB::UpdatePlayerScore(Player* player, uint32 type, uint32 value, bool doAddHonor) { - BattlegroundScoreMap::iterator itr = PlayerScores.find(Source->GetGUID()); - if (itr == PlayerScores.end()) // player not found... - return; + if (!Battleground::UpdatePlayerScore(player, type, value, doAddHonor)) + return false; switch (type) { case SCORE_BASES_ASSAULTED: - ((BattlegroundABScore*)itr->second)->BasesAssaulted += value; - Source->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BG_OBJECTIVE_CAPTURE, AB_OBJECTIVE_ASSAULT_BASE); + player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BG_OBJECTIVE_CAPTURE, AB_OBJECTIVE_ASSAULT_BASE); break; case SCORE_BASES_DEFENDED: - ((BattlegroundABScore*)itr->second)->BasesDefended += value; - Source->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BG_OBJECTIVE_CAPTURE, AB_OBJECTIVE_DEFEND_BASE); + player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BG_OBJECTIVE_CAPTURE, AB_OBJECTIVE_DEFEND_BASE); break; default: - Battleground::UpdatePlayerScore(Source, type, value, doAddHonor); break; } + return true; } bool BattlegroundAB::IsAllNodesControlledByTeam(uint32 team) const diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundAB.h b/src/server/game/Battlegrounds/Zones/BattlegroundAB.h index 9abc7627b24..d92179cf947 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundAB.h +++ b/src/server/game/Battlegrounds/Zones/BattlegroundAB.h @@ -20,6 +20,7 @@ #define __BATTLEGROUNDAB_H #include "Battleground.h" +#include "BattlegroundScore.h" #include "Object.h" enum BG_AB_WorldStates @@ -236,12 +237,38 @@ struct BG_AB_BannerTimer uint8 teamIndex; }; -struct BattlegroundABScore : public BattlegroundScore +struct BattlegroundABScore final : public BattlegroundScore { - BattlegroundABScore(): BasesAssaulted(0), BasesDefended(0) { } - ~BattlegroundABScore() { } - uint32 BasesAssaulted; - uint32 BasesDefended; + friend class BattlegroundAB; + + protected: + BattlegroundABScore(uint64 playerGuid, uint8 team) : BattlegroundScore(playerGuid, team), BasesAssaulted(0), BasesDefended(0) { } + + void UpdateScore(uint32 type, uint32 value) override + { + switch (type) + { + case SCORE_BASES_ASSAULTED: + BasesAssaulted += value; + break; + case SCORE_BASES_DEFENDED: + BasesDefended += value; + break; + default: + BattlegroundScore::UpdateScore(type, value); + break; + } + } + + void BuildObjectivesBlock(WorldPacket& data, ByteBuffer& content) final + { + data.WriteBits(2, 24); // Objectives Count + content << uint32(BasesAssaulted); + content << uint32(BasesDefended); + } + + uint32 BasesAssaulted; + uint32 BasesDefended; }; class BattlegroundAB : public Battleground @@ -261,7 +288,7 @@ class BattlegroundAB : public Battleground WorldSafeLocsEntry const* GetClosestGraveYard(Player* player); /* Scorekeeping */ - void UpdatePlayerScore(Player* Source, uint32 type, uint32 value, bool doAddHonor = true); + bool UpdatePlayerScore(Player* player, uint32 type, uint32 value, bool doAddHonor = true) override; void FillInitialWorldStates(WorldPacket& data); diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp index 16576aa888e..9d55e44d491 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp @@ -47,7 +47,6 @@ BattlegroundAV::BattlegroundAV() } m_Mine_Timer = 0; - m_MaxLevel = 0; for (BG_AV_Nodes i = BG_AV_NODES_FIRSTAID_STATION; i < BG_AV_NODES_MAX; ++i) InitNode(i, 0, false); @@ -60,11 +59,6 @@ BattlegroundAV::BattlegroundAV() BattlegroundAV::~BattlegroundAV() { } -uint16 BattlegroundAV::GetBonusHonor(uint8 kills) /// @todo move this function to Battleground.cpp (needs to find a way to get m_MaxLevel) -{ - return Trinity::Honor::hk_honor_at_level(m_MaxLevel, kills); -} - void BattlegroundAV::HandleKillPlayer(Player* player, Player* killer) { if (GetStatus() != STATUS_IN_PROGRESS) @@ -95,7 +89,7 @@ void BattlegroundAV::HandleKillUnit(Creature* unit, Player* killer) { CastSpellOnTeam(23658, HORDE); //this is a spell which finishes a quest where a player has to kill the boss RewardReputationToTeam(729, BG_AV_REP_BOSS, HORDE); - RewardHonorToTeam(GetBonusHonor(BG_AV_KILL_BOSS), HORDE); + RewardHonorToTeam(GetBonusHonorFromKill(BG_AV_KILL_BOSS), HORDE); EndBattleground(HORDE); DelCreature(AV_CPLACE_TRIGGER17); } @@ -103,7 +97,7 @@ void BattlegroundAV::HandleKillUnit(Creature* unit, Player* killer) { CastSpellOnTeam(23658, ALLIANCE); //this is a spell which finishes a quest where a player has to kill the boss RewardReputationToTeam(730, BG_AV_REP_BOSS, ALLIANCE); - RewardHonorToTeam(GetBonusHonor(BG_AV_KILL_BOSS), ALLIANCE); + RewardHonorToTeam(GetBonusHonorFromKill(BG_AV_KILL_BOSS), ALLIANCE); EndBattleground(ALLIANCE); DelCreature(AV_CPLACE_TRIGGER19); } @@ -116,7 +110,7 @@ void BattlegroundAV::HandleKillUnit(Creature* unit, Player* killer) } m_CaptainAlive[0]=false; RewardReputationToTeam(729, BG_AV_REP_CAPTAIN, HORDE); - RewardHonorToTeam(GetBonusHonor(BG_AV_KILL_CAPTAIN), HORDE); + RewardHonorToTeam(GetBonusHonorFromKill(BG_AV_KILL_CAPTAIN), HORDE); UpdateScore(ALLIANCE, (-1)*BG_AV_RES_CAPTAIN); //spawn destroyed aura for (uint8 i=0; i <= 9; i++) @@ -135,7 +129,7 @@ void BattlegroundAV::HandleKillUnit(Creature* unit, Player* killer) } m_CaptainAlive[1]=false; RewardReputationToTeam(730, BG_AV_REP_CAPTAIN, ALLIANCE); - RewardHonorToTeam(GetBonusHonor(BG_AV_KILL_CAPTAIN), ALLIANCE); + RewardHonorToTeam(GetBonusHonorFromKill(BG_AV_KILL_CAPTAIN), ALLIANCE); UpdateScore(HORDE, (-1)*BG_AV_RES_CAPTAIN); //spawn destroyed aura for (uint8 i=0; i <= 9; i++) @@ -279,33 +273,24 @@ void BattlegroundAV::UpdateScore(uint16 team, int16 points) Creature* BattlegroundAV::AddAVCreature(uint16 cinfoid, uint16 type) { - uint8 level; bool isStatic = false; Creature* creature = NULL; ASSERT(type <= AV_CPLACE_MAX + AV_STATICCPLACE_MAX); if (type >= AV_CPLACE_MAX) //static { type -= AV_CPLACE_MAX; - cinfoid=uint16(BG_AV_StaticCreaturePos[type][4]); - creature = AddCreature(BG_AV_StaticCreatureInfo[cinfoid][0], - (type+AV_CPLACE_MAX), + cinfoid = uint16(BG_AV_StaticCreaturePos[type][4]); + creature = AddCreature(BG_AV_StaticCreatureInfo[cinfoid], + type + AV_CPLACE_MAX, BG_AV_StaticCreaturePos[type][0], BG_AV_StaticCreaturePos[type][1], BG_AV_StaticCreaturePos[type][2], BG_AV_StaticCreaturePos[type][3]); - level = (BG_AV_StaticCreatureInfo[cinfoid][2] == BG_AV_StaticCreatureInfo[cinfoid][3]) - ? BG_AV_StaticCreatureInfo[cinfoid][2] - : urand(BG_AV_StaticCreatureInfo[cinfoid][2], BG_AV_StaticCreatureInfo[cinfoid][3]); isStatic = true; } else { - creature = AddCreature(BG_AV_CreatureInfo[cinfoid][0], - type, - BG_AV_CreaturePos[type]); - level = (BG_AV_CreatureInfo[cinfoid][2] == BG_AV_CreatureInfo[cinfoid][3]) - ? BG_AV_CreatureInfo[cinfoid][2] - : urand(BG_AV_CreatureInfo[cinfoid][2], BG_AV_CreatureInfo[cinfoid][3]); + creature = AddCreature(BG_AV_CreatureInfo[cinfoid][0], type, BG_AV_CreaturePos[type]); } if (!creature) return NULL; @@ -330,10 +315,6 @@ Creature* BattlegroundAV::AddAVCreature(uint16 cinfoid, uint16 type) //just copied this code from a gm-command } - if (level != 0) - level += m_MaxLevel - 60; //maybe we can do this more generic for custom level-range.. actually it's blizzlike - creature->SetLevel(level); - uint32 triggerSpawnID = 0; uint32 newFaction = 0; if (creature->GetEntry() == BG_AV_CreatureInfo[AV_NPC_A_CAPTAIN][0]) @@ -358,9 +339,7 @@ Creature* BattlegroundAV::AddAVCreature(uint16 cinfoid, uint16 type) } if (triggerSpawnID && newFaction) { - if (Creature* trigger = AddCreature(WORLD_TRIGGER, - triggerSpawnID, - BG_AV_CreaturePos[triggerSpawnID])) + if (Creature* trigger = AddCreature(WORLD_TRIGGER, triggerSpawnID, BG_AV_CreaturePos[triggerSpawnID])) { trigger->setFaction(newFaction); trigger->CastSpell(trigger, SPELL_HONORABLE_DEFENDER_25Y, false); @@ -459,11 +438,7 @@ void BattlegroundAV::StartingEventOpenDoors() void BattlegroundAV::AddPlayer(Player* player) { Battleground::AddPlayer(player); - //create score and add it to map, default values are set in constructor - BattlegroundAVScore* sc = new BattlegroundAVScore; - PlayerScores[player->GetGUID()] = sc; - if (m_MaxLevel == 0) - m_MaxLevel=(player->getLevel()%10 == 0)? player->getLevel() : (player->getLevel()-(player->getLevel()%10))+10; /// @todo just look at the code \^_^/ --but queue-info should provide this information.. + PlayerScores[player->GetGUIDLow()] = new BattlegroundAVScore(player->GetGUID(), player->GetBGTeam()); } void BattlegroundAV::EndBattleground(uint32 winner) @@ -499,7 +474,7 @@ void BattlegroundAV::EndBattleground(uint32 winner) if (rep[i] != 0) RewardReputationToTeam(i == 0 ? 730 : 729, rep[i], i == 0 ? ALLIANCE : HORDE); if (kills[i] != 0) - RewardHonorToTeam(GetBonusHonor(kills[i]), i == 0 ? ALLIANCE : HORDE); + RewardHonorToTeam(GetBonusHonorFromKill(kills[i]), i == 0 ? ALLIANCE : HORDE); } /// @todo add enterevademode for all attacking creatures @@ -553,43 +528,29 @@ void BattlegroundAV::HandleAreaTrigger(Player* player, uint32 trigger) } } -void BattlegroundAV::UpdatePlayerScore(Player* Source, uint32 type, uint32 value, bool doAddHonor) +bool BattlegroundAV::UpdatePlayerScore(Player* player, uint32 type, uint32 value, bool doAddHonor) { - BattlegroundScoreMap::iterator itr = PlayerScores.find(Source->GetGUID()); - if (itr == PlayerScores.end()) // player not found... - return; + if (!Battleground::UpdatePlayerScore(player, type, value, doAddHonor)) + return false; switch (type) { case SCORE_GRAVEYARDS_ASSAULTED: - ((BattlegroundAVScore*)itr->second)->GraveyardsAssaulted += value; - Source->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BG_OBJECTIVE_CAPTURE, AV_OBJECTIVE_ASSAULT_GRAVEYARD); + player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BG_OBJECTIVE_CAPTURE, AV_OBJECTIVE_ASSAULT_GRAVEYARD); break; case SCORE_GRAVEYARDS_DEFENDED: - ((BattlegroundAVScore*)itr->second)->GraveyardsDefended += value; - Source->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BG_OBJECTIVE_CAPTURE, AV_OBJECTIVE_DEFEND_GRAVEYARD); + player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BG_OBJECTIVE_CAPTURE, AV_OBJECTIVE_DEFEND_GRAVEYARD); break; case SCORE_TOWERS_ASSAULTED: - ((BattlegroundAVScore*)itr->second)->TowersAssaulted += value; - Source->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BG_OBJECTIVE_CAPTURE, AV_OBJECTIVE_ASSAULT_TOWER); + player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BG_OBJECTIVE_CAPTURE, AV_OBJECTIVE_ASSAULT_TOWER); break; case SCORE_TOWERS_DEFENDED: - ((BattlegroundAVScore*)itr->second)->TowersDefended += value; - Source->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BG_OBJECTIVE_CAPTURE, AV_OBJECTIVE_DEFEND_TOWER); - break; - case SCORE_MINES_CAPTURED: - ((BattlegroundAVScore*)itr->second)->MinesCaptured += value; - break; - case SCORE_LEADERS_KILLED: - ((BattlegroundAVScore*)itr->second)->LeadersKilled += value; - break; - case SCORE_SECONDARY_OBJECTIVES: - ((BattlegroundAVScore*)itr->second)->SecondaryObjectives += value; + player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BG_OBJECTIVE_CAPTURE, AV_OBJECTIVE_DEFEND_TOWER); break; default: - Battleground::UpdatePlayerScore(Source, type, value, doAddHonor); break; } + return true; } void BattlegroundAV::EventPlayerDestroyedPoint(BG_AV_Nodes node) @@ -617,7 +578,7 @@ void BattlegroundAV::EventPlayerDestroyedPoint(BG_AV_Nodes node) UpdateScore((owner == ALLIANCE) ? HORDE : ALLIANCE, -1 * BG_AV_RES_TOWER); RewardReputationToTeam(owner == ALLIANCE ? 730 : 729, BG_AV_REP_TOWER, owner); - RewardHonorToTeam(GetBonusHonor(BG_AV_KILL_TOWER), owner); + RewardHonorToTeam(GetBonusHonorFromKill(BG_AV_KILL_TOWER), owner); SpawnBGObject(BG_AV_OBJECT_TAURA_A_DUNBALDAR_SOUTH+GetTeamIndexByTeamId(owner)+(2*tmp), RESPAWN_ONE_DAY); SpawnBGObject(BG_AV_OBJECT_TFLAG_A_DUNBALDAR_SOUTH+GetTeamIndexByTeamId(owner)+(2*tmp), RESPAWN_ONE_DAY); @@ -1222,27 +1183,27 @@ bool BattlegroundAV::SetupBattleground() if (i <= BG_AV_NODES_FROSTWOLF_HUT) { if (!AddObject(i, BG_AV_OBJECTID_BANNER_A_B, - BG_AV_ObjectPos[i][0], BG_AV_ObjectPos[i][1], BG_AV_ObjectPos[i][2], BG_AV_ObjectPos[i][3], - 0, 0, std::sin(BG_AV_ObjectPos[i][3]/2), std::cos(BG_AV_ObjectPos[i][3]/2), RESPAWN_ONE_DAY) + BG_AV_ObjectPos[i], + 0, 0, std::sin(BG_AV_ObjectPos[i].GetOrientation()/2), std::cos(BG_AV_ObjectPos[i].GetOrientation()/2), RESPAWN_ONE_DAY) || !AddObject(i+11, BG_AV_OBJECTID_BANNER_CONT_A_B, - BG_AV_ObjectPos[i][0], BG_AV_ObjectPos[i][1], BG_AV_ObjectPos[i][2], BG_AV_ObjectPos[i][3], - 0, 0, std::sin(BG_AV_ObjectPos[i][3]/2), std::cos(BG_AV_ObjectPos[i][3]/2), RESPAWN_ONE_DAY) + BG_AV_ObjectPos[i], + 0, 0, std::sin(BG_AV_ObjectPos[i].GetOrientation()/2), std::cos(BG_AV_ObjectPos[i].GetOrientation()/2), RESPAWN_ONE_DAY) || !AddObject(i+33, BG_AV_OBJECTID_BANNER_H_B, - BG_AV_ObjectPos[i][0], BG_AV_ObjectPos[i][1], BG_AV_ObjectPos[i][2], BG_AV_ObjectPos[i][3], - 0, 0, std::sin(BG_AV_ObjectPos[i][3]/2), std::cos(BG_AV_ObjectPos[i][3]/2), RESPAWN_ONE_DAY) + BG_AV_ObjectPos[i], + 0, 0, std::sin(BG_AV_ObjectPos[i].GetOrientation()/2), std::cos(BG_AV_ObjectPos[i].GetOrientation()/2), RESPAWN_ONE_DAY) || !AddObject(i+22, BG_AV_OBJECTID_BANNER_CONT_H_B, - BG_AV_ObjectPos[i][0], BG_AV_ObjectPos[i][1], BG_AV_ObjectPos[i][2], BG_AV_ObjectPos[i][3], - 0, 0, std::sin(BG_AV_ObjectPos[i][3]/2), std::cos(BG_AV_ObjectPos[i][3]/2), RESPAWN_ONE_DAY) + BG_AV_ObjectPos[i], + 0, 0, std::sin(BG_AV_ObjectPos[i].GetOrientation()/2), std::cos(BG_AV_ObjectPos[i].GetOrientation()/2), RESPAWN_ONE_DAY) //aura || !AddObject(BG_AV_OBJECT_AURA_N_FIRSTAID_STATION+i*3, BG_AV_OBJECTID_AURA_N, - BG_AV_ObjectPos[i][0], BG_AV_ObjectPos[i][1], BG_AV_ObjectPos[i][2], BG_AV_ObjectPos[i][3], - 0, 0, std::sin(BG_AV_ObjectPos[i][3]/2), std::cos(BG_AV_ObjectPos[i][3]/2), RESPAWN_ONE_DAY) + BG_AV_ObjectPos[i], + 0, 0, std::sin(BG_AV_ObjectPos[i].GetOrientation()/2), std::cos(BG_AV_ObjectPos[i].GetOrientation()/2), RESPAWN_ONE_DAY) || !AddObject(BG_AV_OBJECT_AURA_A_FIRSTAID_STATION+i*3, BG_AV_OBJECTID_AURA_A, - BG_AV_ObjectPos[i][0], BG_AV_ObjectPos[i][1], BG_AV_ObjectPos[i][2], BG_AV_ObjectPos[i][3], - 0, 0, std::sin(BG_AV_ObjectPos[i][3]/2), std::cos(BG_AV_ObjectPos[i][3]/2), RESPAWN_ONE_DAY) + BG_AV_ObjectPos[i], + 0, 0, std::sin(BG_AV_ObjectPos[i].GetOrientation()/2), std::cos(BG_AV_ObjectPos[i].GetOrientation()/2), RESPAWN_ONE_DAY) || !AddObject(BG_AV_OBJECT_AURA_H_FIRSTAID_STATION+i*3, BG_AV_OBJECTID_AURA_H, - BG_AV_ObjectPos[i][0], BG_AV_ObjectPos[i][1], BG_AV_ObjectPos[i][2], BG_AV_ObjectPos[i][3], - 0, 0, std::sin(BG_AV_ObjectPos[i][3]/2), std::cos(BG_AV_ObjectPos[i][3]/2), RESPAWN_ONE_DAY)) + BG_AV_ObjectPos[i], + 0, 0, std::sin(BG_AV_ObjectPos[i].GetOrientation()/2), std::cos(BG_AV_ObjectPos[i].GetOrientation()/2), RESPAWN_ONE_DAY)) { TC_LOG_ERROR("bg.battleground", "BatteGroundAV: Failed to spawn some object Battleground not created!2"); return false; @@ -1253,23 +1214,23 @@ bool BattlegroundAV::SetupBattleground() if (i <= BG_AV_NODES_STONEHEART_BUNKER) //alliance towers { if (!AddObject(i, BG_AV_OBJECTID_BANNER_A, - BG_AV_ObjectPos[i][0], BG_AV_ObjectPos[i][1], BG_AV_ObjectPos[i][2], BG_AV_ObjectPos[i][3], - 0, 0, std::sin(BG_AV_ObjectPos[i][3]/2), std::cos(BG_AV_ObjectPos[i][3]/2), RESPAWN_ONE_DAY) + BG_AV_ObjectPos[i], + 0, 0, std::sin(BG_AV_ObjectPos[i].GetOrientation()/2), std::cos(BG_AV_ObjectPos[i].GetOrientation()/2), RESPAWN_ONE_DAY) || !AddObject(i+22, BG_AV_OBJECTID_BANNER_CONT_H, - BG_AV_ObjectPos[i][0], BG_AV_ObjectPos[i][1], BG_AV_ObjectPos[i][2], BG_AV_ObjectPos[i][3], - 0, 0, std::sin(BG_AV_ObjectPos[i][3]/2), std::cos(BG_AV_ObjectPos[i][3]/2), RESPAWN_ONE_DAY) + BG_AV_ObjectPos[i], + 0, 0, std::sin(BG_AV_ObjectPos[i].GetOrientation()/2), std::cos(BG_AV_ObjectPos[i].GetOrientation()/2), RESPAWN_ONE_DAY) || !AddObject(BG_AV_OBJECT_TAURA_A_DUNBALDAR_SOUTH+(2*(i-BG_AV_NODES_DUNBALDAR_SOUTH)), BG_AV_OBJECTID_AURA_A, - BG_AV_ObjectPos[i+8][0], BG_AV_ObjectPos[i+8][1], BG_AV_ObjectPos[i+8][2], BG_AV_ObjectPos[i+8][3], - 0, 0, std::sin(BG_AV_ObjectPos[i+8][3]/2), std::cos(BG_AV_ObjectPos[i+8][3]/2), RESPAWN_ONE_DAY) + BG_AV_ObjectPos[i+8], + 0, 0, std::sin(BG_AV_ObjectPos[i+8].GetOrientation()/2), std::cos(BG_AV_ObjectPos[i+8].GetOrientation()/2), RESPAWN_ONE_DAY) || !AddObject(BG_AV_OBJECT_TAURA_H_DUNBALDAR_SOUTH+(2*(i-BG_AV_NODES_DUNBALDAR_SOUTH)), BG_AV_OBJECTID_AURA_N, - BG_AV_ObjectPos[i+8][0], BG_AV_ObjectPos[i+8][1], BG_AV_ObjectPos[i+8][2], BG_AV_ObjectPos[i+8][3], - 0, 0, std::sin(BG_AV_ObjectPos[i+8][3]/2), std::cos(BG_AV_ObjectPos[i+8][3]/2), RESPAWN_ONE_DAY) + BG_AV_ObjectPos[i+8], + 0, 0, std::sin(BG_AV_ObjectPos[i+8].GetOrientation()/2), std::cos(BG_AV_ObjectPos[i+8].GetOrientation()/2), RESPAWN_ONE_DAY) || !AddObject(BG_AV_OBJECT_TFLAG_A_DUNBALDAR_SOUTH+(2*(i-BG_AV_NODES_DUNBALDAR_SOUTH)), BG_AV_OBJECTID_TOWER_BANNER_A, - BG_AV_ObjectPos[i+8][0], BG_AV_ObjectPos[i+8][1], BG_AV_ObjectPos[i+8][2], BG_AV_ObjectPos[i+8][3], - 0, 0, std::sin(BG_AV_ObjectPos[i+8][3]/2), std::cos(BG_AV_ObjectPos[i+8][3]/2), RESPAWN_ONE_DAY) + BG_AV_ObjectPos[i+8], + 0, 0, std::sin(BG_AV_ObjectPos[i+8].GetOrientation()/2), std::cos(BG_AV_ObjectPos[i+8].GetOrientation()/2), RESPAWN_ONE_DAY) || !AddObject(BG_AV_OBJECT_TFLAG_H_DUNBALDAR_SOUTH+(2*(i-BG_AV_NODES_DUNBALDAR_SOUTH)), BG_AV_OBJECTID_TOWER_BANNER_PH, - BG_AV_ObjectPos[i+8][0], BG_AV_ObjectPos[i+8][1], BG_AV_ObjectPos[i+8][2], BG_AV_ObjectPos[i+8][3], - 0, 0, std::sin(BG_AV_ObjectPos[i+8][3]/2), std::cos(BG_AV_ObjectPos[i+8][3]/2), RESPAWN_ONE_DAY)) + BG_AV_ObjectPos[i+8], + 0, 0, std::sin(BG_AV_ObjectPos[i+8].GetOrientation()/2), std::cos(BG_AV_ObjectPos[i+8].GetOrientation()/2), RESPAWN_ONE_DAY)) { TC_LOG_ERROR("bg.battleground", "BatteGroundAV: Failed to spawn some object Battleground not created!3"); return false; @@ -1278,23 +1239,23 @@ bool BattlegroundAV::SetupBattleground() else //horde towers { if (!AddObject(i+7, BG_AV_OBJECTID_BANNER_CONT_A, - BG_AV_ObjectPos[i][0], BG_AV_ObjectPos[i][1], BG_AV_ObjectPos[i][2], BG_AV_ObjectPos[i][3], - 0, 0, std::sin(BG_AV_ObjectPos[i][3]/2), std::cos(BG_AV_ObjectPos[i][3]/2), RESPAWN_ONE_DAY) + BG_AV_ObjectPos[i], + 0, 0, std::sin(BG_AV_ObjectPos[i].GetOrientation()/2), std::cos(BG_AV_ObjectPos[i].GetOrientation()/2), RESPAWN_ONE_DAY) || !AddObject(i+29, BG_AV_OBJECTID_BANNER_H, - BG_AV_ObjectPos[i][0], BG_AV_ObjectPos[i][1], BG_AV_ObjectPos[i][2], BG_AV_ObjectPos[i][3], - 0, 0, std::sin(BG_AV_ObjectPos[i][3]/2), std::cos(BG_AV_ObjectPos[i][3]/2), RESPAWN_ONE_DAY) + BG_AV_ObjectPos[i], + 0, 0, std::sin(BG_AV_ObjectPos[i].GetOrientation()/2), std::cos(BG_AV_ObjectPos[i].GetOrientation()/2), RESPAWN_ONE_DAY) || !AddObject(BG_AV_OBJECT_TAURA_A_DUNBALDAR_SOUTH+(2*(i-BG_AV_NODES_DUNBALDAR_SOUTH)), BG_AV_OBJECTID_AURA_N, - BG_AV_ObjectPos[i+8][0], BG_AV_ObjectPos[i+8][1], BG_AV_ObjectPos[i+8][2], BG_AV_ObjectPos[i+8][3], - 0, 0, std::sin(BG_AV_ObjectPos[i+8][3]/2), std::cos(BG_AV_ObjectPos[i+8][3]/2), RESPAWN_ONE_DAY) + BG_AV_ObjectPos[i+8], + 0, 0, std::sin(BG_AV_ObjectPos[i+8].GetOrientation()/2), std::cos(BG_AV_ObjectPos[i+8].GetOrientation()/2), RESPAWN_ONE_DAY) || !AddObject(BG_AV_OBJECT_TAURA_H_DUNBALDAR_SOUTH+(2*(i-BG_AV_NODES_DUNBALDAR_SOUTH)), BG_AV_OBJECTID_AURA_H, - BG_AV_ObjectPos[i+8][0], BG_AV_ObjectPos[i+8][1], BG_AV_ObjectPos[i+8][2], BG_AV_ObjectPos[i+8][3], - 0, 0, std::sin(BG_AV_ObjectPos[i+8][3]/2), std::cos(BG_AV_ObjectPos[i+8][3]/2), RESPAWN_ONE_DAY) + BG_AV_ObjectPos[i+8], + 0, 0, std::sin(BG_AV_ObjectPos[i+8].GetOrientation()/2), std::cos(BG_AV_ObjectPos[i+8].GetOrientation()/2), RESPAWN_ONE_DAY) || !AddObject(BG_AV_OBJECT_TFLAG_A_DUNBALDAR_SOUTH+(2*(i-BG_AV_NODES_DUNBALDAR_SOUTH)), BG_AV_OBJECTID_TOWER_BANNER_PA, - BG_AV_ObjectPos[i+8][0], BG_AV_ObjectPos[i+8][1], BG_AV_ObjectPos[i+8][2], BG_AV_ObjectPos[i+8][3], - 0, 0, std::sin(BG_AV_ObjectPos[i+8][3]/2), std::cos(BG_AV_ObjectPos[i+8][3]/2), RESPAWN_ONE_DAY) + BG_AV_ObjectPos[i+8], + 0, 0, std::sin(BG_AV_ObjectPos[i+8].GetOrientation()/2), std::cos(BG_AV_ObjectPos[i+8].GetOrientation()/2), RESPAWN_ONE_DAY) || !AddObject(BG_AV_OBJECT_TFLAG_H_DUNBALDAR_SOUTH+(2*(i-BG_AV_NODES_DUNBALDAR_SOUTH)), BG_AV_OBJECTID_TOWER_BANNER_H, - BG_AV_ObjectPos[i+8][0], BG_AV_ObjectPos[i+8][1], BG_AV_ObjectPos[i+8][2], BG_AV_ObjectPos[i+8][3], - 0, 0, std::sin(BG_AV_ObjectPos[i+8][3]/2), std::cos(BG_AV_ObjectPos[i+8][3]/2), RESPAWN_ONE_DAY)) + BG_AV_ObjectPos[i+8], + 0, 0, std::sin(BG_AV_ObjectPos[i+8].GetOrientation()/2), std::cos(BG_AV_ObjectPos[i+8].GetOrientation()/2), RESPAWN_ONE_DAY)) { TC_LOG_ERROR("bg.battleground", "BatteGroundAV: Failed to spawn some object Battleground not created!4"); return false; @@ -1304,14 +1265,11 @@ bool BattlegroundAV::SetupBattleground() { if (!AddObject(BG_AV_OBJECT_BURN_DUNBALDAR_SOUTH+((i-BG_AV_NODES_DUNBALDAR_SOUTH)*10)+j, BG_AV_OBJECTID_FIRE, - BG_AV_ObjectPos[AV_OPLACE_BURN_DUNBALDAR_SOUTH+((i-BG_AV_NODES_DUNBALDAR_SOUTH)*10)+j][0], - BG_AV_ObjectPos[AV_OPLACE_BURN_DUNBALDAR_SOUTH+((i-BG_AV_NODES_DUNBALDAR_SOUTH)*10)+j][1], - BG_AV_ObjectPos[AV_OPLACE_BURN_DUNBALDAR_SOUTH+((i-BG_AV_NODES_DUNBALDAR_SOUTH)*10)+j][2], - BG_AV_ObjectPos[AV_OPLACE_BURN_DUNBALDAR_SOUTH+((i-BG_AV_NODES_DUNBALDAR_SOUTH)*10)+j][3], + BG_AV_ObjectPos[AV_OPLACE_BURN_DUNBALDAR_SOUTH+((i-BG_AV_NODES_DUNBALDAR_SOUTH)*10)+j], 0, 0, - std::sin(BG_AV_ObjectPos[AV_OPLACE_BURN_DUNBALDAR_SOUTH+((i-BG_AV_NODES_DUNBALDAR_SOUTH)*10)+j][3]/2), - std::cos(BG_AV_ObjectPos[AV_OPLACE_BURN_DUNBALDAR_SOUTH+((i-BG_AV_NODES_DUNBALDAR_SOUTH)*10)+j][3]/2), + std::sin(BG_AV_ObjectPos[AV_OPLACE_BURN_DUNBALDAR_SOUTH+((i-BG_AV_NODES_DUNBALDAR_SOUTH)*10)+j].GetOrientation()/2), + std::cos(BG_AV_ObjectPos[AV_OPLACE_BURN_DUNBALDAR_SOUTH+((i-BG_AV_NODES_DUNBALDAR_SOUTH)*10)+j].GetOrientation()/2), RESPAWN_ONE_DAY)) { TC_LOG_ERROR("bg.battleground", "BatteGroundAV: Failed to spawn some object Battleground not created!5.%i", i); @@ -1328,14 +1286,11 @@ bool BattlegroundAV::SetupBattleground() { if (!AddObject(BG_AV_OBJECT_BURN_BUILDING_ALLIANCE+(i*10)+j, BG_AV_OBJECTID_SMOKE, - BG_AV_ObjectPos[AV_OPLACE_BURN_BUILDING_A+(i*10)+j][0], - BG_AV_ObjectPos[AV_OPLACE_BURN_BUILDING_A+(i*10)+j][1], - BG_AV_ObjectPos[AV_OPLACE_BURN_BUILDING_A+(i*10)+j][2], - BG_AV_ObjectPos[AV_OPLACE_BURN_BUILDING_A+(i*10)+j][3], + BG_AV_ObjectPos[AV_OPLACE_BURN_BUILDING_A+(i*10)+j], 0, 0, - std::sin(BG_AV_ObjectPos[AV_OPLACE_BURN_BUILDING_A+(i*10)+j][3]/2), - std::cos(BG_AV_ObjectPos[AV_OPLACE_BURN_BUILDING_A+(i*10)+j][3]/2), + std::sin(BG_AV_ObjectPos[AV_OPLACE_BURN_BUILDING_A+(i*10)+j].GetOrientation()/2), + std::cos(BG_AV_ObjectPos[AV_OPLACE_BURN_BUILDING_A+(i*10)+j].GetOrientation()/2), RESPAWN_ONE_DAY)) { TC_LOG_ERROR("bg.battleground", "BatteGroundAV: Failed to spawn some object Battleground not created!6.%i", i); @@ -1346,14 +1301,11 @@ bool BattlegroundAV::SetupBattleground() { if (!AddObject(BG_AV_OBJECT_BURN_BUILDING_ALLIANCE+(i*10)+j, BG_AV_OBJECTID_FIRE, - BG_AV_ObjectPos[AV_OPLACE_BURN_BUILDING_A+(i*10)+j][0], - BG_AV_ObjectPos[AV_OPLACE_BURN_BUILDING_A+(i*10)+j][1], - BG_AV_ObjectPos[AV_OPLACE_BURN_BUILDING_A+(i*10)+j][2], - BG_AV_ObjectPos[AV_OPLACE_BURN_BUILDING_A+(i*10)+j][3], + BG_AV_ObjectPos[AV_OPLACE_BURN_BUILDING_A+(i*10)+j], 0, 0, - std::sin(BG_AV_ObjectPos[AV_OPLACE_BURN_BUILDING_A+(i*10)+j][3]/2), - std::cos(BG_AV_ObjectPos[AV_OPLACE_BURN_BUILDING_A+(i*10)+j][3]/2), + std::sin(BG_AV_ObjectPos[AV_OPLACE_BURN_BUILDING_A+(i*10)+j].GetOrientation()/2), + std::cos(BG_AV_ObjectPos[AV_OPLACE_BURN_BUILDING_A+(i*10)+j].GetOrientation()/2), RESPAWN_ONE_DAY)) { TC_LOG_ERROR("bg.battleground", "BatteGroundAV: Failed to spawn some object Battleground not created!7.%i", i); @@ -1366,14 +1318,11 @@ bool BattlegroundAV::SetupBattleground() { if (!AddObject(BG_AV_OBJECT_MINE_SUPPLY_N_MIN+i, BG_AV_OBJECTID_MINE_N, - BG_AV_ObjectPos[AV_OPLACE_MINE_SUPPLY_N_MIN+i][0], - BG_AV_ObjectPos[AV_OPLACE_MINE_SUPPLY_N_MIN+i][1], - BG_AV_ObjectPos[AV_OPLACE_MINE_SUPPLY_N_MIN+i][2], - BG_AV_ObjectPos[AV_OPLACE_MINE_SUPPLY_N_MIN+i][3], + BG_AV_ObjectPos[AV_OPLACE_MINE_SUPPLY_N_MIN+i], 0, 0, - std::sin(BG_AV_ObjectPos[AV_OPLACE_MINE_SUPPLY_N_MIN+i][3]/2), - std::cos(BG_AV_ObjectPos[AV_OPLACE_MINE_SUPPLY_N_MIN+i][3]/2), + std::sin(BG_AV_ObjectPos[AV_OPLACE_MINE_SUPPLY_N_MIN+i].GetOrientation()/2), + std::cos(BG_AV_ObjectPos[AV_OPLACE_MINE_SUPPLY_N_MIN+i].GetOrientation()/2), RESPAWN_ONE_DAY)) { TC_LOG_ERROR("bg.battleground", "BatteGroundAV: Failed to spawn some mine supplies Battleground not created!7.5.%i", i); @@ -1384,14 +1333,11 @@ bool BattlegroundAV::SetupBattleground() { if (!AddObject(BG_AV_OBJECT_MINE_SUPPLY_S_MIN+i, BG_AV_OBJECTID_MINE_S, - BG_AV_ObjectPos[AV_OPLACE_MINE_SUPPLY_S_MIN+i][0], - BG_AV_ObjectPos[AV_OPLACE_MINE_SUPPLY_S_MIN+i][1], - BG_AV_ObjectPos[AV_OPLACE_MINE_SUPPLY_S_MIN+i][2], - BG_AV_ObjectPos[AV_OPLACE_MINE_SUPPLY_S_MIN+i][3], + BG_AV_ObjectPos[AV_OPLACE_MINE_SUPPLY_S_MIN+i], 0, 0, - std::sin(BG_AV_ObjectPos[AV_OPLACE_MINE_SUPPLY_S_MIN+i][3]/2), - std::cos(BG_AV_ObjectPos[AV_OPLACE_MINE_SUPPLY_S_MIN+i][3]/2), + std::sin(BG_AV_ObjectPos[AV_OPLACE_MINE_SUPPLY_S_MIN+i].GetOrientation()/2), + std::cos(BG_AV_ObjectPos[AV_OPLACE_MINE_SUPPLY_S_MIN+i].GetOrientation()/2), RESPAWN_ONE_DAY)) { TC_LOG_ERROR("bg.battleground", "BatteGroundAV: Failed to spawn some mine supplies Battleground not created!7.6.%i", i); @@ -1401,14 +1347,11 @@ bool BattlegroundAV::SetupBattleground() if (!AddObject(BG_AV_OBJECT_FLAG_N_SNOWFALL_GRAVE, BG_AV_OBJECTID_BANNER_SNOWFALL_N, - BG_AV_ObjectPos[BG_AV_NODES_SNOWFALL_GRAVE][0], - BG_AV_ObjectPos[BG_AV_NODES_SNOWFALL_GRAVE][1], - BG_AV_ObjectPos[BG_AV_NODES_SNOWFALL_GRAVE][2], - BG_AV_ObjectPos[BG_AV_NODES_SNOWFALL_GRAVE][3], + BG_AV_ObjectPos[BG_AV_NODES_SNOWFALL_GRAVE], 0, 0, - std::sin(BG_AV_ObjectPos[BG_AV_NODES_SNOWFALL_GRAVE][3]/2), - std::cos(BG_AV_ObjectPos[BG_AV_NODES_SNOWFALL_GRAVE][3]/2), + std::sin(BG_AV_ObjectPos[BG_AV_NODES_SNOWFALL_GRAVE].GetOrientation()/2), + std::cos(BG_AV_ObjectPos[BG_AV_NODES_SNOWFALL_GRAVE].GetOrientation()/2), RESPAWN_ONE_DAY)) { TC_LOG_ERROR("bg.battleground", "BatteGroundAV: Failed to spawn some object Battleground not created!8"); @@ -1417,17 +1360,17 @@ bool BattlegroundAV::SetupBattleground() for (uint8 i = 0; i < 4; i++) { if (!AddObject(BG_AV_OBJECT_SNOW_EYECANDY_A+i, BG_AV_OBJECTID_SNOWFALL_CANDY_A, - BG_AV_ObjectPos[AV_OPLACE_SNOW_1+i][0], BG_AV_ObjectPos[AV_OPLACE_SNOW_1+i][1], BG_AV_ObjectPos[AV_OPLACE_SNOW_1+i][2], BG_AV_ObjectPos[AV_OPLACE_SNOW_1+i][3], - 0, 0, std::sin(BG_AV_ObjectPos[AV_OPLACE_SNOW_1+i][3]/2), std::cos(BG_AV_ObjectPos[AV_OPLACE_SNOW_1+i][3]/2), RESPAWN_ONE_DAY) + BG_AV_ObjectPos[AV_OPLACE_SNOW_1+i], + 0, 0, std::sin(BG_AV_ObjectPos[AV_OPLACE_SNOW_1+i].GetOrientation()/2), std::cos(BG_AV_ObjectPos[AV_OPLACE_SNOW_1+i].GetOrientation()/2), RESPAWN_ONE_DAY) || !AddObject(BG_AV_OBJECT_SNOW_EYECANDY_PA+i, BG_AV_OBJECTID_SNOWFALL_CANDY_PA, - BG_AV_ObjectPos[AV_OPLACE_SNOW_1+i][0], BG_AV_ObjectPos[AV_OPLACE_SNOW_1+i][1], BG_AV_ObjectPos[AV_OPLACE_SNOW_1+i][2], BG_AV_ObjectPos[AV_OPLACE_SNOW_1+i][3], - 0, 0, std::sin(BG_AV_ObjectPos[AV_OPLACE_SNOW_1+i][3]/2), std::cos(BG_AV_ObjectPos[AV_OPLACE_SNOW_1+i][3]/2), RESPAWN_ONE_DAY) + BG_AV_ObjectPos[AV_OPLACE_SNOW_1+i], + 0, 0, std::sin(BG_AV_ObjectPos[AV_OPLACE_SNOW_1+i].GetOrientation()/2), std::cos(BG_AV_ObjectPos[AV_OPLACE_SNOW_1+i].GetOrientation()/2), RESPAWN_ONE_DAY) || !AddObject(BG_AV_OBJECT_SNOW_EYECANDY_H+i, BG_AV_OBJECTID_SNOWFALL_CANDY_H, - BG_AV_ObjectPos[AV_OPLACE_SNOW_1+i][0], BG_AV_ObjectPos[AV_OPLACE_SNOW_1+i][1], BG_AV_ObjectPos[AV_OPLACE_SNOW_1+i][2], BG_AV_ObjectPos[AV_OPLACE_SNOW_1+i][3], - 0, 0, std::sin(BG_AV_ObjectPos[AV_OPLACE_SNOW_1+i][3]/2), std::cos(BG_AV_ObjectPos[AV_OPLACE_SNOW_1+i][3]/2), RESPAWN_ONE_DAY) + BG_AV_ObjectPos[AV_OPLACE_SNOW_1+i], + 0, 0, std::sin(BG_AV_ObjectPos[AV_OPLACE_SNOW_1+i].GetOrientation()/2), std::cos(BG_AV_ObjectPos[AV_OPLACE_SNOW_1+i].GetOrientation()/2), RESPAWN_ONE_DAY) || !AddObject(BG_AV_OBJECT_SNOW_EYECANDY_PH+i, BG_AV_OBJECTID_SNOWFALL_CANDY_PH, - BG_AV_ObjectPos[AV_OPLACE_SNOW_1+i][0], BG_AV_ObjectPos[AV_OPLACE_SNOW_1+i][1], BG_AV_ObjectPos[AV_OPLACE_SNOW_1+i][2], BG_AV_ObjectPos[AV_OPLACE_SNOW_1+i][3], - 0, 0, std::sin(BG_AV_ObjectPos[AV_OPLACE_SNOW_1+i][3]/2), std::cos(BG_AV_ObjectPos[AV_OPLACE_SNOW_1+i][3]/2), RESPAWN_ONE_DAY)) + BG_AV_ObjectPos[AV_OPLACE_SNOW_1+i], + 0, 0, std::sin(BG_AV_ObjectPos[AV_OPLACE_SNOW_1+i].GetOrientation()/2), std::cos(BG_AV_ObjectPos[AV_OPLACE_SNOW_1+i].GetOrientation()/2), RESPAWN_ONE_DAY)) { TC_LOG_ERROR("bg.battleground", "BatteGroundAV: Failed to spawn some object Battleground not created!9.%i", i); return false; @@ -1591,8 +1534,6 @@ void BattlegroundAV::DefendNode(BG_AV_Nodes node, uint16 team) void BattlegroundAV::ResetBGSubclass() { - m_MaxLevel=0; - for (uint8 i=0; i<2; i++) //forloop for both teams (it just make 0 == alliance and 1 == horde also for both mines 0=north 1=south { for (uint8 j=0; j<9; j++) diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundAV.h b/src/server/game/Battlegrounds/Zones/BattlegroundAV.h index 03dd0ffcf5c..48ac25b4d11 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundAV.h +++ b/src/server/game/Battlegrounds/Zones/BattlegroundAV.h @@ -20,6 +20,7 @@ #define __BATTLEGROUNDAV_H #include "Battleground.h" +#include "BattlegroundScore.h" #include "Object.h" #define LANG_BG_AV_A_CAPTAIN_BUFF "Begone. Uncouth scum! The Alliance shall prevail in Alterac Valley!" @@ -131,10 +132,10 @@ enum BG_AV_ObjectIds BG_AV_OBJECTID_SNOWFALL_CANDY_PH = 179425, //banners on top of towers: - BG_AV_OBJECTID_TOWER_BANNER_A = 178927, //[PH] Alliance A1 Tower Banner BIG - BG_AV_OBJECTID_TOWER_BANNER_H = 178955, //[PH] Horde H1 Tower Banner BIG - BG_AV_OBJECTID_TOWER_BANNER_PA = 179446, //[PH] Alliance H1 Tower Pre-Banner BIG - BG_AV_OBJECTID_TOWER_BANNER_PH = 179436, //[PH] Horde A1 Tower Pre-Banner BIG + BG_AV_OBJECTID_TOWER_BANNER_A = 178927, //[PH] Alliance A1 Tower Banner BIG + BG_AV_OBJECTID_TOWER_BANNER_H = 178955, //[PH] Horde H1 Tower Banner BIG + BG_AV_OBJECTID_TOWER_BANNER_PA = 179446, //[PH] Alliance H1 Tower Pre-Banner BIG + BG_AV_OBJECTID_TOWER_BANNER_PH = 179436, //[PH] Horde A1 Tower Pre-Banner BIG //Auras BG_AV_OBJECTID_AURA_A = 180421, @@ -148,11 +149,11 @@ enum BG_AV_ObjectIds BG_AV_OBJECTID_GATE_H = 180424, //mine supplies - BG_AV_OBJECTID_MINE_N = 178785, - BG_AV_OBJECTID_MINE_S = 178784, + BG_AV_OBJECTID_MINE_N = 178785, + BG_AV_OBJECTID_MINE_S = 178784, BG_AV_OBJECTID_FIRE = 179065, - BG_AV_OBJECTID_SMOKE = 179066 + BG_AV_OBJECTID_SMOKE = 179066 }; enum BG_AV_Nodes @@ -306,58 +307,58 @@ enum BG_AV_ObjectTypes BG_AV_OBJECT_MINE_SUPPLY_S_MIN = 225, BG_AV_OBJECT_MINE_SUPPLY_S_MAX = 236, - BG_AV_OBJECT_MAX = 237 + BG_AV_OBJECT_MAX = 237 }; enum BG_AV_OBJECTS { - AV_OPLACE_FIRSTAID_STATION = 0, - AV_OPLACE_STORMPIKE_GRAVE = 1, - AV_OPLACE_STONEHEART_GRAVE = 2, - AV_OPLACE_SNOWFALL_GRAVE = 3, - AV_OPLACE_ICEBLOOD_GRAVE = 4, - AV_OPLACE_FROSTWOLF_GRAVE = 5, - AV_OPLACE_FROSTWOLF_HUT = 6, - AV_OPLACE_DUNBALDAR_SOUTH = 7, - AV_OPLACE_DUNBALDAR_NORTH = 8, - AV_OPLACE_ICEWING_BUNKER = 9, - AV_OPLACE_STONEHEART_BUNKER = 10, - AV_OPLACE_ICEBLOOD_TOWER = 11, - AV_OPLACE_TOWER_POINT = 12, - AV_OPLACE_FROSTWOLF_ETOWER = 13, - AV_OPLACE_FROSTWOLF_WTOWER = 14, - AV_OPLACE_BIGBANNER_DUNBALDAR_SOUTH = 15, - AV_OPLACE_BIGBANNER_DUNBALDAR_NORTH = 16, - AV_OPLACE_BIGBANNER_ICEWING_BUNKER = 17, - AV_OPLACE_BIGBANNER_STONEHEART_BUNKER = 18, - AV_OPLACE_BIGBANNER_ICEBLOOD_TOWER = 19, - AV_OPLACE_BIGBANNER_TOWER_POINT = 20, - AV_OPLACE_BIGBANNER_FROSTWOLF_ETOWER = 21, - AV_OPLACE_BIGBANNER_FROSTWOLF_WTOWER = 22, - - AV_OPLACE_BURN_DUNBALDAR_SOUTH = 23, - AV_OPLACE_BURN_DUNBALDAR_NORTH = 33, - AV_OPLACE_BURN_ICEWING_BUNKER = 43, - AV_OPLACE_BURN_STONEHEART_BUNKER = 53, - AV_OPLACE_BURN_ICEBLOOD_TOWER = 63, - AV_OPLACE_BURN_TOWER_POINT = 73, - AV_OPLACE_BURN_FROSTWOLF_ETOWER = 83, - AV_OPLACE_BURN_FROSTWOLF_WTOWER = 93, - AV_OPLACE_BURN_BUILDING_A = 103, - AV_OPLACE_BURN_BUILDING_H = 113, - AV_OPLACE_SNOW_1 = 123, - AV_OPLACE_SNOW_2 = 124, - AV_OPLACE_SNOW_3 = 125, - AV_OPLACE_SNOW_4 = 126, - AV_OPLACE_MINE_SUPPLY_N_MIN = 127, - AV_OPLACE_MINE_SUPPLY_N_MAX = 136, - AV_OPLACE_MINE_SUPPLY_S_MIN = 137, - AV_OPLACE_MINE_SUPPLY_S_MAX = 148, - - AV_OPLACE_MAX = 149 + AV_OPLACE_FIRSTAID_STATION = 0, + AV_OPLACE_STORMPIKE_GRAVE = 1, + AV_OPLACE_STONEHEART_GRAVE = 2, + AV_OPLACE_SNOWFALL_GRAVE = 3, + AV_OPLACE_ICEBLOOD_GRAVE = 4, + AV_OPLACE_FROSTWOLF_GRAVE = 5, + AV_OPLACE_FROSTWOLF_HUT = 6, + AV_OPLACE_DUNBALDAR_SOUTH = 7, + AV_OPLACE_DUNBALDAR_NORTH = 8, + AV_OPLACE_ICEWING_BUNKER = 9, + AV_OPLACE_STONEHEART_BUNKER = 10, + AV_OPLACE_ICEBLOOD_TOWER = 11, + AV_OPLACE_TOWER_POINT = 12, + AV_OPLACE_FROSTWOLF_ETOWER = 13, + AV_OPLACE_FROSTWOLF_WTOWER = 14, + AV_OPLACE_BIGBANNER_DUNBALDAR_SOUTH = 15, + AV_OPLACE_BIGBANNER_DUNBALDAR_NORTH = 16, + AV_OPLACE_BIGBANNER_ICEWING_BUNKER = 17, + AV_OPLACE_BIGBANNER_STONEHEART_BUNKER = 18, + AV_OPLACE_BIGBANNER_ICEBLOOD_TOWER = 19, + AV_OPLACE_BIGBANNER_TOWER_POINT = 20, + AV_OPLACE_BIGBANNER_FROSTWOLF_ETOWER = 21, + AV_OPLACE_BIGBANNER_FROSTWOLF_WTOWER = 22, + + AV_OPLACE_BURN_DUNBALDAR_SOUTH = 23, + AV_OPLACE_BURN_DUNBALDAR_NORTH = 33, + AV_OPLACE_BURN_ICEWING_BUNKER = 43, + AV_OPLACE_BURN_STONEHEART_BUNKER = 53, + AV_OPLACE_BURN_ICEBLOOD_TOWER = 63, + AV_OPLACE_BURN_TOWER_POINT = 73, + AV_OPLACE_BURN_FROSTWOLF_ETOWER = 83, + AV_OPLACE_BURN_FROSTWOLF_WTOWER = 93, + AV_OPLACE_BURN_BUILDING_A = 103, + AV_OPLACE_BURN_BUILDING_H = 113, + AV_OPLACE_SNOW_1 = 123, + AV_OPLACE_SNOW_2 = 124, + AV_OPLACE_SNOW_3 = 125, + AV_OPLACE_SNOW_4 = 126, + AV_OPLACE_MINE_SUPPLY_N_MIN = 127, + AV_OPLACE_MINE_SUPPLY_N_MAX = 136, + AV_OPLACE_MINE_SUPPLY_S_MIN = 137, + AV_OPLACE_MINE_SUPPLY_S_MAX = 148, + + AV_OPLACE_MAX = 149 }; -const float BG_AV_ObjectPos[AV_OPLACE_MAX][4] = +Position const BG_AV_ObjectPos[AV_OPLACE_MAX] = { {638.592f, -32.422f, 46.0608f, -1.62316f }, //firstaid station {669.007f, -294.078f, 30.2909f, 2.77507f }, //stormpike @@ -1228,59 +1229,59 @@ const float BG_AV_StaticCreaturePos[AV_STATICCPLACE_MAX][5] = {-1370.9f, -219.793f, 98.4258f, 5.04381f, 47}, //drek thar }; -const uint32 BG_AV_StaticCreatureInfo[51][4] = +const uint32 BG_AV_StaticCreatureInfo[51] = { - { 2225, 1215, 55, 55 }, //Zora Guthrek - { 3343, 1215, 55, 55 }, //Grelkor - { 3625, 1215, 55, 55 }, //Rarck - { 4255, 1217, 55, 55 }, //Brogus Thunderbrew - { 4257, 1217, 55, 55 }, //Lana Thunderbrew - { 5134, 1217, 55, 55 }, //Jonivera Farmountain - { 5135, 1217, 55, 55 }, //Svalbrad Farmountain - { 5139, 1217, 55, 55 }, //Kurdrum Barleybeard - { 10364, 1215, 55, 55 }, //Yaelika Farclaw - { 10367, 1215, 55, 55 }, //Shrye Ragefist - { 10981, 38, 50, 51 }, //Frostwolf - { 10986, 514, 52, 53 }, //Snowblind Harpy - { 10990, 1274, 50, 51 }, //Alterac Ram - { 11675, 514, 53, 53 }, //Snowblind Windcaller - { 11678, 14, 52, 53 }, //Snowblind Ambusher - { 11839, 39, 56, 56 }, //Wildpaw Brute - { 11947, 1214, 61, 61 }, // Captain Galvangar /// @todo: Duplicate ? Check and confirm - { 11948, 1216, 63, 63 }, //Vanndar Stormpike - { 11949, 1216, 61, 61 }, //Captain Balinda Stonehearth - { 11997, 1334, 60, 60 }, //Stormpike Herald - { 12051, 1214, 57, 57 }, //Frostwolf Legionnaire - { 12096, 1217, 55, 55 }, //Stormpike Quartermaster - { 12097, 1215, 55, 55 }, //Frostwolf Quartermaster - { 12127, 1216, 57, 57 }, //Stormpike Guardsman - { 13176, 1215, 60, 60 }, //Smith Regzar - { 13179, 1215, 59, 59 }, //Wing Commander Guse - { 13216, 1217, 58, 58 }, //Gaelden Hammersmith - { 13218, 1215, 58, 58 }, //Grunnda Wolfheart - { 13236, 1214, 60, 60 }, //Primalist Thurloga - { 13257, 1216, 60, 60 }, //Murgot Deepforge - { 13284, 1214, 58, 58 }, //Frostwolf Shaman - { 13438, 1217, 58, 58 }, //Wing Commander Slidore - { 13442, 1216, 60, 60 }, //Arch Druid Renferal - { 13443, 1216, 60, 60 }, //Druid of the Grove - { 13447, 1216, 58, 58 }, //Corporal Noreg Stormpike - { 13577, 1216, 60, 60 }, //Stormpike Ram Rider Commander - { 13617, 1216, 60, 60 }, //Stormpike Stable Master - { 13797, 32, 60, 61 }, //Mountaineer Boombellow - { 13798, 1214, 60, 61 }, //Jotek - { 13816, 1216, 61, 61 }, //Prospector Stonehewer - { 14185, 877, 59, 59 }, //Najak Hexxen - { 14186, 105, 60, 60 }, //Ravak Grimtotem - { 14187, 1594, 60, 60 }, //Athramanis - { 14188, 57, 59, 59 }, //Dirk Swindle - { 14282, 1214, 53, 54 }, //Frostwolf Bloodhound - { 14283, 1216, 53, 54 }, //Stormpike Owl - { 14284, 1216, 61, 61 }, //Stormpike Battleguard - { 11946, 1214, 63, 63 }, //Drek'Thar /// @todo: Correct the level (Level 80 for boss ?) - { 11948, 1216, 63, 63 }, //Vanndar Stormpike - { 11947, 1214, 61, 61 }, //Captain Galvangar - { 11949, 1216, 61, 61 } //Captain Balinda Stonehearth + 2225, // Zora Guthrek + 3343, // Grelkor + 3625, // Rarck + 4255, // Brogus Thunderbrew + 4257, // Lana Thunderbrew + 5134, // Jonivera Farmountain + 5135, // Svalbrad Farmountain + 5139, // Kurdrum Barleybeard + 10364, // Yaelika Farclaw + 10367, // Shrye Ragefist + 10981, // Frostwolf + 10986, // Snowblind Harpy + 10990, // Alterac Ram + 11675, // Snowblind Windcaller + 11678, // Snowblind Ambusher + 11839, // Wildpaw Brute + 11947, // Captain Galvangar + 11948, // Vanndar Stormpike + 11949, // Captain Balinda Stonehearth + 11997, // Stormpike Herald + 12051, // Frostwolf Legionnaire + 12096, // Stormpike Quartermaster + 12097, // Frostwolf Quartermaster + 12127, // Stormpike Guardsman + 13176, // Smith Regzar + 13179, // Wing Commander Guse + 13216, // Gaelden Hammersmith + 13218, // Grunnda Wolfheart + 13236, // Primalist Thurloga + 13257, // Murgot Deepforge + 13284, // Frostwolf Shaman + 13438, // Wing Commander Slidore + 13442, // Arch Druid Renferal + 13443, // Druid of the Grove + 13447, // Corporal Noreg Stormpike + 13577, // Stormpike Ram Rider Commander + 13617, // Stormpike Stable Master + 13797, // Mountaineer Boombellow + 13798, // Jotek + 13816, // Prospector Stonehewer + 14185, // Najak Hexxen + 14186, // Ravak Grimtotem + 14187, // Athramanis + 14188, // Dirk Swindle + 14282, // Frostwolf Bloodhound + 14283, // Stormpike Owl + 14284, // Stormpike Battleguard + 11946, // Drek'Thar + 11948, // Vanndar Stormpike + 11947, // Captain Galvangar + 11949, // Captain Balinda Stonehearth }; enum BG_AV_Graveyards @@ -1525,18 +1526,53 @@ struct BG_AV_NodeInfo inline BG_AV_Nodes &operator++(BG_AV_Nodes &i){ return i = BG_AV_Nodes(i + 1); } -struct BattlegroundAVScore : public BattlegroundScore +struct BattlegroundAVScore final : public BattlegroundScore { - BattlegroundAVScore() : GraveyardsAssaulted(0), GraveyardsDefended(0), TowersAssaulted(0), - TowersDefended(0), MinesCaptured(0), LeadersKilled(0), SecondaryObjectives(0) { } - ~BattlegroundAVScore() { } - uint32 GraveyardsAssaulted; - uint32 GraveyardsDefended; - uint32 TowersAssaulted; - uint32 TowersDefended; - uint32 MinesCaptured; - uint32 LeadersKilled; - uint32 SecondaryObjectives; + friend class BattlegroundAV; + + protected: + BattlegroundAVScore(uint64 playerGuid, uint8 team) : BattlegroundScore(playerGuid, team), GraveyardsAssaulted(0), GraveyardsDefended(0), TowersAssaulted(0), TowersDefended(0), MinesCaptured(0) { } + + void UpdateScore(uint32 type, uint32 value) override + { + switch (type) + { + case SCORE_GRAVEYARDS_ASSAULTED: + GraveyardsAssaulted += value; + break; + case SCORE_GRAVEYARDS_DEFENDED: + GraveyardsDefended += value; + break; + case SCORE_TOWERS_ASSAULTED: + TowersAssaulted += value; + break; + case SCORE_TOWERS_DEFENDED: + TowersDefended += value; + break; + case SCORE_MINES_CAPTURED: + MinesCaptured += value; + break; + default: + BattlegroundScore::UpdateScore(type, value); + break; + } + } + + void BuildObjectivesBlock(WorldPacket& data, ByteBuffer& content) final + { + data.WriteBits(5, 24); // Objectives Count + content << uint32(GraveyardsAssaulted); + content << uint32(GraveyardsDefended); + content << uint32(TowersAssaulted); + content << uint32(TowersDefended); + content << uint32(MinesCaptured); + } + + uint32 GraveyardsAssaulted; + uint32 GraveyardsDefended; + uint32 TowersAssaulted; + uint32 TowersDefended; + uint32 MinesCaptured; }; class BattlegroundAV : public Battleground @@ -1557,7 +1593,7 @@ class BattlegroundAV : public Battleground /*general stuff*/ void UpdateScore(uint16 team, int16 points); - void UpdatePlayerScore(Player* player, uint32 type, uint32 value, bool doAddHonor = true); + bool UpdatePlayerScore(Player* player, uint32 type, uint32 value, bool doAddHonor = true) override; /*handlestuff*/ //these are functions which get called from extern void EventPlayerClickedOnFlag(Player* source, GameObject* target_obj); @@ -1607,7 +1643,6 @@ class BattlegroundAV : public Battleground /*general */ Creature* AddAVCreature(uint16 cinfoid, uint16 type); - uint16 GetBonusHonor(uint8 kills); /// @todo: Remove this when the core handles this properly /*variables */ int32 m_Team_Scores[2]; @@ -1622,7 +1657,6 @@ class BattlegroundAV : public Battleground uint32 m_CaptainBuffTimer[2]; bool m_CaptainAlive[2]; - uint8 m_MaxLevel; /// @todo: Remove this once battleground->getmaxlevel() returns something usefull/is reworked (?) bool m_IsInformedNearVictory[2]; }; diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundBE.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundBE.cpp index c89fc57b8aa..548e0bf463b 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundBE.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundBE.cpp @@ -16,6 +16,7 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include "ArenaScore.h" #include "BattlegroundBE.h" #include "Language.h" #include "Object.h" @@ -64,7 +65,7 @@ void BattlegroundBE::StartingEventOpenDoors() void BattlegroundBE::AddPlayer(Player* player) { Battleground::AddPlayer(player); - PlayerScores[player->GetGUID()] = new BattlegroundScore; + PlayerScores[player->GetGUIDLow()] = new ArenaScore(player->GetGUID(), player->GetBGTeam()); UpdateArenaWorldState(); } @@ -139,13 +140,3 @@ bool BattlegroundBE::SetupBattleground() return true; } - -void BattlegroundBE::UpdatePlayerScore(Player* Source, uint32 type, uint32 value, bool doAddHonor) -{ - BattlegroundScoreMap::iterator itr = PlayerScores.find(Source->GetGUID()); - if (itr == PlayerScores.end()) // player not found... - return; - - //there is nothing special in this score - Battleground::UpdatePlayerScore(Source, type, value, doAddHonor); -} diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundBE.h b/src/server/game/Battlegrounds/Zones/BattlegroundBE.h index be801dfff2b..6fd4dc37fc8 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundBE.h +++ b/src/server/game/Battlegrounds/Zones/BattlegroundBE.h @@ -59,8 +59,5 @@ class BattlegroundBE : public Battleground void Reset(); void FillInitialWorldStates(WorldPacket &d); void HandleKillPlayer(Player* player, Player* killer); - - /* Scorekeeping */ - void UpdatePlayerScore(Player* Source, uint32 type, uint32 value, bool doAddHonor = true); }; #endif diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundBFG.h b/src/server/game/Battlegrounds/Zones/BattlegroundBFG.h index 1d514eced23..0657862cada 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundBFG.h +++ b/src/server/game/Battlegrounds/Zones/BattlegroundBFG.h @@ -19,12 +19,28 @@ #define __BATTLEGROUNDBFG_H #include "Battleground.h" +#include "BattlegroundScore.h" -class BattlegroundBFGScore : public BattlegroundScore +class BattlegroundBFGScore final : public BattlegroundScore { - public: - BattlegroundBFGScore(): BasesAssaulted(0), BasesDefended(0) {}; - virtual ~BattlegroundBFGScore() {}; + protected: + BattlegroundBFGScore(uint64 playerGuid, uint8 team) : BattlegroundScore(playerGuid, team), BasesAssaulted(0), BasesDefended(0) { } + + void UpdateScore(uint32 type, uint32 value) override + { + switch (type) + { + case SCORE_BASES_ASSAULTED: + BasesAssaulted += value; + break; + case SCORE_BASES_DEFENDED: + BasesDefended += value; + break; + default: + BattlegroundScore::UpdateScore(type, value); + break; + } + } uint32 BasesAssaulted; uint32 BasesDefended; diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundDS.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundDS.cpp index 9e9e82b32b8..1d6970f8317 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundDS.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundDS.cpp @@ -16,6 +16,7 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include "ArenaScore.h" #include "BattlegroundDS.h" #include "Creature.h" #include "GameObject.h" @@ -152,7 +153,7 @@ void BattlegroundDS::StartingEventOpenDoors() void BattlegroundDS::AddPlayer(Player* player) { Battleground::AddPlayer(player); - PlayerScores[player->GetGUID()] = new BattlegroundScore; + PlayerScores[player->GetGUIDLow()] = new ArenaScore(player->GetGUID(), player->GetBGTeam()); UpdateArenaWorldState(); } diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundEY.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundEY.cpp index 213a91bea88..c25c915dd7a 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundEY.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundEY.cpp @@ -363,12 +363,9 @@ void BattlegroundEY::UpdatePointsIcons(uint32 Team, uint32 Point) void BattlegroundEY::AddPlayer(Player* player) { Battleground::AddPlayer(player); - //create score and add it to map - BattlegroundEYScore* sc = new BattlegroundEYScore; + PlayerScores[player->GetGUIDLow()] = new BattlegroundEYScore(player->GetGUID(), player->GetBGTeam()); m_PlayersNearPoint[EY_POINTS_MAX].push_back(player->GetGUID()); - - PlayerScores[player->GetGUID()] = sc; } void BattlegroundEY::RemovePlayer(Player* player, uint64 guid, uint32 /*team*/) @@ -832,22 +829,20 @@ void BattlegroundEY::EventPlayerCapturedFlag(Player* player, uint32 BgObjectType UpdatePlayerScore(player, SCORE_FLAG_CAPTURES, 1); } -void BattlegroundEY::UpdatePlayerScore(Player* player, uint32 type, uint32 value, bool doAddHonor) +bool BattlegroundEY::UpdatePlayerScore(Player* player, uint32 type, uint32 value, bool doAddHonor) { - BattlegroundScoreMap::iterator itr = PlayerScores.find(player->GetGUID()); - if (itr == PlayerScores.end()) // player not found - return; + if (!Battleground::UpdatePlayerScore(player, type, value, doAddHonor)) + return false; switch (type) { - case SCORE_FLAG_CAPTURES: // flags captured - ((BattlegroundEYScore*)itr->second)->FlagCaptures += value; + case SCORE_FLAG_CAPTURES: player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BG_OBJECTIVE_CAPTURE, EY_OBJECTIVE_CAPTURE_FLAG); break; default: - Battleground::UpdatePlayerScore(player, type, value, doAddHonor); break; } + return true; } void BattlegroundEY::FillInitialWorldStates(WorldPacket& data) diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundEY.h b/src/server/game/Battlegrounds/Zones/BattlegroundEY.h index 9e5088d7ba5..dc6413dec34 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundEY.h +++ b/src/server/game/Battlegrounds/Zones/BattlegroundEY.h @@ -20,6 +20,7 @@ #define __BATTLEGROUNDEY_H #include "Battleground.h" +#include "BattlegroundScore.h" #include "Language.h" #include "Object.h" @@ -322,11 +323,33 @@ const BattlegroundEYCapturingPointStruct m_CapturingPointTypes[EY_POINTS_MAX] = BattlegroundEYCapturingPointStruct(BG_EY_OBJECT_N_BANNER_MAGE_TOWER_CENTER, BG_EY_OBJECT_A_BANNER_MAGE_TOWER_CENTER, LANG_BG_EY_HAS_TAKEN_A_M_TOWER, BG_EY_OBJECT_H_BANNER_MAGE_TOWER_CENTER, LANG_BG_EY_HAS_TAKEN_H_M_TOWER, EY_GRAVEYARD_MAGE_TOWER) }; -struct BattlegroundEYScore : public BattlegroundScore +struct BattlegroundEYScore final : public BattlegroundScore { - BattlegroundEYScore() : FlagCaptures(0) { } - ~BattlegroundEYScore() { } - uint32 FlagCaptures; + friend class BattlegroundEY; + + protected: + BattlegroundEYScore(uint64 playerGuid, uint8 team) : BattlegroundScore(playerGuid, team), FlagCaptures(0) { } + + void UpdateScore(uint32 type, uint32 value) override + { + switch (type) + { + case SCORE_FLAG_CAPTURES: // Flags captured + FlagCaptures += value; + break; + default: + BattlegroundScore::UpdateScore(type, value); + break; + } + } + + void BuildObjectivesBlock(WorldPacket& data, ByteBuffer& content) final + { + data.WriteBits(1, 24); // Objectives Count + content << uint32(FlagCaptures); + } + + uint32 FlagCaptures; }; class BattlegroundEY : public Battleground @@ -357,7 +380,7 @@ class BattlegroundEY : public Battleground void Reset(); void UpdateTeamScore(uint32 Team); void EndBattleground(uint32 winner); - void UpdatePlayerScore(Player* Source, uint32 type, uint32 value, bool doAddHonor = true); + bool UpdatePlayerScore(Player* player, uint32 type, uint32 value, bool doAddHonor = true) override; void FillInitialWorldStates(WorldPacket& data); void SetDroppedFlagGUID(uint64 guid, int32 /*TeamID*/ = -1) { m_DroppedFlagGUID = guid;} uint64 GetDroppedFlagGUID() const { return m_DroppedFlagGUID;} diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundIC.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundIC.cpp index faa71fd2ffa..7c1e8204ebc 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundIC.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundIC.cpp @@ -273,7 +273,7 @@ void BattlegroundIC::StartingEventOpenDoors() void BattlegroundIC::AddPlayer(Player* player) { Battleground::AddPlayer(player); - PlayerScores[player->GetGUID()] = new BattlegroundICScore; + PlayerScores[player->GetGUIDLow()] = new BattlegroundICScore(player->GetGUID(), player->GetBGTeam()); if (nodePoint[NODE_TYPE_QUARRY].nodeState == (player->GetTeamId() == TEAM_ALLIANCE ? NODE_STATE_CONTROLLED_A : NODE_STATE_CONTROLLED_H)) player->CastSpell(player, SPELL_QUARRY, true); @@ -314,27 +314,6 @@ void BattlegroundIC::HandleAreaTrigger(Player* player, uint32 trigger) } } -void BattlegroundIC::UpdatePlayerScore(Player* player, uint32 type, uint32 value, bool doAddHonor) -{ - std::map<uint64, BattlegroundScore*>::iterator itr = PlayerScores.find(player->GetGUID()); - - if (itr == PlayerScores.end()) // player not found... - return; - - switch (type) - { - case SCORE_BASES_ASSAULTED: - ((BattlegroundICScore*)itr->second)->BasesAssaulted += value; - break; - case SCORE_BASES_DEFENDED: - ((BattlegroundICScore*)itr->second)->BasesDefended += value; - break; - default: - Battleground::UpdatePlayerScore(player, type, value, doAddHonor); - break; - } -} - void BattlegroundIC::FillInitialWorldStates(WorldPacket& data) { data << uint32(BG_IC_ALLIANCE_RENFORT_SET) << uint32(1); diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundIC.h b/src/server/game/Battlegrounds/Zones/BattlegroundIC.h index 091a75e7449..7903468adad 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundIC.h +++ b/src/server/game/Battlegrounds/Zones/BattlegroundIC.h @@ -20,6 +20,7 @@ #define __BATTLEGROUNDIC_H #include "Battleground.h" +#include "BattlegroundScore.h" #include "Language.h" #include "Object.h" @@ -847,12 +848,38 @@ enum HonorRewards WINNER_HONOR_AMOUNT = 500 }; -struct BattlegroundICScore : public BattlegroundScore +struct BattlegroundICScore final : public BattlegroundScore { - BattlegroundICScore() : BasesAssaulted(0), BasesDefended(0) { } - ~BattlegroundICScore() { } - uint32 BasesAssaulted; - uint32 BasesDefended; + friend class BattlegroundIC; + + protected: + BattlegroundICScore(uint64 playerGuid, uint8 team) : BattlegroundScore(playerGuid, team), BasesAssaulted(0), BasesDefended(0) { } + + void UpdateScore(uint32 type, uint32 value) override + { + switch (type) + { + case SCORE_BASES_ASSAULTED: + BasesAssaulted += value; + break; + case SCORE_BASES_DEFENDED: + BasesDefended += value; + break; + default: + BattlegroundScore::UpdateScore(type, value); + break; + } + } + + void BuildObjectivesBlock(WorldPacket& data, ByteBuffer& content) final + { + data.WriteBits(2, 24); // Objectives Count + content << uint32(BasesAssaulted); + content << uint32(BasesDefended); + } + + uint32 BasesAssaulted; + uint32 BasesDefended; }; class BattlegroundIC : public Battleground @@ -881,8 +908,6 @@ class BattlegroundIC : public Battleground WorldSafeLocsEntry const* GetClosestGraveYard(Player* player); /* Scorekeeping */ - void UpdatePlayerScore(Player* player, uint32 type, uint32 value, bool doAddHonor = true); - void FillInitialWorldStates(WorldPacket& data); void DoAction(uint32 action, uint64 var); @@ -894,6 +919,7 @@ class BattlegroundIC : public Battleground bool IsAllNodesControlledByTeam(uint32 team) const; bool IsSpellAllowed(uint32 spellId, Player const* player) const; + private: uint32 closeFortressDoorsTimer; bool doorsClosed; diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundNA.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundNA.cpp index 70a940ec853..82fcb2f6f91 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundNA.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundNA.cpp @@ -16,6 +16,7 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include "ArenaScore.h" #include "BattlegroundNA.h" #include "Language.h" #include "Object.h" @@ -61,7 +62,7 @@ void BattlegroundNA::StartingEventOpenDoors() void BattlegroundNA::AddPlayer(Player* player) { Battleground::AddPlayer(player); - PlayerScores[player->GetGUID()] = new BattlegroundScore; + PlayerScores[player->GetGUIDLow()] = new ArenaScore(player->GetGUID(), player->GetBGTeam()); UpdateArenaWorldState(); } diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundRL.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundRL.cpp index 5f77c57c064..712d9a6e296 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundRL.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundRL.cpp @@ -16,6 +16,7 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include "ArenaScore.h" #include "BattlegroundRL.h" #include "Language.h" #include "Object.h" @@ -61,7 +62,7 @@ void BattlegroundRL::StartingEventOpenDoors() void BattlegroundRL::AddPlayer(Player* player) { Battleground::AddPlayer(player); - PlayerScores[player->GetGUID()] = new BattlegroundScore; + PlayerScores[player->GetGUIDLow()] = new ArenaScore(player->GetGUID(), player->GetBGTeam()); UpdateArenaWorldState(); } diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundRV.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundRV.cpp index dd61b8b9e6f..1059124d041 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundRV.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundRV.cpp @@ -16,6 +16,7 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include "ArenaScore.h" #include "Battleground.h" #include "BattlegroundRV.h" #include "ObjectAccessor.h" @@ -99,7 +100,7 @@ void BattlegroundRV::StartingEventOpenDoors() void BattlegroundRV::AddPlayer(Player* player) { Battleground::AddPlayer(player); - PlayerScores[player->GetGUID()] = new BattlegroundScore; + PlayerScores[player->GetGUIDLow()] = new ArenaScore(player->GetGUID(), player->GetBGTeam()); UpdateWorldState(BG_RV_WORLD_STATE_A, GetAlivePlayersCountByTeam(ALLIANCE)); UpdateWorldState(BG_RV_WORLD_STATE_H, GetAlivePlayersCountByTeam(HORDE)); diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundSA.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundSA.cpp index 83ac056e831..7c03776ccec 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundSA.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundSA.cpp @@ -454,9 +454,7 @@ void BattlegroundSA::FillInitialWorldStates(WorldPacket& data) void BattlegroundSA::AddPlayer(Player* player) { Battleground::AddPlayer(player); - //create score and add it to map, default values are set in constructor - BattlegroundSAScore* sc = new BattlegroundSAScore; - PlayerScores[player->GetGUID()] = sc; + PlayerScores[player->GetGUIDLow()] = new BattlegroundSAScore(player->GetGUID(), player->GetBGTeam()); SendTransportInit(player); @@ -493,20 +491,6 @@ void BattlegroundSA::HandleAreaTrigger(Player* /*Source*/, uint32 /*Trigger*/) return; } -void BattlegroundSA::UpdatePlayerScore(Player* Source, uint32 type, uint32 value, bool doAddHonor) -{ - BattlegroundScoreMap::iterator itr = PlayerScores.find(Source->GetGUID()); - if (itr == PlayerScores.end()) // player not found... - return; - - if (type == SCORE_DESTROYED_DEMOLISHER) - ((BattlegroundSAScore*)itr->second)->demolishers_destroyed += value; - else if (type == SCORE_DESTROYED_WALL) - ((BattlegroundSAScore*)itr->second)->gates_destroyed += value; - else - Battleground::UpdatePlayerScore(Source, type, value, doAddHonor); -} - void BattlegroundSA::TeleportPlayers() { for (BattlegroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr) diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundSA.h b/src/server/game/Battlegrounds/Zones/BattlegroundSA.h index 880da0735f4..07453144203 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundSA.h +++ b/src/server/game/Battlegrounds/Zones/BattlegroundSA.h @@ -20,16 +20,9 @@ #define __BATTLEGROUNDSA_H #include "Battleground.h" +#include "BattlegroundScore.h" #include "Object.h" -struct BattlegroundSAScore : public BattlegroundScore -{ - BattlegroundSAScore() : demolishers_destroyed(0), gates_destroyed(0) { } - ~BattlegroundSAScore() { } - uint8 demolishers_destroyed; - uint8 gates_destroyed; -}; - #define BG_SA_FLAG_AMOUNT 3 #define BG_SA_DEMOLISHER_AMOUNT 4 @@ -249,7 +242,7 @@ uint32 const BG_SA_NpcEntries[BG_SA_MAXNPC] = NPC_KANRETHAD }; -Position const BG_SA_NpcSpawnlocs[BG_SA_MAXNPC + BG_SA_DEMOLISHER_AMOUNT] = +Position const BG_SA_NpcSpawnlocs[BG_SA_MAXNPC] = { // Cannons { 1436.429f, 110.05f, 41.407f, 5.4f }, @@ -515,6 +508,40 @@ struct BG_SA_RoundScore uint32 time; }; +struct BattlegroundSAScore final : public BattlegroundScore +{ + friend class BattlegroundSA; + + protected: + BattlegroundSAScore(uint64 playerGuid, uint8 team) : BattlegroundScore(playerGuid, team), DemolishersDestroyed(0), GatesDestroyed(0) { } + + void UpdateScore(uint32 type, uint32 value) override + { + switch (type) + { + case SCORE_DESTROYED_DEMOLISHER: + DemolishersDestroyed += value; + break; + case SCORE_DESTROYED_WALL: + GatesDestroyed += value; + break; + default: + BattlegroundScore::UpdateScore(type, value); + break; + } + } + + void BuildObjectivesBlock(WorldPacket& data, ByteBuffer& content) final + { + data.WriteBits(2, 24); // Objectives Count + content << uint32(DemolishersDestroyed); + content << uint32(GatesDestroyed); + } + + uint32 DemolishersDestroyed; + uint32 GatesDestroyed; +}; + /// Class for manage Strand of Ancient battleground class BattlegroundSA : public Battleground { @@ -568,8 +595,6 @@ class BattlegroundSA : public Battleground void HandleAreaTrigger(Player* Source, uint32 Trigger); /* Scorekeeping */ - /// Update score board - void UpdatePlayerScore(Player* Source, uint32 type, uint32 value, bool doAddHonor = true); // Achievement: Not Even a Scratch bool CheckAchievementCriteriaMeet(uint32 criteriaId, Player const* source, Unit const* target = NULL, uint32 miscValue = 0) override; diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundTP.h b/src/server/game/Battlegrounds/Zones/BattlegroundTP.h index 99ac9fbfedc..c871ce4a596 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundTP.h +++ b/src/server/game/Battlegrounds/Zones/BattlegroundTP.h @@ -19,15 +19,31 @@ #define __BATTLEGROUNDTP_H #include "Battleground.h" +#include "BattlegroundScore.h" -class BattlegroundTPScore : public BattlegroundScore +class BattlegroundTPScore final : public BattlegroundScore { - public: - BattlegroundTPScore() : FlagCaptures(0), FlagReturns(0) {}; - virtual ~BattlegroundTPScore() {}; + protected: + BattlegroundTPScore(uint64 playerGuid, uint8 team) : BattlegroundScore(playerGuid, team), BasesAssaulted(0), BasesDefended(0) { } + + void UpdateScore(uint32 type, uint32 value) override + { + switch (type) + { + case SCORE_BASES_ASSAULTED: + BasesAssaulted += value; + break; + case SCORE_BASES_DEFENDED: + BasesDefended += value; + break; + default: + BattlegroundScore::UpdateScore(type, value); + break; + } + } - uint32 FlagCaptures; - uint32 FlagReturns; + uint32 BasesAssaulted; + uint32 BasesDefended; }; class BattlegroundTP : public Battleground diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundWS.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundWS.cpp index eb5ffed657f..740350dd10b 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundWS.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundWS.cpp @@ -229,10 +229,7 @@ void BattlegroundWS::StartingEventOpenDoors() void BattlegroundWS::AddPlayer(Player* player) { Battleground::AddPlayer(player); - //create score and add it to map, default values are set in constructor - BattlegroundWGScore* sc = new BattlegroundWGScore; - - PlayerScores[player->GetGUID()] = sc; + PlayerScores[player->GetGUIDLow()] = new BattlegroundWGScore(player->GetGUID(), player->GetBGTeam()); } void BattlegroundWS::RespawnFlag(uint32 Team, bool captured) @@ -790,26 +787,23 @@ void BattlegroundWS::HandleKillPlayer(Player* player, Player* killer) Battleground::HandleKillPlayer(player, killer); } -void BattlegroundWS::UpdatePlayerScore(Player* player, uint32 type, uint32 value, bool doAddHonor) +bool BattlegroundWS::UpdatePlayerScore(Player* player, uint32 type, uint32 value, bool doAddHonor) { - BattlegroundScoreMap::iterator itr = PlayerScores.find(player->GetGUID()); - if (itr == PlayerScores.end()) // player not found - return; + if (!Battleground::UpdatePlayerScore(player, type, value, doAddHonor)) + return false; switch (type) { case SCORE_FLAG_CAPTURES: // flags captured - ((BattlegroundWGScore*)itr->second)->FlagCaptures += value; player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BG_OBJECTIVE_CAPTURE, WS_OBJECTIVE_CAPTURE_FLAG); break; case SCORE_FLAG_RETURNS: // flags returned - ((BattlegroundWGScore*)itr->second)->FlagReturns += value; player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BG_OBJECTIVE_CAPTURE, WS_OBJECTIVE_RETURN_FLAG); break; default: - Battleground::UpdatePlayerScore(player, type, value, doAddHonor); break; } + return true; } WorldSafeLocsEntry const* BattlegroundWS::GetClosestGraveYard(Player* player) diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundWS.h b/src/server/game/Battlegrounds/Zones/BattlegroundWS.h index c6c25ec52de..41d240feffc 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundWS.h +++ b/src/server/game/Battlegrounds/Zones/BattlegroundWS.h @@ -20,6 +20,7 @@ #define __BATTLEGROUNDWS_H #include "Battleground.h" +#include "BattlegroundScore.h" enum BG_WS_TimerOrScore { @@ -146,12 +147,38 @@ enum BG_WS_Objectives #define WS_EVENT_START_BATTLE 8563 -struct BattlegroundWGScore : public BattlegroundScore +struct BattlegroundWGScore final : public BattlegroundScore { - BattlegroundWGScore() : FlagCaptures(0), FlagReturns(0) { } - ~BattlegroundWGScore() { } - uint32 FlagCaptures; - uint32 FlagReturns; + friend class BattlegroundWS; + + protected: + BattlegroundWGScore(uint64 playerGuid, uint8 team) : BattlegroundScore(playerGuid, team), FlagCaptures(0), FlagReturns(0) { } + + void UpdateScore(uint32 type, uint32 value) override + { + switch (type) + { + case SCORE_FLAG_CAPTURES: // Flags captured + FlagCaptures += value; + break; + case SCORE_FLAG_RETURNS: // Flags returned + FlagReturns += value; + break; + default: + BattlegroundScore::UpdateScore(type, value); + break; + } + } + + void BuildObjectivesBlock(WorldPacket& data, ByteBuffer& content) final + { + data.WriteBits(2, 24); // Objectives Count + content << uint32(FlagCaptures); + content << uint32(FlagReturns); + } + + uint32 FlagCaptures; + uint32 FlagReturns; }; class BattlegroundWS : public Battleground @@ -197,7 +224,7 @@ class BattlegroundWS : public Battleground void UpdateFlagState(uint32 team, uint32 value); void SetLastFlagCapture(uint32 team) { _lastFlagCaptureTeam = team; } void UpdateTeamScore(uint32 team); - void UpdatePlayerScore(Player* player, uint32 type, uint32 value, bool doAddHonor = true); + bool UpdatePlayerScore(Player* player, uint32 type, uint32 value, bool doAddHonor = true) override; void SetDroppedFlagGUID(uint64 guid, int32 team = -1) { if (team == TEAM_ALLIANCE || team == TEAM_HORDE) diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index d1148f6cfb2..c6a2c578c8f 100644 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -142,8 +142,8 @@ bool ForcedDespawnDelayEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/) } Creature::Creature(bool isWorldObject): Unit(isWorldObject), MapObject(), -_pickpocketLootRestore(0), m_groupLootTimer(0), lootingGroupLowGUID(0), m_PlayerDamageReq(0), -m_lootRecipient(0), m_lootRecipientGroup(0), _skinner(0), m_corpseRemoveTime(0), m_respawnTime(0), +m_groupLootTimer(0), lootingGroupLowGUID(0), m_PlayerDamageReq(0), +m_lootRecipient(0), m_lootRecipientGroup(0), _skinner(0), _pickpocketLootRestore(0), m_corpseRemoveTime(0), m_respawnTime(0), m_respawnDelay(300), m_corpseDelay(60), m_respawnradius(0.0f), m_reactState(REACT_AGGRESSIVE), m_defaultMovementType(IDLE_MOTION_TYPE), m_DBTableGuid(0), m_equipmentId(0), m_originalEquipmentId(0), m_AlreadyCallAssistance(false), m_AlreadySearchedAssistance(false), m_regenHealth(true), m_AI_locked(false), m_meleeDamageSchoolMask(SPELL_SCHOOL_MASK_NORMAL), diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index cf6e94328b7..cb0b6dee782 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -26,6 +26,7 @@ #include "BattlefieldWG.h" #include "Battleground.h" #include "BattlegroundMgr.h" +#include "BattlegroundScore.h" #include "CellImpl.h" #include "Channel.h" #include "ChannelMgr.h" diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 6c66e900be7..1d8e8122e30 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -21,6 +21,7 @@ #include "Battlefield.h" #include "BattlefieldMgr.h" #include "Battleground.h" +#include "BattlegroundScore.h" #include "CellImpl.h" #include "ConditionMgr.h" #include "CreatureAI.h" @@ -3618,8 +3619,7 @@ void Unit::RemoveAurasByType(AuraType auraType, uint64 casterGUID, Aura* except, { Aura* aura = (*iter)->GetBase(); AuraApplication * aurApp = aura->GetApplicationOfTarget(GetGUID()); - if (!aurApp) - continue; + ASSERT(aurApp); ++iter; if (aura != except && (!casterGUID || aura->GetCasterGUID() == casterGUID) diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index 2ccaef0456b..068f9513268 100644 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -1707,7 +1707,7 @@ void ObjectMgr::LoadCreatures() } // Skip spawnMask check for transport maps - if (!_transportMaps.count(data.mapid) && data.spawnMask & ~spawnMasks[data.mapid]) + if (!IsTransportMap(data.mapid) && data.spawnMask & ~spawnMasks[data.mapid]) TC_LOG_ERROR("sql.sql", "Table `creature` have creature (GUID: %u Entry: %u) that have wrong spawn mask %u including not supported difficulty modes for map (Id: %u) spawnMasks[data.mapid]: %u.", guid, data.id, data.spawnMask, data.mapid, spawnMasks[data.mapid]); bool ok = true; @@ -2048,7 +2048,7 @@ void ObjectMgr::LoadGameobjects() data.spawnMask = fields[14].GetUInt8(); - if (!_transportMaps.count(data.mapid) && data.spawnMask & ~spawnMasks[data.mapid]) + if (!IsTransportMap(data.mapid) && data.spawnMask & ~spawnMasks[data.mapid]) TC_LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: %u Entry: %u) that has wrong spawn mask %u including not supported difficulty modes for map (Id: %u), skip", guid, data.id, data.spawnMask, data.mapid); data.phaseMask = fields[15].GetUInt32(); diff --git a/src/server/game/Globals/ObjectMgr.h b/src/server/game/Globals/ObjectMgr.h index 62a770f06a8..006bdfeaebf 100644 --- a/src/server/game/Globals/ObjectMgr.h +++ b/src/server/game/Globals/ObjectMgr.h @@ -1326,6 +1326,8 @@ class ObjectMgr void LoadFactionChangeSpells(); void LoadFactionChangeTitles(); + bool IsTransportMap(uint32 mapId) const { return _transportMaps.count(mapId); } + void LoadHotfixData(); HotfixData const& GetHotfixData() const { return _hotfixData; } time_t GetHotfixDate(uint32 entry, uint32 type) const diff --git a/src/server/game/Handlers/BattleGroundHandler.cpp b/src/server/game/Handlers/BattleGroundHandler.cpp index f0b98f9cf6f..faae8ef3ba0 100644 --- a/src/server/game/Handlers/BattleGroundHandler.cpp +++ b/src/server/game/Handlers/BattleGroundHandler.cpp @@ -370,7 +370,7 @@ void WorldSession::HandlePVPLogDataOpcode(WorldPacket & /*recvData*/) return; WorldPacket data; - sBattlegroundMgr->BuildPvpLogDataPacket(&data, bg); + bg->BuildPvPLogDataPacket(data); SendPacket(&data); TC_LOG_DEBUG("network", "WORLD: Sent SMSG_PVP_LOG_DATA Message"); diff --git a/src/server/game/Server/Protocol/Opcodes.cpp b/src/server/game/Server/Protocol/Opcodes.cpp index 5d12537b6e4..379fe4f5297 100644 --- a/src/server/game/Server/Protocol/Opcodes.cpp +++ b/src/server/game/Server/Protocol/Opcodes.cpp @@ -1035,7 +1035,7 @@ void OpcodeTable::Initialize() DEFINE_OPCODE_HANDLER(SMSG_ON_CANCEL_EXPECTED_RIDE_VEHICLE_AURA, STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide ); DEFINE_OPCODE_HANDLER(SMSG_OPEN_CONTAINER, STATUS_UNHANDLED, PROCESS_INPLACE, &WorldSession::Handle_ServerSide ); DEFINE_OPCODE_HANDLER(SMSG_OPEN_LFG_DUNGEON_FINDER, STATUS_UNHANDLED, PROCESS_INPLACE, &WorldSession::Handle_ServerSide ); - DEFINE_OPCODE_HANDLER(SMSG_OVERRIDE_LIGHT, STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide ); + DEFINE_OPCODE_HANDLER(SMSG_OVERRIDE_LIGHT, STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide ); DEFINE_OPCODE_HANDLER(SMSG_PAGE_TEXT_QUERY_RESPONSE, STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide ); DEFINE_OPCODE_HANDLER(SMSG_PARTYKILLLOG, STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide ); DEFINE_OPCODE_HANDLER(SMSG_PARTY_COMMAND_RESULT, STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide ); diff --git a/src/server/scripts/Commands/cs_go.cpp b/src/server/scripts/Commands/cs_go.cpp index f639fdbdd10..6c321a66c48 100644 --- a/src/server/scripts/Commands/cs_go.cpp +++ b/src/server/scripts/Commands/cs_go.cpp @@ -29,6 +29,7 @@ EndScriptData */ #include "Chat.h" #include "Language.h" #include "Player.h" +#include "Transport.h" class go_commandscript : public CommandScript { @@ -132,21 +133,24 @@ public: float x = fields[0].GetFloat(); float y = fields[1].GetFloat(); float z = fields[2].GetFloat(); - float ort = fields[3].GetFloat(); - int mapId = fields[4].GetUInt16(); + float o = fields[3].GetFloat(); + uint32 mapId = fields[4].GetUInt16(); uint32 guid = fields[5].GetUInt32(); uint32 id = fields[6].GetUInt32(); - // if creature is in same map with caster go at its current location - if (Creature* creature = sObjectAccessor->GetCreature(*player, MAKE_NEW_GUID(guid, id, HIGHGUID_UNIT))) + Transport* transport = NULL; + + if (Creature* creature = ObjectAccessor::GetObjectInWorld(MAKE_NEW_GUID(guid, id, HIGHGUID_UNIT), (Creature*)NULL)) { x = creature->GetPositionX(); y = creature->GetPositionY(); z = creature->GetPositionZ(); - ort = creature->GetOrientation(); + o = creature->GetOrientation(); + mapId = creature->GetMapId(); + transport = creature->GetTransport(); } - if (!MapManager::IsValidMapCoord(mapId, x, y, z, ort)) + if (!MapManager::IsValidMapCoord(mapId, x, y, z, o) || sObjectMgr->IsTransportMap(mapId)) { handler->PSendSysMessage(LANG_INVALID_TARGET_COORD, x, y, mapId); handler->SetSentErrorMessage(true); @@ -163,7 +167,11 @@ public: else player->SaveRecallPosition(); - player->TeleportTo(mapId, x, y, z, ort); + if (player->TeleportTo(mapId, x, y, z, o)) + { + if (transport) + transport->AddPassenger(player); + } return true; } @@ -274,8 +282,8 @@ public: if (!guid) return false; - float x, y, z, ort; - int mapId; + float x, y, z, o; + uint32 mapId; // by DB guid if (GameObjectData const* goData = sObjectMgr->GetGOData(guid)) @@ -283,7 +291,7 @@ public: x = goData->posX; y = goData->posY; z = goData->posZ; - ort = goData->orientation; + o = goData->orientation; mapId = goData->mapid; } else @@ -293,7 +301,7 @@ public: return false; } - if (!MapManager::IsValidMapCoord(mapId, x, y, z, ort)) + if (!MapManager::IsValidMapCoord(mapId, x, y, z, o) || sObjectMgr->IsTransportMap(mapId)) { handler->PSendSysMessage(LANG_INVALID_TARGET_COORD, x, y, mapId); handler->SetSentErrorMessage(true); @@ -310,7 +318,7 @@ public: else player->SaveRecallPosition(); - player->TeleportTo(mapId, x, y, z, ort); + player->TeleportTo(mapId, x, y, z, o); return true; } |