698 lines
		
	
	
		
			20 KiB
		
	
	
	
		
			C++
		
	
	
	
			
		
		
	
	
			698 lines
		
	
	
		
			20 KiB
		
	
	
	
		
			C++
		
	
	
	
| //************************************
 | ||
| // 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() : last_move_map_tickcount(0)
 | ||
| {
 | ||
| }
 | ||
| 
 | ||
| CDispatch::~CDispatch()
 | ||
| {
 | ||
| }
 | ||
| 
 | ||
| ENUM_PACK_RET_TYPE CDispatch::UseEquipmentMoveItem(CUser *user, PacketBuf *pBuf)
 | ||
| {
 | ||
| 
 | ||
| 	if (user->get_state() != 3)
 | ||
| 	{
 | ||
| 		return PAK_IGNORE;
 | ||
| 	}
 | ||
| 
 | ||
| 	int v110 = CSecu_ProtectionField::Get()->Check(user, 38);
 | ||
| 	if (v110)
 | ||
| 	{
 | ||
| 		user->SendCmdErrorPacket(84, v110);
 | ||
| 		return PAK_IGNORE;
 | ||
| 	}
 | ||
| 
 | ||
| 	YLOG(u8"UseEquipmentMoveItem :%s ", Utils::ToHexString((const unsigned char *)pBuf->get_buf_ptr(0), 40).c_str());
 | ||
| 
 | ||
| 	short equipment_pos = 0;
 | ||
| 	int equipment_id = 0;
 | ||
| 	short item_pos = 0;
 | ||
| 
 | ||
| 	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)
 | ||
| 	{
 | ||
| 		user->SendCmdErrorPacket(84, -1);
 | ||
| 		return PAK_IGNORE;
 | ||
| 	}
 | ||
| 
 | ||
| 	// 1 ÎïÆ·À¸ 2 ʱװ
 | ||
| 	if (user->CheckItemLock(1, equipment_pos))
 | ||
| 	{
 | ||
| 		user->SendCmdErrorPacket(84, 0xD5);
 | ||
| 		return PAK_IGNORE;
 | ||
| 	}
 | ||
| 
 | ||
| 	CInventory *invenR = user->getCurCharacInvenR();
 | ||
| 	if (!invenR)
 | ||
| 	{
 | ||
| 		YLOG(u8"user->getCurCharacInvenW : error \n");
 | ||
| 		return PAK_IGNORE;
 | ||
| 	}
 | ||
| 
 | ||
| 	Inven_Item *equipment_InvenRef = invenR->GetInvenRef(CInventory::INVENTORY_TYPE_ITEM, equipment_pos);
 | ||
| 	if (!equipment_InvenRef)
 | ||
| 	{
 | ||
| 		YLOG(u8"inven->GetInvenRef : error \n");
 | ||
| 		return PAK_IGNORE;
 | ||
| 	}
 | ||
| 	Inven_Item *item_avartar = invenR->GetInvenRef(CInventory::INVENTORY_TYPE_ITEM, item_pos);
 | ||
| 	if (!item_avartar)
 | ||
| 	{
 | ||
| 		YLOG(u8"inven->GetInvenRef : error \n");
 | ||
| 		return PAK_IGNORE;
 | ||
| 	}
 | ||
| 
 | ||
| 	if (equipment_InvenRef->isEmpty())
 | ||
| 	{
 | ||
| 		YLOG(u8"equipment_InvenRef->isEmpty");
 | ||
| 		return PAK_IGNORE;
 | ||
| 	}
 | ||
| 	if (equipment_InvenRef->getKey() != equipment_id)
 | ||
| 	{
 | ||
| 		YLOG(u8"equipment_InvenRef->getKey() != equipment_id");
 | ||
| 		user->SendCmdErrorPacket(4, 0);
 | ||
| 		return PAK_IGNORE;
 | ||
| 	}
 | ||
| 
 | ||
| 	if (item_avartar->isEmpty())
 | ||
| 	{
 | ||
| 		YLOG(u8"item_avartar->isEmpty");
 | ||
| 		return PAK_IGNORE;
 | ||
| 	}
 | ||
