diff options
Diffstat (limited to 'src/server/game')
-rw-r--r-- | src/server/game/Battlegrounds/BattlegroundMgr.cpp | 34 | ||||
-rw-r--r-- | src/server/game/Battlegrounds/BattlegroundMgr.h | 9 | ||||
-rw-r--r-- | src/server/game/Conditions/ConditionMgr.cpp | 2 | ||||
-rw-r--r-- | src/server/game/Entities/AreaTrigger/AreaTrigger.cpp | 2 | ||||
-rw-r--r-- | src/server/game/Handlers/BattleGroundHandler.cpp | 12 | ||||
-rw-r--r-- | src/server/game/Maps/TerrainMgr.cpp | 12 | ||||
-rw-r--r-- | src/server/game/Movement/PathGenerator.cpp | 3 | ||||
-rw-r--r-- | src/server/game/World/World.cpp | 5 |
8 files changed, 58 insertions, 21 deletions
diff --git a/src/server/game/Battlegrounds/BattlegroundMgr.cpp b/src/server/game/Battlegrounds/BattlegroundMgr.cpp index 2739854926b..b6716c248ae 100644 --- a/src/server/game/Battlegrounds/BattlegroundMgr.cpp +++ b/src/server/game/Battlegrounds/BattlegroundMgr.cpp @@ -32,6 +32,7 @@ #include "Player.h" #include "SharedDefines.h" #include "World.h" +#include "WorldSession.h" bool BattlegroundTemplate::IsArena() const { @@ -64,7 +65,7 @@ uint8 BattlegroundTemplate::GetMaxLevel() const BattlegroundMgr::BattlegroundMgr() : m_NextRatedArenaUpdate(sWorld->getIntConfig(CONFIG_ARENA_RATED_UPDATE_TIMER)), - m_UpdateTimer(0), m_ArenaTesting(false), m_Testing(false) + m_UpdateTimer(0), m_ArenaTesting(0), m_Testing(false) { } BattlegroundMgr::~BattlegroundMgr() @@ -300,6 +301,15 @@ BattlegroundScriptTemplate const* BattlegroundMgr::FindBattlegroundScriptTemplat return Trinity::Containers::MapGetValuePtr(_battlegroundScriptTemplates, { mapId, BATTLEGROUND_TYPE_NONE }); } +void BattlegroundMgr::QueuePlayerForArena(Player const* player, uint8 teamSize, uint8 roles) +{ + WorldPackets::Battleground::BattlemasterJoinArena packet((WorldPacket(CMSG_BATTLEMASTER_JOIN_ARENA))); + packet.TeamSizeIndex = teamSize; + packet.Roles = roles; + + player->GetSession()->HandleBattlemasterJoinArena(packet); +} + uint32 BattlegroundMgr::CreateClientVisibleInstanceId(BattlegroundTypeId bgTypeId, BattlegroundBracketId bracket_id) { if (IsArenaType(bgTypeId)) @@ -507,10 +517,23 @@ void BattlegroundMgr::ToggleTesting() sWorld->SendWorldText(m_Testing ? LANG_DEBUG_BG_ON : LANG_DEBUG_BG_OFF); } -void BattlegroundMgr::ToggleArenaTesting() +bool BattlegroundMgr::ToggleArenaTesting(uint32 battlemasterListId) { - m_ArenaTesting = !m_ArenaTesting; - sWorld->SendWorldText(m_ArenaTesting ? LANG_DEBUG_ARENA_ON : LANG_DEBUG_ARENA_OFF); + if (battlemasterListId != 0) + { + BattlegroundTemplate const* bgTemplate = GetBattlegroundTemplateByTypeId(static_cast<BattlegroundTypeId>(battlemasterListId)); + if (!bgTemplate) + return false; + + if (!bgTemplate->IsArena()) + return false; + } + + if (m_ArenaTesting != battlemasterListId) + sWorld->SendWorldText((battlemasterListId != 0) ? LANG_DEBUG_ARENA_ON : LANG_DEBUG_ARENA_OFF); + + m_ArenaTesting = battlemasterListId; + return true; } bool BattlegroundMgr::IsValidQueueId(BattlegroundQueueTypeId bgQueueTypeId) @@ -686,6 +709,9 @@ BattlegroundTypeId BattlegroundMgr::GetRandomBG(BattlegroundTypeId bgTypeId) { if (BattlegroundTemplate const* bgTemplate = GetBattlegroundTemplateByTypeId(bgTypeId)) { + if (bgTemplate->IsArena() && isArenaTesting()) + return static_cast<BattlegroundTypeId>(m_ArenaTesting); + std::vector<BattlegroundTemplate const*> ids; ids.reserve(bgTemplate->MapIDs.size()); for (int32 mapId : bgTemplate->MapIDs) diff --git a/src/server/game/Battlegrounds/BattlegroundMgr.h b/src/server/game/Battlegrounds/BattlegroundMgr.h index b31b0193af0..8aa341cbca8 100644 --- a/src/server/game/Battlegrounds/BattlegroundMgr.h +++ b/src/server/game/Battlegrounds/BattlegroundMgr.h @@ -126,10 +126,11 @@ class TC_GAME_API BattlegroundMgr void ScheduleQueueUpdate(uint32 arenaMatchmakerRating, BattlegroundQueueTypeId bgQueueTypeId, BattlegroundBracketId bracket_id); uint32 GetPrematureFinishTime() const; - void ToggleArenaTesting(); + // Return whether toggling was successful. In case of a non-existing battlemasterListId, or this battlemasterListId is not an arena, this would return false. + bool ToggleArenaTesting(uint32 battlemasterListId); void ToggleTesting(); - bool isArenaTesting() const { return m_ArenaTesting; } + bool isArenaTesting() const { return m_ArenaTesting != 0; } bool isTesting() const { return m_Testing; } static bool IsRandomBattleground(uint32 battlemasterListId); @@ -162,6 +163,8 @@ class TC_GAME_API BattlegroundMgr void LoadBattlegroundScriptTemplate(); BattlegroundScriptTemplate const* FindBattlegroundScriptTemplate(uint32 mapId, BattlegroundTypeId bgTypeId) const; + static void QueuePlayerForArena(Player const* player, uint8 teamSize, uint8 roles); + private: uint32 CreateClientVisibleInstanceId(BattlegroundTypeId bgTypeId, BattlegroundBracketId bracket_id); static bool IsArenaType(BattlegroundTypeId bgTypeId); @@ -185,7 +188,7 @@ class TC_GAME_API BattlegroundMgr std::vector<ScheduledQueueUpdate> m_QueueUpdateScheduler; uint32 m_NextRatedArenaUpdate; uint32 m_UpdateTimer; - bool m_ArenaTesting; + uint32 m_ArenaTesting; bool m_Testing; BattleMastersMap mBattleMastersMap; diff --git a/src/server/game/Conditions/ConditionMgr.cpp b/src/server/game/Conditions/ConditionMgr.cpp index fcf78441463..89012688d26 100644 --- a/src/server/game/Conditions/ConditionMgr.cpp +++ b/src/server/game/Conditions/ConditionMgr.cpp @@ -103,7 +103,7 @@ char const* const ConditionMgr::StaticSourceTypeData[CONDITION_SOURCE_TYPE_MAX_D ConditionMgr::ConditionTypeInfo const ConditionMgr::StaticConditionTypeData[CONDITION_MAX] = { { .Name = "None", .HasConditionValue1 = false, .HasConditionValue2 = false, .HasConditionValue3 = false, .HasConditionStringValue1 = false }, - { .Name = "Aura", .HasConditionValue1 = true, .HasConditionValue2 = true, .HasConditionValue3 = true, .HasConditionStringValue1 = false }, + { .Name = "Aura", .HasConditionValue1 = true, .HasConditionValue2 = true, .HasConditionValue3 = false, .HasConditionStringValue1 = false }, { .Name = "Item Stored", .HasConditionValue1 = true, .HasConditionValue2 = true, .HasConditionValue3 = true, .HasConditionStringValue1 = false }, { .Name = "Item Equipped", .HasConditionValue1 = true, .HasConditionValue2 = false, .HasConditionValue3 = false, .HasConditionStringValue1 = false }, { .Name = "Zone", .HasConditionValue1 = true, .HasConditionValue2 = false, .HasConditionValue3 = false, .HasConditionStringValue1 = false }, diff --git a/src/server/game/Entities/AreaTrigger/AreaTrigger.cpp b/src/server/game/Entities/AreaTrigger/AreaTrigger.cpp index 829aa4d4816..74aa8596a58 100644 --- a/src/server/game/Entities/AreaTrigger/AreaTrigger.cpp +++ b/src/server/game/Entities/AreaTrigger/AreaTrigger.cpp @@ -178,7 +178,7 @@ bool AreaTrigger::Create(AreaTriggerCreatePropertiesId areaTriggerCreateProperti SetScaleCurve(areaTriggerData.ModifyValue(&UF::AreaTriggerData::ExtraScaleCurve), 1.0f); - if (caster) + if (caster && spellInfo) { if (Player const* modOwner = caster->GetSpellModOwner()) { diff --git a/src/server/game/Handlers/BattleGroundHandler.cpp b/src/server/game/Handlers/BattleGroundHandler.cpp index 8fb5a150793..e78a52042b9 100644 --- a/src/server/game/Handlers/BattleGroundHandler.cpp +++ b/src/server/game/Handlers/BattleGroundHandler.cpp @@ -540,9 +540,16 @@ void WorldSession::HandleBattlemasterJoinArena(WorldPackets::Battleground::Battl return; Group* grp = _player->GetGroup(); + if (!grp) + { + grp = new Group(); + grp->Create(_player); + } + // no group found, error if (!grp) return; + if (grp->GetLeaderGUID() != _player->GetGUID()) return; @@ -559,7 +566,10 @@ void WorldSession::HandleBattlemasterJoinArena(WorldPackets::Battleground::Battl GroupQueueInfo* ginfo = nullptr; ObjectGuid errorGuid; - GroupJoinBattlegroundResult err = grp->CanJoinBattlegroundQueue(bgTemplate, bgQueueTypeId, arenatype, arenatype, true, packet.TeamSizeIndex, errorGuid); + GroupJoinBattlegroundResult err = ERR_BATTLEGROUND_NONE; + if (!sBattlegroundMgr->isArenaTesting()) + err = grp->CanJoinBattlegroundQueue(bgTemplate, bgQueueTypeId, arenatype, arenatype, true, packet.TeamSizeIndex, errorGuid); + if (!err) { TC_LOG_DEBUG("bg.battleground", "Battleground: arena team id {}, leader {} queued with matchmaker rating {} for type {}", _player->GetArenaTeamId(packet.TeamSizeIndex), _player->GetName(), matchmakerRating, arenatype); diff --git a/src/server/game/Maps/TerrainMgr.cpp b/src/server/game/Maps/TerrainMgr.cpp index 2e6d8e184b9..65655e6e84b 100644 --- a/src/server/game/Maps/TerrainMgr.cpp +++ b/src/server/game/Maps/TerrainMgr.cpp @@ -22,7 +22,7 @@ #include "GridMap.h" #include "Log.h" #include "Memory.h" -#include "MMapFactory.h" +#include "MMapManager.h" #include "PhasingHandler.h" #include "Random.h" #include "ScriptMgr.h" @@ -39,7 +39,7 @@ TerrainInfo::TerrainInfo(uint32 mapId) : _mapId(mapId), _parentTerrain(nullptr), TerrainInfo::~TerrainInfo() { VMAP::VMapFactory::createOrGetVMapManager()->unloadMap(GetId()); - MMAP::MMapFactory::createOrGetMMapManager()->unloadMap(GetId()); + MMAP::MMapManager::instance()->unloadMap(GetId()); } char const* TerrainInfo::GetMapName() const @@ -185,7 +185,7 @@ void TerrainInfo::LoadMapAndVMapImpl(int32 gx, int32 gy) void TerrainInfo::LoadMMapInstanceImpl(uint32 mapId, uint32 instanceId) { - MMAP::MMapFactory::createOrGetMMapManager()->loadMapInstance(sWorld->GetDataPath(), _mapId, mapId, instanceId); + MMAP::MMapManager::instance()->loadMapInstance(sWorld->GetDataPath(), _mapId, mapId, instanceId); } void TerrainInfo::LoadMap(int32 gx, int32 gy) @@ -239,7 +239,7 @@ void TerrainInfo::LoadMMap(int32 gx, int32 gy) if (!DisableMgr::IsPathfindingEnabled(GetId())) return; - switch (MMAP::LoadResult mmapLoadResult = MMAP::MMapFactory::createOrGetMMapManager()->loadMap(sWorld->GetDataPath(), GetId(), gx, gy)) + switch (MMAP::LoadResult mmapLoadResult = MMAP::MMapManager::instance()->loadMap(sWorld->GetDataPath(), GetId(), gx, gy)) { case MMAP::LoadResult::Success: TC_LOG_DEBUG("mmaps.tiles", "MMAP loaded name:{}, id:{}, x:{}, y:{} (mmap rep.: x:{}, y:{})", GetMapName(), GetId(), gx, gy, gx, gy); @@ -274,7 +274,7 @@ void TerrainInfo::UnloadMapImpl(int32 gx, int32 gy) { _gridMap[gx][gy] = nullptr; VMAP::VMapFactory::createOrGetVMapManager()->unloadMap(GetId(), gx, gy); - MMAP::MMapFactory::createOrGetMMapManager()->unloadMap(GetId(), gx, gy); + MMAP::MMapManager::instance()->unloadMap(GetId(), gx, gy); for (std::shared_ptr<TerrainInfo> const& childTerrain : _childTerrain) childTerrain->UnloadMapImpl(gx, gy); @@ -284,7 +284,7 @@ void TerrainInfo::UnloadMapImpl(int32 gx, int32 gy) void TerrainInfo::UnloadMMapInstanceImpl(uint32 mapId, uint32 instanceId) { - MMAP::MMapFactory::createOrGetMMapManager()->unloadMapInstance(_mapId, mapId, instanceId); + MMAP::MMapManager::instance()->unloadMapInstance(_mapId, mapId, instanceId); } GridMap* TerrainInfo::GetGrid(uint32 mapId, float x, float y, bool loadIfMissing /*= true*/) diff --git a/src/server/game/Movement/PathGenerator.cpp b/src/server/game/Movement/PathGenerator.cpp index 1d8285822ec..49f2f0150fa 100644 --- a/src/server/game/Movement/PathGenerator.cpp +++ b/src/server/game/Movement/PathGenerator.cpp @@ -22,7 +22,6 @@ #include "DisableMgr.h" #include "G3DPosition.hpp" #include "Log.h" -#include "MMapFactory.h" #include "MMapManager.h" #include "Map.h" #include "Metric.h" @@ -42,7 +41,7 @@ PathGenerator::PathGenerator(WorldObject const* owner) : uint32 mapId = PhasingHandler::GetTerrainMapId(_source->GetPhaseShift(), _source->GetMapId(), _source->GetMap()->GetTerrain(), _startPosition.x, _startPosition.y); if (DisableMgr::IsPathfindingEnabled(_source->GetMapId())) { - MMAP::MMapManager* mmap = MMAP::MMapFactory::createOrGetMMapManager(); + MMAP::MMapManager* mmap = MMAP::MMapManager::instance(); _navMeshQuery = mmap->GetNavMeshQuery(mapId, _source->GetMapId(), _source->GetInstanceId()); _navMesh = _navMeshQuery ? _navMeshQuery->getAttachedNavMesh() : mmap->GetNavMesh(mapId); } diff --git a/src/server/game/World/World.cpp b/src/server/game/World/World.cpp index 2776b10628e..d4436a76e96 100644 --- a/src/server/game/World/World.cpp +++ b/src/server/game/World/World.cpp @@ -69,7 +69,7 @@ #include "LootItemStorage.h" #include "LootMgr.h" #include "M2Stores.h" -#include "MMapFactory.h" +#include "MMapManager.h" #include "Map.h" #include "MapManager.h" #include "MapUtils.h" @@ -188,7 +188,6 @@ World::~World() delete command; VMAP::VMapFactory::clear(); - MMAP::MMapFactory::clear(); /// @todo free addSessQueue } @@ -1356,7 +1355,7 @@ bool World::SetInitialWorldSettings() vmmgr2->InitializeThreadUnsafe(mapData); - MMAP::MMapManager* mmmgr = MMAP::MMapFactory::createOrGetMMapManager(); + MMAP::MMapManager* mmmgr = MMAP::MMapManager::instance(); mmmgr->InitializeThreadUnsafe(mapData); ///- Initialize static helper structures |