新增部分未解析数据包

This commit is contained in:
Longfeng Qin 2024-09-16 15:30:00 +08:00
parent dc45c19cbe
commit d94fcdfa76
13 changed files with 185 additions and 33 deletions

View File

@ -6,6 +6,7 @@ using PSO2SERVER.Models;
using PSO2SERVER.Network; using PSO2SERVER.Network;
using PSO2SERVER.Packets; using PSO2SERVER.Packets;
using PSO2SERVER.Packets.Handlers; using PSO2SERVER.Packets.Handlers;
using PSO2SERVER.Packets.PSOPackets;
using PSO2SERVER.Zone; using PSO2SERVER.Zone;
namespace PSO2SERVER namespace PSO2SERVER
@ -34,12 +35,7 @@ namespace PSO2SERVER
InputArc4 = null; InputArc4 = null;
OutputArc4 = null; OutputArc4 = null;
var welcome = new PacketWriter(); SendPacket(new ServerHelloPacket());
welcome.Write((ushort)3);
welcome.Write((ushort)201);
welcome.Write((ushort)0);
welcome.Write((ushort)0);
SendPacket(0x03, 0x08, 0, welcome.ToArray());
} }
public bool IsClosed { get; private set; } public bool IsClosed { get; private set; }
@ -65,7 +61,7 @@ namespace PSO2SERVER
return; return;
} }
Logger.Write("[接收] 接收到 {0} 字节", size); //Logger.Write("[接收] 接收到 {0} 字节", size);
Array.Copy(data, 0, _readBuffer, _readBufferSize, size); Array.Copy(data, 0, _readBuffer, _readBufferSize, size);

View File

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PSO2SERVER.Packets.Handlers
{
//[PacketHandlerAttr(0x03, 0x00)]
//class MapTransfer : PacketHandler
//{
// /// (0x03, 0x00) Map Transfer.
// public override void HandlePacket(Client context, byte flags, byte[] data, uint position, uint size)
// {
// //var info = string.Format("[接收] 接收到的数据 (hex): ");
// //Logger.WriteHex(info, data);
// }
//}
}

View File

