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


C++ NewItemOrBag函数代码示例

本文整理汇总了C++中NewItemOrBag函数的典型用法代码示例。如果您正苦于以下问题:C++ NewItemOrBag函数的具体用法?C++ NewItemOrBag怎么用?C++ NewItemOrBag使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: bar

void AuctionHouseMgr::LoadAuctionItems()
{
    // data needs to be at first place for Item::LoadFromDB
    QueryResult *result = CharacterDatabase.Query( "SELECT data,itemguid,item_template FROM auctionhouse JOIN item_instance ON itemguid = guid" );

    if( !result )
    {
        barGoLink bar(1);
        bar.step();
        sLog.outString();
        sLog.outString(">> Loaded 0 auction items");
        return;
    }

    barGoLink bar( (int)result->GetRowCount() );

    uint32 count = 0;

    Field *fields;
    do
    {
        bar.step();

        fields = result->Fetch();
        uint32 item_guid        = fields[1].GetUInt32();
        uint32 item_template    = fields[2].GetUInt32();

        ItemPrototype const *proto = ObjectMgr::GetItemPrototype(item_template);

        if(!proto)
        {
            sLog.outError( "AuctionHouseMgr::LoadAuctionItems: Unknown item (GUID: %u id: #%u) in auction, skipped.", item_guid,item_template);
            continue;
        }

        Item *item = NewItemOrBag(proto);

        if(!item->LoadFromDB(item_guid,0, result))
        {
            delete item;
            continue;
        }
        AddAItem(item);

        ++count;
    }
    while( result->NextRow() );
    delete result;

    sLog.outString();
    sLog.outString( ">> Loaded %u auction items", count );
}
开发者ID:ContaCtcore,项目名称:Gcontact,代码行数:52,代码来源:AuctionHouseMgr.cpp

示例2: SetUInt64Value

bool Bag::LoadFromDB(uint32 guid, uint64 owner_guid, uint32 auctioncheck)
{
    if(!Item::LoadFromDB(guid, owner_guid, auctioncheck))
        return false;

    // cleanup bag content related item value fields (its will be filled correctly from `character_inventory`)
    for (uint32 i = 0; i < GetProto()->ContainerSlots; i++)
    {
        SetUInt64Value(CONTAINER_FIELD_SLOT_1 + (i*2), 0);
        if (m_bagslot[i])
        {
            delete m_bagslot[i];
            m_bagslot[i] = NULL;
        }
    }

    if(GetSlot()!=NULL_SLOT)                                // equiped bag
    {
        QueryResult *result = sDatabase.PQuery("SELECT `slot`,`item`,`item_template` FROM `character_inventory` WHERE `guid` = '%u' AND `bag` = '%u'", GUID_LOPART(GetOwnerGUID()), GetSlot());

        if (result)
        {
            do
            {
                Field *fields = result->Fetch();
                uint8  slot      = fields[0].GetUInt8();
                uint32 item_guid = fields[1].GetUInt32();
                uint32 item_id   = fields[2].GetUInt32();

                ItemPrototype const *proto = objmgr.GetItemPrototype(item_id);

                if(!proto)
                {
                    sLog.outError( "Bag::LoadFromDB: Player %d have unknown item (id: #%u) in bag #%u, skipped.", GUID_LOPART(GetOwnerGUID()), item_id, GetSlot());
                    continue;
                }

                Item *item = NewItemOrBag(proto);
                item->SetSlot(NULL_SLOT);
                if(!item->LoadFromDB(item_guid, owner_guid, 1))
                    continue;
                StoreItem( slot, item, true );
            } while (result->NextRow());

            delete result;
        }
    }
    return true;
}
开发者ID:Artea,项目名称:mangos-svn,代码行数:49,代码来源:Bag.cpp

示例3: getMSTime

