修正部分数据包处理 快捷栏生成处理
角色生成函数还需要继续修正
This commit is contained in:
parent
3f3b4b146a
commit
391dd3d1b6
@ -69,6 +69,8 @@ namespace PSO2SERVER
|
||||
public uint MovementTimestamp { get; internal set; }
|
||||
public Party.Party currentParty;
|
||||
|
||||
public PSOPalette Palette { get; set; } = new PSOPalette();
|
||||
|
||||
public PSOLocation CurrentLocation;
|
||||
public PSOLocation LastLocation;
|
||||
|
||||
|
@ -19,10 +19,7 @@ namespace PSO2SERVER.Json
|
||||
var fixedList = new FixedList<T>(list.Count);
|
||||
|
||||
// 将 list 中的元素添加到 FixedList 中
|
||||
foreach (var item in list)
|
||||
{
|
||||
fixedList.Add(item);
|
||||
}
|
||||
fixedList.SetListItem(list);
|
||||
|
||||
return fixedList;
|
||||
}
|
||||
|
@ -7,6 +7,8 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Collections;
|
||||
using System.Xml.Linq;
|
||||
using System.IO;
|
||||
using PSO2SERVER.Protocol;
|
||||
|
||||
namespace PSO2SERVER.Models
|
||||
{
|
||||
@ -47,6 +49,7 @@ namespace PSO2SERVER.Models
|
||||
|
||||
_data.Add(item);
|
||||
}
|
||||
|
||||
public void Insert(int index, T item)
|
||||
{
|
||||
if (index < 0 || index > _data.Count)
|
||||
@ -57,6 +60,7 @@ namespace PSO2SERVER.Models
|
||||
|
||||
_data.Insert(index, item);
|
||||
}
|
||||
|
||||
public void RemoveAt(int index)
|
||||
{
|
||||
if (index < 0 || index >= _data.Count)
|
||||
@ -72,6 +76,73 @@ namespace PSO2SERVER.Models
|
||||
|
||||
_data.RemoveAt(_data.Count - 1);
|
||||
}
|
||||
|
||||
public void SetItem(int index, T value)
|
||||
{
|
||||
// 如果 index 超出当前长度,但没有超出最大容量,进行扩展
|
||||
if (index >= _data.Count)
|
||||
{
|
||||
// 如果 index 没有超过最大容量
|
||||
if (index < _capacity)
|
||||
{
|
||||
// 扩展 _data 列表,填充默认值
|
||||
while (_data.Count <= index && _data.Count < _capacity)
|
||||
{
|
||||
_data.Add(default(T));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(index), "索引超出最大容量.");
|
||||
}
|
||||
}
|
||||
|
||||
// 赋值
|
||||
_data[index] = value;
|
||||
}
|
||||
|
||||
public void SetListItem(List<T> value)
|
||||
{
|
||||
// 截取最大容量的值,如果传入的值超过了 _capacity
|
||||
if (value.Count > _capacity)
|
||||
{
|
||||
value = value.Take(_capacity).ToList();
|
||||
}
|
||||
|
||||
// 更新已有的元素
|
||||
for (var i = 0; i < _data.Count && i < value.Count; i++)
|
||||
{
|
||||
_data[i] = value[i];
|
||||
}
|
||||
|
||||
// 如果 value 的长度超过当前 _data 长度并且未超过最大容量,则扩展 _data 长度
|
||||
if (value.Count > _data.Count)
|
||||
{
|
||||
// 计算要增加的元素数量
|
||||
int elementsToAdd = value.Count - _data.Count;
|
||||
|
||||
// 添加元素,确保不超过最大容量
|
||||
for (var i = 0; i < elementsToAdd && _data.Count < _capacity; i++)
|
||||
{
|
||||
_data.Add(default(T)); // 填充默认值
|
||||
}
|
||||
|
||||
// 将传入的 value 中剩余的元素(超出 _data 长度部分)复制到 _data
|
||||
for (var i = _data.Count; i < value.Count; i++)
|
||||
{
|
||||
_data[i] = value[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void SetAll(T newValue)
|
||||
{
|
||||
for (int i = 0; i < _data.Count; i++)
|
||||
{
|
||||
_data[i] = newValue;
|
||||
}
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
_data.Clear();
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Security.AccessControl;
|
||||
using PSO2SERVER.Protocol.Packets;
|
||||
|
||||
|
||||
@ -57,20 +58,18 @@ namespace PSO2SERVER.Models
|
||||
|
||||
public AccountFlagsPacket ToAccountFlags()
|
||||
{
|
||||
return new AccountFlagsPacket
|
||||
{
|
||||
Flags = new List<byte>(flags),
|
||||
Params = new List<uint>(paramsList)
|
||||
};
|
||||
var aflags = new AccountFlagsPacket();
|
||||
aflags.Flags.SetListItem(flags);
|
||||
aflags.Params.SetListItem(paramsList);
|
||||
return aflags;
|
||||
}
|
||||
|
||||
public CharacterFlagsPacket ToCharFlags()
|
||||
{
|
||||
return new CharacterFlagsPacket
|
||||
{
|
||||
Flags = new List<byte>(flags),
|
||||
Params = new List<uint>(paramsList)
|
||||
};
|
||||
var cflags = new CharacterFlagsPacket();
|
||||
cflags.Flags.SetListItem(flags);
|
||||
cflags.Params.SetListItem(paramsList);
|
||||
return cflags;
|
||||
}
|
||||
|
||||
private static byte SetBit(byte byteValue, byte index, byte val)
|
||||
|
@ -258,7 +258,7 @@ namespace PSO2SERVER.Models
|
||||
|
||||
[JsonProperty("unk8")]
|
||||
[JsonConverter(typeof(FixedListConverter<byte>))]
|
||||
public FixedList<byte> Unk8 { get; set; } = new FixedList<byte>(0x04);
|
||||
public FixedList<byte> Unk8 { get; set; } = new FixedList<byte>(0x04, 0);
|
||||
|
||||
// Equipable races
|
||||
[JsonProperty("race")]
|
||||
@ -584,62 +584,62 @@ namespace PSO2SERVER.Models
|
||||
public class Data7
|
||||
{
|
||||
[JsonConverter(typeof(FixedListConverter<byte>))]
|
||||
public FixedList<byte> unk { get; set; } = new FixedList<byte>(0x38);
|
||||
public FixedList<byte> unk { get; set; } = new FixedList<byte>(0x38, 0);
|
||||
}
|
||||
public class Data8
|
||||
{
|
||||
[JsonConverter(typeof(FixedListConverter<byte>))]
|
||||
public FixedList<byte> unk { get; set; } = new FixedList<byte>(0x10);
|
||||
public FixedList<byte> unk { get; set; } = new FixedList<byte>(0x10, 0);
|
||||
}
|
||||
public class Data9
|
||||
{
|
||||
[JsonConverter(typeof(FixedListConverter<byte>))]
|
||||
public FixedList<byte> unk { get; set; } = new FixedList<byte>(0x3C);
|
||||
public FixedList<byte> unk { get; set; } = new FixedList<byte>(0x3C, 0);
|
||||
}
|
||||
public class Data10
|
||||
{
|
||||
[JsonConverter(typeof(FixedListConverter<byte>))]
|
||||
public FixedList<byte> unk { get; set; } = new FixedList<byte>(0x24);
|
||||
public FixedList<byte> unk { get; set; } = new FixedList<byte>(0x24, 0);
|
||||
}
|
||||
public class Data11
|
||||
{
|
||||
[JsonConverter(typeof(FixedListConverter<byte>))]
|
||||
public FixedList<byte> unk { get; set; } = new FixedList<byte>(0x10);
|
||||
public FixedList<byte> unk { get; set; } = new FixedList<byte>(0x10, 0);
|
||||
}
|
||||
public class Data12
|
||||
{
|
||||
[JsonConverter(typeof(FixedListConverter<byte>))]
|
||||
public FixedList<byte> unk { get; set; } = new FixedList<byte>(0x24);
|
||||
public FixedList<byte> unk { get; set; } = new FixedList<byte>(0x24, 0);
|
||||
}
|
||||
public class Data13
|
||||
{
|
||||
[JsonConverter(typeof(FixedListConverter<byte>))]
|
||||
public FixedList<byte> unk { get; set; } = new FixedList<byte>(0x50);
|
||||
public FixedList<byte> unk { get; set; } = new FixedList<byte>(0x50, 0);
|
||||
}
|
||||
public class Data14
|
||||
{
|
||||
[JsonConverter(typeof(FixedListConverter<byte>))]
|
||||
public FixedList<byte> unk { get; set; } = new FixedList<byte>(0x7C);
|
||||
public FixedList<byte> unk { get; set; } = new FixedList<byte>(0x7C, 0);
|
||||
}
|
||||
public class Data15
|
||||
{
|
||||
[JsonConverter(typeof(FixedListConverter<byte>))]
|
||||
public FixedList<byte> unk { get; set; } = new FixedList<byte>(0x10);
|
||||
public FixedList<byte> unk { get; set; } = new FixedList<byte>(0x10, 0);
|
||||
}
|
||||
public class Data16
|
||||
{
|
||||
[JsonConverter(typeof(FixedListConverter<byte>))]
|
||||
public FixedList<byte> unk { get; set; } = new FixedList<byte>(0x12);
|
||||
public FixedList<byte> unk { get; set; } = new FixedList<byte>(0x12, 0);
|
||||
}
|
||||
public class Data17
|
||||
{
|
||||
[JsonConverter(typeof(FixedListConverter<byte>))]
|
||||
public FixedList<byte> unk { get; set; } = new FixedList<byte>(0x5A);
|
||||
public FixedList<byte> unk { get; set; } = new FixedList<byte>(0x5A, 0);
|
||||
}
|
||||
public class Data18
|
||||
{
|
||||
[JsonConverter(typeof(FixedListConverter<byte>))]
|
||||
public FixedList<byte> unk { get; set; } = new FixedList<byte>(0x08);
|
||||
public FixedList<byte> unk { get; set; } = new FixedList<byte>(0x08, 0);
|
||||
}
|
||||
public class ShortData
|
||||
{
|
||||
@ -648,17 +648,17 @@ namespace PSO2SERVER.Models
|
||||
public class Data19
|
||||
{
|
||||
[JsonConverter(typeof(FixedListConverter<byte>))]
|
||||
public FixedList<byte> unk { get; set; } = new FixedList<byte>(0x54);
|
||||
public FixedList<byte> unk { get; set; } = new FixedList<byte>(0x54, 0);
|
||||
}
|
||||
public class Data19Vita
|
||||
{
|
||||
[JsonConverter(typeof(FixedListConverter<byte>))]
|
||||
public FixedList<byte> unk { get; set; } = new FixedList<byte>(0x2C);
|
||||
public FixedList<byte> unk { get; set; } = new FixedList<byte>(0x2C, 0);
|
||||
}
|
||||
public class Data20
|
||||
{
|
||||
[JsonConverter(typeof(FixedListConverter<byte>))]
|
||||
public FixedList<byte> unk { get; set; } = new FixedList<byte>(0x1C);
|
||||
public FixedList<byte> unk { get; set; } = new FixedList<byte>(0x1C, 0);
|
||||
}
|
||||
|
||||
public struct GenderDmg
|
||||
|
@ -16,7 +16,7 @@ namespace PSO2SERVER.Models
|
||||
[JsonProperty("items")]
|
||||
[JsonConverter(typeof(FixedListConverter<PalettePA>))]
|
||||
// Items in the subpalette.
|
||||
public FixedList<PalettePA> Items { get; set; } = new FixedList<PalettePA>(0x0C);
|
||||
public FixedList<PalettePA> Items { get; set; } = new FixedList<PalettePA>(0x0C, new PalettePA());
|
||||
|
||||
// 从字节流中读取数据
|
||||
public void ReadFromStream(PacketReader reader)
|
||||
@ -27,7 +27,7 @@ namespace PSO2SERVER.Models
|
||||
// 读取每个 PalettePA
|
||||
var palettePA = new PalettePA();
|
||||
palettePA.ReadFromStream(reader);
|
||||
Items.Add(palettePA); // 将读取的数据存储到 FixedList 中
|
||||
Items.SetItem(i, palettePA);
|
||||
}
|
||||
}
|
||||
|
||||
@ -58,7 +58,6 @@ namespace PSO2SERVER.Models
|
||||
|
||||
public PalettePA()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public PalettePA(byte id, byte category, byte unk, byte level)
|
||||
@ -88,14 +87,14 @@ namespace PSO2SERVER.Models
|
||||
|
||||
public class WeaponPalette
|
||||
{
|
||||
public ulong Uuid { get; set; }
|
||||
public uint Unk1 { get; set; }
|
||||
public PalettePA Unk2 { get; set; }
|
||||
public PalettePA Unk3 { get; set; }
|
||||
public PalettePA Unk4 { get; set; }
|
||||
public ulong Uuid { get; set; } = 0;
|
||||
public uint Unk1 { get; set; } = 0;
|
||||
public PalettePA Unk2 { get; set; } = new PalettePA();
|
||||
public PalettePA Unk3 { get; set; } = new PalettePA();
|
||||
public PalettePA Unk4 { get; set; } = new PalettePA();
|
||||
public uint[] Unk { get; set; } = new uint[3];
|
||||
public uint PetId { get; set; }
|
||||
public PalettePA[] Skills { get; set; } = new PalettePA[6];
|
||||
public uint PetId { get; set; } = 0;
|
||||
public List<PalettePA> Skills { get; set; } = new List<PalettePA>(6);
|
||||
|
||||
public WeaponPalette()
|
||||
{
|
||||
@ -116,9 +115,8 @@ namespace PSO2SERVER.Models
|
||||
Unk[i] = reader.ReadUInt32();
|
||||
}
|
||||
PetId = reader.ReadUInt32();
|
||||
for (int i = 0; i < Skills.Length; i++)
|
||||
for (int i = 0; i < Skills.Count; i++)
|
||||
{
|
||||
Skills[i] = new PalettePA();
|
||||
Skills[i].ReadFromStream(reader);
|
||||
}
|
||||
}
|
||||
@ -144,90 +142,59 @@ namespace PSO2SERVER.Models
|
||||
|
||||
public class PSOPalette
|
||||
{
|
||||
public struct Palette
|
||||
public uint CurPalette { get; set; } = 0;
|
||||
public uint CurSubpalette { get; set; } = 0;
|
||||
public uint CurBook { get; set; } = 0;
|
||||
public FixedList<WeaponPalette> Palettes { get; set; } = new FixedList<WeaponPalette>(6, new WeaponPalette());
|
||||
public FixedList<SubPalette> Subpalettes { get; set; } = new FixedList<SubPalette>(6, new SubPalette());
|
||||
public List<uint> DefaultPas { get; set; } = new List<uint>();
|
||||
|
||||
public PSOPalette() { }
|
||||
|
||||
public void ReadFromStream(PacketReader reader)
|
||||
{
|
||||
public uint CurPalette;
|
||||
public uint CurSubpalette;
|
||||
public uint CurBook;
|
||||
public WeaponPalette[] Palettes;
|
||||
public SubPalette[] Subpalettes;
|
||||
public List<uint> DefaultPas;
|
||||
CurPalette = reader.ReadUInt32();
|
||||
CurSubpalette = reader.ReadUInt32();
|
||||
CurBook = reader.ReadUInt32();
|
||||
|
||||
// 构造函数
|
||||
public static Palette Create()
|
||||
for (int i = 0; i < Palettes.Length; i++)
|
||||
{
|
||||
Palette palette = new Palette
|
||||
{
|
||||
CurPalette = 0,
|
||||
CurSubpalette = 0,
|
||||
CurBook = 0,
|
||||
Palettes = new WeaponPalette[6],
|
||||
Subpalettes = new SubPalette[6],
|
||||
DefaultPas = new List<uint>()
|
||||
};
|
||||
|
||||
// 初始化 Palettes
|
||||
for (int i = 0; i < palette.Palettes.Length; i++)
|
||||
{
|
||||
palette.Palettes[i] = new WeaponPalette();
|
||||
}
|
||||
|
||||
// 初始化 Subpalettes(根据需要可以进行自定义初始化)
|
||||
for (int i = 0; i < palette.Subpalettes.Length; i++)
|
||||
{
|
||||
palette.Subpalettes[i] = new SubPalette(); // 这里可以根据需要进行初始化
|
||||
}
|
||||
|
||||
return palette;
|
||||
Palettes[i].ReadFromStream(reader);
|
||||
}
|
||||
|
||||
public void ReadFromStream(PacketReader reader)
|
||||
for (int i = 0; i < Subpalettes.Length; i++)
|
||||
{
|
||||
CurPalette = reader.ReadUInt32();
|
||||
CurSubpalette = reader.ReadUInt32();
|
||||
CurBook = reader.ReadUInt32();
|
||||
|
||||
for (int i = 0; i < Palettes.Length; i++)
|
||||
{
|
||||
Palettes[i].ReadFromStream(reader);
|
||||
}
|
||||
|
||||
for (int i = 0; i < Subpalettes.Length; i++)
|
||||
{
|
||||
Subpalettes[i].ReadFromStream(reader);
|
||||
}
|
||||
|
||||
int defaultPasCount = reader.ReadInt32(); // 假设先读入数量
|
||||
DefaultPas.Clear();
|
||||
for (int i = 0; i < defaultPasCount; i++)
|
||||
{
|
||||
DefaultPas.Add(reader.ReadUInt32());
|
||||
}
|
||||
Subpalettes[i].ReadFromStream(reader);
|
||||
}
|
||||
|
||||
public void WriteToStream(PacketWriter writer)
|
||||
int defaultPasCount = reader.ReadInt32(); // 假设先读入数量
|
||||
DefaultPas.Clear();
|
||||
for (int i = 0; i < defaultPasCount; i++)
|
||||
{
|
||||
writer.Write(CurPalette);
|
||||
writer.Write(CurSubpalette);
|
||||
writer.Write(CurBook);
|
||||
|
||||
for (int i = 0; i < Palettes.Length; i++)
|
||||
{
|
||||
Palettes[i].WriteToStream(writer);
|
||||
}
|
||||
|
||||
for (int i = 0; i < Subpalettes.Length; i++)
|
||||
{
|
||||
Subpalettes[i].WriteToStream(writer);
|
||||
}
|
||||
|
||||
writer.Write(DefaultPas.Count);
|
||||
foreach (var value in DefaultPas)
|
||||
{
|
||||
writer.Write(value);
|
||||
}
|
||||
DefaultPas.Add(reader.ReadUInt32());
|
||||
}
|
||||
}
|
||||
|
||||
public void WriteToStream(PacketWriter writer)
|
||||
{
|
||||
writer.Write(CurPalette);
|
||||
writer.Write(CurSubpalette);
|
||||
writer.Write(CurBook);
|
||||
|
||||
for (int i = 0; i < Palettes.Length; i++)
|
||||
{
|
||||
Palettes[i].WriteToStream(writer);
|
||||
}
|
||||
|
||||
for (int i = 0; i < Subpalettes.Length; i++)
|
||||
{
|
||||
Subpalettes[i].WriteToStream(writer);
|
||||
}
|
||||
|
||||
foreach (var value in DefaultPas)
|
||||
{
|
||||
writer.Write(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
16
Server/Protocol/Handlers/0F-ItemHandler/0F-28-UNK.cs
Normal file
16
Server/Protocol/Handlers/0F-ItemHandler/0F-28-UNK.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using PSO2SERVER.Models;
|
||||
using PSO2SERVER.Protocol.Packets;
|
||||
|
||||
namespace PSO2SERVER.Protocol.Handlers
|
||||
{
|
||||
[PacketHandlerAttr(0x0F, 0x28)]
|
||||
public class _0F_28_UNK : PacketHandler
|
||||
{
|
||||
public override void HandlePacket(Client context, byte flags, byte[] data, uint position, uint size)
|
||||
{
|
||||
var info = string.Format("[<--] 接收到的数据 (hex): {0} 字节", data.Length);
|
||||
Logger.WriteHex(info, data);
|
||||
}
|
||||
}
|
||||
}
|
16
Server/Protocol/Handlers/0F-ItemHandler/0F-DA-UNK0FDA.cs
Normal file
16
Server/Protocol/Handlers/0F-ItemHandler/0F-DA-UNK0FDA.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using PSO2SERVER.Models;
|
||||
using PSO2SERVER.Protocol.Packets;
|
||||
|
||||
namespace PSO2SERVER.Protocol.Handlers
|
||||
{
|
||||
[PacketHandlerAttr(0x0F, 0xDA)]
|
||||
public class _0F_DA_UNK : PacketHandler
|
||||
{
|
||||
public override void HandlePacket(Client context, byte flags, byte[] data, uint position, uint size)
|
||||
{
|
||||
var info = string.Format("[<--] 接收到的数据 (hex): {0} 字节", data.Length);
|
||||
Logger.WriteHex(info, data);
|
||||
}
|
||||
}
|
||||
}
|
@ -47,7 +47,7 @@ namespace PSO2SERVER.Protocol.Handlers
|
||||
//context.SendPacket(File.ReadAllBytes("testbed/237.23-7.210.189.208.30.bin"));
|
||||
|
||||
// 先给一个空的 Palette
|
||||
context.SendPacket(new LoadPalettePacket());
|
||||
context.SendPacket(new LoadPalettePacket(context.Palette));
|
||||
|
||||
// memset packet - Enables menus TODO
|
||||
// Also holds event items and likely other stuff too
|
||||
|
@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using PSO2SERVER.Models;
|
||||
using PSO2SERVER.Protocol.Packets;
|
||||
|
||||
namespace PSO2SERVER.Protocol.Handlers
|
||||
{
|
||||
[PacketHandlerAttr(0x21, 0x00)]
|
||||
public class LoadPalettesRequest : PacketHandler
|
||||
{
|
||||
public override void HandlePacket(Client context, byte flags, byte[] data, uint position, uint size)
|
||||
{
|
||||
var info = string.Format("[<--] 接收到的数据 (hex): {0} 字节", data.Length);
|
||||
Logger.WriteHex(info, data);
|
||||
|
||||
//TODO
|
||||
context.SendPacket(new LoadPalettePacket(context.Palette));
|
||||
}
|
||||
}
|
||||
}
|
@ -12,7 +12,7 @@ namespace PSO2SERVER.Protocol.Handlers
|
||||
var info = string.Format("[<--] 接收到的数据 (hex): {0} 字节", data.Length);
|
||||
Logger.WriteHex(info, data);
|
||||
|
||||
var Palette = PSOPalette.Palette.Create();
|
||||
var Palette = new PSOPalette();
|
||||
|
||||
context.SendPacket(new FullPaletteInfoPacket(Palette));
|
||||
}
|
||||
|
@ -0,0 +1,52 @@
|
||||
using System;
|
||||
using PSO2SERVER.Models;
|
||||
using PSO2SERVER.Protocol.Packets;
|
||||
|
||||
namespace PSO2SERVER.Protocol.Handlers
|
||||
{
|
||||
[PacketHandlerAttr(0x21, 0x0A)]
|
||||
public class SetDefaultPAs : PacketHandler
|
||||
{
|
||||
public class SetDefaultPAsPacket
|
||||
{
|
||||
public FixedList<uint> Default { get; set; } = new FixedList<uint>(0x1A0, 0);
|
||||
|
||||
// 从数据流中读取数据并填充到 Default 列表
|
||||
public static SetDefaultPAsPacket ReadFromStream(PacketReader reader)
|
||||
{
|
||||
// 假设 Default 是该类的静态字段,因此直接访问
|
||||
SetDefaultPAsPacket packet = new SetDefaultPAsPacket();
|
||||
|
||||
// 从流中读取 uint 类型的数据并填充到 Default 列表
|
||||
for (var i = 0; i < (int)packet.Default.Capacity; i++)
|
||||
{
|
||||
packet.Default[i] = reader.ReadUInt32(); // 读取 uint 值并存入 Default 列表
|
||||
}
|
||||
|
||||
return packet;
|
||||
}
|
||||
|
||||
// 将 Default 列表的数据写入到数据流
|
||||
public void WriteToStream(PacketWriter writer)
|
||||
{
|
||||
// 将 Default 列表中的每个 uint 元素写入数据流
|
||||
for (var i = 0; i < (int)Default.Capacity; i++)
|
||||
{
|
||||
writer.Write(Default[i]); // 写入 uint 值
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void HandlePacket(Client context, byte flags, byte[] data, uint position, uint size)
|
||||
{
|
||||
var info = string.Format("[<--] 接收到的数据 (hex): {0} 字节", data.Length);
|
||||
Logger.WriteHex(info, data);
|
||||
|
||||
var reader = new PacketReader(data, position, size);
|
||||
var packet = SetDefaultPAsPacket.ReadFromStream(reader);
|
||||
|
||||
|
||||
context.SendPacket(new NewDefaultPAsPacket(packet.Default));
|
||||
}
|
||||
}
|
||||
}
|
16
Server/Protocol/Handlers/34-UNK/34-72-UNK.cs
Normal file
16
Server/Protocol/Handlers/34-UNK/34-72-UNK.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using PSO2SERVER.Models;
|
||||
using PSO2SERVER.Protocol.Packets;
|
||||
|
||||
namespace PSO2SERVER.Protocol.Handlers
|
||||
{
|
||||
[PacketHandlerAttr(0x34, 0x72)]
|
||||
public class _34_72_UNK : PacketHandler
|
||||
{
|
||||
public override void HandlePacket(Client context, byte flags, byte[] data, uint position, uint size)
|
||||
{
|
||||
var info = string.Format("[<--] 接收到的数据 (hex): {0} 字节", data.Length);
|
||||
Logger.WriteHex(info, data);
|
||||
}
|
||||
}
|
||||
}
|
16
Server/Protocol/Handlers/48-UNK/48-16-UNK4816.cs
Normal file
16
Server/Protocol/Handlers/48-UNK/48-16-UNK4816.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using PSO2SERVER.Models;
|
||||
using PSO2SERVER.Protocol.Packets;
|
||||
|
||||
namespace PSO2SERVER.Protocol.Handlers
|
||||
{
|
||||
[PacketHandlerAttr(0x48, 0x16)]
|
||||
public class _48_16_UNK : PacketHandler
|
||||
{
|
||||
public override void HandlePacket(Client context, byte flags, byte[] data, uint position, uint size)
|
||||
{
|
||||
var info = string.Format("[<--] 接收到的数据 (hex): {0} 字节", data.Length);
|
||||
Logger.WriteHex(info, data);
|
||||
}
|
||||
}
|
||||
}
|
16
Server/Protocol/Handlers/49-UNK/49-00-UNK4900.cs
Normal file
16
Server/Protocol/Handlers/49-UNK/49-00-UNK4900.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using PSO2SERVER.Models;
|
||||
using PSO2SERVER.Protocol.Packets;
|
||||
|
||||
namespace PSO2SERVER.Protocol.Handlers
|
||||
{
|
||||
[PacketHandlerAttr(0x49, 0x00)]
|
||||
public class _49_00_UNK : PacketHandler
|
||||
{
|
||||
public override void HandlePacket(Client context, byte flags, byte[] data, uint position, uint size)
|
||||
{
|
||||
var info = string.Format("[<--] 接收到的数据 (hex): {0} 字节", data.Length);
|
||||
Logger.WriteHex(info, data);
|
||||
}
|
||||
}
|
||||
}
|
@ -13,22 +13,22 @@ namespace PSO2SERVER.Protocol.Packets
|
||||
public WeaponPalette[] Palettes { get; set; } = new WeaponPalette[6];
|
||||
public SubPalette[] Subpalettes { get; set; } = new SubPalette[6];
|
||||
|
||||
public LoadPalettePacket()
|
||||
public LoadPalettePacket(PSOPalette palette)
|
||||
{
|
||||
CurPalette = 1;
|
||||
CurSubpalette = 0;
|
||||
CurBook = 0;
|
||||
CurPalette = palette.CurPalette;
|
||||
CurSubpalette = palette.CurSubpalette;
|
||||
CurBook = palette.CurBook;
|
||||
|
||||
// 初始化 Palettes
|
||||
for (int i = 0; i < Palettes.Length; i++)
|
||||
{
|
||||
Palettes[i] = new WeaponPalette();
|
||||
Palettes[i] = palette.Palettes[i];
|
||||
}
|
||||
|
||||
// 初始化 Subpalettes(根据需要可以进行自定义初始化)
|
||||
for (int i = 0; i < Subpalettes.Length; i++)
|
||||
{
|
||||
Subpalettes[i] = new SubPalette(); // 这里可以根据需要进行初始化
|
||||
Subpalettes[i] = palette.Subpalettes[i]; // 这里可以根据需要进行初始化
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10,9 +10,9 @@ namespace PSO2SERVER.Protocol.Packets
|
||||
{
|
||||
public class FullPaletteInfoPacket : Packet
|
||||
{
|
||||
private Palette Palette = Palette.Create();
|
||||
private PSOPalette Palette = new PSOPalette();
|
||||
|
||||
public FullPaletteInfoPacket(Palette palette)
|
||||
public FullPaletteInfoPacket(PSOPalette palette)
|
||||
{
|
||||
this.Palette = palette;
|
||||
}
|
||||
|
@ -11,14 +11,16 @@ namespace PSO2SERVER.Protocol.Packets
|
||||
{
|
||||
public const int SeekAfter = 0x240; // 576 bytes
|
||||
|
||||
public FixedList<uint> Default { get; set; } = new FixedList<uint>(0x1A0);
|
||||
public FixedList<uint> Default { get; set; } = new FixedList<uint>(0x1A0, 0);
|
||||
|
||||
public NewDefaultPAsPacket(List<uint> Default)
|
||||
{
|
||||
foreach (var item in Default)
|
||||
{
|
||||
this.Default.Add(item);
|
||||
}
|
||||
this.Default.SetListItem(Default);
|
||||
}
|
||||
|
||||
public NewDefaultPAsPacket(FixedList<uint> Default)
|
||||
{
|
||||
this.Default = Default;
|
||||
}
|
||||
|
||||
public void ReadFromStream(PacketReader reader)
|
||||
@ -28,7 +30,7 @@ namespace PSO2SERVER.Protocol.Packets
|
||||
// 读取 Default
|
||||
for (int i = 0; i < Default.Capacity; i++)
|
||||
{
|
||||
Default.Add(reader.ReadUInt32());
|
||||
Default.SetItem(i, reader.ReadUInt32());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,14 +9,18 @@ namespace PSO2SERVER.Protocol.Packets
|
||||
public class AccountFlagsPacket : Packet
|
||||
{
|
||||
// Accounts flags (0x400 bytes)
|
||||
public List<byte> Flags { get; set; }
|
||||
public FixedList<byte> Flags { get; set; } = new FixedList<byte>(0x400, 0);
|
||||
// Accounts parameters (0x100 bytes)
|
||||
public List<uint> Params { get; set; }
|
||||
public FixedList<uint> Params { get; set; } = new FixedList<uint>(0x100, 0);
|
||||
|
||||
public AccountFlagsPacket()
|
||||
{
|
||||
Flags = new List<byte>(new byte[0x400]);
|
||||
Params = new List<uint>(new uint[0x100]);
|
||||
}
|
||||
|
||||
public AccountFlagsPacket(FixedList<byte> Flags, FixedList<uint> Params)
|
||||
{
|
||||
this.Flags = Flags;
|
||||
this.Params = Params;
|
||||
}
|
||||
|
||||
#region implemented abstract members of Packet
|
||||
@ -24,8 +28,8 @@ namespace PSO2SERVER.Protocol.Packets
|
||||
public override byte[] Build()
|
||||
{
|
||||
var pkt = new PacketWriter();
|
||||
pkt.Write(new byte[0x400]);
|
||||
pkt.Write(new byte[0x400]);
|
||||
pkt.WriteList(Flags);
|
||||
pkt.WriteList(Params);
|
||||
return pkt.ToArray();
|
||||
}
|
||||
|
||||
|
@ -12,17 +12,21 @@ namespace PSO2SERVER.Protocol.Packets
|
||||
/// <summary>
|
||||
/// Character flags.
|
||||
/// </summary>
|
||||
public List<byte> Flags { get; set; }
|
||||
public FixedList<byte> Flags { get; set; } = new FixedList<byte>(0xC00, 0);
|
||||
|
||||
/// <summary>
|
||||
/// Character parameters.
|
||||
/// </summary>
|
||||
public List<uint> Params { get; set; }
|
||||
public FixedList<uint> Params { get; set; } = new FixedList<uint>(0x100, 0);
|
||||
|
||||
public CharacterFlagsPacket()
|
||||
{
|
||||
Flags = new List<byte>(new byte[0xC00]);
|
||||
Params = new List<uint>(new uint[0x100]);
|
||||
}
|
||||
|
||||
public CharacterFlagsPacket(FixedList<byte> Flags, FixedList<uint> Params)
|
||||
{
|
||||
this.Flags = Flags;
|
||||
this.Params = Params;
|
||||
}
|
||||
|
||||
#region implemented abstract members of Packet
|
||||
@ -30,8 +34,8 @@ namespace PSO2SERVER.Protocol.Packets
|
||||
public override byte[] Build()
|
||||
{
|
||||
var pkt = new PacketWriter();
|
||||
pkt.Write(new byte[0xC00]);
|
||||
pkt.Write(new byte[0x400]);
|
||||
pkt.WriteList(Flags);
|
||||
pkt.WriteList(Params);
|
||||
return pkt.ToArray();
|
||||
}
|
||||
|
||||
|
@ -332,6 +332,7 @@
|
||||
<Compile Include="Protocol\Handlers\04-ObjectHandler\04-75-ActionEnd.cs" />
|
||||
<Compile Include="Protocol\Handlers\06-PlayerStatusHandler\06-01-DealDamage.cs" />
|
||||
<Compile Include="Protocol\Handlers\0B-QuestHandler\0B-20-AcceptQuest.cs" />
|
||||
<Compile Include="Protocol\Handlers\0F-ItemHandler\0F-28-UNK.cs" />
|
||||
<Compile Include="Protocol\Handlers\11-ClientHandler\11-14-BlockLogin.cs" />
|
||||
<Compile Include="Protocol\Handlers\11-ClientHandler\11-90-CharacterUndeletionRequest.cs" />
|
||||
<Compile Include="Protocol\Handlers\11-ClientHandler\11-64-AllBlocksListRequest.cs" />
|
||||
@ -347,6 +348,8 @@
|
||||
<Compile Include="Protocol\Handlers\1F-ClientOrderHandler\1F-01-TakenOrdersRequest.cs" />
|
||||
<Compile Include="Protocol\Handlers\1F-ClientOrderHandler\1F-0F-UNK.cs" />
|
||||
<Compile Include="Protocol\Handlers\1F-ClientOrderHandler\1F-09-UNK1F09.cs" />
|
||||
<Compile Include="Protocol\Handlers\21-PaletteHandler\21-00-LoadPalettesRequest.cs" />
|
||||
<Compile Include="Protocol\Handlers\21-PaletteHandler\21-0A-SetDefaultPAs.cs" />
|
||||
<Compile Include="Protocol\Handlers\23-FlagHandler\23-0B-SkitItemAddRequest.cs" />
|
||||
<Compile Include="Protocol\Handlers\03-ServerHandler\03-03-InitialLoad.cs" />
|
||||
<Compile Include="Protocol\Handlers\03-ServerHandler\03-0C-ServerPong.cs" />
|
||||
@ -398,6 +401,10 @@
|
||||
<Compile Include="Protocol\Handlers\2B-SettingHandler\2B-00-SettingsRequest.cs" />
|
||||
<Compile Include="Protocol\Handlers\2F-SymbolHandler\2F-06-SymbolArtHandler.cs" />
|
||||
<Compile Include="Protocol\Handlers\3B-ForgeHandler\3B-00-CharacterForgeInfoRequest.cs" />
|
||||
<Compile Include="Protocol\Handlers\0F-ItemHandler\0F-DA-UNK0FDA.cs" />
|
||||
<Compile Include="Protocol\Handlers\34-UNK\34-72-UNK.cs" />
|
||||
<Compile Include="Protocol\Handlers\48-UNK\48-16-UNK4816.cs" />
|
||||
<Compile Include="Protocol\Handlers\49-UNK\49-00-UNK4900.cs" />
|
||||
<Compile Include="Protocol\Handlers\4A-ARKSMisionsHandler\4A-00-MissionListRequest.cs" />
|
||||
<Compile Include="Protocol\Handlers\4D-ClassicMissionPassHandler\4D-02-MissionPassRequest.cs" />
|
||||
<Compile Include="Protocol\Handlers\4D-ClassicMissionPassHandler\4D-00-MissionPassInfoRequest.cs" />
|
||||
|
Loading…
Reference in New Issue
Block a user