修正部分错误
This commit is contained in:
parent
d2ac82b478
commit
b147a7ee04
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using PSO2SERVER.Protocol.Packets;
|
||||
|
||||
@ -29,6 +30,27 @@ namespace PSO2SERVER
|
||||
WriteFile(text, args);
|
||||
}
|
||||
|
||||
public static void WriteObj(object obj)
|
||||
{
|
||||
if (obj == null)
|
||||
{
|
||||
WriteError("无法分析空的对象.");
|
||||
return;
|
||||
}
|
||||
|
||||
Type objType = obj.GetType();
|
||||
Write($"当前分析对象: {objType.FullName}");
|
||||
|
||||
// Use reflection to get all public fields of the object
|
||||
var fields = objType.GetFields(BindingFlags.Public | BindingFlags.Instance);
|
||||
|
||||
foreach (var field in fields)
|
||||
{
|
||||
var value = field.GetValue(obj);
|
||||
Write($"{field.Name}: {value}");
|
||||
}
|
||||
}
|
||||
|
||||
public static void WriteSend(string text, params object[] args)
|
||||
{
|
||||
AddLine(ConsoleColor.Green, string.Format(text, args));
|
||||
|
@ -6,15 +6,15 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace PSO2SERVER.Models
|
||||
{
|
||||
public enum ItemTypes
|
||||
public enum ItemTypes : ushort
|
||||
{
|
||||
NoItem,
|
||||
NoItem = 0,
|
||||
Weapon,
|
||||
Clothing,
|
||||
Consumable,
|
||||
Camo,
|
||||
Unknown,
|
||||
Unit,
|
||||
Unknown
|
||||
Camo = 10,
|
||||
}
|
||||
|
||||
[Flags]
|
||||
|
@ -26,7 +26,7 @@ namespace PSO2SERVER.Models
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Explicit)]
|
||||
public struct Items
|
||||
public unsafe struct Items
|
||||
{
|
||||
[FieldOffset(0)]
|
||||
public PSO2ItemWeapon Weapon;
|
||||
@ -38,10 +38,10 @@ namespace PSO2SERVER.Models
|
||||
public PSO2ItemCamo Camo;
|
||||
[FieldOffset(0)]
|
||||
public PSO2ItemUnit Unit;
|
||||
//[FieldOffset(0)]
|
||||
//public byte[] Unknown;
|
||||
//[FieldOffset(0)]
|
||||
//public PSO2ItemNone None;
|
||||
[FieldOffset(0)]
|
||||
public fixed byte Unknown[0x28];
|
||||
[FieldOffset(0)]
|
||||
public fixed byte Noitem[0x28];
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
@ -89,28 +89,28 @@ namespace PSO2SERVER.Models
|
||||
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public unsafe struct PSO2ItemNone
|
||||
{
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public unsafe struct PSO2ItemWeapon
|
||||
{
|
||||
/// Item flags.
|
||||
public byte flags;
|
||||
/// Item element.
|
||||
public byte element;
|
||||
/// Item force.
|
||||
public byte force;
|
||||
public byte grind;
|
||||
public byte grindPercent;
|
||||
public byte unknown1;
|
||||
public short unknown2;
|
||||
public fixed short affixes[8];
|
||||
public byte unk1;
|
||||
public ushort unk2;
|
||||
/// Item affix IDs.
|
||||
public fixed ushort affixes[8];
|
||||
/// Item potential.
|
||||
public uint potential;
|
||||
public byte extend;
|
||||
public byte unknown3;
|
||||
public ushort unknown4;
|
||||
public uint unknown5;
|
||||
public uint unknown6;
|
||||
public byte unk4;
|
||||
public ushort unk5;
|
||||
public uint unk6;
|
||||
public uint unk7;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
@ -414,4 +414,35 @@ namespace PSO2SERVER.Models
|
||||
public uint StorageId { get; set; }
|
||||
}
|
||||
|
||||
}
|
||||
public static class AffixUtils
|
||||
{
|
||||
public static ushort[] ReadPackedAffixes(Stream reader)
|
||||
{
|
||||
byte[] packed = new byte[12];
|
||||
reader.Read(packed, 0, packed.Length);
|
||||
|
||||
ushort[] affixes = new ushort[8];
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
affixes[i * 2] = BitConverter.ToUInt16(new byte[] { packed[i * 3], (byte)((packed[i * 3 + 2] & 0xF0) >> 4) }, 0);
|
||||
affixes[i * 2 + 1] = BitConverter.ToUInt16(new byte[] { packed[i * 3 + 1], (byte)(packed[i * 3 + 2] & 0xF) }, 0);
|
||||
}
|
||||
return affixes;
|
||||
}
|
||||
|
||||
public static void WritePackedAffixes(ushort[] affixes, Stream writer)
|
||||
{
|
||||
byte[] packed = new byte[12];
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
byte[] affix1 = BitConverter.GetBytes(affixes[i * 2]);
|
||||
byte[] affix2 = BitConverter.GetBytes(affixes[i * 2 + 1]);
|
||||
|
||||
packed[i * 3] = affix1[0];
|
||||
packed[i * 3 + 1] = affix2[0];
|
||||
packed[i * 3 + 2] = (byte)((affix1[1] << 4) | (affix2[1] & 0xF));
|
||||
}
|
||||
writer.Write(packed, 0, packed.Length);
|
||||
}
|
||||
}
|
||||
}
|
@ -58,7 +58,7 @@ namespace PSO2SERVER.Protocol.Handlers
|
||||
};
|
||||
|
||||
|
||||
Logger.Write($"PKT:Object1 {pkt.Object1.ToString()} Object3 {pkt.Object3.ToString()} Action {pkt.Action}");
|
||||
//Logger.Write($"PKT:Object1 {pkt.Object1.ToString()} Object3 {pkt.Object3.ToString()} Action {pkt.Action}");
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using PSO2SERVER.Models;
|
||||
using PSO2SERVER.Protocol.Packets;
|
||||
|
||||
namespace PSO2SERVER.Protocol.Handlers
|
||||
{
|
||||
[PacketHandlerAttr(0x0F, 0x1C)]
|
||||
public class GetItemDescription : PacketHandler
|
||||
{
|
||||
public struct GetItemDescriptionPacket
|
||||
{
|
||||
/// Item ID which description is requested.
|
||||
public ItemId Item { get; set; }
|
||||
}
|
||||
|
||||
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 pkt = reader.ReadStruct<GetItemDescriptionPacket>();
|
||||
|
||||
Logger.WriteObj(pkt.Item);
|
||||
}
|
||||
}
|
||||
}
|
@ -340,6 +340,7 @@
|
||||
<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-01-ItemPickupRequest.cs" />
|
||||
<Compile Include="Protocol\Handlers\0F-ItemHandler\0F-1C-GetItemDescription.cs" />
|
||||
<Compile Include="Protocol\Handlers\0F-ItemHandler\0F-E0-MoveToMatStorageRequest.cs" />
|
||||
<Compile Include="Protocol\Handlers\0F-ItemHandler\0F-28-UNK.cs" />
|
||||
<Compile Include="Protocol\Handlers\11-ClientHandler\11-14-BlockLogin.cs" />
|
||||
|
@ -35,7 +35,7 @@ namespace ServerTest
|
||||
foreach (var p in PacketHandlers.GetLoadedHandlers())
|
||||
{
|
||||
Assert.IsNotNull(p);
|
||||
Assert.IsInstanceOf(typeof(PacketHandler), p, "Loaded PacketHandler is not a Packet Handler!");
|
||||
Assert.IsInstanceOf(typeof(PacketHandler), p, "加载的PacketHandler不是一个包处理程序!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user