修正部分数据包处理 快捷栏生成处理

角色生成函数还需要继续修正
This commit is contained in:
Longfeng Qin 2024-12-10 21:54:32 +08:00
parent 3f3b4b146a
commit 391dd3d1b6
21 changed files with 347 additions and 143 deletions

View File

@ -69,6 +69,8 @@ namespace PSO2SERVER
public uint MovementTimestamp { get; internal set; } public uint MovementTimestamp { get; internal set; }
public Party.Party currentParty; public Party.Party currentParty;
public PSOPalette Palette { get; set; } = new PSOPalette();
public PSOLocation CurrentLocation; public PSOLocation CurrentLocation;
public PSOLocation LastLocation; public PSOLocation LastLocation;

View File

@ -19,10 +19,7 @@ namespace PSO2SERVER.Json
var fixedList = new FixedList<T>(list.Count); var fixedList = new FixedList<T>(list.Count);
// 将 list 中的元素添加到 FixedList 中 // 将 list 中的元素添加到 FixedList 中
foreach (var item in list) fixedList.SetListItem(list);
{
fixedList.Add(item);
}
return fixedList; return fixedList;
} }

View File

@ -7,6 +7,8 @@ using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Collections; using System.Collections;
using System.Xml.Linq; using System.Xml.Linq;
using System.IO;
using PSO2SERVER.Protocol;
namespace PSO2SERVER.Models namespace PSO2SERVER.Models
{ {
@ -47,6 +49,7 @@ namespace PSO2SERVER.Models
_data.Add(item); _data.Add(item);
} }
public void Insert(int index, T item) public void Insert(int index, T item)
{ {
if (index < 0 || index > _data.Count) if (index < 0 || index > _data.Count)
@ -57,6 +60,7 @@ namespace PSO2SERVER.Models
_data.Insert(index, item); _data.Insert(index, item);
} }
public void RemoveAt(int index) public void RemoveAt(int index)
{ {
if (index < 0 || index >= _data.Count) if (index < 0 || index >= _data.Count)
@ -72,6 +76,73 @@ namespace PSO2SERVER.Models
_data.RemoveAt(_data.Count - 1); _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() public void Clear()
{ {
_data.Clear(); _data.Clear();

View File

@ -1,4 +1,5 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Security.AccessControl;
using PSO2SERVER.Protocol.Packets; using PSO2SERVER.Protocol.Packets;
@ -57,20 +58,18 @@ namespace PSO2SERVER.Models
public AccountFlagsPacket ToAccountFlags() public AccountFlagsPacket ToAccountFlags()
{ {
return new AccountFlagsPacket var aflags = new AccountFlagsPacket();
{ aflags.Flags.SetListItem(flags);
Flags = new List<byte>(flags), aflags.Params.SetListItem(paramsList);
Params = new List<uint>(paramsList) return aflags;
};
} }
public CharacterFlagsPacket ToCharFlags() public CharacterFlagsPacket ToCharFlags()
{ {
return new CharacterFlagsPacket var cflags = new CharacterFlagsPacket();
{ cflags.Flags.SetListItem(flags);
Flags = new List<byte>(flags), cflags.Params.SetListItem(paramsList);
Params = new List<uint>(paramsList) return cflags;
};
} }
private static byte SetBit(byte byteValue, byte index, byte val) private static byte SetBit(byte byteValue, byte index, byte val)

View File

@ -258,7 +258,7 @@ namespace PSO2SERVER.Models
[JsonProperty("unk8")] [JsonProperty("unk8")]
[JsonConverter(typeof(FixedListConverter<byte>))] [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 // Equipable races
[JsonProperty("race")] [JsonProperty("race")]
@ -584,62 +584,62 @@ namespace PSO2SERVER.Models
public class Data7 public class Data7
{ {
[JsonConverter(typeof(FixedListConverter<byte>))] [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 public class Data8
{ {
[JsonConverter(typeof(FixedListConverter<byte>))] [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 public class Data9
{ {
[JsonConverter(typeof(FixedListConverter<byte>))] [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 public class Data10
{ {
[JsonConverter(typeof(FixedListConverter<byte>))] [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 public class Data11
{ {
[JsonConverter(typeof(FixedListConverter<byte>))] [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 public class Data12
{ {
[JsonConverter(typeof(FixedListConverter<byte>))] [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 public class Data13
{ {
[JsonConverter(typeof(FixedListConverter<byte>))] [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 public class Data14
{ {
[JsonConverter(typeof(FixedListConverter<byte>))] [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 public class Data15
{ {
[JsonConverter(typeof(FixedListConverter<byte>))] [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 public class Data16
{ {
[JsonConverter(typeof(FixedListConverter<byte>))] [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 public class Data17
{ {
[JsonConverter(typeof(FixedListConverter<byte>))] [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 public class Data18
{ {
[JsonConverter(typeof(FixedListConverter<byte>))] [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 public class ShortData
{ {
@ -648,17 +648,17 @@ namespace PSO2SERVER.Models
public class Data19 public class Data19
{ {
[JsonConverter(typeof(FixedListConverter<byte>))] [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 public class Data19Vita
{ {
[JsonConverter(typeof(FixedListConverter<byte>))] [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 public class Data20
{ {
[JsonConverter(typeof(FixedListConverter<byte>))] [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 public struct GenderDmg

View File

@ -16,7 +16,7 @@ namespace PSO2SERVER.Models
[JsonProperty("items")] [JsonProperty("items")]
[JsonConverter(typeof(FixedListConverter<PalettePA>))] [JsonConverter(typeof(FixedListConverter<PalettePA>))]
// Items in the subpalette. // 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) public void ReadFromStream(PacketReader reader)
@ -27,7 +27,7 @@ namespace PSO2SERVER.Models
// 读取每个 PalettePA // 读取每个 PalettePA
var palettePA = new PalettePA(); var palettePA = new PalettePA();
palettePA.ReadFromStream(reader); palettePA.ReadFromStream(reader);
Items.Add(palettePA); // 将读取的数据存储到 FixedList 中 Items.SetItem(i, palettePA);
} }
} }
@ -58,7 +58,6 @@ namespace PSO2SERVER.Models
public PalettePA() public PalettePA()
{ {
} }
public PalettePA(byte id, byte category, byte unk, byte level) public PalettePA(byte id, byte category, byte unk, byte level)
@ -88,14 +87,14 @@ namespace PSO2SERVER.Models
public class WeaponPalette public class WeaponPalette
{ {
public ulong Uuid { get; set; } public ulong Uuid { get; set; } = 0;
public uint Unk1 { get; set; } public uint Unk1 { get; set; } = 0;
public PalettePA Unk2 { get; set; } public PalettePA Unk2 { get; set; } = new PalettePA();
public PalettePA Unk3 { get; set; } public PalettePA Unk3 { get; set; } = new PalettePA();
public PalettePA Unk4 { get; set; } public PalettePA Unk4 { get; set; } = new PalettePA();
public uint[] Unk { get; set; } = new uint[3]; public uint[] Unk { get; set; } = new uint[3];
public uint PetId { get; set; } public uint PetId { get; set; } = 0;
public PalettePA[] Skills { get; set; } = new PalettePA[6]; public List<PalettePA> Skills { get; set; } = new List<PalettePA>(6);
public WeaponPalette() public WeaponPalette()
{ {
@ -116,9 +115,8 @@ namespace PSO2SERVER.Models
Unk[i] = reader.ReadUInt32(); Unk[i] = reader.ReadUInt32();
} }
PetId = 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); Skills[i].ReadFromStream(reader);
} }
} }
@ -144,90 +142,59 @@ namespace PSO2SERVER.Models
public class PSOPalette 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; CurPalette = reader.ReadUInt32();
public uint CurSubpalette; CurSubpalette = reader.ReadUInt32();
public uint CurBook; CurBook = reader.ReadUInt32();
public WeaponPalette[] Palettes;
public SubPalette[] Subpalettes;
public List<uint> DefaultPas;
// 构造函数 for (int i = 0; i < Palettes.Length; i++)
public static Palette Create()
{ {
Palette palette = new Palette Palettes[i].ReadFromStream(reader);
{
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;
} }
public void ReadFromStream(PacketReader reader) for (int i = 0; i < Subpalettes.Length; i++)
{ {
CurPalette = reader.ReadUInt32(); Subpalettes[i].ReadFromStream(reader);
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());
}
} }
public void WriteToStream(PacketWriter writer) int defaultPasCount = reader.ReadInt32(); // 假设先读入数量
DefaultPas.Clear();
for (int i = 0; i < defaultPasCount; i++)
{ {
writer.Write(CurPalette); DefaultPas.Add(reader.ReadUInt32());
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);
}
} }
} }
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);
}
}
} }
} }

View 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);
}
}
}

View 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);
}
}
}

View File

@ -47,7 +47,7 @@ namespace PSO2SERVER.Protocol.Handlers
//context.SendPacket(File.ReadAllBytes("testbed/237.23-7.210.189.208.30.bin")); //context.SendPacket(File.ReadAllBytes("testbed/237.23-7.210.189.208.30.bin"));
// 先给一个空的 Palette // 先给一个空的 Palette
context.SendPacket(new LoadPalettePacket()); context.SendPacket(new LoadPalettePacket(context.Palette));
// memset packet - Enables menus TODO // memset packet - Enables menus TODO
// Also holds event items and likely other stuff too // Also holds event items and likely other stuff too

View File

@ -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));
}
}
}

View File

@ -12,7 +12,7 @@ namespace PSO2SERVER.Protocol.Handlers
var info = string.Format("[<--] 接收到的数据 (hex): {0} 字节", data.Length); var info = string.Format("[<--] 接收到的数据 (hex): {0} 字节", data.Length);
Logger.WriteHex(info, data); Logger.WriteHex(info, data);
var Palette = PSOPalette.Palette.Create(); var Palette = new PSOPalette();
context.SendPacket(new FullPaletteInfoPacket(Palette)); context.SendPacket(new FullPaletteInfoPacket(Palette));
} }

View File

@ -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));
}
}
}

View 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);
}
}
}

View 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);
}
}
}

View 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);
}
}
}

View File

@ -13,22 +13,22 @@ namespace PSO2SERVER.Protocol.Packets
public WeaponPalette[] Palettes { get; set; } = new WeaponPalette[6]; public WeaponPalette[] Palettes { get; set; } = new WeaponPalette[6];
public SubPalette[] Subpalettes { get; set; } = new SubPalette[6]; public SubPalette[] Subpalettes { get; set; } = new SubPalette[6];
public LoadPalettePacket() public LoadPalettePacket(PSOPalette palette)
{ {
CurPalette = 1; CurPalette = palette.CurPalette;
CurSubpalette = 0; CurSubpalette = palette.CurSubpalette;
CurBook = 0; CurBook = palette.CurBook;
// 初始化 Palettes // 初始化 Palettes
for (int i = 0; i < Palettes.Length; i++) for (int i = 0; i < Palettes.Length; i++)
{ {
Palettes[i] = new WeaponPalette(); Palettes[i] = palette.Palettes[i];
} }
// 初始化 Subpalettes根据需要可以进行自定义初始化 // 初始化 Subpalettes根据需要可以进行自定义初始化
for (int i = 0; i < Subpalettes.Length; i++) for (int i = 0; i < Subpalettes.Length; i++)
{ {
Subpalettes[i] = new SubPalette(); // 这里可以根据需要进行初始化 Subpalettes[i] = palette.Subpalettes[i]; // 这里可以根据需要进行初始化
} }
} }

View File

@ -10,9 +10,9 @@ namespace PSO2SERVER.Protocol.Packets
{ {
public class FullPaletteInfoPacket : Packet 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; this.Palette = palette;
} }

View File

@ -11,14 +11,16 @@ namespace PSO2SERVER.Protocol.Packets
{ {
public const int SeekAfter = 0x240; // 576 bytes 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) public NewDefaultPAsPacket(List<uint> Default)
{ {
foreach (var item in Default) this.Default.SetListItem(Default);
{ }
this.Default.Add(item);
} public NewDefaultPAsPacket(FixedList<uint> Default)
{
this.Default = Default;
} }
public void ReadFromStream(PacketReader reader) public void ReadFromStream(PacketReader reader)
@ -28,7 +30,7 @@ namespace PSO2SERVER.Protocol.Packets
// 读取 Default // 读取 Default
for (int i = 0; i < Default.Capacity; i++) for (int i = 0; i < Default.Capacity; i++)
{ {
Default.Add(reader.ReadUInt32()); Default.SetItem(i, reader.ReadUInt32());
} }
} }

View File

@ -9,14 +9,18 @@ namespace PSO2SERVER.Protocol.Packets
public class AccountFlagsPacket : Packet public class AccountFlagsPacket : Packet
{ {
// Accounts flags (0x400 bytes) // 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) // Accounts parameters (0x100 bytes)
public List<uint> Params { get; set; } public FixedList<uint> Params { get; set; } = new FixedList<uint>(0x100, 0);
public AccountFlagsPacket() 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 #region implemented abstract members of Packet
@ -24,8 +28,8 @@ namespace PSO2SERVER.Protocol.Packets
public override byte[] Build() public override byte[] Build()
{ {
var pkt = new PacketWriter(); var pkt = new PacketWriter();
pkt.Write(new byte[0x400]); pkt.WriteList(Flags);
pkt.Write(new byte[0x400]); pkt.WriteList(Params);
return pkt.ToArray(); return pkt.ToArray();
} }

View File

@ -12,17 +12,21 @@ namespace PSO2SERVER.Protocol.Packets
/// <summary> /// <summary>
/// Character flags. /// Character flags.
/// </summary> /// </summary>
public List<byte> Flags { get; set; } public FixedList<byte> Flags { get; set; } = new FixedList<byte>(0xC00, 0);
/// <summary> /// <summary>
/// Character parameters. /// Character parameters.
/// </summary> /// </summary>
public List<uint> Params { get; set; } public FixedList<uint> Params { get; set; } = new FixedList<uint>(0x100, 0);
public CharacterFlagsPacket() 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 #region implemented abstract members of Packet
@ -30,8 +34,8 @@ namespace PSO2SERVER.Protocol.Packets
public override byte[] Build() public override byte[] Build()
{ {
var pkt = new PacketWriter(); var pkt = new PacketWriter();
pkt.Write(new byte[0xC00]); pkt.WriteList(Flags);
pkt.Write(new byte[0x400]); pkt.WriteList(Params);
return pkt.ToArray(); return pkt.ToArray();
} }

View File

@ -332,6 +332,7 @@
<Compile Include="Protocol\Handlers\04-ObjectHandler\04-75-ActionEnd.cs" /> <Compile Include="Protocol\Handlers\04-ObjectHandler\04-75-ActionEnd.cs" />
<Compile Include="Protocol\Handlers\06-PlayerStatusHandler\06-01-DealDamage.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\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-14-BlockLogin.cs" />
<Compile Include="Protocol\Handlers\11-ClientHandler\11-90-CharacterUndeletionRequest.cs" /> <Compile Include="Protocol\Handlers\11-ClientHandler\11-90-CharacterUndeletionRequest.cs" />
<Compile Include="Protocol\Handlers\11-ClientHandler\11-64-AllBlocksListRequest.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-01-TakenOrdersRequest.cs" />
<Compile Include="Protocol\Handlers\1F-ClientOrderHandler\1F-0F-UNK.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\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\23-FlagHandler\23-0B-SkitItemAddRequest.cs" />
<Compile Include="Protocol\Handlers\03-ServerHandler\03-03-InitialLoad.cs" /> <Compile Include="Protocol\Handlers\03-ServerHandler\03-03-InitialLoad.cs" />
<Compile Include="Protocol\Handlers\03-ServerHandler\03-0C-ServerPong.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\2B-SettingHandler\2B-00-SettingsRequest.cs" />
<Compile Include="Protocol\Handlers\2F-SymbolHandler\2F-06-SymbolArtHandler.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\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\4A-ARKSMisionsHandler\4A-00-MissionListRequest.cs" />
<Compile Include="Protocol\Handlers\4D-ClassicMissionPassHandler\4D-02-MissionPassRequest.cs" /> <Compile Include="Protocol\Handlers\4D-ClassicMissionPassHandler\4D-02-MissionPassRequest.cs" />
<Compile Include="Protocol\Handlers\4D-ClassicMissionPassHandler\4D-00-MissionPassInfoRequest.cs" /> <Compile Include="Protocol\Handlers\4D-ClassicMissionPassHandler\4D-00-MissionPassInfoRequest.cs" />