当前位置: 首页>>代码示例>>C++>>正文


C++ Corpse::GetLowGUID方法代码示例

本文整理汇总了C++中Corpse::GetLowGUID方法的典型用法代码示例。如果您正苦于以下问题:C++ Corpse::GetLowGUID方法的具体用法?C++ Corpse::GetLowGUID怎么用?C++ Corpse::GetLowGUID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Corpse的用法示例。


在下文中一共展示了Corpse::GetLowGUID方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: CleanCharacters

void DatabaseCleaner::CleanCharacters()
{
    set<uint32> chr_guids;
    set<uint32> chr_guilds;
    set<uint32> chr_charters;
    Log.Notice("DatabaseCleaner", "Loading guids...");
    QueryResult* result = CharacterDatabase.Query("SELECT guid, guildid, charterId FROM characters");
    if (result)
    {
        do
        {
            chr_guids.insert(result->Fetch()[0].GetUInt32());
            if (result->Fetch()[1].GetUInt32() != 0)
                chr_guilds.insert(result->Fetch()[1].GetUInt32());
            if (result->Fetch()[2].GetUInt32() != 0)
                chr_guilds.insert(result->Fetch()[2].GetUInt32());
        } while (result->NextRow());
        delete result;
    }
    Log.Notice("DatabaseCleaner", "Got %u guids.", chr_guids.size());
    Log.Notice("DatabaseCleaner", "Cleaning playeritems...");
    result = CharacterDatabase.Query("SELECT ownerguid, guid FROM playeritems");
    vector<uint64> tokill_items;
    if (result)
    {
        do
        {
            if (result->Fetch()[0].GetUInt32() != 0 && chr_guids.find(result->Fetch()[0].GetUInt32()) == chr_guids.end())
            {
                tokill_items.push_back(result->Fetch()[1].GetUInt64());
            }
        } while (result->NextRow());
        delete result;
    }

    for (vector<uint64>::iterator itr = tokill_items.begin(); itr != tokill_items.end(); ++itr)
    {
        CharacterDatabase.WaitExecute("DELETE FROM playeritems WHERE guid = " I64FMTD, *itr);
    }

    Log.Notice("DatabaseCleaner", "Deleted %u item instances.", tokill_items.size());
    Log.Notice("DatabaseCleaner", "Cleaning questlog...");
    result = CharacterDatabase.Query("SELECT index, player_guid FROM questlog");
    vector<uint32> tokill_quests;
    if (result)
    {
        do
        {
            if (chr_guids.find(result->Fetch()[1].GetUInt32()) == chr_guids.end())
                tokill_quests.push_back(result->Fetch()[0].GetUInt32());
        } while (result->NextRow());
        delete result;
    }

    for (vector<uint32>::iterator itr = tokill_quests.begin(); itr != tokill_quests.end(); ++itr)
        CharacterDatabase.WaitExecute("DELETE FROM questlog WHERE index = %u", *itr);

    Log.Notice("DatabaseCleaner", "Deleted %u questlog entries.", tokill_quests.size());
    Log.Notice("DatabaseCleaner", "Cleaning corpses...");
    vector<uint32> tokill_corpses;
    result = CharacterDatabase.Query("SELECT * FROM corpses");
    if (result)
    {
        do
        {
            Corpse* pCorpse = new Corpse(0, result->Fetch()[0].GetUInt32());
            pCorpse->LoadValues(result->Fetch()[8].GetString());
            pCorpse->SetLowGUID(0);
            if (pCorpse->GetDisplayId() == 0 ||
                GET_LOWGUID_PART(pCorpse->GetOwner()) == 0 ||
                chr_guids.find(GET_LOWGUID_PART(pCorpse->GetOwner())) == chr_guids.end())
            {
                tokill_corpses.push_back(pCorpse->GetLowGUID());
            }
            delete pCorpse;
        } while (result->NextRow());
        delete result;
    }

    for (vector<uint32>::iterator itr = tokill_corpses.begin(); itr != tokill_corpses.end(); ++itr)
        CharacterDatabase.WaitExecute("DELETE FROM corpses WHERE guid = %u", *itr);

    Log.Notice("DatabaseCleaner", "Removed %u corpses.", tokill_corpses.size());
    Log.Notice("DatabaseCleaner", "Cleaning mailbox...");
    result = CharacterDatabase.Query("SELECT message_id, player_guid FROM mailbox");
    vector<uint32> tokill_mail;
    if (result)
    {
        do
        {
            if (chr_guids.find(result->Fetch()[1].GetUInt32()) == chr_guids.end())
                tokill_mail.push_back(result->Fetch()[0].GetUInt32());
        } while (result->NextRow());
        delete result;
    }

    for (vector<uint32>::iterator itr = tokill_mail.begin(); itr != tokill_mail.end(); ++itr)
        CharacterDatabase.WaitExecute("DELETE FROM mailbox WHERE message_id = %u", *itr);
    Log.Notice("DatabaseCleaner", "Deleted %u mail messages.", tokill_mail.size());
    Log.Notice("DatabaseCleaner", "Cleaning guilds table...");
//.........这里部分代码省略.........
开发者ID:lev1976g,项目名称:easywow,代码行数:101,代码来源:DatabaseCleaner.cpp

示例2: DeleteCharacter

uint8 WorldSession::DeleteCharacter(uint32 guid)
{
    PlayerInfo* inf = objmgr.GetPlayerInfo(guid);
    if (inf != NULL && inf->m_loggedInPlayer == NULL)
    {
        QueryResult* result = CharacterDatabase.Query("SELECT name FROM characters WHERE guid = %u AND acct = %u", (uint32)guid, _accountId);
        if (!result)
            return E_CHAR_DELETE_FAILED;

        string name = result->Fetch()[0].GetString();
        delete result;

        if (inf->guild)
        {
            if (inf->guild->GetGuildLeader() == inf->guid)
                return E_CHAR_DELETE_FAILED_GUILD_LEADER;
            else
                inf->guild->RemoveGuildMember(inf, NULL);
        }

        for (int i = 0; i < NUM_CHARTER_TYPES; ++i)
        {
            Charter* c = objmgr.GetCharterByGuid(guid, (CharterTypes)i);
            if (c != NULL)
                c->RemoveSignature((uint32)guid);
        }

        for (int i = 0; i < NUM_ARENA_TEAM_TYPES; ++i)
        {
            ArenaTeam* t = objmgr.GetArenaTeamByGuid((uint32)guid, i);
            if (t != NULL && t->m_leader == guid)
                return E_CHAR_DELETE_FAILED_ARENA_CAPTAIN;
            if (t != NULL)
                t->RemoveMember(inf);
        }

        /*if( _socket != NULL )
            sPlrLog.write("Account: %s | IP: %s >> Deleted player %s", GetAccountName().c_str(), GetSocket()->GetRemoteIP().c_str(), name.c_str());*/

        sPlrLog.writefromsession(this, "deleted character %s (GUID: %u)", name.c_str(), (uint32)guid);

        CharacterDatabase.WaitExecute("DELETE FROM characters WHERE guid = %u", (uint32)guid);

        Corpse* c = objmgr.GetCorpseByOwner((uint32)guid);
        if (c)
            CharacterDatabase.Execute("DELETE FROM corpses WHERE guid = %u", c->GetLowGUID());

        CharacterDatabase.Execute("DELETE FROM playeritems WHERE ownerguid=%u", (uint32)guid);
        CharacterDatabase.Execute("DELETE FROM gm_tickets WHERE playerguid = %u", (uint32)guid);
        CharacterDatabase.Execute("DELETE FROM playerpets WHERE ownerguid = %u", (uint32)guid);
        CharacterDatabase.Execute("DELETE FROM playerpetspells WHERE ownerguid = %u", (uint32)guid);
        CharacterDatabase.Execute("DELETE FROM tutorials WHERE playerId = %u", (uint32)guid);
        CharacterDatabase.Execute("DELETE FROM questlog WHERE player_guid = %u", (uint32)guid);
        CharacterDatabase.Execute("DELETE FROM playercooldowns WHERE player_guid = %u", (uint32)guid);
        CharacterDatabase.Execute("DELETE FROM mailbox WHERE player_guid = %u", (uint32)guid);
        CharacterDatabase.Execute("DELETE FROM social_friends WHERE character_guid = %u OR friend_guid = %u", (uint32)guid, (uint32)guid);
        CharacterDatabase.Execute("DELETE FROM social_ignores WHERE character_guid = %u OR ignore_guid = %u", (uint32)guid, (uint32)guid);
        CharacterDatabase.Execute("DELETE FROM character_achievement WHERE guid = '%u' AND achievement NOT IN (457, 467, 466, 465, 464, 463, 462, 461, 460, 459, 458, 1404, 1405, 1406, 1407, 1408, 1409, 1410, 1411, 1412, 1413, 1415, 1414, 1416, 1417, 1418, 1419, 1420, 1421, 1422, 1423, 1424, 1425, 1426, 1427, 1463, 1400, 456, 1402)", (uint32)guid);
        CharacterDatabase.Execute("DELETE FROM character_achievement_progress WHERE guid = '%u'", (uint32)guid);
        CharacterDatabase.Execute("DELETE FROM playerspells WHERE GUID = '%u'", guid);
        CharacterDatabase.Execute("DELETE FROM playerdeletedspells WHERE GUID = '%u'", guid);
        CharacterDatabase.Execute("DELETE FROM playerreputations WHERE guid = '%u'", guid);
        CharacterDatabase.Execute("DELETE FROM playerskills WHERE GUID = '%u'", guid);

        /* remove player info */
        objmgr.DeletePlayerInfo((uint32)guid);
        return E_CHAR_DELETE_SUCCESS;
    }
    return E_CHAR_DELETE_FAILED;
}
开发者ID:lev1976g,项目名称:easywow,代码行数:70,代码来源:CharacterHandler.cpp


注:本文中的Corpse::GetLowGUID方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。