-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathClient_MessageHandlers.cs
164 lines (137 loc) · 4.54 KB
/
Client_MessageHandlers.cs
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
using System;
using System.Threading;
namespace ClientSimulator
{
public partial class Client
{
private void HandleVersionAndCryptKeyResponse(byte[] buffer, int pos, int bodyLen)
{
#if DEBUG
Console.WriteLine($"<< {nameof(HandleVersionAndCryptKeyResponse)}");
#endif
SendLoginRequest(_userName, _password);
}
private void HandleLoginGrantedResponse(byte[] buffer, int pos, int bodyLen)
{
#if DEBUG
Console.WriteLine($"<< {nameof(HandleLoginGrantedResponse)}");
#endif
if (LoggedIn)
return;
if (_hasConnectionSlot)
{
Console.WriteLine($"{_userName} logged in");
_connectionSlots.Release();
_hasConnectionSlot = false;
}
LoggedIn = true;
_pingTimer = new Timer(Ping, null, 0, 15000);
_udpPingTimer = new Timer(UdpPing, null, 5000, 60000);
SendCharacterSelectRequest();
}
private void HandlePingReply(byte[] buffer, int pos, int bodyLen)
{
#if DEBUG
Console.WriteLine($"<< {nameof(HandlePingReply)}");
#endif
}
private void HandleSetSessionId(byte[] buffer, int pos, int bodyLen)
{
#if DEBUG
Console.WriteLine($"<< {nameof(HandleSetSessionId)}");
#endif
SessionId = ReadShortLowEndian(buffer, ref pos);
if (!OverviewRequested)
SendOverviewRequest();
else if (CharacterSelected)
SendGameOpenRequest();
}
private void HandleSetRealm(byte[] buffer, int pos, int bodyLen)
{
#if DEBUG
Console.WriteLine($"<< {nameof(HandleSetRealm)}");
#endif
}
private void HandleCharacterOverview(byte[] buffer, int pos, int bodyLen)
{
#if DEBUG
Console.WriteLine($"<< {nameof(HandleCharacterOverview)}");
#endif
SendCharacterSelectRequest();
}
private void HandleStartArena(byte[] buffer, int pos, int bodyLen)
{
#if DEBUG
Console.WriteLine($"<< {nameof(HandleStartArena)}");
#endif
}
private void HandleGameOpenReply(byte[] buffer, int pos, int bodyLen)
{
#if DEBUG
Console.WriteLine($"<< {nameof(HandleGameOpenReply)}");
#endif
SendWorldInitRequest();
}
private void HandleLosCheck(byte[] buffer, int pos, int bodyLen)
{
#if DEBUG
Console.WriteLine($"<< {nameof(HandleLosCheck)}");
#endif
ushort player = ReadUShort(buffer, ref pos);
ushort target = ReadUShort(buffer, ref pos);
_ = ReadUShort(buffer, ref pos);
_ = ReadUShort(buffer, ref pos);
SendLosCheck(player, target);
}
private void HandleStatusUpdate(byte[] buffer, int pos, int bodyLen)
{
#if DEBUG
Console.WriteLine($"<< {nameof(HandleStatusUpdate)}");
#endif
}
private void HandleSetPlayerPositionAndOid(byte[] buffer, int pos, int bodyLen)
{
#if DEBUG
Console.WriteLine($"<< {nameof(HandleSetPlayerPositionAndOid)}");
#endif
float x_loc = ReadFloat32LowEndian(buffer, ref pos);
float y_loc = ReadFloat32LowEndian(buffer, ref pos);
float z_loc = ReadFloat32LowEndian(buffer, ref pos);
ushort oid = ReadUShort(buffer, ref pos);
PositionHeading = ReadUShort(buffer, ref pos); // Heading
_positionTimer ??= new Timer(PositionUpdateTimerCallback, null, 1000, 250);
ZoneX = x_loc;
ZoneY = y_loc;
ZoneZ = z_loc;
PositionSpeed = 0;
}
private void HandlePlayerPositionUpdate(byte[] buffer, int pos, int bodyLen)
{
#if DEBUG
Console.WriteLine($"<< {nameof(HandlePlayerPositionUpdate)}");
#endif
}
private void HandlePlayerInitResponse(byte[] buffer, int pos, int bodyLen)
{
#if DEBUG
Console.WriteLine($"<< {nameof(HandlePlayerInitResponse)}");
#endif
}
private void HandleControlledHorse(byte[] buffer, int pos, int bodyLen)
{
#if DEBUG
Console.WriteLine($"<< {nameof(HandleControlledHorse)}");
#endif
if (PlayerInitSent)
return;
SendPlayerInitRequest();
}
private void HandleUDPInitReply(byte[] buffer, int pos, int bodyLen)
{
#if DEBUG
Console.WriteLine($"<< {nameof(HandleUDPInitReply)}");
#endif
SendUdpPingRequest();
}
}
}