2024-09-10 00:31:40 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using Newtonsoft.Json;
|
2024-09-10 01:13:20 +08:00
|
|
|
|
using PSO2SERVER.Models;
|
2024-11-27 18:05:53 +08:00
|
|
|
|
using PSO2SERVER.Protocol.Packets;
|
2024-09-10 01:13:20 +08:00
|
|
|
|
using PSO2SERVER.Object;
|
|
|
|
|
using PSO2SERVER.Database;
|
|
|
|
|
using PSO2SERVER.Zone;
|
2024-12-02 20:43:28 +08:00
|
|
|
|
using static PSO2SERVER.Models.CharacterStruct;
|
2024-09-10 00:31:40 +08:00
|
|
|
|
|
2024-11-27 18:05:53 +08:00
|
|
|
|
namespace PSO2SERVER.Protocol.Handlers
|
2024-09-10 00:31:40 +08:00
|
|
|
|
{
|
|
|
|
|
[PacketHandlerAttr(0x11, 0x3E)]
|
|
|
|
|
public class CharacterSpawn : PacketHandler
|
|
|
|
|
{
|
|
|
|
|
#region implemented abstract members of PacketHandler
|
|
|
|
|
|
|
|
|
|
public override void HandlePacket(Client context, byte flags, byte[] data, uint position, uint size)
|
|
|
|
|
{
|
2024-09-20 21:58:37 +08:00
|
|
|
|
if (context._account == null || context.Character == null)
|
2024-09-10 00:31:40 +08:00
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
// Looks/Jobs
|
|
|
|
|
if (size > 0)
|
|
|
|
|
{
|
|
|
|
|
var reader = new PacketReader(data);
|
|
|
|
|
|
2024-09-22 00:08:44 +08:00
|
|
|
|
var info = string.Format("[<--] 接收到的数据 (hex): {0} 字节", data.Length);
|
2024-09-19 11:48:56 +08:00
|
|
|
|
Logger.WriteHex(info, data);
|
|
|
|
|
|
2024-09-10 00:31:40 +08:00
|
|
|
|
reader.BaseStream.Seek(0x38, SeekOrigin.Begin);
|
2024-12-02 20:43:28 +08:00
|
|
|
|
context.Character.Looks = reader.ReadStruct<LooksParam>();
|
|
|
|
|
context.Character.Jobs = reader.ReadStruct<JobParam>();
|
2024-09-10 00:31:40 +08:00
|
|
|
|
|
2024-09-10 01:13:20 +08:00
|
|
|
|
using(var db = new ServerEf())
|
2024-09-10 00:31:40 +08:00
|
|
|
|
db.ChangeTracker.DetectChanges();
|
|
|
|
|
}
|
|
|
|
|
|
2024-09-17 11:29:41 +08:00
|
|
|
|
// 将客户端发送至默认大厅
|
2024-09-10 00:31:40 +08:00
|
|
|
|
Map lobbyMap = ZoneManager.Instance.MapFromInstance("lobby", "lobby");
|
|
|
|
|
lobbyMap.SpawnClient(context, lobbyMap.GetDefaultLocation(), "lobby");
|
|
|
|
|
|
|
|
|
|
// Unlock Controls
|
2024-09-16 16:58:51 +08:00
|
|
|
|
context.SendPacket(new UnlockControlsPacket());
|
2024-09-10 00:31:40 +08:00
|
|
|
|
|
|
|
|
|
//context.SendPacket(File.ReadAllBytes("testbed/237.23-7.210.189.208.30.bin"));
|
|
|
|
|
|
2024-09-17 11:29:41 +08:00
|
|
|
|
// 先给一个空的 Palette
|
2024-12-10 21:54:32 +08:00
|
|
|
|
context.SendPacket(new LoadPalettePacket(context.Palette));
|
2024-09-10 00:31:40 +08:00
|
|
|
|
|
2024-09-21 12:35:09 +08:00
|
|
|
|
// memset packet - Enables menus TODO
|
2024-09-10 00:31:40 +08:00
|
|
|
|
// Also holds event items and likely other stuff too
|
2024-09-21 12:35:09 +08:00
|
|
|
|
//var memSetPacket = File.ReadAllBytes(ServerApp.ServerMemoryPacket);
|
|
|
|
|
//context.SendPacket(memSetPacket);
|
|
|
|
|
context.SendPacket(new CharacterFlagsPacket());
|
2024-09-10 00:31:40 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|