| 
 | ||
| 	int item_id = item_avartar->getKey();
 | ||
| 
 | ||
| 	CDataManager *DataManager = CDataManager::G_CDataManager();
 | ||
| 
 | ||
| 	if (!DataManager)
 | ||
| 	{
 | ||
| 		YLOG(u8"G_CDataManager error");
 | ||
| 		return PAK_IGNORE;
 | ||
| 	}
 | ||
| 
 | ||
| 	CEquipItem *equipment_citem = (CEquipItem *)DataManager->find_item(equipment_id);
 | ||
| 	CStackableItem *item_citem = (CStackableItem *)DataManager->find_item(item_id);
 | ||
| 	YLOG(u8"equipment_citem +12: %p", *(int *)equipment_citem + 12);
 | ||
| 
 | ||
| 	if (!equipment_citem || !item_citem)
 | ||
| 	{
 | ||
| 		YLOG(u8"!equipment_citem || !item_citem");
 | ||
| 		return PAK_IGNORE;
 | ||
| 	}
 | ||
| 
 | ||
| 	YLOG(u8"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
 | ||
| 	int equipment_Type = ((CEquipItem *)equipment_citem)->GetItemType();
 | ||
| 	int rarity = equipment_citem->get_rarity();
 | ||
| 	if (rarity != 4)
 | ||
| 	{
 | ||
| 		return PAK_OK;
 | ||
| 	}
 | ||
| 
 | ||
| 	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());
 | ||
| 
 | ||
| 	if (equipment_Type <= 9 || equipment_Type > 21 || equipment_Type == 11)
 | ||
| 	{
 | ||
| 		YLOG(u8"equipment_Type <= 9 || equipment_Type > 21 || equipment_Type == 11");
 | ||
| 		user->SendCmdErrorPacket(84, 0xD5);
 | ||
| 		return PAK_IGNORE;
 | ||
| 	}
 | ||
| 
 | ||
| 	if (item_citem->is_stackable() != true || item_citem->GetItemType() != ITEM_TYPE_CONSUMABLES)
 | ||
| 	{
 | ||
| 		YLOG(u8"item_citem->is_stackable() != true || item_citem->GetItemType() != ITEM_TYPE_CONSUMABLES");
 | ||
| 
 | ||
| 		// ûÓоµÏñÊÖ»úÈÏÖ¤,ÎÞ·¨Ê¹Óøù¦ÄÜ
 | ||
| 		user->SendCmdErrorPacket(205, 209);
 | ||
| 		return PAK_IGNORE;
 | ||
| 	}
 | ||
| 
 | ||
| 	Inven_Item new_equipment_item = {};
 | ||
| 	invenR->GetInvenSlot(&new_equipment_item, CInventory::INVENTORY_TYPE_ITEM, equipment_pos);
 | ||
| 
 | ||
| 	int v9 = 0; // ·µ»Ø¸ø¿Í»§¶ËµÄ´íÎóÂë
 | ||
| 	if (item_id == ITEM_ID_KUAJIESHI)
 | ||
