From 970a6124bafb7754754fc555bf0e2f3536f1bb99 Mon Sep 17 00:00:00 2001 From: zamalaev Date: Wed, 8 Jan 2014 13:33:38 +0400 Subject: [PATCH] Implemented SMSG_START_TIMER (Implement bg countdown timer) --- src/game/BattleGround/BattleGround.cpp | 29 ++++++++++++++++++++++++++ src/game/BattleGround/BattleGround.h | 3 +++ src/game/Opcodes.cpp | 1 + src/game/Opcodes.h | 1 + 4 files changed, 34 insertions(+) diff --git a/src/game/BattleGround/BattleGround.cpp b/src/game/BattleGround/BattleGround.cpp index 1eab7d97d..e39b2548e 100644 --- a/src/game/BattleGround/BattleGround.cpp +++ b/src/game/BattleGround/BattleGround.cpp @@ -219,6 +219,7 @@ BattleGround::BattleGround() m_IsArena = false; m_Winner = TEAM_NONE; m_StartTime = 0; + m_CountdownTimer = 0; m_Events = 0; m_IsRated = false; m_Name = ""; @@ -399,6 +400,24 @@ void BattleGround::Update(uint32 diff) { ModifyStartDelayTime(diff); + if (m_CountdownTimer >= 10000) + { + uint32 countdownMaxForBGType = isArena() ? ARENA_COUNTDOWN_MAX : BATTLEGROUND_COUNTDOWN_MAX; + + WorldPacket data(SMSG_START_TIMER, 4+4+4); + data << uint32(0); + data << uint32(countdownMaxForBGType - (m_StartTime / 1000)); + data << uint32(countdownMaxForBGType); + + for (BattleGroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr) + if (Player* player = sObjectMgr.GetPlayer(itr->first)) + player->GetSession()->SendPacket(&data); + + m_CountdownTimer = 0; + } + else + m_CountdownTimer += diff; + if (!(m_Events & BG_STARTING_EVENT_1)) { m_Events |= BG_STARTING_EVENT_1; @@ -1217,6 +1236,16 @@ void BattleGround::AddPlayer(Player* plr) plr->CastSpell(plr, SPELL_BATTLEGROUND_DAMPENING, true); } + if (GetStatus() == STATUS_WAIT_JOIN) // not started yet + { + int32 countdownMaxForBGType = isArena() ? ARENA_COUNTDOWN_MAX : BATTLEGROUND_COUNTDOWN_MAX; + WorldPacket data(SMSG_START_TIMER, 4+4+4); + data << uint32(0); // unk + data << uint32(countdownMaxForBGType - (m_StartTime / 1000)); + data << uint32(countdownMaxForBGType); + plr->GetSession()->SendPacket(&data); + } + plr->GetAchievementMgr().ResetAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HEALING_DONE, ACHIEVEMENT_CRITERIA_CONDITION_MAP, GetMapId()); plr->GetAchievementMgr().ResetAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_DAMAGE_DONE, ACHIEVEMENT_CRITERIA_CONDITION_MAP, GetMapId()); diff --git a/src/game/BattleGround/BattleGround.h b/src/game/BattleGround/BattleGround.h index c21424f0a..f6882b10c 100644 --- a/src/game/BattleGround/BattleGround.h +++ b/src/game/BattleGround/BattleGround.h @@ -112,6 +112,8 @@ enum BattleGroundTimeIntervals RESPAWN_IMMEDIATELY = 0, // secs BUFF_RESPAWN_TIME = 180, // secs ARENA_SPAWN_BUFF_OBJECTS = 90000, // ms - 90sec after start + BATTLEGROUND_COUNTDOWN_MAX = 120, // secs + ARENA_COUNTDOWN_MAX = 60, // secs }; enum BattleGroundStartTimeIntervals @@ -575,6 +577,7 @@ class BattleGround BattleGroundStatus m_Status; uint32 m_ClientInstanceID; // the instance-id which is sent to the client and without any other internal use uint32 m_StartTime; + uint32 m_CountdownTimer; bool m_ArenaBuffSpawned; // to cache if arenabuff event is started (cause bool is faster than checking IsActiveEvent) int32 m_EndTime; // it is set to 120000 when bg is ending and it decreases itself BattleGroundBracketId m_BracketId; diff --git a/src/game/Opcodes.cpp b/src/game/Opcodes.cpp index 7593d9c10..fef85640d 100644 --- a/src/game/Opcodes.cpp +++ b/src/game/Opcodes.cpp @@ -1412,4 +1412,5 @@ void InitializeOpcodes() //OPCODE(CMSG_OBJECT_UPDATE_FAILED, STATUS_LOGGEDIN, PROCESS_INPLACE, &WorldSession::HandleObjectUpdateFailedOpcode ); OPCODE(CMSG_REFORGE_ITEM, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleReforgeItemOpcode ); OPCODE(SMSG_REFORGE_RESULT, STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide ); + OPCODE(SMSG_START_TIMER, STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide ); }; diff --git a/src/game/Opcodes.h b/src/game/Opcodes.h index ad59c7c90..47005ba45 100644 --- a/src/game/Opcodes.h +++ b/src/game/Opcodes.h @@ -1430,6 +1430,7 @@ enum Opcodes CMSG_REFORGE_ITEM = 0x331A, // 4.3.4 15595 SMSG_REFORGE_RESULT = 0x58A4, // 4.3.4 15595 CMSG_LOAD_SCREEN = 0x2422, // 4.3.4 15595 + SMSG_START_TIMER = 0x59A5, // 4.3.4 15595 }; #define MAX_OPCODE_TABLE_SIZE 0xFFFF