Refactored inventory to "ReferencedItemPackage" as this is a more general approach closer to what the FFXIV client uses. Added itempackage code to the LinkedItemList packets (also renamed from EquipmentList). Cleaned up trade code.

This commit is contained in:
Filip Maj 2019-06-02 16:57:46 -04:00
parent 37cca32de8
commit 42ee97d467
16 changed files with 646 additions and 591 deletions

View file

@ -1,29 +0,0 @@
using System;
using System.IO;
using FFXIVClassic.Common;
namespace FFXIVClassic_Map_Server.packets.send.actor.inventory
{
class EquipmentListX01Packet
{
public const ushort OPCODE = 0x014D;
public const uint PACKET_SIZE = 0x28;
public static SubPacket BuildPacket(uint playerActorID, ushort equipSlot, uint itemSlot)
{
byte[] data = new byte[PACKET_SIZE - 0x20];
using (MemoryStream mem = new MemoryStream(data))
{
using (BinaryWriter binWriter = new BinaryWriter(mem))
{
binWriter.Write((UInt16)equipSlot);
binWriter.Write((UInt32)itemSlot);
}
}
return new SubPacket(OPCODE, playerActorID, data);
}
}
}

View file

@ -0,0 +1,46 @@
using System;
using System.IO;
using FFXIVClassic.Common;
namespace FFXIVClassic_Map_Server.packets.send.actor.inventory
{
class LinkedItemListX01Packet
{
public const ushort OPCODE = 0x014D;
public const uint PACKET_SIZE = 0x28;
public static SubPacket BuildPacket(uint playerActorID, ushort position, uint linkedItem)
{
byte[] data = new byte[PACKET_SIZE - 0x20];
using (MemoryStream mem = new MemoryStream(data))
{
using (BinaryWriter binWriter = new BinaryWriter(mem))
{
binWriter.Write((UInt16)position);
binWriter.Write((UInt32)linkedItem);
}
}
return new SubPacket(OPCODE, playerActorID, data);
}
public static SubPacket BuildPacket(uint playerActorID, ushort position, ushort itemSlot, ushort itemPackageCode)
{
byte[] data = new byte[PACKET_SIZE - 0x20];
using (MemoryStream mem = new MemoryStream(data))
{
using (BinaryWriter binWriter = new BinaryWriter(mem))
{
binWriter.Write((UInt16)position);
binWriter.Write((UInt16)itemSlot);
binWriter.Write((UInt16)itemPackageCode);
}
}
return new SubPacket(OPCODE, playerActorID, data);
}
}
}

View file

@ -7,12 +7,12 @@ using FFXIVClassic.Common;
namespace FFXIVClassic_Map_Server.packets.send.actor.inventory
{
class EquipmentListX08Packet
class LinkedItemListX08Packet
{
public const ushort OPCODE = 0x14E;
public const uint PACKET_SIZE = 0x58;
public static SubPacket BuildPacket(uint playerActorId, InventoryItem[] equipment, List<ushort> slotsToUpdate, ref int listOffset)
public static SubPacket BuildPacket(uint playerActorId, uint[] linkedItemList, List<ushort> slotsToUpdate, ref int listOffset)
{
byte[] data = new byte[PACKET_SIZE - 0x20];
@ -28,8 +28,8 @@ namespace FFXIVClassic_Map_Server.packets.send.actor.inventory
for (int i = 0; i < max; i++)
{
binWriter.Write((UInt16)slotsToUpdate[i]);
binWriter.Write((UInt32)equipment[slotsToUpdate[i]].slot);
binWriter.Write((UInt16)slotsToUpdate[i]); //LinkedItemPackageSlot
binWriter.Write((UInt32)linkedItemList[slotsToUpdate[i]]); //ItemPackage Slot + ItemPackage Code
listOffset++;
}

View file

@ -7,12 +7,12 @@ using FFXIVClassic.Common;
namespace FFXIVClassic_Map_Server.packets.send.actor.inventory
{
class EquipmentListX16Packet
class LinkedItemListX16Packet
{
public const ushort OPCODE = 0x14F;
public const uint PACKET_SIZE = 0x80;
public static SubPacket BuildPacket(uint playerActorId, InventoryItem[] equipment, List<ushort> slotsToUpdate, ref int listOffset)
public static SubPacket BuildPacket(uint playerActorId, uint[] linkedItemList, List<ushort> slotsToUpdate, ref int listOffset)
{
byte[] data = new byte[PACKET_SIZE - 0x20];
@ -28,8 +28,8 @@ namespace FFXIVClassic_Map_Server.packets.send.actor.inventory
for (int i = 0; i < max; i++)
{
binWriter.Write((UInt16)slotsToUpdate[i]);
binWriter.Write((UInt32)equipment[slotsToUpdate[i]].slot);
binWriter.Write((UInt16)slotsToUpdate[i]); //LinkedItemPackageSlot
binWriter.Write((UInt32)linkedItemList[slotsToUpdate[i]]); //ItemPackage Slot + ItemPackage Code
listOffset++;
}

View file

@ -7,12 +7,12 @@ using FFXIVClassic.Common;
namespace FFXIVClassic_Map_Server.packets.send.actor.inventory
{
class EquipmentListX32Packet
class LinkedItemListX32Packet
{
public const ushort OPCODE = 0x150;
public const uint PACKET_SIZE = 0xE0;
public static SubPacket BuildPacket(uint playerActorId, InventoryItem[] equipment, List<ushort> slotsToUpdate, ref int listOffset)
public static SubPacket BuildPacket(uint playerActorId, uint[] linkedItemList, List<ushort> slotsToUpdate, ref int listOffset)
{
byte[] data = new byte[PACKET_SIZE - 0x20];
@ -28,8 +28,8 @@ namespace FFXIVClassic_Map_Server.packets.send.actor.inventory
for (int i = 0; i < max; i++)
{
binWriter.Write((UInt16)slotsToUpdate[i]);
binWriter.Write((UInt32)equipment[slotsToUpdate[i]].slot);
binWriter.Write((UInt16)slotsToUpdate[i]); //LinkedItemPackageSlot
binWriter.Write((UInt32)linkedItemList[slotsToUpdate[i]]); //ItemPackage Slot + ItemPackage Code
listOffset++;
}

View file

@ -7,12 +7,12 @@ using FFXIVClassic.Common;
namespace FFXIVClassic_Map_Server.packets.send.actor.inventory
{
class EquipmentListX64Packet
class LinkedItemListX64Packet
{
public const ushort OPCODE = 0x151;
public const uint PACKET_SIZE = 0x194;
public static SubPacket BuildPacket(uint playerActorId, InventoryItem[] equipment, List<ushort> slotsToUpdate, ref int listOffset)
public static SubPacket BuildPacket(uint playerActorId, uint[] linkedItemList, List<ushort> slotsToUpdate, ref int listOffset)
{
byte[] data = new byte[PACKET_SIZE - 0x20];
@ -28,8 +28,8 @@ namespace FFXIVClassic_Map_Server.packets.send.actor.inventory
for (int i = 0; i < max; i++)
{
binWriter.Write((UInt16)slotsToUpdate[i]);
binWriter.Write((UInt32)equipment[slotsToUpdate[i]].slot);
binWriter.Write((UInt16)slotsToUpdate[i]); //LinkedItemPackageSlot
binWriter.Write((UInt32)linkedItemList[slotsToUpdate[i]]); //ItemPackage Slot + ItemPackage Code
listOffset++;
}