DP_S/src/dispatch.cpp

698 lines
20 KiB
C++
Raw Normal View History

2022-09-02 01:27:05 +08:00
//************************************
// 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"
2024-04-24 10:25:44 +08:00
CDispatch::CDispatch() : last_move_map_tickcount(0)
2022-09-02 01:27:05 +08:00
{
}
CDispatch::~CDispatch()
{
}
2024-04-24 10:25:44 +08:00
ENUM_PACK_RET_TYPE CDispatch::UseEquipmentMoveItem(CUser *user, PacketBuf *pBuf)
2022-09-02 01:27:05 +08:00
{
2022-09-02 23:34:06 +08:00
if (user->get_state() != 3)
2022-09-02 01:27:05 +08:00
{
2022-09-02 23:34:06 +08:00
return PAK_IGNORE;
}
2022-09-02 01:27:05 +08:00
2022-09-02 23:34:06 +08:00
int v110 = CSecu_ProtectionField::Get()->Check(user, 38);
if (v110)
{
user->SendCmdErrorPacket(84, v110);
return PAK_IGNORE;
}
2022-09-02 01:27:05 +08:00
2024-05-24 19:02:09 +08:00
YLOG(u8"UseEquipmentMoveItem :%s ", Utils::ToHexString((const unsigned char *)pBuf->get_buf_ptr(0), 40).c_str());
2022-09-12 13:35:16 +08:00
short equipment_pos = 0;
int equipment_id = 0;
short item_pos = 0;
2024-04-24 10:25:44 +08:00
if ((unsigned __int8)pBuf->get_short(&equipment_pos) != 1 || (unsigned __int8)pBuf->get_int(&equipment_id) != 1 || (unsigned __int8)pBuf->get_short(&item_pos) != 1)
2022-09-12 13:35:16 +08:00
{
user->SendCmdErrorPacket(84, -1);
return PAK_IGNORE;
}
2022-09-02 01:27:05 +08:00
2024-04-24 10:25:44 +08:00
// 1 <20><>Ʒ<EFBFBD><C6B7> 2 ʱװ
2022-09-02 23:34:06 +08:00
if (user->CheckItemLock(1, equipment_pos))
{
user->SendCmdErrorPacket(84, 0xD5);
return PAK_IGNORE;
}
2022-09-02 01:27:05 +08:00
2024-04-24 10:25:44 +08:00
CInventory *invenR = user->getCurCharacInvenR();
2022-09-02 23:34:06 +08:00
if (!invenR)
{
2024-05-24 19:02:09 +08:00
YLOG(u8"user->getCurCharacInvenW : error \n");
2022-09-02 23:34:06 +08:00
return PAK_IGNORE;
}
2024-04-24 10:25:44 +08:00
Inven_Item *equipment_InvenRef = invenR->GetInvenRef(CInventory::INVENTORY_TYPE_ITEM, equipment_pos);
2022-09-02 23:34:06 +08:00
if (!equipment_InvenRef)
{
2024-05-24 19:02:09 +08:00
YLOG(u8"inven->GetInvenRef : error \n");
2022-09-02 23:34:06 +08:00
return PAK_IGNORE;
}
2024-04-24 10:25:44 +08:00
Inven_Item *item_avartar = invenR->GetInvenRef(CInventory::INVENTORY_TYPE_ITEM, item_pos);
2022-09-02 23:34:06 +08:00
if (!item_avartar)
{
2024-05-24 19:02:09 +08:00
YLOG(u8"inven->GetInvenRef : error \n");
2022-09-02 23:34:06 +08:00
return PAK_IGNORE;
}
if (equipment_InvenRef->isEmpty())
{
2024-05-24 19:02:09 +08:00
YLOG(u8"equipment_InvenRef->isEmpty");
2022-09-02 23:34:06 +08:00
return PAK_IGNORE;
}
if (equipment_InvenRef->getKey() != equipment_id)
{
2024-05-24 19:02:09 +08:00
YLOG(u8"equipment_InvenRef->getKey() != equipment_id");
2022-09-02 23:34:06 +08:00
user->SendCmdErrorPacket(4, 0);
return PAK_IGNORE;
}
if (item_avartar->isEmpty())
{
2024-05-24 19:02:09 +08:00
YLOG(u8"item_avartar->isEmpty");
2022-09-02 23:34:06 +08:00
return PAK_IGNORE;
}
int item_id = item_avartar->getKey();
2024-04-24 10:25:44 +08:00
CDataManager *DataManager = CDataManager::G_CDataManager();
2022-09-02 23:34:06 +08:00
if (!DataManager)
{
2024-05-24 19:02:09 +08:00
YLOG(u8"G_CDataManager error");
2022-09-02 23:34:06 +08:00
return PAK_IGNORE;
}
2024-04-24 10:25:44 +08:00
CEquipItem *equipment_citem = (CEquipItem *)DataManager->find_item(equipment_id);
CStackableItem *item_citem = (CStackableItem *)DataManager->find_item(item_id);
2024-05-24 19:02:09 +08:00
YLOG(u8"equipment_citem +12: %p", *(int *)equipment_citem + 12);
2022-09-02 23:34:06 +08:00
if (!equipment_citem || !item_citem)
{
2024-05-24 19:02:09 +08:00
YLOG(u8"!equipment_citem || !item_citem");
2022-09-02 23:34:06 +08:00
return PAK_IGNORE;
}
2024-05-24 19:02:09 +08:00
YLOG(u8"UseEquipmentMoveItem [ equipment_pos:%d equipment_id:%d item_pos:%d item_id:%d ]", equipment_pos, equipment_id, item_pos, item_id);
2022-09-02 23:34:06 +08:00
2024-04-24 10:25:44 +08:00
// Data: equipment_citem->GetItemType=147418664 item_citem->is_stackable=1 item_citem->GetItemType=11
int equipment_Type = ((CEquipItem *)equipment_citem)->GetItemType();
2022-09-03 17:30:34 +08:00
int rarity = equipment_citem->get_rarity();
2022-09-12 18:11:08 +08:00
if (rarity != 4)
{
return PAK_OK;
}
2024-05-24 19:02:09 +08:00
YLOG(u8"Data: equipment_citem->GetItemType=%d item_citem->is_stackable=%d item_citem->GetItemType=%d", equipment_Type, item_citem->is_stackable(), item_citem->GetItemType());
2022-09-02 23:34:06 +08:00
if (equipment_Type <= 9 || equipment_Type > 21 || equipment_Type == 11)
{
2024-05-24 19:02:09 +08:00
YLOG(u8"equipment_Type <= 9 || equipment_Type > 21 || equipment_Type == 11");
2022-09-02 23:34:06 +08:00
user->SendCmdErrorPacket(84, 0xD5);
return PAK_IGNORE;
}
if (item_citem->is_stackable() != true || item_citem->GetItemType() != ITEM_TYPE_CONSUMABLES)
{
2024-05-24 19:02:09 +08:00
YLOG(u8"item_citem->is_stackable() != true || item_citem->GetItemType() != ITEM_TYPE_CONSUMABLES");
2022-09-02 23:34:06 +08:00
2024-04-24 10:25:44 +08:00
// û<>о<EFBFBD><D0BE><EFBFBD><EFBFBD>ֻ<EFBFBD><D6BB><EFBFBD>֤,<2C>޷<EFBFBD>ʹ<EFBFBD>øù<C3B8><C3B9><EFBFBD>
2022-09-02 23:34:06 +08:00
user->SendCmdErrorPacket(205, 209);
return PAK_IGNORE;
}
2022-09-03 17:30:34 +08:00
Inven_Item new_equipment_item = {};
invenR->GetInvenSlot(&new_equipment_item, CInventory::INVENTORY_TYPE_ITEM, equipment_pos);
2024-04-24 10:25:44 +08:00
int v9 = 0; // <20><><EFBFBD>ظ<EFBFBD><D8B8>ͻ<EFBFBD><CDBB>˵Ĵ<CBB5><C4B4><EFBFBD><EFBFBD><EFBFBD>
2022-09-03 17:30:34 +08:00
if (item_id == ITEM_ID_KUAJIESHI)
2022-09-02 23:34:06 +08:00
{
2024-05-24 19:02:09 +08:00
YLOG(u8"user->CheckInTrade:%d", user->CheckInTrade());
2022-09-02 23:34:06 +08:00
if (user->CheckInTrade())
2022-09-02 01:27:05 +08:00
{
2022-09-02 23:34:06 +08:00
v9 = 19;
2022-09-02 01:27:05 +08:00
}
2022-09-02 23:34:06 +08:00
if (!user->IsExistAccountCargo())
2022-09-02 01:27:05 +08:00
{
2022-09-02 23:34:06 +08:00
v9 = 19;
2024-05-24 19:02:09 +08:00
YLOG(u8"user->IsExistAccountCargo :%d", user->IsExistAccountCargo());
2022-09-02 01:27:05 +08:00
}
2022-09-02 23:34:06 +08:00
else
2022-09-02 01:27:05 +08:00
{
2024-04-24 10:25:44 +08:00
CAccountCargo *AccountCargo = user->GetAccountCargo();
2022-09-02 01:27:05 +08:00
2024-05-24 19:02:09 +08:00
YLOG(u8"ins_item.IsTradeLimitAttachTypeItem :%d", new_equipment_item.IsTradeLimitAttachTypeItem());
YLOG(u8"AccountCargo->CheckInsertCondition :%d", AccountCargo->CheckInsertCondition(&new_equipment_item));
2022-09-02 01:27:05 +08:00
2022-09-02 23:34:06 +08:00
int empty_slot = 0;
if (AccountCargo->CheckSlotEmpty(empty_slot) != 1)
{
empty_slot = AccountCargo->GetEmptySlot();
if (empty_slot < 0)
{
v9 = 4;
2024-05-24 19:02:09 +08:00
YLOG("AccountCargo->CheckSlotEmpty :%d", empty_slot);
2022-09-02 23:34:06 +08:00
return PAK_IGNORE;
}
}
2024-05-24 19:02:09 +08:00
YLOG(u8"empty_slot :%d", empty_slot);
2024-04-24 10:25:44 +08:00
// inven->delete_item(1, emblem_inven_slot, 1, 8, 1);
2022-09-02 23:34:06 +08:00
auto invenW = user->getCurCharacInvenW();
2024-04-24 10:25:44 +08:00
InterfacePacketBuf *packet_guard = (InterfacePacketBuf *)PacketGuard::NewPacketGuard();
2024-05-24 19:02:09 +08:00
YLOG("%p", invenW);
2022-09-02 23:34:06 +08:00
if (invenW->delete_item(CInventory::INVENTORY_TYPE_ITEM, equipment_pos, 1, 37, 1) && invenW->delete_item(CInventory::INVENTORY_TYPE_ITEM, item_pos, 1, 37, 1))
{
2022-09-03 17:30:34 +08:00
int a9 = AccountCargo->InsertItem(&new_equipment_item, empty_slot);
user->SendUpdateItemList(1, new_equipment_item.GetItemSpace(), equipment_pos);
2022-09-02 23:34:06 +08:00
user->SendUpdateItemList(1, item_avartar->GetItemSpace(), item_pos);
user->send_itemspace(12);
packet_guard->put_header(1, 2000);
packet_guard->put_int(1);
packet_guard->finalize(1);
2024-04-24 10:25:44 +08:00
user->Send((PacketGuard *)packet_guard);
PacketGuard::DelPacketGuard((PacketGuard *)packet_guard);
2022-09-12 18:11:08 +08:00
SendNoti(user, "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>װ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
2022-09-02 23:34:06 +08:00
return PAK_OK;
}
else
{
packet_guard->put_header(1, 2000);
packet_guard->put_int(0);
packet_guard->finalize(0);
2024-04-24 10:25:44 +08:00
user->Send((PacketGuard *)packet_guard);
PacketGuard::DelPacketGuard((PacketGuard *)packet_guard);
2022-09-12 18:11:08 +08:00
SendNoti(user, "װ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><EFBFBD>");
2022-09-02 23:34:06 +08:00
}
return PAK_IGNORE;
2022-09-02 01:27:05 +08:00
}
2022-09-02 23:34:06 +08:00
}
2022-09-02 01:27:05 +08:00
2022-09-02 23:34:06 +08:00
/*
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Call (2000)
<EFBFBD><EFBFBD>ԿCall (װ<EFBFBD><EFBFBD>λ<EFBFBD><EFBFBD>,2)
<EFBFBD><EFBFBD>ԿCall (װ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,4)
<EFBFBD><EFBFBD>ԿCall (<EFBFBD><EFBFBD>Ʒλ<EFBFBD><EFBFBD>,2)
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Call ()
*/
2024-04-24 10:25:44 +08:00
return PAK_OK;
2022-09-02 01:27:05 +08:00
}
2024-04-24 10:25:44 +08:00
ENUM_PACK_RET_TYPE CDispatch::Dispatcher_ModItemAttr_dispatch_sig(Dispatcher_ModItemAttr *dis_mod, CUser *user, PacketBuf *pBuf)
2022-09-03 17:30:34 +08:00
{
if (user->get_state() != 3 || !user->getCurCharacR())
{
user->SendCmdErrorPacket(84, 0xD1u);
return PAK_IGNORE;
}
2022-09-12 13:35:16 +08:00
short equipment_pos = 0;
int equipment_id = 0;
short item_pos = 0;
2024-04-24 10:25:44 +08:00
if ((unsigned __int8)pBuf->get_short(&equipment_pos) != 1 || (unsigned __int8)pBuf->get_int(&equipment_id) != 1 || (unsigned __int8)pBuf->get_short(&item_pos) != 1)
2022-09-12 13:35:16 +08:00
{
user->SendCmdErrorPacket(84, -1);
return PAK_IGNORE;
}
2022-09-03 17:30:34 +08:00
2024-04-24 10:25:44 +08:00
auto CurCharacInvenW = (CInventory *)user->getCurCharacInvenW();
2022-09-03 17:30:34 +08:00
Inven_Item equipment_inven = {};
CurCharacInvenW->GetInvenSlot(&equipment_inven, CInventory::INVENTORY_TYPE_ITEM, equipment_pos);
if (equipment_inven.isEmpty() || equipment_inven.getKey() != equipment_id)
{
user->SendCmdErrorPacket(84, 4);
return PAK_IGNORE;
}
2024-04-24 10:25:44 +08:00
CEquipItem *equipment_item = (CEquipItem *)CDataManager::G_CDataManager()->find_item(equipment_id);
2022-09-13 22:47:38 +08:00
2024-05-24 19:02:09 +08:00
YLOG("(*(int(**)(CItem*))(*(_DWORD*)equipment_item + 12)) :%p %p"
2022-09-17 00:49:27 +08:00
2024-05-24 19:02:09 +08:00
,
(*(int (**)(CItem *))(*(_DWORD *)equipment_item + 12)), ((int (**)(CItem *))(*(_DWORD *)equipment_item + 12))
2022-09-17 00:49:27 +08:00
2022-09-13 22:47:38 +08:00
);
2022-09-03 17:30:34 +08:00
if (!equipment_item)
{
user->SendCmdErrorPacket(84, 4);
return PAK_IGNORE;
}
2022-09-04 00:06:13 +08:00
int equipment_Type = equipment_item->GetItemType();
2022-09-03 17:30:34 +08:00
if (equipment_Type <= 9 || equipment_Type > 21 || equipment_Type == 11)
{
user->SendCmdErrorPacket(84, 19);
return PAK_IGNORE;
}
Inven_Item item_inven = {};
CurCharacInvenW->GetInvenSlot(&item_inven, CInventory::INVENTORY_TYPE_ITEM, item_pos);
if (item_inven.isEmpty())
{
user->SendCmdErrorPacket(84, 17);
return PAK_IGNORE;
}
if (user->CheckItemLock(1, equipment_pos))
{
user->SendCmdErrorPacket(84, 0xD5u);
return PAK_IGNORE;
}
if (item_inven.getKey() != ITEM_ID_YIJIRUHUN)
{
user->SendCmdErrorPacket(84, 17);
return PAK_IGNORE;
}
2024-04-24 10:25:44 +08:00
int grade = equipment_item->get_grade(); // <20><><EFBFBD><EFBFBD><EFBFBD>ȼ<EFBFBD>
int rarity = equipment_item->get_rarity(); // ϡ<><CFA1>
2022-09-03 17:30:34 +08:00
int attach_type = equipment_item->GetAttachType();
auto add_info = item_inven.get_add_info();
if (equipment_item->GetAttachType() != 3)
{
user->SendCmdErrorPacket(84, 19);
return PAK_IGNORE;
}
if (equipment_inven.package != 0)
{
user->SendCmdErrorPacket(84, 18);
return PAK_IGNORE;
}
if (CurCharacInvenW->delete_item(CInventory::INVENTORY_TYPE_ITEM, item_pos, 1, 3, 1) != 1)
{
user->SendCmdErrorPacket(84, -3);
return PAK_IGNORE;
}
equipment_inven.package = 1;
CurCharacInvenW->update_item(
CInventory::INVENTORY_TYPE_ITEM,
equipment_pos,
equipment_inven);
2022-09-12 13:35:16 +08:00
2022-09-03 17:30:34 +08:00
dis_mod->_SendResult(user, 1, item_pos, equipment_pos);
return PAK_IGNORE;
}
2022-09-02 01:27:05 +08:00
2024-04-24 10:25:44 +08:00
ENUM_PACK_RET_TYPE CDispatch::UseJewel_dispatch_sig(void *pDispatcher_UseJewel, CUser *user, PacketBuf *pBuf)
2022-09-12 13:35:16 +08:00
{
printf("getCurCharacName :%s \n", user->getCurCharacName().c_str());
printf("getCurCharacNo :%d \n", user->getCurCharacNo());
printf("get_buf_ptr :%p %p \n", pBuf->get_buf_ptr(0));
printf("get_len :%d \n", pBuf->get_len());
// printf("pBuf :%s \n", Util::ToHexString((const unsigned char*)pBuf->get_buf_ptr(0),40).c_str());
int state = user->get_state();
2024-05-24 19:02:09 +08:00
YLOG("state :%d \n", state);
2024-04-24 10:25:44 +08:00
// У<><D0A3><EFBFBD><EFBFBD>ɫ״̬<D7B4>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƕ
2022-09-12 13:35:16 +08:00
if (state != 3)
return PAK_IGNORE;
int isEnableAvatarSocketAction = user->isEnableAvatarSocketAction();
if (isEnableAvatarSocketAction)
user->SendCmdErrorPacket(205, (unsigned char)isEnableAvatarSocketAction);
2024-04-24 10:25:44 +08:00
// <20><><EFBFBD><EFBFBD>packet_buf
2022-09-12 13:35:16 +08:00
2024-04-24 10:25:44 +08:00
short avartar_inven_slot = 0; // ʱװ<CAB1><D7B0><EFBFBD>ڵı<DAB5><C4B1><EFBFBD><EFBFBD><EFBFBD>
int avartar_item_id = 0; // ʱװitem_id
char emblem_cnt = 0; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƕ<EFBFBD><C7B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2022-09-12 13:35:16 +08:00
2024-04-24 10:25:44 +08:00
if ((unsigned __int8)pBuf->get_short(&avartar_inven_slot) != 1 || (unsigned __int8)pBuf->get_int(&avartar_item_id) != 1 || (unsigned __int8)pBuf->get_byte(&emblem_cnt) != 1)
2022-09-12 13:35:16 +08:00
{
user->SendCmdErrorPacket(205, -1);
return PAK_IGNORE;
}
if (user->CheckItemLock(2, avartar_inven_slot))
{
user->SendCmdErrorPacket(205, 213);
return PAK_IGNORE;
}
2024-04-24 10:25:44 +08:00
// <20><>ȡʱװ<CAB1><D7B0><EFBFBD><EFBFBD>
CInventory *CurCharacInvenW = user->getCurCharacInvenW();
2022-09-17 00:49:27 +08:00
if (!CurCharacInvenW)
2022-09-12 13:35:16 +08:00
{
2024-05-24 19:02:09 +08:00
YLOG("pUser->getCurCharacInvenW : error \n");
2022-09-12 13:35:16 +08:00
return PAK_IGNORE;
}
2024-04-24 10:25:44 +08:00
Inven_Item *avartar_inven_item = CurCharacInvenW->GetInvenRef(CInventory::INVENTORY_TYPE_AVARTAR, avartar_inven_slot);
2022-09-17 00:49:27 +08:00
if (!avartar_inven_item)
2022-09-12 13:35:16 +08:00
{
2024-05-24 19:02:09 +08:00
YLOG("inven->GetInvenRef : error \n");
2022-09-12 13:35:16 +08:00
return PAK_IGNORE;
}
2024-04-24 10:25:44 +08:00
// У<><D0A3>ʱװ <20><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7>Ϸ<EFBFBD>
2022-09-17 00:49:27 +08:00
if (avartar_inven_item->isEmpty() || (avartar_inven_item->getKey() != avartar_item_id) || user->CheckItemLock(2, avartar_inven_slot))
2022-09-12 13:35:16 +08:00
{
2024-05-24 19:02:09 +08:00
YLOG("avartar->isEmpty() || avartar->getKey() || pUser->CheckItemLock() : error \n");
2022-09-12 13:35:16 +08:00
return PAK_IGNORE;
}
2024-04-24 10:25:44 +08:00
// <20><>ȡʱװ<CAB1><D7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2022-09-17 00:49:27 +08:00
auto avartar_add_info = avartar_inven_item->get_add_info();
2024-04-24 10:25:44 +08:00
auto inven_avartar_mgr = (WongWork::CAvatarItemMgr *)CurCharacInvenW->GetAvatarItemMgrW();
2022-09-17 00:49:27 +08:00
2024-04-24 10:25:44 +08:00
stAvatarEmblemInfo_t *JewelSocketData = (stAvatarEmblemInfo_t *)inven_avartar_mgr->getJewelSocketData(avartar_add_info);
2022-09-17 00:49:27 +08:00
if (!JewelSocketData)
2022-09-12 13:35:16 +08:00
{
2024-05-24 19:02:09 +08:00
YLOG("jewel_socket_data : error \n");
2022-09-12 13:35:16 +08:00
return PAK_IGNORE;
}
2024-05-24 19:02:09 +08:00
YLOG("jewel_socket_data 1:%s \n", Utils::ToHexString((const unsigned char *)JewelSocketData, 30).c_str());
2022-09-12 13:35:16 +08:00
if (emblem_cnt <= 3)
{
std::map<int, std::pair<int, int>> emblems;
for (int i = 0; i < emblem_cnt; i++)
{
2024-04-24 10:25:44 +08:00
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵı<DAB5><C4B1><EFBFBD><EFBFBD><EFBFBD>
2022-09-12 13:35:16 +08:00
short emblem_inven_slot = 0;
pBuf->get_short(&emblem_inven_slot);
2024-04-24 10:25:44 +08:00
// <20><><EFBFBD><EFBFBD>item_id
2022-09-12 13:35:16 +08:00
int emblem_item_id = 0;
pBuf->get_int(&emblem_item_id);
2024-04-24 10:25:44 +08:00
// <20>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>Ƕ<EFBFBD><C7B6>ʱװ<CAB1><D7B0><EFBFBD><EFBFBD>id
2022-09-12 13:35:16 +08:00
char avartar_socket_slot = 0;
pBuf->get_byte(&avartar_socket_slot);
2024-05-24 19:02:09 +08:00
YLOG("emblem_inven_slot :%d emblem_item_id :%d avartar_socket_slot :%d", emblem_inven_slot, emblem_item_id, avartar_socket_slot);
2022-09-17 00:49:27 +08:00
2024-04-24 10:25:44 +08:00
// <20><>ȡ<EFBFBD><C8A1><EFBFBD>µ<EFBFBD><C2B5><EFBFBD>
Inven_Item *emblem = CurCharacInvenW->GetInvenRef(CInventory::INVENTORY_TYPE_ITEM, emblem_inven_slot);
// У<><D0A3><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7>Ϸ<EFBFBD>
2022-09-12 13:35:16 +08:00
if (emblem->isEmpty() || (emblem->getKey() != emblem_item_id) || (avartar_socket_slot >= 3))
{
2024-05-24 19:02:09 +08:00
YLOG("emblem->isEmpty() || (emblem->getKey() : error \n");
2022-09-12 13:35:16 +08:00
user->SendCmdErrorPacket(205, 209);
return PAK_IGNORE;
}
2024-04-24 10:25:44 +08:00
// У<><D0A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>ʱװ<CAB1><D7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫҪ<C9AB><D2AA>
2022-09-12 13:35:16 +08:00
2024-04-24 10:25:44 +08:00
// <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>pvf<76><66><EFBFBD><EFBFBD>
CDataManager *DataManager = CDataManager::G_CDataManager();
2022-09-12 13:35:16 +08:00
if (!DataManager)
{
2024-05-24 19:02:09 +08:00
YLOG("CDataManager::G_CDataManager() : error \n");
2022-09-12 13:35:16 +08:00
user->SendCmdErrorPacket(205, 209);
return PAK_IGNORE;
}
2024-04-24 10:25:44 +08:00
CStackableItem *citem = (CStackableItem *)DataManager->find_item(emblem_item_id);
2022-09-12 13:35:16 +08:00
if (!citem)
{
2024-05-24 19:02:09 +08:00
YLOG("DataManager->find_item() : error \n");
2022-09-12 13:35:16 +08:00
user->SendCmdErrorPacket(205, 209);
return PAK_IGNORE;
}
2024-04-24 10:25:44 +08:00
// У<><D0A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2022-09-12 13:35:16 +08:00
if (!citem->is_stackable() || (citem->GetItemType() != 20))
{
2024-05-24 19:02:09 +08:00
YLOG("citem->is_stackable() || (citem->GetItemType() : error \n");
2022-09-12 13:35:16 +08:00
user->SendCmdErrorPacket(205, 209);
return PAK_IGNORE;
}
2024-04-24 10:25:44 +08:00
// <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>֧<EFBFBD>ֵIJ<D6B5><C4B2><EFBFBD>
2022-09-12 13:35:16 +08:00
int emblem_socket_type = citem->getJewelTargetSocket();
2024-04-24 10:25:44 +08:00
// 01 00 C4 25 26 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
// <20><>ȡҪ<C8A1><D2AA>Ƕ<EFBFBD><C7B6>ʱװ<CAB1><D7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2022-09-17 00:49:27 +08:00
sizeof(stAvatarEmblemInfo_t);
int avartar_socket_type = JewelSocketData->EmblemSocketData[avartar_socket_slot].slot_type;
2024-05-24 19:02:09 +08:00
YLOG("emblem_socket_type :%d avartar_socket_type :%d", emblem_socket_type, avartar_socket_type);
2022-09-12 13:35:16 +08:00
if (!(emblem_socket_type & avartar_socket_type))
{
2024-04-24 10:25:44 +08:00
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ͳ<EFBFBD>ƥ<EFBFBD><C6A5>
2024-05-24 19:02:09 +08:00
YLOG("emblem_socket_type & avartar_socket_type\n");
2022-09-12 13:35:16 +08:00
user->SendCmdErrorPacket(205, 209);
return PAK_IGNORE;
}
2024-05-24 19:02:09 +08:00
YLOG("avartar_socket_slot:%d emblem_inven_slot:%d emblem_item_id:%d\n", avartar_socket_slot, emblem_inven_slot, emblem_item_id);
2022-09-12 13:35:16 +08:00
emblems[avartar_socket_slot] = std::make_pair(emblem_inven_slot, emblem_item_id);
2022-09-17 00:49:27 +08:00
if (CurCharacInvenW->delete_item(CInventory::INVENTORY_TYPE_ITEM, emblem_inven_slot, 1, 8, 1))
{
JewelSocketData->EmblemSocketData[avartar_socket_slot].slot_item_id = emblem_item_id;
}
2022-09-12 13:35:16 +08:00
}
2024-05-24 19:02:09 +08:00
YLOG("jewel_socket_data 2:%s \n", Utils::ToHexString((const unsigned char *)JewelSocketData, 30).c_str());
2022-09-12 13:35:16 +08:00
2022-09-17 00:49:27 +08:00
inven_avartar_mgr->setEmblemSocketData(avartar_add_info, JewelSocketData);
2024-04-24 10:25:44 +08:00
// ʱװ<CAB1><D7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݴ浵
DB_UpdateAvatarJewelSlot::makeRequest(user->getCurCharacNo(), (unsigned int)avartar_add_info, (void *)JewelSocketData);
2022-09-12 13:35:16 +08:00
2024-04-24 10:25:44 +08:00
// ֪ͨ<CDA8>ͻ<EFBFBD><CDBB><EFBFBD>ʱװ<CAB1><D7B0><EFBFBD><EFBFBD><EFBFBD>Ѹ<EFBFBD><D1B8><EFBFBD>
2022-09-12 13:35:16 +08:00
user->SendUpdateItemList(1, 1, avartar_inven_slot);
2024-04-24 10:25:44 +08:00
// <20>ذ<EFBFBD><D8B0><EFBFBD><EFBFBD>ͻ<EFBFBD><CDBB><EFBFBD>
InterfacePacketBuf *packet_guard = (InterfacePacketBuf *)PacketGuard::NewPacketGuard();
2022-09-12 13:35:16 +08:00
packet_guard->put_header(1, 204);
packet_guard->put_int(1);
packet_guard->finalize(1);
2024-04-24 10:25:44 +08:00
user->Send((PacketGuard *)packet_guard);
PacketGuard::DelPacketGuard((PacketGuard *)packet_guard);
2022-09-17 00:49:27 +08:00
SendNoti(user, "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƕ");
2022-09-12 13:35:16 +08:00
return PAK_OK;
}
return PAK_IGNORE;
}
2024-04-24 10:25:44 +08:00
ENUM_PACK_RET_TYPE CDispatch::MoveMap_dispatch_sig(void *a1, CUser *user, PacketBuf *pBuf)
2022-09-12 18:11:08 +08:00
{
USER_DATA data;
if (user_map.Find(user, &data))
{
auto CurTickCount = CSystemTime::G_CSystemTime()->getCurTickCount();
if (CurTickCount >= last_move_map_tickcount)
{
if ((CurTickCount - last_move_map_tickcount) <= 1000)
{
data.abnormal_data_count++;
}
last_move_map_tickcount = CurTickCount;
}
user_map.Change(user, data);
2024-04-24 10:25:44 +08:00
// <20>ж<EFBFBD><D0B6><EFBFBD><ECB3A3><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD>3
2022-09-12 18:11:08 +08:00
if (data.abnormal_data_count >= 3)
{
return PAK_ERROR;
}
}
return PAK_OK;
}
2024-04-24 10:25:44 +08:00
ENUM_PACK_RET_TYPE CDispatch::Inter_LoadEtc_dispatch_sig(void *a1, CUser *user, char *a3)
2022-09-12 18:11:08 +08:00
{
user->getCurCharacNo();
user->getCurCharacName();
user_map.Push(user, {});
return PAK_OK;
}
2024-04-24 10:25:44 +08:00
ENUM_PACK_RET_TYPE CDispatch::DisPatcher_ReturnToSelectCharacter_dispatch_sig(void *a1, CUser *user, char *a3)
2022-09-12 18:11:08 +08:00
{
user_map.Erase(user);
return PAK_OK;
}
2024-04-24 10:25:44 +08:00
ENUM_PACK_RET_TYPE CDispatch::ProcessIPG_ResultOutput(CUser *user, int Goods_No, int item_id, int Cera_Type, InterfacePacketBuf *pbuf)
2022-09-17 14:53:51 +08:00
{
2024-04-24 10:25:44 +08:00
if (Cera_Type == 0) // 0<>ǵ<EFBFBD>ȯ 1<>Ǵ<EFBFBD><C7B4><EFBFBD>
2022-09-17 14:53:51 +08:00
{
2022-09-21 16:28:11 +08:00
CeraShopBonusCodeType cera_shop_bonus_code_;
if (CGameDataManager::Get()->is_cera_shop_bonus_code(Goods_No, &cera_shop_bonus_code_))
2022-09-17 14:53:51 +08:00
{
2022-09-21 16:28:11 +08:00
CeraShopBonusItemType BonusItem;
int cur_purchase_count = cera_shop_bonus_code_.code_count;
if (cur_purchase_count > 0)
2022-09-17 14:53:51 +08:00
{
2022-09-21 16:28:11 +08:00
if (!CGameDataManager::Get()->get_cera_shop_bonus_item_map()->Find(cur_purchase_count, &BonusItem))
2022-09-17 14:53:51 +08:00
{
2022-09-21 16:28:11 +08:00
goto IPG_END;
2022-09-17 14:53:51 +08:00
}
2022-09-21 16:28:11 +08:00
}
else
{
if (!CGameDataManager::Get()->get_rand_cera_shop_bonus_item(&BonusItem))
2022-09-17 14:53:51 +08:00
{
2022-09-21 16:28:11 +08:00
goto IPG_END;
2022-09-17 14:53:51 +08:00
}
}
2022-09-21 16:28:11 +08:00
if (user->getCurCharacR())
2022-09-17 14:53:51 +08:00
{
2022-09-21 16:28:11 +08:00
if (BonusItem.item_num == 0)
2022-09-17 14:53:51 +08:00
{
2022-09-21 16:28:11 +08:00
goto IPG_END;
}
else if (BonusItem.item_id == 1)
{
WongWork::CCeraShop::G_CCeraShop()->_processCoin(user, BonusItem.item_num, 0);
}
else
{
auto item = CDataManager::G_CDataManager()->find_item(BonusItem.item_id);
if (item)
2022-09-17 14:53:51 +08:00
{
2024-04-24 10:25:44 +08:00
// if (item->is_stackable()
2022-09-21 16:28:11 +08:00
// && ((*(int(**)(CItem*))(*(_DWORD*)item + 12))(item) == 16 // GetItemType
// || (*(int(**)(CItem*))(*(_DWORD*)item + 12))(item) == 34)) // GetItemType
2022-09-17 14:53:51 +08:00
{
2022-09-21 16:28:11 +08:00
int inserted = -1;
Inven_Item v60 = {};
2024-04-24 10:25:44 +08:00
*(_DWORD *)((char *)&v60 + 2) = BonusItem.item_id;
*(_DWORD *)((char *)&v60 + 7) = BonusItem.item_num;
2022-09-17 14:53:51 +08:00
2024-04-24 10:25:44 +08:00
(*(void (**)(CItem *, Inven_Item *))(*(_DWORD *)item + 8))(item, &v60);
2022-09-17 14:53:51 +08:00
2024-04-24 10:25:44 +08:00
auto CurCharacInvenW = user->getCurCharacInvenW();
2022-09-17 14:53:51 +08:00
2022-09-21 16:28:11 +08:00
inserted = CurCharacInvenW->insertItemIntoInventory(v60, 15, 1, 0);
if (inserted == -1)
{
auto CurCharacNo = user->getCurCharacNo();
2022-09-17 14:53:51 +08:00
2024-04-24 10:25:44 +08:00
((WongWork::CMailBoxHelper *)(user))->ReqDBSendNewMailCashShop(&v60, 0, CurCharacNo, 1, 0, 0);
2022-09-17 14:53:51 +08:00
}
2022-09-21 16:28:11 +08:00
else
{
user->SendUpdateItemList(1, 0, inserted);
}
2022-09-17 14:53:51 +08:00
}
}
}
2022-09-21 16:28:11 +08:00
}
2022-09-17 14:53:51 +08:00
2022-09-21 16:28:11 +08:00
pbuf->put_int(BonusItem.item_id);
pbuf->put_int(BonusItem.item_num);
2022-09-17 14:53:51 +08:00
2024-04-24 10:25:44 +08:00
std::vector<unsigned char> code;
2022-09-21 16:28:11 +08:00
for (int i = 0; i < 0x30; i++)
{
code.push_back(0x90);
2022-09-17 14:53:51 +08:00
}
2024-04-24 10:25:44 +08:00
// 0817964F 0817967F
CMem::WriteBytes((void *)0x0817964F, code.data(), code.size());
2022-09-21 16:28:11 +08:00
return PAK_OK;
2022-09-17 14:53:51 +08:00
}
}
2022-09-21 16:28:11 +08:00
IPG_END:
2024-04-24 10:25:44 +08:00
std::vector<unsigned char> code = {
0x8B, 0x85, 0x04, 0xFF, 0xFF, 0xFF, 0x89, 0x44, 0x24, 0x04, 0x8D, 0x85, 0x14, 0xFF, 0xFF, 0xFF,
0x89, 0x04, 0x24, 0xE8, 0xD5, 0x22, 0xF5, 0xFF, 0x8B, 0x85, 0x00, 0xFF, 0xFF, 0xFF, 0x89, 0x44,
0x24, 0x04, 0x8D, 0x85, 0x14, 0xFF, 0xFF, 0xFF, 0x89, 0x04, 0x24, 0xE8, 0xBD, 0x22, 0xF5, 0xFF};
CMem::WriteBytes((void *)0x0817964F, code.data(), code.size());
2022-09-17 14:53:51 +08:00
return PAK_OK;
}
2024-04-24 10:25:44 +08:00
ENUM_PACK_RET_TYPE CDispatch::Init_done(int argc, const char **argv)
2022-09-21 16:28:11 +08:00
{
return PAK_OK;
}
2024-04-24 10:25:44 +08:00
ENUM_PACK_RET_TYPE CDispatch::importCashShopItemList(const std::string *str)
2022-09-21 16:28:11 +08:00
{
/**
[cash_shop_bonus_code]
3
10000 10053 0 0 <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡһ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
10054 10110 1 1 <EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD>
100178 100180 3 3 <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
[cash_shop_bonus_item]
3
1 3037 10
2 3037 100
3 3037 1000
*/
if (*str == "[cash_shop_bonus_code]")
{
int _total = ScanInt();
for (int i = 0; i < _total; i++)
{
CeraShopBonusCodeType cera_shop_bonus_ = {};
cera_shop_bonus_.code_min = ScanInt();
cera_shop_bonus_.code_max = ScanInt();
cera_shop_bonus_.code_count = ScanInt();
CGameDataManager::Get()->get_cera_shop_bonus_code_array()->push_back(cera_shop_bonus_);
}
}
else if (*str == "[cash_shop_bonus_item]")
{
int _total = ScanInt();
for (int i = 0; i < _total; i++)
{
int index_ = ScanInt();
int item_id = ScanInt();
int item_num = ScanInt();
int is_random = ScanInt();
if (is_random == 1)
{
2024-04-24 10:25:44 +08:00
CGameDataManager::Get()->get_cera_shop_bonus_item_map_rand()->Push(index_, {item_id, item_num, true});
2022-09-21 16:28:11 +08:00
}
CGameDataManager::Get()->add_cera_shop_bonus_item(index_, item_id, item_num, is_random);
}
}
return PAK_OK;
}
2024-04-24 10:25:44 +08:00
void CDispatch::SendMsg(CUser *user, int pack_id, int status, const std::string &str)
2022-09-12 18:11:08 +08:00
{
char out_str[0xff] = {};
memset(out_str, 0, sizeof(out_str));
2024-04-24 10:25:44 +08:00
DNFFLib::ConvertGBKtoUTF8((char *)str.c_str(), out_str);
InterfacePacketBuf *packet_guard = (InterfacePacketBuf *)PacketGuard::NewPacketGuard();
2022-09-12 18:11:08 +08:00
packet_guard->put_header(1, pack_id);
packet_guard->put_int(status);
packet_guard->put_int(strlen(out_str));
packet_guard->put_str(out_str, strlen(out_str));
2024-04-24 10:25:44 +08:00
user->Send((PacketGuard *)packet_guard);
PacketGuard::DelPacketGuard((PacketGuard *)packet_guard);
2022-09-12 18:11:08 +08:00
}
2024-04-24 10:25:44 +08:00
void CDispatch::SendNoti(CUser *user, const std::string &str, NOTI_PACKETMESSAGE_TYPE type)
2022-09-12 18:11:08 +08:00
{
char out_str[0xff] = {};
memset(out_str, 0, sizeof(out_str));
2024-04-24 10:25:44 +08:00
DNFFLib::ConvertGBKtoUTF8((char *)str.c_str(), out_str);
2022-09-12 18:11:08 +08:00
user->SendNotiPacketMessage(out_str, type);
}