/
PacketHandlers.cs
3367 lines (2783 loc) · 81.4 KB
/
PacketHandlers.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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#region References
using System;
using System.Collections.Generic;
using System.IO;
using Server.Accounting;
using Server.ContextMenus;
using Server.Diagnostics;
using Server.Gumps;
using Server.HuePickers;
using Server.Items;
using Server.Menus;
using Server.Mobiles;
using Server.Prompts;
using Server.Targeting;
using CV = Server.ClientVersion;
#endregion
namespace Server.Network
{
public enum MessageType
{
Regular = 0x00,
System = 0x01,
Emote = 0x02,
Label = 0x06,
Focus = 0x07,
Whisper = 0x08,
Yell = 0x09,
Spell = 0x0A,
Guild = 0x0D,
Alliance = 0x0E,
Command = 0x0F,
Encoded = 0xC0
}
public static class PacketHandlers
{
private static readonly PacketHandler[] m_Handlers;
private static readonly PacketHandler[] m_6017Handlers;
private static readonly PacketHandler[] m_ExtendedHandlersLow;
private static readonly Dictionary<int, PacketHandler> m_ExtendedHandlersHigh;
private static readonly EncodedPacketHandler[] m_EncodedHandlersLow;
private static readonly Dictionary<int, EncodedPacketHandler> m_EncodedHandlersHigh;
public static PacketHandler[] Handlers { get { return m_Handlers; } }
static PacketHandlers()
{
m_Handlers = new PacketHandler[0x100];
m_6017Handlers = new PacketHandler[0x100];
m_ExtendedHandlersLow = new PacketHandler[0x100];
m_ExtendedHandlersHigh = new Dictionary<int, PacketHandler>();
m_EncodedHandlersLow = new EncodedPacketHandler[0x100];
m_EncodedHandlersHigh = new Dictionary<int, EncodedPacketHandler>();
Register(0x00, 104, false, CreateCharacter);
Register(0x01, 5, false, Disconnect);
Register(0x02, 7, true, MovementReq);
Register(0x03, 0, true, AsciiSpeech);
Register(0x04, 2, true, GodModeRequest);
Register(0x05, 5, true, AttackReq);
Register(0x06, 5, true, UseReq);
Register(0x07, 7, true, LiftReq);
Register(0x08, 14, true, DropReq);
Register(0x09, 5, true, LookReq);
Register(0x0A, 11, true, Edit);
Register(0x12, 0, true, TextCommand);
Register(0x13, 10, true, EquipReq);
Register(0x14, 6, true, ChangeZ);
Register(0x22, 3, true, Resynchronize);
Register(0x2C, 2, true, DeathStatusResponse);
Register(0x34, 10, true, MobileQuery);
Register(0x3A, 0, true, ChangeSkillLock);
Register(0x3B, 0, true, VendorBuyReply);
Register(0x47, 11, true, NewTerrain);
Register(0x48, 73, true, NewAnimData);
Register(0x58, 106, true, NewRegion);
Register(0x5D, 73, false, PlayCharacter);
Register(0x61, 9, true, DeleteStatic);
Register(0x6C, 19, true, TargetResponse);
Register(0x6F, 0, true, SecureTrade);
Register(0x72, 5, true, SetWarMode);
Register(0x73, 2, false, PingReq);
Register(0x75, 35, true, RenameRequest);
Register(0x79, 9, true, ResourceQuery);
Register(0x7E, 2, true, GodviewQuery);
Register(0x7D, 13, true, MenuResponse);
Register(0x80, 62, false, AccountLogin);
Register(0x83, 39, false, DeleteCharacter);
Register(0x91, 65, false, GameLogin);
Register(0x95, 9, true, HuePickerResponse);
Register(0x96, 0, true, GameCentralMoniter);
Register(0x98, 0, true, MobileNameRequest);
Register(0x9A, 0, true, AsciiPromptResponse);
Register(0x9B, 258, true, HelpRequest);
Register(0x9D, 51, true, GMSingle);
Register(0x9F, 0, true, VendorSellReply);
Register(0xA0, 3, false, PlayServer);
Register(0xA4, 149, false, SystemInfo);
Register(0xA7, 4, true, RequestScrollWindow);
Register(0xAD, 0, true, UnicodeSpeech);
Register(0xB1, 0, true, DisplayGumpResponse);
Register(0xB6, 9, true, ObjectHelpRequest);
Register(0xB8, 0, true, ProfileReq);
Register(0xBB, 9, false, AccountID);
Register(0xBD, 0, true, ClientVersion);
Register(0xBE, 0, true, AssistVersion);
Register(0xBF, 0, true, ExtendedCommand);
Register(0xC2, 0, true, UnicodePromptResponse);
Register(0xC8, 2, true, SetUpdateRange);
Register(0xC9, 6, true, TripTime);
Register(0xCA, 6, true, UTripTime);
Register(0xCF, 0, false, AccountLogin);
Register(0xD0, 0, true, ConfigurationFile);
Register(0xD1, 2, true, LogoutReq);
Register(0xD6, 0, true, BatchQueryProperties);
Register(0xD7, 0, true, EncodedCommand);
Register(0xE1, 0, false, ClientType);
Register(0xEC, 0, false, EquipMacro);
Register(0xED, 0, false, UnequipMacro);
Register(0xEF, 21, false, LoginServerSeed);
Register(0xF4, 0, false, CrashReport);
Register(0xF8, 106, false, CreateCharacter70160);
//Register(0xFA, 1, true, Unhandled); // Currently Handled in UltimaStore.cs
Register(0xFB, 2, false, PublicHouseContent);
Register6017(0x08, 15, true, DropReq6017);
Register(0x8D, 0, false, ECCreateCharacter);
RegisterExtended(0x05, false, ScreenSize);
RegisterExtended(0x06, true, PartyMessage);
RegisterExtended(0x07, true, QuestArrow);
RegisterExtended(0x09, true, DisarmRequest);
RegisterExtended(0x0A, true, StunRequest);
RegisterExtended(0x0B, false, Language);
RegisterExtended(0x0C, true, CloseStatus);
RegisterExtended(0x0E, true, Animate);
RegisterExtended(0x0F, false, Empty); // What's this?
RegisterExtended(0x10, true, QueryProperties);
RegisterExtended(0x13, true, ContextMenuRequest);
RegisterExtended(0x15, true, ContextMenuResponse);
RegisterExtended(0x1A, true, StatLockChange);
RegisterExtended(0x1C, true, CastSpell);
RegisterExtended(0x24, false, UnhandledBF);
RegisterExtended(0x2C, true, BandageTarget);
#region Stygian Abyss
RegisterExtended(0x32, true, ToggleFlying);
#endregion
RegisterExtended(0x2D, true, TargetedSpell);
RegisterExtended(0x2E, true, TargetedSkillUse);
RegisterExtended(0x30, true, TargetByResourceMacro);
RegisterEncoded(0x19, true, SetAbility);
RegisterEncoded(0x28, true, GuildGumpRequest);
RegisterEncoded(0x32, true, QuestGumpRequest);
}
public static void Register(int packetID, int length, bool ingame, OnPacketReceive onReceive)
{
m_Handlers[packetID] = new PacketHandler(packetID, length, ingame, onReceive);
if (m_6017Handlers[packetID] == null)
{
m_6017Handlers[packetID] = new PacketHandler(packetID, length, ingame, onReceive);
}
}
public static PacketHandler GetHandler(int packetID)
{
return m_Handlers[packetID];
}
public static void Register6017(int packetID, int length, bool ingame, OnPacketReceive onReceive)
{
m_6017Handlers[packetID] = new PacketHandler(packetID, length, ingame, onReceive);
}
public static PacketHandler Get6017Handler(int packetID)
{
return m_6017Handlers[packetID];
}
public static void RegisterExtended(int packetID, bool ingame, OnPacketReceive onReceive)
{
if (packetID >= 0 && packetID < 0x100)
{
m_ExtendedHandlersLow[packetID] = new PacketHandler(packetID, 0, ingame, onReceive);
}
else
{
m_ExtendedHandlersHigh[packetID] = new PacketHandler(packetID, 0, ingame, onReceive);
}
}
public static PacketHandler GetExtendedHandler(int packetID)
{
if (packetID >= 0 && packetID < 0x100)
{
return m_ExtendedHandlersLow[packetID];
}
else
{
PacketHandler handler;
m_ExtendedHandlersHigh.TryGetValue(packetID, out handler);
return handler;
}
}
public static void RemoveExtendedHandler(int packetID)
{
if (packetID >= 0 && packetID < 0x100)
{
m_ExtendedHandlersLow[packetID] = null;
}
else
{
m_ExtendedHandlersHigh.Remove(packetID);
}
}
public static void RegisterEncoded(int packetID, bool ingame, OnEncodedPacketReceive onReceive)
{
if (packetID >= 0 && packetID < 0x100)
{
m_EncodedHandlersLow[packetID] = new EncodedPacketHandler(packetID, ingame, onReceive);
}
else
{
m_EncodedHandlersHigh[packetID] = new EncodedPacketHandler(packetID, ingame, onReceive);
}
}
public static EncodedPacketHandler GetEncodedHandler(int packetID)
{
if (packetID >= 0 && packetID < 0x100)
{
return m_EncodedHandlersLow[packetID];
}
else
{
EncodedPacketHandler handler;
m_EncodedHandlersHigh.TryGetValue(packetID, out handler);
return handler;
}
}
public static void RemoveEncodedHandler(int packetID)
{
if (packetID >= 0 && packetID < 0x100)
{
m_EncodedHandlersLow[packetID] = null;
}
else
{
m_EncodedHandlersHigh.Remove(packetID);
}
}
public static void RegisterThrottler(int packetID, ThrottlePacketCallback t)
{
PacketHandler ph = GetHandler(packetID);
if (ph != null)
{
ph.ThrottleCallback = t;
}
ph = Get6017Handler(packetID);
if (ph != null)
{
ph.ThrottleCallback = t;
}
}
private static void Unhandled(NetState state, PacketReader pvSrc)
{ }
private static void UnhandledBF(NetState state, PacketReader pvSrc)
{ }
public static void Empty(NetState state, PacketReader pvSrc)
{ }
public static void SetAbility(NetState state, IEntity e, EncodedReader reader)
{
EventSink.InvokeSetAbility(new SetAbilityEventArgs(state.Mobile, reader.ReadInt32()));
}
public static void GuildGumpRequest(NetState state, IEntity e, EncodedReader reader)
{
EventSink.InvokeGuildGumpRequest(new GuildGumpRequestArgs(state.Mobile));
}
public static void QuestGumpRequest(NetState state, IEntity e, EncodedReader reader)
{
EventSink.InvokeQuestGumpRequest(new QuestGumpRequestArgs(state.Mobile));
}
public static void EncodedCommand(NetState state, PacketReader pvSrc)
{
IEntity e = World.FindEntity(pvSrc.ReadInt32());
int packetID = pvSrc.ReadUInt16();
EncodedPacketHandler ph = GetEncodedHandler(packetID);
if (ph != null)
{
if (ph.Ingame && state.Mobile == null)
{
Console.WriteLine(
"Client: {0}: Sent ingame packet (0xD7x{1:X2}) before having been attached to a mobile", state, packetID);
state.Dispose();
}
else if (ph.Ingame && state.Mobile.Deleted)
{
state.Dispose();
}
else
{
ph.OnReceive(state, e, new EncodedReader(pvSrc));
}
}
else
{
pvSrc.Trace(state);
}
}
public static void RenameRequest(NetState state, PacketReader pvSrc)
{
Mobile from = state.Mobile;
Mobile targ = World.FindMobile(pvSrc.ReadInt32());
if (targ != null)
{
EventSink.InvokeRenameRequest(new RenameRequestEventArgs(from, targ, pvSrc.ReadStringSafe()));
}
}
public static void SecureTrade(NetState state, PacketReader pvSrc)
{
switch (pvSrc.ReadByte())
{
case 1: // Cancel
{
Serial serial = pvSrc.ReadInt32();
SecureTradeContainer cont = World.FindItem(serial) as SecureTradeContainer;
if (cont != null)
{
SecureTrade trade = cont.Trade;
if (trade != null)
{
if (trade.From.Mobile == state.Mobile || trade.To.Mobile == state.Mobile)
{
trade.Cancel();
}
}
}
}
break;
case 2: // Check
{
Serial serial = pvSrc.ReadInt32();
SecureTradeContainer cont = World.FindItem(serial) as SecureTradeContainer;
if (cont != null)
{
SecureTrade trade = cont.Trade;
bool value = pvSrc.ReadInt32() != 0;
if (trade != null)
{
if (trade.From.Mobile == state.Mobile)
{
trade.From.Accepted = value;
trade.Update();
}
else if (trade.To.Mobile == state.Mobile)
{
trade.To.Accepted = value;
trade.Update();
}
}
}
}
break;
case 3: // Update Gold
{
Serial serial = pvSrc.ReadInt32();
SecureTradeContainer cont = World.FindItem(serial) as SecureTradeContainer;
if (cont != null)
{
int gold = pvSrc.ReadInt32();
int plat = pvSrc.ReadInt32();
SecureTrade trade = cont.Trade;
if (trade != null)
{
if (trade.From.Mobile == state.Mobile)
{
trade.From.Gold = gold;
trade.From.Plat = plat;
trade.UpdateFromCurrency();
}
else if (trade.To.Mobile == state.Mobile)
{
trade.To.Gold = gold;
trade.To.Plat = plat;
trade.UpdateToCurrency();
}
}
}
}
break;
}
}
public static void VendorBuyReply(NetState state, PacketReader pvSrc)
{
pvSrc.Seek(1, SeekOrigin.Begin);
int msgSize = pvSrc.ReadUInt16();
Mobile vendor = World.FindMobile(pvSrc.ReadInt32());
byte flag = pvSrc.ReadByte();
if (vendor == null)
{
return;
}
else if (vendor.Deleted || !Utility.RangeCheck(vendor.Location, state.Mobile.Location, 10))
{
state.Send(new EndVendorBuy(vendor));
return;
}
if (flag == 0x02)
{
msgSize -= 1 + 2 + 4 + 1;
if ((msgSize / 7) > 100)
{
return;
}
var buyList = new List<BuyItemResponse>(msgSize / 7);
for (; msgSize > 0; msgSize -= 7)
{
byte layer = pvSrc.ReadByte();
Serial serial = pvSrc.ReadInt32();
int amount = pvSrc.ReadInt16();
buyList.Add(new BuyItemResponse(serial, amount));
}
if (buyList.Count > 0)
{
IVendor v = vendor as IVendor;
if (v != null && v.OnBuyItems(state.Mobile, buyList))
{
state.Send(new EndVendorBuy(vendor));
}
}
}
else
{
state.Send(new EndVendorBuy(vendor));
}
}
public static void VendorSellReply(NetState state, PacketReader pvSrc)
{
Serial serial = pvSrc.ReadInt32();
Mobile vendor = World.FindMobile(serial);
if (vendor == null)
{
return;
}
else if (vendor.Deleted || !Utility.RangeCheck(vendor.Location, state.Mobile.Location, 10))
{
state.Send(new EndVendorSell(vendor));
return;
}
int count = pvSrc.ReadUInt16();
if (count < 100 && pvSrc.Size == (1 + 2 + 4 + 2 + (count * 6)))
{
var sellList = new List<SellItemResponse>(count);
for (int i = 0; i < count; i++)
{
Item item = World.FindItem(pvSrc.ReadInt32());
int Amount = pvSrc.ReadInt16();
if (item != null && Amount > 0)
{
sellList.Add(new SellItemResponse(item, Amount));
}
}
if (sellList.Count > 0)
{
IVendor v = vendor as IVendor;
if (v != null && v.OnSellItems(state.Mobile, sellList))
{
state.Send(new EndVendorSell(vendor));
}
}
}
}
public static void DeleteCharacter(NetState state, PacketReader pvSrc)
{
pvSrc.Seek(30, SeekOrigin.Current);
int index = pvSrc.ReadInt32();
EventSink.InvokeDeleteRequest(new DeleteRequestEventArgs(state, index));
}
public static void ResourceQuery(NetState state, PacketReader pvSrc)
{
if (VerifyGC(state))
{ }
}
public static void GameCentralMoniter(NetState state, PacketReader pvSrc)
{
if (VerifyGC(state))
{
int type = pvSrc.ReadByte();
int num1 = pvSrc.ReadInt32();
Console.WriteLine("God Client: {0}: Game central moniter", state);
Console.WriteLine(" - Type: {0}", type);
Console.WriteLine(" - Number: {0}", num1);
pvSrc.Trace(state);
}
}
public static void GodviewQuery(NetState state, PacketReader pvSrc)
{
if (VerifyGC(state))
{
Console.WriteLine("God Client: {0}: Godview query 0x{1:X}", state, pvSrc.ReadByte());
}
}
public static void GMSingle(NetState state, PacketReader pvSrc)
{
if (VerifyGC(state))
{
pvSrc.Trace(state);
}
}
public static void DeathStatusResponse(NetState state, PacketReader pvSrc)
{
// Ignored
}
public static void ObjectHelpRequest(NetState state, PacketReader pvSrc)
{
Mobile from = state.Mobile;
Serial serial = pvSrc.ReadInt32();
int unk = pvSrc.ReadByte();
string lang = pvSrc.ReadString(3);
if (serial.IsItem)
{
Item item = World.FindItem(serial);
if (item != null && from.Map == item.Map && Utility.InUpdateRange(from, item) && from.CanSee(item))
{
item.OnHelpRequest(from);
}
}
else if (serial.IsMobile)
{
Mobile m = World.FindMobile(serial);
if (m != null && from.Map == m.Map && Utility.InUpdateRange(from, m) && from.CanSee(m))
{
m.OnHelpRequest(m);
}
}
}
public static void MobileNameRequest(NetState state, PacketReader pvSrc)
{
Mobile m = World.FindMobile(pvSrc.ReadInt32());
if (m != null && Utility.InUpdateRange(state.Mobile, m) && state.Mobile.CanSee(m))
{
state.Send(new MobileName(m));
}
}
public static void RequestScrollWindow(NetState state, PacketReader pvSrc)
{
int lastTip = pvSrc.ReadInt16();
int type = pvSrc.ReadByte();
}
public static void AttackReq(NetState state, PacketReader pvSrc)
{
Mobile from = state.Mobile;
Mobile m = World.FindMobile(pvSrc.ReadInt32());
if (m != null)
{
from.Attack(m);
}
}
public static void HuePickerResponse(NetState state, PacketReader pvSrc)
{
int serial = pvSrc.ReadInt32();
int value = pvSrc.ReadInt16();
int hue = pvSrc.ReadInt16() & 0x3FFF;
hue = Utility.ClipDyedHue(hue);
foreach (HuePicker huePicker in state.HuePickers)
{
if (huePicker.Serial == serial)
{
state.RemoveHuePicker(huePicker);
huePicker.OnResponse(hue);
break;
}
}
}
public static void TripTime(NetState state, PacketReader pvSrc)
{
int unk1 = pvSrc.ReadByte();
int unk2 = pvSrc.ReadInt32();
state.Send(new TripTimeResponse(unk1));
}
public static void UTripTime(NetState state, PacketReader pvSrc)
{
int unk1 = pvSrc.ReadByte();
int unk2 = pvSrc.ReadInt32();
state.Send(new UTripTimeResponse(unk1));
}
public static void ChangeZ(NetState state, PacketReader pvSrc)
{
if (VerifyGC(state))
{
int x = pvSrc.ReadInt16();
int y = pvSrc.ReadInt16();
int z = pvSrc.ReadSByte();
Console.WriteLine("God Client: {0}: Change Z ({1}, {2}, {3})", state, x, y, z);
}
}
public static void SystemInfo(NetState state, PacketReader pvSrc)
{
int v1 = pvSrc.ReadByte();
int v2 = pvSrc.ReadUInt16();
int v3 = pvSrc.ReadByte();
string s1 = pvSrc.ReadString(32);
string s2 = pvSrc.ReadString(32);
string s3 = pvSrc.ReadString(32);
string s4 = pvSrc.ReadString(32);
int v4 = pvSrc.ReadUInt16();
int v5 = pvSrc.ReadUInt16();
int v6 = pvSrc.ReadInt32();
int v7 = pvSrc.ReadInt32();
int v8 = pvSrc.ReadInt32();
}
public static void Edit(NetState state, PacketReader pvSrc)
{
if (VerifyGC(state))
{
int type = pvSrc.ReadByte(); // 10 = static, 7 = npc, 4 = dynamic
int x = pvSrc.ReadInt16();
int y = pvSrc.ReadInt16();
int id = pvSrc.ReadInt16();
int z = pvSrc.ReadSByte();
int hue = pvSrc.ReadUInt16();
Console.WriteLine("God Client: {0}: Edit {6} ({1}, {2}, {3}) 0x{4:X} (0x{5:X})", state, x, y, z, id, hue, type);
}
}
public static void DeleteStatic(NetState state, PacketReader pvSrc)
{
if (VerifyGC(state))
{
int x = pvSrc.ReadInt16();
int y = pvSrc.ReadInt16();
int z = pvSrc.ReadInt16();
int id = pvSrc.ReadUInt16();
Console.WriteLine("God Client: {0}: Delete Static ({1}, {2}, {3}) 0x{4:X}", state, x, y, z, id);
}
}
public static void NewAnimData(NetState state, PacketReader pvSrc)
{
if (VerifyGC(state))
{
Console.WriteLine("God Client: {0}: New tile animation", state);
pvSrc.Trace(state);
}
}
public static void NewTerrain(NetState state, PacketReader pvSrc)
{
if (VerifyGC(state))
{
int x = pvSrc.ReadInt16();
int y = pvSrc.ReadInt16();
int id = pvSrc.ReadUInt16();
int width = pvSrc.ReadInt16();
int height = pvSrc.ReadInt16();
Console.WriteLine("God Client: {0}: New Terrain ({1}, {2})+({3}, {4}) 0x{5:X4}", state, x, y, width, height, id);
}
}
public static void NewRegion(NetState state, PacketReader pvSrc)
{
if (VerifyGC(state))
{
string name = pvSrc.ReadString(40);
int unk = pvSrc.ReadInt32();
int x = pvSrc.ReadInt16();
int y = pvSrc.ReadInt16();
int width = pvSrc.ReadInt16();
int height = pvSrc.ReadInt16();
int zStart = pvSrc.ReadInt16();
int zEnd = pvSrc.ReadInt16();
string desc = pvSrc.ReadString(40);
int soundFX = pvSrc.ReadInt16();
int music = pvSrc.ReadInt16();
int nightFX = pvSrc.ReadInt16();
int dungeon = pvSrc.ReadByte();
int light = pvSrc.ReadInt16();
Console.WriteLine("God Client: {0}: New Region '{1}' ('{2}')", state, name, desc);
}
}
public static void AccountID(NetState state, PacketReader pvSrc)
{ }
public static bool VerifyGC(NetState state)
{
if (state.Mobile == null || state.Mobile.IsPlayer())
{
if (state.Running)
{
Console.WriteLine("Warning: {0}: Player using godclient, disconnecting", state);
}
state.Dispose();
return false;
}
else
{
return true;
}
}
public static void TextCommand(NetState state, PacketReader pvSrc)
{
int type = pvSrc.ReadByte();
string command = pvSrc.ReadString();
Mobile m = state.Mobile;
switch (type)
{
case 0x00: // Go
{
if (VerifyGC(state))
{
try
{
var split = command.Split(' ');
int x = Utility.ToInt32(split[0]);
int y = Utility.ToInt32(split[1]);
int z;
if (split.Length >= 3)
{
z = Utility.ToInt32(split[2]);
}
else if (m.Map != null)
{
z = m.Map.GetAverageZ(x, y);
}
else
{
z = 0;
}
m.Location = new Point3D(x, y, z);
}
catch
{ }
}
break;
}
case 0xC7: // Animate
{
EventSink.InvokeAnimateRequest(new AnimateRequestEventArgs(m, command));
break;
}
case 0x24: // Use skill
{
int skillIndex;
if (!int.TryParse(command.Split(' ')[0], out skillIndex))
{
break;
}
Skills.UseSkill(m, skillIndex);
break;
}
case 0x43: // Open spellbook
{
int booktype;
if (!int.TryParse(command, out booktype))
{
booktype = 1;
}
EventSink.InvokeOpenSpellbookRequest(new OpenSpellbookRequestEventArgs(m, booktype));
break;
}
case 0x27: // Cast spell from book
{
var split = command.Split(' ');
if (split.Length > 0)
{
int spellID = Utility.ToInt32(split[0]) - 1;
int serial = split.Length > 1 ? Utility.ToInt32(split[1]) : -1;
EventSink.InvokeCastSpellRequest(new CastSpellRequestEventArgs(m, spellID, World.FindItem(serial)));
}
break;
}
case 0x58: // Open door
{
EventSink.InvokeOpenDoorMacroUsed(new OpenDoorMacroEventArgs(m));
break;
}
case 0x56: // Cast spell from macro
{
int spellID = Utility.ToInt32(command) - 1;
EventSink.InvokeCastSpellRequest(new CastSpellRequestEventArgs(m, spellID, null));
break;
}
case 0xF4: // Invoke virtues from macro
{
int virtueID = Utility.ToInt32(command) - 1;
EventSink.InvokeVirtueMacroRequest(new VirtueMacroRequestEventArgs(m, virtueID));
break;
}
case 0x2F: // Old scroll double click
{
/*
* This command is still sent for items 0xEF3 - 0xEF9
*
* Command is one of three, depending on the item ID of the scroll:
* - [scroll serial]
* - [scroll serial] [target serial]
* - [scroll serial] [x] [y] [z]
*/
break;
}
default:
{
Console.WriteLine("Client: {0}: Unknown text-command type 0x{1:X2}: {2}", state, type, command);
break;
}
}
}
public static void GodModeRequest(NetState state, PacketReader pvSrc)
{
if (VerifyGC(state))
{
state.Send(new GodModeReply(pvSrc.ReadBoolean()));
}
}
public static void AsciiPromptResponse(NetState state, PacketReader pvSrc)
{
int serial = pvSrc.ReadInt32();
int prompt = pvSrc.ReadInt32();
int type = pvSrc.ReadInt32();
string text = pvSrc.ReadStringSafe();
if (text == null || text.Length > 128)
{
return;
}
Mobile from = state.Mobile;
Prompt p = from.Prompt;
if (from != null && p != null && p.Sender.Serial == serial && p.TypeId == prompt)
{
from.Prompt = null;
if (type == 0)
{
p.OnCancel(from);
}
else
{
p.OnResponse(from, text);
}
}
}
public static void UnicodePromptResponse(NetState state, PacketReader pvSrc)
{
int serial = pvSrc.ReadInt32();
int prompt = pvSrc.ReadInt32();
int type = pvSrc.ReadInt32();
string lang = pvSrc.ReadString(4);
string text = pvSrc.ReadUnicodeStringLESafe();
if (text.Length > 128)
{
return;
}
Mobile from = state.Mobile;
Prompt p = from.Prompt;
int promptSerial = (p != null && p.Sender != null) ? p.Sender.Serial.Value : from.Serial.Value;
if (p != null && promptSerial == serial && p.TypeId == prompt)
{
from.Prompt = null;
if (type == 0)
{
p.OnCancel(from);
}
else
{
p.OnResponse(from, text);
}
}
}