mirror of
https://bitbucket.org/Ioncannon/project-meteor-server.git
synced 2025-04-21 20:27:47 +00:00
Added 0x6c to the actorIdChanger. Mount appearance is now broadcast to show Goobbue. Equipment packets implemented as well as Equipment object.
This commit is contained in:
parent
a47d5f96a5
commit
b7fd3e442c
9 changed files with 194 additions and 290 deletions
|
@ -65,6 +65,7 @@
|
||||||
<Compile Include="actors\area\Zone.cs" />
|
<Compile Include="actors\area\Zone.cs" />
|
||||||
<Compile Include="actors\chara\npc\NpcWork.cs" />
|
<Compile Include="actors\chara\npc\NpcWork.cs" />
|
||||||
<Compile Include="actors\chara\AetheryteWork.cs" />
|
<Compile Include="actors\chara\AetheryteWork.cs" />
|
||||||
|
<Compile Include="actors\chara\player\Equipment.cs" />
|
||||||
<Compile Include="actors\chara\player\Inventory.cs" />
|
<Compile Include="actors\chara\player\Inventory.cs" />
|
||||||
<Compile Include="actors\chara\Work.cs" />
|
<Compile Include="actors\chara\Work.cs" />
|
||||||
<Compile Include="actors\debug\Debug.cs" />
|
<Compile Include="actors\debug\Debug.cs" />
|
||||||
|
|
113
FFXIVClassic Map Server/actors/chara/player/Equipment.cs
Normal file
113
FFXIVClassic Map Server/actors/chara/player/Equipment.cs
Normal file
|
@ -0,0 +1,113 @@
|
||||||
|
using FFXIVClassic_Map_Server.Actors;
|
||||||
|
using FFXIVClassic_Map_Server.dataobjects;
|
||||||
|
using FFXIVClassic_Map_Server.packets.send.Actor.inventory;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FFXIVClassic_Map_Server.actors.chara.player
|
||||||
|
{
|
||||||
|
class Equipment
|
||||||
|
{
|
||||||
|
public const int SLOT_MAINHAND = 0x00;
|
||||||
|
public const int SLOT_OFFHAND = 0x01;
|
||||||
|
public const int SLOT_THROWINGWEAPON = 0x04;
|
||||||
|
public const int SLOT_PACK = 0x05;
|
||||||
|
public const int SLOT_POUCH = 0x06;
|
||||||
|
public const int SLOT_HEAD = 0x08;
|
||||||
|
public const int SLOT_UNDERSHIRT = 0x09;
|
||||||
|
public const int SLOT_BODY = 0x0A;
|
||||||
|
public const int SLOT_UNDERGARMENT = 0x0B;
|
||||||
|
public const int SLOT_LEGS = 0x0C;
|
||||||
|
public const int SLOT_HANDS = 0x0D;
|
||||||
|
public const int SLOT_BOOTS = 0x0E;
|
||||||
|
public const int SLOT_WAIST = 0x0F;
|
||||||
|
public const int SLOT_NECK = 0x10;
|
||||||
|
public const int SLOT_EARS = 0x11;
|
||||||
|
public const int SLOT_WRISTS = 0x13;
|
||||||
|
public const int SLOT_RIGHTFINGER = 0x15;
|
||||||
|
public const int SLOT_LEFTFINGER = 0x16;
|
||||||
|
|
||||||
|
private Player owner;
|
||||||
|
private ushort inventoryCapacity;
|
||||||
|
private ushort inventoryCode;
|
||||||
|
private Item[] list;
|
||||||
|
|
||||||
|
public Equipment(Player ownerPlayer, ushort capacity, ushort code)
|
||||||
|
{
|
||||||
|
owner = ownerPlayer;
|
||||||
|
inventoryCapacity = capacity;
|
||||||
|
inventoryCode = code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Item GetItemAtSlot(ushort slot)
|
||||||
|
{
|
||||||
|
if (slot < list.Length)
|
||||||
|
return list[slot];
|
||||||
|
else
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetEquipment(List<Tuple<ushort, Item>> toEquip)
|
||||||
|
{
|
||||||
|
List<ushort> slotsToUpdate = new List<ushort>();
|
||||||
|
for (int i = 0; i < toEquip.Count; i++)
|
||||||
|
{
|
||||||
|
slotsToUpdate.Add(toEquip[i].Item1);
|
||||||
|
list[toEquip[i].Item1] = toEquip[i].Item2;
|
||||||
|
}
|
||||||
|
|
||||||
|
SendEquipmentPackets(slotsToUpdate);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Equip(ushort slot, Item item)
|
||||||
|
{
|
||||||
|
if (slot < list.Length)
|
||||||
|
list[slot] = item;
|
||||||
|
SendEquipmentPackets(slot, item);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Unequip(ushort slot)
|
||||||
|
{
|
||||||
|
if (slot < list.Length)
|
||||||
|
list[slot] = null;
|
||||||
|
SendEquipmentPackets(slot, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SendEquipmentPackets(ushort equipSlot, Item item)
|
||||||
|
{
|
||||||
|
if (item == null)
|
||||||
|
owner.queuePacket(EquipmentListX01Packet.buildPacket(owner.actorId, equipSlot, 0));
|
||||||
|
else
|
||||||
|
owner.queuePacket(EquipmentListX01Packet.buildPacket(owner.actorId, equipSlot, item.slot));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SendEquipmentPackets(List<ushort> slotsToUpdate)
|
||||||
|
{
|
||||||
|
int currentIndex = 0;
|
||||||
|
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
if (list.Length - currentIndex >= 64)
|
||||||
|
owner.queuePacket(EquipmentListX64Packet.buildPacket(owner.actorId, list, slotsToUpdate, ref currentIndex));
|
||||||
|
else if (list.Length - currentIndex >= 32)
|
||||||
|
owner.queuePacket(EquipmentListX32Packet.buildPacket(owner.actorId, list, slotsToUpdate, ref currentIndex));
|
||||||
|
else if (list.Length - currentIndex >= 16)
|
||||||
|
owner.queuePacket(EquipmentListX16Packet.buildPacket(owner.actorId, list, slotsToUpdate, ref currentIndex));
|
||||||
|
else if (list.Length - currentIndex > 1)
|
||||||
|
owner.queuePacket(EquipmentListX08Packet.buildPacket(owner.actorId, list, slotsToUpdate, ref currentIndex));
|
||||||
|
else if (list.Length - currentIndex == 1)
|
||||||
|
{
|
||||||
|
owner.queuePacket(EquipmentListX01Packet.buildPacket(owner.actorId, slotsToUpdate[currentIndex], list[currentIndex].slot));
|
||||||
|
currentIndex++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -581,12 +581,12 @@ namespace FFXIVClassic_Map_Server.Actors
|
||||||
|
|
||||||
public void sendChocoboAppearance()
|
public void sendChocoboAppearance()
|
||||||
{
|
{
|
||||||
queuePacket(SetCurrentMountChocoboPacket.buildPacket(actorId, chocoboAppearance));
|
broadcastPacket(SetCurrentMountChocoboPacket.buildPacket(actorId, chocoboAppearance), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendGoobbueAppearance()
|
public void sendGoobbueAppearance()
|
||||||
{
|
{
|
||||||
queuePacket(SetCurrentMountGoobbuePacket.buildPacket(actorId, 1));
|
broadcastPacket(SetCurrentMountGoobbuePacket.buildPacket(actorId, 1), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMountState(byte mountState)
|
public void setMountState(byte mountState)
|
||||||
|
|
|
@ -163,7 +163,7 @@ namespace FFXIVClassic_Lobby_Server.packets
|
||||||
while (binreader.BaseStream.Position + 4 < data.Length)
|
while (binreader.BaseStream.Position + 4 < data.Length)
|
||||||
{
|
{
|
||||||
uint read = binreader.ReadUInt32();
|
uint read = binreader.ReadUInt32();
|
||||||
if (read == 0x029B2941 || read == 0x02977DC7 || read == 0x0297D2C8 || read == 0x0230d573 || read == 0x23317df || read == 0x23344a3 || read == 0x1730bdb) //Original ID
|
if (read == 0x029B2941 || read == 0x02977DC7 || read == 0x0297D2C8 || read == 0x0230d573 || read == 0x23317df || read == 0x23344a3 || read == 0x1730bdb || read == 0x6c) //Original ID
|
||||||
{
|
{
|
||||||
binWriter.BaseStream.Seek(binreader.BaseStream.Position - 0x4, SeekOrigin.Begin);
|
binWriter.BaseStream.Seek(binreader.BaseStream.Position - 0x4, SeekOrigin.Begin);
|
||||||
binWriter.Write(actorID);
|
binWriter.Write(actorID);
|
||||||
|
|
|
@ -13,7 +13,7 @@ namespace FFXIVClassic_Map_Server.packets.send.Actor.inventory
|
||||||
public const ushort OPCODE = 0x014D;
|
public const ushort OPCODE = 0x014D;
|
||||||
public const uint PACKET_SIZE = 0x28;
|
public const uint PACKET_SIZE = 0x28;
|
||||||
|
|
||||||
public static SubPacket buildPacket(uint playerActorID, ushort slot, uint itemSlot)
|
public static SubPacket buildPacket(uint playerActorID, ushort equipSlot, uint itemSlot)
|
||||||
{
|
{
|
||||||
byte[] data = new byte[PACKET_SIZE - 0x20];
|
byte[] data = new byte[PACKET_SIZE - 0x20];
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ namespace FFXIVClassic_Map_Server.packets.send.Actor.inventory
|
||||||
{
|
{
|
||||||
using (BinaryWriter binWriter = new BinaryWriter(mem))
|
using (BinaryWriter binWriter = new BinaryWriter(mem))
|
||||||
{
|
{
|
||||||
binWriter.Write((UInt16)slot);
|
binWriter.Write((UInt16)equipSlot);
|
||||||
binWriter.Write((UInt32)itemSlot);
|
binWriter.Write((UInt32)itemSlot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using FFXIVClassic_Lobby_Server.packets;
|
using FFXIVClassic_Lobby_Server.packets;
|
||||||
|
using FFXIVClassic_Map_Server.dataobjects;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
@ -13,85 +14,33 @@ namespace FFXIVClassic_Map_Server.packets.send.Actor.inventory
|
||||||
public const ushort OPCODE = 0x14E;
|
public const ushort OPCODE = 0x14E;
|
||||||
public const uint PACKET_SIZE = 0x58;
|
public const uint PACKET_SIZE = 0x58;
|
||||||
|
|
||||||
public const uint UNEQUIPPED = 0xFFFFFFFF;
|
public static SubPacket buildPacket(uint playerActorId, Item[] equipment, List<ushort> slotsToUpdate, ref int listOffset)
|
||||||
|
|
||||||
public const int SLOT_MAINHAND = 0x00;
|
|
||||||
public const int SLOT_OFFHAND = 0x01;
|
|
||||||
public const int SLOT_THROWINGWEAPON = 0x04;
|
|
||||||
public const int SLOT_PACK = 0x05;
|
|
||||||
public const int SLOT_POUCH = 0x06;
|
|
||||||
public const int SLOT_HEAD = 0x08;
|
|
||||||
public const int SLOT_UNDERSHIRT = 0x09;
|
|
||||||
public const int SLOT_BODY = 0x0A;
|
|
||||||
public const int SLOT_UNDERGARMENT = 0x0B;
|
|
||||||
public const int SLOT_LEGS = 0x0C;
|
|
||||||
public const int SLOT_HANDS = 0x0D;
|
|
||||||
public const int SLOT_BOOTS = 0x0E;
|
|
||||||
public const int SLOT_WAIST = 0x0F;
|
|
||||||
public const int SLOT_NECK = 0x10;
|
|
||||||
public const int SLOT_EARS = 0x11;
|
|
||||||
public const int SLOT_WRISTS = 0x13;
|
|
||||||
public const int SLOT_RIGHTFINGER = 0x15;
|
|
||||||
public const int SLOT_LEFTFINGER = 0x16;
|
|
||||||
|
|
||||||
private uint[] equipment = new uint[0x17];
|
|
||||||
|
|
||||||
public EquipmentListX08Packet()
|
|
||||||
{
|
{
|
||||||
for (int i = 0; i < equipment.Length; i++)
|
|
||||||
equipment[i] = UNEQUIPPED; //We will use this as "Unequipped"
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setItem(int slot, uint itemSlot)
|
|
||||||
{
|
|
||||||
if (slot >= equipment.Length)
|
|
||||||
return;
|
|
||||||
|
|
||||||
equipment[slot] = itemSlot;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<SubPacket> buildPackets(uint playerActorID)
|
|
||||||
{
|
|
||||||
List<SubPacket> packets = new List<SubPacket>();
|
|
||||||
int packetCount = 0;
|
|
||||||
int runningCount = 0;
|
|
||||||
byte[] data = new byte[PACKET_SIZE - 0x20];
|
byte[] data = new byte[PACKET_SIZE - 0x20];
|
||||||
MemoryStream mem = new MemoryStream(data);
|
|
||||||
BinaryWriter binWriter = new BinaryWriter(mem);
|
|
||||||
|
|
||||||
for (int i = 0; i < equipment.Length; i++)
|
using (MemoryStream mem = new MemoryStream(data))
|
||||||
{
|
{
|
||||||
if (equipment[i] == UNEQUIPPED)
|
using (BinaryWriter binWriter = new BinaryWriter(mem))
|
||||||
continue;
|
|
||||||
|
|
||||||
binWriter.Write((UInt16)i);
|
|
||||||
binWriter.Write((UInt32)equipment[i]);
|
|
||||||
|
|
||||||
packetCount++;
|
|
||||||
runningCount++;
|
|
||||||
|
|
||||||
//Create another packet
|
|
||||||
if (runningCount >= 8)
|
|
||||||
{
|
{
|
||||||
packetCount = 0;
|
int max;
|
||||||
binWriter.Write((UInt32)8);
|
if (slotsToUpdate.Count - listOffset <= 8)
|
||||||
binWriter.Dispose();
|
max = slotsToUpdate.Count - listOffset;
|
||||||
mem.Dispose();
|
else
|
||||||
packets.Add(new SubPacket(OPCODE, playerActorID, playerActorID, data));
|
max = 8;
|
||||||
data = new byte[PACKET_SIZE - 0x20];
|
|
||||||
mem = new MemoryStream(data);
|
for (int i = 0; i < max; i++)
|
||||||
binWriter = new BinaryWriter(mem);
|
{
|
||||||
|
binWriter.Write((UInt16)slotsToUpdate[i]);
|
||||||
|
binWriter.Write((UInt32)equipment[slotsToUpdate[i]].slot);
|
||||||
|
listOffset++;
|
||||||
|
}
|
||||||
|
|
||||||
|
binWriter.Seek(0x30, SeekOrigin.Begin);
|
||||||
|
binWriter.Write((UInt32)max);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Create any leftover subpacket
|
return new SubPacket(OPCODE, playerActorId, playerActorId, data);
|
||||||
binWriter.BaseStream.Seek(0x30, SeekOrigin.Begin);
|
|
||||||
binWriter.Write((UInt32)packetCount);
|
|
||||||
binWriter.Dispose();
|
|
||||||
mem.Dispose();
|
|
||||||
packets.Add(new SubPacket(OPCODE, playerActorID, playerActorID, data));
|
|
||||||
|
|
||||||
return packets;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using FFXIVClassic_Lobby_Server.packets;
|
using FFXIVClassic_Lobby_Server.packets;
|
||||||
|
using FFXIVClassic_Map_Server.dataobjects;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
@ -13,85 +14,31 @@ namespace FFXIVClassic_Map_Server.packets.send.Actor.inventory
|
||||||
public const ushort OPCODE = 0x14F;
|
public const ushort OPCODE = 0x14F;
|
||||||
public const uint PACKET_SIZE = 0x80;
|
public const uint PACKET_SIZE = 0x80;
|
||||||
|
|
||||||
public const uint UNEQUIPPED = 0xFFFFFFFF;
|
public static SubPacket buildPacket(uint playerActorId, Item[] equipment, List<ushort> slotsToUpdate, ref int listOffset)
|
||||||
|
|
||||||
public const int SLOT_MAINHAND = 0x00;
|
|
||||||
public const int SLOT_OFFHAND = 0x01;
|
|
||||||
public const int SLOT_THROWINGWEAPON = 0x04;
|
|
||||||
public const int SLOT_PACK = 0x05;
|
|
||||||
public const int SLOT_POUCH = 0x06;
|
|
||||||
public const int SLOT_HEAD = 0x08;
|
|
||||||
public const int SLOT_UNDERSHIRT = 0x09;
|
|
||||||
public const int SLOT_BODY = 0x0A;
|
|
||||||
public const int SLOT_UNDERGARMENT = 0x0B;
|
|
||||||
public const int SLOT_LEGS = 0x0C;
|
|
||||||
public const int SLOT_HANDS = 0x0D;
|
|
||||||
public const int SLOT_BOOTS = 0x0E;
|
|
||||||
public const int SLOT_WAIST = 0x0F;
|
|
||||||
public const int SLOT_NECK = 0x10;
|
|
||||||
public const int SLOT_EARS = 0x11;
|
|
||||||
public const int SLOT_WRISTS = 0x13;
|
|
||||||
public const int SLOT_RIGHTFINGER = 0x15;
|
|
||||||
public const int SLOT_LEFTFINGER = 0x16;
|
|
||||||
|
|
||||||
private uint[] equipment = new uint[0x17];
|
|
||||||
|
|
||||||
public EquipmentListX16Packet()
|
|
||||||
{
|
{
|
||||||
for (int i = 0; i < equipment.Length; i++)
|
|
||||||
equipment[i] = UNEQUIPPED; //We will use this as "Unequipped"
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setItem(int slot, uint itemSlot)
|
|
||||||
{
|
|
||||||
if (slot >= equipment.Length)
|
|
||||||
return;
|
|
||||||
|
|
||||||
equipment[slot] = itemSlot;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<SubPacket> buildPackets(uint playerActorID)
|
|
||||||
{
|
|
||||||
List<SubPacket> packets = new List<SubPacket>();
|
|
||||||
int packetCount = 0;
|
|
||||||
int runningCount = 0;
|
|
||||||
byte[] data = new byte[PACKET_SIZE - 0x20];
|
byte[] data = new byte[PACKET_SIZE - 0x20];
|
||||||
MemoryStream mem = new MemoryStream(data);
|
|
||||||
BinaryWriter binWriter = new BinaryWriter(mem);
|
|
||||||
|
|
||||||
for (int i = 0; i < equipment.Length; i++)
|
using (MemoryStream mem = new MemoryStream(data))
|
||||||
{
|
{
|
||||||
if (equipment[i] == UNEQUIPPED)
|
using (BinaryWriter binWriter = new BinaryWriter(mem))
|
||||||
continue;
|
|
||||||
|
|
||||||
binWriter.Write((UInt16)i);
|
|
||||||
binWriter.Write((UInt32)equipment[i]);
|
|
||||||
|
|
||||||
packetCount++;
|
|
||||||
runningCount++;
|
|
||||||
|
|
||||||
//Create another packet
|
|
||||||
if (runningCount >= 16)
|
|
||||||
{
|
{
|
||||||
packetCount = 0;
|
int max;
|
||||||
binWriter.Write((UInt32)8);
|
if (slotsToUpdate.Count - listOffset <= 16)
|
||||||
binWriter.Dispose();
|
max = slotsToUpdate.Count - listOffset;
|
||||||
mem.Dispose();
|
else
|
||||||
packets.Add(new SubPacket(OPCODE, playerActorID, playerActorID, data));
|
max = 16;
|
||||||
data = new byte[PACKET_SIZE - 0x20];
|
|
||||||
mem = new MemoryStream(data);
|
for (int i = 0; i < max; i++)
|
||||||
binWriter = new BinaryWriter(mem);
|
{
|
||||||
|
binWriter.Write((UInt16)slotsToUpdate[i]);
|
||||||
|
binWriter.Write((UInt32)equipment[slotsToUpdate[i]].slot);
|
||||||
|
listOffset++;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Create any leftover subpacket
|
return new SubPacket(OPCODE, playerActorId, playerActorId, data);
|
||||||
binWriter.BaseStream.Seek(0x30, SeekOrigin.Begin);
|
|
||||||
binWriter.Write((UInt32)packetCount);
|
|
||||||
binWriter.Dispose();
|
|
||||||
mem.Dispose();
|
|
||||||
packets.Add(new SubPacket(OPCODE, playerActorID, playerActorID, data));
|
|
||||||
|
|
||||||
return packets;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using FFXIVClassic_Lobby_Server.packets;
|
using FFXIVClassic_Lobby_Server.packets;
|
||||||
|
using FFXIVClassic_Map_Server.dataobjects;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
@ -13,86 +14,32 @@ namespace FFXIVClassic_Map_Server.packets.send.Actor.inventory
|
||||||
public const ushort OPCODE = 0x150;
|
public const ushort OPCODE = 0x150;
|
||||||
public const uint PACKET_SIZE = 0xE0;
|
public const uint PACKET_SIZE = 0xE0;
|
||||||
|
|
||||||
public const uint UNEQUIPPED = 0xFFFFFFFF;
|
public static SubPacket buildPacket(uint playerActorId, Item[] equipment, List<ushort> slotsToUpdate, ref int listOffset)
|
||||||
|
|
||||||
public const int SLOT_MAINHAND = 0x00;
|
|
||||||
public const int SLOT_OFFHAND = 0x01;
|
|
||||||
public const int SLOT_THROWINGWEAPON = 0x04;
|
|
||||||
public const int SLOT_PACK = 0x05;
|
|
||||||
public const int SLOT_POUCH = 0x06;
|
|
||||||
public const int SLOT_HEAD = 0x08;
|
|
||||||
public const int SLOT_UNDERSHIRT = 0x09;
|
|
||||||
public const int SLOT_BODY = 0x0A;
|
|
||||||
public const int SLOT_UNDERGARMENT = 0x0B;
|
|
||||||
public const int SLOT_LEGS = 0x0C;
|
|
||||||
public const int SLOT_HANDS = 0x0D;
|
|
||||||
public const int SLOT_BOOTS = 0x0E;
|
|
||||||
public const int SLOT_WAIST = 0x0F;
|
|
||||||
public const int SLOT_NECK = 0x10;
|
|
||||||
public const int SLOT_EARS = 0x11;
|
|
||||||
public const int SLOT_WRISTS = 0x13;
|
|
||||||
public const int SLOT_RIGHTFINGER = 0x15;
|
|
||||||
public const int SLOT_LEFTFINGER = 0x16;
|
|
||||||
|
|
||||||
private uint[] equipment = new uint[0x17];
|
|
||||||
|
|
||||||
public EquipmentListX32Packet()
|
|
||||||
{
|
{
|
||||||
for (int i = 0; i < equipment.Length; i++)
|
|
||||||
equipment[i] = UNEQUIPPED; //We will use this as "Unequipped"
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setItem(int slot, uint itemSlot)
|
|
||||||
{
|
|
||||||
if (slot >= equipment.Length)
|
|
||||||
return;
|
|
||||||
|
|
||||||
equipment[slot] = itemSlot;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<SubPacket> buildPackets(uint playerActorID)
|
|
||||||
{
|
|
||||||
List<SubPacket> packets = new List<SubPacket>();
|
|
||||||
int packetCount = 0;
|
|
||||||
int runningCount = 0;
|
|
||||||
byte[] data = new byte[PACKET_SIZE - 0x20];
|
byte[] data = new byte[PACKET_SIZE - 0x20];
|
||||||
MemoryStream mem = new MemoryStream(data);
|
|
||||||
BinaryWriter binWriter = new BinaryWriter(mem);
|
|
||||||
|
|
||||||
for (int i = 0; i < equipment.Length; i++)
|
using (MemoryStream mem = new MemoryStream(data))
|
||||||
{
|
{
|
||||||
if (equipment[i] == UNEQUIPPED)
|
using (BinaryWriter binWriter = new BinaryWriter(mem))
|
||||||
continue;
|
|
||||||
|
|
||||||
binWriter.Write((UInt16)i);
|
|
||||||
binWriter.Write((UInt32)equipment[i]);
|
|
||||||
|
|
||||||
packetCount++;
|
|
||||||
runningCount++;
|
|
||||||
|
|
||||||
//Create another packet
|
|
||||||
if (runningCount >= 32)
|
|
||||||
{
|
{
|
||||||
packetCount = 0;
|
int max;
|
||||||
binWriter.Write((UInt32)8);
|
if (slotsToUpdate.Count - listOffset <= 32)
|
||||||
binWriter.Dispose();
|
max = slotsToUpdate.Count - listOffset;
|
||||||
mem.Dispose();
|
else
|
||||||
packets.Add(new SubPacket(OPCODE, playerActorID, playerActorID, data));
|
max = 32;
|
||||||
data = new byte[PACKET_SIZE - 0x20];
|
|
||||||
mem = new MemoryStream(data);
|
for (int i = 0; i < max; i++)
|
||||||
binWriter = new BinaryWriter(mem);
|
{
|
||||||
|
binWriter.Write((UInt16)slotsToUpdate[i]);
|
||||||
|
binWriter.Write((UInt32)equipment[slotsToUpdate[i]].slot);
|
||||||
|
listOffset++;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Create any leftover subpacket
|
return new SubPacket(OPCODE, playerActorId, playerActorId, data);
|
||||||
binWriter.BaseStream.Seek(0x30, SeekOrigin.Begin);
|
}
|
||||||
binWriter.Write((UInt32)packetCount);
|
|
||||||
binWriter.Dispose();
|
|
||||||
mem.Dispose();
|
|
||||||
packets.Add(new SubPacket(OPCODE, playerActorID, playerActorID, data));
|
|
||||||
|
|
||||||
return packets;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using FFXIVClassic_Lobby_Server.packets;
|
using FFXIVClassic_Lobby_Server.packets;
|
||||||
|
using FFXIVClassic_Map_Server.dataobjects;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
@ -13,85 +14,31 @@ namespace FFXIVClassic_Map_Server.packets.send.Actor.inventory
|
||||||
public const ushort OPCODE = 0x151;
|
public const ushort OPCODE = 0x151;
|
||||||
public const uint PACKET_SIZE = 0x194;
|
public const uint PACKET_SIZE = 0x194;
|
||||||
|
|
||||||
public const uint UNEQUIPPED = 0xFFFFFFFF;
|
public static SubPacket buildPacket(uint playerActorId, Item[] equipment, List<ushort> slotsToUpdate, ref int listOffset)
|
||||||
|
|
||||||
public const int SLOT_MAINHAND = 0x00;
|
|
||||||
public const int SLOT_OFFHAND = 0x01;
|
|
||||||
public const int SLOT_THROWINGWEAPON = 0x04;
|
|
||||||
public const int SLOT_PACK = 0x05;
|
|
||||||
public const int SLOT_POUCH = 0x06;
|
|
||||||
public const int SLOT_HEAD = 0x08;
|
|
||||||
public const int SLOT_UNDERSHIRT = 0x09;
|
|
||||||
public const int SLOT_BODY = 0x0A;
|
|
||||||
public const int SLOT_UNDERGARMENT = 0x0B;
|
|
||||||
public const int SLOT_LEGS = 0x0C;
|
|
||||||
public const int SLOT_HANDS = 0x0D;
|
|
||||||
public const int SLOT_BOOTS = 0x0E;
|
|
||||||
public const int SLOT_WAIST = 0x0F;
|
|
||||||
public const int SLOT_NECK = 0x10;
|
|
||||||
public const int SLOT_EARS = 0x11;
|
|
||||||
public const int SLOT_WRISTS = 0x13;
|
|
||||||
public const int SLOT_RIGHTFINGER = 0x15;
|
|
||||||
public const int SLOT_LEFTFINGER = 0x16;
|
|
||||||
|
|
||||||
private uint[] equipment = new uint[0x17];
|
|
||||||
|
|
||||||
public EquipmentListX64Packet()
|
|
||||||
{
|
{
|
||||||
for (int i = 0; i < equipment.Length; i++)
|
|
||||||
equipment[i] = UNEQUIPPED; //We will use this as "Unequipped"
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setItem(int slot, uint itemSlot)
|
|
||||||
{
|
|
||||||
if (slot >= equipment.Length)
|
|
||||||
return;
|
|
||||||
|
|
||||||
equipment[slot] = itemSlot;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<SubPacket> buildPackets(uint playerActorID)
|
|
||||||
{
|
|
||||||
List<SubPacket> packets = new List<SubPacket>();
|
|
||||||
int packetCount = 0;
|
|
||||||
int runningCount = 0;
|
|
||||||
byte[] data = new byte[PACKET_SIZE - 0x20];
|
byte[] data = new byte[PACKET_SIZE - 0x20];
|
||||||
MemoryStream mem = new MemoryStream(data);
|
|
||||||
BinaryWriter binWriter = new BinaryWriter(mem);
|
|
||||||
|
|
||||||
for (int i = 0; i < equipment.Length; i++)
|
using (MemoryStream mem = new MemoryStream(data))
|
||||||
{
|
{
|
||||||
if (equipment[i] == UNEQUIPPED)
|
using (BinaryWriter binWriter = new BinaryWriter(mem))
|
||||||
continue;
|
|
||||||
|
|
||||||
binWriter.Write((UInt16)i);
|
|
||||||
binWriter.Write((UInt32)equipment[i]);
|
|
||||||
|
|
||||||
packetCount++;
|
|
||||||
runningCount++;
|
|
||||||
|
|
||||||
//Create another packet
|
|
||||||
if (runningCount >= 64)
|
|
||||||
{
|
{
|
||||||
packetCount = 0;
|
int max;
|
||||||
binWriter.Write((UInt32)8);
|
if (slotsToUpdate.Count - listOffset <= 64)
|
||||||
binWriter.Dispose();
|
max = slotsToUpdate.Count - listOffset;
|
||||||
mem.Dispose();
|
else
|
||||||
packets.Add(new SubPacket(OPCODE, playerActorID, playerActorID, data));
|
max = 64;
|
||||||
data = new byte[PACKET_SIZE - 0x20];
|
|
||||||
mem = new MemoryStream(data);
|
for (int i = 0; i < max; i++)
|
||||||
binWriter = new BinaryWriter(mem);
|
{
|
||||||
|
binWriter.Write((UInt16)slotsToUpdate[i]);
|
||||||
|
binWriter.Write((UInt32)equipment[slotsToUpdate[i]].slot);
|
||||||
|
listOffset++;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Create any leftover subpacket
|
return new SubPacket(OPCODE, playerActorId, playerActorId, data);
|
||||||
binWriter.BaseStream.Seek(0x30, SeekOrigin.Begin);
|
|
||||||
binWriter.Write((UInt32)packetCount);
|
|
||||||
binWriter.Dispose();
|
|
||||||
mem.Dispose();
|
|
||||||
packets.Add(new SubPacket(OPCODE, playerActorID, playerActorID, data));
|
|
||||||
|
|
||||||
return packets;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue