mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-26 07:06:23 +00:00
refactor(Core/BG/AB): code cleanup (#1903)
This commit is contained in:
committed by
Stoabrogga
parent
d769d0e62c
commit
c6b5805065
@@ -34,9 +34,7 @@ BattlegroundAB::BattlegroundAB()
|
||||
StartMessageIds[BG_STARTING_EVENT_FOURTH] = LANG_BG_AB_HAS_BEGUN;
|
||||
}
|
||||
|
||||
BattlegroundAB::~BattlegroundAB()
|
||||
{
|
||||
}
|
||||
BattlegroundAB::~BattlegroundAB() = default;
|
||||
|
||||
void BattlegroundAB::PostUpdateImpl(uint32 diff)
|
||||
{
|
||||
@@ -70,14 +68,14 @@ void BattlegroundAB::PostUpdateImpl(uint32 diff)
|
||||
NodeOccupied(node);
|
||||
SendNodeUpdate(node);
|
||||
|
||||
SendMessage2ToAll(LANG_BG_AB_NODE_TAKEN, teamId == TEAM_ALLIANCE ? CHAT_MSG_BG_SYSTEM_ALLIANCE : CHAT_MSG_BG_SYSTEM_HORDE, NULL, teamId == TEAM_ALLIANCE ? LANG_BG_AB_ALLY : LANG_BG_AB_HORDE, LANG_BG_AB_NODE_STABLES + node);
|
||||
SendMessage2ToAll(LANG_BG_AB_NODE_TAKEN, teamId == TEAM_ALLIANCE ? CHAT_MSG_BG_SYSTEM_ALLIANCE : CHAT_MSG_BG_SYSTEM_HORDE, nullptr, teamId == TEAM_ALLIANCE ? LANG_BG_AB_ALLY : LANG_BG_AB_HORDE, LANG_BG_AB_NODE_STABLES + node);
|
||||
PlaySoundToAll(teamId == TEAM_ALLIANCE ? BG_AB_SOUND_NODE_CAPTURED_ALLIANCE : BG_AB_SOUND_NODE_CAPTURED_HORDE);
|
||||
break;
|
||||
}
|
||||
case BG_AB_EVENT_ALLIANCE_TICK:
|
||||
case BG_AB_EVENT_HORDE_TICK:
|
||||
{
|
||||
TeamId teamId = TeamId(eventId - BG_AB_EVENT_ALLIANCE_TICK);
|
||||
auto teamId = TeamId(eventId - BG_AB_EVENT_ALLIANCE_TICK);
|
||||
uint8 controlledPoints = _controlledPoints[teamId];
|
||||
if (controlledPoints == 0)
|
||||
{
|
||||
@@ -85,9 +83,9 @@ void BattlegroundAB::PostUpdateImpl(uint32 diff)
|
||||
break;
|
||||
}
|
||||
|
||||
uint8 honorRewards = uint8(m_TeamScores[teamId] / _honorTics);
|
||||
uint8 reputationRewards = uint8(m_TeamScores[teamId] / _reputationTics);
|
||||
uint8 information = uint8(m_TeamScores[teamId] / BG_AB_WARNING_NEAR_VICTORY_SCORE);
|
||||
auto honorRewards = uint8(m_TeamScores[teamId] / _honorTics);
|
||||
auto reputationRewards = uint8(m_TeamScores[teamId] / _reputationTics);
|
||||
auto information = uint8(m_TeamScores[teamId] / BG_AB_WARNING_NEAR_VICTORY_SCORE);
|
||||
m_TeamScores[teamId] += BG_AB_TickPoints[controlledPoints];
|
||||
if (m_TeamScores[teamId] > BG_AB_MAX_TEAM_SCORE)
|
||||
m_TeamScores[teamId] = BG_AB_MAX_TEAM_SCORE;
|
||||
@@ -111,6 +109,8 @@ void BattlegroundAB::PostUpdateImpl(uint32 diff)
|
||||
_bgEvents.ScheduleEvent(eventId, BG_AB_TickIntervals[controlledPoints]);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -183,6 +183,8 @@ void BattlegroundAB::HandleAreaTrigger(Player* player, uint32 trigger)
|
||||
case 4020: // Unk1
|
||||
case 4021: // Unk2
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -207,13 +209,13 @@ void BattlegroundAB::DeleteBanner(uint8 node)
|
||||
|
||||
void BattlegroundAB::FillInitialWorldStates(WorldPacket& data)
|
||||
{
|
||||
for (uint8 node = 0; node < BG_AB_DYNAMIC_NODES_COUNT; ++node)
|
||||
for (auto & node : _capturePointInfo)
|
||||
{
|
||||
if (_capturePointInfo[node]._state == BG_AB_NODE_STATE_NEUTRAL)
|
||||
data << uint32(_capturePointInfo[node]._iconNone) << uint32(1);
|
||||
if (node._state == BG_AB_NODE_STATE_NEUTRAL)
|
||||
data << uint32(node._iconNone) << uint32(1);
|
||||
|
||||
for (uint8 i = BG_AB_NODE_STATE_ALLY_OCCUPIED; i <= BG_AB_NODE_STATE_HORDE_CONTESTED; ++i)
|
||||
data << uint32(_capturePointInfo[node]._iconCapture + i-1) << uint32(_capturePointInfo[node]._state == i);
|
||||
data << uint32(node._iconCapture + i-1) << uint32(node._state == i);
|
||||
}
|
||||
|
||||
data << uint32(BG_AB_OP_OCCUPIED_BASES_ALLY) << uint32(_controlledPoints[TEAM_ALLIANCE]);
|
||||
@@ -452,7 +454,7 @@ GraveyardStruct const* BattlegroundAB::GetClosestGraveyard(Player* player)
|
||||
|
||||
void BattlegroundAB::UpdatePlayerScore(Player* player, uint32 type, uint32 value, bool doAddHonor)
|
||||
{
|
||||
BattlegroundScoreMap::iterator itr = PlayerScores.find(player->GetGUID());
|
||||
auto itr = PlayerScores.find(player->GetGUID());
|
||||
if (itr == PlayerScores.end())
|
||||
return;
|
||||
|
||||
@@ -485,9 +487,9 @@ void BattlegroundAB::ApplyPhaseMask()
|
||||
phaseMask |= 1 << (i*2+1 + _capturePointInfo[i]._ownerTeamId);
|
||||
|
||||
const BattlegroundPlayerMap& bgPlayerMap = GetPlayers();
|
||||
for (BattlegroundPlayerMap::const_iterator itr = bgPlayerMap.begin(); itr != bgPlayerMap.end(); ++itr)
|
||||
for (auto itr : bgPlayerMap)
|
||||
{
|
||||
itr->second->SetPhaseMask(phaseMask, false);
|
||||
itr->second->UpdateObjectVisibility(true, false);
|
||||
itr.second->SetPhaseMask(phaseMask, false);
|
||||
itr.second->UpdateObjectVisibility(true, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -212,41 +212,41 @@ const float BG_AB_SpiritGuidePos[BG_AB_ALL_NODES_COUNT][4] =
|
||||
|
||||
struct BattlegroundABScore : public BattlegroundScore
|
||||
{
|
||||
BattlegroundABScore(Player* player) : BattlegroundScore(player), BasesAssaulted(0), BasesDefended(0) { }
|
||||
~BattlegroundABScore() { }
|
||||
explicit BattlegroundABScore(Player* player) : BattlegroundScore(player), BasesAssaulted(0), BasesDefended(0) { }
|
||||
~BattlegroundABScore() override = default;
|
||||
uint32 BasesAssaulted;
|
||||
uint32 BasesDefended;
|
||||
|
||||
uint32 GetAttr1() const final override { return BasesAssaulted; }
|
||||
uint32 GetAttr2() const final override { return BasesDefended; }
|
||||
uint32 GetAttr1() const final { return BasesAssaulted; }
|
||||
uint32 GetAttr2() const final { return BasesDefended; }
|
||||
};
|
||||
|
||||
class BattlegroundAB : public Battleground
|
||||
{
|
||||
public:
|
||||
BattlegroundAB();
|
||||
~BattlegroundAB();
|
||||
~BattlegroundAB() override;
|
||||
|
||||
void AddPlayer(Player* player);
|
||||
void StartingEventCloseDoors();
|
||||
void StartingEventOpenDoors();
|
||||
void RemovePlayer(Player* player);
|
||||
void HandleAreaTrigger(Player* player, uint32 trigger);
|
||||
bool SetupBattleground();
|
||||
void Init();
|
||||
void AddPlayer(Player* player) override;
|
||||
void StartingEventCloseDoors() override;
|
||||
void StartingEventOpenDoors() override;
|
||||
void RemovePlayer(Player* player) override;
|
||||
void HandleAreaTrigger(Player* player, uint32 trigger) override;
|
||||
bool SetupBattleground() override;
|
||||
void Init() override;
|
||||
void EndBattleground(TeamId winnerTeamId);
|
||||
GraveyardStruct const* GetClosestGraveyard(Player* player);
|
||||
GraveyardStruct const* GetClosestGraveyard(Player* player) override;
|
||||
|
||||
void UpdatePlayerScore(Player* player, uint32 type, uint32 value, bool doAddHonor = true);
|
||||
void FillInitialWorldStates(WorldPacket& data);
|
||||
void EventPlayerClickedOnFlag(Player* source, GameObject* gameObject);
|
||||
void UpdatePlayerScore(Player* player, uint32 type, uint32 value, bool doAddHonor = true) override;
|
||||
void FillInitialWorldStates(WorldPacket& data) override;
|
||||
void EventPlayerClickedOnFlag(Player* source, GameObject* gameObject) override;
|
||||
|
||||
bool AllNodesConrolledByTeam(TeamId teamId) const;
|
||||
bool AllNodesConrolledByTeam(TeamId teamId) const override;
|
||||
bool IsTeamScores500Disadvantage(TeamId teamId) const { return _teamScores500Disadvantage[teamId]; }
|
||||
|
||||
TeamId GetPrematureWinner();
|
||||
TeamId GetPrematureWinner() override;
|
||||
private:
|
||||
void PostUpdateImpl(uint32 diff);
|
||||
void PostUpdateImpl(uint32 diff) override;
|
||||
|
||||
void DeleteBanner(uint8 node);
|
||||
void CreateBanner(uint8 node, bool delay);
|
||||
@@ -273,8 +273,8 @@ class BattlegroundAB : public Battleground
|
||||
EventMap _bgEvents;
|
||||
uint32 _honorTics;
|
||||
uint32 _reputationTics;
|
||||
uint8 _controlledPoints[BG_TEAMS_COUNT];
|
||||
bool _teamScores500Disadvantage[BG_TEAMS_COUNT];
|
||||
uint8 _controlledPoints[BG_TEAMS_COUNT]{};
|
||||
bool _teamScores500Disadvantage[BG_TEAMS_COUNT]{};
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user