forked from Elfocrash/L2dotNET
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGamePacketHandler.cs
More file actions
138 lines (130 loc) · 7.68 KB
/
GamePacketHandler.cs
File metadata and controls
138 lines (130 loc) · 7.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
using System;
using System.Collections.Concurrent;
using System.Runtime.Remoting.Contexts;
using log4net;
using L2dotNET.Network.clientpackets;
using L2dotNET.Network.clientpackets.ClanAPI;
using L2dotNET.Network.clientpackets.ItemEnchantAPI;
using L2dotNET.Network.clientpackets.PartyAPI;
using L2dotNET.Network.clientpackets.PetAPI;
using L2dotNET.Network.clientpackets.RecipeAPI;
using L2dotNET.Network.clientpackets.VehicleAPI;
namespace L2dotNET.Network
{
[Synchronization]
public class GamePacketHandler
{
private static readonly ILog Log = LogManager.GetLogger(typeof(GamePacketHandler));
private static readonly ConcurrentDictionary<byte, Type> ClientPackets = new ConcurrentDictionary<byte, Type>();
private static readonly ConcurrentDictionary<short, Type> ClientPacketsD0 = new ConcurrentDictionary<short, Type>();
static GamePacketHandler()
{
//TODO: Review class packets, looks like some is missing and with wrong KeyValue
ClientPackets.TryAdd(0x00, typeof(ProtocolVersion));
ClientPackets.TryAdd(0x01, typeof(MoveBackwardToLocation));
ClientPackets.TryAdd(0x03, typeof(EnterWorld));
ClientPackets.TryAdd(0x04, typeof(RequestAction));
ClientPackets.TryAdd(0x08, typeof(AuthLogin));
ClientPackets.TryAdd(0x09, typeof(Logout));
ClientPackets.TryAdd(0x0a, typeof(AttackRequest));
ClientPackets.TryAdd(0x0b, typeof(CharacterCreate));
ClientPackets.TryAdd(0x0c, typeof(CharacterDelete));
ClientPackets.TryAdd(0x0d, typeof(CharacterSelected));
ClientPackets.TryAdd(0x0e, typeof(NewCharacter));
ClientPackets.TryAdd(0x0f, typeof(RequestItemList));
ClientPackets.TryAdd(0x11, typeof(RequestUnEquipItem));
ClientPackets.TryAdd(0x12, typeof(RequestDropItem));
ClientPackets.TryAdd(0x14, typeof(RequestUseItem));
ClientPackets.TryAdd(0x16, typeof(RequestAddTradeItem));
ClientPackets.TryAdd(0x17, typeof(RequestTradeDone));
ClientPackets.TryAdd(0x1A, typeof(RequestStartTrade));
ClientPackets.TryAdd(0x1b, typeof(RequestSocialAction));
ClientPackets.TryAdd(0x1e, typeof(RequestSellItem));
ClientPackets.TryAdd(0x1f, typeof(RequestBuyItem));
ClientPackets.TryAdd(0x20, typeof(RequestLinkHtml));
ClientPackets.TryAdd(0x20, typeof(RequestLinkHtml));
ClientPackets.TryAdd(0x21, typeof(RequestBypassToServer));
ClientPackets.TryAdd(0x26, typeof(RequestWithdrawalPledge));
ClientPackets.TryAdd(0x29, typeof(RequestJoinParty));
ClientPackets.TryAdd(0x2a, typeof(RequestAnswerJoinParty));
ClientPackets.TryAdd(0x2b, typeof(RequestWithDrawalParty));
ClientPackets.TryAdd(0x2c, typeof(RequestOustPartyMember));
ClientPackets.TryAdd(0x2f, typeof(RequestMagicSkillUse));
ClientPackets.TryAdd(0x30, typeof(Appearing));
ClientPackets.TryAdd(0x32, typeof(RequestWarehouseWithdraw));
ClientPackets.TryAdd(0x33, typeof(RequestShortCutReg));
ClientPackets.TryAdd(0x35, typeof(RequestShortCutDel));
ClientPackets.TryAdd(0x36, typeof(CannotMoveAnymore));
ClientPackets.TryAdd(0x37, typeof(RequestTargetCanceld));
ClientPackets.TryAdd(0x38, typeof(Say2));
ClientPackets.TryAdd(0x3B, typeof(RequestWarehouseDeposit));
ClientPackets.TryAdd(0x3F, typeof(RequestSkillList));
ClientPackets.TryAdd(0x42, typeof(RequestGetOnVehicle));
ClientPackets.TryAdd(0x43, typeof(RequestGetOffVehicle));
ClientPackets.TryAdd(0x44, typeof(AnswerTradeRequest));
ClientPackets.TryAdd(0x45, typeof(RequestActionUse));
ClientPackets.TryAdd(0x46, typeof(RequestRestart));
ClientPackets.TryAdd(0x48, typeof(ValidatePosition));
ClientPackets.TryAdd(0x4a, typeof(StartRotating));
ClientPackets.TryAdd(0x4b, typeof(FinishRotating));
ClientPackets.TryAdd(0x57, typeof(RequestShowBoard));
ClientPackets.TryAdd(0x58, typeof(RequestEnchantItem));
ClientPackets.TryAdd(0x59, typeof(RequestDestroyItem));
ClientPackets.TryAdd(0x62, typeof(CharacterRestore));
ClientPackets.TryAdd(0x64, typeof(RequestQuestAbort));
ClientPackets.TryAdd(0x66, typeof(RequestPledgeInfo));
ClientPackets.TryAdd(0x6D, typeof(RequestSendMsnChatLog));
ClientPackets.TryAdd(0x73, typeof(RequestAcquireSkillInfo));
ClientPackets.TryAdd(0x5b, typeof(SendBypassBuildCmd));
ClientPackets.TryAdd(0x75, typeof(RequestMoveToLocationInVehicle));
ClientPackets.TryAdd(0x7C, typeof(RequestAcquireSkill));
ClientPackets.TryAdd(0x7D, typeof(RequestRestartPoint));
ClientPackets.TryAdd(0x80, typeof(RequestPartyMatchList));
ClientPackets.TryAdd(0x85, typeof(RequestTutorialLinkHtml));
ClientPackets.TryAdd(0x86, typeof(RequestTutorialPassCmdToServer));
ClientPackets.TryAdd(0x8c, typeof(RequestGetItemFromPet));
ClientPackets.TryAdd(0x93, typeof(RequestChangePetName));
ClientPackets.TryAdd(0x94, typeof(RequestPetUseItem));
ClientPackets.TryAdd(0x95, typeof(RequestGiveItemToPet));
ClientPackets.TryAdd(0x9d, typeof(RequestSkillCoolTime));
ClientPackets.TryAdd(0xaa, typeof(BypassUserCmd));
ClientPackets.TryAdd(0xB0, typeof(MultiSellChoose));
ClientPackets.TryAdd(0xB1, typeof(NetPingResponse));
ClientPackets.TryAdd(0xB5, typeof(RequestRecipeBookOpen));
ClientPackets.TryAdd(0xB6, typeof(RequestRecipeBookDestroy));
ClientPackets.TryAdd(0xB7, typeof(RequestRecipeItemMakeInfo));
ClientPackets.TryAdd(0xB8, typeof(RequestRecipeItemMakeSelf));
ClientPackets.TryAdd(0xC1, typeof(ObserverReturn));
ClientPackets.TryAdd(0xC7, typeof(RequestWearItem));
ClientPackets.TryAdd(0xcd, typeof(RequestShowMiniMap));
ClientPackets.TryAdd(0xcf, typeof(RequestRecordInfo));
ClientPacketsD0.TryAdd(0x05, typeof(RequestAutoSoulShot));
ClientPacketsD0.TryAdd(0x08, typeof(RequestManorList));
ClientPacketsD0.TryAdd(0x11, typeof(RequestExSetPledgeCrestLarge));
ClientPacketsD0.TryAdd(0x1d, typeof(RequestPledgeMemberInfo));
ClientPacketsD0.TryAdd(0x22, typeof(RequestCursedWeaponList));
ClientPacketsD0.TryAdd(0x23, typeof(RequestCursedWeaponLocation));
}
public static void HandlePacket(Packet packet, GameClient client)
{
PacketBase packetBase = null;
if (packet.FirstOpcode != 0xD0)
{
Log.Info($"Received packet with Opcode:{packet.FirstOpcode:X2}");
if (ClientPackets.ContainsKey(packet.FirstOpcode))
packetBase = (PacketBase)Activator.CreateInstance(ClientPackets[packet.FirstOpcode], packet, client);
}
else
{
Log.Info($"Received packet with Opcode 0xD0 and seccond Opcode:{packet.SecondOpcode:X2}");
if (ClientPacketsD0.ContainsKey((short)packet.SecondOpcode))
packetBase = (PacketBase)Activator.CreateInstance(ClientPacketsD0[(short)packet.SecondOpcode], packet, client);
}
if (client.IsTerminated)
return;
if (packetBase == null)
throw new ArgumentNullException(nameof(packetBase), $"Packet with opcode: {packet.FirstOpcode:X2} doesn't exist in the dictionary.");
packetBase.RunImpl();
}
}
}