-
Notifications
You must be signed in to change notification settings - Fork 9
/
srvmgr.cpp
2528 lines (2221 loc) · 46.8 KB
/
srvmgr.cpp
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
#include <winsock2.h>
#include <windows.h>
#include "srvmgr.h"
#include "srvmgrdef.h"
#include "charcheck.h"
#include "shared.h"
#pragma warning(disable:4996) // no_deprecate
#include "config_new.h"
#include <string>
#include <stdexcept>
#include <vector>
#include <sstream>
#include <ctime>
#include "lib\utils.hpp"
#include "lib\packet.hpp"
#include "lib\socket.hpp"
#include "srvmgr_new.h"
#include "player_info.h"
#include "zxmgr.h"
/// CDECL íåò î÷èñòêè ñòåêà ôóíêöèåé
/// STDCALL åñòü
char alog_vis[] = " id: 0x%.4X; (%d, %d)[%d] - vision=%d.%d\n";
char camp1[] = "Player %s tried to camp from building.";
char camp2[] = "Player %s initiated camping.";
char player_respawn[] = "Player %s respawned.";
char enter_b1[] = "<cmd: enter to building>\n";
char cancel_camp1[] = "Player %s cancelled camping.";
char enter_shop1[] = "Player %s entered shop ID=%u from (%u, %u).";
char enter_inn1[] = "Player %s entered inn ID=%u from (%u, %u).";
char left_shop1[] = "Player %s left shop.";
char left_inn1[] = "Player %s left inn.";
char aErrPoint[] = "name: %s, error dst\n";
char aArea_Cast[] = "player %s: area_cast from (%d, %d)[%d] to (%d, %d)[%d], vision=%d.%d\n";
char config[BUF_MAX];
bool exiting = false;
int(__cdecl *print_log)(char *message);
HANDLE hThread;
char avisall[] = "name: %s - id: 0x%.2X\n";
DWORD dwThreadId;
char ctl_dir[BUF_MAX];
Encoding encoding = CP1251;
char map_name_buf[0x200];
char log_invalid_packet[]="Invalid packet '%.2X' from '%s'\n";
char log_color_crasher[]="Player %s tried to use color crash bug\n";
unsigned spirit_factor = 256;
#include "bugs.h"
#ifdef SRV_LOG
struct client {
SOCKET s;
std::string ip, name;
struct client *n, *p;
} *c0 = 0;
#endif
char info[100];
char numb[] = "0123456789ABCDEF";
char spirit[MAX_PATH];
char perc_s[]="%s\n";
double exp_death = 1.0;
double exp_full = 0.9;
const char * __stdcall get_player_name(void *pl)
{
return *(const char **)((char *)pl + 0x18);
}
void * __stdcall get_player(void *un)
{
return *(void **)((char *)un + 0x14);
}
void __stdcall auto_war_cpp(void *unit_from, void *unit_to, int att)
{
void *player_from = get_player(unit_from);
void *player_to = get_player(unit_to);
Printf("Player %s (%s) set auto-war to player %s", get_player_name(player_from), att ? "attacker" : "victim", get_player_name(player_to));
}
void __declspec(naked) auto_war_1()
{ // 005B56EF
__asm
{
push 1
push [ebp+0xc]
push [ebp+8]
call auto_war_cpp
mov ecx, [ebp+8]
mov edx, [ecx+0x14]
push edx
mov edx, 0x05B56F6
jmp edx
}
}
void __declspec(naked) auto_war_2()
{ // 005B57C6
__asm
{
push 0
push [ebp+8]
push [ebp+0xc]
call auto_war_cpp
mov ecx, [ebp+8]
mov edx, [ecx+0x14]
push edx
mov edx, 0x05B57CD
jmp edx
}
}
void __stdcall log_dip_change_cpp(byte *player_from, byte *player_to, int was, int became)
{
char names[][7] = {"war", "ally", "ignore", "vision"};
int flags[4] = {1, 2, 4, 0x10};
for (int i = 0; i < 4; ++i)
{
if ((was & flags[i]) && !(became & flags[i]))
Printf("Player %s unset %s to player %s", get_player_name(player_from), names[i], get_player_name(player_to));
if (!(was & flags[i]) && (became & flags[i]))
Printf("Player %s set %s to player %s", get_player_name(player_from), names[i], get_player_name(player_to));
}
}
void __declspec(naked) log_dip_change()
{ // 005081DC
__asm
{
// magic here
mov ecx, [ebp-0x9E8]
mov ecx, dword ptr [ecx+0x14]
and ecx, GMF_PLAYERS_VISION
cmp ecx, GMF_PLAYERS_VISION
jnz do_no_vision
mov eax, [ebp-0xA0C]
mov ecx, [ebp-0x9DC]
movzx ebx, word ptr [ecx+eax*2]
or ebx, 0x10
mov word ptr [ecx+eax*2], bx
do_no_vision:
mov ecx, [ebp-0x9E8]
mov ecx, dword ptr [ecx+0x14]
and ecx, GMF_PLAYERS_ALLY
cmp ecx, GMF_PLAYERS_ALLY
jnz do_normal
mov eax, [ebp-0xA0C]
mov ecx, [ebp-0x9DC]
movzx ebx, word ptr [ecx+eax*2]
or ebx, 0x02
mov word ptr [ecx+eax*2], bx
do_normal:
push esi
push edx
push [ebp - 0x9E8]
push [ebp - 0x9E4]
call log_dip_change_cpp
mov edx, [ebp - 0xA08]
mov ecx, 0x005081E2
jmp ecx
}
}
char * _stdcall chat_log_cpp(char *msg, char *player_from, char *player_to, unsigned int type)
{
static char m[5000];
if (type == 1)
{
_snprintf(m, sizeof(m)-1, "--> %s: %s", player_from, msg);
}
else if (type == 2)
{
_snprintf(m, sizeof(m)-1, "%s >>> %s: %s", player_from, player_to, msg);
}
else
{
_snprintf(m, sizeof(m)-1, "%s: %s", player_from, msg);
}
return m;
}
void _declspec(naked) chat_log()
{ // 0050721C
__asm
{
mov edx, [ebp-0x528]
mov eax, [edx+0x0a]
sar eax, 8
and eax, 0xFF
push eax
cmp eax, 2
jnz skip_player_to
mov edx, [ebp-0x528]
mov eax, [edx+0x0a]
and eax, 0xFF
push eax
mov ecx, 0x6CDB24
mov ecx, [ecx]
mov edx, 0x535B50
call edx
test eax, eax
jz skip_player_to
mov eax, [eax+0x18]
push eax
jmp join_player_to
skip_player_to:
xor eax, eax
push eax
jmp join_player_to
join_player_to:
mov ecx, [ebp-0x104]
mov eax, [ecx+0x18]
push eax
mov eax, [ebp-0x108]
push eax
call chat_log_cpp
push eax
mov edx, 0x0043A857
call edx
add esp, 4
mov edx, 0x00507267
jmp edx
}
}
void _declspec(naked) player_respawned_init()
{
__asm
{
mov eax, [ebp-0x34]
mov dword ptr [eax+0x130], 0
mov eax, [eax + 0x14]
test eax, eax
jz pri_skip
mov eax, [eax + 0x18]
test eax, eax
jz pri_skip
push eax
push offset player_respawn
call Printf
pri_skip:
mov edx, 0x531197
jmp edx
}
}
unsigned int _stdcall respawn_update_exp_cpp(unsigned int exp)
{
return static_cast<unsigned int>(exp * (exp_full / exp_death));
}
void _declspec(naked) player_respawned()
{ // 00531278
__asm
{
push eax
call respawn_update_exp_cpp
mov edx, 0x0531283
jmp edx
}
}
unsigned int _stdcall death_update_exp_cpp(unsigned int exp)
{
return static_cast<unsigned int>(exp * exp_death);
}
void _declspec(naked) death_update_exp(void *unit)
{
__asm
{
push ebp
mov ebp, esp
sub esp, 4
mov edx, dword ptr [ebp+8] // unit
mov dword ptr [edx+0x130], 0
mov dword ptr [ebp-4], 1
due_cycle: cmp dword ptr [ebp-4], 6
jge due_cycle_ex
mov edx, dword ptr [ebp+8] // unit
mov ecx, dword ptr [ebp-4] // i
mov eax, [edx + ecx*4 + 0x23C]
push eax
call death_update_exp_cpp
mov edx, dword ptr [ebp+8] // unit
mov ecx, dword ptr [ebp-4] // i
mov [edx + ecx*4 + 0x23C], eax
add [edx + 0x130], eax
inc dword ptr [ebp-4]
jmp due_cycle
due_cycle_ex:
mov esp, ebp
pop ebp
ret 4
}
}
void _declspec(naked) player_died()
{ // 00556A56
__asm
{
push [ebp - 0x18]
call death_update_exp
mov edx, 0x556A5D
jmp edx
}
}
void _declspec(naked) player_killed()
{ // 00557005
__asm
{
push [ebp - 0x18]
call death_update_exp
mov edx, 0x55700C
jmp edx
}
}
void _declspec(naked) player_pkilled()
{ // 00556BE6
__asm
{
push [ebp - 0x18]
call death_update_exp
mov edx, 0x556BED
jmp edx
}
}
void _declspec(naked) heal_enemies()
{ // 0053A5CB
__asm
{ // skip a check
mov edx, 0x0053A5D5
jmp edx
}
}
void _declspec(naked) add_health_potions()
{ // 0054D700
__asm
{ // ïðîïóñòèòü äîáàâëåíèå çåëüåâ
mov edx, 0x54D8AC
jmp edx
}
}
void _declspec(naked) skip_updating_character_log()
{
__asm
{
mov edx, 0x4F119B
jmp edx
}
}
void _declspec(naked) skip_returning_character_log()
{
__asm
{
mov edx, 0x4F1414
jmp edx
}
}
unsigned int get_spirit_level(unsigned int power)
{
if (spirit_factor == 0) return 5;
unsigned int level = power / spirit_factor + 1;
if (level > 5) level = 5;
return level;
}
char *__stdcall get_zombie(unsigned int power)
{
unsigned int level = get_spirit_level(power);
if (level == 1) return "F_Zombie.1";
_snprintf(spirit, MAX_PATH-1, "%c_Zombie.%d", "AF"[rand()%2], level);
return spirit;
}
char *__stdcall get_skeleton(unsigned int power)
{
_snprintf(spirit, MAX_PATH-1, "%c_Skeleton.%d", "AF"[rand()%2], get_spirit_level(power));
return spirit;
}
char *__stdcall get_ghost(unsigned int power)
{
unsigned int level = get_spirit_level(power);
if (level == 1) return "Ghost";
_snprintf(spirit, MAX_PATH-1, "Ghost.%d", level);
return spirit;
}
void __declspec(naked) zombie_gen()
{ // 53B6D3
__asm
{
mov edx, [ebp-0x40]
push edx
call get_zombie
push eax
lea ecx, [ebp - 0x0EC]
mov edx, 0x53B6DE
jmp edx
}
}
void __declspec(naked) skeleton_gen()
{ // 53B7EB
__asm
{
mov edx, [ebp-0x40]
push edx
call get_skeleton
push eax
lea ecx, [ebp - 0x0F0]
mov edx, 0x53B7F6
jmp edx
}
}
void __declspec(naked) ghost_gen()
{ // 53B910
__asm
{
mov edx, [ebp-0x40]
push edx
call get_ghost
push eax
lea ecx, [ebp - 0x0F4]
mov edx, 0x53B91B
jmp edx
}
}
void __declspec(naked) redir_log()
{
__asm
{
push dword ptr [ebp+8]
push offset perc_s
call log_format
mov edx, 0x401D90
call edx
mov [ebp-0x14],eax
mov edx, 0x43A87A
jmp edx
}
}
//char mtap_test[] = "unit %.4X, flags: %.2X, sig: %.2X\n";
//char ucss_test[] = "unit %.4X, flags: %.2X, change\n";
char eghp_test[] = "unit %.4X, eff: %d, bit: %d, ret: %.6X, ret2: %.6X\n";
char ep1t[] = "effect packet 1\n";
char ep2t[] = "effect packet 2, id=%.2X\n";
char ep3t[] = "effect packet 3\n";
char ep4t[] = "effect packet 4\n";
void __declspec(naked) effect_packet_1()
{
__asm // 0051BAC3
{
mov eax, [ebp-4]
mov byte ptr [eax+9], 0x86
mov ecx, [ebp-4]
mov edx, 0x51baca
jmp edx
}
}
void __declspec(naked) effect_packet_2()
{
__asm // 0051BBA7
{
mov eax, [ebp+0x0c]
xor ecx, ecx
mov cl, [eax+8]
cmp cl, 0x02
jz ep2_send_coords
cmp cl, 0x03
jz ep2_send_coords
cmp cl, 0x11
jz ep2_send_coords
cmp cl, 0x17
jz ep2_send_coords
cmp cl, 0x16
jz ep2_send_coords
cmp cl, 0x07
jz ep2_send_coords
cmp cl, 0x06
jz ep2_send_coords
jmp ep2_skip_coords
ep2_send_coords:
mov edx, 0xFFB
xor ecx, ecx
push ecx
push ecx
push edx
mov eax, 0x10000010
push eax
push ecx
mov eax, [ebp + 8]
push eax
mov ecx, 0x6C3A08
mov edx, 0x519221
call edx
ep2_skip_coords:
jmp ep2_skip
mov eax, [ebp+0x0c]
xor ecx, ecx
mov cl, [eax+8]
push ecx
push offset ep2t
call log_format
ep2_skip:
mov eax, [ebp-4]
mov byte ptr [eax+9], 0x86
mov ecx, [ebp-4]
mov edx, 0x51bbae
jmp edx
}
}
void __declspec(naked) effect_packet_3()
{
__asm // 0051BE21
{
mov eax, [ebp-4]
mov byte ptr [eax+9], 0x86
mov ecx, [ebp+8]
mov edx, 0x51be28
jmp edx
}
}
void __declspec(naked) effect_packet_4()
{
__asm // 0051BEB0
{
mov edx, [ebp-0x18]
mov byte ptr [edx+9], 0x86
mov eax, [ebp+8]
mov edx, 0x51beb7
jmp edx
}
}
char eg1_t[] = "invisibility gone 1\n";
char eg2_t[] = "invisibility gone 2\n";
/*
* effect packet 2
* invisibility gone 1
* invisible has gone packet sent, 5564F6 52A921 53EF9A 51BD9E
*/
void __declspec(naked) effect_gone_1()
{
__asm
{
mov eax, [ebp-4]
xor ecx, ecx
mov cx, [eax+0x0c]
mov edx, 0x53ef5e
jmp edx
}
}
void __declspec(naked) effect_gone_2()
{
__asm
{
mov eax, [ebp-0x14]
xor ecx, ecx
mov cx, [eax+0x0c]
mov edx, 0x53F121
jmp edx
}
}
/*
* [5.12.2010 0:20:29.811] unit 0001, eff: 32, ret: 53F717, ret2: 537624 hang
* [5.12.2010 0:20:35.062] unit 0001, eff: 32, ret: 51BD9E, ret2: 53EF9A gone
*/
char ehgp_t[] = "invisible has gone packet sent, %.6X %.6X %.6X %.6X\n";
void __declspec(naked) effect_hang_gone_packet()
{
__asm
{
mov eax, [ebp+0x10]
cmp al, 0x89
jnz ehgp_pass // not gone
mov eax, [ebp+8]
xor edx, edx
mov dx, [eax+0x0C]
cmp edx, 12
jnz ehgp_pass
mov edx, 0xFFB
xor ecx, ecx
push ecx
push ecx
push edx
mov eax, 0x10
push eax
push ecx
mov eax, [ebp + 0x0c]
push eax
mov ecx, 0x6C3A08
mov edx, 0x519221
call edx
jmp ehgp_pass
ehgp_pass:
mov dword ptr [ebp-4], 0x6CDB28
mov edx, 0x51BDB4
jmp edx
}
}
void __declspec(naked) move_turn_attack_packet()
{
__asm
{
push ebp
mov ebp, esp
sub esp, 8
mov [ebp - 8], ecx
mov dword ptr [ebp - 4], 0x70A7D0
mov eax, [ebp + 0x18] // destination player
test eax, eax
jz mtap_skip
movsx edx, word ptr [eax + 4]
cmp edx, 0x10
jl mtap_skip
cmp edx, 0x20
jge mtap_skip
// mov eax, dword ptr [mode]
// test eax, TEST_FLAG
// jz mtap_pass
mov eax, [ebp + 0x14]
cmp al, 0x71
jz mtap_pass
mov eax, [ebp + 8] // unit
mov ecx, [eax + 0x144] // effects flags
and ecx, 0x1000 // invisibility
test ecx, ecx
jz mtap_pass // visible
// jmp mtap_skip
mov ecx, 0x6A8B8C
mov edx, [ecx]
mov eax, [ebp + 8] // changed unit
mov eax, [eax + 0x14] // player of changed unit
movsx ecx, word ptr [eax + 4] // id
imul ecx, 0x46
mov eax, [ebp + 0x18] // destination player
movsx eax, word ptr [eax + 4] // id
add ecx, eax
add ecx, 0xA8C4
add ecx, edx
test byte ptr [ecx], 0x10 // vision
jz mtap_skip
jmp mtap_pass
mtap_pass:
mov eax, [ebp + 0x14]
and eax, 0xFF
test eax, eax
jnz loc_51B9C3
mov ecx, [ebp - 4]
mov byte ptr [ecx + 9], 0x6B
jmp loc_51B9CC
loc_51B9C3:
mov edx, [ebp - 4]
mov al, byte ptr [ebp + 0x14]
mov [edx + 9], al
loc_51B9CC:
mov ecx, [ebp - 4]
mov dl, [ebp + 0x10]
mov [ecx+0x0D], dl
mov dl, [ebp + 0x0C]
mov [ecx+0x0C], dl
mov ecx, [ebp+8]
mov edx, 0x52BABD
call edx
mov edx, [ebp+0x10]
and edx, 0xFF
mov eax, 0x642C2C
mov eax, [eax]
mov ecx, [eax+4]
add ecx, edx
mov edx, [ebp + 8]
mov [edx+0x138], ecx
mov eax, [ebp - 4]
mov ecx, [ebp + 8]
mov dx, [ecx + 4]
mov [eax+0x0A], dx
mov edx, [ebp + 0x18]
movsx edx, word ptr [edx + 4]
mov word ptr [eax+7], dx // broadcast
mov ecx, [ebp + 8]
push ecx
push eax // packet
mov ecx, [ebp - 8]
mov edx, 0x51B0F0
call edx
mtap_skip:
mov esp, ebp
pop ebp
retn 0x14
}
}
void __declspec(naked) broadcast_move_turn_attack_packet()
{ // 51B99E
__asm
{
push ebp
mov ebp, esp
sub esp, 0x0C
mov [ebp - 0x0C], ecx
lea ecx, [ebp-0x08]
mov edx, 0x496DC0
call edx
mov ecx, 0x06CDB24
mov ecx, [ecx]
push ecx
lea ecx, [ebp-0x08]
mov edx, 0x496DD0
call edx
l_50303D:
test eax, eax
jz l_503051
push eax
mov eax, [ebp+0x14]
push eax
mov eax, [ebp+0x10]
push eax
mov eax, [ebp+0x0c]
push eax
mov eax, [ebp+8]
push eax
mov ecx, [ebp-0x0c]
call move_turn_attack_packet
lea ecx, [ebp-0x08]
mov edx, 0x496E20
call edx
jmp l_50303D
// ---------------------------------------------------------------------------
l_503051: // CODE XREF: sub_50301F+20j
mov esp, ebp
pop ebp
ret 0x10
}
}
// 1) TODO: ãäå-òî ïðîëåçàþò êîîðäèíàòû
// +2) TODO: ïðè âèçèáëå - ôîðñèðîâàòü îòïðàâêó ïîîðäèíàò è óãëà ïîñûëàòü
// 3) ïîñûëàòü 6B, 6D êàê?
// 1c0 : 71 (.text:0051C5E1) , ...
void __declspec(naked) unit_change_single_send()
{ // 00519346
__asm
{
mov eax, [ebp + 8] // unit
mov ecx, [eax + 0x144] // effects flags
and ecx, 0x1000
test ecx, ecx
jz ucss_send // visible
// jmp ucss_skip_send
mov ecx, 0x6A8B8C
mov edx, [ecx]
mov eax, [ebp + 8] // changed unit
mov eax, [eax + 0x14] // player of changed unit
movsx ecx, word ptr [eax + 4] // id
imul ecx, 0x46
mov eax, [ebp + 0x0C] // destination player
movsx eax, word ptr [eax + 4] // id
add ecx, eax
add ecx, 0xA8C4
add ecx, edx
test byte ptr [ecx], 0x10 // vision
jz ucss_skip_send
jmp ucss_send
ucss_skip_send:
mov eax, [ebp + 0x10]
cmp eax, 0x10000010
jz ucss_send
and eax, 0xFFFFFFEF
mov [ebp + 0x10], eax
ucss_send:
mov eax, [ebp + 8]
xor ecx, ecx
mov cx, [eax + 0x1A4]
mov edx, 0x519352
jmp edx
//ucss_skip_send_2:
mov edx, 0x51A0BB
jmp edx
}
}
char ucss2_t[] = "warn, sending coords to invisible char\n";
void __declspec(naked) unit_change_single_send_2()
{
__asm
{
mov ecx, [ebp+8]
mov ecx, [ecx+0x1C0]
mov edx, 0x5196FD
jmp edx
}
}
void __declspec(naked) pkill_msg()
{
__asm { // from 00556C0F
mov eax, [ebp-0x18]
mov ecx, [eax+0x40]
mov edx, [ecx+0x14]
mov eax, [edx+0x18]
push eax
mov edx, 0x00556C1C
jmp edx
}
}
void __declspec(naked) print_packet_info()
{
__asm
{
mov eax, [Config::LogMode]
test eax, SVL_DIPLOMACY
jz ppi_skip_log
mov eax, [ebp+8]
mov edi, offset info
mov byte ptr [edi+4], 0
mov edx, offset numb
xor ecx, ecx
mov cl, [eax+5]
shr cl, 4
mov cl, [edx+ecx]
mov [edi], cl
mov cl, [eax+5]
and cl, 0x0F
mov cl, [edx+ecx]
mov [edi+1], cl
mov cl, [eax+9]
shr cl, 4
mov cl, [edx+ecx]
mov [edi+2], cl
mov cl, [eax+9]
and cl, 0x0F
mov cl, [edx+ecx]
mov [edi+3], cl
push edi
mov edx, 0x043A857
call edx
add esp, 4
ppi_skip_log:
mov edx, [ebp+8]
xor eax, eax
mov al, [edx+9]
mov edx, 0x050587A
jmp edx
}
}
int __stdcall check_sig_c_s(unsigned char c)
{
// static int counter = 30;
unsigned char arr[] = {0x02, 0x04, 0x05, 0x07, 0x08, 0x09, 0x12, 0x13, 0x14, 0x16,
0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x21, 0x22, 0x23,
0x24, 0x25, 0x26, 0x32, 0x33, 0x34, 0x35, 0x36, 0x38, 0x39, 0x3A, 0x3B,
0x3E, 0x3F, 0x45, 0x46, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x91, 0xAE,
0xBE, 0xC1, 0xD0, 0x64};
// if (!--counter) return 0;
for (size_t i = 0; i < sizeof(arr); ++i)
{
if (c == arr[i]) return 1;
}
return 0;
}
void __declspec(naked) add_player_to_map()
{
__asm
{
push ebp
mov ebp, esp
sub esp, 0x0C
mov eax, [ecx + 0x4C] // unit
test eax, 8
jz aptm_already_on_map
mov edx, 0x052C40F
jmp edx
aptm_already_on_map:
mov edx, 0x052C47B
jmp edx
}
}
void _declspec(naked) packet_recvd()
{ // jmp 00504ABC
__asm {
mov ecx, dword ptr[ebp+8]
xor eax, eax
mov al, byte ptr [ecx+9]
push eax
call check_sig_c_s
test eax,eax
jnz pr_ex
// ÐÒÉÝÕÞÉÍ ÇÁÄÁ
mov ecx, [ebp+8]
xor eax,eax
mov ax, [ecx+5]
push eax
mov ecx, 0x6CDB24
mov ecx, [ecx]
mov edx, 0x535B50
call edx
test eax, eax
jz pr_ex // skip for now
mov [ebp-0xB0C], eax // player
mov ecx, [eax + 0xA78]
push ecx
mov edx, [ebp+8]
xor ecx, ecx
mov cl, [edx+9]
push ecx
push offset log_invalid_packet
call log_format
// disconnect him
mov eax, [ebp-0xB0C]
xor ecx, ecx
mov cx, [eax+4]
push ecx
mov ecx, 0x6C3A08
mov edx, 0x518544
call edx
test eax, eax
jz pr_sk
mov eax, [eax+29Ch]
test eax, eax
jnz pr_sk
mov ecx, [ebp-0xB0C]
push ecx