-
Notifications
You must be signed in to change notification settings - Fork 4
/
modProcess.bas
3632 lines (3436 loc) · 181 KB
/
modProcess.bas
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
Attribute VB_Name = "modProcess"
Option Explicit
Sub ReadClientData(Index As Long)
On Error GoTo LogDatShit
Dim St As String, SocketData As String, PacketLength As Long, PacketOrder As Integer, PacketID As Long, PacketCheckSum As Long, CurrentCheckSum As Long
Dim MapNum As Long
Dim Tick As Currency
Tick = getTime
With Player(Index)
MapNum = .Map
SocketData = .SocketData + Receive(.Socket)
.LastMsg = Tick
If .Access = 0 Then
If .LastMsg > .FloodTimer Then
.FloodTimer = .LastMsg
End If
If .FloodTimer - .LastMsg > 5000 And .Flag(41) = 0 And .Mode = modePlaying Then
.FloodTimer = 0
SendAll Chr$(56) + Chr$(15) + .Name + " has been autosquelched!"
.Flag(41) = 5
Exit Sub
End If
End If
LoopRead:
If Len(SocketData) >= 5 Then
PacketLength = GetInt(Mid$(SocketData, 1, 2))
PacketCheckSum = Asc(Mid$(SocketData, 3, 1))
PacketOrder = Asc(Mid$(SocketData, 4, 1))
If PacketLength >= 5072 And .Access = 0 Then
Hacker Index, "C.1.2"
Exit Sub
End If
If Len(SocketData) - 4 >= PacketLength Then
St = Mid$(SocketData, 5, PacketLength)
SocketData = Mid$(SocketData, PacketLength + 5)
If PacketLength > 0 Then
PacketID = Asc(Mid$(St, 1, 1))
CurrentCheckSum = CheckSum(St) * 20 Mod 194
If Not CurrentCheckSum = PacketCheckSum Then
PrintDebug "Bad Checksum from " & .Name + " " + .IP
AddSocketQue Index
Exit Sub
End If
If Not PacketOrder = .PacketOrder Then
AddSocketQue Index
Exit Sub
Else
.PacketOrder = .PacketOrder + 1
If .PacketOrder > 250 Then .PacketOrder = 0
End If
If Len(St) > 1 Then
St = Mid$(St, 2)
Else
St = ""
End If
Select Case PacketID
Case 170: 'Raw Data
ProcessRawData Index, St
Case Else:
ProcessString Index, PacketID, St
End Select
End If
GoTo LoopRead
End If
End If
.SocketData = SocketData
End With
Exit Sub
LogDatShit:
SendToGods Chr$(16) & Chr$(0) & "WARNING: Server Crashed on Packet # " + CStr(PacketID) & " from " & Player(Index).Name & " DATA: " & St & " " & Err.Description
PrintLog "WARNING: Server Crashed on Packet # " + CStr(PacketID) & " from " & Player(Index).Name & " DATA: " & St & " " & Err.Description
PrintDebug "WARNING: Server Crashed on Packet # " + CStr(PacketID) & " from " & Player(Index).Name & " DATA: " & St & " " & Err.Description
BootPlayer Index, 0, "Crashed Server"
End Sub
Sub ProcessGodCommand(Index As Long, St As String)
Dim A As Long, B As Long, C As Long, D As Long, St1 As String
With Player(Index)
Select Case Asc(Mid$(St, 1, 1))
Case 0 'Server Message
If Len(St) >= 2 Then
SendAll Chr$(30) + "[" + .Name + "] " + Mid$(St, 2)
Else
Hacker Index, "A.28"
End If
Case 1 'Warp
If Len(St) = 5 Then
A = Asc(Mid$(St, 2, 1)) * 256 + Asc(Mid$(St, 3, 1))
B = Asc(Mid$(St, 4, 1))
C = Asc(Mid$(St, 5, 1))
If A >= 1 And A <= MaxMaps And B <= 11 And C <= 11 Then
PrintGod Player(Index).User, " (Warp) Map: " + CStr(A) + " X: " + CStr(B) + " Y: " + CStr(C) + " Map Name: " + Map(A).Name
Partmap Index
.Map = A
.X = B
.Y = C
JoinMap Index
End If
Else
Hacker Index, "A.29"
End If
Case 2 'WarpMe
If Len(St) = 2 Then
A = Asc(Mid$(St, 2, 1))
If A >= 1 And A <= MaxUsers And A <> Index Then
If Player(A).Mode = modePlaying Then
PrintGod Player(Index).User, " (WarpMe) Warped to Player: " + Player(A).Name + " Map: " + CStr(Player(A).Map) + " Map Name: " + Map(Player(A).Map).Name
Partmap Index
.Map = Player(A).Map
.X = Player(A).X
.Y = Player(A).Y
JoinMap Index
End If
End If
Else
Hacker Index, "A.30"
End If
Case 3 'WarpPlayer
If Len(St) = 6 Then
A = Asc(Mid$(St, 2, 1))
B = Asc(Mid$(St, 3, 1)) * 256 + Asc(Mid$(St, 4, 1))
C = Asc(Mid$(St, 5, 1))
D = Asc(Mid$(St, 6, 1))
If A >= 1 And A <= MaxUsers And B >= 1 And B <= MaxMaps And C <= 11 And D <= 11 Then
With Player(A)
If .Mode = modePlaying Then
PrintGod Player(Index).User, " (WarpToMe) Warped Player: " + Player(A).Name + " Map: " + CStr(Player(Index).Map) + " Map Name: " + Map(Player(Index).Map).Name
Partmap A
.Map = B
.X = C
.Y = D
JoinMap A
End If
End With
End If
Else
Hacker Index, "A.31"
End If
Case 4 'Set MOTD
If Len(St) > 1 And .Access >= 3 Then
World.MOTD = Mid$(St, 2)
PrintGod Player(Index).User, " (MOTD) " + World.MOTD
DataRS.Edit
DataRS!MOTD = World.MOTD
DataRS.Update
Else
Hacker Index, "A.32"
End If
Case 5 'Disband Guild
If Len(St) = 2 And .Access >= 2 Then
A = Asc(Mid$(St, 2, 1))
PrintGod Player(Index).User, " (Delete Guild) " + Guild(A).Name
DeleteGuild A, 3
Else
Hacker Index, "A.33"
End If
Case 6 'Set sprite
If Len(St) = 4 Then
A = Asc(Mid$(St, 2, 1))
B = Asc(Mid$(St, 3, 1)) * 256 + Asc(Mid$(St, 4, 1))
If A >= 1 And A <= MaxUsers And B <= MaxSprite Then
With Player(A)
If .Mode = modePlaying Then
PrintGod Player(Index).User, " (SetSprite) " + Player(A).Name
If B = 0 Then
.Sprite = .Class * 2 + .Gender - 1
Else
.Sprite = B
End If
SendToMap .Map, Chr$(63) + Chr$(A) + DoubleChar$(CLng(.Sprite))
End If
End With
End If
Else
Hacker Index, "A.34"
End If
Case 7 'Set name
If Len(St) >= 3 And Len(St) <= 17 And .Access >= 2 Then
A = Asc(Mid$(St, 2, 1))
If A >= 1 And A <= MaxUsers Then
With Player(A)
If .Mode = modePlaying Then
UserRS.Index = "Name"
UserRS.Seek "=", Mid$(St, 3)
If UserRS.NoMatch = True Then
PrintGod Player(Index).User, " (SetName) " + Player(A).Name + " (to) " + Mid$(St, 3)
.Name = Mid$(St, 3)
SendAll Chr$(64) + Chr$(A) + .Name
Else
SendSocket Index, Chr$(16) + Chr$(16)
End If
End If
End With
End If
Else
Hacker Index, "A.35"
End If
Case 8 'Resetmap
If Len(St) = 1 And .Access >= 2 Then
Dim PlayerString As String
For A = 1 To MaxUsers
If Player(A).Map = .Map Then PlayerString = PlayerString + Player(A).Name + ", "
Next A
PrintGod Player(Index).User, " (ResetMap) Map: " + CStr(Player(Index).Map) + " - " + PlayerString
ResetMap CLng(.Map)
Else
Hacker Index, "A.84"
End If
Case 9 'Boot
If Len(St) >= 2 Then
A = Asc(Mid$(St, 2, 1))
If A >= 1 And A <= MaxUsers Then
If Not Player(A).Access = 4 Then
PrintGod Player(Index).User, " (Boot) Booted " + Player(A).Name + " for reason " + Mid$(St, 3)
BootPlayer A, Index, Mid$(St, 3)
End If
End If
Else
Hacker Index, "A.36"
End If
Case 10 'Ban
If Len(St) >= 3 Then
A = Asc(Mid$(St, 2, 1))
If A >= 1 And A <= MaxUsers Then
If Not Player(A).Access = 4 Then
If BanPlayer(A, Index, Asc(Mid$(St, 3, 1)), Mid$(St, 4), Player(Index).Name) = False Then
PrintGod Player(Index).User, " (Ban) Banned " + Player(A).Name + " for reason " + Mid$(St, 4)
SendSocket Index, Chr$(16) + Chr$(13) 'Ban list full
End If
End If
End If
Else
Hacker Index, "A.37"
End If
Case 11 'Remove Ban
If Len(St) = 2 Then
A = Asc(Mid$(St, 2, 1))
If A >= 1 And A <= 50 Then
If Not Ban(A).Banner = "SuperAdmin" Or .Access = 4 Then
PrintGod Player(Index).User, " (Remove Ban) Player: " + Ban(A).Name
SendAll Chr$(56) + Chr$(15) + Ban(A).Name + " has been unbanned by " + .Name + "."
With Ban(A)
.ComputerID = ""
.IPAddress = ""
.Name = ""
.Reason = ""
.UnbanDate = 0
.Banner = ""
.InUse = False
End With
BanRS.Seek "=", A
If BanRS.NoMatch = False Then
BanRS.Delete
End If
End If
End If
Else
Hacker Index, "A.38"
End If
Case 12 'List Bans
If Len(St) = 1 And .Access >= 1 Then
St1 = ""
For A = 1 To 50
With Ban(A)
If .InUse = True Then
St1 = St1 + DoubleChar(2 + Len(.Name)) + Chr$(69) + Chr$(A) + .Name
End If
End With
Next A
St1 = St1 + DoubleChar(1) + Chr$(69)
SendRaw Index, St1
Else
Hacker Index, "A.39"
End If
Case 14 'Chat
If Len(St) >= 2 Then
SendToGodsAllBut Index, Chr$(90) + Chr$(Index) + Mid$(St, 2)
PrintChat "God", Player(Index).User + ": " + Mid$(St, 2)
Else
Hacker Index, "Attempted God Chat Attempt"
End If
Case 15 'Set Guild Sprite
If Len(St) = 3 And .Access >= 2 Then
A = Asc(Mid$(St, 2, 1))
B = Asc(Mid$(St, 3, 1)) * 256 + Asc(Mid$(St, 4, 1))
If A >= 1 Then
UserRS.Index = "Name"
With Guild(A)
If .Name <> "" Then
.Sprite = B
GuildRS.Bookmark = .Bookmark
GuildRS.Edit
GuildRS!Sprite = B
GuildRS.Update
For C = 0 To 19
With .Member(C)
If .Name <> "" Then
D = FindPlayer(.Name)
If D > 0 Then
With Player(D)
If B > 0 Then
.Sprite = B
Else
.Sprite = .Class * 2 + .Gender - 1
End If
SendToMap .Map, Chr$(63) + Chr$(D) + DoubleChar$(CLng(.Sprite))
End With
Else
UserRS.Seek "=", .Name
If UserRS.NoMatch = False Then
If B > 0 Then
D = B
Else
D = UserRS!Class * 2 + UserRS!Gender - 1
End If
If D >= 1 And D <= MaxSprite Then
UserRS.Edit
UserRS!Sprite = D
UserRS.Update
End If
End If
End If
End If
End With
Next C
End If
End With
End If
Else
Hacker Index, "A.41"
End If
Case 16 'Float
If Len(St) > 4 Then
A = Asc(Mid$(St, 2, 1))
B = Asc(Mid$(St, 3, 1))
C = Asc(Mid$(St, 4, 1))
SendToMap .Map, Chr$(112) + Chr$(A) + Chr$(B) + Chr$(C) + Mid$(St, 5)
End If
Case 17 'Set Status
If Len(St) = 3 Then
A = Asc(Mid$(St, 2, 1))
B = Asc(Mid$(St, 3, 1))
If A >= 1 And A <= MaxUsers And B <= 255 Then
With Player(A)
If .Mode = modePlaying Then
PrintGod Player(Index).User, " (Set Status) Player: " + .Name + " - Status: " + CStr(B)
If B = 0 Then
.Status = 0
Else
.Status = B
End If
SendToMap .Map, Chr$(91) + Chr$(A) + Chr$(.Status)
End If
End With
End If
End If
Case 18 'Scan
If Len(St) >= 1 And .Access >= 2 Then
A = Asc(Mid$(St, 2, 1))
If A >= 1 And A <= MaxUsers Then
PrintGod Player(Index).User, " (Scan) Player: " + Player(A).Name
St1 = ""
With Player(A)
St1 = Chr$(104) & Chr$(A) & Chr$(.Class) & Chr$(.Level) + Chr$(0) + Chr$(0) + Chr$(0) + Chr$(0) + Chr$(.MaxHP) & Chr$(.MaxMana) & Chr$(.MaxEnergy)
For B = 1 To 20
St1 = St1 & DoubleChar$(CLng(.Inv(B).Object)) & QuadChar(.Inv(B).Value)
Next B
For B = 1 To 5
St1 = St1 & DoubleChar$(CLng(.EquippedObject(B).Object)) & QuadChar(.EquippedObject(B).Value)
Next B
For B = 0 To 29
St1 = St1 & DoubleChar$(CLng(.ItemBank(B).Object)) & QuadChar(.ItemBank(B).Value)
Next B
SendSocket Index, St1
SendSocket Index, Chr$(16) & Chr$(0) & .User & " - " & .IP & " - Bank: " & CStr(.Bank)
SendSocket A, Chr$(154) + Chr$(Index)
End With
End If
End If
Case 25 'Set Class
If Len(St) = 3 Then
A = Asc(Mid$(St, 2, 1))
B = Asc(Mid$(St, 3, 1))
If A >= 1 And A <= MaxUsers And B <= 255 Then
With Player(A)
If .Mode = modePlaying Then
If B > 0 & B <= NumClasses Then
.Class = B
SetPlayerClass A, B
SetPlayerHP A, .MaxHP
SetPlayerEnergy A, .MaxEnergy
SetPlayerMana A, .MaxMana
SetPlayerSprite A, 0
CalculateStats A
End If
End If
End With
End If
Else
Hacker Index, "A.34"
End If
End Select
End With
End Sub
Sub ProcessScriptProjectile(Index As Long, St As String)
Dim Damage As Long
Dim Target As Long
Target = Asc(Mid$(St, 2, 1))
Damage = Asc(Mid$(St, 3, 1))
If Damage > 20 Then
Hacker Index, "P.1"
End If
If Player(Index).ProjectileDamage(Damage).Live = True Then
Player(Index).ProjectileDamage(Damage).Live = False
Damage = Player(Index).ProjectileDamage(Damage).Damage
Else
Damage = 0
End If
Select Case Asc(Mid$(St, 1, 1))
Case 1 'Magic Monster Attack
MagicAttackMonster Index, Target, Damage
Case 2 'Non Magic Monster Attack
AttackMonster Index, Target, Damage
Case 3 'Magic Player Attack
MagicAttackPlayer Index, Target, Damage
Case 4 'Non Magic Player Attack
AttackPlayer Index, Target, Damage
End Select
End Sub
Sub ProcessString(Index As Long, PacketID As Long, St As String)
On Error GoTo LogDatShit
Dim A As Long, B As Long, C As Long, D As Long, E As Long, F As Long, G As Long, H As Long, I As Long
Dim St1 As String, St2 As String
Dim MapNum As Long
Dim Tick As Currency
Dim GetObjResult As Long
Dim DropObjResult As Long
Tick = getTime()
With Player(Index)
MapNum = .Map
Select Case .Mode
Case modeNotConnected
Select Case PacketID
Case 0 'New Account
If .ClientVer = CurrentClientVer Then
A = InStr(1, St, Chr$(0))
If A > 1 And A < Len(St) Then
St1 = Trim$(Mid$(St, 1, A - 1))
B = Len(St1)
If B >= 3 And B <= 15 And ValidName(St1) Then
UserRS.Index = "User"
UserRS.Seek "=", St1
E = 0
St1 = UCase$(St1)
For F = 1 To MaxUsers
If F <> Index Then
If St1 = UCase$(Player(F).User) Then
E = 1
Exit For
End If
End If
Next F
If UserRS.NoMatch = True And GuildNum(St1) = 0 And E = 0 Then
UserRS.AddNew
UserRS!User = St1
.User = St1
St1 = Trim$(UCase$(Mid$(St, A + 1)))
If Len(St1) > 15 Then
UserRS!Password = Left$(St1, 15)
Else
UserRS!Password = St1
End If
UserRS.Update
UserRS.Seek "=", .User
.Bookmark = UserRS.Bookmark
.Access = 0
.Class = 0
SavePlayerData Index
SendSocket Index, Chr$(2) 'New account created!
AddSocketQue Index
Else
SendSocket Index, Chr$(1) + Chr$(1) 'User Already Exists
AddSocketQue Index
End If
Else
Hacker Index, "A.79"
End If
Else
AddSocketQue Index
End If
Else
SendSocket Index, Chr$(116)
AddSocketQue Index
End If
Case 1 'Log on
If .ClientVer = CurrentClientVer Then
A = InStr(1, St, Chr$(0))
If A > 1 And A < Len(St) Then
.User = Mid$(St, 1, A - 1)
UserRS.Index = "User"
UserRS.Seek "=", .User
If UserRS.NoMatch = False Then
If UCase$(Mid$(St, A + 1)) = UCase$(UserRS!Password) Then
B = 0
St1 = UCase$(.User)
For A = 1 To MaxUsers
If A <> Index Then
If St1 = UCase$(Player(A).User) Then
AddSocketQue A
B = 1
Exit For
End If
'If .ComputerID = Player(A).ComputerID Then
' AddSocketQue A
' B = 2
' Exit For
'End If
End If
Next A
If B = 0 Then
'Account Data
.Access = UserRS!Access
.Bookmark = UserRS.Bookmark
'Character Data
.Name = UserRS!Name
CheckBan Index, .Name, .ComputerID, .IP
PrintLog "Login accepted from " + .Name
.Class = UserRS!Class
.Gender = UserRS!Gender
.Sprite = UserRS!Sprite
.Map = UserRS!Map
If Not IsNull(UserRS!Email) Then
.Email = UserRS!Email
Else
.Email = ""
End If
If .Map < 1 Then .Map = 1
If .Map > MaxMaps Then .Map = MaxMaps
.X = UserRS!X
If .X > 11 Then .X = 11
.Y = UserRS!Y
If .Y > 11 Then .Y = 11
.D = UserRS!D
.desc = UserRS!desc
.IsDead = False
.CastTimer = 0
.SpeedTick = 0
.LastSkillUse = 0
'Character Physical Stats
.Level = UserRS!Level
If .Level > World.MaxLevel Then .Level = World.MaxLevel
.Experience = UserRS!Experience
'Inventory Data
For A = 1 To 20
.Inv(A).Object = UserRS.Fields("InvObject" + CStr(A))
.Inv(A).Value = UserRS.Fields("InvValue" + CStr(A))
.Inv(A).ItemPrefix = UserRS.Fields("InvPrefix" + CStr(A))
.Inv(A).ItemSuffix = UserRS.Fields("InvSuffix" + CStr(A))
If .Inv(A).ItemPrefix > 0 Then
If ItemPrefix(.Inv(A).ItemPrefix).Name = "" Then
.Inv(A).ItemPrefix = 0
End If
End If
If .Inv(A).ItemSuffix > 0 Then
If ItemSuffix(.Inv(A).ItemSuffix).Name = "" Then
.Inv(A).ItemSuffix = 0
End If
End If
Next A
For A = 1 To 6
.EquippedObject(A).Object = UserRS.Fields("EquippedObject" + CStr(A))
.EquippedObject(A).Value = UserRS.Fields("EquippedVal" + CStr(A))
.EquippedObject(A).ItemPrefix = UserRS.Fields("EquippedPrefix" + CStr(A))
.EquippedObject(A).ItemSuffix = UserRS.Fields("EquippedSuffix" + CStr(A))
Next A
If .Class > 0 Then CalculateStats Index
'Item Bank
For B = 0 To 29
.ItemBank(B).Object = UserRS.Fields("BankObject" + CStr(B))
.ItemBank(B).Value = UserRS.Fields("BankValue" + CStr(B))
.ItemBank(B).ItemPrefix = UserRS.Fields("BankPrefix" + CStr(B))
.ItemBank(B).ItemSuffix = UserRS.Fields("BankSuffix" + CStr(B))
Next B
.SpeedStrikes = 0
'Character Vital Stats
.HP = .MaxHP
.Energy = .MaxEnergy
.Mana = .MaxMana
'Flags
For B = 0 To MaxPlayerFlags
.Flag(B) = 0
Next B
Dim Position As Long
St1 = ""
If Not IsNull(UserRS!flags) Then
St1 = UserRS!flags
For B = 0 To MaxPlayerFlags
If Position < Len(St1) Then
A = Asc(Mid$(St1, Position + 1, 1)) * 256& + Asc(Mid$(St1, Position + 2, 1))
.Flag(A) = Asc(Mid$(St1, Position + 3, 1)) * 16777216 + Asc(Mid$(St1, Position + 4, 1)) * 65536 + Asc(Mid$(St1, Position + 5, 1)) * 256& + Asc(Mid$(St1, Position + 6, 1))
Position = Position + 6
End If
Next B
End If
'Load Skills
St1 = ""
If Not IsNull(UserRS!Skills) Then
St1 = UserRS!Skills
For A = 0 To 9
With .Skill(A + 1)
If Len(St1) >= A * 5 + 5 Then
.Level = Asc(Mid$(St1, A * 5 + 1, 1))
.Experience = Asc(Mid$(St1, A * 5 + 2, 1)) * 16777216 + Asc(Mid$(St1, A * 5 + 3, 1)) * 65536 + Asc(Mid$(St1, A * 5 + 4, 1)) * 256& + Asc(Mid$(St1, A * 5 + 5, 1))
Else
.Level = 0
.Experience = 0
End If
End With
Next A
End If
'Load Magic
St1 = ""
If Not IsNull(UserRS!Magic) Then
St1 = UserRS!Magic
For A = 0 To 254
With .MagicLevel(A + 1)
If Len(St1) >= A * 5 + 6 Then
.Level = Asc(Mid$(St1, A * 5 + 1, 1))
.Experience = Asc(Mid$(St1, A * 5 + 2, 1)) * 16777216 + Asc(Mid$(St1, A * 5 + 3, 1)) * 65536 + Asc(Mid$(St1, A * 5 + 4, 1)) * 256& + Asc(Mid$(St1, A * 5 + 5, 1))
Else
.Level = 0
.Experience = 0
End If
End With
Next A
End If
'Misc Data
.Bank = UserRS!Bank
.Status = UserRS!Status
.Guild = 0
.GuildRank = 0
.GuildSlot = 0
'Find Guild
St1 = .Name
For A = 1 To MaxGuilds
With Guild(A)
If .Name <> "" Then
For B = 0 To 19
If .Member(B).Name = St1 Then
Player(Index).Guild = A
Player(Index).GuildRank = .Member(B).Rank
Player(Index).GuildSlot = B
Exit For
End If
Next B
End If
End With
Next A
For A = 1 To MaxPlayerTimers
.JoinRequest = 0
.ScriptTimer(A) = 0
Next A
If Not .Mode = modeBanned Then
.Mode = modeConnected
SendCharacterData Index
If World.MOTD <> "" Then
SendSocket Index, Chr$(4) + World.MOTD
End If
End If
Else
If B = 1 Then
SendSocket Index, Chr$(0) + Chr$(2)
Else
SendSocket Index, Chr$(0) + Chr$(5)
End If
End If
Else
SendSocket Index, Chr$(0) + Chr$(1) 'Invalid User/Password
End If
Else
SendSocket Index, Chr$(0) + Chr$(1) 'Invalid User/Password
End If
Else
Hacker Index, "A.1"
End If
End If
Case 29 'Pong
If Len(St) > 0 Then
Hacker Index, "A.2"
End If
Case 35 'Get player count
SendRawReal Index, CStr(NumUsers - 1)
Case 61 'Version & CompID
If Len(St) > 1 Then
ProcessVersion Index, St
Else
SendSocket Index, Chr$(116)
End If
End Select
Case modeConnected
Select Case PacketID
Case 2 'Create New Character
If Len(St) >= 4 Then
A = InStr(3, St, vbNullChar)
If A > 1 Then
St1 = Trim$(Mid$(St, 3, A - 3))
If Len(St1) >= 3 And Len(St1) <= 15 And ValidName(St1) Then
UserRS.Index = "Name"
UserRS.Seek "=", St1
If (UserRS.NoMatch Or UCase$(.Name) = UCase$(St1)) And GuildNum(St1) = 0 And NPCNum(St1) = 0 Then
If .Class > 0 Then
UserRS.Bookmark = .Bookmark
DeleteCharacter
End If
.Class = Asc(Mid$(St, 1, 1))
If .Class < 1 Then .Class = 1
If .Class > NumClasses Then .Class = NumClasses
.Gender = Asc(Mid$(St, 2, 1))
If .Gender > 1 Then .Gender = 1
.Sprite = .Class * 2 + .Gender - 1
.Name = St1
If A < Len(St) Then
St1 = Mid$(St, A + 1)
If Len(St1) > 255 Then
.desc = Left$(St1, 255)
Else
.desc = St1
End If
Else
.desc = ""
End If
.Level = 1
.Bank = 0
.Status = 2
.MaxHP = Class(.Class).StartHP
.HP = .MaxHP
.MaxEnergy = Class(.Class).StartEnergy
.Energy = .MaxEnergy
.MaxMana = Class(.Class).StartMana
.Mana = .MaxMana
.Email = ""
.Experience = 0
.SpeedStrikes = 0
For A = 1 To 20
.Inv(A).Object = 0
.Inv(A).Value = 0
.Inv(A).ItemPrefix = 0
.Inv(A).ItemSuffix = 0
Next A
For A = 1 To 6
.EquippedObject(A).Object = 0
.EquippedObject(A).Value = 0
.EquippedObject(A).ItemPrefix = 0
.EquippedObject(A).ItemSuffix = 0
Next A
For A = 0 To 29
.ItemBank(A).Object = 0
.ItemBank(A).Value = 0
.ItemBank(A).ItemPrefix = 0
.ItemBank(A).ItemSuffix = 0
Next A
For A = 0 To 255
.Flag(A) = 0
Next A
.Map = World.StartLocation(0).Map
If .Map < 1 Then .Map = 1
If .Map > MaxMaps Then .Map = MaxMaps
.X = World.StartLocation(0).X
If .X > 11 Then .X = 11
.Y = World.StartLocation(0).Y
If .Y > 11 Then .Y = 11
.Guild = 0
.GuildRank = 0
GiveStartingEQ Index
SavePlayerData Index
CalculateStats Index
SendCharacterData Index
Else
SendSocket Index, Chr$(13) 'Name already in use
End If
Else
AddSocketQue Index
End If
Else
Hacker Index, "A.4"
End If
Else
Hacker Index, "A.5"
End If
Case 4 'Delete Account
If Len(St) = 0 Then
.Class = 0
UserRS.Bookmark = .Bookmark
DeleteAccount
AddSocketQue Index
Else
Hacker Index, "A.7"
End If
Case 5 'Play
If .Class > 0 Then
If MapNum > 0 Then
Hacker Index, "Old"
Else
Hacker Index, "A.8"
End If
Else
Hacker Index, "A.9"
End If
Case 6 'Done Processing New Data
SendDataPacket Index, 1
Case 7 'Request List
If Len(St) = 1 Then
Select Case Asc(Mid$(St, 1, 1))
Case 1 'Objects
SendSocket Index, Chr$(122) + ObjectVersionList
Case 2 'NPCs
SendSocket Index, Chr$(123) + NPCVersionList
Case 3 'Halls
SendSocket Index, Chr$(124) + HallVersionList
Case 4 'Monsters
SendSocket Index, Chr$(125) + MonsterVersionList
Case 5 'Magic
SendSocket Index, Chr$(126) + MagicVersionList
Case 6 'Prefix
SendSocket Index, Chr$(131) + PrefixVersionList
Case 7 'Suffix
SendSocket Index, Chr$(132) + SuffixVersionList
Case 8 'Server Options
SendServerOptions Index
SendSocket Index, Chr$(140)
End Select
Else
Hacker Index, "Request List"
End If
Case 23 'Done receiving Data
If Len(St) = 0 Then
JoinGame Index
Else
Hacker Index, "A.10"
End If
Case 24 'Send Next Packet
If Len(St) = 1 Then
SendDataPacket Index, Asc(Mid$(St, 1, 1))
Else
Hacker Index, "A.11"
End If
Case 29 'Pong
If Len(St) > 0 Then
Hacker Index, "A.13"
End If
Case 79 'Request Object
If Len(St) > 0 Then
A = GetInt(Mid$(St, 1, 2))
With Object(A)
SendSocket Index, Chr$(31) + DoubleChar$(A) + DoubleChar$(CLng(.Picture)) + Chr$(.Type) + Chr$(.Data(0)) + Chr$(.Data(1)) + Chr$(.Data(2)) + Chr$(.flags) + Chr$(.ClassReq) + Chr$(.LevelReq) + Chr$(.Version) + DoubleChar$(.SellPrice) + .Name
End With
End If
Case 80 'Request NPC
If Len(St) > 0 Then
A = GetInt(Mid$(St, 1, 2))
St2 = vbNullString
With NPC(A)
For B = 0 To 9
St2 = St2 + DoubleChar$(.SaleItem(B).GiveObject) + QuadChar$(.SaleItem(B).GiveValue) + DoubleChar$(.SaleItem(B).TakeObject) + QuadChar$(.SaleItem(B).TakeValue)
Next B
SendSocket Index, Chr$(85) + DoubleChar$(A) + Chr$(.Version) + Chr$(.flags) + St2 + .Name
End With
End If
Case 81 'Request Hall
If Len(St) > 0 Then
A = Asc(Mid$(St, 1, 1))
With Hall(A)
SendSocket Index, Chr$(82) + Chr$(A) + Chr$(.Version) + .Name
End With
End If
Case 82 'Request Monster
If Len(St) > 0 Then
A = GetInt(Mid$(St, 1, 2))
With Monster(A)
SendSocket Index, Chr$(32) + DoubleChar$(A) + DoubleChar$(CLng(.Sprite)) + Chr$(.Version) + DoubleChar$(CLng(.HP)) + Chr$(.flags) + .Name
End With
End If
Case 83 'Request Magic
If Len(St) > 0 Then
A = GetInt(Mid$(St, 1, 2))
With Magic(A)
SendSocket Index, Chr$(127) + DoubleChar$(A) + Chr$(.Class) + Chr$(.Level) + Chr$(.Version) + DoubleChar$(CLng(.Icon)) + Chr$(.IconType) + DoubleChar$(CLng(.CastTimer)) + .Name + vbNullChar + .Description
End With
End If
Case 84 'Request Prefix
If Len(St) > 0 Then
A = Asc(Mid$(St, 1, 1))
With ItemPrefix(A)
SendSocket Index, Chr$(133) + Chr$(A) + Chr$(.ModificationType) + Chr$(.ModificationValue) + Chr$(.OccursNaturally) + Chr$(.Version) + .Name
End With
End If
Case 85 'Request Suffix
If Len(St) > 0 Then
A = Asc(Mid$(St, 1, 1))
With ItemSuffix(A)
SendSocket Index, Chr$(134) + Chr$(A) + Chr$(.ModificationType) + Chr$(.ModificationValue) + Chr$(.OccursNaturally) + Chr$(.Version) + .Name
End With
End If
Case 98 'Ban
If Len(St) > 0 Then
If Len(St) < 255 Then
BanPlayer Index, 0, 1, St, "Server"
Else
BanPlayer Index, 0, 1, "Cheating", "Server"
End If
PrintCheat .Name & " " & .IP & " " & St
End If
Case 99 'Cheat Report
If Len(St) > 0 Then
PrintCheat .Name & " " & .IP & " " & St
End If
Case 100 'Debug Report
If Len(St) > 0 Then
PrintDebug "(Player Submitted) - " + .Name + " " + .IP + " " & St
End If
Case Else
Hacker Index, "B.2 - " + CStr(PacketID)
End Select
Case modePlaying
Select Case PacketID
Case 3 'Change Password
If Len(St) > 0 Then
UserRS.Bookmark = .Bookmark
UserRS.Edit
PrintPassword .Name + " change password " + UserRS!Password + " to " + St
UserRS!Password = St