| 	{
 | ||
| 		YLOG(u8"user->CheckInTrade:%d", user->CheckInTrade());
 | ||
| 
 | ||
| 		if (user->CheckInTrade())
 | ||
| 		{
 | ||
| 			v9 = 19;
 | ||
| 		}
 | ||
| 		if (!user->IsExistAccountCargo())
 | ||
| 		{
 | ||
| 			v9 = 19;
 | ||
| 			YLOG(u8"user->IsExistAccountCargo :%d", user->IsExistAccountCargo());
 | ||
| 		}
 | ||
| 		else
 | ||
| 		{
 | ||
| 			CAccountCargo *AccountCargo = user->GetAccountCargo();
 | ||
| 
 | ||
| 			YLOG(u8"ins_item.IsTradeLimitAttachTypeItem :%d", new_equipment_item.IsTradeLimitAttachTypeItem());
 | ||
| 			YLOG(u8"AccountCargo->CheckInsertCondition :%d", AccountCargo->CheckInsertCondition(&new_equipment_item));
 | ||
| 
 | ||
| 			int empty_slot = 0;
 | ||
| 			if (AccountCargo->CheckSlotEmpty(empty_slot) != 1)
 | ||
| 			{
 | ||
| 				empty_slot = AccountCargo->GetEmptySlot();
 | ||
| 				if (empty_slot < 0)
 | ||
| 				{
 | ||
| 					v9 = 4;
 | ||
| 					YLOG("AccountCargo->CheckSlotEmpty :%d", empty_slot);
 | ||
| 					return PAK_IGNORE;
 | ||
| 				}
 | ||
| 			}
 | ||
| 			YLOG(u8"empty_slot :%d", empty_slot);
 | ||
| 			// inven->delete_item(1, emblem_inven_slot, 1, 8, 1);
 | ||
| 			auto invenW = user->getCurCharacInvenW();
 | ||
| 			InterfacePacketBuf *packet_guard = (InterfacePacketBuf *)PacketGuard::NewPacketGuard();
 | ||
| 			YLOG("%p", invenW);
 | ||
| 			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))
 | ||
| 			{
 | ||
| 				int a9 = AccountCargo->InsertItem(&new_equipment_item, empty_slot);
 | ||
| 				user->SendUpdateItemList(1, new_equipment_item.GetItemSpace(), equipment_pos);
 | ||
| 				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);
 | ||
| 				user->Send((PacketGuard *)packet_guard);
 | ||
| 				PacketGuard::DelPacketGuard((PacketGuard *)packet_guard);
 | ||
| 				SendNoti(user, "ÒÑÍê³É×°±¸¿ç½ç");
 | ||
| 
 | ||
| 				return PAK_OK;
 | ||
| 			}
 | ||
| 			else
 | ||
| 			{
 | ||
| 				packet_guard->put_header(1, 2000);
 | ||
| 				packet_guard->put_int(0);
 | ||
| 				packet_guard->finalize(0);
 | ||
| 				user->Send((PacketGuard *)packet_guard);
 | ||
| 				PacketGuard::DelPacketGuard((PacketGuard *)packet_guard);
 | ||
| 				SendNoti(user, "×°±¸¿ç½çʧ°Ü");
 | ||
| 			}
 | ||
| 			return PAK_IGNORE;
 | ||
| 		}
 | ||
| 	}
 | ||
| 
 | ||
| 	/*
 | ||
| 		»º³åCall (2000)
 | ||
| 		ÃÜÔ¿Call (×°±¸Î»ÖÃ,2)
 | ||
| 		ÃÜÔ¿Call (×°±¸´úÂë,4)
 | ||
| 		ÃÜÔ¿Call (ÎïÆ·Î»ÖÃ,2)
 | ||
| 		·¢°üCall ()
 | ||
| 	*/
 | ||
| 	return PAK_OK;
 | ||
| }
 | ||
| 
 | ||
| ENUM_PACK_RET_TYPE CDispatch::Dispatcher_ModItemAttr_dispatch_sig(Dispatcher_ModItemAttr *dis_mod, CUser *user, PacketBuf *pBuf)
 | ||
| {
 | ||
| 	if (user->get_state() != 3 || !user->getCurCharacR())
 | ||
| 	{
 | ||
| 		user->SendCmdErrorPacket(84, 0xD1u);
 | ||
| 		return PAK_IGNORE;
 | ||
| 	}
 | ||
| 	short equipment_pos = 0;
 | ||
| 	int equipment_id = 0;
 | ||
| 	short item_pos = 0;
 | ||
| 
 | ||
| 	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)
 | ||
| 	{
 | ||
| 		user->SendCmdErrorPacket(84, -1);
 | ||
| 		return PAK_IGNORE;
 | ||
| 	}
 | ||
| 
 | ||
| 	auto CurCharacInvenW = (CInventory *)user->getCurCharacInvenW();
 | ||
| 	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;
 | ||
| 	}
 | ||