void AuctionHouseMgr::LoadAuctionItems()
{
    uint32 oldMSTime = getMSTime();

    // data needs to be at first place for Item::LoadFromDB
    PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_LOAD_AUCTION_ITEMS);
    PreparedQueryResult result = CharacterDatabase.Query(stmt);

    if (!result)
    {
        sLog->outString(">> Loaded 0 auction items. DB table `auctionhouse` or `item_instance` is empty!");
        sLog->outString();
        return;
    }

    uint32 count = 0;

    do
    {

        Field* fields = result->Fetch();

        uint32 item_guid        = fields[11].GetUInt32();
        uint32 item_template    = fields[12].GetUInt32();

        ItemPrototype const *proto = ObjectMgr::GetItemPrototype(item_template);
        if (!proto)
        {
            sLog->outError("AuctionHouseMgr::LoadAuctionItems: Unknown item (GUID: %u id: #%u) in auction, skipped.", item_guid,item_template);
            continue;
        }

        Item *item = NewItemOrBag(proto);
        if (!item->LoadFromDB(item_guid, 0, fields, item_template))
        {
            delete item;
            continue;
        }
        AddAItem(item);

        ++count;
    }
    while (result->NextRow());

    sLog->outString(">> Loaded %u auction items in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
    sLog->outString();
}
开发者ID:AlexTheBest,项目名称:ACore,代码行数:47,代码来源:AuctionHouseMgr.cpp

示例4: MANGOS_ASSERT

Item* Item::CreateItem( uint32 item, uint32 count, Player const* player, uint32 randomPropertyId)
{
    if (count < 1)
        return NULL;                                        //don't create item at zero count

    if (ItemPrototype const* pProto = ObjectMgr::GetItemPrototype(item))
    {
        if (count > pProto->GetMaxStackSize())
            count = pProto->GetMaxStackSize();

        MANGOS_ASSERT(count != 0 && "pProto->Stackable == 0 but checked at loading already");

        Item* pItem = NewItemOrBag(pProto);
        if (pItem->Create(sObjectMgr.GenerateItemLowGuid(), item, player))
        {
            /** World of Warcraft Armory **/
            if (sWorld.getConfig(CONFIG_BOOL_ARMORY_SUPPORT))
            {
                if (pProto->Quality > 2 && pProto->Flags != 2048 && (pProto->Class == ITEM_CLASS_WEAPON || pProto->Class == ITEM_CLASS_ARMOR) && player)
                {
                    std::ostringstream ss;
                    sLog.outDetail("WoWArmory: write feed log (guid: %u, type: 2, data: %u)", player->GetGUIDLow(), item);
                    ss << "REPLACE INTO armory_character_feed_log (guid, type, data, date, counter, item_guid) VALUES (" << player->GetGUIDLow() << ", 2, " << item << ", UNIX_TIMESTAMP(NOW()), 1," << pItem->GetGUIDLow()  << ")";
                    CharacterDatabase.PExecute( ss.str().c_str() );
                }
            }
            /** World of Warcraft Armory **/

            pItem->SetCount(count);
            if (uint32 randId = randomPropertyId ? randomPropertyId : Item::GenerateItemRandomPropertyId(item))
                pItem->SetItemRandomProperties(randId);

            return pItem;
        }
        else
            delete pItem;
    }
    return NULL;
}
开发者ID:Archives,项目名称:easy-mangos,代码行数:39,代码来源:Item.cpp

示例5: MANGOS_ASSERT

Item* Item::CreateItem( uint32 item, uint32 count, Player const* player )
{
    if (count < 1)
        return NULL;                                        //don't create item at zero count

    if (ItemPrototype const* pProto = ObjectMgr::GetItemPrototype(item))
    {
        if (count > pProto->GetMaxStackSize())
            count = pProto->GetMaxStackSize();

        MANGOS_ASSERT(count != 0 && "pProto->Stackable == 0 but checked at loading already");

        Item* pItem = NewItemOrBag(pProto);
        if (pItem->Create(sObjectMgr.GenerateItemLowGuid(), item, player))
        {
            pItem->SetCount(count);
            return pItem;
        }
        else
            delete pItem;
    }
    return NULL;
}
开发者ID:ArgentPrawn,项目名称:server,代码行数:23,代码来源:Item.cpp


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