PSO2SERVER/Server/Packets/Handlers/11-ClientHandler/11-3E-CharacterSpawn.cs

60 lines
2.0 KiB
C#
Raw Normal View History

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;
using PSO2SERVER.Packets.PSOPackets;
using PSO2SERVER.Object;
using PSO2SERVER.Database;
using PSO2SERVER.Zone;
2024-09-10 00:31:40 +08:00
2024-09-10 01:13:20 +08:00
namespace PSO2SERVER.Packets.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-19 11:48:56 +08:00
var info = string.Format("[<--] 接收到的数据 (hex): ");
Logger.WriteHex(info, data);
2024-09-10 00:31:40 +08:00
reader.BaseStream.Seek(0x38, SeekOrigin.Begin);
context.Character.Looks = reader.ReadStruct<Character.LooksParam>();
context.Character.Jobs = reader.ReadStruct<Character.JobParam>();
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
context.SendPacket(new LoadPalettePacket());
2024-09-10 00:31:40 +08:00
// memset packet - Enables menus
// Also holds event items and likely other stuff too
2024-09-15 17:17:05 +08:00
var memSetPacket = File.ReadAllBytes(ServerApp.ServerMemoryPacket);
2024-09-10 00:31:40 +08:00
context.SendPacket(memSetPacket);
}
#endregion
}
}