aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Globals/ObjectMgr.cpp
diff options
context:
space:
mode:
authorMeji <alvaro.megias@outlook.com>2024-05-23 21:48:41 +0200
committerGitHub <noreply@github.com>2024-05-23 21:48:41 +0200
commite51670741023a7ea6309c16c9233848da49db1fa (patch)
tree813633c55d213c1e85bbcf4173c6d2680b6280f1 /src/server/game/Globals/ObjectMgr.cpp
parent3e1672f5d4f47b178993da775654c42f20426450 (diff)
Core/Creatures: Check fallback difficulty data for creature static flags override (#29992)
Diffstat (limited to 'src/server/game/Globals/ObjectMgr.cpp')
-rw-r--r--src/server/game/Globals/ObjectMgr.cpp21
1 files changed, 17 insertions, 4 deletions
diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp
index bccf1d057be..9f8ffeb4d8e 100644
--- a/src/server/game/Globals/ObjectMgr.cpp
+++ b/src/server/game/Globals/ObjectMgr.cpp
@@ -10722,7 +10722,16 @@ JumpChargeParams const* ObjectMgr::GetJumpChargeParams(int32 id) const
CreatureStaticFlagsOverride const* ObjectMgr::GetCreatureStaticFlagsOverride(ObjectGuid::LowType spawnId, Difficulty difficultyId) const
{
- return Trinity::Containers::MapGetValuePtr(_creatureStaticFlagsOverrideStore, std::make_pair(spawnId, difficultyId));
+ CreatureStaticFlagsOverride const* staticFlagsOverride = Trinity::Containers::MapGetValuePtr(_creatureStaticFlagsOverrideStore, std::make_pair(spawnId, difficultyId));
+ if (staticFlagsOverride)
+ return staticFlagsOverride;
+
+ // If there is no data for the difficulty, try to get data for the fallback difficulty
+ DifficultyEntry const* difficultyEntry = sDifficultyStore.LookupEntry(difficultyId);
+ if (difficultyEntry)
+ return GetCreatureStaticFlagsOverride(spawnId, Difficulty(difficultyEntry->FallbackDifficultyID));
+
+ return nullptr;
}
void ObjectMgr::LoadGameObjectQuestItems()
@@ -10889,10 +10898,14 @@ void ObjectMgr::LoadCreatureStaticFlagsOverride()
continue;
}
- if (std::find(creatureData->spawnDifficulties.begin(), creatureData->spawnDifficulties.end(), difficultyId) == creatureData->spawnDifficulties.end())
+ // DIFFICULTY_NONE is always a valid fallback
+ if (difficultyId != DIFFICULTY_NONE)
{
- TC_LOG_ERROR("sql.sql", "Table `creature_static_flags_override` has data for a creature that is not available for the specified DifficultyId (SpawnId: {}, DifficultyId: {}), skipped", spawnId, difficultyId);
- continue;
+ if (std::find(creatureData->spawnDifficulties.begin(), creatureData->spawnDifficulties.end(), difficultyId) == creatureData->spawnDifficulties.end())
+ {
+ TC_LOG_ERROR("sql.sql", "Table `creature_static_flags_override` has data for a creature that is not available for the specified DifficultyId (SpawnId: {}, DifficultyId: {}), skipped", spawnId, difficultyId);
+ continue;
+ }
}
CreatureStaticFlagsOverride& staticFlagsOverride = _creatureStaticFlagsOverrideStore[std::make_pair(spawnId, difficultyId)];