aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xsrc/server/game/Battlegrounds/Battleground.cpp19
-rwxr-xr-xsrc/server/game/Battlegrounds/Battleground.h2
-rwxr-xr-xsrc/server/game/Battlegrounds/Zones/BattlegroundAB.cpp19
-rwxr-xr-xsrc/server/game/Battlegrounds/Zones/BattlegroundAB.h2
-rwxr-xr-xsrc/server/game/Battlegrounds/Zones/BattlegroundAV.cpp13
-rwxr-xr-xsrc/server/game/Battlegrounds/Zones/BattlegroundAV.h4
-rwxr-xr-xsrc/server/game/Battlegrounds/Zones/BattlegroundEY.cpp10
-rwxr-xr-xsrc/server/game/Battlegrounds/Zones/BattlegroundEY.h2
-rwxr-xr-xsrc/server/game/Battlegrounds/Zones/BattlegroundWS.cpp9
-rwxr-xr-xsrc/server/game/Battlegrounds/Zones/BattlegroundWS.h2
10 files changed, 74 insertions, 8 deletions
diff --git a/src/server/game/Battlegrounds/Battleground.cpp b/src/server/game/Battlegrounds/Battleground.cpp
index d00bbcf098d..54422a8c5d3 100755
--- a/src/server/game/Battlegrounds/Battleground.cpp
+++ b/src/server/game/Battlegrounds/Battleground.cpp
@@ -404,6 +404,17 @@ inline void Battleground::_ProcessRessurect(uint32 diff)
}
}
+uint32 Battleground::GetPrematureWinner()
+{
+ uint32 winner = 0;
+ if (GetPlayersCountByTeam(ALLIANCE) >= GetMinPlayersPerTeam())
+ winner = ALLIANCE;
+ else if (GetPlayersCountByTeam(HORDE) >= GetMinPlayersPerTeam())
+ winner = HORDE;
+
+ return winner;
+}
+
inline void Battleground::_ProcessProgress(uint32 diff)
{
// *********************************************************
@@ -418,13 +429,7 @@ inline void Battleground::_ProcessProgress(uint32 diff)
else if (m_PrematureCountDownTimer < diff)
{
// time's up!
- uint32 winner = 0;
- if (GetPlayersCountByTeam(ALLIANCE) >= GetMinPlayersPerTeam())
- winner = ALLIANCE;
- else if (GetPlayersCountByTeam(HORDE) >= GetMinPlayersPerTeam())
- winner = HORDE;
-
- EndBattleground(winner);
+ EndBattleground(GetPrematureWinner());
m_PrematureCountDown = false;
}
else if (!sBattlegroundMgr->isTesting())
diff --git a/src/server/game/Battlegrounds/Battleground.h b/src/server/game/Battlegrounds/Battleground.h
index 6e839bfa6e2..71dbd097b0a 100755
--- a/src/server/game/Battlegrounds/Battleground.h
+++ b/src/server/game/Battlegrounds/Battleground.h
@@ -528,6 +528,8 @@ class Battleground
virtual uint64 GetFlagPickerGUID(int32 /*team*/ = -1) const { return 0; }
virtual void SetDroppedFlagGUID(uint64 /*guid*/, int32 /*team*/ = -1) {}
uint32 GetTeamScore(uint32 TeamID) const;
+
+ virtual uint32 GetPrematureWinner();
protected:
// this method is called, when BG cannot spawn its own spirit guide, or something is wrong, It correctly ends Battleground
diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundAB.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundAB.cpp
index 5a887c647b1..8f7231ba66e 100755
--- a/src/server/game/Battlegrounds/Zones/BattlegroundAB.cpp
+++ b/src/server/game/Battlegrounds/Zones/BattlegroundAB.cpp
@@ -548,6 +548,25 @@ void BattlegroundAB::EventPlayerClickedOnFlag(Player* source, GameObject* /*targ
PlaySoundToAll(sound);
}
+uint32 BattlegroundAB::GetPrematureWinner()
+{
+ // How many bases each team owns
+ uint8 ally = 0, horde = 0;
+ for (uint8 i = 0; i < BG_AB_DYNAMIC_NODES_COUNT; ++i)
+ if (m_Nodes[i] == BG_AB_NODE_STATUS_ALLY_OCCUPIED)
+ ++ally;
+ else if (m_Nodes[i] == BG_AB_NODE_STATUS_HORDE_OCCUPIED)
+ ++horde;
+
+ if (ally > horde)
+ return ALLIANCE;
+ else if (horde > ally)
+ return HORDE;
+
+ // If the values are equal, fall back to the original result (based on number of players on each team)
+ return Battleground::GetPrematureWinner();
+}
+
bool BattlegroundAB::SetupBattleground()
{
for (int i = 0; i < BG_AB_DYNAMIC_NODES_COUNT; ++i)
diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundAB.h b/src/server/game/Battlegrounds/Zones/BattlegroundAB.h
index 63c89717c8f..b80e216a216 100755
--- a/src/server/game/Battlegrounds/Zones/BattlegroundAB.h
+++ b/src/server/game/Battlegrounds/Zones/BattlegroundAB.h
@@ -272,6 +272,8 @@ class BattlegroundAB : public Battleground
/* achievement req. */
bool IsAllNodesConrolledByTeam(uint32 team) const; // overwrited
bool IsTeamScores500Disadvantage(uint32 team) const { return m_TeamScores500Disadvantage[GetTeamIndexByTeamId(team)]; }
+
+ uint32 GetPrematureWinner();
private:
void PostUpdateImpl(uint32 diff);
/* Gameobject spawning/despawning */
diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp
index a348ec69b8a..95aa0308c7d 100755
--- a/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp
+++ b/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp
@@ -1695,3 +1695,16 @@ bool BattlegroundAV::IsAllTowersControlledAndCaptainAlive(uint32 team) const
return false;
}
+
+uint32 BattlegroundAV::GetPrematureWinner()
+{
+ uint32 allianceScore = m_Team_Scores[GetTeamIndexByTeamId(ALLIANCE)];
+ uint32 hordeScore = m_Team_Scores[GetTeamIndexByTeamId(HORDE)];
+
+ if (allianceScore > hordeScore)
+ return ALLIANCE;
+ else if (hordeScore > allianceScore)
+ return HORDE;
+
+ return Battleground::GetPrematureWinner();
+} \ No newline at end of file
diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundAV.h b/src/server/game/Battlegrounds/Zones/BattlegroundAV.h
index dab67fe3258..bedd946a78c 100755
--- a/src/server/game/Battlegrounds/Zones/BattlegroundAV.h
+++ b/src/server/game/Battlegrounds/Zones/BattlegroundAV.h
@@ -1556,7 +1556,7 @@ class BattlegroundAV : public Battleground
/*general stuff*/
void UpdateScore(uint16 team, int16 points);
- void UpdatePlayerScore(Player* Source, uint32 type, uint32 value, bool doAddHonor = true);
+ void UpdatePlayerScore(Player* Source, uint32 type, uint32 value, bool doAddHonor = true);
/*handlestuff*/ //these are functions which get called from extern
void EventPlayerClickedOnFlag(Player* source, GameObject* target_obj);
@@ -1572,6 +1572,8 @@ class BattlegroundAV : public Battleground
/* achievement req. */
bool IsBothMinesControlledByTeam(uint32 team) const;
bool IsAllTowersControlledAndCaptainAlive(uint32 team) const;
+
+ uint32 GetPrematureWinner();
private:
void PostUpdateImpl(uint32 diff);
diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundEY.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundEY.cpp
index e900bc9b1d3..458e86729e7 100755
--- a/src/server/game/Battlegrounds/Zones/BattlegroundEY.cpp
+++ b/src/server/game/Battlegrounds/Zones/BattlegroundEY.cpp
@@ -937,3 +937,13 @@ bool BattlegroundEY::IsAllNodesConrolledByTeam(uint32 team) const
return count == EY_POINTS_MAX;
}
+
+uint32 BattlegroundEY::GetPrematureWinner()
+{
+ if (GetTeamScore(TEAM_ALLIANCE) > GetTeamScore(TEAM_HORDE))
+ return ALLIANCE;
+ else if (GetTeamScore(TEAM_HORDE) > GetTeamScore(TEAM_ALLIANCE))
+ return HORDE;
+
+ return Battleground::GetPrematureWinner();
+} \ No newline at end of file
diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundEY.h b/src/server/game/Battlegrounds/Zones/BattlegroundEY.h
index 61ee5b16c1c..2cfd4ca7e0f 100755
--- a/src/server/game/Battlegrounds/Zones/BattlegroundEY.h
+++ b/src/server/game/Battlegrounds/Zones/BattlegroundEY.h
@@ -369,6 +369,8 @@ class BattlegroundEY : public Battleground
/* achievement req. */
bool IsAllNodesConrolledByTeam(uint32 team) const;
+
+ uint32 GetPrematureWinner();
private:
void PostUpdateImpl(uint32 diff);
diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundWS.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundWS.cpp
index 5fd6e43c029..965045c5293 100755
--- a/src/server/game/Battlegrounds/Zones/BattlegroundWS.cpp
+++ b/src/server/game/Battlegrounds/Zones/BattlegroundWS.cpp
@@ -858,3 +858,12 @@ void BattlegroundWS::FillInitialWorldStates(WorldPacket& data)
data << uint32(BG_WS_FLAG_STATE_ALLIANCE) << uint32(1);
}
+uint32 BattlegroundWS::GetPrematureWinner()
+{
+ if (GetTeamScore(TEAM_ALLIANCE) > GetTeamScore(TEAM_HORDE))
+ return ALLIANCE;
+ else if (GetTeamScore(TEAM_HORDE) > GetTeamScore(TEAM_ALLIANCE))
+ return HORDE;
+
+ return Battleground::GetPrematureWinner();
+} \ No newline at end of file
diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundWS.h b/src/server/game/Battlegrounds/Zones/BattlegroundWS.h
index ec9f4ab1506..5b72de43b32 100755
--- a/src/server/game/Battlegrounds/Zones/BattlegroundWS.h
+++ b/src/server/game/Battlegrounds/Zones/BattlegroundWS.h
@@ -211,6 +211,8 @@ class BattlegroundWS : public Battleground
void AddPoint(uint32 TeamID, uint32 Points = 1) { m_TeamScores[GetTeamIndexByTeamId(TeamID)] += Points; }
void SetTeamPoint(uint32 TeamID, uint32 Points = 0) { m_TeamScores[GetTeamIndexByTeamId(TeamID)] = Points; }
void RemovePoint(uint32 TeamID, uint32 Points = 1) { m_TeamScores[GetTeamIndexByTeamId(TeamID)] -= Points; }
+
+ uint32 GetPrematureWinner();
private:
uint64 m_FlagKeepers[2]; // 0 - alliance, 1 - horde
uint64 m_DroppedFlagGUID[2];