Ru-MaNGOS

Ru-MaNGOS (http://mangos.ytdb.ru/index.php)
-   Принятые патчи (http://mangos.ytdb.ru/forumdisplay.php?f=5)
-   -   [11982] USE_CREATURE_IN_GOSSIP_MENU_CHECK (http://mangos.ytdb.ru/showthread.php?t=5396)

virusav 27.04.2012 21:29

[11982] USE_CREATURE_IN_GOSSIP_MENU_CHECK
 
Если в конфиге поставить LogFilter_DbStrictedCheck = 0, то получаем много ошибок вида
Код:

... Table `gossip_menu` contain unused (in creature or GO or menu options) menu id XXX.
При этом большинство из этих menu_id есть в базе.
Проблема в том, что не учитываются коды меню из таблицы `creature_template`.
Код:

diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp
index 75c7d30..629b253 100644
--- a/src/game/ObjectMgr.cpp
+++ b/src/game/ObjectMgr.cpp
@@ -8698,7 +8698,10 @@ void ObjectMgr::LoadGossipMenuItems(std::set<uint32>& gossipScriptSet)
    for(uint32 i = 1;  i < sCreatureStorage.MaxEntry; ++i)
        if (CreatureInfo const* cInfo = sCreatureStorage.LookupEntry<CreatureInfo>(i))
            if (cInfo->GossipMenuId)
+            {
+                menu_ids.erase(cInfo->GossipMenuId);
                menu2CInfoMap.insert(Menu2CInfoMap::value_type(cInfo->GossipMenuId, cInfo));
+            }
 
    do
    {

Результаты проверки:
1. Чистое ядро: в логе 1414 номеров menu_id, совпадения с таблицей `creature_template` есть.
2. С патчем: в логе 111 номеров menu_id. В таблицах `creature_template`, `gameobject_template` и `gossip_menu_option` совпадений нет.

schmoozerd 28.04.2012 15:13

Nice catch. Atm we only consider menus with gossip_menu_option entries as "found"

So I think this should be good:
Код:

diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp
index 75c7d30..180142b 100644
--- a/src/game/ObjectMgr.cpp
+++ b/src/game/ObjectMgr.cpp
@@ -8681,7 +8681,7 @@ void ObjectMgr::LoadGossipMenuItems(std::set<uint32>& gossipScriptSet)
            if (itr->first)
                menu_ids.insert(itr->first);
 
-        for(uint32 i = 1; i < sGOStorage.MaxEntry; ++i)
+        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);
@@ -8695,11 +8695,17 @@ void ObjectMgr::LoadGossipMenuItems(std::set<uint32>& gossipScriptSet)
    // prepare menuid -> CreatureInfo map for fast access
    typedef  std::multimap<uint32, const CreatureInfo*> Menu2CInfoMap;
    Menu2CInfoMap menu2CInfoMap;
-    for(uint32 i = 1;  i < sCreatureStorage.MaxEntry; ++i)
+    for (uint32 i = 1;  i < sCreatureStorage.MaxEntry; ++i)
        if (CreatureInfo const* cInfo = sCreatureStorage.LookupEntry<CreatureInfo>(i))
            if (cInfo->GossipMenuId)
+            {
                menu2CInfoMap.insert(Menu2CInfoMap::value_type(cInfo->GossipMenuId, cInfo));
 
+                // unused check data preparing part
+                if (!sLog.HasLogFilter(LOG_FILTER_DB_STRICTED_CHECK))
+                    menu_ids.erase(cInfo->GossipMenuId);
+            }
+
    do
    {
        bar.step();
@@ -8777,7 +8783,7 @@ void ObjectMgr::LoadGossipMenuItems(std::set<uint32>& gossipScriptSet)
        if (gMenuItem.option_id >= GOSSIP_OPTION_MAX)
            sLog.outErrorDb("Table gossip_menu_option for menu %u, id %u has unknown option id %u. Option will not be used", gMenuItem.menu_id, gMenuItem.id, gMenuItem.option_id);
 
-        if (gMenuItem.menu_id && (gMenuItem.npc_option_npcflag || !sLog.HasLogFilter(LOG_FILTER_DB_STRICTED_CHECK)))
+        if (gMenuItem.menu_id && gMenuItem.npc_option_npcflag)
        {
            bool found_menu_uses = false;
            bool found_flags_uses = false;
@@ -8792,10 +8798,6 @@ void ObjectMgr::LoadGossipMenuItems(std::set<uint32>& gossipScriptSet)
                // some from creatures with gossip menu can use gossip option base at npc_flags
                if (gMenuItem.npc_option_npcflag & cInfo->npcflag)
                    found_flags_uses = true;
-
-                // unused check data preparing part
-                if (!sLog.HasLogFilter(LOG_FILTER_DB_STRICTED_CHECK))
-                    menu_ids.erase(gMenuItem.menu_id);
            }
 
            if (found_menu_uses && !found_flags_uses)


virusav 28.04.2012 16:05

Если menu_id есть в таблицах `creature_template`, `gameobject_template` или `gossip_menu_option`, то в переменной menu_ids их не должно быть.

Если LOG_FILTER_DB_STRICTED_CHECK = 1, то menu_id, отсутствующие в соответствующих таблицах, удаляются из menu_ids.

Если удалять menu_id из menu_ids только при LOG_FILTER_DB_STRICTED_CHECK = 0, то будем обрабатывать больше записей, чем в моем варианте.

Все равно существующие записи не дадут ошибку в логе при любом значении LOG_FILTER_DB_STRICTED_CHECK, поэтому лучше их сразу удалять при проверке в цикле по объектам, нпц и подпукнтам госсипов.

Если я неправильно понял суть переменной menu_ids, то просьба пояснить.

schmoozerd 28.04.2012 16:38

Very hard for me to understand what you really mean.

If LOG_FILTER_* is set this means that the related log is filtered. which means not displayed.
Hence if you want to see LOG_FILTER_* output you have to set =0.

HasLogFilter(*) returns if LOG_FILTER_* = 1.

The idea is to output which menu-ids are unused if you run the mode in DB_STRICTED_CHECK (by setting LOG_FILTER_DB_STRICTED_CHECK = 0 )

So the check !HasLogFilter(*) returns if you want the additional checks.

the variable menu_ids has the idea to contains all entries of `gossip_menu` - which are unused.
To actually fill this variable (it is a set) all used menu-ids are inserted, and all used are erased.
This way, the remaining are exactly the ones that are unused.

In current clean code, the removed ones are the ones that
- are used in gameobject_template
- OR are used in gossip_menu_option.action_menu_id
- OR are used in gossip_menu_option

hence the many ones that are used only in creature_template are not removed, and hence give false error output.
Your patch fixes this.

However with your patch, menu-ids used in gossip_menu_option are attempted to remvoe again, (which is useless) - this is why I removed these few lines in my patch (chunk @@ -8792,10 +8798,6 @@ )

virusav 28.04.2012 17:22

В моем представлении должно быть так:
1. Заполняем menu_ids.
2. Удаляем из menu_ids все меню объектов.
3. Удаляем из menu_ids все меню нпц.
4. Удаляем из menu_ids все `gossip_menu_option`.`action_menu_id`.
5. Если LOG_FILTER_DB_STRICTED_CHECK = 1, то удаляем из menu_ids все неиспользуемые меню.
6. Если LOG_FILTER_DB_STRICTED_CHECK = 0, то выводим ошибки.

После пунктов 2, 3 и 4 в menu_ids должны остаться только неиспользуемые меню.
Если пропустить пункт 3, то в пунктах 5 и 6 будем обрабатывать больше записей.

Возможно, я не так понял вашу правку, так как сейчас у меня нет исходников под рукой.

Лишь бы патч был принят в правильном варианте:)

KiriX 30.04.2012 23:19

virusav, schmoozerd предлагает точно тоже самое, что и ты, только немного иначе в коде. Более правильно по его мнению (тут уж я судить не берусь). Но работать будет точно также как и предполагает твоя правка =)

virusav 02.05.2012 19:24

Предлагаю принять какой-нибудь вариант патча, раз оба правильные.:)

schmoozerd 04.05.2012 17:47

In [11982]. Thank you :)

Sorry for the misunderstandings :(


Текущее время: 22:52. Часовой пояс GMT +3.

ru-mangos.ru - Русское сообщество MaNGOS