UpdateStoragePacket

This commit is contained in:
Longfeng Qin 2024-12-11 04:26:15 +08:00
parent 27d77e46e1
commit 63d5ef6693
5 changed files with 101 additions and 4 deletions

View File

@ -80,7 +80,7 @@ namespace PSO2SERVER.Protocol.Handlers
srcObj = null;
}
//Logger.WriteInternal("[OBJ] {0} (ID {1}) <{2}> --> Ent {3} (ID {4})", srcObj.name, srcObj.Header.ID, command, (ObjectType)dstObject.ObjectType, dstObject.ID);
//Logger.WriteInternal("[OBJ] {0} (ID {1}) <{2}> --> Ent {3} (ID {4})", srcObj.name, srcObj.player.ID, command, (ObjectType)dstObject.ObjectType, dstObject.ID);
// TODO: Delete this code and do this COMPLETELY correctly!!!
if (pkt.Action == "Transfer" && context.CurrentMap.Name == "lobby")

View File

@ -94,7 +94,7 @@ namespace PSO2SERVER.Protocol.Packets
// 队伍结构数据
for (int i = 0; i < players.Length; i++)
{
entries[i].id = new ObjectHeader((uint)players[i].Account.AccountId, ObjectType.Player); // Header of player
entries[i].id = new ObjectHeader((uint)players[i].Account.AccountId, ObjectType.Player); // player of player
entries[i].nickname = players[i].Account.Nickname;
entries[i].char_name = players[i].Name;
entries[i].level = (byte)players[i].Jobs.entries.hunter.level;
@ -150,7 +150,7 @@ namespace PSO2SERVER.Protocol.Packets
//for(int i = 0; i < players.Length; i++)
//{
// PartyEntry pe = new PartyEntry();
// pkt.WriteStruct(new ObjectHeader((uint)players[i].Accounts.AccountId, ObjectType.Player)); // Header of player
// pkt.WriteStruct(new ObjectHeader((uint)players[i].Accounts.AccountId, ObjectType.Player)); // player of player
// pkt.WriteUtf16(players[i].name, 0xD863, 0xA9);
// pkt.WriteUtf16(players[i].Accounts.Nickname, 0xD863, 0xA9);
// pkt.Write((byte)players[i].Jobs.entries.hunter.level); // Active class level
@ -175,7 +175,7 @@ namespace PSO2SERVER.Protocol.Packets
//for(int i = 0; i < 4 - players.Length; i++) // Empty entries
//{
// pkt.WriteStruct(new ObjectHeader(0, 0)); // Header of player
// pkt.WriteStruct(new ObjectHeader(0, 0)); // player of player
// pkt.WriteMagic(0, 0xD863, 0xA9);
// pkt.WriteMagic(0, 0xD863, 0xA9);
// pkt.Write((byte)0); // Active class level

View File

@ -0,0 +1,39 @@
using PSO2SERVER.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace PSO2SERVER.Protocol.Packets
{
public class EquipedWeaponPacket : Packet
{
/// Player changing the weapon.
public ObjectHeader player { get; set; } = new ObjectHeader();
/// New weapon.
public PSO2Items Item { get; set; } = new PSO2Items();
public EquipedWeaponPacket(uint player_id, PSO2Items item)
{
player = new ObjectHeader(player_id, ObjectType.Player);
Item = item;
}
#region implemented abstract members of Packet
public override byte[] Build()
{
var pkt = new PacketWriter();
pkt.WriteObjectHeader(player);
pkt.WriteStruct(Item);
return pkt.ToArray();
}
public override PacketHeader GetHeader()
{
return new PacketHeader(0x0F, 0x21, PacketFlags.None);
}
#endregion
}
}

View File

@ -0,0 +1,56 @@
using PSO2SERVER.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace PSO2SERVER.Protocol.Packets
{
public class UpdateStoragePacket : Packet
{
// Unk field (can be a list of UpdatedStorageItem)
public List<UpdatedStorageItem> Unk { get; set; }
// Already existing items being updated
public List<UpdatedStorageItem> Updated { get; set; }
// New items added
public List<NewStorageItem> NewItems { get; set; }
// Additional unknown fields (uint and ulong)
public uint Unk2 { get; set; }
public ulong Unk3 { get; set; }
public UpdateStoragePacket(List<UpdatedStorageItem> unk, List<UpdatedStorageItem> updated, List<NewStorageItem> newItems, uint unk2, ulong unk3)
{
Unk = unk;
Updated = updated;
NewItems = newItems;
Unk2 = unk2;
Unk3 = unk3;
}
#region implemented abstract members of Packet
public override byte[] Build()
{
var pkt = new PacketWriter();
pkt.WriteMagic(Unk.Count, 0x4DC2, 0x2A);
foreach(var u in Unk) { pkt.WriteStruct(u); }
pkt.WriteMagic(Updated.Count, 0x4DC2, 0x2A);
foreach (var u in Updated) { pkt.WriteStruct(u); }
pkt.WriteMagic(NewItems.Count, 0x4DC2, 0x2A);
foreach (var u in NewItems) { pkt.WriteStruct(u); }
pkt.Write(Unk2);
pkt.Write(Unk3);
return pkt.ToArray();
}
public override PacketHeader GetHeader()
{
return new PacketHeader(0x0F, 0x22, PacketFlags.PACKED);
}
#endregion
}
}

View File

@ -422,6 +422,8 @@
<Compile Include="Protocol\PacketError.cs" />
<Compile Include="Protocol\Packets\04-ObjectRelatedPacket\04-75-ActionEndPacket.cs" />
<Compile Include="Protocol\Packets\0B-QuestPacket\0B-1B-QuestCategoryStopperPacket.cs" />
<Compile Include="Protocol\Packets\0F-ItemPacket\0F-22-UpdateStoragePacket.cs" />
<Compile Include="Protocol\Packets\0F-ItemPacket\0F-21-EquipedWeaponPacket.cs" />
<Compile Include="Protocol\Packets\0F-ItemPacket\00 - 复制.cs" />
<Compile Include="Protocol\Packets\0F-ItemPacket\0F-00-ItemAttributesPacket.cs" />
<Compile Include="Protocol\Packets\0F-ItemPacket\0F-02-ItemPickupResponsePacket.cs" />