From 0ccee499bc94efa776e34db90fe62c170036ed46 Mon Sep 17 00:00:00 2001 From: LordJZ Date: Sun, 16 May 2010 07:41:25 +0400 Subject: [PATCH] [9910] Implement expected from 3.2.x time limit for BattleGroundWS. With updates and fixes from zergtmn. Signed-off-by: VladimirMangos --- src/game/BattleGroundWS.cpp | 32 ++++++++++++++++++++++++++++++++ src/game/BattleGroundWS.h | 8 +++++++- src/game/Player.cpp | 2 ++ src/shared/revision_nr.h | 2 +- 4 files changed, 42 insertions(+), 2 deletions(-) diff --git a/src/game/BattleGroundWS.cpp b/src/game/BattleGroundWS.cpp index ba2b6e41105..9a121e0da03 100644 --- a/src/game/BattleGroundWS.cpp +++ b/src/game/BattleGroundWS.cpp @@ -86,6 +86,31 @@ void BattleGroundWS::Update(uint32 diff) RespawnFlagAfterDrop(HORDE); } } + + if (m_EndTimer <= diff) + { + uint32 allianceScore = GetTeamScore(ALLIANCE); + uint32 hordeScore = GetTeamScore(HORDE); + + if (allianceScore > hordeScore) + EndBattleGround(ALLIANCE); + else if (allianceScore < hordeScore) + EndBattleGround(HORDE); + else + { + // if 0 => tie + EndBattleGround(m_LastCapturedFlagTeam); + } + } + else + { + uint32 minutesLeftPrev = GetRemainingTimeInMinutes(); + m_EndTimer -= diff; + uint32 minutesLeft = GetRemainingTimeInMinutes(); + + if (minutesLeft != minutesLeftPrev) + UpdateWorldState(BG_WS_TIME_REMAINING, minutesLeft); + } } } @@ -165,6 +190,8 @@ void BattleGroundWS::EventPlayerCapturedFlag(Player *Source) if (GetStatus() != STATUS_IN_PROGRESS) return; + m_LastCapturedFlagTeam = Source->GetTeam(); + uint32 winner = 0; Source->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_ENTER_PVP_COMBAT); @@ -526,6 +553,8 @@ void BattleGroundWS::Reset() m_HonorWinKills = (isBGWeekend) ? 3 : 1; m_HonorEndKills = (isBGWeekend) ? 4 : 2; + m_EndTimer = BG_WS_TIME_LIMIT; + m_LastCapturedFlagTeam = 0; } void BattleGroundWS::EndBattleGround(uint32 winner) @@ -626,4 +655,7 @@ void BattleGroundWS::FillInitialWorldStates(WorldPacket& data, uint32& count) FillInitialWorldState(data, count, BG_WS_FLAG_STATE_ALLIANCE, 2); else FillInitialWorldState(data, count, BG_WS_FLAG_STATE_ALLIANCE, 1); + + FillInitialWorldState(data, count, BG_WS_UNK1, 1); + FillInitialWorldState(data, count, BG_WS_TIME_REMAINING, GetRemainingTimeInMinutes()); } diff --git a/src/game/BattleGroundWS.h b/src/game/BattleGroundWS.h index 42d3d9817ef..e6766b6288a 100644 --- a/src/game/BattleGroundWS.h +++ b/src/game/BattleGroundWS.h @@ -24,6 +24,7 @@ #define BG_WS_MAX_TEAM_SCORE 3 #define BG_WS_FLAG_RESPAWN_TIME (23*IN_MILLISECONDS) #define BG_WS_FLAG_DROP_TIME (10*IN_MILLISECONDS) +#define BG_WS_TIME_LIMIT (25*MINUTE*IN_MILLISECONDS) enum BG_WS_Sound { @@ -53,7 +54,9 @@ enum BG_WS_WorldStates BG_WS_FLAG_CAPTURES_HORDE = 1582, BG_WS_FLAG_CAPTURES_MAX = 1601, BG_WS_FLAG_STATE_HORDE = 2338, - BG_WS_FLAG_STATE_ALLIANCE = 2339 + BG_WS_FLAG_STATE_ALLIANCE = 2339, + BG_WS_UNK1 = 4247, // Show time limit? + BG_WS_TIME_REMAINING = 4248 }; enum BG_WS_FlagState @@ -128,6 +131,7 @@ class BattleGroundWS : public BattleGround virtual void Reset(); void EndBattleGround(uint32 winner); virtual WorldSafeLocsEntry const* GetClosestGraveYard(Player* player); + uint32 GetRemainingTimeInMinutes() { return m_EndTimer ? (m_EndTimer-1) / (MINUTE * IN_MILLISECONDS) + 1 : 0; } void UpdateFlagState(uint32 team, uint32 value); void UpdateTeamScore(uint32 team); @@ -152,5 +156,7 @@ class BattleGroundWS : public BattleGround uint32 m_ReputationCapture; uint32 m_HonorWinKills; uint32 m_HonorEndKills; + uint32 m_EndTimer; + uint32 m_LastCapturedFlagTeam; }; #endif diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 09b97483188..f8c56e4999f 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -8066,6 +8066,8 @@ static WorldStatePair WS_world_states[] = { 0x641, 0x3 }, // 12 1601 unk (max flag captures?) { 0x922, 0x1 }, // 13 2338 horde (0 - hide, 1 - flag ok, 2 - flag picked up (flashing), 3 - flag picked up (not flashing) { 0x923, 0x1 }, // 14 2339 alliance (0 - hide, 1 - flag ok, 2 - flag picked up (flashing), 3 - flag picked up (not flashing) + { 0x1097,0x1 }, // 15 4247 show time limit? + { 0x1098,0x19 }, // 16 4248 time remaining in minutes { 0x0, 0x0 } }; diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 7df376018d2..144c2c2d43c 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "9909" + #define REVISION_NR "9910" #endif // __REVISION_NR_H__