diff options
Diffstat (limited to 'src')
34 files changed, 257 insertions, 226 deletions
diff --git a/src/server/game/Battlegrounds/Arena.cpp b/src/server/game/Battlegrounds/Arena.cpp index c642fdc1b62..c1f50c437c0 100644 --- a/src/server/game/Battlegrounds/Arena.cpp +++ b/src/server/game/Battlegrounds/Arena.cpp @@ -27,7 +27,7 @@ #include "WorldStatePackets.h" #include "WorldSession.h" -Arena::Arena() +Arena::Arena(BattlegroundTemplate const* battlegroundTemplate) : Battleground(battlegroundTemplate) { StartDelayTimes[BG_STARTING_EVENT_FIRST] = BG_START_DELAY_1M; StartDelayTimes[BG_STARTING_EVENT_SECOND] = BG_START_DELAY_30S; diff --git a/src/server/game/Battlegrounds/Arena.h b/src/server/game/Battlegrounds/Arena.h index dd2f5113005..52a03980b01 100644 --- a/src/server/game/Battlegrounds/Arena.h +++ b/src/server/game/Battlegrounds/Arena.h @@ -48,7 +48,7 @@ enum ArenaWorldStates class TC_GAME_API Arena : public Battleground { protected: - Arena(); + Arena(BattlegroundTemplate const* battlegroundTemplate); void AddPlayer(Player* player) override; void RemovePlayer(Player* /*player*/, ObjectGuid /*guid*/, uint32 /*team*/) override; diff --git a/src/server/game/Battlegrounds/Battleground.cpp b/src/server/game/Battlegrounds/Battleground.cpp index dd330ba325b..14c0a8b0d9e 100644 --- a/src/server/game/Battlegrounds/Battleground.cpp +++ b/src/server/game/Battlegrounds/Battleground.cpp @@ -51,20 +51,19 @@ void Battleground::BroadcastWorker(Do& _do) _do(player); } -Battleground::Battleground() +Battleground::Battleground(BattlegroundTemplate const* battlegroundTemplate) : _battlegroundTemplate(battlegroundTemplate), _pvpDifficultyEntry(nullptr) { - m_TypeID = BATTLEGROUND_TYPE_NONE; + ASSERT(_battlegroundTemplate, "Nonexisting Battleground Template passed to battleground ctor!"); + m_RandomTypeID = BATTLEGROUND_TYPE_NONE; m_InstanceID = 0; m_Status = STATUS_NONE; m_ClientInstanceID = 0; m_EndTime = 0; m_LastResurrectTime = 0; - m_BracketId = BG_BRACKET_ID_FIRST; m_InvitedAlliance = 0; m_InvitedHorde = 0; m_ArenaType = 0; - m_IsArena = false; _winnerTeamId = BG_TEAM_NEUTRAL; m_StartTime = 0; m_CountdownTimer = 0; @@ -75,20 +74,10 @@ Battleground::Battleground() m_IsRated = false; m_BuffChange = false; m_IsRandom = false; - m_LevelMin = 0; - m_LevelMax = 0; m_InBGFreeSlotQueue = false; m_SetDeleteThis = false; - m_MaxPlayersPerTeam = 0; - m_MaxPlayers = 0; - m_MinPlayersPerTeam = 0; - m_MinPlayers = 0; - - m_MapId = 0; m_Map = NULL; - m_StartMaxDist = 0.0f; - ScriptId = 0; m_ArenaTeamIds[TEAM_ALLIANCE] = 0; m_ArenaTeamIds[TEAM_HORDE] = 0; @@ -108,8 +97,6 @@ Battleground::Battleground() m_PrematureCountDown = false; m_PrematureCountDownTimer = 0; - m_queueId = 0; - m_LastPlayerPositionBroadcast = 0; m_HonorMode = BG_NORMAL; @@ -242,11 +229,11 @@ inline void Battleground::_CheckSafePositions(uint32 diff) continue; Position pos = player->GetPosition(); - Position const* startPos = GetTeamStartPosition(Battleground::GetTeamIndexByTeamId(player->GetBGTeam())); - if (pos.GetExactDistSq(startPos) > maxDist) + WorldSafeLocsEntry const* startPos = GetTeamStartPosition(Battleground::GetTeamIndexByTeamId(player->GetBGTeam())); + if (pos.GetExactDistSq(startPos->Loc) > maxDist) { TC_LOG_DEBUG("bg.battleground", "BATTLEGROUND: Sending %s back to start location (map: %u) (possible exploit)", player->GetName().c_str(), GetMapId()); - player->TeleportTo(GetMapId(), startPos->GetPositionX(), startPos->GetPositionY(), startPos->GetPositionZ(), startPos->GetOrientation()); + player->TeleportTo(startPos->Loc); } } } @@ -431,7 +418,7 @@ inline void Battleground::_ProcessJoin(uint32 diff) if (!FindBgMap()) { - TC_LOG_ERROR("bg.battleground", "Battleground::_ProcessJoin: map (map id: %u, instance id: %u) is not created!", m_MapId, m_InstanceID); + TC_LOG_ERROR("bg.battleground", "Battleground::_ProcessJoin: map (map id: %u, instance id: %u) is not created!", GetMapId(), m_InstanceID); EndNow(); return; } @@ -483,7 +470,7 @@ inline void Battleground::_ProcessJoin(uint32 diff) if (Player* player = ObjectAccessor::FindPlayer(itr->first)) { // BG Status packet - BattlegroundQueueTypeId bgQueueTypeId = BattlegroundMgr::BGQueueTypeId(m_TypeID, GetArenaType()); + BattlegroundQueueTypeId bgQueueTypeId = BattlegroundMgr::BGQueueTypeId(GetTypeID(), GetArenaType()); uint32 queueSlot = player->GetBattlegroundQueueIndex(bgQueueTypeId); WorldPackets::Battleground::BattlefieldStatusActive battlefieldStatus; @@ -524,7 +511,7 @@ inline void Battleground::_ProcessJoin(uint32 diff) } // Announce BG starting if (sWorld->getBoolConfig(CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_ENABLE)) - sWorld->SendWorldText(LANG_BG_STARTED_ANNOUNCE_WORLD, GetName().c_str(), GetMinLevel(), GetMaxLevel()); + sWorld->SendWorldText(LANG_BG_STARTED_ANNOUNCE_WORLD, GetName(), GetMinLevel(), GetMaxLevel()); } } @@ -563,7 +550,7 @@ Player* Battleground::_GetPlayer(ObjectGuid guid, bool offlineRemove, char const player = ObjectAccessor::FindPlayer(guid); if (!player) TC_LOG_ERROR("bg.battleground", "Battleground::%s: player (%s) not found for BG (map: %u, instance id: %u)!", - context, guid.ToString().c_str(), m_MapId, m_InstanceID); + context, guid.ToString().c_str(), GetMapId(), m_InstanceID); } return player; } @@ -588,16 +575,15 @@ BattlegroundMap* Battleground::GetBgMap() const return m_Map; } -void Battleground::SetTeamStartPosition(TeamId teamId, Position const& pos) +WorldSafeLocsEntry const* Battleground::GetTeamStartPosition(TeamId teamId) const { ASSERT(teamId < TEAM_NEUTRAL); - StartPosition[teamId] = pos; + return _battlegroundTemplate->StartLocation[teamId]; } -Position const* Battleground::GetTeamStartPosition(TeamId teamId) const +float Battleground::GetStartMaxDist() const { - ASSERT(teamId < TEAM_NEUTRAL); - return &StartPosition[teamId]; + return _battlegroundTemplate->MaxStartDistSq; } void Battleground::SendPacketToAll(WorldPacket const* packet) const @@ -856,6 +842,11 @@ void Battleground::EndBattleground(uint32 winner) } } +uint32 Battleground::GetScriptId() const +{ + return _battlegroundTemplate->ScriptId; +} + uint32 Battleground::GetBonusHonorFromKill(uint32 kills) const { //variable kills means how many honorable kills you scored (so we need kills * honor_for_one_kill) @@ -997,7 +988,7 @@ void Battleground::Reset() if (m_InvitedAlliance > 0 || m_InvitedHorde > 0) TC_LOG_ERROR("bg.battleground", "Battleground::Reset: one of the counters is not 0 (alliance: %u, horde: %u) for BG (map: %u, instance id: %u)!", - m_InvitedAlliance, m_InvitedHorde, m_MapId, m_InstanceID); + m_InvitedAlliance, m_InvitedHorde, GetMapId(), m_InstanceID); m_InvitedAlliance = 0; m_InvitedHorde = 0; @@ -1059,7 +1050,7 @@ void Battleground::AddPlayer(Player* player) SendPacketToTeam(team, playerJoined.Write(), player); // BG Status packet - BattlegroundQueueTypeId bgQueueTypeId = sBattlegroundMgr->BGQueueTypeId(m_TypeID, GetArenaType()); + BattlegroundQueueTypeId bgQueueTypeId = sBattlegroundMgr->BGQueueTypeId(GetTypeID(), GetArenaType()); uint32 queueSlot = player->GetBattlegroundQueueIndex(bgQueueTypeId); WorldPackets::Battleground::BattlefieldStatusActive battlefieldStatus; @@ -1182,7 +1173,7 @@ void Battleground::AddToBGFreeSlotQueue() { if (!m_InBGFreeSlotQueue && isBattleground()) { - sBattlegroundMgr->AddToBGFreeSlotQueue(m_TypeID, this); + sBattlegroundMgr->AddToBGFreeSlotQueue(GetTypeID(), this); m_InBGFreeSlotQueue = true; } } @@ -1192,7 +1183,7 @@ void Battleground::RemoveFromBGFreeSlotQueue() { if (m_InBGFreeSlotQueue) { - sBattlegroundMgr->RemoveFromBGFreeSlotQueue(m_TypeID, m_InstanceID); + sBattlegroundMgr->RemoveFromBGFreeSlotQueue(GetTypeID(), m_InstanceID); m_InBGFreeSlotQueue = false; } } @@ -1264,6 +1255,16 @@ uint32 Battleground::GetFreeSlotsForTeam(uint32 Team) const return 0; } +bool Battleground::isArena() const +{ + return _battlegroundTemplate->IsArena(); +} + +bool Battleground::isBattleground() const +{ + return !isArena(); +} + bool Battleground::HasFreeSlots() const { return GetPlayersSize() < GetMaxPlayers(); @@ -1373,7 +1374,7 @@ bool Battleground::AddObject(uint32 type, uint32 entry, float x, float y, float if (!rotation0 && !rotation1 && !rotation2 && !rotation3) { TC_LOG_DEBUG("bg.battleground", "Battleground::AddObject: gameoobject [entry: %u, object type: %u] for BG (map: %u) has zeroed rotation fields, " - "orientation used temporally, but please fix the spawn", entry, type, m_MapId); + "orientation used temporally, but please fix the spawn", entry, type, GetMapId()); rot = QuaternionData::fromEulerAnglesZYX(o, 0.f, 0.f); } @@ -1385,7 +1386,7 @@ bool Battleground::AddObject(uint32 type, uint32 entry, float x, float y, float if (!go) { TC_LOG_ERROR("bg.battleground", "Battleground::AddObject: cannot create gameobject (entry: %u) for BG (map: %u, instance id: %u)!", - entry, m_MapId, m_InstanceID); + entry, GetMapId(), m_InstanceID); return false; } @@ -1441,7 +1442,7 @@ void Battleground::DoorClose(uint32 type) } else TC_LOG_ERROR("bg.battleground", "Battleground::DoorClose: door gameobject (type: %u, %s) not found for BG (map: %u, instance id: %u)!", - type, BgObjects[type].ToString().c_str(), m_MapId, m_InstanceID); + type, BgObjects[type].ToString().c_str(), GetMapId(), m_InstanceID); } void Battleground::DoorOpen(uint32 type) @@ -1453,7 +1454,7 @@ void Battleground::DoorOpen(uint32 type) } else TC_LOG_ERROR("bg.battleground", "Battleground::DoorOpen: door gameobject (type: %u, %s) not found for BG (map: %u, instance id: %u)!", - type, BgObjects[type].ToString().c_str(), m_MapId, m_InstanceID); + type, BgObjects[type].ToString().c_str(), GetMapId(), m_InstanceID); } GameObject* Battleground::GetBGObject(uint32 type, bool logError) @@ -1463,10 +1464,10 @@ GameObject* Battleground::GetBGObject(uint32 type, bool logError) { if (logError) TC_LOG_ERROR("bg.battleground", "Battleground::GetBGObject: gameobject (type: %u, %s) not found for BG (map: %u, instance id: %u)!", - type, BgObjects[type].ToString().c_str(), m_MapId, m_InstanceID); + type, BgObjects[type].ToString().c_str(), GetMapId(), m_InstanceID); else TC_LOG_INFO("bg.battleground", "Battleground::GetBGObject: gameobject (type: %u, %s) not found for BG (map: %u, instance id: %u)!", - type, BgObjects[type].ToString().c_str(), m_MapId, m_InstanceID); + type, BgObjects[type].ToString().c_str(), GetMapId(), m_InstanceID); } return obj; } @@ -1478,14 +1479,19 @@ Creature* Battleground::GetBGCreature(uint32 type, bool logError) { if (logError) TC_LOG_ERROR("bg.battleground", "Battleground::GetBGCreature: creature (type: %u, %s) not found for BG (map: %u, instance id: %u)!", - type, BgCreatures[type].ToString().c_str(), m_MapId, m_InstanceID); + type, BgCreatures[type].ToString().c_str(), GetMapId(), m_InstanceID); else TC_LOG_INFO("bg.battleground", "Battleground::GetBGCreature: creature (type: %u, %s) not found for BG (map: %u, instance id: %u)!", - type, BgCreatures[type].ToString().c_str(), m_MapId, m_InstanceID); + type, BgCreatures[type].ToString().c_str(), GetMapId(), m_InstanceID); } return creature; } +uint32 Battleground::GetMapId() const +{ + return _battlegroundTemplate->BattlemasterEntry->MapID[0]; +} + void Battleground::SpawnBGObject(uint32 type, uint32 respawntime) { if (Map* map = FindBgMap()) @@ -1514,7 +1520,7 @@ Creature* Battleground::AddCreature(uint32 entry, uint32 type, float x, float y, if (!sObjectMgr->GetCreatureTemplate(entry)) { TC_LOG_ERROR("bg.battleground", "Battleground::AddCreature: creature template (entry: %u) does not exist for BG (map: %u, instance id: %u)!", - entry, m_MapId, m_InstanceID); + entry, GetMapId(), m_InstanceID); return nullptr; } @@ -1535,7 +1541,7 @@ Creature* Battleground::AddCreature(uint32 entry, uint32 type, float x, float y, if (!creature) { TC_LOG_ERROR("bg.battleground", "Battleground::AddCreature: cannot create creature (entry: %u) for BG (map: %u, instance id: %u)!", - entry, m_MapId, m_InstanceID); + entry, GetMapId(), m_InstanceID); return nullptr; } @@ -1573,7 +1579,7 @@ bool Battleground::DelCreature(uint32 type) } TC_LOG_ERROR("bg.battleground", "Battleground::DelCreature: creature (type: %u, %s) not found for BG (map: %u, instance id: %u)!", - type, BgCreatures[type].ToString().c_str(), m_MapId, m_InstanceID); + type, BgCreatures[type].ToString().c_str(), GetMapId(), m_InstanceID); BgCreatures[type].Clear(); return false; } @@ -1591,7 +1597,7 @@ bool Battleground::DelObject(uint32 type) return true; } TC_LOG_ERROR("bg.battleground", "Battleground::DelObject: gameobject (type: %u, %s) not found for BG (map: %u, instance id: %u)!", - type, BgObjects[type].ToString().c_str(), m_MapId, m_InstanceID); + type, BgObjects[type].ToString().c_str(), GetMapId(), m_InstanceID); BgObjects[type].Clear(); return false; } @@ -1614,7 +1620,7 @@ bool Battleground::AddSpiritGuide(uint32 type, float x, float y, float z, float return true; } TC_LOG_ERROR("bg.battleground", "Battleground::AddSpiritGuide: cannot create spirit guide (type: %u, entry: %u) for BG (map: %u, instance id: %u)!", - type, entry, m_MapId, m_InstanceID); + type, entry, GetMapId(), m_InstanceID); EndNow(); return false; } @@ -1672,7 +1678,7 @@ void Battleground::HandleTriggerBuff(ObjectGuid go_guid) if (index < 0) { TC_LOG_ERROR("bg.battleground", "Battleground::HandleTriggerBuff: cannot find buff gameobject (%s, entry: %u, type: %u) in internal data for BG (map: %u, instance id: %u)!", - go_guid.ToString().c_str(), obj->GetEntry(), obj->GetGoType(), m_MapId, m_InstanceID); + go_guid.ToString().c_str(), obj->GetEntry(), obj->GetGoType(), GetMapId(), m_InstanceID); return; } @@ -1797,7 +1803,7 @@ int32 Battleground::GetObjectType(ObjectGuid guid) if (BgObjects[i] == guid) return i; TC_LOG_ERROR("bg.battleground", "Battleground::GetObjectType: player used gameobject (%s) which is not in internal data for BG (map: %u, instance id: %u), cheating?", - guid.ToString().c_str(), m_MapId, m_InstanceID); + guid.ToString().c_str(), GetMapId(), m_InstanceID); return -1; } @@ -1825,8 +1831,7 @@ void Battleground::StartCriteriaTimer(CriteriaTimedTypes type, uint32 entry) void Battleground::SetBracket(PVPDifficultyEntry const* bracketEntry) { - m_BracketId = bracketEntry->GetBracketId(); - SetLevelRange(bracketEntry->MinLevel, bracketEntry->MaxLevel); + _pvpDifficultyEntry = bracketEntry; } void Battleground::RewardXPAtKill(Player* killer, Player* victim) @@ -1856,7 +1861,78 @@ bool Battleground::CheckAchievementCriteriaMeet(uint32 criteriaId, Player const* return false; } +char const* Battleground::GetName() const +{ + return _battlegroundTemplate->BattlemasterEntry->Name->Str[sWorld->GetDefaultDbcLocale()]; +} + +uint64 Battleground::GetQueueId() const +{ + return uint64(_battlegroundTemplate->Id) | UI64LIT(0x1F10000000000000); +} + +BattlegroundTypeId Battleground::GetTypeID(bool getRandom) const +{ + return getRandom ? m_RandomTypeID : _battlegroundTemplate->Id; +} + +BattlegroundBracketId Battleground::GetBracketId() const +{ + return _pvpDifficultyEntry->GetBracketId(); +} + uint8 Battleground::GetUniqueBracketId() const { return uint8(GetMinLevel() / 5) - 1; // 10 - 1, 15 - 2, 20 - 3, etc. } + +uint32 Battleground::GetMaxPlayers() const +{ + return GetMaxPlayersPerTeam() * 2; +} + +uint32 Battleground::GetMinPlayers() const +{ + return GetMinPlayersPerTeam() * 2; +} + +uint32 Battleground::GetMinLevel() const +{ + if (_pvpDifficultyEntry) + return _pvpDifficultyEntry->MinLevel; + + return _battlegroundTemplate->GetMinLevel(); +} + +uint32 Battleground::GetMaxLevel() const +{ + if (_pvpDifficultyEntry) + return _pvpDifficultyEntry->MaxLevel; + + return _battlegroundTemplate->GetMaxLevel(); +} + +uint32 Battleground::GetMaxPlayersPerTeam() const +{ + if (isArena()) + { + switch (GetArenaType()) + { + case ARENA_TYPE_2v2: + return 2; + case ARENA_TYPE_3v3: + return 3; + case ARENA_TYPE_5v5: // removed + return 5; + default: + break; + } + } + + return _battlegroundTemplate->GetMaxPlayersPerTeam(); +} + +uint32 Battleground::GetMinPlayersPerTeam() const +{ + return _battlegroundTemplate->GetMinPlayersPerTeam(); +} diff --git a/src/server/game/Battlegrounds/Battleground.h b/src/server/game/Battlegrounds/Battleground.h index 84c350bad2b..23a01a37f44 100644 --- a/src/server/game/Battlegrounds/Battleground.h +++ b/src/server/game/Battlegrounds/Battleground.h @@ -34,6 +34,7 @@ class Unit; class WorldObject; class WorldPacket; struct BattlegroundScore; +struct BattlegroundTemplate; struct PVPDifficultyEntry; struct WorldSafeLocsEntry; @@ -239,7 +240,7 @@ This class is used to: class TC_GAME_API Battleground { public: - Battleground(); + Battleground(BattlegroundTemplate const* battlegroundTemplate); virtual ~Battleground(); void Update(uint32 diff); @@ -262,36 +263,33 @@ class TC_GAME_API Battleground /* Battleground */ // Get methods: - std::string const& GetName() const { return m_Name; } - uint64 GetQueueId() const { return m_queueId; } - BattlegroundTypeId GetTypeID(bool GetRandom = false) const { return GetRandom ? m_RandomTypeID : m_TypeID; } - BattlegroundBracketId GetBracketId() const { return m_BracketId; } + char const* GetName() const; + uint64 GetQueueId() const; + BattlegroundTypeId GetTypeID(bool getRandom = false) const; + BattlegroundBracketId GetBracketId() const; uint32 GetInstanceID() const { return m_InstanceID; } BattlegroundStatus GetStatus() const { return m_Status; } uint32 GetClientInstanceID() const { return m_ClientInstanceID; } uint32 GetElapsedTime() const { return m_StartTime; } uint32 GetRemainingTime() const { return m_EndTime; } uint32 GetLastResurrectTime() const { return m_LastResurrectTime; } - uint32 GetMaxPlayers() const { return m_MaxPlayers; } - uint32 GetMinPlayers() const { return m_MinPlayers; } + uint32 GetMaxPlayers() const; + uint32 GetMinPlayers() const; - uint32 GetMinLevel() const { return m_LevelMin; } - uint32 GetMaxLevel() const { return m_LevelMax; } + uint32 GetMinLevel() const; + uint32 GetMaxLevel() const; - uint32 GetMaxPlayersPerTeam() const { return m_MaxPlayersPerTeam; } - uint32 GetMinPlayersPerTeam() const { return m_MinPlayersPerTeam; } + uint32 GetMaxPlayersPerTeam() const; + uint32 GetMinPlayersPerTeam() const; int32 GetStartDelayTime() const { return m_StartDelayTime; } uint8 GetArenaType() const { return m_ArenaType; } BattlegroundTeamId GetWinner() const { return _winnerTeamId; } - uint32 GetScriptId() const { return ScriptId; } + uint32 GetScriptId() const; uint32 GetBonusHonorFromKill(uint32 kills) const; bool IsRandom() const { return m_IsRandom; } // Set methods: - void SetQueueId(uint64 queueId) { m_queueId = queueId; } - void SetName(std::string const& name) { m_Name = name; } - void SetTypeID(BattlegroundTypeId TypeID) { m_TypeID = TypeID; } void SetRandomTypeID(BattlegroundTypeId TypeID) { m_RandomTypeID = TypeID; } //here we can count minlevel and maxlevel for players void SetBracket(PVPDifficultyEntry const* bracketEntry); @@ -301,21 +299,13 @@ class TC_GAME_API Battleground void SetElapsedTime(uint32 Time) { m_StartTime = Time; } void SetRemainingTime(uint32 Time) { m_EndTime = Time; } void SetLastResurrectTime(uint32 Time) { m_LastResurrectTime = Time; } - void SetMaxPlayers(uint32 MaxPlayers) { m_MaxPlayers = MaxPlayers; } - void SetMinPlayers(uint32 MinPlayers) { m_MinPlayers = MinPlayers; } - void SetLevelRange(uint32 min, uint32 max) { m_LevelMin = min; m_LevelMax = max; } void SetRated(bool state) { m_IsRated = state; } void SetArenaType(uint8 type) { m_ArenaType = type; } - void SetArenaorBGType(bool _isArena) { m_IsArena = _isArena; } void SetWinner(BattlegroundTeamId winnerTeamId) { _winnerTeamId = winnerTeamId; } - void SetScriptId(uint32 scriptId) { ScriptId = scriptId; } void ModifyStartDelayTime(int diff) { m_StartDelayTime -= diff; } void SetStartDelayTime(int Time) { m_StartDelayTime = Time; } - void SetMaxPlayersPerTeam(uint32 MaxPlayers) { m_MaxPlayersPerTeam = MaxPlayers; } - void SetMinPlayersPerTeam(uint32 MinPlayers) { m_MinPlayersPerTeam = MinPlayers; } - void AddToBGFreeSlotQueue(); //this queue will be useful when more battlegrounds instances will be available void RemoveFromBGFreeSlotQueue(); //this method could delete whole BG instance, if another free is available @@ -327,8 +317,8 @@ class TC_GAME_API Battleground bool HasFreeSlots() const; uint32 GetFreeSlotsForTeam(uint32 Team) const; - bool isArena() const { return m_IsArena; } - bool isBattleground() const { return !m_IsArena; } + bool isArena() const; + bool isBattleground() const; bool isRated() const { return m_IsRated; } typedef std::map<ObjectGuid, BattlegroundPlayer> BattlegroundPlayerMap; @@ -352,19 +342,16 @@ class TC_GAME_API Battleground Creature* GetBGCreature(uint32 type, bool logError = true); // Location - void SetMapId(uint32 MapID) { m_MapId = MapID; } - uint32 GetMapId() const { return m_MapId; } + uint32 GetMapId() const; // Map pointers void SetBgMap(BattlegroundMap* map) { m_Map = map; } BattlegroundMap* GetBgMap() const; BattlegroundMap* FindBgMap() const { return m_Map; } - void SetTeamStartPosition(TeamId teamId, Position const& pos); - Position const* GetTeamStartPosition(TeamId teamId) const; + WorldSafeLocsEntry const* GetTeamStartPosition(TeamId teamId) const; - void SetStartMaxDist(float startMaxDist) { m_StartMaxDist = startMaxDist; } - float GetStartMaxDist() const { return m_StartMaxDist; } + float GetStartMaxDist() const; // Packet Transfer // method that should fill worldpacket with actual world states (not yet implemented for all battlegrounds!) @@ -482,7 +469,7 @@ class TC_GAME_API Battleground void SetDeleteThis() { m_SetDeleteThis = true; } void RewardXPAtKill(Player* killer, Player* victim); - bool CanAwardArenaPoints() const { return m_LevelMin >= BG_AWARD_ARENA_POINTS_MIN_LEVEL; } + bool CanAwardArenaPoints() const { return GetMinLevel() >= BG_AWARD_ARENA_POINTS_MIN_LEVEL; } virtual ObjectGuid GetFlagPickerGUID(int32 /*team*/ = -1) const { return ObjectGuid::Empty; } virtual void SetDroppedFlagGUID(ObjectGuid /*guid*/, int32 /*team*/ = -1) { } @@ -569,7 +556,6 @@ class TC_GAME_API Battleground private: // Battleground - BattlegroundTypeId m_TypeID; BattlegroundTypeId m_RandomTypeID; uint32 m_InstanceID; // Battleground Instance's GUID! BattlegroundStatus m_Status; @@ -580,18 +566,15 @@ class TC_GAME_API Battleground uint32 m_ValidStartPositionTimer; int32 m_EndTime; // it is set to 120000 when bg is ending and it decreases itself uint32 m_LastResurrectTime; - BattlegroundBracketId m_BracketId; uint8 m_ArenaType; // 2=2v2, 3=3v3, 5=5v5 bool m_InBGFreeSlotQueue; // used to make sure that BG is only once inserted into the BattlegroundMgr.BGFreeSlotQueue[bgTypeId] deque bool m_SetDeleteThis; // used for safe deletion of the bg after end / all players leave - bool m_IsArena; + BattlegroundTeamId _winnerTeamId; int32 m_StartDelayTime; bool m_IsRated; // is this battle rated? bool m_PrematureCountDown; uint32 m_PrematureCountDownTimer; - std::string m_Name; - uint64 m_queueId; uint32 m_LastPlayerPositionBroadcast; // Player lists @@ -615,19 +598,11 @@ class TC_GAME_API Battleground uint32 m_ArenaTeamMMR[BG_TEAMS_COUNT]; - // Limits - uint32 m_LevelMin; - uint32 m_LevelMax; - uint32 m_MaxPlayersPerTeam; - uint32 m_MaxPlayers; - uint32 m_MinPlayersPerTeam; - uint32 m_MinPlayers; - // Start location - uint32 m_MapId; BattlegroundMap* m_Map; Position StartPosition[BG_TEAMS_COUNT]; - float m_StartMaxDist; - uint32 ScriptId; + + BattlegroundTemplate const* _battlegroundTemplate; + PVPDifficultyEntry const* _pvpDifficultyEntry; }; #endif diff --git a/src/server/game/Battlegrounds/BattlegroundMgr.cpp b/src/server/game/Battlegrounds/BattlegroundMgr.cpp index 48f5fca6ad3..bc401647ae1 100644 --- a/src/server/game/Battlegrounds/BattlegroundMgr.cpp +++ b/src/server/game/Battlegrounds/BattlegroundMgr.cpp @@ -52,6 +52,26 @@ bool BattlegroundTemplate::IsArena() const return BattlemasterEntry->InstanceType == MAP_ARENA; } +uint16 BattlegroundTemplate::GetMinPlayersPerTeam() const +{ + return BattlemasterEntry->MinPlayers; +} + +uint16 BattlegroundTemplate::GetMaxPlayersPerTeam() const +{ + return BattlemasterEntry->MaxPlayers; +} + +uint8 BattlegroundTemplate::GetMinLevel() const +{ + return BattlemasterEntry->MinLevel; +} + +uint8 BattlegroundTemplate::GetMaxLevel() const +{ + return BattlemasterEntry->MaxLevel; +} + /*********************************************************/ /*** BATTLEGROUND MANAGER ***/ /*********************************************************/ @@ -365,32 +385,9 @@ Battleground* BattlegroundMgr::CreateNewBattleground(BattlegroundTypeId original bg->Reset(); // reset the new bg (set status to status_wait_queue from status_none) bg->SetStatus(STATUS_WAIT_JOIN); // start the joining of the bg bg->SetArenaType(arenaType); - bg->SetTypeID(originalBgTypeId); bg->SetRandomTypeID(bgTypeId); bg->SetRated(isRated); bg->SetRandom(isRandom); - bg->SetQueueId(uint64(bgTypeId) | UI64LIT(0x1F10000000000000)); - - // Set up correct min/max player counts for scoreboards - if (bg->isArena()) - { - uint32 maxPlayersPerTeam = 0; - switch (arenaType) - { - case ARENA_TYPE_2v2: - maxPlayersPerTeam = 2; - break; - case ARENA_TYPE_3v3: - maxPlayersPerTeam = 3; - break; - case ARENA_TYPE_5v5: - maxPlayersPerTeam = 5; - break; - } - - bg->SetMaxPlayersPerTeam(maxPlayersPerTeam); - bg->SetMaxPlayers(maxPlayersPerTeam * 2); - } return bg; } @@ -405,74 +402,60 @@ bool BattlegroundMgr::CreateBattleground(BattlegroundTemplate const* bgTemplate) switch (bgTemplate->Id) { case BATTLEGROUND_AV: - bg = new BattlegroundAV; + bg = new BattlegroundAV(bgTemplate); break; case BATTLEGROUND_WS: - bg = new BattlegroundWS; + bg = new BattlegroundWS(bgTemplate); break; case BATTLEGROUND_AB: - bg = new BattlegroundAB; + bg = new BattlegroundAB(bgTemplate); break; case BATTLEGROUND_NA: - bg = new BattlegroundNA; + bg = new BattlegroundNA(bgTemplate); break; case BATTLEGROUND_BE: - bg = new BattlegroundBE; + bg = new BattlegroundBE(bgTemplate); break; case BATTLEGROUND_EY: - bg = new BattlegroundEY; + bg = new BattlegroundEY(bgTemplate); break; case BATTLEGROUND_RL: - bg = new BattlegroundRL; + bg = new BattlegroundRL(bgTemplate); break; case BATTLEGROUND_SA: - bg = new BattlegroundSA; + bg = new BattlegroundSA(bgTemplate); break; case BATTLEGROUND_DS: - bg = new BattlegroundDS; + bg = new BattlegroundDS(bgTemplate); break; case BATTLEGROUND_RV: - bg = new BattlegroundRV; + bg = new BattlegroundRV(bgTemplate); break; case BATTLEGROUND_IC: - bg = new BattlegroundIC; + bg = new BattlegroundIC(bgTemplate); break; case BATTLEGROUND_AA: - bg = new Battleground; + bg = new Battleground(bgTemplate); break; case BATTLEGROUND_RB: - bg = new Battleground; + bg = new Battleground(bgTemplate); bg->SetRandom(true); break; case BATTLEGROUND_TP: - bg = new BattlegroundTP; + bg = new BattlegroundTP(bgTemplate); break; case BATTLEGROUND_BFG: - bg = new BattlegroundBFG; + bg = new BattlegroundBFG(bgTemplate); break; default: return false; } - bg->SetTypeID(bgTemplate->Id); bg->SetInstanceID(0); AddBattleground(bg); } - bg->SetMapId(bgTemplate->BattlemasterEntry->MapID[0]); - bg->SetName(bgTemplate->BattlemasterEntry->Name->Str[sWorld->GetDefaultDbcLocale()]); bg->SetInstanceID(0); - bg->SetArenaorBGType(bgTemplate->IsArena()); - bg->SetMinPlayersPerTeam(bgTemplate->MinPlayersPerTeam); - bg->SetMaxPlayersPerTeam(bgTemplate->MaxPlayersPerTeam); - bg->SetMinPlayers(bgTemplate->MinPlayersPerTeam * 2); - bg->SetMaxPlayers(bgTemplate->MaxPlayersPerTeam * 2); - bg->SetTeamStartPosition(TEAM_ALLIANCE, bgTemplate->StartLocation[TEAM_ALLIANCE]); - bg->SetTeamStartPosition(TEAM_HORDE, bgTemplate->StartLocation[TEAM_HORDE]); - bg->SetStartMaxDist(bgTemplate->MaxStartDistSq); - bg->SetLevelRange(bgTemplate->MinLevel, bgTemplate->MaxLevel); - bg->SetScriptId(bgTemplate->ScriptId); - bg->SetQueueId(uint64(bgTemplate->Id) | UI64LIT(0x1F10000000000000)); AddBattleground(bg); @@ -483,11 +466,8 @@ void BattlegroundMgr::LoadBattlegroundTemplates() { uint32 oldMSTime = getMSTime(); - _battlegroundMapTemplates.clear(); - _battlegroundTemplates.clear(); - - // 0 1 2 3 4 5 6 7 8 9 - QueryResult result = WorldDatabase.Query("SELECT ID, MinPlayersPerTeam, MaxPlayersPerTeam, MinLvl, MaxLvl, AllianceStartLoc, HordeStartLoc, StartMaxDist, Weight, ScriptName FROM battleground_template"); + // 0 1 2 3 4 5 + QueryResult result = WorldDatabase.Query("SELECT ID, AllianceStartLoc, HordeStartLoc, StartMaxDist, Weight, ScriptName FROM battleground_template"); if (!result) { TC_LOG_ERROR("server.loading", ">> Loaded 0 battlegrounds. DB table `battleground_template` is empty."); @@ -513,61 +493,47 @@ void BattlegroundMgr::LoadBattlegroundTemplates() continue; } - BattlegroundTemplate bgTemplate; + BattlegroundTemplate& bgTemplate = _battlegroundTemplates[bgTypeId]; bgTemplate.Id = bgTypeId; - bgTemplate.MinPlayersPerTeam = fields[1].GetUInt16(); - bgTemplate.MaxPlayersPerTeam = fields[2].GetUInt16(); - bgTemplate.MinLevel = fields[3].GetUInt8(); - bgTemplate.MaxLevel = fields[4].GetUInt8(); - float dist = fields[7].GetFloat(); + float dist = fields[3].GetFloat(); bgTemplate.MaxStartDistSq = dist * dist; - bgTemplate.Weight = fields[8].GetUInt8(); - bgTemplate.ScriptId = sObjectMgr->GetScriptId(fields[9].GetString()); + bgTemplate.Weight = fields[4].GetUInt8(); + bgTemplate.ScriptId = sObjectMgr->GetScriptId(fields[5].GetString()); bgTemplate.BattlemasterEntry = bl; - if (bgTemplate.MaxPlayersPerTeam == 0 || bgTemplate.MinPlayersPerTeam > bgTemplate.MaxPlayersPerTeam) - { - TC_LOG_ERROR("sql.sql", "Table `battleground_template` for id %u contains bad values for MinPlayersPerTeam (%u) and MaxPlayersPerTeam(%u).", - bgTemplate.Id, bgTemplate.MinPlayersPerTeam, bgTemplate.MaxPlayersPerTeam); - continue; - } - - if (bgTemplate.MinLevel == 0 || bgTemplate.MaxLevel == 0 || bgTemplate.MinLevel > bgTemplate.MaxLevel) - { - TC_LOG_ERROR("sql.sql", "Table `battleground_template` for id %u contains bad values for MinLevel (%u) and MaxLevel (%u).", - bgTemplate.Id, bgTemplate.MinLevel, bgTemplate.MaxLevel); - continue; - } - if (bgTemplate.Id != BATTLEGROUND_AA && bgTemplate.Id != BATTLEGROUND_RB) { - uint32 startId = fields[5].GetUInt32(); + uint32 startId = fields[1].GetUInt32(); if (WorldSafeLocsEntry const* start = sObjectMgr->GetWorldSafeLoc(startId)) - { - bgTemplate.StartLocation[TEAM_ALLIANCE].Relocate(start->Loc); - } + bgTemplate.StartLocation[TEAM_ALLIANCE] = start; + else if (bgTemplate.StartLocation[TEAM_ALLIANCE]) // reload case + TC_LOG_ERROR("sql.sql", "Table `battleground_template` for id %u contains a non-existing WorldSafeLocs.dbc id %u in field `AllianceStartLoc`. Ignoring.", bgTemplate.Id, startId); else { TC_LOG_ERROR("sql.sql", "Table `battleground_template` for id %u contains a non-existing WorldSafeLocs.dbc id %u in field `AllianceStartLoc`. BG not created.", bgTemplate.Id, startId); + _battlegroundTemplates.erase(bgTypeId); continue; } - startId = fields[6].GetUInt32(); + startId = fields[2].GetUInt32(); if (WorldSafeLocsEntry const* start = sObjectMgr->GetWorldSafeLoc(startId)) - { - bgTemplate.StartLocation[TEAM_HORDE].Relocate(start->Loc); - } + bgTemplate.StartLocation[TEAM_HORDE] = start; + else if (bgTemplate.StartLocation[TEAM_HORDE]) // reload case + TC_LOG_ERROR("sql.sql", "Table `battleground_template` for id %u contains a non-existing WorldSafeLocs.dbc id %u in field `HordeStartLoc`. Ignoring.", bgTemplate.Id, startId); else { TC_LOG_ERROR("sql.sql", "Table `battleground_template` for id %u contains a non-existing WorldSafeLocs.dbc id %u in field `HordeStartLoc`. BG not created.", bgTemplate.Id, startId); + _battlegroundTemplates.erase(bgTypeId); continue; } } if (!CreateBattleground(&bgTemplate)) + { + TC_LOG_ERROR("bg.battleground", "Could not create battleground template class (%u)!", bgTemplate.Id); + _battlegroundTemplates.erase(bgTypeId); continue; - - _battlegroundTemplates[bgTypeId] = bgTemplate; + } if (bgTemplate.BattlemasterEntry->MapID[1] == -1) // in this case we have only one mapId _battlegroundMapTemplates[bgTemplate.BattlemasterEntry->MapID[0]] = &_battlegroundTemplates[bgTypeId]; @@ -588,8 +554,8 @@ void BattlegroundMgr::SendBattlegroundList(Player* player, ObjectGuid const& gui WorldPackets::Battleground::BattlefieldList battlefieldList; battlefieldList.BattlemasterGuid = guid; battlefieldList.BattlemasterListID = bgTypeId; - battlefieldList.MinLevel = bgTemplate->MinLevel; - battlefieldList.MaxLevel = bgTemplate->MaxLevel; + battlefieldList.MinLevel = bgTemplate->GetMinLevel(); + battlefieldList.MaxLevel = bgTemplate->GetMaxLevel(); battlefieldList.PvpAnywhere = guid.IsEmpty(); battlefieldList.HasRandomWinToday = player->GetRandomWinner(); player->SendDirectMessage(battlefieldList.Write()); @@ -602,9 +568,9 @@ void BattlegroundMgr::SendToBattleground(Player* player, uint32 instanceId, Batt uint32 mapid = bg->GetMapId(); uint32 team = player->GetBGTeam(); - Position const* pos = bg->GetTeamStartPosition(Battleground::GetTeamIndexByTeamId(team)); - TC_LOG_DEBUG("bg.battleground", "BattlegroundMgr::SendToBattleground: Sending %s to map %u, %s (bgType %u)", player->GetName().c_str(), mapid, pos->ToString().c_str(), bgTypeId); - player->TeleportTo(mapid, pos->GetPositionX(), pos->GetPositionY(), pos->GetPositionZ(), pos->GetOrientation()); + WorldSafeLocsEntry const* pos = bg->GetTeamStartPosition(Battleground::GetTeamIndexByTeamId(team)); + TC_LOG_DEBUG("bg.battleground", "BattlegroundMgr::SendToBattleground: Sending %s to map %u, %s (bgType %u)", player->GetName().c_str(), mapid, pos->Loc.ToString().c_str(), bgTypeId); + player->TeleportTo(pos->Loc); } else TC_LOG_ERROR("bg.battleground", "BattlegroundMgr::SendToBattleground: Instance %u (bgType %u) not found while trying to teleport player %s", instanceId, bgTypeId, player->GetName().c_str()); diff --git a/src/server/game/Battlegrounds/BattlegroundMgr.h b/src/server/game/Battlegrounds/BattlegroundMgr.h index 0793ca7a546..38cc163835c 100644 --- a/src/server/game/Battlegrounds/BattlegroundMgr.h +++ b/src/server/game/Battlegrounds/BattlegroundMgr.h @@ -47,17 +47,17 @@ struct BattlegroundData struct BattlegroundTemplate { BattlegroundTypeId Id; - uint16 MinPlayersPerTeam; - uint16 MaxPlayersPerTeam; - uint8 MinLevel; - uint8 MaxLevel; - Position StartLocation[BG_TEAMS_COUNT]; + WorldSafeLocsEntry const* StartLocation[BG_TEAMS_COUNT] = { }; float MaxStartDistSq; uint8 Weight; uint32 ScriptId; BattlemasterListEntry const* BattlemasterEntry; bool IsArena() const; + uint16 GetMinPlayersPerTeam() const; + uint16 GetMaxPlayersPerTeam() const; + uint8 GetMinLevel() const; + uint8 GetMaxLevel() const; }; namespace WorldPackets diff --git a/src/server/game/Battlegrounds/BattlegroundQueue.cpp b/src/server/game/Battlegrounds/BattlegroundQueue.cpp index cd160be4896..72dc24b11ba 100644 --- a/src/server/game/Battlegrounds/BattlegroundQueue.cpp +++ b/src/server/game/Battlegrounds/BattlegroundQueue.cpp @@ -217,13 +217,13 @@ GroupQueueInfo* BattlegroundQueue::AddGroup(Player* leader, Group* grp, Battlegr // Show queue status to player only (when joining queue) if (sWorld->getBoolConfig(CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_PLAYERONLY)) { - ChatHandler(leader->GetSession()).PSendSysMessage(LANG_BG_QUEUE_ANNOUNCE_SELF, bg->GetName().c_str(), q_min_level, q_max_level, + ChatHandler(leader->GetSession()).PSendSysMessage(LANG_BG_QUEUE_ANNOUNCE_SELF, bg->GetName(), q_min_level, q_max_level, qAlliance, (MinPlayers > qAlliance) ? MinPlayers - qAlliance : (uint32)0, qHorde, (MinPlayers > qHorde) ? MinPlayers - qHorde : (uint32)0); } // System message else { - sWorld->SendWorldText(LANG_BG_QUEUE_ANNOUNCE_WORLD, bg->GetName().c_str(), q_min_level, q_max_level, + sWorld->SendWorldText(LANG_BG_QUEUE_ANNOUNCE_WORLD, bg->GetName(), q_min_level, q_max_level, qAlliance, (MinPlayers > qAlliance) ? MinPlayers - qAlliance : (uint32)0, qHorde, (MinPlayers > qHorde) ? MinPlayers - qHorde : (uint32)0); } } diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundAB.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundAB.cpp index ebe3f5462b6..edd6d3e67ed 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundAB.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundAB.cpp @@ -30,7 +30,7 @@ #include "WorldSession.h" #include "WorldStatePackets.h" -BattlegroundAB::BattlegroundAB() +BattlegroundAB::BattlegroundAB(BattlegroundTemplate const* battlegroundTemplate) : Battleground(battlegroundTemplate) { m_IsInformedNearVictory = false; m_BuffChange = true; diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundAB.h b/src/server/game/Battlegrounds/Zones/BattlegroundAB.h index e90d2c0311a..c95d33ee82e 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundAB.h +++ b/src/server/game/Battlegrounds/Zones/BattlegroundAB.h @@ -311,7 +311,7 @@ struct BattlegroundABScore final : public BattlegroundScore class BattlegroundAB : public Battleground { public: - BattlegroundAB(); + BattlegroundAB(BattlegroundTemplate const* battlegroundTemplate); ~BattlegroundAB(); void AddPlayer(Player* player) override; diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp index 1dabe1a572d..402b223841c 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp @@ -27,7 +27,7 @@ #include "WorldSession.h" #include "WorldStatePackets.h" -BattlegroundAV::BattlegroundAV() +BattlegroundAV::BattlegroundAV(BattlegroundTemplate const* battlegroundTemplate) : Battleground(battlegroundTemplate) { BgObjects.resize(BG_AV_OBJECT_MAX); BgCreatures.resize(AV_CPLACE_MAX+AV_STATICCPLACE_MAX); diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundAV.h b/src/server/game/Battlegrounds/Zones/BattlegroundAV.h index b05768dcd5c..afcab05675d 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundAV.h +++ b/src/server/game/Battlegrounds/Zones/BattlegroundAV.h @@ -1624,7 +1624,7 @@ struct BattlegroundAVScore final : public BattlegroundScore class BattlegroundAV : public Battleground { public: - BattlegroundAV(); + BattlegroundAV(BattlegroundTemplate const* battlegroundTemplate); ~BattlegroundAV(); /* inherited from BattlegroundClass */ diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundBE.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundBE.cpp index 44010f7f989..cff1ecf3f66 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundBE.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundBE.cpp @@ -20,7 +20,7 @@ #include "Player.h" #include "WorldStatePackets.h" -BattlegroundBE::BattlegroundBE() +BattlegroundBE::BattlegroundBE(BattlegroundTemplate const* battlegroundTemplate) : Arena(battlegroundTemplate) { BgObjects.resize(BG_BE_OBJECT_MAX); } diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundBE.h b/src/server/game/Battlegrounds/Zones/BattlegroundBE.h index 63ccf8fe4ba..81060b5b8dd 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundBE.h +++ b/src/server/game/Battlegrounds/Zones/BattlegroundBE.h @@ -44,7 +44,7 @@ enum BattlegroundBEGameObjects class BattlegroundBE : public Arena { public: - BattlegroundBE(); + BattlegroundBE(BattlegroundTemplate const* battlegroundTemplate); /* inherited from BattlegroundClass */ void StartingEventCloseDoors() override; diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundBFG.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundBFG.cpp index 74ce91e071b..1d59b6a6b0d 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundBFG.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundBFG.cpp @@ -17,7 +17,7 @@ #include "BattlegroundBFG.h" -BattlegroundBFG::BattlegroundBFG() +BattlegroundBFG::BattlegroundBFG(BattlegroundTemplate const* battlegroundTemplate) : Battleground(battlegroundTemplate) { } diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundBFG.h b/src/server/game/Battlegrounds/Zones/BattlegroundBFG.h index 36ab6a85909..03864646df2 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundBFG.h +++ b/src/server/game/Battlegrounds/Zones/BattlegroundBFG.h @@ -66,7 +66,7 @@ class BattlegroundBFGScore final : public BattlegroundScore class BattlegroundBFG : public Battleground { public: - BattlegroundBFG(); + BattlegroundBFG(BattlegroundTemplate const* battlegroundTemplate); ~BattlegroundBFG(); }; diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundDS.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundDS.cpp index 9e719137006..e5bc13db919 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundDS.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundDS.cpp @@ -22,7 +22,7 @@ #include "Random.h" #include "WorldStatePackets.h" -BattlegroundDS::BattlegroundDS() +BattlegroundDS::BattlegroundDS(BattlegroundTemplate const* battlegroundTemplate) : Arena(battlegroundTemplate) { BgObjects.resize(BG_DS_OBJECT_MAX); BgCreatures.resize(BG_DS_NPC_MAX); diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundDS.h b/src/server/game/Battlegrounds/Zones/BattlegroundDS.h index 0884f47bcb4..d151548f21d 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundDS.h +++ b/src/server/game/Battlegrounds/Zones/BattlegroundDS.h @@ -91,7 +91,7 @@ enum BattlegroundDSEvents class BattlegroundDS : public Arena { public: - BattlegroundDS(); + BattlegroundDS(BattlegroundTemplate const* battlegroundTemplate); /* inherited from BattlegroundClass */ void StartingEventCloseDoors() override; diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundEY.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundEY.cpp index 9cf74c56dd9..476daf5db21 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundEY.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundEY.cpp @@ -38,7 +38,7 @@ uint32 BG_EY_HonorScoreTicks[BG_HONOR_MODE_NUM] = 160 // holiday }; -BattlegroundEY::BattlegroundEY() +BattlegroundEY::BattlegroundEY(BattlegroundTemplate const* battlegroundTemplate) : Battleground(battlegroundTemplate) { m_BuffChange = true; BgObjects.resize(BG_EY_OBJECT_MAX); diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundEY.h b/src/server/game/Battlegrounds/Zones/BattlegroundEY.h index 3cd88f6c196..e1028d491dd 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundEY.h +++ b/src/server/game/Battlegrounds/Zones/BattlegroundEY.h @@ -391,7 +391,7 @@ struct BattlegroundEYScore final : public BattlegroundScore class BattlegroundEY : public Battleground { public: - BattlegroundEY(); + BattlegroundEY(BattlegroundTemplate const* battlegroundTemplate); ~BattlegroundEY(); /* inherited from BattlegroundClass */ diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundIC.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundIC.cpp index b8c28b586f8..79109ebb493 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundIC.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundIC.cpp @@ -27,7 +27,7 @@ #include "Vehicle.h" #include "WorldStatePackets.h" -BattlegroundIC::BattlegroundIC() +BattlegroundIC::BattlegroundIC(BattlegroundTemplate const* battlegroundTemplate) : Battleground(battlegroundTemplate) { BgObjects.resize(MAX_NORMAL_GAMEOBJECTS_SPAWNS + MAX_AIRSHIPS_SPAWNS + MAX_HANGAR_TELEPORTERS_SPAWNS + MAX_FORTRESS_TELEPORTERS_SPAWNS + MAX_HANGAR_TELEPORTER_EFFECTS_SPAWNS + MAX_FORTRESS_TELEPORTER_EFFECTS_SPAWNS); BgCreatures.resize(MAX_NORMAL_NPCS_SPAWNS + MAX_WORKSHOP_SPAWNS + MAX_DOCKS_SPAWNS + MAX_SPIRIT_GUIDES_SPAWNS + MAX_HANGAR_NPCS_SPAWNS); diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundIC.h b/src/server/game/Battlegrounds/Zones/BattlegroundIC.h index d8bba7e761a..05b37f9c246 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundIC.h +++ b/src/server/game/Battlegrounds/Zones/BattlegroundIC.h @@ -954,7 +954,7 @@ struct BattlegroundICScore final : public BattlegroundScore class BattlegroundIC : public Battleground { public: - BattlegroundIC(); + BattlegroundIC(BattlegroundTemplate const* battlegroundTemplate); ~BattlegroundIC(); /* inherited from BattlegroundClass */ diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundNA.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundNA.cpp index 91fdf22b608..846578dfc98 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundNA.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundNA.cpp @@ -20,7 +20,7 @@ #include "Player.h" #include "WorldStatePackets.h" -BattlegroundNA::BattlegroundNA() +BattlegroundNA::BattlegroundNA(BattlegroundTemplate const* battlegroundTemplate) : Arena(battlegroundTemplate) { BgObjects.resize(BG_NA_OBJECT_MAX); } diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundNA.h b/src/server/game/Battlegrounds/Zones/BattlegroundNA.h index 0d18b4fbfd4..187623a2dd7 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundNA.h +++ b/src/server/game/Battlegrounds/Zones/BattlegroundNA.h @@ -43,7 +43,7 @@ enum BattlegroundNAGameObjects class BattlegroundNA : public Arena { public: - BattlegroundNA(); + BattlegroundNA(BattlegroundTemplate const* battlegroundTemplate); /* inherited from BattlegroundClass */ void StartingEventCloseDoors() override; diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundRL.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundRL.cpp index 0a65f4736d8..4b657a69b11 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundRL.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundRL.cpp @@ -20,7 +20,7 @@ #include "Player.h" #include "WorldStatePackets.h" -BattlegroundRL::BattlegroundRL() +BattlegroundRL::BattlegroundRL(BattlegroundTemplate const* battlegroundTemplate) : Arena(battlegroundTemplate) { BgObjects.resize(BG_RL_OBJECT_MAX); } diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundRL.h b/src/server/game/Battlegrounds/Zones/BattlegroundRL.h index cc49535afef..5fcb42853e5 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundRL.h +++ b/src/server/game/Battlegrounds/Zones/BattlegroundRL.h @@ -39,7 +39,7 @@ enum BattlegroundRLGameObjects class BattlegroundRL : public Arena { public: - BattlegroundRL(); + BattlegroundRL(BattlegroundTemplate const* battlegroundTemplate); /* inherited from BattlegroundClass */ void FillInitialWorldStates(WorldPackets::WorldState::InitWorldStates& packet) override; diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundRV.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundRV.cpp index c7c29fcc986..c927f4109d3 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundRV.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundRV.cpp @@ -22,7 +22,7 @@ #include "Player.h" #include "WorldStatePackets.h" -BattlegroundRV::BattlegroundRV() +BattlegroundRV::BattlegroundRV(BattlegroundTemplate const* battlegroundTemplate) : Arena(battlegroundTemplate) { BgObjects.resize(BG_RV_OBJECT_MAX); diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundRV.h b/src/server/game/Battlegrounds/Zones/BattlegroundRV.h index a2f2cf26553..ff1c1f2da0e 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundRV.h +++ b/src/server/game/Battlegrounds/Zones/BattlegroundRV.h @@ -92,7 +92,7 @@ enum BattlegroundRVData class BattlegroundRV : public Arena { public: - BattlegroundRV(); + BattlegroundRV(BattlegroundTemplate const* battlegroundTemplate); /* inherited from BattlegroundClass */ void StartingEventOpenDoors() override; diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundSA.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundSA.cpp index 0abb08afd0f..3bd0712b39f 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundSA.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundSA.cpp @@ -30,7 +30,7 @@ #include "UpdateData.h" #include "WorldStatePackets.h" -BattlegroundSA::BattlegroundSA() +BattlegroundSA::BattlegroundSA(BattlegroundTemplate const* battlegroundTemplate) : Battleground(battlegroundTemplate) { StartMessageIds[BG_STARTING_EVENT_FOURTH] = 0; // handle by Kanrethad diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundSA.h b/src/server/game/Battlegrounds/Zones/BattlegroundSA.h index 429b601d725..8b2e0a19659 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundSA.h +++ b/src/server/game/Battlegrounds/Zones/BattlegroundSA.h @@ -564,7 +564,7 @@ struct BattlegroundSAScore final : public BattlegroundScore class BattlegroundSA : public Battleground { public: - BattlegroundSA(); + BattlegroundSA(BattlegroundTemplate const* battlegroundTemplate); ~BattlegroundSA(); /** diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundTP.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundTP.cpp index dfd3ba2f79a..8cbdd141c5d 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundTP.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundTP.cpp @@ -17,7 +17,7 @@ #include "BattlegroundTP.h" -BattlegroundTP::BattlegroundTP() +BattlegroundTP::BattlegroundTP(BattlegroundTemplate const* battlegroundTemplate) : Battleground(battlegroundTemplate) { } diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundTP.h b/src/server/game/Battlegrounds/Zones/BattlegroundTP.h index 642a5e4039b..fbd4ed8d910 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundTP.h +++ b/src/server/game/Battlegrounds/Zones/BattlegroundTP.h @@ -66,7 +66,7 @@ class BattlegroundTPScore final : public BattlegroundScore class BattlegroundTP : public Battleground { public: - BattlegroundTP(); + BattlegroundTP(BattlegroundTemplate const* battlegroundTemplate); ~BattlegroundTP(); }; diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundWS.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundWS.cpp index 96f9fef0297..30298d78a0d 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundWS.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundWS.cpp @@ -43,7 +43,7 @@ uint32 BG_WSG_Honor[BG_HONOR_MODE_NUM][BG_WSG_REWARD_NUM] = {60, 40, 80} // holiday }; -BattlegroundWS::BattlegroundWS() +BattlegroundWS::BattlegroundWS(BattlegroundTemplate const* battlegroundTemplate) : Battleground(battlegroundTemplate) { BgObjects.resize(BG_WS_OBJECT_MAX); BgCreatures.resize(BG_CREATURES_MAX_WS); diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundWS.h b/src/server/game/Battlegrounds/Zones/BattlegroundWS.h index 427690aa69f..d40f185240d 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundWS.h +++ b/src/server/game/Battlegrounds/Zones/BattlegroundWS.h @@ -211,7 +211,7 @@ class BattlegroundWS : public Battleground { public: /* Construction */ - BattlegroundWS(); + BattlegroundWS(BattlegroundTemplate const* battlegroundTemplate); ~BattlegroundWS(); /* inherited from BattlegroundClass */ diff --git a/src/server/game/DataStores/DB2Stores.cpp b/src/server/game/DataStores/DB2Stores.cpp index c9defdcc578..369de7d0b0f 100644 --- a/src/server/game/DataStores/DB2Stores.cpp +++ b/src/server/game/DataStores/DB2Stores.cpp @@ -837,6 +837,20 @@ void DB2Manager::LoadStores(std::string const& dataPath, uint32 defaultLocale) for (AzeriteUnlockMappingEntry const* azeriteUnlockMapping : sAzeriteUnlockMappingStore) azeriteUnlockMappings[azeriteUnlockMapping->AzeriteUnlockMappingSetID].push_back(azeriteUnlockMapping); + for (BattlemasterListEntry const* battlemaster : sBattlemasterListStore) + { + if (battlemaster->MaxLevel < battlemaster->MinLevel) + { + TC_LOG_ERROR("db2.hotfix.battlemaster_list", "Battlemaster (%u) contains bad values for MinLevel (%u) and MaxLevel (%u). Swapping values.", battlemaster->ID, battlemaster->MinLevel, battlemaster->MaxLevel); + std::swap(*(int8*)&battlemaster->MaxLevel, *(int8*)&battlemaster->MinLevel); + } + if (battlemaster->MaxPlayers < battlemaster->MinPlayers) + { + TC_LOG_ERROR("db2.hotfix.battlemaster_list", "Battlemaster (%u) contains bad values for MinPlayers (%u) and MaxPlayers (%u). Swapping values.", battlemaster->ID, battlemaster->MinPlayers, battlemaster->MaxPlayers); + std::swap(*(int8*)&battlemaster->MaxPlayers, *(int8*)&battlemaster->MinPlayers); + } + } + ASSERT(BATTLE_PET_SPECIES_MAX_ID >= sBattlePetSpeciesStore.GetNumRows(), "BATTLE_PET_SPECIES_MAX_ID (%d) must be equal to or greater than %u", BATTLE_PET_SPECIES_MAX_ID, sBattlePetSpeciesStore.GetNumRows()); |