| 	CEquipItem *equipment_item = (CEquipItem *)CDataManager::G_CDataManager()->find_item(equipment_id);
 | ||
| 
 | ||
| 	YLOG("(*(int(**)(CItem*))(*(_DWORD*)equipment_item + 12)) :%p  %p"
 | ||
| 
 | ||
| 		 ,
 | ||
| 		 (*(int (**)(CItem *))(*(_DWORD *)equipment_item + 12)), ((int (**)(CItem *))(*(_DWORD *)equipment_item + 12))
 | ||
| 
 | ||
| 	);
 | ||
| 
 | ||
| 	if (!equipment_item)
 | ||
| 	{
 | ||
| 		user->SendCmdErrorPacket(84, 4);
 | ||
| 		return PAK_IGNORE;
 | ||
| 	}
 | ||
| 
 | ||
| 	int equipment_Type = equipment_item->GetItemType();
 | ||
| 
 | ||
| 	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;
 | ||
| 	}
 | ||
| 
 | ||
| 	int grade = equipment_item->get_grade();   // µôÂäµÈ¼¶
 | ||
| 	int rarity = equipment_item->get_rarity(); // Ï¡ÓÐ
 | ||
| 	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);
 | ||
| 
 | ||
| 	dis_mod->_SendResult(user, 1, item_pos, equipment_pos);
 | ||
| 
 | ||
| 	return PAK_IGNORE;
 | ||
| }
 | ||
| 
 | ||
| ENUM_PACK_RET_TYPE CDispatch::UseJewel_dispatch_sig(void *pDispatcher_UseJewel, CUser *user, PacketBuf *pBuf)
 | ||
| {
 | ||
| 	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();
 | ||
| 	YLOG("state :%d \n", state);
 | ||
| 	// УÑé½Çɫ״̬ÊÇ·ñÔÊÐíÏâǶ
 | ||
| 	if (state != 3)
 | ||
| 		return PAK_IGNORE;
 | ||
| 
 | ||
| 	int isEnableAvatarSocketAction = user->isEnableAvatarSocketAction();
 | ||
| 	if (isEnableAvatarSocketAction)
 | ||
| 		user->SendCmdErrorPacket(205, (unsigned char)isEnableAvatarSocketAction);
 | ||
| 	// ½âÎöpacket_buf
 | ||
| 
 | ||
| 	short avartar_inven_slot = 0; // ʱװËùÔڵı³°ü²Û
 | ||
| 	int avartar_item_id = 0;	  // ʱװitem_id
 | ||
| 	char emblem_cnt = 0;		  // ±¾´ÎÏâǶ»ÕÕÂÊýÁ¿
 | ||
| 
 | ||
| 	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)
 | ||
| 	{
 | ||
| 		user->SendCmdErrorPacket(205, -1);
 | ||
| 		return PAK_IGNORE;
 | ||
| 	}
 | ||
| 
 | ||
| 	if (user->CheckItemLock(2, avartar_inven_slot))
 | ||
| 	{
 | ||
| 		user->SendCmdErrorPacket(205, 213);
 | ||
| 		return PAK_IGNORE;
 | ||
| 	}
 | ||
| 
 | ||
| 	// »ñȡʱװµÀ¾ß
 | ||
| 	CInventory *CurCharacInvenW = user->getCurCharacInvenW();
 | ||
| 	if (!CurCharacInvenW)
 | ||
| 	{
 | ||
| 		YLOG("pUser->getCurCharacInvenW : error \n");
 | ||
| 		return PAK_IGNORE;
 | ||
| 	}
 | ||
| 	Inven_Item *avartar_inven_item = CurCharacInvenW->GetInvenRef(CInventory::INVENTORY_TYPE_AVARTAR, avartar_inven_slot);
 | ||
| 	if (!avartar_inven_item)
 | ||
| 	{
 | ||
| 		YLOG("inven->GetInvenRef : error \n");
 | ||
| 		return PAK_IGNORE;
 | ||
| 	}
 | ||
| 	// УÑéʱװ Êý¾ÝÊÇ·ñºÏ·¨
 | ||
| 	if (avartar_inven_item->isEmpty() || (avartar_inven_item->getKey() != avartar_item_id) || user->CheckItemLock(2, avartar_inven_slot))
 | ||
| 	{
 | ||
| 
 | ||
| 		YLOG("avartar->isEmpty() || avartar->getKey() || pUser->CheckItemLock() : error \n");
 | ||
| 		return PAK_IGNORE;
 | ||
| 	}
 | ||
| 	// »ñȡʱװ²å²ÛÊý¾Ý
 | ||
| 	auto avartar_add_info = avartar_inven_item->get_add_info();
 | ||
| 	auto inven_avartar_mgr = (WongWork::CAvatarItemMgr *)CurCharacInvenW->GetAvatarItemMgrW();
 | ||
| 
 | ||
| 	stAvatarEmblemInfo_t *JewelSocketData = (stAvatarEmblemInfo_t *)inven_avartar_mgr->getJewelSocketData(avartar_add_info);
 | ||
| 
 | ||
| 	if (!JewelSocketData)
 | ||
| 	{
 | ||
| 		YLOG("jewel_socket_data : error \n");
 | ||
| 		return PAK_IGNORE;
 | ||
| 	}
 | ||
| 
 | ||
| 	YLOG("jewel_socket_data 1:%s \n", Utils::ToHexString((const unsigned char *)JewelSocketData, 30).c_str());
 | ||
| 	if (emblem_cnt <= 3)
 | ||
| 	{
 | ||
| 		std::map<int, std::pair<int, int>> emblems;
 | ||
| 		for (int i = 0; i < emblem_cnt; i++)
 | ||
| 		{
 | ||
| 			// »ÕÕÂËùÔڵı³°ü²Û
 | ||
| 			short emblem_inven_slot = 0;
 | ||
| 			pBuf->get_short(&emblem_inven_slot);
 | ||
| 			// »ÕÕÂitem_id
 | ||
| 			int emblem_item_id = 0;
 | ||
| 			pBuf->get_int(&emblem_item_id);
 | ||
| 			// ¸Ã»ÕÕÂÏâǶµÄʱװ²å²Ûid
 | ||
| 			char avartar_socket_slot = 0;
 | ||
| 			pBuf->get_byte(&avartar_socket_slot);
 | ||
| 
 | ||
| 			YLOG("emblem_inven_slot :%d emblem_item_id :%d avartar_socket_slot :%d", emblem_inven_slot, emblem_item_id, avartar_socket_slot);
 | ||
| 
 | ||
| 			// »ñÈ¡»ÕÕµÀ¾ß
 | ||
| 			Inven_Item *emblem = CurCharacInvenW->GetInvenRef(CInventory::INVENTORY_TYPE_ITEM, emblem_inven_slot);
 | ||
| 			// УÑé»ÕÕ¼°²å²ÛÊý¾ÝÊÇ·ñºÏ·¨
 | ||
| 			if (emblem->isEmpty() || (emblem->getKey() != emblem_item_id) || (avartar_socket_slot >= 3))
 | ||
| 			{
 | ||
| 				YLOG("emblem->isEmpty() || (emblem->getKey() : error \n");
 | ||
| 				user->SendCmdErrorPacket(205, 209);
 | ||
| 				return PAK_IGNORE;
 | ||
| 			}
 | ||
| 
 | ||
| 			// УÑé»ÕÕÂÊÇ·ñÂú×ãʱװ²å²ÛÑÕɫҪÇó
 | ||
| 
 | ||
| 			// »ñÈ¡»ÕÕÂpvfÊý¾Ý
 | ||
| 			CDataManager *DataManager = CDataManager::G_CDataManager();
 | ||
| 			if (!DataManager)
 | ||
| 			{
 | ||
| 				YLOG("CDataManager::G_CDataManager() : error \n");
 | ||
| 				user->SendCmdErrorPacket(205, 209);
 | ||
| 				return PAK_IGNORE;
 | ||
| 			}
 | ||
| 			CStackableItem *citem = (CStackableItem *)DataManager->find_item(emblem_item_id);
 | ||
| 			if (!citem)
 | ||
| 			{
 | ||
| 				YLOG("DataManager->find_item() : error \n");
 | ||
| 				user->SendCmdErrorPacket(205, 209);
 | ||
| 				return PAK_IGNORE;
 | ||
| 			}
 | ||
| 
 | ||
| 			// УÑé»ÕÕÂÀàÐÍ
 | ||
| 			if (!citem->is_stackable() || (citem->GetItemType() != 20))
 | ||
| 			{
 | ||
| 				YLOG("citem->is_stackable() || (citem->GetItemType() : error \n");
 | ||
| 				user->SendCmdErrorPacket(205, 209);
 | ||
| 				return PAK_IGNORE;
 | ||
| 			}
 | ||
| 
 | ||
| 			// »ñÈ¡»ÕÕÂÖ§³ÖµÄ²å²Û
 | ||
| 			int emblem_socket_type = citem->getJewelTargetSocket();
 | ||
| 
 | ||
| 			// 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
 | ||
| 			// »ñȡҪÏâǶµÄʱװ²å²ÛÀàÐÍ
 | ||
| 
 | ||
| 			sizeof(stAvatarEmblemInfo_t);
 | ||
| 
 | ||
| 			int avartar_socket_type = JewelSocketData->EmblemSocketData[avartar_socket_slot].slot_type;
 | ||
| 			YLOG("emblem_socket_type :%d avartar_socket_type :%d", emblem_socket_type, avartar_socket_type);
 | ||
| 			if (!(emblem_socket_type & avartar_socket_type))
 | ||
| 			{
 | ||
| 				// ²å²ÛÀàÐͲ»Æ¥Åä
 | ||
| 				YLOG("emblem_socket_type & avartar_socket_type\n");
 | ||
| 				user->SendCmdErrorPacket(205, 209);
 | ||
| 				return PAK_IGNORE;
 | ||
| 			}
 | ||
| 			YLOG("avartar_socket_slot:%d emblem_inven_slot:%d emblem_item_id:%d\n", avartar_socket_slot, emblem_inven_slot, emblem_item_id);
 | ||
| 			emblems[avartar_socket_slot] = std::make_pair(emblem_inven_slot, emblem_item_id);
 | ||
| 
 | ||
| 			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;
 | ||
| 			}
 | ||
| 		}
 | ||
| 
 | ||
| 		YLOG("jewel_socket_data 2:%s \n", Utils::ToHexString((const unsigned char *)JewelSocketData, 30).c_str());
 | ||
| 
 | ||
| 		inven_avartar_mgr->setEmblemSocketData(avartar_add_info, JewelSocketData);
 | ||
| 		// ʱװ²å²ÛÊý¾Ý´æµµ
 | ||
| 		DB_UpdateAvatarJewelSlot::makeRequest(user->getCurCharacNo(), (unsigned int)avartar_add_info, (void *)JewelSocketData);
 | ||
| 
 | ||
| 		// ֪ͨ¿Í»§¶ËʱװÊý¾ÝÒѸüÐÂ
 | ||
| 		user->SendUpdateItemList(1, 1, avartar_inven_slot);
 | ||
| 		// »Ø°ü¸ø¿Í»§¶Ë
 | ||
| 		InterfacePacketBuf *packet_guard = (InterfacePacketBuf *)PacketGuard::NewPacketGuard();
 | ||
| 
 | ||
| 		packet_guard->put_header(1, 204);
 | ||
| 		packet_guard->put_int(1);
 | ||
| 		packet_guard->finalize(1);
 | ||
| 		user->Send((PacketGuard *)packet_guard);
 | ||
| 		PacketGuard::DelPacketGuard((PacketGuard *)packet_guard);
 | ||
| 		SendNoti(user, "ÒÑÍê³É»ÕÕÂÏâǶ");
 | ||
| 		return PAK_OK;
 | ||
| 	}
 | ||
| 	return PAK_IGNORE;
 | ||
| }
 | ||
| 
 | ||
| ENUM_PACK_RET_TYPE CDispatch::MoveMap_dispatch_sig(void *a1, CUser *user, PacketBuf *pBuf)
 | ||
| {
 | ||
| 	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);
 | ||
| 
 | ||
| 		// ÅжÏÒì³£´ÎÊýÊÇ·ñ´óÓÚµÈÓÚ3
 | ||
| 		if (data.abnormal_data_count >= 3)
 | ||
| 		{
 | ||
| 			return PAK_ERROR;
 | ||
| 		}
 | ||
| 	}
 | ||
| 	return PAK_OK;
 | ||
| }
 | ||
| 
 | ||
| ENUM_PACK_RET_TYPE CDispatch::Inter_LoadEtc_dispatch_sig(void *a1, CUser *user, char *a3)
 | ||
| {
 | ||
| 	user->getCurCharacNo();
 | ||
| 	user->getCurCharacName();
 | ||
| 
 | ||
| 	user_map.Push(user, {});
 | ||
| 	return PAK_OK;
 | ||
| }
 | ||
| 
 | ||
| ENUM_PACK_RET_TYPE CDispatch::DisPatcher_ReturnToSelectCharacter_dispatch_sig(void *a1, CUser *user, char *a3)
 | ||
| {
 | ||
| 
 | ||
| 	user_map.Erase(user);
 | ||
| 	return PAK_OK;
 | ||
| }
 | ||
| 
 | ||
| ENUM_PACK_RET_TYPE CDispatch::ProcessIPG_ResultOutput(CUser *user, int Goods_No, int item_id, int Cera_Type, InterfacePacketBuf *pbuf)
 | ||
| {
 | ||
| 
 | ||
| 	if (Cera_Type == 0) // 0Êǵãȯ 1ÊÇ´ú±Ò
 | ||
| 	{
 | ||
| 		CeraShopBonusCodeType cera_shop_bonus_code_;
 | ||
| 		if (CGameDataManager::Get()->is_cera_shop_bonus_code(Goods_No, &cera_shop_bonus_code_))
 | ||
| 		{
 | ||
| 			CeraShopBonusItemType BonusItem;
 | ||
| 			int cur_purchase_count = cera_shop_bonus_code_.code_count;
 | ||
| 			if (cur_purchase_count > 0)
 | ||
| 			{
 | ||
| 				if (!CGameDataManager::Get()->get_cera_shop_bonus_item_map()->Find(cur_purchase_count, &BonusItem))
 | ||
| 				{
 | ||
| 					goto IPG_END;
 | ||
| 				}
 | ||
| 			}
 | ||
| 			else
 | ||
| 			{
 | ||
| 				if (!CGameDataManager::Get()->get_rand_cera_shop_bonus_item(&BonusItem))
 | ||
| 				{
 | ||
| 					goto IPG_END;
 | ||
| 				}
 | ||
| 			}
 | ||
| 
 | ||
| 			if (user->getCurCharacR())
 | ||
| 			{
 | ||
| 				if (BonusItem.item_num == 0)
 | ||
| 				{
 | ||
| 					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)
 | ||
| 					{
 | ||
| 						// if (item->is_stackable()
 | ||
| 						//	&& ((*(int(**)(CItem*))(*(_DWORD*)item + 12))(item) == 16		// GetItemType
 | ||
| 						//		|| (*(int(**)(CItem*))(*(_DWORD*)item + 12))(item) == 34))	// GetItemType
 | ||
| 						{
 | ||
| 							int inserted = -1;
 | ||
| 							Inven_Item v60 = {};
 | ||
| 							*(_DWORD *)((char *)&v60 + 2) = BonusItem.item_id;
 | ||
| 							*(_DWORD *)((char *)&v60 + 7) = BonusItem.item_num;
 | ||
| 
 | ||
| 							(*(void (**)(CItem *, Inven_Item *))(*(_DWORD *)item + 8))(item, &v60);
 | ||
| 
 | ||
| 							auto CurCharacInvenW = user->getCurCharacInvenW();
 | ||
| 
 | ||
| 							inserted = CurCharacInvenW->insertItemIntoInventory(v60, 15, 1, 0);
 | ||
| 							if (inserted == -1)
 | ||
| 							{
 | ||
| 								auto CurCharacNo = user->getCurCharacNo();
 | ||
| 
 | ||
| 								((WongWork::CMailBoxHelper *)(user))->ReqDBSendNewMailCashShop(&v60, 0, CurCharacNo, 1, 0, 0);
 | ||
| 							}
 | ||
| 							else
 | ||
| 							{
 | ||
| 								user->SendUpdateItemList(1, 0, inserted);
 | ||
| 							}
 | ||
| 						}
 | ||
| 					}
 | ||
| 				}
 | ||
| 			}
 | ||
| 
 | ||
| 			pbuf->put_int(BonusItem.item_id);
 | ||
| 			pbuf->put_int(BonusItem.item_num);
 | ||
| 
 | ||
| 			std::vector<unsigned char> code;
 | ||
| 			for (int i = 0; i < 0x30; i++)
 | ||
| 			{
 | ||
| 				code.push_back(0x90);
 | ||
| 			}
 | ||
| 			// 0817964F	0817967F
 | ||
| 			CMem::WriteBytes((void *)0x0817964F, code.data(), code.size());
 | ||
| 			return PAK_OK;
 | ||
| 		}
 | ||
| 	}
 | ||
