Skip to content

Commit

Permalink
[9910] Implement expected from 3.2.x time limit for BattleGroundWS.
Browse files Browse the repository at this point in the history
With updates and fixes from zergtmn.

Signed-off-by: VladimirMangos <vladimir@getmangos.com>
  • Loading branch information
LordJZ authored and VladimirMangos committed May 16, 2010
1 parent 84d9ad0 commit 0ccee49
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 2 deletions.
32 changes: 32 additions & 0 deletions src/game/BattleGroundWS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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());
}
8 changes: 7 additions & 1 deletion src/game/BattleGroundWS.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand All @@ -152,5 +156,7 @@ class BattleGroundWS : public BattleGround
uint32 m_ReputationCapture;
uint32 m_HonorWinKills;
uint32 m_HonorEndKills;
uint32 m_EndTimer;
uint32 m_LastCapturedFlagTeam;
};
#endif
2 changes: 2 additions & 0 deletions src/game/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
};

Expand Down
2 changes: 1 addition & 1 deletion src/shared/revision_nr.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "9909"
#define REVISION_NR "9910"
#endif // __REVISION_NR_H__

1 comment on commit 0ccee49

@LordJZ
Copy link
Contributor

@LordJZ LordJZ commented on 0ccee49 May 16, 2010

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BG_WS_UNK1 can be renamed to BG_WS_TIMER_ENABLED

Please sign in to comment.