mirror of
https://github.com/mangosfour/server.git
synced 2025-12-14 07:37:01 +00:00
[10712] Startup checks for gossip_menu and gosip_menu_option table data.
Existance `gosup_menu` id refercned from gameobject field and unused meni ids activated only with disabled LogFilter_DbStrictedCheck.
This commit is contained in:
parent
534ff29f15
commit
a87648c56b
6 changed files with 67 additions and 14 deletions
|
|
@ -9132,6 +9132,19 @@ void ObjectMgr::LoadGossipMenu()
|
|||
|
||||
sLog.outString();
|
||||
sLog.outString( ">> Loaded %u gossip_menu entries", count);
|
||||
|
||||
// post loading tests
|
||||
for(uint32 i = 1; i < sCreatureStorage.MaxEntry; ++i)
|
||||
if (CreatureInfo const* cInfo = sCreatureStorage.LookupEntry<CreatureInfo>(i))
|
||||
if (cInfo->GossipMenuId)
|
||||
if (m_mGossipMenusMap.find(cInfo->GossipMenuId) == m_mGossipMenusMap.end())
|
||||
sLog.outErrorDb("Creature (Entry: %u) has gossip_menu_id = %u for nonexistent menu", cInfo->Entry, cInfo->GossipMenuId);
|
||||
|
||||
for(uint32 i = 1; i < sGOStorage.MaxEntry; ++i)
|
||||
if (GameObjectInfo const* gInfo = sGOStorage.LookupEntry<GameObjectInfo>(i))
|
||||
if (uint32 menuid = gInfo->GetGossipMenuId())
|
||||
if (m_mGossipMenusMap.find(menuid) == m_mGossipMenusMap.end())
|
||||
ERROR_DB_STRICT_LOG("Gameobject (Entry: %u) has gossip_menu_id = %u for nonexistent menu", gInfo->id, menuid);
|
||||
}
|
||||
|
||||
void ObjectMgr::LoadGossipMenuItems()
|
||||
|
|
@ -9157,6 +9170,25 @@ void ObjectMgr::LoadGossipMenuItems()
|
|||
return;
|
||||
}
|
||||
|
||||
// prepare data for unused menu ids
|
||||
std::set<uint32> menu_ids; // for later integrity check
|
||||
if (!sLog.HasLogFilter(LOG_FILTER_DB_STRICTED_CHECK)) // check unused menu ids only in strict mode
|
||||
{
|
||||
for (GossipMenusMap::const_iterator itr = m_mGossipMenusMap.begin(); itr != m_mGossipMenusMap.end(); ++itr)
|
||||
menu_ids.insert(itr->first);
|
||||
|
||||
for(uint32 i = 1; i < sCreatureStorage.MaxEntry; ++i)
|
||||
if (CreatureInfo const* cInfo = sCreatureStorage.LookupEntry<CreatureInfo>(i))
|
||||
if (cInfo->GossipMenuId)
|
||||
menu_ids.erase(cInfo->GossipMenuId);
|
||||
|
||||
for(uint32 i = 1; i < sGOStorage.MaxEntry; ++i)
|
||||
if (GameObjectInfo const* gInfo = sGOStorage.LookupEntry<GameObjectInfo>(i))
|
||||
if (uint32 menuid = gInfo->GetGossipMenuId())
|
||||
menu_ids.erase(menuid);
|
||||
}
|
||||
|
||||
// loading
|
||||
barGoLink bar((int)result->GetRowCount());
|
||||
|
||||
uint32 count = 0;
|
||||
|
|
@ -9197,6 +9229,15 @@ void ObjectMgr::LoadGossipMenuItems()
|
|||
uint32 cond_3_val_1 = fields[19].GetUInt32();
|
||||
uint32 cond_3_val_2 = fields[20].GetUInt32();
|
||||
|
||||
if (gMenuItem.menu_id) // == 0 id is special and not have menu_id data
|
||||
{
|
||||
if (m_mGossipMenusMap.find(gMenuItem.menu_id) == m_mGossipMenusMap.end())
|
||||
{
|
||||
sLog.outErrorDb("Gossip menu option (MenuId: %u) for nonexistent menu", gMenuItem.menu_id);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (!PlayerCondition::IsValid(cond_1, cond_1_val_1, cond_1_val_2))
|
||||
{
|
||||
sLog.outErrorDb("Table gossip_menu_option menu %u, invalid condition 1 for id %u", gMenuItem.menu_id, gMenuItem.id);
|
||||
|
|
@ -9213,6 +9254,14 @@ void ObjectMgr::LoadGossipMenuItems()
|
|||
continue;
|
||||
}
|
||||
|
||||
if (gMenuItem.action_menu_id)
|
||||
{
|
||||
if (m_mGossipMenusMap.find(gMenuItem.action_menu_id) == m_mGossipMenusMap.end())
|
||||
sLog.outErrorDb("Gossip menu option (MenuId: %u Id: %u) have action_menu_id = %u for nonexistent menu", gMenuItem.menu_id, gMenuItem.id, gMenuItem.action_menu_id);
|
||||
else if (!sLog.HasLogFilter(LOG_FILTER_DB_STRICTED_CHECK))
|
||||
menu_ids.erase(gMenuItem.action_menu_id);
|
||||
}
|
||||
|
||||
if (gMenuItem.option_icon >= GOSSIP_ICON_MAX)
|
||||
{
|
||||
sLog.outErrorDb("Table gossip_menu_option for menu %u, id %u has unknown icon id %u. Replacing with GOSSIP_ICON_CHAT", gMenuItem.menu_id, gMenuItem.id, gMenuItem.option_icon);
|
||||
|
|
@ -9261,10 +9310,13 @@ void ObjectMgr::LoadGossipMenuItems()
|
|||
|
||||
delete result;
|
||||
|
||||
if (!gossipScriptSet.empty())
|
||||
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 = gossipScriptSet.begin(); itr != gossipScriptSet.end(); ++itr)
|
||||
sLog.outErrorDb("Table `gossip_scripts` contain unused script, id %u.", *itr);
|
||||
for(std::set<uint32>::const_iterator itr = menu_ids.begin(); itr != menu_ids.end(); ++itr)
|
||||
sLog.outErrorDb("Table `gossip_menu` contain unused (in creature or GO or menu options) menu id %u.", *itr);
|
||||
}
|
||||
|
||||
sLog.outString();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue