aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Globals
diff options
context:
space:
mode:
authorOvahlord <dreadkiller@gmx.de>2024-04-26 22:32:17 +0200
committerOvahlord <dreadkiller@gmx.de>2024-05-28 16:45:11 +0200
commitf28011735862eac1808edc14869ecda5143cc35b (patch)
tree3de0bddda94ba8feb2966a8973cd42effc604c0e /src/server/game/Globals
parent2ee8c63d9386a225a676ad9c39e7b9b00abc858a (diff)
Core/Creature: implement overriding creature static flags based on spawnId and difficultyId (#29940)
(cherry picked from commit b5ce4a66df0c76583c662056e46619c8fe98f297)
Diffstat (limited to 'src/server/game/Globals')
-rw-r--r--src/server/game/Globals/ObjectMgr.cpp66
-rw-r--r--src/server/game/Globals/ObjectMgr.h5
2 files changed, 71 insertions, 0 deletions
diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp
index cbe210594f8..d74c79c8d36 100644
--- a/src/server/game/Globals/ObjectMgr.cpp
+++ b/src/server/game/Globals/ObjectMgr.cpp
@@ -10754,6 +10754,11 @@ JumpChargeParams const* ObjectMgr::GetJumpChargeParams(int32 id) const
return Trinity::Containers::MapGetValuePtr(_jumpChargeParams, id);
}
+CreatureStaticFlagsOverride const* ObjectMgr::GetCreatureStaticFlagsOverride(ObjectGuid::LowType spawnId, Difficulty difficultyId) const
+{
+ return Trinity::Containers::MapGetValuePtr(_creatureStaticFlagsOverrideStore, std::make_pair(spawnId, difficultyId));
+}
+
void ObjectMgr::LoadGameObjectQuestItems()
{
uint32 oldMSTime = getMSTime();
@@ -10887,6 +10892,67 @@ void ObjectMgr::LoadCreatureQuestCurrencies()
TC_LOG_INFO("server.loading", ">> Loaded {} creature quest currencies in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
}
+void ObjectMgr::LoadCreatureStaticFlagsOverride()
+{
+ // reload case
+ _creatureStaticFlagsOverrideStore.clear();
+
+ uint32 oldMSTime = getMSTime();
+
+ // 0 1 2 3 4 5 6 7 8 9
+ QueryResult result = WorldDatabase.Query("SELECT SpawnId, DifficultyId, StaticFlags1, StaticFlags2, StaticFlags3, StaticFlags4, StaticFlags5, StaticFlags6, StaticFlags7, StaticFlags8 FROM creature_static_flags_override");
+
+ if (!result)
+ {
+ TC_LOG_INFO("server.loading", ">> Loaded 0 creature static flag overrides. DB table `creature_static_flags_override` is empty.");
+ return;
+ }
+
+ uint32 count = 0;
+ do
+ {
+ Field* fields = result->Fetch();
+
+ ObjectGuid::LowType spawnId = fields[0].GetUInt64();
+ Difficulty difficultyId = static_cast<Difficulty>(fields[1].GetUInt8());
+
+ CreatureData const* creatureData = GetCreatureData(spawnId);
+ if (!creatureData)
+ {
+ TC_LOG_ERROR("sql.sql", "Table `creature_static_flags_override` has data for nonexistent creature (SpawnId: {}), skipped", spawnId);
+ 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)];
+ if (!fields[2].IsNull())
+ staticFlagsOverride.StaticFlags1 = static_cast<CreatureStaticFlags>(fields[2].GetUInt32());
+ if (!fields[3].IsNull())
+ staticFlagsOverride.StaticFlags2 = static_cast<CreatureStaticFlags2>(fields[3].GetUInt32());
+ if (!fields[4].IsNull())
+ staticFlagsOverride.StaticFlags3 = static_cast<CreatureStaticFlags3>(fields[4].GetUInt32());
+ if (!fields[5].IsNull())
+ staticFlagsOverride.StaticFlags4 = static_cast<CreatureStaticFlags4>(fields[5].GetUInt32());
+ if (!fields[6].IsNull())
+ staticFlagsOverride.StaticFlags5 = static_cast<CreatureStaticFlags5>(fields[6].GetUInt32());
+ if (!fields[7].IsNull())
+ staticFlagsOverride.StaticFlags6 = static_cast<CreatureStaticFlags6>(fields[7].GetUInt32());
+ if (!fields[8].IsNull())
+ staticFlagsOverride.StaticFlags7 = static_cast<CreatureStaticFlags7>(fields[8].GetUInt32());
+ if (!fields[9].IsNull())
+ staticFlagsOverride.StaticFlags8 = static_cast<CreatureStaticFlags8>(fields[9].GetUInt32());
+
+ ++count;
+ } while (result->NextRow());
+
+ TC_LOG_INFO("server.loading", ">> Loaded {} creature static flag overrides in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
+}
+
void ObjectMgr::InitializeQueriesData(QueryDataGroup mask)
{
uint32 oldMSTime = getMSTime();
diff --git a/src/server/game/Globals/ObjectMgr.h b/src/server/game/Globals/ObjectMgr.h
index e26de428769..d373047127c 100644
--- a/src/server/game/Globals/ObjectMgr.h
+++ b/src/server/game/Globals/ObjectMgr.h
@@ -503,6 +503,7 @@ typedef std::unordered_map<uint32, EquipmentInfoContainerInternal> EquipmentInfo
typedef std::unordered_map<uint32, CreatureModelInfo> CreatureModelContainer;
typedef std::unordered_map<std::pair<uint32, Difficulty>, std::vector<uint32>> CreatureQuestItemMap;
typedef std::unordered_map<uint32, std::vector<int32>> CreatureQuestCurrenciesMap;
+typedef std::unordered_map<std::pair<ObjectGuid::LowType, Difficulty>, CreatureStaticFlagsOverride> CreatureStaticFlagsOverrideMap;
typedef std::unordered_map<uint32, DestructibleHitpoint> DestructibleHitpointContainer;
typedef std::unordered_map<uint32, GameObjectTemplate> GameObjectTemplateContainer;
typedef std::unordered_map<uint32, GameObjectTemplateAddon> GameObjectTemplateAddonContainer;
@@ -1322,6 +1323,7 @@ class TC_GAME_API ObjectMgr
void LoadGameObjectQuestItems();
void LoadCreatureQuestItems();
void LoadCreatureQuestCurrencies();
+ void LoadCreatureStaticFlagsOverride();
void LoadTempSummons();
void LoadCreatures();
void LoadLinkedRespawn();
@@ -1757,6 +1759,8 @@ class TC_GAME_API ObjectMgr
JumpChargeParams const* GetJumpChargeParams(int32 id) const;
+ CreatureStaticFlagsOverride const* GetCreatureStaticFlagsOverride(ObjectGuid::LowType spawnId, Difficulty difficultyId) const;
+
private:
// first free id for selected id type
uint32 _auctionId;
@@ -1899,6 +1903,7 @@ class TC_GAME_API ObjectMgr
GameObjectQuestItemMap _gameObjectQuestItemStore;
CreatureQuestItemMap _creatureQuestItemStore;
CreatureQuestCurrenciesMap _creatureQuestCurrenciesStore;
+ CreatureStaticFlagsOverrideMap _creatureStaticFlagsOverrideStore;
EquipmentInfoContainer _equipmentInfoStore;
LinkedRespawnContainer _linkedRespawnStore;
CreatureLocaleContainer _creatureLocaleStore;