mirror of
https://github.com/mangosfour/server.git
synced 2025-12-12 19:37:03 +00:00
[11852] Add support for db scripts assigned to gossip menus
This commit is contained in:
parent
83e85416f4
commit
4c82458874
13 changed files with 76 additions and 48 deletions
|
|
@ -8487,11 +8487,12 @@ void ObjectMgr::LoadNpcGossips()
|
|||
sLog.outString( ">> Loaded %d NpcTextId ", count );
|
||||
}
|
||||
|
||||
void ObjectMgr::LoadGossipMenu()
|
||||
void ObjectMgr::LoadGossipMenu(std::set<uint32>& gossipScriptSet)
|
||||
{
|
||||
m_mGossipMenusMap.clear();
|
||||
|
||||
QueryResult* result = WorldDatabase.Query("SELECT entry, text_id, "
|
||||
// 0 1 2
|
||||
QueryResult* result = WorldDatabase.Query("SELECT entry, text_id, script_id, "
|
||||
// 3 4 5 6 7 8
|
||||
"cond_1, cond_1_val_1, cond_1_val_2, cond_2, cond_2_val_1, cond_2_val_2 FROM gossip_menu");
|
||||
|
||||
if (!result)
|
||||
|
|
@ -8519,13 +8520,14 @@ void ObjectMgr::LoadGossipMenu()
|
|||
|
||||
gMenu.entry = fields[0].GetUInt32();
|
||||
gMenu.text_id = fields[1].GetUInt32();
|
||||
gMenu.script_id = fields[2].GetUInt32();
|
||||
|
||||
ConditionType cond_1 = (ConditionType)fields[2].GetUInt32();
|
||||
uint32 cond_1_val_1 = fields[3].GetUInt32();
|
||||
uint32 cond_1_val_2 = fields[4].GetUInt32();
|
||||
ConditionType cond_2 = (ConditionType)fields[5].GetUInt32();
|
||||
uint32 cond_2_val_1 = fields[6].GetUInt32();
|
||||
uint32 cond_2_val_2 = fields[7].GetUInt32();
|
||||
ConditionType cond_1 = (ConditionType)fields[3].GetUInt32();
|
||||
uint32 cond_1_val_1 = fields[4].GetUInt32();
|
||||
uint32 cond_1_val_2 = fields[5].GetUInt32();
|
||||
ConditionType cond_2 = (ConditionType)fields[6].GetUInt32();
|
||||
uint32 cond_2_val_1 = fields[7].GetUInt32();
|
||||
uint32 cond_2_val_2 = fields[8].GetUInt32();
|
||||
|
||||
if (!GetGossipText(gMenu.text_id))
|
||||
{
|
||||
|
|
@ -8533,6 +8535,19 @@ void ObjectMgr::LoadGossipMenu()
|
|||
continue;
|
||||
}
|
||||
|
||||
// Check script-id
|
||||
if (gMenu.script_id)
|
||||
{
|
||||
if (sGossipScripts.find(gMenu.script_id) == sGossipScripts.end())
|
||||
{
|
||||
sLog.outErrorDb("Table gossip_menu for menu %u, text-id %u have script_id %u that does not exist in `gossip_scripts`, ignoring", gMenu.entry, gMenu.text_id, gMenu.script_id);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Remove used script id
|
||||
gossipScriptSet.erase(gMenu.script_id);
|
||||
}
|
||||
|
||||
if (!PlayerCondition::IsValid(cond_1, cond_1_val_1, cond_1_val_2))
|
||||
{
|
||||
sLog.outErrorDb("Table gossip_menu entry %u, invalid condition 1 for id %u", gMenu.entry, gMenu.text_id);
|
||||
|
|
@ -8573,7 +8588,7 @@ void ObjectMgr::LoadGossipMenu()
|
|||
ERROR_DB_STRICT_LOG("Gameobject (Entry: %u) has gossip_menu_id = %u for nonexistent menu", gInfo->id, menuid);
|
||||
}
|
||||
|
||||
void ObjectMgr::LoadGossipMenuItems()
|
||||
void ObjectMgr::LoadGossipMenuItems(std::set<uint32>& gossipScriptSet)
|
||||
{
|
||||
m_mGossipMenuItemsMap.clear();
|
||||
|
||||
|
|
@ -8615,11 +8630,6 @@ void ObjectMgr::LoadGossipMenuItems()
|
|||
|
||||
uint32 count = 0;
|
||||
|
||||
std::set<uint32> gossipScriptSet;
|
||||
|
||||
for(ScriptMapMap::const_iterator itr = sGossipScripts.begin(); itr != sGossipScripts.end(); ++itr)
|
||||
gossipScriptSet.insert(itr->first);
|
||||
|
||||
// prepare menuid -> CreatureInfo map for fast access
|
||||
typedef std::multimap<uint32, const CreatureInfo*> Menu2CInfoMap;
|
||||
Menu2CInfoMap menu2CInfoMap;
|
||||
|
|
@ -8749,6 +8759,7 @@ void ObjectMgr::LoadGossipMenuItems()
|
|||
continue;
|
||||
}
|
||||
|
||||
// Remove used script id
|
||||
gossipScriptSet.erase(gMenuItem.action_script_id);
|
||||
}
|
||||
|
||||
|
|
@ -8765,9 +8776,6 @@ void ObjectMgr::LoadGossipMenuItems()
|
|||
|
||||
delete result;
|
||||
|
||||
for(std::set<uint32>::const_iterator itr = gossipScriptSet.begin(); itr != gossipScriptSet.end(); ++itr)
|
||||
sLog.outErrorDb("Table `gossip_scripts` contain unused script, id %u.", *itr);
|
||||
|
||||
if (!sLog.HasLogFilter(LOG_FILTER_DB_STRICTED_CHECK))
|
||||
{
|
||||
for(std::set<uint32>::const_iterator itr = menu_ids.begin(); itr != menu_ids.end(); ++itr)
|
||||
|
|
@ -8778,6 +8786,23 @@ void ObjectMgr::LoadGossipMenuItems()
|
|||
sLog.outString(">> Loaded %u gossip_menu_option entries", count);
|
||||
}
|
||||
|
||||
void ObjectMgr::LoadGossipMenus()
|
||||
{
|
||||
// Check which script-ids in gossip_scripts are not used
|
||||
std::set<uint32> gossipScriptSet;
|
||||
for (ScriptMapMap::const_iterator itr = sGossipScripts.begin(); itr != sGossipScripts.end(); ++itr)
|
||||
gossipScriptSet.insert(itr->first);
|
||||
|
||||
// Load gossip_menu and gossip_menu_option data
|
||||
sLog.outString( "(Re)Loading Gossip menus..." );
|
||||
LoadGossipMenu(gossipScriptSet);
|
||||
sLog.outString( "(Re)Loading Gossip menu options..." );
|
||||
LoadGossipMenuItems(gossipScriptSet);
|
||||
|
||||
for (std::set<uint32>::const_iterator itr = gossipScriptSet.begin(); itr != gossipScriptSet.end(); ++itr)
|
||||
sLog.outErrorDb("Table `gossip_scripts` contains unused script, id %u.", *itr);
|
||||
}
|
||||
|
||||
void ObjectMgr::AddVendorItem( uint32 entry,uint32 item, uint32 maxcount, uint32 incrtime, uint32 extendedcost )
|
||||
{
|
||||
VendorItemData& vList = m_mCacheVendorItemMap[entry];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue