Loading...   

  • Created By Uleat On: 08:02 PM September 12, 2014
  • Link

 common/patches/rof.cpp | 59 ++++++++++++++++++++++++++++++++++----------------
 1 file changed, 40 insertions(+), 19 deletions(-)

diff --git a/common/patches/rof.cpp b/common/patches/rof.cpp
index d5303cc..d9cccac 100644
--- a/common/patches/rof.cpp
+++ b/common/patches/rof.cpp
@@ -2244,8 +2244,10 @@ ENCODE(OP_ItemPacket) {
 	ItemPacket_Struct *old_item_pkt=(ItemPacket_Struct *)__emu_buffer;
 	InternalSerializedItem_Struct *int_struct=(InternalSerializedItem_Struct *)(old_item_pkt->SerializedItem);
 
+	bool is_limbo_item = (old_item_pkt->PacketType == ItemPacketSummonItem);
+
 	uint32 length;
-	char *serialized=SerializeItem((ItemInst *)int_struct->inst,int_struct->slot_id,&length,0);
+	char *serialized = SerializeItem((ItemInst *)int_struct->inst, (is_limbo_item) ? 10000 : int_struct->slot_id, &length, 0);
 
 	if (!serialized) {
 		_log(NET__STRUCTS, "Serialization failed on item slot %d.",int_struct->slot_id);
@@ -4307,8 +4309,17 @@ DECODE(OP_MoveItem)
 
 	//_log(NET__ERROR, "Moved item from %u to %u", eq->from_slot.MainSlot, eq->to_slot.MainSlot);
 	_log(NET__ERROR, "MoveItem SlotType from %i to %i, MainSlot from %i to %i, SubSlot from %i to %i, AugSlot from %i to %i, Unknown01 from %i to %i, Number %u", eq->from_slot.SlotType, eq->to_slot.SlotType, eq->from_slot.MainSlot, eq->to_slot.MainSlot, eq->from_slot.SubSlot, eq->to_slot.SubSlot, eq->from_slot.AugSlot, eq->to_slot.AugSlot, eq->from_slot.Unknown01, eq->to_slot.Unknown01, eq->number_in_stack);
-	emu->from_slot = RoFToServerSlot(eq->from_slot);
-	emu->to_slot = RoFToServerSlot(eq->to_slot);
+	
+	if (eq->from_slot.SlotType == maps::MapLimbo) { // limbo.main to possessions.maincursor should be the only incoming from->limbo packet
+		// current server code for this event requires that 'from' and 'to' slots be equal or an errant action occurs
+		emu->to_slot = RoFToServerSlot(eq->to_slot);	// this should translate to MainCursor
+		emu->from_slot = emu->to_slot;					// this should also be MainCursor
+	}
+	else {
+		emu->from_slot = RoFToServerSlot(eq->from_slot);
+		emu->to_slot = RoFToServerSlot(eq->to_slot);
+	}
+
 	IN(number_in_stack);
 
 	_hex(NET__ERROR, eq, sizeof(structs::MoveItem_Struct));
@@ -4895,12 +4906,28 @@ char* SerializeItem(const ItemInst *inst, int16 slot_id_in, uint32 *length, uint
 	hdr.stacksize = stackable ? charges : 1;
 	hdr.unknown004 = 0;
 
-	structs::ItemSlotStruct slot_id = ServerToRoFSlot(slot_id_in);
+	// limbo slots are currently not a part of the normal slot conversion due to their not existing in the server code
+	if (slot_id_in == 10000) { // limbo main slot (external call)
+		hdr.slot_type = maps::MapLimbo;
+		hdr.main_slot = inst->GetCurrentSlot();
+		hdr.sub_slot = ~0;
+		hdr.unknown013 = ~0;
+	}
+	else if ((slot_id_in >= 10101) && (slot_id_in <= 13610)) { // limbo sub slot (recursive call)
+		hdr.slot_type = maps::MapLimbo;
+		hdr.main_slot = ((slot_id_in - 10000) / 100) - 1;
+		hdr.sub_slot = (slot_id_in - 1) % 10;
+		hdr.unknown013 = ~0;
+	}
+	else {
+		structs::ItemSlotStruct slot_id = ServerToRoFSlot(slot_id_in);
+
+		hdr.slot_type = (merchant_slot == 0) ? slot_id.SlotType : 9; // 9 is merchant 20 is reclaim items?
+		hdr.main_slot = (merchant_slot == 0) ? slot_id.MainSlot : merchant_slot;
+		hdr.sub_slot = (merchant_slot == 0) ? slot_id.SubSlot : 0xffff;
+		hdr.unknown013 = (merchant_slot == 0) ? slot_id.AugSlot : 0xffff;
+	}
 
-	hdr.slot_type = (merchant_slot == 0) ? slot_id.SlotType : 9; // 9 is merchant 20 is reclaim items?
-	hdr.main_slot = (merchant_slot == 0) ? slot_id.MainSlot : merchant_slot;
-	hdr.sub_slot = (merchant_slot == 0) ? slot_id.SubSlot : 0xffff;
-	hdr.unknown013 = (merchant_slot == 0) ? slot_id.AugSlot : 0xffff;
 	//hdr.unknown013 = 0xffff;
 	hdr.price = inst->GetPrice();
 	hdr.merchant_slot = (merchant_slot == 0) ? 1 : inst->GetMerchantCount();
@@ -5366,21 +5393,15 @@ char* SerializeItem(const ItemInst *inst, int16 slot_id_in, uint32 *length, uint
 			iqbs.subitem_count++;
 
 			if(slot_id_in >= EmuConstants::GENERAL_BEGIN && slot_id_in <= EmuConstants::GENERAL_END) // (< 30) - no cursor?
-				//SubSlotNumber = (((slot_id_in + 3) * 10) + x + 1);
-				SubSlotNumber = (((slot_id_in + 3) * EmuConstants::ITEM_CONTAINER_SIZE) + x + 1);
+				SubSlotNumber = (((slot_id_in + 3) * EmuConstants::ITEM_CONTAINER_SIZE) + (x + 1));
 			else if(slot_id_in >= EmuConstants::BANK_BEGIN && slot_id_in <= EmuConstants::BANK_END)
-				//SubSlotNumber = (((slot_id_in - 2000) * 10) + 2030 + x + 1);
 				SubSlotNumber = (((slot_id_in - EmuConstants::BANK_BEGIN) * EmuConstants::ITEM_CONTAINER_SIZE) + EmuConstants::BANK_BAGS_BEGIN + x);
-			else if(slot_id_in >= EmuConstants::SHARED_BANK_BEGIN && slot_id_in <= EmuConstants::SHARED_BANK_END)
-				//SubSlotNumber = (((slot_id_in - 2500) * 10) + 2530 + x + 1);
+			else if (slot_id_in >= EmuConstants::SHARED_BANK_BEGIN && slot_id_in <= EmuConstants::SHARED_BANK_END)
 				SubSlotNumber = (((slot_id_in - EmuConstants::SHARED_BANK_BEGIN) * EmuConstants::ITEM_CONTAINER_SIZE) + EmuConstants::SHARED_BANK_BAGS_BEGIN + x);
+			else if (slot_id_in == 10000)
+				SubSlotNumber = 10000 + ((inst->GetCurrentSlot() + 1) * 100) + (x + 1);
 			else
-				SubSlotNumber = slot_id_in; // ???????
-
-			/*
-			// TEST CODE: <watch>
-			SubSlotNumber = Inventory::CalcSlotID(slot_id_in, x);
-			*/
+				SubSlotNumber = slot_id_in;
 
 			SubSerializations[x] = SerializeItem(subitem, SubSlotNumber, &SubLengths[x], depth + 1);
 		}

Raw Paste Data