diff --git a/src/game/Object/ObjectMgr.cpp b/src/game/Object/ObjectMgr.cpp index 9a8bbf08..1ae9805f 100644 --- a/src/game/Object/ObjectMgr.cpp +++ b/src/game/Object/ObjectMgr.cpp @@ -9071,6 +9071,58 @@ void ObjectMgr::LoadGossipMenus() { sLog.outErrorDb("Table `db_scripts [type = %d]` contains unused script, id %u.", DBS_ON_GOSSIP, *itr); } + + LoadCoreSideGossipTextIdCache(); +} + +/* + This method will send the correct return when the code calls + pPlayer->GetGossipTextId(pCreature) + Otherwise teh default +*/ +void ObjectMgr::LoadCoreSideGossipTextIdCache() +{ + m_mCacheNpcTextIdMap.clear(); + + QueryResult* result = WorldDatabase.Query("SELECT `ct`.`Entry`, " + "`gm`.`text_id` " + "FROM `creature_template` `ct` " + "LEFT JOIN (" + " SELECT " + " `entry`, MIN(`text_id`) as `text_id` " + " FROM `gossip_menu` " + " GROUP BY `entry` " + ") As gm on `ct`.`GossipMenuId` = `gm`.`entry` " + "WHERE `ct`.GossipMenuId <> 0 " + "ORDER BY `ct`.`Entry` ASC, `gm`.`entry` ASC, `gm`.`text_id` ASC" + ); + + if (!result) + { + BarGoLink bar(1); + bar.step(); + sLog.outErrorDb(">> Loaded core side gossip text id cache, NO DATA FOUND !"); + sLog.outString(); + return; + } + + BarGoLink bar(result->GetRowCount()); + + uint32 count = 0; + + do + { + bar.step(); + Field* fields = result->Fetch(); + m_mCacheNpcTextIdMap[fields[0].GetUInt32()] = fields[1].GetUInt32(); + + ++count; + } + while (result->NextRow()); + + sLog.outString(">> Loaded %u core side gossip text id in cache", count); + sLog.outString(); + } void ObjectMgr::AddVendorItem(uint32 entry, uint32 item, uint32 maxcount, uint32 incrtime) diff --git a/src/game/Object/ObjectMgr.h b/src/game/Object/ObjectMgr.h index da80bc8d..a0d70949 100644 --- a/src/game/Object/ObjectMgr.h +++ b/src/game/Object/ObjectMgr.h @@ -731,6 +731,8 @@ class ObjectMgr void LoadGameTele(); void LoadGossipMenus(); + void LoadCoreSideGossipTextIdCache(); + void LoadVendorTemplates(); void LoadVendors() @@ -1086,7 +1088,7 @@ class ObjectMgr bool AddGameTele(GameTele& data); bool DeleteGameTele(const std::string& name); - uint32 GetNpcGossip(uint32 entry) const + uint32 GetNpcGossipTextId(uint32 entry) const { CacheNpcTextIdMap::const_iterator iter = m_mCacheNpcTextIdMap.find(entry); if (iter == m_mCacheNpcTextIdMap.end()) diff --git a/src/game/Object/Player.cpp b/src/game/Object/Player.cpp index 9710c42b..9d01cce5 100644 --- a/src/game/Object/Player.cpp +++ b/src/game/Object/Player.cpp @@ -13803,7 +13803,7 @@ uint32 Player::GetGossipTextId(WorldObject* pSource) return DEFAULT_GOSSIP_MESSAGE; } - if (uint32 pos = sObjectMgr.GetNpcGossip(((Creature*)pSource)->GetGUIDLow())) + if (uint32 pos = sObjectMgr.GetNpcGossipTextId(((Creature*)pSource)->GetEntry())) { return pos; } diff --git a/src/modules/SD3 b/src/modules/SD3 index 8e937b8d..cda75d0c 160000 --- a/src/modules/SD3 +++ b/src/modules/SD3 @@ -1 +1 @@ -Subproject commit 8e937b8dfedc563c2ac4c1ebcda9ca2f7d25ce95 +Subproject commit cda75d0c980e7e6e864a6efb24bb235cf63701d2