| IPG_END:
 | ||
| 	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());
 | ||
| 	return PAK_OK;
 | ||
| }
 | ||
| 
 | ||
| ENUM_PACK_RET_TYPE CDispatch::Init_done(int argc, const char **argv)
 | ||
| {
 | ||
| 
 | ||
| 	return PAK_OK;
 | ||
| }
 | ||
| 
 | ||
| ENUM_PACK_RET_TYPE CDispatch::importCashShopItemList(const std::string *str)
 | ||
| {
 | ||
| 	/**
 | ||
| 
 | ||
| 		[cash_shop_bonus_code]
 | ||
| 			3
 | ||
| 			10000	10053	0	0 Ëæ»ú»ñȡһ¸ö·¢ËÍ
 | ||
| 			10054	10110	1	1 ·¢µÚÒ»¸ö
 | ||
| 			100178	100180	3	3 ·¢µÚÈý¸ö
 | ||
| 
 | ||
| 		[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)
 | ||
| 			{
 | ||
| 				CGameDataManager::Get()->get_cera_shop_bonus_item_map_rand()->Push(index_, {item_id, item_num, true});
 | ||
| 			}
 | ||
| 			CGameDataManager::Get()->add_cera_shop_bonus_item(index_, item_id, item_num, is_random);
 | ||
| 		}
 | ||
| 	}
 | ||
| 	return PAK_OK;
 | ||
| }
 | ||
| 
 | ||
| void CDispatch::SendMsg(CUser *user, int pack_id, int status, const std::string &str)
 | ||
| {
 | ||
| 	char out_str[0xff] = {};
 | ||
| 	memset(out_str, 0, sizeof(out_str));
 | ||
| 	DNFFLib::ConvertGBKtoUTF8((char *)str.c_str(), out_str);
 | ||
| 	InterfacePacketBuf *packet_guard = (InterfacePacketBuf *)PacketGuard::NewPacketGuard();
 | ||
| 	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));
 | ||
| 	user->Send((PacketGuard *)packet_guard);
 | ||
| 	PacketGuard::DelPacketGuard((PacketGuard *)packet_guard);
 | ||
| }
 | ||
| 
 | ||
| void CDispatch::SendNoti(CUser *user, const std::string &str, NOTI_PACKETMESSAGE_TYPE type)
 | ||
| {
 | ||
| 	char out_str[0xff] = {};
 | ||
| 	memset(out_str, 0, sizeof(out_str));
 | ||
| 	DNFFLib::ConvertGBKtoUTF8((char *)str.c_str(), out_str);
 | ||
| 	user->SendNotiPacketMessage(out_str, type);
 | ||
| }
 |