aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Globals/ObjectMgr.cpp
diff options
context:
space:
mode:
authorJeremy <Golrag@users.noreply.github.com>2024-03-27 18:55:44 +0100
committerGitHub <noreply@github.com>2024-03-27 18:55:44 +0100
commit1f855ef56336c6a7fd74898e9c9beba77828c69b (patch)
treeecf633a2a1c04ca4832f51777e4f9f4c3a1ea4cc /src/server/game/Globals/ObjectMgr.cpp
parent5c4b1ace41b417539ed0abfec7475c23765e81c9 (diff)
Core/GameObjects: Implement destructible_hitpoint table to store health info about destructible buildings (#29836)
Diffstat (limited to 'src/server/game/Globals/ObjectMgr.cpp')
-rw-r--r--src/server/game/Globals/ObjectMgr.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp
index ab693e0143b..0a60ee9719e 100644
--- a/src/server/game/Globals/ObjectMgr.cpp
+++ b/src/server/game/Globals/ObjectMgr.cpp
@@ -7480,6 +7480,33 @@ void ObjectMgr::LoadGameObjectLocales()
TC_LOG_INFO("server.loading", ">> Loaded {} gameobject_template_locale strings in {} ms", uint32(_gameObjectLocaleStore.size()), GetMSTimeDiffToNow(oldMSTime));
}
+void ObjectMgr::LoadDestructibleHitpoints()
+{
+ uint32 oldMSTime = getMSTime();
+
+ _destructibleHitpointStore.clear(); // need for reload case
+
+ // 0 1 2
+ QueryResult result = WorldDatabase.Query("SELECT Id, IntactNumHits, DamagedNumHits FROM destructible_hitpoint");
+ if (!result)
+ return;
+
+ do
+ {
+ Field* fields = result->Fetch();
+
+ uint32 id = fields[0].GetUInt32();
+
+ DestructibleHitpoint& data = _destructibleHitpointStore[id];
+ data.Id = id;
+ data.IntactNumHits = fields[1].GetUInt32();
+ data.DamagedNumHits = fields[2].GetUInt32();
+
+ } while (result->NextRow());
+
+ TC_LOG_INFO("server.loading", ">> Loaded {} destructible_hitpoint records in {} ms", _destructibleHitpointStore.size(), GetMSTimeDiffToNow(oldMSTime));
+}
+
inline void CheckGOLockId(GameObjectTemplate const* goInfo, uint32 dataN, uint32 N)
{
if (sLockStore.LookupEntry(dataN))
@@ -7741,6 +7768,10 @@ void ObjectMgr::LoadGameObjectTemplate()
got.barberChair.SitAnimKit = 0;
}
break;
+ case GAMEOBJECT_TYPE_DESTRUCTIBLE_BUILDING:
+ if (got.destructibleBuilding.HealthRec && !GetDestructibleHitpoint(got.destructibleBuilding.HealthRec))
+ TC_LOG_ERROR("sql.sql", "GameObject (Entry: {}) Has non existing Destructible Hitpoint Record {}.", entry, got.destructibleBuilding.HealthRec);
+ break;
case GAMEOBJECT_TYPE_GARRISON_BUILDING:
if (uint32 transportMap = got.garrisonBuilding.SpawnMap)
_transportMaps.insert(transportMap);
@@ -10452,6 +10483,11 @@ TerrainSwapInfo const* ObjectMgr::GetTerrainSwapInfo(uint32 terrainSwapId) const
return Trinity::Containers::MapGetValuePtr(_terrainSwapInfoById, terrainSwapId);
}
+DestructibleHitpoint const* ObjectMgr::GetDestructibleHitpoint(uint32 entry) const
+{
+ return Trinity::Containers::MapGetValuePtr(_destructibleHitpointStore, entry);
+}
+
GameObjectTemplate const* ObjectMgr::GetGameObjectTemplate(uint32 entry) const
{
return Trinity::Containers::MapGetValuePtr(_gameObjectTemplateStore, entry);