mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-15 23:20:36 +01:00
Core/Battleground: Use a general solution for MSG_BATTLEGROUND_PLAYER_POSITIONS
This commit is contained in:
@@ -573,6 +573,8 @@ class Battleground
|
||||
void RewardXPAtKill(Player* killer, Player* victim);
|
||||
bool CanAwardArenaPoints() const { return m_LevelMin >= BG_AWARD_ARENA_POINTS_MIN_LEVEL; }
|
||||
|
||||
virtual uint64 GetFlagPickerGUID(int32 /*team*/ = -1) const { return 0; }
|
||||
|
||||
protected:
|
||||
// this method is called, when BG cannot spawn its own spirit guide, or something is wrong, It correctly ends Battleground
|
||||
void EndNow();
|
||||
|
||||
@@ -341,7 +341,7 @@ class BattlegroundEY : public Battleground
|
||||
virtual void StartingEventOpenDoors();
|
||||
|
||||
/* BG Flags */
|
||||
uint64 GetFlagPickerGUID() const { return m_FlagKeeper; }
|
||||
uint64 GetFlagPickerGUID(int32 /*team*/ = -1) const { return m_FlagKeeper; }
|
||||
void SetFlagPicker(uint64 guid) { m_FlagKeeper = guid; }
|
||||
bool IsFlagPickedup() const { return m_FlagKeeper != 0; }
|
||||
uint8 GetFlagState() const { return m_FlagState; }
|
||||
|
||||
@@ -359,7 +359,7 @@ void BattlegroundWS::EventPlayerDroppedFlag(Player* Source)
|
||||
{
|
||||
if (!this->IsHordeFlagPickedup())
|
||||
return;
|
||||
if (GetHordeFlagPickerGUID() == Source->GetGUID())
|
||||
if (GetFlagPickerGUID(BG_TEAM_HORDE) == Source->GetGUID())
|
||||
{
|
||||
SetHordeFlagPicker(0);
|
||||
Source->RemoveAurasDueToSpell(BG_WS_SPELL_WARSONG_FLAG);
|
||||
@@ -369,7 +369,7 @@ void BattlegroundWS::EventPlayerDroppedFlag(Player* Source)
|
||||
{
|
||||
if (!this->IsAllianceFlagPickedup())
|
||||
return;
|
||||
if (GetAllianceFlagPickerGUID() == Source->GetGUID())
|
||||
if (GetFlagPickerGUID(BG_TEAM_ALLIANCE) == Source->GetGUID())
|
||||
{
|
||||
SetAllianceFlagPicker(0);
|
||||
Source->RemoveAurasDueToSpell(BG_WS_SPELL_SILVERWING_FLAG);
|
||||
@@ -384,7 +384,7 @@ void BattlegroundWS::EventPlayerDroppedFlag(Player* Source)
|
||||
{
|
||||
if (!IsHordeFlagPickedup())
|
||||
return;
|
||||
if (GetHordeFlagPickerGUID() == Source->GetGUID())
|
||||
if (GetFlagPickerGUID(BG_TEAM_HORDE) == Source->GetGUID())
|
||||
{
|
||||
SetHordeFlagPicker(0);
|
||||
Source->RemoveAurasDueToSpell(BG_WS_SPELL_WARSONG_FLAG);
|
||||
@@ -401,7 +401,7 @@ void BattlegroundWS::EventPlayerDroppedFlag(Player* Source)
|
||||
{
|
||||
if (!IsAllianceFlagPickedup())
|
||||
return;
|
||||
if (GetAllianceFlagPickerGUID() == Source->GetGUID())
|
||||
if (GetFlagPickerGUID(BG_TEAM_ALLIANCE) == Source->GetGUID())
|
||||
{
|
||||
SetAllianceFlagPicker(0);
|
||||
Source->RemoveAurasDueToSpell(BG_WS_SPELL_SILVERWING_FLAG);
|
||||
@@ -629,12 +629,12 @@ void BattlegroundWS::HandleAreaTrigger(Player* Source, uint32 Trigger)
|
||||
break;
|
||||
case 3646: // Alliance Flag spawn
|
||||
if (m_FlagState[BG_TEAM_HORDE] && !m_FlagState[BG_TEAM_ALLIANCE])
|
||||
if (GetHordeFlagPickerGUID() == Source->GetGUID())
|
||||
if (GetFlagPickerGUID(BG_TEAM_HORDE) == Source->GetGUID())
|
||||
EventPlayerCapturedFlag(Source);
|
||||
break;
|
||||
case 3647: // Horde Flag spawn
|
||||
if (m_FlagState[BG_TEAM_ALLIANCE] && !m_FlagState[BG_TEAM_HORDE])
|
||||
if (GetAllianceFlagPickerGUID() == Source->GetGUID())
|
||||
if (GetFlagPickerGUID(BG_TEAM_ALLIANCE) == Source->GetGUID())
|
||||
EventPlayerCapturedFlag(Source);
|
||||
break;
|
||||
case 3649: // unk1
|
||||
|
||||
@@ -168,8 +168,12 @@ class BattlegroundWS : public Battleground
|
||||
virtual void StartingEventOpenDoors();
|
||||
|
||||
/* BG Flags */
|
||||
uint64 GetAllianceFlagPickerGUID() const { return m_FlagKeepers[BG_TEAM_ALLIANCE]; }
|
||||
uint64 GetHordeFlagPickerGUID() const { return m_FlagKeepers[BG_TEAM_HORDE]; }
|
||||
uint64 GetFlagPickerGUID(int32 team) const
|
||||
{
|
||||
if (team == BG_TEAM_ALLIANCE || team == BG_TEAM_HORDE)
|
||||
return m_FlagKeepers[BG_TEAM_ALLIANCE];
|
||||
return 0;
|
||||
}
|
||||
void SetAllianceFlagPicker(uint64 guid) { m_FlagKeepers[BG_TEAM_ALLIANCE] = guid; }
|
||||
void SetHordeFlagPicker(uint64 guid) { m_FlagKeepers[BG_TEAM_HORDE] = guid; }
|
||||
bool IsAllianceFlagPickedup() const { return m_FlagKeepers[BG_TEAM_ALLIANCE] != 0; }
|
||||
@@ -177,10 +181,6 @@ class BattlegroundWS : public Battleground
|
||||
void RespawnFlag(uint32 Team, bool captured);
|
||||
void RespawnFlagAfterDrop(uint32 Team);
|
||||
uint8 GetFlagState(uint32 team) { return m_FlagState[GetTeamIndexByTeamId(team)]; }
|
||||
void AddTimedAura(uint32 aura);
|
||||
void RemoveTimedAura(uint32 aura);
|
||||
bool IsBrutalTimerDone;
|
||||
bool IsForceTimerDone;
|
||||
|
||||
/* Battleground Events */
|
||||
virtual void EventPlayerDroppedFlag(Player* Source);
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
|
||||
#include "ArenaTeam.h"
|
||||
#include "BattlegroundMgr.h"
|
||||
#include "BattlegroundWS.h"
|
||||
#include "Battleground.h"
|
||||
#include "Chat.h"
|
||||
#include "Language.h"
|
||||
@@ -252,56 +251,42 @@ void WorldSession::HandleBattlegroundPlayerPositionsOpcode(WorldPacket & /*recv_
|
||||
if (!bg) // can't be received if player not in battleground
|
||||
return;
|
||||
|
||||
switch(bg->GetTypeID(true))
|
||||
uint32 count = 0;
|
||||
Player* aplr = NULL;
|
||||
Player* hplr = NULL;
|
||||
|
||||
if (uint64 guid = bg->GetFlagPickerGUID(BG_TEAM_ALLIANCE))
|
||||
{
|
||||
case BATTLEGROUND_WS:
|
||||
{
|
||||
uint32 count = 0;
|
||||
|
||||
Player* aplr = ObjectAccessor::FindPlayer(((BattlegroundWS*)bg)->GetAllianceFlagPickerGUID());
|
||||
if (aplr)
|
||||
++count;
|
||||
|
||||
Player* hplr = ObjectAccessor::FindPlayer(((BattlegroundWS*)bg)->GetHordeFlagPickerGUID());
|
||||
if (hplr)
|
||||
++count;
|
||||
|
||||
WorldPacket data(MSG_BATTLEGROUND_PLAYER_POSITIONS, 4 + 4 + 16 * count);
|
||||
data << 0;
|
||||
data << count;
|
||||
if (aplr)
|
||||
{
|
||||
data << uint64(aplr->GetGUID());
|
||||
data << float(aplr->GetPositionX());
|
||||
data << float(aplr->GetPositionY());
|
||||
}
|
||||
|
||||
if (hplr)
|
||||
{
|
||||
data << uint64(hplr->GetGUID());
|
||||
data << float(hplr->GetPositionX());
|
||||
data << float(hplr->GetPositionY());
|
||||
}
|
||||
|
||||
SendPacket(&data);
|
||||
break;
|
||||
}
|
||||
case BATTLEGROUND_EY:
|
||||
//TODO : fix me!
|
||||
break;
|
||||
case BATTLEGROUND_AB:
|
||||
case BATTLEGROUND_AV:
|
||||
{
|
||||
WorldPacket data(MSG_BATTLEGROUND_PLAYER_POSITIONS, (4+4));
|
||||
data << uint32(0);
|
||||
data << uint32(0);
|
||||
SendPacket(&data);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
//maybe it is sent also in arena - do nothing
|
||||
break;
|
||||
aplr = ObjectAccessor::FindPlayer(guid);
|
||||
if (aplr)
|
||||
++count;
|
||||
}
|
||||
|
||||
if (uint64 guid = bg->GetFlagPickerGUID(BG_TEAM_HORDE))
|
||||
{
|
||||
hplr = ObjectAccessor::FindPlayer(guid);
|
||||
if (hplr)
|
||||
++count;
|
||||
}
|
||||
|
||||
WorldPacket data(MSG_BATTLEGROUND_PLAYER_POSITIONS, 4 + 4 + 16 * count);
|
||||
data << 0;
|
||||
data << count;
|
||||
if (aplr)
|
||||
{
|
||||
data << uint64(aplr->GetGUID());
|
||||
data << float(aplr->GetPositionX());
|
||||
data << float(aplr->GetPositionY());
|
||||
}
|
||||
|
||||
if (hplr)
|
||||
{
|
||||
data << uint64(hplr->GetGUID());
|
||||
data << float(hplr->GetPositionX());
|
||||
data << float(hplr->GetPositionY());
|
||||
}
|
||||
|
||||
SendPacket(&data);
|
||||
}
|
||||
|
||||
void WorldSession::HandlePVPLogDataOpcode(WorldPacket & /*recv_data*/)
|
||||
|
||||
Reference in New Issue
Block a user