diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/server/game/Battlegrounds/Battleground.cpp | 32 | ||||
-rw-r--r-- | src/server/game/Battlegrounds/Battleground.h | 10 | ||||
-rw-r--r-- | src/server/game/Battlegrounds/Zones/BattlegroundEY.cpp | 13 | ||||
-rw-r--r-- | src/server/game/Battlegrounds/Zones/BattlegroundEY.h | 1 | ||||
-rw-r--r-- | src/server/game/Battlegrounds/Zones/BattlegroundWS.cpp | 23 | ||||
-rw-r--r-- | src/server/game/Battlegrounds/Zones/BattlegroundWS.h | 1 | ||||
-rw-r--r-- | src/server/game/Spells/Auras/SpellAuraDefines.h | 4 | ||||
-rw-r--r-- | src/server/game/Spells/Auras/SpellAuraEffects.cpp | 42 | ||||
-rw-r--r-- | src/server/game/Spells/Auras/SpellAuraEffects.h | 1 |
9 files changed, 83 insertions, 44 deletions
diff --git a/src/server/game/Battlegrounds/Battleground.cpp b/src/server/game/Battlegrounds/Battleground.cpp index 4a50c20179c..0f475589192 100644 --- a/src/server/game/Battlegrounds/Battleground.cpp +++ b/src/server/game/Battlegrounds/Battleground.cpp @@ -112,6 +112,8 @@ Battleground::Battleground(BattlegroundTemplate const* battlegroundTemplate) : _ StartMessageIds[BG_STARTING_EVENT_FOURTH] = BG_TEXT_BATTLE_HAS_BEGUN; } +Battleground::Battleground(Battleground const&) = default; + Battleground::~Battleground() { // remove objects and creatures @@ -138,6 +140,8 @@ Battleground::~Battleground() for (BattlegroundScoreMap::const_iterator itr = PlayerScores.begin(); itr != PlayerScores.end(); ++itr) delete itr->second; + + _playerPositions.clear(); } void Battleground::Update(uint32 diff) @@ -248,7 +252,16 @@ void Battleground::_ProcessPlayerPositionBroadcast(uint32 diff) m_LastPlayerPositionBroadcast = 0; WorldPackets::Battleground::BattlegroundPlayerPositions playerPositions; - GetPlayerPositionData(&playerPositions.FlagCarriers); + + for (WorldPackets::Battleground::BattlegroundPlayerPosition& playerPosition : _playerPositions) + { + // Update position data if we found player. + if (Player* player = ObjectAccessor::GetPlayer(GetBgMap(), playerPosition.Guid)) + playerPosition.Pos = player->GetPosition(); + + playerPositions.FlagCarriers.push_back(playerPosition); + } + SendPacketToAll(playerPositions.Write()); } } @@ -992,6 +1005,8 @@ void Battleground::Reset() PlayerScores.clear(); ResetBGSubclass(); + + _playerPositions.clear(); } void Battleground::StartBattleground() @@ -1669,6 +1684,21 @@ void Battleground::PSendMessageToAll(uint32 entry, ChatMsg msgType, Player const va_end(ap); } +void Battleground::AddPlayerPosition(WorldPackets::Battleground::BattlegroundPlayerPosition const& position) +{ + _playerPositions.push_back(position); +} + +void Battleground::RemovePlayerPosition(ObjectGuid guid) +{ + auto itr = std::remove_if(_playerPositions.begin(), _playerPositions.end(), [guid](WorldPackets::Battleground::BattlegroundPlayerPosition const& playerPosition) + { + return playerPosition.Guid == guid; + }); + + _playerPositions.erase(itr, _playerPositions.end()); +} + void Battleground::EndNow() { RemoveFromBGFreeSlotQueue(); diff --git a/src/server/game/Battlegrounds/Battleground.h b/src/server/game/Battlegrounds/Battleground.h index dcd89fff157..383855cec1b 100644 --- a/src/server/game/Battlegrounds/Battleground.h +++ b/src/server/game/Battlegrounds/Battleground.h @@ -23,6 +23,7 @@ #include "Position.h" #include "SharedDefines.h" #include <map> +#include <vector> class BattlegroundMap; class Creature; @@ -259,8 +260,11 @@ class TC_GAME_API Battleground { public: Battleground(BattlegroundTemplate const* battlegroundTemplate); + Battleground(Battleground const&); virtual ~Battleground(); + Battleground& operator=(Battleground const&) = delete; + void Update(uint32 diff); virtual bool SetupBattleground() // must be implemented in BG subclass @@ -502,6 +506,9 @@ class TC_GAME_API Battleground // because BattleGrounds with different types and same level range has different m_BracketId uint8 GetUniqueBracketId() const; + void AddPlayerPosition(WorldPackets::Battleground::BattlegroundPlayerPosition const& position); + void RemovePlayerPosition(ObjectGuid guid); + protected: // this method is called, when BG cannot spawn its own spirit guide, or something is wrong, It correctly ends Battleground void EndNow(); @@ -549,7 +556,6 @@ class TC_GAME_API Battleground void _ProcessJoin(uint32 diff); void _CheckSafePositions(uint32 diff); void _ProcessPlayerPositionBroadcast(uint32 diff); - virtual void GetPlayerPositionData(std::vector<WorldPackets::Battleground::BattlegroundPlayerPosition>* /*positions*/) const { } // Scorekeeping BattlegroundScoreMap PlayerScores; // Player scores @@ -624,5 +630,7 @@ class TC_GAME_API Battleground BattlegroundTemplate const* _battlegroundTemplate; PVPDifficultyEntry const* _pvpDifficultyEntry; + + std::vector<WorldPackets::Battleground::BattlegroundPlayerPosition> _playerPositions; }; #endif diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundEY.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundEY.cpp index e93c0b952bb..c42350756d5 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundEY.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundEY.cpp @@ -118,19 +118,6 @@ void BattlegroundEY::PostUpdateImpl(uint32 diff) } } -void BattlegroundEY::GetPlayerPositionData(std::vector<WorldPackets::Battleground::BattlegroundPlayerPosition>* positions) const -{ - if (Player* player = ObjectAccessor::GetPlayer(GetBgMap(), m_FlagKeeper)) - { - WorldPackets::Battleground::BattlegroundPlayerPosition position; - position.Guid = player->GetGUID(); - position.Pos = player->GetPosition(); - position.IconID = player->GetTeam() == ALLIANCE ? PLAYER_POSITION_ICON_ALLIANCE_FLAG : PLAYER_POSITION_ICON_HORDE_FLAG; - position.ArenaSlot = PLAYER_POSITION_ARENA_SLOT_NONE; - positions->push_back(position); - } -} - void BattlegroundEY::StartingEventCloseDoors() { SpawnBGObject(BG_EY_OBJECT_DOOR_A, RESPAWN_IMMEDIATELY); diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundEY.h b/src/server/game/Battlegrounds/Zones/BattlegroundEY.h index c6e06735579..6590348875b 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundEY.h +++ b/src/server/game/Battlegrounds/Zones/BattlegroundEY.h @@ -445,7 +445,6 @@ class BattlegroundEY : public Battleground uint32 GetPrematureWinner() override; protected: void PostUpdateImpl(uint32 diff) override; - void GetPlayerPositionData(std::vector<WorldPackets::Battleground::BattlegroundPlayerPosition>* positions) const override; void EventPlayerCapturedFlag(Player* Source, uint32 BgObjectType); void EventTeamCapturedPoint(Player* Source, uint32 Point); diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundWS.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundWS.cpp index 483e7ab1706..fbdaa647090 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundWS.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundWS.cpp @@ -194,29 +194,6 @@ void BattlegroundWS::PostUpdateImpl(uint32 diff) } } -void BattlegroundWS::GetPlayerPositionData(std::vector<WorldPackets::Battleground::BattlegroundPlayerPosition>* positions) const -{ - if (Player* player = ObjectAccessor::GetPlayer(GetBgMap(), m_FlagKeepers[TEAM_ALLIANCE])) - { - WorldPackets::Battleground::BattlegroundPlayerPosition position; - position.Guid = player->GetGUID(); - position.Pos = player->GetPosition(); - position.IconID = PLAYER_POSITION_ICON_ALLIANCE_FLAG; - position.ArenaSlot = PLAYER_POSITION_ARENA_SLOT_NONE; - positions->push_back(position); - } - - if (Player* player = ObjectAccessor::GetPlayer(GetBgMap(), m_FlagKeepers[TEAM_HORDE])) - { - WorldPackets::Battleground::BattlegroundPlayerPosition position; - position.Guid = player->GetGUID(); - position.Pos = player->GetPosition(); - position.IconID = PLAYER_POSITION_ICON_HORDE_FLAG; - position.ArenaSlot = PLAYER_POSITION_ARENA_SLOT_NONE; - positions->push_back(position); - } -} - void BattlegroundWS::StartingEventCloseDoors() { for (uint32 i = BG_WS_OBJECT_DOOR_A_1; i <= BG_WS_OBJECT_DOOR_H_4; ++i) diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundWS.h b/src/server/game/Battlegrounds/Zones/BattlegroundWS.h index 3aa02818143..851fb7d96be 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundWS.h +++ b/src/server/game/Battlegrounds/Zones/BattlegroundWS.h @@ -273,7 +273,6 @@ class BattlegroundWS : public Battleground protected: void PostUpdateImpl(uint32 diff) override; - void GetPlayerPositionData(std::vector<WorldPackets::Battleground::BattlegroundPlayerPosition>* positions) const override; private: ObjectGuid m_FlagKeepers[2]; // 0 - alliance, 1 - horde diff --git a/src/server/game/Spells/Auras/SpellAuraDefines.h b/src/server/game/Spells/Auras/SpellAuraDefines.h index 654c4faeb61..8b21dc63149 100644 --- a/src/server/game/Spells/Auras/SpellAuraDefines.h +++ b/src/server/game/Spells/Auras/SpellAuraDefines.h @@ -469,8 +469,8 @@ enum AuraType : uint32 SPELL_AURA_SHOW_CONFIRMATION_PROMPT = 394, SPELL_AURA_AREA_TRIGGER = 395, // NYI SPELL_AURA_TRIGGER_SPELL_ON_POWER_AMOUNT = 396, // NYI Triggers spell when health goes above (MiscA = 0) or falls below (MiscA = 1) specified percent value (once, not every time condition has meet) - SPELL_AURA_397 = 397, - SPELL_AURA_398 = 398, + SPELL_AURA_BATTLEGROUND_PLAYER_POSITION_FACTIONAL = 397, + SPELL_AURA_BATTLEGROUND_PLAYER_POSITION = 398, SPELL_AURA_MOD_TIME_RATE = 399, SPELL_AURA_MOD_SKILL_2 = 400, SPELL_AURA_401 = 401, diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp index 714539fb265..9d00bc6009c 100644 --- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp +++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp @@ -19,6 +19,7 @@ #include "Battlefield.h" #include "BattlefieldMgr.h" #include "Battleground.h" +#include "BattlegroundPackets.h" #include "CellImpl.h" #include "Common.h" #include "DB2Stores.h" @@ -463,8 +464,8 @@ NonDefaultConstructible<pAuraEffectHandler> AuraEffectHandler[TOTAL_AURAS]= &AuraEffect::HandleShowConfirmationPrompt, //394 SPELL_AURA_SHOW_CONFIRMATION_PROMPT &AuraEffect::HandleCreateAreaTrigger, //395 SPELL_AURA_AREA_TRIGGER &AuraEffect::HandleNULL, //396 SPELL_AURA_TRIGGER_SPELL_ON_POWER_AMOUNT - &AuraEffect::HandleNULL, //397 - &AuraEffect::HandleNULL, //398 + &AuraEffect::HandleBattlegroundPlayerPosition, //397 SPELL_AURA_BATTLEGROUND_PLAYER_POSITION_FACTIONAL + &AuraEffect::HandleBattlegroundPlayerPosition, //398 SPELL_AURA_BATTLEGROUND_PLAYER_POSITION &AuraEffect::HandleNULL, //399 SPELL_AURA_MOD_TIME_RATE &AuraEffect::HandleAuraModSkill, //400 SPELL_AURA_MOD_SKILL_2 &AuraEffect::HandleNULL, //401 @@ -6368,6 +6369,43 @@ void AuraEffect::HandleModOverrideZonePVPType(AuraApplication const* aurApp, uin target->UpdatePvPState(); } +void AuraEffect::HandleBattlegroundPlayerPosition(AuraApplication const* aurApp, uint8 mode, bool apply) const +{ + if (!(mode & AURA_EFFECT_HANDLE_REAL)) + return; + + Player* target = aurApp->GetTarget()->ToPlayer(); + if (!target) + return; + + BattlegroundMap* battlegroundMap = target->GetMap()->ToBattlegroundMap(); + if (!battlegroundMap) + return; + + Battleground* bg = battlegroundMap->GetBG(); + if (!bg) + return; + + if (apply) + { + WorldPackets::Battleground::BattlegroundPlayerPosition playerPosition; + playerPosition.Guid = target->GetGUID(); + playerPosition.ArenaSlot = static_cast<uint8>(GetMiscValue()); + playerPosition.Pos = target->GetPosition(); + + if (GetAuraType() == SPELL_AURA_BATTLEGROUND_PLAYER_POSITION_FACTIONAL) + playerPosition.IconID = target->GetTeam() == ALLIANCE ? PLAYER_POSITION_ICON_HORDE_FLAG : PLAYER_POSITION_ICON_ALLIANCE_FLAG; + else if (GetAuraType() == SPELL_AURA_BATTLEGROUND_PLAYER_POSITION) + playerPosition.IconID = target->GetTeam() == ALLIANCE ? PLAYER_POSITION_ICON_ALLIANCE_FLAG : PLAYER_POSITION_ICON_HORDE_FLAG; + else + TC_LOG_WARN("spell.auras", "Unknown aura effect %u handled by HandleBattlegroundPlayerPosition.", GetAuraType()); + + bg->AddPlayerPosition(playerPosition); + } + else + bg->RemovePlayerPosition(target->GetGUID()); +} + template TC_GAME_API void AuraEffect::GetTargetList(std::list<Unit*>&) const; template TC_GAME_API void AuraEffect::GetTargetList(std::deque<Unit*>&) const; template TC_GAME_API void AuraEffect::GetTargetList(std::vector<Unit*>&) const; diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.h b/src/server/game/Spells/Auras/SpellAuraEffects.h index d4be1e62b83..b73b4210bb8 100644 --- a/src/server/game/Spells/Auras/SpellAuraEffects.h +++ b/src/server/game/Spells/Auras/SpellAuraEffects.h @@ -319,6 +319,7 @@ class TC_GAME_API AuraEffect void HandleCreateAreaTrigger(AuraApplication const* aurApp, uint8 mode, bool apply) const; void HandleLinkedSummon(AuraApplication const* aurApp, uint8 mode, bool apply) const; void HandleModOverrideZonePVPType(AuraApplication const* aurApp, uint8 mode, bool apply) const; + void HandleBattlegroundPlayerPosition(AuraApplication const* aurApp, uint8 mode, bool apply) const; // aura effect periodic tick handlers void HandlePeriodicDummyAuraTick(Unit* target, Unit* caster) const; |