2022-9-2 01:27:03
This commit is contained in:
132
src/dispatch.cpp
Normal file
132
src/dispatch.cpp
Normal file
@@ -0,0 +1,132 @@
|
||||
//************************************
|
||||
// FileName: D:\VisualStudioSource\dnf_project\src\Dispatch.cpp
|
||||
// FullName: D:\VisualStudioSource\dnf_project\src
|
||||
// Date: 2022/09/01
|
||||
// By: Vance
|
||||
// Copyright (c) 2022. Vance All rights reserved
|
||||
//************************************
|
||||
|
||||
#include "dispatch.h"
|
||||
|
||||
CDispatch::CDispatch()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
CDispatch::~CDispatch()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int CDispatch::UseEquipmentMoveItem(CUser* user, PacketBuf* pBuf)
|
||||
{
|
||||
int result = 0;
|
||||
|
||||
if (pBuf)
|
||||
{
|
||||
int equipment_pos = pBuf->get_short(); //装备位置
|
||||
int equipment_id = pBuf->get_int(); //装备代码
|
||||
int item_pos = pBuf->get_short(); //物品位置
|
||||
|
||||
|
||||
//1 物品栏 2 时装
|
||||
if (user->CheckItemLock(1, equipment_pos))
|
||||
{
|
||||
user->SendCmdErrorPacket(83, 213);
|
||||
return result;
|
||||
}
|
||||
|
||||
CInventory* inven = user->getCurCharacInvenW();
|
||||
if (!inven)
|
||||
{
|
||||
LOG("user->getCurCharacInvenW : error \n");
|
||||
return result;
|
||||
}
|
||||
|
||||
Inven_Item* equipment_avartar = inven->GetInvenRef(CInventory::INVENTORY_TYPE_ITEM, equipment_pos);
|
||||
if (!equipment_avartar)
|
||||
{
|
||||
LOG("inven->GetInvenRef : error \n");
|
||||
return result;
|
||||
}
|
||||
Inven_Item* item_avartar = inven->GetInvenRef(CInventory::INVENTORY_TYPE_ITEM, item_pos);
|
||||
if (!item_avartar)
|
||||
{
|
||||
LOG("inven->GetInvenRef : error \n");
|
||||
return result;
|
||||
}
|
||||
|
||||
if (equipment_avartar->isEmpty() )
|
||||
{
|
||||
LOG("服务器背包为空");
|
||||
return result;
|
||||
}
|
||||
if (equipment_avartar->getKey() != equipment_id)
|
||||
{
|
||||
LOG("需要操作的装备ID和数据库的装备ID不一致");
|
||||
return result;
|
||||
}
|
||||
|
||||
if (item_avartar->isEmpty())
|
||||
{
|
||||
LOG("需要操作的物品为空");
|
||||
return result;
|
||||
}
|
||||
|
||||
int item_id = item_avartar->getKey();
|
||||
|
||||
CDataManager* DataManager = CDataManager::G_CDataManager();
|
||||
|
||||
if (!DataManager)
|
||||
{
|
||||
LOG("G_CDataManager 错误");
|
||||
return result;
|
||||
}
|
||||
|
||||
CItem* equipment_citem = DataManager->find_item(equipment_id);
|
||||
CItem* item_citem = DataManager->find_item(item_id);
|
||||
|
||||
if (!equipment_citem || !item_citem)
|
||||
{
|
||||
LOG("获取pvf中数据失败!");
|
||||
return result;
|
||||
}
|
||||
|
||||
LOG("UseEquipmentMoveItem [ equipment_pos:%d equipment_id:%d item_pos:%d item_id:%d ]"
|
||||
, equipment_pos
|
||||
, equipment_id
|
||||
, item_pos
|
||||
, item_id
|
||||
);
|
||||
|
||||
//Data: equipment_citem->GetItemType=147418664 item_citem->is_stackable=1 item_citem->GetItemType=11
|
||||
LOG("Data: equipment_citem->GetItemType=%d item_citem->is_stackable=%d item_citem->GetItemType=%d"
|
||||
, equipment_citem->GetItemType()
|
||||
, item_citem->is_stackable()
|
||||
, item_citem->GetItemType()
|
||||
|
||||
);
|
||||
|
||||
//if (!item_citem->is_stackable() || (equipment_citem->GetItemType() != 20))
|
||||
//{
|
||||
// LOG("citem->is_stackable() || (citem->GetItemType() : error \n");
|
||||
// pUser->SendCmdErrorPacket(205, 209);
|
||||
// return 0;
|
||||
//}
|
||||
|
||||
/*
|
||||
缓冲Call (2000)
|
||||
密钥Call (装备位置,2)
|
||||
密钥Call (装备代码,4)
|
||||
密钥Call (物品位置,2)
|
||||
发包Call ()
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user