@ -9,6 +9,13 @@ namespace PSO2SERVER.Packets.Handlers
[PacketHandlerAttr(0x03, 0x03)] [PacketHandlerAttr(0x03, 0x03)]
public class InitialLoad : PacketHandler public class InitialLoad : PacketHandler
{ {
/// (0x03, 0x03) Initial Load (?).
///
/// (C -> S) Sent when the client loads for the first time in the session.
///
/// Response to: [`Packet::LoadingScreenTransition`] (?).
///
/// Respond with: lobby map setup.
// Ninji note: 3-3 may not be the correct place to do this // Ninji note: 3-3 may not be the correct place to do this
// Once we have better state tracking, we should make sure that // Once we have better state tracking, we should make sure that
// 3-3 only does anything at the points where the client is supposed // 3-3 only does anything at the points where the client is supposed
@ -26,7 +33,7 @@ namespace PSO2SERVER.Packets.Handlers
// Set Player ID // Set Player ID
var setPlayerId = new PacketWriter(); var setPlayerId = new PacketWriter();
setPlayerId.WritePlayerHeader((uint)context.User.PlayerId); setPlayerId.WritePlayerHeader((uint)context.User.PlayerId);
context.SendPacket(6, 0, 0, setPlayerId.ToArray()); context.SendPacket(0x06, 0x00, 0, setPlayerId.ToArray());
// Spawn Player // Spawn Player
new CharacterSpawn().HandlePacket(context, flags, data, position, size); new CharacterSpawn().HandlePacket(context, flags, data, position, size);

View File

@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PSO2SERVER.Packets.Handlers
{
//[PacketHandlerAttr(0x03, 0x06)]
//class _0B_06_UNK : PacketHandler
//{
// public override void HandlePacket(Client context, byte flags, byte[] data, uint position, uint size)
// {
// //var info = string.Format("[接收] 接收到的数据 (hex): ");
// //Logger.WriteHex(info, data);
// }
//}
}

View File

@ -28,9 +28,11 @@ namespace PSO2SERVER.Packets.Handlers
} }
else if(srcObject.EntityType == EntityType.Player) else if(srcObject.EntityType == EntityType.Player)
{ {
srcObj = new PSOObject(); srcObj = new PSOObject
srcObj.Header = srcObject; {
srcObj.Name = "Player"; Header = srcObject,
Name = "Player"
};
} }
else else
{ {

View File

@ -1,11 +1,34 @@
using System.IO; using System.Collections.Generic;
using System.IO;
using System.Linq; using System.Linq;
namespace PSO2SERVER.Packets.Handlers namespace PSO2SERVER.Packets.Handlers
{ {
[PacketHandlerAttr(0x07, 0x00)] [PacketHandlerAttr(0x07, 0x00)]
public class ChatHandler : PacketHandler public class ChatHandler : PacketHandler
{ {
//public uint Unk1 { get; set; }
//public uint Unk2 { get; set; }
//public uint Unk3 { get; set; }
//public byte[] VerId { get; set; } = new byte[0x20];
//public List<NetInterface> Interfaces { get; set; } = new List<NetInterface>();
//public byte[] Unk4 { get; set; } = new byte[0x90];
//public byte[] Unk5 { get; set; } = new byte[0x10];
//public Language TextLang { get; set; }
//public Language VoiceLang { get; set; }
//public Language TextLang2 { get; set; }
//public Language LangLang { get; set; }
//public string Language { get; set; } = new string(' ', 0x10);
//public uint Unk6 { get; set; }
//public uint Unk7 { get; set; }
//public uint Magic1 { get; set; }
//public byte[] Unk8 { get; set; } = new byte[0x20];
//public byte[] Unk9 { get; set; } = new byte[0x44];
//public string Username { get; set; } = new string(' ', 0x40);
//public string Password { get; set; } = new string(' ', 0x40);
//public uint Unk10 { get; set; }
//public string Unk11 { get; set; }
#region implemented abstract members of PacketHandler #region implemented abstract members of PacketHandler
public override void HandlePacket(Client context, byte flags, byte[] data, uint position, uint size) public override void HandlePacket(Client context, byte flags, byte[] data, uint position, uint size)
@ -67,4 +90,25 @@ namespace PSO2SERVER.Packets.Handlers
#endregion #endregion
} }
public enum MessageChannel : byte
{
// Map channel.
Map = 0,
// Party channel.
Party = 1,
// Alliance channel.
Alliance = 2,
// Whisper channel.
Whisper = 3,
// Group channel.
Group = 4,
// Undefined channel.
Undefined = 0xFF
}
} }

View File

@ -4,13 +4,13 @@ using PSO2SERVER.Packets.PSOPackets;
namespace PSO2SERVER.Packets.Handlers namespace PSO2SERVER.Packets.Handlers
{ {
[PacketHandlerAttr(0x0B, 0x09)] //[PacketHandlerAttr(0x0B, 0x09)]
class _0B_09_UNK : PacketHandler //class _0B_09_UNK : PacketHandler
{ //{
public override void HandlePacket(Client context, byte flags, byte[] data, uint position, uint size) // public override void HandlePacket(Client context, byte flags, byte[] data, uint position, uint size)
{ // {
var info = string.Format("[接收] 接收到的数据 (hex): "); // //var info = string.Format("[接收] 接收到的数据 (hex): ");
Logger.WriteHex(info, data); // //Logger.WriteHex(info, data);
} // }
} //}
} }

View File

@ -4,13 +4,13 @@ using PSO2SERVER.Packets.PSOPackets;
namespace PSO2SERVER.Packets.Handlers namespace PSO2SERVER.Packets.Handlers
{ {
[PacketHandlerAttr(0x0E, 0x19)] // [PacketHandlerAttr(0x0E, 0x19)]
class _0E_19_UNK : PacketHandler // class _0E_19_UNK : PacketHandler
{ // {
public override void HandlePacket(Client context, byte flags, byte[] data, uint position, uint size) // public override void HandlePacket(Client context, byte flags, byte[] data, uint position, uint size)
{ // {
var info = string.Format("[接收] 接收到的数据 (hex): "); // //var info = string.Format("[接收] 接收到的数据 (hex): ");
Logger.WriteHex(info, data); // //Logger.WriteHex(info, data);
} // }
} // }
} }

View File

@ -5,7 +5,7 @@ using System.Linq;
namespace PSO2SERVER.Packets.Handlers namespace PSO2SERVER.Packets.Handlers
{ {
[PacketHandlerAttr(0x11, 0x4)] [PacketHandlerAttr(0x11, 0x04)]
public class StartGame : PacketHandler public class StartGame : PacketHandler
{ {
#region implemented abstract members of PacketHandler #region implemented abstract members of PacketHandler
@ -46,7 +46,7 @@ namespace PSO2SERVER.Packets.Handlers
PartyManager.Instance.CreateNewParty(context); PartyManager.Instance.CreateNewParty(context);
// Transition to the loading screen // Transition to the loading screen
context.SendPacket(new NoPayloadPacket(0x3, 0x4)); context.SendPacket(new NoPayloadPacket(0x03, 0x04));
// TODO Set area, Set character, possibly more. See PolarisLegacy for more. // TODO Set area, Set character, possibly more. See PolarisLegacy for more.
} }

View File

@ -78,7 +78,7 @@ namespace PSO2SERVER.Packets.Handlers
var decryptedToken = new byte[16]; var decryptedToken = new byte[16];
tempDecryptor.TransformBlock(decryptedBlob, 0, 0x10, decryptedToken, 0); tempDecryptor.TransformBlock(decryptedBlob, 0, 0x10, decryptedToken, 0);
context.SendPacket(0x11, 0xC, 0, decryptedToken); context.SendPacket(0x11, 0x0C, 0, decryptedToken);
} }
#endregion #endregion

View File

@ -0,0 +1,11 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace PSO2SERVER.Packets.PSOPackets
{
class LoadingScreenTransitionPacket
{
}
}

View File

@ -0,0 +1,49 @@
using System;
using System.IO;
using PSO2SERVER.Models;
namespace PSO2SERVER.Packets.PSOPackets
{
class ServerHelloPacket : Packet
{
/// <summary>
/// Unknown. Seems to be always 0x03.
/// </summary>
public ushort Unk1 { get; set; }
/// <summary>
/// Block Id.
/// </summary>
public ushort BlockId { get; set; }
public uint Unk2 { get; set; }
public ServerHelloPacket()
{
Unk1 = 0x03; // Initialize Unk1 with default value
}
public override byte[] Build()
{
//var welcome = new PacketWriter();
//welcome.Write((ushort)3);
//welcome.Write((ushort)201);
//welcome.Write((ushort)0);
//welcome.Write((ushort)0);
PacketWriter writer = new PacketWriter();
writer.Write(Unk1);
writer.Seek(4, SeekOrigin.Current); // Skip 4 bytes
writer.Write(BlockId);
writer.Write(Unk2);
return writer.ToArray();
}
public override PacketHeader GetHeader()
{
return new PacketHeader(0x03, 0x08, PacketFlags.None);
}
}
}

View File

@ -170,6 +170,8 @@
<Compile Include="Models\Quest.cs" /> <Compile Include="Models\Quest.cs" />
<Compile Include="Network\PortChecker.cs" /> <Compile Include="Network\PortChecker.cs" />
<Compile Include="Object\ObjectManager.cs" /> <Compile Include="Object\ObjectManager.cs" />
<Compile Include="Packets\Handlers\03-06-UNK.cs" />
<Compile Include="Packets\Handlers\03-00-MapTransfer.cs" />
<Compile Include="Packets\Handlers\03-03-InitialLoad.cs" /> <Compile Include="Packets\Handlers\03-03-InitialLoad.cs" />
<Compile Include="Packets\Handlers\03-0C-PingResponse.cs" /> <Compile Include="Packets\Handlers\03-0C-PingResponse.cs" />
<Compile Include="Packets\Handlers\03-10-DoItMaybe.cs" /> <Compile Include="Packets\Handlers\03-10-DoItMaybe.cs" />
@ -194,6 +196,7 @@
<Compile Include="Packets\Handlers\03-34-ReturnToLobbyHandler.cs" /> <Compile Include="Packets\Handlers\03-34-ReturnToLobbyHandler.cs" />
<Compile Include="Packets\Handlers\11-41-CreateCharacterOne.cs" /> <Compile Include="Packets\Handlers\11-41-CreateCharacterOne.cs" />
<Compile Include="Packets\Handlers\2F-06-SymbolArtHandler.cs" /> <Compile Include="Packets\Handlers\2F-06-SymbolArtHandler.cs" />
<Compile Include="Packets\PSOPackets\03-08-ServerHelloPacket.cs" />
<Compile Include="Packets\PSOPackets\1C-1F-GuildInfoPacket.cs" /> <Compile Include="Packets\PSOPackets\1C-1F-GuildInfoPacket.cs" />
<Compile Include="Packets\PSOPackets\11-01-LoginDataPacket.cs" /> <Compile Include="Packets\PSOPackets\11-01-LoginDataPacket.cs" />
<Compile Include="Packets\PSOPackets\04-07-MovementPacket.cs" /> <Compile Include="Packets\PSOPackets\04-07-MovementPacket.cs" />
@ -207,6 +210,7 @@
<Compile Include="Packets\PSOPackets\11-1C-SetCurrencyPacket.cs" /> <Compile Include="Packets\PSOPackets\11-1C-SetCurrencyPacket.cs" />
<Compile Include="Packets\PSOPackets\0F-14-SetMesetaPacket.cs" /> <Compile Include="Packets\PSOPackets\0F-14-SetMesetaPacket.cs" />
<Compile Include="Packets\PSOPackets\0E-25-SetQuestPacket.cs" /> <Compile Include="Packets\PSOPackets\0E-25-SetQuestPacket.cs" />
<Compile Include="Packets\PSOPackets\03-04-LoadingScreenTransitionPacket.cs" />
<Compile Include="Packets\PSOPackets\UN-UN-SetScenePacket.cs" /> <Compile Include="Packets\PSOPackets\UN-UN-SetScenePacket.cs" />
<Compile Include="Packets\PSOPackets\2F-07-SymbolArtList.cs" /> <Compile Include="Packets\PSOPackets\2F-07-SymbolArtList.cs" />
<Compile Include="Packets\PSOPackets\04-02-TeleportTransferPacket.cs" /> <Compile Include="Packets\PSOPackets\04-02-TeleportTransferPacket.cs" />