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


C++ ChatHandler::FillMessageData方法代码示例

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


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

示例1: HandleMsg

void ItemHandler::HandleMsg (NetworkPacket & recv_data, GameClient *pClient)
{
    NetworkPacket data;
    char f[ 256 ];
    sprintf (f, "WORLDSERVER: Item Opcode 0x%.4X", recv_data.opcode);
    LOG.outString (f);
    switch (recv_data.opcode)
    {
        case CMSG_SWAP_INV_ITEM:
        {
            //ok i'm gonna do that a looootttt cleaner :/
            uint8 srcslot, destslot;
            recv_data >> srcslot >> destslot;
            int slot = destslot;

            //START OF LINA LVL REQUIREMENT SWAP PATCH
            int8 CharLvl, ItemLvl;
            //printf("ITEM: LVL TEST\n");
            CharLvl=pClient->getCurrentChar()->getLevel();
            ItemLvl=WORLDSERVER.GetItem(pClient->getCurrentChar()->getItemIdBySlot(srcslot))->RequiredLevel;
            //printf("ITEM: CharLvl %d, ItemLvl %d\n", CharLvl, ItemLvl);
            if (CharLvl < ItemLvl)
            {
                ChatHandler * MsgLvlItem = new ChatHandler;
                if(MsgLvlItem  !=NULL)
                {
                    //NEED TO PUT SOME CODE TO UNGRAY ITEM
                    uint8 buf[256];
                    NetworkPacket data;
                    sprintf((char*)buf,"You need the Lvl %d to equip that item.", ItemLvl);
                    MsgLvlItem->FillMessageData(&data, 0x09, pClient, buf);
                    pClient->SendMsg (&data);
                    delete(MsgLvlItem);
                }
                else printf("ITEM: CMSG_SWAP_INV_ITEM can't send message\n");
                return;
            }
            //END OF LINA LVL REQUIREMENT SWAP PATCH

            //these are the bags slots...ignore it for now
            if ((slot <= 22) && (slot >=19))
                destslot = srcslot;

            //check to make sure items are not being put in wrong spots
            if (((srcslot > 23) && (destslot < 19)) || ((srcslot < 23) && (destslot > 19)))
            {
                if ((pClient->getCurrentChar()->getGuidBySlot(destslot) != 0) && (pClient->getCurrentChar()->getGuidBySlot(srcslot) != 0))
                {
                    Item * tmpitem1 = WORLDSERVER.GetItem(pClient->getCurrentChar()->getItemIdBySlot(destslot));
                    Item * tmpitem2 = WORLDSERVER.GetItem(pClient->getCurrentChar()->getItemIdBySlot(srcslot));
                    if ((tmpitem1 != NULL) && (tmpitem2 != NULL))
                    {
                        if (tmpitem1->Inventorytype != tmpitem2->Inventorytype)
                        {
                            data.Initialize (18, SMSG_INVENTORY_CHANGE_FAILURE);
                            data << uint8(0x0c) ;
                            data << uint32(pClient->getCurrentChar()->getGuidBySlot(destslot));
                            data << uint32(0x00000040);
                            data << uint32(pClient->getCurrentChar()->getGuidBySlot(srcslot));
                            data << uint32(0x00000040);
                            data << uint8(0);
                            pClient->SendMsg (&data);
                            return;
                        }
                    }
                }
            }

            //swap items
            pClient->getCurrentChar()->SwapItemInSlot((int)srcslot, (int)destslot);
            UpdateMask updateMask;
            updateMask.SetLength (PLAYER_FIELDS);

            //error
            if (srcslot == destslot)
            {
                data.Initialize (18, SMSG_INVENTORY_CHANGE_FAILURE);
                data << uint8(0x0c) ;
                data << uint32(pClient->getCurrentChar()->getGuidBySlot(destslot));
                data << uint32(0x00000040);
                data << uint32(pClient->getCurrentChar()->getGuidBySlot(srcslot));
                data << uint32(0x00000040);
                data << uint8(0);
                pClient->SendMsg (&data);
                return;
            }
            pClient->getCurrentChar()->updateItemStats();
            //send to zone players...they don't need to know about the item if the slot is over 19
            if (destslot < 19)
            {
                pClient->getCurrentChar ()->setUpdateValue (
                    PLAYER_FIELD_INV_SLOT_HEAD  + (destslot*2),
                    pClient->getCurrentChar()->getGuidBySlot(destslot),
                    updateMask.data);
                pClient->getCurrentChar ()->setUpdateValue (
                    PLAYER_FIELD_INV_SLOT_HEAD  + (destslot*2)+1,
                    pClient->getCurrentChar()->getGuidBySlot(destslot) == 0 ? 0 : 0x00000040,
                    updateMask.data);
            }
            if (srcslot < 19)
//.........这里部分代码省略.........
开发者ID:madhatternc,项目名称:mangos2,代码行数:101,代码来源:ItemHandler.cpp


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