diff options
Diffstat (limited to 'src')
33 files changed, 299 insertions, 336 deletions
diff --git a/src/server/game/Battlegrounds/Battleground.cpp b/src/server/game/Battlegrounds/Battleground.cpp index b1b7a29fd0f..48a7a346568 100755 --- a/src/server/game/Battlegrounds/Battleground.cpp +++ b/src/server/game/Battlegrounds/Battleground.cpp @@ -247,19 +247,41 @@ void Battleground::Update(uint32 diff) return; } - _ProcessOfflineQueue(); - _ProcessRessurect(diff); - - if (GetStatus() == STATUS_IN_PROGRESS && !isArena() && sBattlegroundMgr->GetPrematureFinishTime() && (GetPlayersCountByTeam(ALLIANCE) < GetMinPlayersPerTeam() || GetPlayersCountByTeam(HORDE) < GetMinPlayersPerTeam())) - _ProcessProgress(diff); - else if (m_PrematureCountDown) - m_PrematureCountDown = false; - - if (GetStatus() == STATUS_WAIT_JOIN && GetPlayersSize()) - _ProcessJoin(diff); - - if (GetStatus() == STATUS_WAIT_LEAVE) - _ProcessLeave(diff); + switch(GetStatus()) + { + case STATUS_WAIT_JOIN: + if (GetPlayersSize()) + { + _ProcessJoin(diff); + } + break; + case STATUS_IN_PROGRESS: + _ProcessOfflineQueue(); + // after 47 minutes without one team losing, the arena closes with no winner and no rating change + if (isArena()) + { + if (GetStartTime() >= 47*MINUTE*IN_MILLISECONDS) + { + UpdateArenaWorldState(); + CheckArenaAfterTimerConditions(); + return; + } + } + else + { + _ProcessRessurect(diff); + if (sBattlegroundMgr->GetPrematureFinishTime() && (GetPlayersCountByTeam(ALLIANCE) < GetMinPlayersPerTeam() || GetPlayersCountByTeam(HORDE) < GetMinPlayersPerTeam())) + _ProcessProgress(diff); + else if (m_PrematureCountDown) + m_PrematureCountDown = false; + } + break; + case STATUS_WAIT_LEAVE: + _ProcessLeave(diff); + break; + default: + break; + } // Update start time and reset stats timer m_StartTime += diff; @@ -514,7 +536,7 @@ inline void Battleground::_ProcessLeave(uint32 diff) } } -inline Player* Battleground::_GetPlayer(const uint64 guid, bool offlineRemove, const char* context) const +inline Player* Battleground::_GetPlayer(uint64 guid, bool offlineRemove, const char* context) const { Player* player = NULL; if (!offlineRemove) @@ -874,7 +896,7 @@ void Battleground::BlockMovement(Player* plr) plr->SetClientControl(plr, 0); // movement disabled NOTE: the effect will be automatically removed by client when the player is teleported from the battleground, so no need to send with uint8(1) in RemovePlayerAtLeave() } -void Battleground::RemovePlayerAtLeave(const uint64 guid, bool Transport, bool SendPacket) +void Battleground::RemovePlayerAtLeave(uint64 guid, bool Transport, bool SendPacket) { uint32 team = GetPlayerTeam(guid); bool participant = false; @@ -897,16 +919,19 @@ void Battleground::RemovePlayerAtLeave(const uint64 guid, bool Transport, bool S RemovePlayerFromResurrectQueue(guid); - Player *plr = ObjectAccessor::FindPlayer(guid); + Player* plr = ObjectAccessor::FindPlayer(guid); // should remove spirit of redemption - if (plr && plr->HasAuraType(SPELL_AURA_SPIRIT_OF_REDEMPTION)) - plr->RemoveAurasByType(SPELL_AURA_MOD_SHAPESHIFT); - - if (plr && !plr->isAlive()) // resurrect on exit + if (plr) { - plr->ResurrectPlayer(1.0f); - plr->SpawnCorpseBones(); + if (plr->HasAuraType(SPELL_AURA_SPIRIT_OF_REDEMPTION)) + plr->RemoveAurasByType(SPELL_AURA_MOD_SHAPESHIFT); + + if (!plr->isAlive()) // resurrect on exit + { + plr->ResurrectPlayer(1.0f); + plr->SpawnCorpseBones(); + } } RemovePlayer(plr, guid, team); // BG subclass specific code @@ -1170,16 +1195,17 @@ void Battleground::AddOrSetPlayerToCorrectBgGroup(Player* player, uint32 team) // This method should be called when player logs into running battleground void Battleground::EventPlayerLoggedIn(Player* player) { + uint64 guid = player->GetGUID(); // player is correct pointer for (std::deque<uint64>::iterator itr = m_OfflineQueue.begin(); itr != m_OfflineQueue.end(); ++itr) { - if (*itr == player->GetGUID()) + if (*itr == guid) { m_OfflineQueue.erase(itr); break; } } - m_Players[player->GetGUID()].OfflineRemoveTime = 0; + m_Players[guid].OfflineRemoveTime = 0; PlayerAddedToBGCheckIfBGIsRunning(player); // if battleground is starting, then add preparation aura // we don't have to do that, because preparation aura isn't removed when player logs out @@ -1188,13 +1214,14 @@ void Battleground::EventPlayerLoggedIn(Player* player) // This method should be called when player logs out from running battleground void Battleground::EventPlayerLoggedOut(Player* player) { + uint64 guid = player->GetGUID(); // player is correct pointer, it is checked in WorldSession::LogoutPlayer() m_OfflineQueue.push_back(player->GetGUID()); - m_Players[player->GetGUID()].OfflineRemoveTime = sWorld->GetGameTime() + MAX_OFFLINE_TIME; + m_Players[guid].OfflineRemoveTime = sWorld->GetGameTime() + MAX_OFFLINE_TIME; if (GetStatus() == STATUS_IN_PROGRESS) { // drop flag and handle other cleanups - RemovePlayer(player, player->GetGUID(), GetPlayerTeam(player->GetGUID())); + RemovePlayer(player, guid, GetPlayerTeam(guid)); // 1 player is logging out, if it is the last, then end arena! if (isArena()) @@ -1337,7 +1364,7 @@ void Battleground::UpdatePlayerScore(Player* Source, uint32 type, uint32 value, } } -void Battleground::AddPlayerToResurrectQueue(const uint64 npc_guid, const uint64 player_guid) +void Battleground::AddPlayerToResurrectQueue(uint64 npc_guid, uint64 player_guid) { m_ReviveQueue[npc_guid].push_back(player_guid); @@ -1348,7 +1375,7 @@ void Battleground::AddPlayerToResurrectQueue(const uint64 npc_guid, const uint64 plr->CastSpell(plr, SPELL_WAITING_FOR_RESURRECT, true); } -void Battleground::RemovePlayerFromResurrectQueue(const uint64 player_guid) +void Battleground::RemovePlayerFromResurrectQueue(uint64 player_guid) { for (std::map<uint64, std::vector<uint64> >::iterator itr = m_ReviveQueue.begin(); itr != m_ReviveQueue.end(); ++itr) { @@ -1586,6 +1613,9 @@ bool Battleground::AddSpiritGuide(uint32 type, float x, float y, float z, float void Battleground::SendMessageToAll(int32 entry, ChatMsg type, Player const* source) { + if (!entry) + return; + Trinity::BattlegroundChatBuilder bg_builder(type, entry, source); Trinity::LocalizedPacketDo<Trinity::BattlegroundChatBuilder> bg_do(bg_builder); BroadcastWorker(bg_do); @@ -1593,6 +1623,9 @@ void Battleground::SendMessageToAll(int32 entry, ChatMsg type, Player const* sou void Battleground::PSendMessageToAll(int32 entry, ChatMsg type, Player const* source, ...) { + if (!entry) + return; + va_list ap; va_start(ap, source); @@ -1605,6 +1638,9 @@ void Battleground::PSendMessageToAll(int32 entry, ChatMsg type, Player const* so void Battleground::SendWarningToAll(int32 entry, ...) { + if (!entry) + return; + const char *format = sObjectMgr->GetTrinityStringForDBCLocale(entry); char str[1024]; @@ -1656,7 +1692,7 @@ const char* Battleground::GetTrinityString(int32 entry) // IMPORTANT NOTICE: // buffs aren't spawned/despawned when players captures anything // buffs are in their positions when battleground starts -void Battleground::HandleTriggerBuff(const uint64 go_guid) +void Battleground::HandleTriggerBuff(uint64 go_guid) { GameObject *obj = GetBgMap()->GetGameObject(go_guid); if (!obj || obj->GetGoType() != GAMEOBJECT_TYPE_TRAP || !obj->isSpawned()) @@ -1725,7 +1761,7 @@ void Battleground::HandleKillPlayer(Player* player, Player* killer) // Return the player's team based on battlegroundplayer info // Used in same faction arena matches mainly -uint32 Battleground::GetPlayerTeam(const uint64 guid) const +uint32 Battleground::GetPlayerTeam(uint64 guid) const { BattlegroundPlayerMap::const_iterator itr = m_Players.find(guid); if (itr != m_Players.end()) @@ -1738,7 +1774,7 @@ uint32 Battleground::GetOtherTeam(uint32 teamId) const return teamId ? ((teamId == ALLIANCE) ? HORDE : ALLIANCE) : 0; } -bool Battleground::IsPlayerInBattleground(const uint64 guid) const +bool Battleground::IsPlayerInBattleground(uint64 guid) const { BattlegroundPlayerMap::const_iterator itr = m_Players.find(guid); if (itr != m_Players.end()) @@ -1783,7 +1819,7 @@ void Battleground::SetHoliday(bool is_holiday) m_HonorMode = is_holiday ? BG_HOLIDAY : BG_NORMAL; } -int32 Battleground::GetObjectType(const uint64 guid) +int32 Battleground::GetObjectType(uint64 guid) { for (uint32 i = 0; i < m_BgObjects.size(); ++i) if (m_BgObjects[i] == guid) diff --git a/src/server/game/Battlegrounds/Battleground.h b/src/server/game/Battlegrounds/Battleground.h index 114397b0b10..4f2f87c14c6 100755 --- a/src/server/game/Battlegrounds/Battleground.h +++ b/src/server/game/Battlegrounds/Battleground.h @@ -312,14 +312,12 @@ This class is used to: */ class Battleground { - friend class BattlegroundMgr; - public: - /* Construction */ Battleground(); - /*Battleground(const Battleground& bg);*/ virtual ~Battleground(); - virtual void Update(uint32 diff); // must be implemented in BG subclass of BG specific update code, but must in begginning call parent version + + void Update(uint32 diff); + virtual bool SetupBattleground() // must be implemented in BG subclass { return true; @@ -419,8 +417,8 @@ class Battleground uint32 GetReviveQueueSize() const { return m_ReviveQueue.size(); } - void AddPlayerToResurrectQueue(const uint64 npc_guid, const uint64 player_guid); - void RemovePlayerFromResurrectQueue(const uint64 player_guid); + void AddPlayerToResurrectQueue(uint64 npc_guid, uint64 player_guid); + void RemovePlayerFromResurrectQueue(uint64 player_guid); void StartBattleground(); @@ -497,10 +495,13 @@ class Battleground // used for rated arena battles void SetArenaTeamIdForTeam(uint32 Team, uint32 ArenaTeamId) { m_ArenaTeamIds[GetTeamIndexByTeamId(Team)] = ArenaTeamId; } uint32 GetArenaTeamIdForTeam(uint32 Team) const { return m_ArenaTeamIds[GetTeamIndexByTeamId(Team)]; } + uint32 GetArenaTeamIdByIndex(uint32 index) const { return m_ArenaTeamIds[index]; } void SetArenaTeamRatingChangeForTeam(uint32 Team, int32 RatingChange) { m_ArenaTeamRatingChanges[GetTeamIndexByTeamId(Team)] = RatingChange; } int32 GetArenaTeamRatingChangeForTeam(uint32 Team) const { return m_ArenaTeamRatingChanges[GetTeamIndexByTeamId(Team)]; } + int32 GetArenaTeamRatingChangeByIndex(uint32 index) const { return m_ArenaTeamRatingChanges[index]; } void SetArenaMatchmakerRating(uint32 Team, uint32 MMR){ m_ArenaTeamMMR[GetTeamIndexByTeamId(Team)] = MMR; } - uint32 GetArenaMatchmakerRating(uint32 Team) { return m_ArenaTeamMMR[GetTeamIndexByTeamId(Team)]; } + uint32 GetArenaMatchmakerRating(uint32 Team) const { return m_ArenaTeamMMR[GetTeamIndexByTeamId(Team)]; } + uint32 GetArenaMatchmakerRatingByIndex(uint32 index) const { return m_ArenaTeamMMR[index]; } void CheckArenaAfterTimerConditions(); void CheckArenaWinConditions(); void UpdateArenaWorldState(); @@ -515,14 +516,13 @@ class Battleground // Battleground events virtual void EventPlayerDroppedFlag(Player* /*player*/) {} virtual void EventPlayerClickedOnFlag(Player* /*player*/, GameObject* /*target_obj*/) {} - virtual void EventPlayerCapturedFlag(Player* /*player*/) {} void EventPlayerLoggedIn(Player* player); void EventPlayerLoggedOut(Player* player); virtual void EventPlayerDamagedGO(Player* /*plr*/, GameObject* /*go*/, uint32 /*eventType*/) {} virtual void EventPlayerUsedGO(Player* /*player*/, GameObject* /*go*/){} // this function can be used by spell to interact with the BG map - virtual void DoAction(uint32 /*action*/, const uint64 /*var*/) {} + virtual void DoAction(uint32 /*action*/, uint64 /*var*/) {} virtual void HandlePlayerResurrect(Player* /*player*/) {} @@ -533,10 +533,10 @@ class Battleground void AddOrSetPlayerToCorrectBgGroup(Player* player, uint32 team); - virtual void RemovePlayerAtLeave(const uint64 guid, bool Transport, bool SendPacket); + virtual void RemovePlayerAtLeave(uint64 guid, bool Transport, bool SendPacket); // can be extended in in BG subclass - void HandleTriggerBuff(const uint64 go_guid); + void HandleTriggerBuff(uint64 go_guid); void SetHoliday(bool is_holiday); // TODO: make this protected: @@ -550,7 +550,7 @@ class Battleground bool DelCreature(uint32 type); bool DelObject(uint32 type); bool AddSpiritGuide(uint32 type, float x, float y, float z, float o, uint32 team); - int32 GetObjectType(const uint64 guid); + int32 GetObjectType(uint64 guid); void DoorOpen(uint32 type); void DoorClose(uint32 type); @@ -560,10 +560,11 @@ class Battleground virtual bool HandlePlayerUnderMap(Player* /*plr*/) { return false; } // since arenas can be AvA or Hvh, we have to get the "temporary" team of a player - uint32 GetPlayerTeam(const uint64 guid) const; + uint32 GetPlayerTeam(uint64 guid) const; uint32 GetOtherTeam(uint32 teamId) const; - bool IsPlayerInBattleground(const uint64 guid) const; + bool IsPlayerInBattleground(uint64 guid) const; + bool ToBeDeleted() const { return m_SetDeleteThis; } void SetDeleteThis() { m_SetDeleteThis = true; } // virtual score-array - get's used in bg-subclasses @@ -577,7 +578,7 @@ class Battleground void EndNow(); void PlayerAddedToBGCheckIfBGIsRunning(Player* plr); - Player* _GetPlayer(const uint64 guid, bool offlineRemove, const char* context) const; + Player* _GetPlayer(uint64 guid, bool offlineRemove, const char* context) const; Player* _GetPlayer(BattlegroundPlayerMap::iterator itr, const char* context); Player* _GetPlayer(BattlegroundPlayerMap::const_iterator itr, const char* context) const; Player* _GetPlayerForTeam(uint32 teamId, BattlegroundPlayerMap::const_iterator itr, const char* context) const; @@ -631,6 +632,36 @@ class Battleground uint32 m_PrematureCountDownTimer; char const *m_Name; + /* Pre- and post-update hooks */ + + /** + * @brief Pre-update hook. + * + * Will be called before battleground update is started. Depending on + * the result of this call actual update body may be skipped. + * + * @param diff a time difference between two worldserver update loops in + * milliseconds. + * + * @return @c true if update must be performed, @c false otherwise. + * + * @see Update(), PostUpdateImpl(). + */ + virtual bool PreUpdateImpl(uint32 /* diff */) { return true; }; + + /** + * @brief Post-update hook. + * + * Will be called after battleground update has passed. May be used to + * implement custom update effects in subclasses. + * + * @param diff a time difference between two worldserver update loops in + * milliseconds. + * + * @see Update(), PreUpdateImpl(). + */ + virtual void PostUpdateImpl(uint32 /* diff */) { }; + // Player lists std::vector<uint64> m_ResurrectQueue; // Player GUID std::deque<uint64> m_OfflineQueue; // Player GUID diff --git a/src/server/game/Battlegrounds/BattlegroundMgr.cpp b/src/server/game/Battlegrounds/BattlegroundMgr.cpp index 2772b5de258..b9a92f0cb44 100755 --- a/src/server/game/Battlegrounds/BattlegroundMgr.cpp +++ b/src/server/game/Battlegrounds/BattlegroundMgr.cpp @@ -104,7 +104,7 @@ void BattlegroundMgr::Update(uint32 diff) itr->second->Update(diff); // use the SetDeleteThis variable // direct deletion caused crashes - if (itr->second->m_SetDeleteThis) + if (itr->second->ToBeDeleted()) { Battleground* bg = itr->second; m_Battlegrounds[i].erase(itr); @@ -239,20 +239,20 @@ void BattlegroundMgr::BuildPvpLogDataPacket(WorldPacket *data, Battleground *bg) // it seems this must be according to BG_WINNER_A/H and _NOT_ BG_TEAM_A/H for (int8 i = 1; i >= 0; --i) { - uint32 pointsLost = bg->m_ArenaTeamRatingChanges[i] < 0 ? abs(bg->m_ArenaTeamRatingChanges[i]) : 0; - uint32 pointsGained = bg->m_ArenaTeamRatingChanges[i] > 0 ? bg->m_ArenaTeamRatingChanges[i] : 0; - uint32 MatchmakerRating = bg->m_ArenaTeamMMR[i]; + int32 rating_change = bg->GetArenaTeamRatingChangeByIndex(i); + + uint32 pointsLost = rating_change < 0 ? -rating_change : 0; + uint32 pointsGained = rating_change > 0 ? rating_change : 0; + uint32 MatchmakerRating = bg->GetArenaMatchmakerRatingByIndex(i); *data << uint32(pointsLost); // Rating Lost *data << uint32(pointsGained); // Rating gained *data << uint32(MatchmakerRating); // Matchmaking Value - sLog->outDebug(LOG_FILTER_BATTLEGROUND, "rating change: %d", bg->m_ArenaTeamRatingChanges[i]); + sLog->outDebug(LOG_FILTER_BATTLEGROUND, "rating change: %d", rating_change); } for (int8 i = 1; i >= 0; --i) { - uint32 at_id = bg->m_ArenaTeamIds[i]; - ArenaTeam* at = sArenaTeamMgr->GetArenaTeamById(at_id); - if (at) + if (ArenaTeam* at = sArenaTeamMgr->GetArenaTeamById(bg->GetArenaTeamIdByIndex(i))) *data << at->GetName(); else *data << uint8(0); @@ -417,7 +417,7 @@ void BattlegroundMgr::BuildPlaySoundPacket(WorldPacket *data, uint32 soundid) *data << uint32(soundid); } -void BattlegroundMgr::BuildPlayerLeftBattlegroundPacket(WorldPacket *data, const uint64 guid) +void BattlegroundMgr::BuildPlayerLeftBattlegroundPacket(WorldPacket *data, uint64 guid) { data->Initialize(SMSG_BATTLEGROUND_PLAYER_LEFT, 8); *data << uint64(guid); @@ -604,10 +604,7 @@ Battleground* BattlegroundMgr::CreateNewBattleground(BattlegroundTypeId bgTypeId bg->SetBracket(bracketEntry); // generate a new instance id - uint32 instanceId = sMapMgr->GenerateInstanceId(); - // set instance id - bg->SetInstanceID(instanceId); - + bg->SetInstanceID(sMapMgr->GenerateInstanceId()); // set instance id bg->SetClientInstanceID(CreateClientVisibleInstanceId(isRandom ? BATTLEGROUND_RB : bgTypeId, bracketEntry->GetBracketId())); // reset the new bg (set status to status_wait_queue from status_none) @@ -625,11 +622,11 @@ Battleground* BattlegroundMgr::CreateNewBattleground(BattlegroundTypeId bgTypeId } // used to create the BG templates -uint32 BattlegroundMgr::CreateBattleground(BattlegroundTypeId bgTypeId, bool IsArena, uint32 MinPlayersPerTeam, uint32 MaxPlayersPerTeam, uint32 LevelMin, uint32 LevelMax, char* BattlegroundName, uint32 MapID, float Team1StartLocX, float Team1StartLocY, float Team1StartLocZ, float Team1StartLocO, float Team2StartLocX, float Team2StartLocY, float Team2StartLocZ, float Team2StartLocO, uint32 scriptId) +uint32 BattlegroundMgr::CreateBattleground(CreateBattlegroundData& data) { // Create the BG Battleground *bg = NULL; - switch(bgTypeId) + switch (data.bgTypeId) { case BATTLEGROUND_AV: bg = new BattlegroundAV; break; case BATTLEGROUND_WS: bg = new BattlegroundWS; break; @@ -649,41 +646,35 @@ uint32 BattlegroundMgr::CreateBattleground(BattlegroundTypeId bgTypeId, bool IsA break; } - bg->SetMapId(MapID); - bg->SetTypeID(bgTypeId); + bg->SetMapId(data.MapID); + bg->SetTypeID(data.bgTypeId); bg->SetInstanceID(0); - bg->SetArenaorBGType(IsArena); - bg->SetMinPlayersPerTeam(MinPlayersPerTeam); - bg->SetMaxPlayersPerTeam(MaxPlayersPerTeam); - bg->SetMinPlayers(MinPlayersPerTeam * 2); - bg->SetMaxPlayers(MaxPlayersPerTeam * 2); - bg->SetName(BattlegroundName); - bg->SetTeamStartLoc(ALLIANCE, Team1StartLocX, Team1StartLocY, Team1StartLocZ, Team1StartLocO); - bg->SetTeamStartLoc(HORDE, Team2StartLocX, Team2StartLocY, Team2StartLocZ, Team2StartLocO); - bg->SetLevelRange(LevelMin, LevelMax); - bg->SetScriptId(scriptId); + bg->SetArenaorBGType(data.IsArena); + bg->SetMinPlayersPerTeam(data.MinPlayersPerTeam); + bg->SetMaxPlayersPerTeam(data.MaxPlayersPerTeam); + bg->SetMinPlayers(data.MinPlayersPerTeam * 2); + bg->SetMaxPlayers(data.MaxPlayersPerTeam * 2); + bg->SetName(data.BattlegroundName); + bg->SetTeamStartLoc(ALLIANCE, data.Team1StartLocX, data.Team1StartLocY, data.Team1StartLocZ, data.Team1StartLocO); + bg->SetTeamStartLoc(HORDE, data.Team2StartLocX, data.Team2StartLocY, data.Team2StartLocZ, data.Team2StartLocO); + bg->SetLevelRange(data.LevelMin, data.LevelMax); + bg->SetScriptId(data.scriptId); // add bg to update list AddBattleground(bg->GetInstanceID(), bg->GetTypeID(), bg); // return some not-null value, bgTypeId is good enough for me - return bgTypeId; + return data.bgTypeId; } void BattlegroundMgr::CreateInitialBattlegrounds() { uint32 oldMSTime = getMSTime(); - float AStartLoc[4]; - float HStartLoc[4]; - uint32 MaxPlayersPerTeam, MinPlayersPerTeam, MinLvl, MaxLvl, start1, start2; uint8 selectionWeight; BattlemasterListEntry const *bl; - WorldSafeLocsEntry const *start; - bool IsArena; - uint32 scriptId = 0; - // 0 1 2 3 4 5 6 7 8 9 10 + // 0 1 2 3 4 5 6 7 8 9 10 QueryResult result = WorldDatabase.Query("SELECT id, MinPlayersPerTeam, MaxPlayersPerTeam, MinLvl, MaxLvl, AllianceStartLoc, AllianceStartO, HordeStartLoc, HordeStartO, Weight, ScriptName FROM battleground_template"); if (!result) @@ -693,7 +684,7 @@ void BattlegroundMgr::CreateInitialBattlegrounds() return; } - uint32 count = 0; + uint32 count = 0, startId; do { @@ -711,85 +702,83 @@ void BattlegroundMgr::CreateInitialBattlegrounds() continue; } - BattlegroundTypeId bgTypeID = BattlegroundTypeId(bgTypeID_); - - IsArena = (bl->type == TYPE_ARENA); - MinPlayersPerTeam = fields[1].GetUInt32(); - MaxPlayersPerTeam = fields[2].GetUInt32(); - MinLvl = fields[3].GetUInt32(); - MaxLvl = fields[4].GetUInt32(); + CreateBattlegroundData data; + data.bgTypeId = BattlegroundTypeId(bgTypeID_); + data.IsArena = (bl->type == TYPE_ARENA); + data.MinPlayersPerTeam = fields[1].GetUInt32(); + data.MaxPlayersPerTeam = fields[2].GetUInt32(); + data.LevelMin = fields[3].GetUInt32(); + data.LevelMax = fields[4].GetUInt32(); //check values from DB - if (MaxPlayersPerTeam == 0 || MinPlayersPerTeam == 0 || MinPlayersPerTeam > MaxPlayersPerTeam) + if (data.MaxPlayersPerTeam == 0 || data.MinPlayersPerTeam == 0 || data.MinPlayersPerTeam > data.MaxPlayersPerTeam) { - MinPlayersPerTeam = 0; // by default now expected strong full bg requirement - MaxPlayersPerTeam = 40; + data.MinPlayersPerTeam = 0; // by default now expected strong full bg requirement + data.MaxPlayersPerTeam = 40; } - if (MinLvl == 0 || MaxLvl == 0 || MinLvl > MaxLvl) + if (data.LevelMin == 0 || data.LevelMax == 0 || data.LevelMin > data.LevelMax) { //TO-DO: FIX ME - MinLvl = 0;//bl->minlvl; - MaxLvl = 80;//bl->maxlvl; + data.LevelMin = 0;//bl->minlvl; + data.LevelMax = 80;//bl->maxlvl; } - start1 = fields[5].GetUInt32(); - - start = sWorldSafeLocsStore.LookupEntry(start1); - if (start) + startId = fields[5].GetUInt32(); + if (WorldSafeLocsEntry const* start = sWorldSafeLocsStore.LookupEntry(startId)) { - AStartLoc[0] = start->x; - AStartLoc[1] = start->y; - AStartLoc[2] = start->z; - AStartLoc[3] = fields[6].GetFloat(); + data.Team1StartLocX = start->x; + data.Team1StartLocY = start->y; + data.Team1StartLocZ = start->z; + data.Team1StartLocO = fields[6].GetFloat(); } - else if (bgTypeID == BATTLEGROUND_AA || bgTypeID == BATTLEGROUND_RB) + else if (data.bgTypeId == BATTLEGROUND_AA || data.bgTypeId == BATTLEGROUND_RB) { - AStartLoc[0] = 0; - AStartLoc[1] = 0; - AStartLoc[2] = 0; - AStartLoc[3] = fields[6].GetFloat(); + data.Team1StartLocX = 0; + data.Team1StartLocY = 0; + data.Team1StartLocZ = 0; + data.Team1StartLocO = fields[6].GetFloat(); } else { - sLog->outErrorDb("Table `battleground_template` for id %u have non-existed WorldSafeLocs.dbc id %u in field `AllianceStartLoc`. BG not created.", bgTypeID, start1); + sLog->outErrorDb("Table `battleground_template` for id %u have non-existed WorldSafeLocs.dbc id %u in field `AllianceStartLoc`. BG not created.", data.bgTypeId, startId); continue; } - start2 = fields[7].GetUInt32(); - - start = sWorldSafeLocsStore.LookupEntry(start2); - if (start) + startId = fields[7].GetUInt32(); + if (WorldSafeLocsEntry const* start = sWorldSafeLocsStore.LookupEntry(startId)) { - HStartLoc[0] = start->x; - HStartLoc[1] = start->y; - HStartLoc[2] = start->z; - HStartLoc[3] = fields[8].GetFloat(); + data.Team2StartLocX = start->x; + data.Team2StartLocY = start->y; + data.Team2StartLocZ = start->z; + data.Team2StartLocO = fields[8].GetFloat(); } - else if (bgTypeID == BATTLEGROUND_AA || bgTypeID == BATTLEGROUND_RB) + else if (data.bgTypeId == BATTLEGROUND_AA || data.bgTypeId == BATTLEGROUND_RB) { - HStartLoc[0] = 0; - HStartLoc[1] = 0; - HStartLoc[2] = 0; - HStartLoc[3] = fields[8].GetFloat(); + data.Team2StartLocX = 0; + data.Team2StartLocY = 0; + data.Team2StartLocZ = 0; + data.Team2StartLocO = fields[8].GetFloat(); } else { - sLog->outErrorDb("Table `battleground_template` for id %u have non-existed WorldSafeLocs.dbc id %u in field `HordeStartLoc`. BG not created.", bgTypeID, start2); + sLog->outErrorDb("Table `battleground_template` for id %u have non-existed WorldSafeLocs.dbc id %u in field `HordeStartLoc`. BG not created.", data.bgTypeId, startId); continue; } selectionWeight = fields[9].GetUInt8(); - scriptId = sObjectMgr->GetScriptId(fields[10].GetCString()); - //sLog->outDetail("Creating battleground %s, %u-%u", bl->name[sWorld->GetDBClang()], MinLvl, MaxLvl); - if (!CreateBattleground(bgTypeID, IsArena, MinPlayersPerTeam, MaxPlayersPerTeam, MinLvl, MaxLvl, bl->name[sWorld->GetDefaultDbcLocale()], bl->mapid[0], AStartLoc[0], AStartLoc[1], AStartLoc[2], AStartLoc[3], HStartLoc[0], HStartLoc[1], HStartLoc[2], HStartLoc[3], scriptId)) + data.scriptId = sObjectMgr->GetScriptId(fields[10].GetCString()); + data.BattlegroundName = bl->name[sWorld->GetDefaultDbcLocale()]; + data.MapID = bl->mapid[0]; + + if (!CreateBattleground(data)) continue; - if (IsArena) + if (data.IsArena) { - if (bgTypeID != BATTLEGROUND_AA) - m_ArenaSelectionWeights[bgTypeID] = selectionWeight; + if (data.bgTypeId != BATTLEGROUND_AA) + m_ArenaSelectionWeights[data.bgTypeId] = selectionWeight; } - else if (bgTypeID != BATTLEGROUND_RB) - m_BGSelectionWeights[bgTypeID] = selectionWeight; + else if (data.bgTypeId != BATTLEGROUND_RB) + m_BGSelectionWeights[data.bgTypeId] = selectionWeight; ++count; } while (result->NextRow()); @@ -816,7 +805,7 @@ void BattlegroundMgr::InitAutomaticArenaPointDistribution() sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Automatic Arena Point Distribution initialized."); } -void BattlegroundMgr::BuildBattlegroundListPacket(WorldPacket *data, const uint64 guid, Player* plr, BattlegroundTypeId bgTypeId, uint8 fromWhere) +void BattlegroundMgr::BuildBattlegroundListPacket(WorldPacket *data, uint64 guid, Player* plr, BattlegroundTypeId bgTypeId, uint8 fromWhere) { if (!plr) return; @@ -901,7 +890,7 @@ void BattlegroundMgr::SendToBattleground(Player *pl, uint32 instanceId, Battlegr } } -void BattlegroundMgr::SendAreaSpiritHealerQueryOpcode(Player *pl, Battleground *bg, const uint64 guid) +void BattlegroundMgr::SendAreaSpiritHealerQueryOpcode(Player *pl, Battleground *bg, uint64 guid) { WorldPacket data(SMSG_AREA_SPIRIT_HEALER_TIME, 12); uint32 time_ = 30000 - bg->GetLastResurrectTime(); // resurrect every 30 seconds diff --git a/src/server/game/Battlegrounds/BattlegroundMgr.h b/src/server/game/Battlegrounds/BattlegroundMgr.h index 56aba19dbbe..0b0c0ceb2a6 100755 --- a/src/server/game/Battlegrounds/BattlegroundMgr.h +++ b/src/server/game/Battlegrounds/BattlegroundMgr.h @@ -32,27 +32,48 @@ typedef UNORDERED_MAP<uint32, BattlegroundTypeId> BattleMastersMap; #define BATTLEGROUND_ARENA_POINT_DISTRIBUTION_DAY 86400 // seconds in a day #define WS_ARENA_DISTRIBUTION_TIME 20001 // Custom worldstate +struct CreateBattlegroundData +{ + BattlegroundTypeId bgTypeId; + bool IsArena; + uint32 MinPlayersPerTeam; + uint32 MaxPlayersPerTeam; + uint32 LevelMin; + uint32 LevelMax; + char* BattlegroundName; + uint32 MapID; + float Team1StartLocX; + float Team1StartLocY; + float Team1StartLocZ; + float Team1StartLocO; + float Team2StartLocX; + float Team2StartLocY; + float Team2StartLocZ; + float Team2StartLocO; + uint32 scriptId; +}; + class BattlegroundMgr { - /// Todo: Thread safety? - /* Construction */ friend class ACE_Singleton<BattlegroundMgr, ACE_Null_Mutex>; - BattlegroundMgr(); - public: + private: + BattlegroundMgr(); ~BattlegroundMgr(); + + public: void Update(uint32 diff); /* Packet Building */ void BuildPlayerJoinedBattlegroundPacket(WorldPacket *data, Player *plr); - void BuildPlayerLeftBattlegroundPacket(WorldPacket *data, const uint64 guid); - void BuildBattlegroundListPacket(WorldPacket *data, const uint64 guid, Player *plr, BattlegroundTypeId bgTypeId, uint8 fromWhere); + void BuildPlayerLeftBattlegroundPacket(WorldPacket *data, uint64 guid); + void BuildBattlegroundListPacket(WorldPacket *data, uint64 guid, Player *plr, BattlegroundTypeId bgTypeId, uint8 fromWhere); void BuildGroupJoinedBattlegroundPacket(WorldPacket *data, GroupJoinBattlegroundResult result); void BuildUpdateWorldStatePacket(WorldPacket *data, uint32 field, uint32 value); void BuildPvpLogDataPacket(WorldPacket *data, Battleground *bg); void BuildBattlegroundStatusPacket(WorldPacket *data, Battleground *bg, uint8 QueueSlot, uint8 StatusID, uint32 Time1, uint32 Time2, uint8 arenatype, uint8 uiFrame = 1); void BuildPlaySoundPacket(WorldPacket *data, uint32 soundid); - void SendAreaSpiritHealerQueryOpcode(Player *pl, Battleground *bg, const uint64 guid); + void SendAreaSpiritHealerQueryOpcode(Player *pl, Battleground *bg, uint64 guid); /* Battlegrounds */ Battleground* GetBattlegroundThroughClientInstance(uint32 instanceId, BattlegroundTypeId bgTypeId); @@ -61,7 +82,7 @@ class BattlegroundMgr Battleground* GetBattlegroundTemplate(BattlegroundTypeId bgTypeId); Battleground* CreateNewBattleground(BattlegroundTypeId bgTypeId, PvPDifficultyEntry const* bracketEntry, uint8 arenaType, bool isRated); - uint32 CreateBattleground(BattlegroundTypeId bgTypeId, bool IsArena, uint32 MinPlayersPerTeam, uint32 MaxPlayersPerTeam, uint32 LevelMin, uint32 LevelMax, char* BattlegroundName, uint32 MapID, float Team1StartLocX, float Team1StartLocY, float Team1StartLocZ, float Team1StartLocO, float Team2StartLocX, float Team2StartLocY, float Team2StartLocZ, float Team2StartLocO, uint32 scriptId); + uint32 CreateBattleground(CreateBattlegroundData& data); void AddBattleground(uint32 InstanceID, BattlegroundTypeId bgTypeId, Battleground* BG) { m_Battlegrounds[bgTypeId][InstanceID] = BG; }; void RemoveBattleground(uint32 instanceID, BattlegroundTypeId bgTypeId) { m_Battlegrounds[bgTypeId].erase(instanceID); } diff --git a/src/server/game/Battlegrounds/BattlegroundQueue.cpp b/src/server/game/Battlegrounds/BattlegroundQueue.cpp index a021a28ee0d..2dbe799150c 100755 --- a/src/server/game/Battlegrounds/BattlegroundQueue.cpp +++ b/src/server/game/Battlegrounds/BattlegroundQueue.cpp @@ -281,7 +281,7 @@ uint32 BattlegroundQueue::GetAverageQueueWaitTime(GroupQueueInfo* ginfo, Battleg } //remove player from queue and from group info, if group info is empty then remove it too -void BattlegroundQueue::RemovePlayer(const uint64 guid, bool decreaseInvitedCount) +void BattlegroundQueue::RemovePlayer(uint64 guid, bool decreaseInvitedCount) { //Player *plr = ObjectAccessor::FindPlayer(guid); @@ -322,6 +322,7 @@ void BattlegroundQueue::RemovePlayer(const uint64 guid, bool decreaseInvitedCoun } } } + //player can't be in queue without group, but just in case if (bracket_id == -1) { @@ -342,32 +343,24 @@ void BattlegroundQueue::RemovePlayer(const uint64 guid, bool decreaseInvitedCoun // if invited to bg, and should decrease invited count, then do it if (decreaseInvitedCount && group->IsInvitedToBGInstanceGUID) - { - Battleground* bg = sBattlegroundMgr->GetBattleground(group->IsInvitedToBGInstanceGUID, group->BgTypeId == BATTLEGROUND_AA ? BATTLEGROUND_TYPE_NONE : group->BgTypeId); - if (bg) + if (Battleground* bg = sBattlegroundMgr->GetBattleground(group->IsInvitedToBGInstanceGUID, group->BgTypeId == BATTLEGROUND_AA ? BATTLEGROUND_TYPE_NONE : group->BgTypeId)) bg->DecreaseInvitedCount(group->Team); - } // remove player queue info m_QueuedPlayers.erase(itr); // announce to world if arena team left queue for rated match, show only once if (group->ArenaType && group->IsRated && group->Players.empty() && sWorld->getBoolConfig(CONFIG_ARENA_QUEUE_ANNOUNCER_ENABLE)) - { - ArenaTeam *Team = sArenaTeamMgr->GetArenaTeamById(group->ArenaTeamId); - if (Team) + if (ArenaTeam *Team = sArenaTeamMgr->GetArenaTeamById(group->ArenaTeamId)) sWorld->SendWorldText(LANG_ARENA_QUEUE_ANNOUNCE_WORLD_EXIT, Team->GetName().c_str(), group->ArenaType, group->ArenaType, group->ArenaTeamRating); - } - //if player leaves queue and he is invited to rated arena match, then he have to lose + // if player leaves queue and he is invited to rated arena match, then he have to lose if (group->IsInvitedToBGInstanceGUID && group->IsRated && decreaseInvitedCount) { - ArenaTeam * at = sArenaTeamMgr->GetArenaTeamById(group->ArenaTeamId); - if (at) + if (ArenaTeam * at = sArenaTeamMgr->GetArenaTeamById(group->ArenaTeamId)) { sLog->outDebug(LOG_FILTER_BATTLEGROUND, "UPDATING memberLost's personal arena rating for %u by opponents rating: %u", GUID_LOPART(guid), group->OpponentsTeamRating); - Player *plr = ObjectAccessor::FindPlayer(guid); - if (plr) + if (Player *plr = ObjectAccessor::FindPlayer(guid)) at->MemberLost(plr, group->OpponentsMatchmakerRating); else at->OfflineMemberLost(guid, group->OpponentsMatchmakerRating); @@ -405,7 +398,7 @@ void BattlegroundQueue::RemovePlayer(const uint64 guid, bool decreaseInvitedCoun } //returns true when player pl_guid is in queue and is invited to bgInstanceGuid -bool BattlegroundQueue::IsPlayerInvited(const uint64 pl_guid, const uint32 bgInstanceGuid, const uint32 removeTime) +bool BattlegroundQueue::IsPlayerInvited(uint64 pl_guid, const uint32 bgInstanceGuid, const uint32 removeTime) { QueuedPlayersMap::const_iterator qItr = m_QueuedPlayers.find(pl_guid); return (qItr != m_QueuedPlayers.end() @@ -413,7 +406,7 @@ bool BattlegroundQueue::IsPlayerInvited(const uint64 pl_guid, const uint32 bgIns && qItr->second.GroupInfo->RemoveInviteTime == removeTime); } -bool BattlegroundQueue::GetPlayerGroupInfoData(const uint64 guid, GroupQueueInfo* ginfo) +bool BattlegroundQueue::GetPlayerGroupInfoData(uint64 guid, GroupQueueInfo* ginfo) { QueuedPlayersMap::const_iterator qItr = m_QueuedPlayers.find(guid); if (qItr == m_QueuedPlayers.end()) @@ -918,7 +911,6 @@ void BattlegroundQueue::Update(BattlegroundTypeId bgTypeId, BattlegroundBracketI GroupsQueueType::iterator itr_team[BG_TEAMS_COUNT]; //optimalization : --- we dont need to use selection_pools - each update we select max 2 groups - for (uint32 i = BG_QUEUE_PREMADE_ALLIANCE; i < BG_QUEUE_NORMAL_ALLIANCE; i++) { // take the group that joined first @@ -936,6 +928,7 @@ void BattlegroundQueue::Update(BattlegroundTypeId bgTypeId, BattlegroundBracketI } } } + // now we are done if we have 2 groups - ali vs horde! // if we don't have, we must try to continue search in same queue // tmp variables are correctly set @@ -955,6 +948,7 @@ void BattlegroundQueue::Update(BattlegroundTypeId bgTypeId, BattlegroundBracketI } } } + // this code isn't much userfriendly - but it is supposed to continue search for mathing group in ALLIANCE queue if (m_SelectionPools[BG_TEAM_HORDE].GetPlayerCount() == 0 && m_SelectionPools[BG_TEAM_ALLIANCE].GetPlayerCount()) { diff --git a/src/server/game/Battlegrounds/BattlegroundQueue.h b/src/server/game/Battlegrounds/BattlegroundQueue.h index 61b7deceae8..c2579b7623a 100755 --- a/src/server/game/Battlegrounds/BattlegroundQueue.h +++ b/src/server/game/Battlegrounds/BattlegroundQueue.h @@ -76,9 +76,9 @@ class BattlegroundQueue bool CheckNormalMatch(Battleground* bg_template, BattlegroundBracketId bracket_id, uint32 minPlayers, uint32 maxPlayers); bool CheckSkirmishForSameFaction(BattlegroundBracketId bracket_id, uint32 minPlayersPerTeam); GroupQueueInfo * AddGroup(Player* leader, Group* group, BattlegroundTypeId bgTypeId, PvPDifficultyEntry const* bracketEntry, uint8 ArenaType, bool isRated, bool isPremade, uint32 ArenaRating, uint32 MatchmakerRating, uint32 ArenaTeamId = 0); - void RemovePlayer(const uint64 guid, bool decreaseInvitedCount); - bool IsPlayerInvited(const uint64 pl_guid, const uint32 bgInstanceGuid, const uint32 removeTime); - bool GetPlayerGroupInfoData(const uint64 guid, GroupQueueInfo* ginfo); + void RemovePlayer(uint64 guid, bool decreaseInvitedCount); + bool IsPlayerInvited(uint64 pl_guid, const uint32 bgInstanceGuid, const uint32 removeTime); + bool GetPlayerGroupInfoData(uint64 guid, GroupQueueInfo* ginfo); void PlayerInvitedToBGUpdateAverageWaitTime(GroupQueueInfo* ginfo, BattlegroundBracketId bracket_id); uint32 GetAverageQueueWaitTime(GroupQueueInfo* ginfo, BattlegroundBracketId bracket_id) const; @@ -131,7 +131,7 @@ class BattlegroundQueue class BGQueueInviteEvent : public BasicEvent { public: - BGQueueInviteEvent(const uint64 pl_guid, uint32 BgInstanceGUID, BattlegroundTypeId BgTypeId, uint8 arenaType, uint32 removeTime) : + BGQueueInviteEvent(uint64 pl_guid, uint32 BgInstanceGUID, BattlegroundTypeId BgTypeId, uint8 arenaType, uint32 removeTime) : m_PlayerGuid(pl_guid), m_BgInstanceGUID(BgInstanceGUID), m_BgTypeId(BgTypeId), m_ArenaType(arenaType), m_RemoveTime(removeTime) { }; @@ -155,7 +155,7 @@ class BGQueueInviteEvent : public BasicEvent class BGQueueRemoveEvent : public BasicEvent { public: - BGQueueRemoveEvent(const uint64 pl_guid, uint32 bgInstanceGUID, BattlegroundTypeId BgTypeId, BattlegroundQueueTypeId bgQueueTypeId, uint32 removeTime) + BGQueueRemoveEvent(uint64 pl_guid, uint32 bgInstanceGUID, BattlegroundTypeId BgTypeId, BattlegroundQueueTypeId bgQueueTypeId, uint32 removeTime) : m_PlayerGuid(pl_guid), m_BgInstanceGUID(bgInstanceGUID), m_RemoveTime(removeTime), m_BgTypeId(BgTypeId), m_BgQueueTypeId(bgQueueTypeId) {} diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundAA.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundAA.cpp index 62a23e5d5ae..809c214b790 100755 --- a/src/server/game/Battlegrounds/Zones/BattlegroundAA.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundAA.cpp @@ -23,7 +23,6 @@ BattlegroundAA::BattlegroundAA() { - m_StartDelayTimes[BG_STARTING_EVENT_FIRST] = BG_START_DELAY_1M; m_StartDelayTimes[BG_STARTING_EVENT_SECOND] = BG_START_DELAY_30S; m_StartDelayTimes[BG_STARTING_EVENT_THIRD] = BG_START_DELAY_15S; @@ -40,11 +39,6 @@ BattlegroundAA::~BattlegroundAA() } -void BattlegroundAA::Update(uint32 diff) -{ - Battleground::Update(diff); -} - void BattlegroundAA::StartingEventCloseDoors() { } diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundAA.h b/src/server/game/Battlegrounds/Zones/BattlegroundAA.h index 1ded667ddb9..c94d54916e0 100755 --- a/src/server/game/Battlegrounds/Zones/BattlegroundAA.h +++ b/src/server/game/Battlegrounds/Zones/BattlegroundAA.h @@ -30,12 +30,9 @@ class BattlegroundAAScore : public BattlegroundScore class BattlegroundAA : public Battleground { - friend class BattlegroundMgr; - public: BattlegroundAA(); ~BattlegroundAA(); - void Update(uint32 diff); /* inherited from BattlegroundClass */ virtual void AddPlayer(Player *plr); diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundAB.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundAB.cpp index a22ee93853e..8bc64a0f7d8 100755 --- a/src/server/game/Battlegrounds/Zones/BattlegroundAB.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundAB.cpp @@ -55,10 +55,8 @@ BattlegroundAB::~BattlegroundAB() { } -void BattlegroundAB::Update(uint32 diff) +void BattlegroundAB::PostUpdateImpl(uint32 diff) { - Battleground::Update(diff); - if (GetStatus() == STATUS_IN_PROGRESS) { int team_points[BG_TEAMS_COUNT] = { 0, 0 }; @@ -225,7 +223,7 @@ void BattlegroundAB::HandleAreaTrigger(Player *Source, uint32 Trigger) if (GetStatus() != STATUS_IN_PROGRESS) return; - switch(Trigger) + switch (Trigger) { case 3948: // Arathi Basin Alliance Exit. if (Source->GetTeam() != ALLIANCE) @@ -436,11 +434,11 @@ void BattlegroundAB::EventPlayerClickedOnFlag(Player *source, GameObject* /*targ return; uint8 node = BG_AB_NODE_STABLES; - GameObject* obj=GetBgMap()->GetGameObject(m_BgObjects[node*8+7]); + GameObject* obj = GetBgMap()->GetGameObject(m_BgObjects[node*8+7]); while ((node < BG_AB_DYNAMIC_NODES_COUNT) && ((!obj) || (!source->IsWithinDistInMap(obj, 10)))) { ++node; - obj=GetBgMap()->GetGameObject(m_BgObjects[node*8+BG_AB_OBJECT_AURA_CONTESTED]); + obj = GetBgMap()->GetGameObject(m_BgObjects[node*8+BG_AB_OBJECT_AURA_CONTESTED]); } if (node == BG_AB_DYNAMIC_NODES_COUNT) @@ -687,7 +685,7 @@ void BattlegroundAB::UpdatePlayerScore(Player *Source, uint32 type, uint32 value if (itr == m_PlayerScores.end()) // player not found... return; - switch(type) + switch (type) { case SCORE_BASES_ASSAULTED: ((BattlegroundABScore*)itr->second)->BasesAssaulted += value; diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundAB.h b/src/server/game/Battlegrounds/Zones/BattlegroundAB.h index f0371040992..84398389c10 100755 --- a/src/server/game/Battlegrounds/Zones/BattlegroundAB.h +++ b/src/server/game/Battlegrounds/Zones/BattlegroundAB.h @@ -241,13 +241,10 @@ class BattlegroundABScore : public BattlegroundScore class BattlegroundAB : public Battleground { - friend class BattlegroundMgr; - public: BattlegroundAB(); ~BattlegroundAB(); - void Update(uint32 diff); void AddPlayer(Player *plr); virtual void StartingEventCloseDoors(); virtual void StartingEventOpenDoors(); @@ -270,6 +267,7 @@ class BattlegroundAB : public Battleground bool IsAllNodesConrolledByTeam(uint32 team) const; // overwrited bool IsTeamScores500Disadvantage(uint32 team) const { return m_TeamScores500Disadvantage[GetTeamIndexByTeamId(team)]; } private: + virtual void PostUpdateImpl(uint32 diff); /* Gameobject spawning/despawning */ void _CreateBanner(uint8 node, uint8 type, uint8 teamIndex, bool delay); void _DelBanner(uint8 node, uint8 type, uint8 teamIndex); diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp index 27ba0e32485..b01385e6536 100755 --- a/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp @@ -140,7 +140,7 @@ void BattlegroundAV::HandleQuestComplete(uint32 questid, Player* player) uint8 team = GetTeamIndexByTeamId(player->GetTeam()); //TODO add reputation, events (including quest not available anymore, next quest availabe, go/npc de/spawning)and maybe honor sLog->outDebug(LOG_FILTER_BATTLEGROUND, "BG_AV Quest %i completed", questid); - switch(questid) + switch (questid) { case AV_QUEST_A_SCRAPS1: case AV_QUEST_A_SCRAPS2: @@ -339,10 +339,8 @@ Creature* BattlegroundAV::AddAVCreature(uint16 cinfoid, uint16 type) return creature; } -void BattlegroundAV::Update(uint32 diff) +void BattlegroundAV::PostUpdateImpl(uint32 diff) { - Battleground::Update(diff); - if (GetStatus() == STATUS_IN_PROGRESS) { for (uint8 i=0; i <= 1; i++)//0=alliance, 1=horde @@ -495,7 +493,7 @@ void BattlegroundAV::HandleAreaTrigger(Player *Source, uint32 Trigger) return; uint32 SpellId = 0; - switch(Trigger) + switch (Trigger) { case 95: case 2608: @@ -535,7 +533,7 @@ void BattlegroundAV::UpdatePlayerScore(Player* Source, uint32 type, uint32 value if (itr == m_PlayerScores.end()) // player not found... return; - switch(type) + switch (type) { case SCORE_GRAVEYARDS_ASSAULTED: ((BattlegroundAVScore*)itr->second)->GraveyardsAssaulted += value; @@ -863,7 +861,7 @@ void BattlegroundAV::EventPlayerClickedOnFlag(Player *source, GameObject* target sLog->outDebug(LOG_FILTER_BATTLEGROUND, "BG_AV using gameobject %i with type %i", target_obj->GetEntry(), object); if (object < 0) return; - switch(target_obj->GetEntry()) + switch (target_obj->GetEntry()) { case BG_AV_OBJECTID_BANNER_A: case BG_AV_OBJECTID_BANNER_A_B: @@ -969,7 +967,9 @@ void BattlegroundAV::EventPlayerAssaultsPoint(Player* player, uint32 object) { if (object == BG_AV_OBJECT_FLAG_N_SNOWFALL_GRAVE) //initial capping { - ASSERT(owner == AV_NEUTRAL_TEAM && m_Nodes[node].TotalOwner == AV_NEUTRAL_TEAM); + if (!(owner == AV_NEUTRAL_TEAM && m_Nodes[node].TotalOwner == AV_NEUTRAL_TEAM)) + return; + if (team == ALLIANCE) SpawnBGObject(BG_AV_OBJECT_FLAG_C_A_SNOWFALL_GRAVE, RESPAWN_IMMEDIATELY); else @@ -978,7 +978,9 @@ void BattlegroundAV::EventPlayerAssaultsPoint(Player* player, uint32 object) } else if (m_Nodes[node].TotalOwner == AV_NEUTRAL_TEAM) //recapping, when no team owns this node realy { - ASSERT(m_Nodes[node].State != POINT_CONTROLED); + if (!(m_Nodes[node].State != POINT_CONTROLED)) + return; + if (team == ALLIANCE) SpawnBGObject(object-11, RESPAWN_IMMEDIATELY); else @@ -1346,7 +1348,7 @@ bool BattlegroundAV::SetupBattleground() //creatures sLog->outDebug(LOG_FILTER_BATTLEGROUND, "BG_AV start poputlating nodes"); - for (BG_AV_Nodes i= BG_AV_NODES_FIRSTAID_STATION; i < BG_AV_NODES_MAX; ++i) + for (BG_AV_Nodes i = BG_AV_NODES_FIRSTAID_STATION; i < BG_AV_NODES_MAX; ++i) { if (m_Nodes[i].Owner) PopulateNode(i); @@ -1489,4 +1491,3 @@ void BattlegroundAV::ResetBGSubclass() DelCreature(i); } - diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundAV.h b/src/server/game/Battlegrounds/Zones/BattlegroundAV.h index 653a08a46c8..5832a0f87c5 100755 --- a/src/server/game/Battlegrounds/Zones/BattlegroundAV.h +++ b/src/server/game/Battlegrounds/Zones/BattlegroundAV.h @@ -1534,12 +1534,9 @@ class BattlegroundAVScore : public BattlegroundScore class BattlegroundAV : public Battleground { - friend class BattlegroundMgr; - public: BattlegroundAV(); ~BattlegroundAV(); - void Update(uint32 diff); /* inherited from BattlegroundClass */ virtual void AddPlayer(Player *plr); @@ -1567,6 +1564,8 @@ class BattlegroundAV : public Battleground virtual WorldSafeLocsEntry const* GetClosestGraveYard(Player* player); private: + virtual void PostUpdateImpl(uint32 diff); + /* Nodes occupying */ void EventPlayerAssaultsPoint(Player* player, uint32 object); void EventPlayerDefendsPoint(Player* player, uint32 object); diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundBE.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundBE.cpp index 229d24304b5..e88103acb25 100755 --- a/src/server/game/Battlegrounds/Zones/BattlegroundBE.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundBE.cpp @@ -44,20 +44,6 @@ BattlegroundBE::~BattlegroundBE() } -void BattlegroundBE::Update(uint32 diff) -{ - Battleground::Update(diff); - - if (GetStatus() == STATUS_IN_PROGRESS) - { - if (GetStartTime() >= 47*MINUTE*IN_MILLISECONDS) // after 47 minutes without one team losing, the arena closes with no winner and no rating change - { - UpdateArenaWorldState(); - CheckArenaAfterTimerConditions(); - } - } -} - void BattlegroundBE::StartingEventCloseDoors() { for (uint32 i = BG_BE_OBJECT_DOOR_1; i <= BG_BE_OBJECT_DOOR_4; ++i) @@ -127,7 +113,7 @@ void BattlegroundBE::HandleAreaTrigger(Player *Source, uint32 Trigger) //uint32 SpellId = 0; //uint64 buff_guid = 0; - switch(Trigger) + switch (Trigger) { case 4538: // buff trigger? //buff_guid = m_BgObjects[BG_BE_OBJECT_BUFF_1]; diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundBE.h b/src/server/game/Battlegrounds/Zones/BattlegroundBE.h index c4d01b9027b..65475997b90 100755 --- a/src/server/game/Battlegrounds/Zones/BattlegroundBE.h +++ b/src/server/game/Battlegrounds/Zones/BattlegroundBE.h @@ -50,12 +50,9 @@ class BattlegroundBEScore : public BattlegroundScore class BattlegroundBE : public Battleground { - friend class BattlegroundMgr; - public: BattlegroundBE(); ~BattlegroundBE(); - void Update(uint32 diff); /* inherited from BattlegroundClass */ virtual void AddPlayer(Player *plr); diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundDS.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundDS.cpp index e29db014a68..3c1e3612d1a 100755 --- a/src/server/game/Battlegrounds/Zones/BattlegroundDS.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundDS.cpp @@ -44,19 +44,8 @@ BattlegroundDS::~BattlegroundDS() } -void BattlegroundDS::Update(uint32 diff) +void BattlegroundDS::PostUpdateImpl(uint32 diff) { - Battleground::Update(diff); - - if (GetStatus() == STATUS_IN_PROGRESS) - { - if (GetStartTime() >= 47*MINUTE*IN_MILLISECONDS) // after 47 minutes without one team losing, the arena closes with no winner and no rating change - { - UpdateArenaWorldState(); - CheckArenaAfterTimerConditions(); - } - } - if (getWaterFallTimer() < diff) { if (isWaterFallActive()) @@ -141,7 +130,7 @@ void BattlegroundDS::HandleAreaTrigger(Player *Source, uint32 Trigger) if (GetStatus() != STATUS_IN_PROGRESS) return; - switch(Trigger) + switch (Trigger) { case 5347: case 5348: diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundDS.h b/src/server/game/Battlegrounds/Zones/BattlegroundDS.h index bc457c7a961..02da03d6450 100755 --- a/src/server/game/Battlegrounds/Zones/BattlegroundDS.h +++ b/src/server/game/Battlegrounds/Zones/BattlegroundDS.h @@ -59,12 +59,9 @@ class BattlegroundDSScore : public BattlegroundScore class BattlegroundDS : public Battleground { - friend class BattlegroundMgr; - public: BattlegroundDS(); ~BattlegroundDS(); - void Update(uint32 diff); /* inherited from BattlegroundClass */ virtual void AddPlayer(Player *plr); @@ -81,6 +78,8 @@ class BattlegroundDS : public Battleground private: uint32 m_waterTimer; bool m_waterfallActive; + + virtual void PostUpdateImpl(uint32 diff); protected: bool isWaterFallActive() { return m_waterfallActive; }; void setWaterFallActive(bool active) { m_waterfallActive = active; }; diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundEY.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundEY.cpp index c125b8f2232..77d2c72da32 100755 --- a/src/server/game/Battlegrounds/Zones/BattlegroundEY.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundEY.cpp @@ -54,10 +54,8 @@ BattlegroundEY::~BattlegroundEY() { } -void BattlegroundEY::Update(uint32 diff) +void BattlegroundEY::PostUpdateImpl(uint32 diff) { - Battleground::Update(diff); - if (GetStatus() == STATUS_IN_PROGRESS) { m_PointAddingTimer -= diff; @@ -375,7 +373,7 @@ void BattlegroundEY::HandleAreaTrigger(Player *Source, uint32 Trigger) if (!Source->isAlive()) //hack code, must be removed later return; - switch(Trigger) + switch (Trigger) { case TR_BLOOD_ELF_POINT: if (m_PointState[BLOOD_ELF] == EY_POINT_UNDER_CONTROL && m_PointOwnedByTeam[BLOOD_ELF] == Source->GetTeam()) @@ -811,7 +809,7 @@ void BattlegroundEY::UpdatePlayerScore(Player *Source, uint32 type, uint32 value if (itr == m_PlayerScores.end()) // player not found return; - switch(type) + switch (type) { case SCORE_FLAG_CAPTURES: // flags captured ((BattlegroundEYScore*)itr->second)->FlagCaptures += value; @@ -877,7 +875,7 @@ WorldSafeLocsEntry const *BattlegroundEY::GetClosestGraveYard(Player* player) { uint32 g_id = 0; - switch(player->GetTeam()) + switch (player->GetTeam()) { case ALLIANCE: g_id = EY_GRAVEYARD_MAIN_ALLIANCE; break; case HORDE: g_id = EY_GRAVEYARD_MAIN_HORDE; break; diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundEY.h b/src/server/game/Battlegrounds/Zones/BattlegroundEY.h index 33d7ccdadb5..1418effd6e9 100755 --- a/src/server/game/Battlegrounds/Zones/BattlegroundEY.h +++ b/src/server/game/Battlegrounds/Zones/BattlegroundEY.h @@ -23,8 +23,11 @@ class Battleground; -#define BG_EY_FLAG_RESPAWN_TIME (8*IN_MILLISECONDS) //8 seconds -#define BG_EY_FPOINTS_TICK_TIME (2*IN_MILLISECONDS) //2 seconds +enum BG_EY_Misc +{ + BG_EY_FLAG_RESPAWN_TIME = (8*IN_MILLISECONDS), + BG_EY_FPOINTS_TICK_TIME = (2*IN_MILLISECONDS), +}; enum BG_EY_WorldStates { @@ -328,12 +331,9 @@ class BattlegroundEYScore : public BattlegroundScore class BattlegroundEY : public Battleground { - friend class BattlegroundMgr; - public: BattlegroundEY(); ~BattlegroundEY(); - void Update(uint32 diff); /* inherited from BattlegroundClass */ virtual void AddPlayer(Player *plr); @@ -349,7 +349,7 @@ class BattlegroundEY : public Battleground void RespawnFlagAfterDrop(); void RemovePlayer(Player *plr, uint64 guid, uint32 team); - void HandleBuffUse(uint64 const buff_guid); + void HandleBuffUse(uint64 buff_guid); void HandleAreaTrigger(Player *Source, uint32 Trigger); void HandleKillPlayer(Player* player, Player* killer); virtual WorldSafeLocsEntry const* GetClosestGraveYard(Player* player); @@ -369,8 +369,9 @@ class BattlegroundEY : public Battleground /* achievement req. */ bool IsAllNodesConrolledByTeam(uint32 team) const; private: + virtual void PostUpdateImpl(uint32 diff); + void EventPlayerCapturedFlag(Player *Source, uint32 BgObjectType); - void EventPlayerCapturedFlag(Player* /*Source*/) {} void EventTeamCapturedPoint(Player *Source, uint32 Point); void EventTeamLostPoint(Player *Source, uint32 Point); void UpdatePointsCount(uint32 Team); diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundIC.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundIC.cpp index 622a193cc21..9df7cce05d8 100755 --- a/src/server/game/Battlegrounds/Zones/BattlegroundIC.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundIC.cpp @@ -85,7 +85,7 @@ void BattlegroundIC::SendTransportInit(Player* player) player->GetSession()->SendPacket(&packet); } -void BattlegroundIC::DoAction(uint32 action, uint64 const var) +void BattlegroundIC::DoAction(uint32 action, uint64 var) { if (action != ACTION_TELEPORT_PLAYER_TO_TRANSPORT) return; @@ -108,9 +108,8 @@ void BattlegroundIC::DoAction(uint32 action, uint64 const var) plr->TeleportTo(GetMapId(), TeleportToTransportPosition.GetPositionX(), TeleportToTransportPosition.GetPositionY(), TeleportToTransportPosition.GetPositionZ(), TeleportToTransportPosition.GetOrientation(), TELE_TO_NOT_LEAVE_TRANSPORT); } -void BattlegroundIC::Update(uint32 diff) +void BattlegroundIC::PostUpdateImpl(uint32 diff) { - Battleground::Update(diff); if (GetStatus() != STATUS_IN_PROGRESS) return; @@ -406,7 +405,7 @@ bool BattlegroundIC::SetupBattleground() } //Send transport init packet to all player in map - for (BattlegroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end();itr++) + for (BattlegroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr) { if (Player* player = ObjectAccessor::FindPlayer(itr->first)) SendTransportInit(player); diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundIC.h b/src/server/game/Battlegrounds/Zones/BattlegroundIC.h index 563d477c796..700e1d4f0a3 100755 --- a/src/server/game/Battlegrounds/Zones/BattlegroundIC.h +++ b/src/server/game/Battlegrounds/Zones/BattlegroundIC.h @@ -857,17 +857,15 @@ class BattlegroundICScore : public BattlegroundScore class BattlegroundIC : public Battleground { - friend class BattlegroundMgr; - public: BattlegroundIC(); ~BattlegroundIC(); - void Update(uint32 diff); /* inherited from BattlegroundClass */ virtual void AddPlayer(Player *plr); virtual void StartingEventCloseDoors(); virtual void StartingEventOpenDoors(); + virtual void PostUpdateImpl(uint32 diff); void RemovePlayer(Player *plr, uint64 guid, uint32 team); void HandleAreaTrigger(Player *Source, uint32 Trigger); @@ -888,7 +886,7 @@ class BattlegroundIC : public Battleground void FillInitialWorldStates(WorldPacket& data); - void DoAction(uint32 action, uint64 const var); + void DoAction(uint32 action, uint64 var); virtual void HandlePlayerResurrect(Player* player); diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundNA.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundNA.cpp index 1844f93ecdd..beb2e617c25 100755 --- a/src/server/game/Battlegrounds/Zones/BattlegroundNA.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundNA.cpp @@ -44,20 +44,6 @@ BattlegroundNA::~BattlegroundNA() } -void BattlegroundNA::Update(uint32 diff) -{ - Battleground::Update(diff); - - if (GetStatus() == STATUS_IN_PROGRESS) - { - if (GetStartTime() >= 47*MINUTE*IN_MILLISECONDS) // after 47 minutes without one team losing, the arena closes with no winner and no rating change - { - UpdateArenaWorldState(); - CheckArenaAfterTimerConditions(); - } - } -} - void BattlegroundNA::StartingEventCloseDoors() { for (uint32 i = BG_NA_OBJECT_DOOR_1; i <= BG_NA_OBJECT_DOOR_4; ++i) @@ -123,7 +109,7 @@ void BattlegroundNA::HandleAreaTrigger(Player *Source, uint32 Trigger) //uint32 SpellId = 0; //uint64 buff_guid = 0; - switch(Trigger) + switch (Trigger) { case 4536: // buff trigger? case 4537: // buff trigger? diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundNA.h b/src/server/game/Battlegrounds/Zones/BattlegroundNA.h index 1eeffc80e2b..8c217459110 100755 --- a/src/server/game/Battlegrounds/Zones/BattlegroundNA.h +++ b/src/server/game/Battlegrounds/Zones/BattlegroundNA.h @@ -51,12 +51,9 @@ class BattlegroundNAScore : public BattlegroundScore class BattlegroundNA : public Battleground { - friend class BattlegroundMgr; - public: BattlegroundNA(); ~BattlegroundNA(); - void Update(uint32 diff); /* inherited from BattlegroundClass */ virtual void AddPlayer(Player *plr); diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundRB.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundRB.cpp index 54bb64a1603..c8f3474a172 100755 --- a/src/server/game/Battlegrounds/Zones/BattlegroundRB.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundRB.cpp @@ -35,11 +35,6 @@ BattlegroundRB::~BattlegroundRB() } -void BattlegroundRB::Update(uint32 diff) -{ - Battleground::Update(diff); -} - void BattlegroundRB::StartingEventCloseDoors() { } diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundRB.h b/src/server/game/Battlegrounds/Zones/BattlegroundRB.h index 47c31bcd302..be32bd654ea 100755 --- a/src/server/game/Battlegrounds/Zones/BattlegroundRB.h +++ b/src/server/game/Battlegrounds/Zones/BattlegroundRB.h @@ -30,12 +30,9 @@ class BattlegroundRBScore : public BattlegroundScore class BattlegroundRB : public Battleground { - friend class BattlegroundMgr; - public: BattlegroundRB(); ~BattlegroundRB(); - void Update(uint32 diff); virtual void AddPlayer(Player *plr); virtual void StartingEventCloseDoors(); diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundRL.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundRL.cpp index 20005863de2..0c64b8ad8d8 100755 --- a/src/server/game/Battlegrounds/Zones/BattlegroundRL.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundRL.cpp @@ -44,20 +44,6 @@ BattlegroundRL::~BattlegroundRL() } -void BattlegroundRL::Update(uint32 diff) -{ - Battleground::Update(diff); - - if (GetStatus() == STATUS_IN_PROGRESS) - { - if (GetStartTime() >= 47*MINUTE*IN_MILLISECONDS) // after 47 minutes without one team losing, the arena closes with no winner and no rating change - { - UpdateArenaWorldState(); - CheckArenaAfterTimerConditions(); - } - } -} - void BattlegroundRL::StartingEventCloseDoors() { for (uint32 i = BG_RL_OBJECT_DOOR_1; i <= BG_RL_OBJECT_DOOR_2; ++i) @@ -124,7 +110,7 @@ void BattlegroundRL::HandleAreaTrigger(Player *Source, uint32 Trigger) //uint32 SpellId = 0; //uint64 buff_guid = 0; - switch(Trigger) + switch (Trigger) { case 4696: // buff trigger? case 4697: // buff trigger? diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundRL.h b/src/server/game/Battlegrounds/Zones/BattlegroundRL.h index 7977e2945f4..87fe34e65d6 100755 --- a/src/server/game/Battlegrounds/Zones/BattlegroundRL.h +++ b/src/server/game/Battlegrounds/Zones/BattlegroundRL.h @@ -47,12 +47,9 @@ class BattlegroundRLScore : public BattlegroundScore class BattlegroundRL : public Battleground { - friend class BattlegroundMgr; - public: BattlegroundRL(); ~BattlegroundRL(); - void Update(uint32 diff); /* inherited from BattlegroundClass */ virtual void AddPlayer(Player *plr); diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundRV.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundRV.cpp index f8518db6f5a..aa80be6f6cb 100755 --- a/src/server/game/Battlegrounds/Zones/BattlegroundRV.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundRV.cpp @@ -44,49 +44,37 @@ BattlegroundRV::~BattlegroundRV() } -void BattlegroundRV::Update(uint32 diff) +void BattlegroundRV::PostUpdateImpl(uint32 diff) { - Battleground::Update(diff); - - if (GetStatus() == STATUS_IN_PROGRESS) - { - if (GetStartTime() >= 47*MINUTE*IN_MILLISECONDS) // after 47 minutes without one team losing, the arena closes with no winner and no rating change - { - UpdateArenaWorldState(); - CheckArenaAfterTimerConditions(); - } - } - if (getTimer() < diff) { - uint32 i; - switch(getState()) + switch (getState()) { case BG_RV_STATE_OPEN_FENCES: setTimer(BG_RV_PILAR_TO_FIRE_TIMER); setState(BG_RV_STATE_CLOSE_FIRE); break; case BG_RV_STATE_CLOSE_FIRE: - for (i = BG_RV_OBJECT_FIRE_1; i <= BG_RV_OBJECT_FIREDOOR_2; ++i) + for (uint8 i = BG_RV_OBJECT_FIRE_1; i <= BG_RV_OBJECT_FIREDOOR_2; ++i) DoorClose(i); setTimer(BG_RV_FIRE_TO_PILAR_TIMER); setState(BG_RV_STATE_OPEN_PILARS); break; case BG_RV_STATE_OPEN_PILARS: - for (i = BG_RV_OBJECT_PILAR_1; i <= BG_RV_OBJECT_PULLEY_2; ++i) + for (uint8 i = BG_RV_OBJECT_PILAR_1; i <= BG_RV_OBJECT_PULLEY_2; ++i) DoorOpen(i); setTimer(BG_RV_PILAR_TO_FIRE_TIMER); setState(BG_RV_STATE_OPEN_FIRE); break; case BG_RV_STATE_OPEN_FIRE: // FIXME: after 3.2.0 it's only decorative and should be opened only one time at battle start - for (i = BG_RV_OBJECT_FIRE_1; i <= BG_RV_OBJECT_FIREDOOR_2; ++i) + for (uint8 i = BG_RV_OBJECT_FIRE_1; i <= BG_RV_OBJECT_FIREDOOR_2; ++i) DoorOpen(i); setTimer(BG_RV_FIRE_TO_PILAR_TIMER); setState(BG_RV_STATE_CLOSE_PILARS); break; case BG_RV_STATE_CLOSE_PILARS: - for (i = BG_RV_OBJECT_PILAR_1; i <= BG_RV_OBJECT_PULLEY_2; ++i) + for (uint8 i = BG_RV_OBJECT_PILAR_1; i <= BG_RV_OBJECT_PULLEY_2; ++i) DoorOpen(i); setTimer(BG_RV_PILAR_TO_FIRE_TIMER); setState(BG_RV_STATE_CLOSE_FIRE); @@ -167,7 +155,7 @@ void BattlegroundRV::HandleAreaTrigger(Player *Source, uint32 Trigger) if (GetStatus() != STATUS_IN_PROGRESS) return; - switch(Trigger) + switch (Trigger) { case 5224: case 5226: diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundRV.h b/src/server/game/Battlegrounds/Zones/BattlegroundRV.h index cea0390f665..6cda12cb79d 100755 --- a/src/server/game/Battlegrounds/Zones/BattlegroundRV.h +++ b/src/server/game/Battlegrounds/Zones/BattlegroundRV.h @@ -100,12 +100,9 @@ class BattlegroundRVScore : public BattlegroundScore class BattlegroundRV : public Battleground { - friend class BattlegroundMgr; - public: BattlegroundRV(); ~BattlegroundRV(); - void Update(uint32 diff); /* inherited from BattlegroundClass */ virtual void AddPlayer(Player *plr); @@ -124,6 +121,8 @@ class BattlegroundRV : public Battleground uint32 Timer; uint32 State; + virtual void PostUpdateImpl(uint32 diff); + protected: uint32 getTimer() { return Timer; }; void setTimer(uint32 timer) { Timer = timer; }; diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundSA.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundSA.cpp index 1487a1b5943..8867e03422f 100755 --- a/src/server/game/Battlegrounds/Zones/BattlegroundSA.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundSA.cpp @@ -278,7 +278,7 @@ void BattlegroundSA::StartShips() ShipsStarted = true; } -void BattlegroundSA::Update(uint32 diff) +void BattlegroundSA::PostUpdateImpl(uint32 diff) { if (InitSecondRound) { diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundSA.h b/src/server/game/Battlegrounds/Zones/BattlegroundSA.h index 3623af57792..e404d350329 100755 --- a/src/server/game/Battlegrounds/Zones/BattlegroundSA.h +++ b/src/server/game/Battlegrounds/Zones/BattlegroundSA.h @@ -410,12 +410,8 @@ struct BG_SA_RoundScore /// Class for manage Strand of Ancient battleground class BattlegroundSA : public Battleground { - friend class BattlegroundMgr; - public: - /// Constructor BattlegroundSA(); - /// Destructor ~BattlegroundSA(); /** @@ -423,7 +419,7 @@ class BattlegroundSA : public Battleground * -Update timer * -Round switch */ - void Update(uint32 diff); + void PostUpdateImpl(uint32 diff); /* inherited from BattlegroundClass */ /// Called when a player join battle diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundWS.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundWS.cpp index 120d7887adf..c0c39cae117 100755 --- a/src/server/game/Battlegrounds/Zones/BattlegroundWS.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundWS.cpp @@ -62,10 +62,8 @@ BattlegroundWS::~BattlegroundWS() { } -void BattlegroundWS::Update(uint32 diff) +void BattlegroundWS::PostUpdateImpl(uint32 diff) { - Battleground::Update(diff); - if (GetStatus() == STATUS_IN_PROGRESS) { if (GetStartTime() >= 25*MINUTE*IN_MILLISECONDS) @@ -256,8 +254,7 @@ void BattlegroundWS::RespawnFlagAfterDrop(uint32 team) PlaySoundToAll(BG_WS_SOUND_FLAGS_RESPAWNED); - GameObject *obj = GetBgMap()->GetGameObject(GetDroppedFlagGUID(team)); - if (obj) + if (GameObject *obj = GetBgMap()->GetGameObject(GetDroppedFlagGUID(team))) obj->Delete(); else sLog->outError("unknown droped flag bg, guid: %u", GUID_LOPART(GetDroppedFlagGUID(team))); diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundWS.h b/src/server/game/Battlegrounds/Zones/BattlegroundWS.h index 8917110fb15..7b3dee9becb 100755 --- a/src/server/game/Battlegrounds/Zones/BattlegroundWS.h +++ b/src/server/game/Battlegrounds/Zones/BattlegroundWS.h @@ -157,13 +157,10 @@ class BattlegroundWGScore : public BattlegroundScore class BattlegroundWS : public Battleground { - friend class BattlegroundMgr; - public: /* Construction */ BattlegroundWS(); ~BattlegroundWS(); - void Update(uint32 diff); /* inherited from BattlegroundClass */ virtual void AddPlayer(Player *plr); @@ -226,6 +223,8 @@ class BattlegroundWS : public Battleground bool m_BothFlagsKept; uint8 m_FlagDebuffState; // 0 - no debuffs, 1 - focused assault, 2 - brutal assault uint8 m_minutesElapsed; + + virtual void PostUpdateImpl(uint32 diff); }; #endif diff --git a/src/server/game/Maps/MapManager.h b/src/server/game/Maps/MapManager.h index 068dbe33ae3..0392c1f6579 100755 --- a/src/server/game/Maps/MapManager.h +++ b/src/server/game/Maps/MapManager.h @@ -33,8 +33,6 @@ struct TransportCreatureProto; class MapManager { friend class ACE_Singleton<MapManager, ACE_Thread_Mutex>; - typedef UNORDERED_MAP<uint32, Map*> MapMapType; - typedef std::vector<bool> InstanceIds; public: @@ -151,11 +149,14 @@ class MapManager MapUpdater * GetMapUpdater() { return &m_updater; } private: + typedef UNORDERED_MAP<uint32, Map*> MapMapType; + typedef std::vector<bool> InstanceIds; + // debugging code, should be deleted some day void checkAndCorrectGridStatesArray(); // just for debugging to find some memory overwrites GridState* i_GridStates[MAX_GRID_STATE]; // shadow entries to the global array in Map.cpp int i_GridStateErrorCount; - private: + MapManager(); ~MapManager(); |