Показать сообщение отдельно
Старый 12.09.2012, 18:09   #11
Konctantin
RuDB Dev
 
Аватар для Konctantin
 
Регистрация: 01.02.2010
Адрес: localhost
Сообщений: 592
Сказал(а) спасибо: 323
Поблагодарили 283 раз(а) в 122 сообщениях
Записей в дневнике: 2
Konctantin Это имя известно всемKonctantin Это имя известно всемKonctantin Это имя известно всемKonctantin Это имя известно всемKonctantin Это имя известно всемKonctantin Это имя известно всем
По умолчанию

может не надо создавать тип, а использовать готовую коллекцию:
Код:
std::map<NPCFlags, char*> associative = std::map<NPCFlags, char*>();
associative[UNIT_NPC_FLAG_TRAINER]             = "UNIT_NPC_FLAG_TRAINER";
associative[UNIT_NPC_FLAG_VENDOR]             = "UNIT_NPC_FLAG_VENDOR";
associative[UNIT_NPC_FLAG_FLIGHTMASTER]     = "UNIT_NPC_FLAG_FLIGHTMASTER";
associative[UNIT_NPC_FLAG_INNKEEPER]      = "UNIT_NPC_FLAG_INNKEEPER";
associative[UNIT_NPC_FLAG_BANKER]         = "UNIT_NPC_FLAG_BANKER";
associative[UNIT_NPC_FLAG_PETITIONER]     = "UNIT_NPC_FLAG_PETITIONER";
associative[UNIT_NPC_FLAG_TABARDDESIGNER] = "UNIT_NPC_FLAG_TABARDDESIGNER";
associative[UNIT_NPC_FLAG_BATTLEMASTER]   = "UNIT_NPC_FLAG_BATTLEMASTER";
associative[UNIT_NPC_FLAG_AUCTIONEER]     = "UNIT_NPC_FLAG_AUCTIONEER";
associative[UNIT_NPC_FLAG_STABLEMASTER]   = "UNIT_NPC_FLAG_STABLEMASTER";
associative[UNIT_NPC_FLAG_GUILD_BANKER]   = "UNIT_NPC_FLAG_GUILD_BANKER";

uint32 gossip_npcflags_all = 0;
for (std::map<NPCFlags, char*>::const_iterator itr = associative.begin(); itr != associative.end(); ++itr)
    gossip_npcflags_all |= itr->first;

QueryResult* result = WorldDatabase.PQuery (
                            "SELECT "
                            "`creature_template`.`entry`, `creature_template`.`gossip_menu_id`, (`creature_template`.`npcflag` & %u) &~ BIT_OR(`gossip_menu_option`.`npc_option_npcflag`) AS `flags` "
                            "FROM "
                            "`creature_template`, `gossip_menu_option` "
                            "WHERE "
                            "`creature_template`.`gossip_menu_id`>0 "
                            "AND `creature_template`.`ScriptName`='' "
                            "AND `gossip_menu_option`.`menu_id`=`creature_template`.`gossip_menu_id` "
                            "GROUP BY "
                            "`creature_template`.`entry`, `creature_template`.`gossip_menu_id` "
                            "HAVING "
                            "`flags`>0", gossip_npcflags_all);
if (result)
{
    BarGoLink bar (result->GetRowCount());
    do
    {
        bar.step();

        Field* fields = result->Fetch();

        for (std::map<NPCFlags, char*>::const_iterator itr = associative.begin(); itr != associative.end(); ++itr)
        {
            if (fields[2].GetUInt32() & itr->first)
                sLog.outErrorDb("Table `creature_template` with `entry` = %u and `gossip_menu_id` = %u has flag %s in `npcflag` but gossip menu does not have option with that value in `npc_option_npcflag`.", fields[0].GetUInt32(), fields[1].GetUInt32(), itr->second);
        }
    }
    while (result->NextRow());

    delete result;
}
__________________
Konctantin вне форума   Ответить с цитированием