Core/Maps: Fixed MapDifficulty lookup for instances that do not have a selectable difficulty on interface (40 mans)
Closes #14366
This commit is contained in:
@@ -883,9 +883,9 @@ void Map2ZoneCoordinates(float& x, float& y, uint32 zone)
|
||||
std::swap(x, y); // client have map coords swapped
|
||||
}
|
||||
|
||||
MapDifficultyEntry const* GetDefaultMapDifficulty(uint32 mapID)
|
||||
MapDifficultyEntry const* GetDefaultMapDifficulty(uint32 mapId, Difficulty* difficulty /*= nullptr*/)
|
||||
{
|
||||
auto itr = sMapDifficultyMap.find(mapID);
|
||||
auto itr = sMapDifficultyMap.find(mapId);
|
||||
if (itr == sMapDifficultyMap.end())
|
||||
return nullptr;
|
||||
|
||||
@@ -894,14 +894,22 @@ MapDifficultyEntry const* GetDefaultMapDifficulty(uint32 mapID)
|
||||
|
||||
for (auto& p : itr->second)
|
||||
{
|
||||
DifficultyEntry const* difficulty = sDifficultyStore.LookupEntry(p.first);
|
||||
if (!difficulty)
|
||||
DifficultyEntry const* difficultyEntry = sDifficultyStore.LookupEntry(p.first);
|
||||
if (!difficultyEntry)
|
||||
continue;
|
||||
|
||||
if (difficulty->Flags & DIFFICULTY_FLAG_DEFAULT)
|
||||
if (difficultyEntry->Flags & DIFFICULTY_FLAG_DEFAULT)
|
||||
{
|
||||
if (difficulty)
|
||||
*difficulty = Difficulty(p.first);
|
||||
|
||||
return p.second;
|
||||
}
|
||||
}
|
||||
|
||||
if (difficulty)
|
||||
*difficulty = Difficulty(itr->second.begin()->first);
|
||||
|
||||
return itr->second.begin()->second;
|
||||
}
|
||||
|
||||
@@ -922,7 +930,7 @@ MapDifficultyEntry const* GetDownscaledMapDifficultyData(uint32 mapId, Difficult
|
||||
{
|
||||
DifficultyEntry const* diffEntry = sDifficultyStore.LookupEntry(difficulty);
|
||||
if (!diffEntry)
|
||||
return GetDefaultMapDifficulty(mapId);
|
||||
return GetDefaultMapDifficulty(mapId, &difficulty);
|
||||
|
||||
uint32 tmpDiff = difficulty;
|
||||
MapDifficultyEntry const* mapDiff = GetMapDifficultyData(mapId, Difficulty(tmpDiff));
|
||||
@@ -931,7 +939,7 @@ MapDifficultyEntry const* GetDownscaledMapDifficultyData(uint32 mapId, Difficult
|
||||
tmpDiff = diffEntry->FallbackDifficultyID;
|
||||
diffEntry = sDifficultyStore.LookupEntry(tmpDiff);
|
||||
if (!diffEntry)
|
||||
return GetDefaultMapDifficulty(mapId);
|
||||
return GetDefaultMapDifficulty(mapId, &difficulty);
|
||||
|
||||
// pull new data
|
||||
mapDiff = GetMapDifficultyData(mapId, Difficulty(tmpDiff)); // we are 10 normal or 25 normal
|
||||
|
||||
@@ -66,7 +66,7 @@ void Zone2MapCoordinates(float &x, float &y, uint32 zone);
|
||||
void Map2ZoneCoordinates(float &x, float &y, uint32 zone);
|
||||
|
||||
typedef std::unordered_map<uint32, std::unordered_map<uint32, MapDifficultyEntry const*>> MapDifficultyMap;
|
||||
MapDifficultyEntry const* GetDefaultMapDifficulty(uint32 mapID);
|
||||
MapDifficultyEntry const* GetDefaultMapDifficulty(uint32 mapId, Difficulty* difficulty = nullptr);
|
||||
MapDifficultyEntry const* GetMapDifficultyData(uint32 mapId, Difficulty difficulty);
|
||||
MapDifficultyEntry const* GetDownscaledMapDifficultyData(uint32 mapId, Difficulty &difficulty);
|
||||
|
||||
|
||||
@@ -802,7 +802,7 @@ Player::Player(WorldSession* session): Unit(true)
|
||||
m_dungeonDifficulty = DIFFICULTY_NORMAL;
|
||||
m_raidDifficulty = DIFFICULTY_NORMAL_RAID;
|
||||
m_legacyRaidDifficulty = DIFFICULTY_10_N;
|
||||
m_raidMapDifficulty = DIFFICULTY_NORMAL_RAID;
|
||||
m_prevMapDifficulty = DIFFICULTY_NORMAL_RAID;
|
||||
|
||||
m_lastPotionId = 0;
|
||||
_talentMgr = new PlayerTalentInfo();
|
||||
@@ -19990,10 +19990,10 @@ void Player::SendExplorationExperience(uint32 Area, uint32 Experience)
|
||||
GetSession()->SendPacket(WorldPackets::Misc::ExplorationExperience(Experience, Area).Write());
|
||||
}
|
||||
|
||||
void Player::SendDungeonDifficulty()
|
||||
void Player::SendDungeonDifficulty(int32 forcedDifficulty /*= -1*/)
|
||||
{
|
||||
WorldPackets::Misc::DungeonDifficultySet dungeonDifficultySet;
|
||||
dungeonDifficultySet.DifficultyID = GetDungeonDifficultyID();
|
||||
dungeonDifficultySet.DifficultyID = forcedDifficulty == -1 ? GetDungeonDifficultyID() : forcedDifficulty;
|
||||
GetSession()->SendPacket(dungeonDifficultySet.Write());
|
||||
}
|
||||
|
||||
@@ -22642,11 +22642,20 @@ void Player::SendInitialPacketsAfterAddToMap()
|
||||
|
||||
if (GetMap()->IsRaid())
|
||||
{
|
||||
DifficultyEntry const* difficulty = sDifficultyStore.AssertEntry(GetMap()->GetDifficultyID());
|
||||
SendRaidDifficulty((difficulty->Flags & DIFFICULTY_FLAG_LEGACY) != 0, GetMap()->GetDifficultyID());
|
||||
m_prevMapDifficulty = GetMap()->GetDifficultyID();
|
||||
DifficultyEntry const* difficulty = sDifficultyStore.AssertEntry(m_prevMapDifficulty);
|
||||
SendRaidDifficulty((difficulty->Flags & DIFFICULTY_FLAG_LEGACY) != 0, m_prevMapDifficulty);
|
||||
}
|
||||
else if (GetMap()->IsNonRaidDungeon())
|
||||
SendDungeonDifficulty();
|
||||
{
|
||||
m_prevMapDifficulty = GetMap()->GetDifficultyID();
|
||||
SendDungeonDifficulty(m_prevMapDifficulty);
|
||||
}
|
||||
else if (!GetMap()->Instanceable())
|
||||
{
|
||||
DifficultyEntry const* difficulty = sDifficultyStore.AssertEntry(m_prevMapDifficulty);
|
||||
SendRaidDifficulty((difficulty->Flags & DIFFICULTY_FLAG_LEGACY) != 0);
|
||||
}
|
||||
|
||||
if (_garrison)
|
||||
_garrison->SendRemoteInfo();
|
||||
|
||||
@@ -2132,7 +2132,7 @@ class Player : public Unit, public GridObject<Player>
|
||||
void SendAutoRepeatCancel(Unit* target);
|
||||
void SendExplorationExperience(uint32 Area, uint32 Experience);
|
||||
|
||||
void SendDungeonDifficulty();
|
||||
void SendDungeonDifficulty(int32 forcedDifficulty = -1);
|
||||
void SendRaidDifficulty(bool legacy, int32 forcedDifficulty = -1);
|
||||
void ResetInstances(uint8 method, bool isRaid, bool isLegacy);
|
||||
void SendResetInstanceSuccess(uint32 MapId);
|
||||
@@ -2760,7 +2760,7 @@ class Player : public Unit, public GridObject<Player>
|
||||
Difficulty m_dungeonDifficulty;
|
||||
Difficulty m_raidDifficulty;
|
||||
Difficulty m_legacyRaidDifficulty;
|
||||
Difficulty m_raidMapDifficulty;
|
||||
Difficulty m_prevMapDifficulty;
|
||||
|
||||
uint32 m_atLoginFlags;
|
||||
|
||||
|
||||
@@ -214,7 +214,7 @@ InstanceMap* MapInstanced::CreateInstance(uint32 InstanceId, InstanceSave* save,
|
||||
// some instances only have one difficulty
|
||||
GetDownscaledMapDifficultyData(GetId(), difficulty);
|
||||
|
||||
TC_LOG_DEBUG("maps", "MapInstanced::CreateInstance: %s map instance %d for %d created with difficulty %s", save?"":"new ", InstanceId, GetId(), difficulty?"heroic":"normal");
|
||||
TC_LOG_DEBUG("maps", "MapInstanced::CreateInstance: %s map instance %d for %d created with difficulty %s", save ? "" : "new ", InstanceId, GetId(), difficulty ? "heroic" : "normal");
|
||||
|
||||
InstanceMap* map = new InstanceMap(GetId(), GetGridExpiry(), InstanceId, difficulty, this);
|
||||
ASSERT(map->IsDungeon());
|
||||
|
||||
Reference in New Issue
Block a user