forked from jewalky/srvmgr
-
Notifications
You must be signed in to change notification settings - Fork 5
/
zxmgr.cpp
1327 lines (1174 loc) · 34.5 KB
/
zxmgr.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 "syslib.h"
#include "zxmgr.h"
#include "srvmgr.h"
#include "srvmgrdef.h"
#include "lib\utils.hpp"
#include "player_info.h"
namespace zxmgr
{
std::vector<byte*> _stdcall GetPlayers()
{
std::vector<byte*> vec;
unsigned long var_8, var_C;
__asm
{
mov [var_8], 0x00642C2C
lea ecx, [var_8]
mov edx, 0x00496DC0
call edx
mov ecx, 0x006CDB24
mov ecx, [ecx]
push ecx
lea ecx, [var_8]
mov edx, 0x00496DD0
call edx
doloop:
test eax, eax
jz ret_break
mov [var_C], eax
}
byte* ch = (byte*)(var_C);
vec.push_back(ch);
__asm
{
lea ecx, [var_8]
mov edx, 0x00496E20
call edx
jmp doloop
ret_break:
}
return vec;
}
void __declspec(naked) SendMessageRaw(byte* pptr, char* message)
{
__asm
{
push ebp
mov ebp, esp
push [ebp+0x08]
lea eax, [ebp+0x0C]
push eax
mov ecx, 0x006C3A08
mov edx, 0x0051CD89
call edx
mov esp, ebp
pop ebp
retn
}
}
void __stdcall SendMessage(byte* pptr, const char* mask, ...)
{
va_list arglist;
va_start(arglist, mask);
char buffer[4096];
vsprintf(buffer, mask, arglist);
SendMessageRaw(pptr, buffer);
va_end(arglist);
}
void __declspec(naked) Kick(byte* pptr, bool silent)
{
__asm
{
push ebp
mov ebp, esp
mov eax, [ebp+0x08]
test eax, eax
jz endp
cmp dword ptr [eax+2Ch], 0 // AI
jnz endp
mov eax, [eax+0x38]
push eax
mov ecx, 0x00642C2C
mov ecx, [ecx]
mov edx, 0x004EE028
call edx
mov eax, [ebp+0x08]
xor ecx, ecx
mov cx, [eax+4]
push ecx
mov ecx, 0x006C3A08
mov edx, 0x00518544
call edx
push eax
mov ecx, 0x006C3A08
mov edx, 0x005170B6
call edx
mov ecx, 0x006C3A08
mov edx, 0x0051800F
call edx
// сообщение в чате про кик
cmp [ebp+0x0C], 1
jz skip_message
mov eax, [ebp+0x08]
mov eax, [eax+0x14]
and eax, 0x3F000800
cmp eax, 0x3F000800
jz skip_message // невидимый, и кика соотв. видеть не должны
mov eax, [ebp+0x08]
push eax
mov ecx, 0x006C3A08
mov edx, 0x0051D49B
call edx
// "»грок был выкикан с сервера" (c) ленд
skip_message:
mov ecx, 0x00642C2C
mov ecx, [ecx]
mov edx, [ecx]
dec edx
mov eax, [ebp+0x08]
mov [eax+0x0A50], edx
mov ecx, 0x006CDB24
mov ecx, [ecx]
mov edx, 0x00534DDD
call edx
endp:
mov esp, ebp
pop ebp
retn
}
}
void _stdcall KickAllSilent(byte* pptr)
{
std::vector<byte*> players = GetPlayers();
for (std::vector<byte*>::iterator it = players.begin(); it != players.end(); ++it)
{
byte* player = (*it);
if (player && player != pptr && !*(uint32_t*)(player + 0x2C))
Kick(player, true);
}
}
void _stdcall KickAll(byte* pptr)
{
std::vector<byte*> players = GetPlayers();
for (std::vector<byte*>::iterator it = players.begin(); it != players.end(); ++it)
{
byte* player = (*it);
if (player && player != pptr && !*(uint32_t*)(player + 0x2C))
Kick(player, false);
}
}
byte* _stdcall FindByNickname(const char* nickname)
{
std::vector<byte*> players = GetPlayers();
for (std::vector<byte*>::iterator it = players.begin(); it != players.end(); ++it)
{
byte* player = (*it);
if (!player) continue;
const char* pl_name = *(const char**)(player + 0x18);
std::string pl_nickname = pl_name;
if (*(uint32_t*)(player + 0x2C))
{
// convert to cp-866
for (size_t i = 0; i < pl_nickname.length(); i++)
{
uint8_t ch = pl_nickname[i];
if (ch == 0xA8) ch = 0xF0;
else if (ch == 0xB8) ch = 0xF1;
else if (ch >= 0xC0 && ch <= 0xEF)
ch -= 0x40;
else if (ch >= 0xF0 && ch <= 0xFF)
ch -= 0x10;
pl_nickname[i] = ch;
}
}
if (pl_nickname == nickname) return player;
}
return 0;
}
byte* _stdcall FindByLogin(const char* login)
{
std::vector<byte*> players = GetPlayers();
for (std::vector<byte*>::iterator it = players.begin(); it != players.end(); ++it)
{
byte* player = (*it);
if (!player) continue;
if (*(uint32_t*)(player + 0x2C)) continue; // AI check
const char* pl_login = *(const char**)(player + 0x0A78);
if (!strcmp(pl_login, login)) return player;
}
return 0;
}
void _stdcall Kill(byte* pptr, byte* caster)
{
std::vector<byte*> units = GetUnits(pptr);
for (std::vector<byte*>::iterator it = units.begin(); it != units.end(); ++it)
{
byte* unit = (*it);
if (!unit) continue;
if (*(byte**)(unit + 0x14) != pptr) continue;
if (caster && unit == *(byte**)(caster + 0x38)) continue;
*(byte**)(unit + 0x40) = NULL; // damage_by
*(int16_t*)(unit + 0x94) = -50;
UpdateUnit(unit, 0, 0xFFFFFFFF, 0xFFB, 0, 0);
}
}
void _stdcall KillAll(byte* pptr, bool ai_only) // ¬Ќ»ћјЌ»≈! в отличие от оригинального #killall, убивает ¬—≈’ за исключением кастера.
{
std::vector<byte*> units = GetUnits();
for (std::vector<byte*>::iterator it = units.begin(); it != units.end(); ++it)
{
byte* unit = (*it);
if (!unit) continue;
if (pptr && unit == *(byte**)(pptr + 0x38)) continue;
if (ai_only && *(byte**)(unit + 0x14) &&
!*(uint32_t*)(*(byte**)(unit + 0x14) + 0x2C)) continue;
*(byte**)(unit + 0x40) = NULL; // damage_by
*(int32_t*)(unit + 0x94) = -50;
UpdateUnit(unit, 0, 0xFFFFFFFF, 0xFFB, 0, 0);
}
}
bool IsConnected(byte* pptr)
{
return (GetNetworkStruct(pptr));
}
byte __declspec(naked) *Summon(byte* pptr, const char* unitname, byte* pthis, bool ishero, byte* targetptr)
{
__asm
{
push ebp
mov ebp, esp
sub esp, 0x08
// wellllllll
push [ebp+0x0C]
lea ecx, [ebp-0x08]
mov edx, 0x005DD8F8
call edx // CString::CString(const char*)
//mov [ebp-0x08], eax
push [ebp+0x14]
mov eax, [ebp+0x08]
mov eax, [ebp+0x08]
push [eax+0x38]
//push [ebp-0x08]
lea ecx, [ebp-0x08]
push ecx
mov ecx, 0x00642C2C
mov ecx, [ecx]
mov edx, 0x00509879
call edx
mov [ebp-0x04], eax
test eax, eax
jz s_endp
/*mov ecx, [ebp+0x14]
test ecx, ecx
jz s_endp
mov ebx, [ecx+0x2C]
test ebx, ebx
jz s_endp
mov ebx, [ebp+0x14]
mov [eax+0x14], ebx*/
push 0
push 0
push 0x0FFB
push 0xFFFFFFFF
push 0
push eax
mov ecx, 0x006C3A08
mov edx, 0x00519221
call edx
s_endp:
lea ecx, [ebp-0x08]
mov edx, 0x005DD88A
call edx // CString::~CString()
mov eax, [ebp-0x04]
mov esp, ebp
pop ebp
retn
}
}
// добавить денег игроку
void __declspec(naked) GiveMoney(byte* pptr, unsigned long count, unsigned long flags)
{
__asm
{
push ebp
mov ebp, esp
push [ebp+0x10]
push [ebp+0x0C]
mov ecx, [ebp+0x08]
mov edx, 0x00534AC1
call edx
mov esp, ebp
pop ebp
retn
}
}
// 51CEFB - ¤ так пон¤л, обновление (изменение) информации об игроке
void __declspec(naked) UpdatePlayer(unsigned long flags, unsigned long info, unsigned long unknown, byte* player)
{
__asm
{
push ebp
mov ebp, esp
push [ebp+0x14]
push [ebp+0x10]
push [ebp+0x0C]
push [ebp+0x08]
mov ecx, 0x006C3A08
mov edx, 0x0051CEFB
call edx
mov esp, ebp
pop ebp
retn
}
}
void __stdcall Own(byte* to, byte* from)
{
if (!from || !to) return;
std::vector<byte*> units = GetUnits(from);
for (std::vector<byte*>::iterator it = units.begin(); it != units.end(); ++it)
{
byte* unit = (*it);
if (!unit) continue;
if (unit == *(byte**)(*(byte**)(unit + 0x14) + 0x38)) continue;
*(byte**)(unit + 0x14) = to;
UpdateUnit(unit, 0, 0xFFFFFFFF, 0xFFB, 0, 0);
}
}
std::vector<byte*> _stdcall GetUnits(byte* player)
{
std::vector<byte*> retval;
unsigned long var_4, var_C;
__asm
{
mov eax, 0x006CDB3C
mov eax, [eax]
add eax, 0x04
mov edx, [eax+0x04]
mov [var_C], edx
loop_units:
mov edx, [var_C]
test edx, edx
jz exit_loop
mov eax, [edx]
mov ecx, [edx+0x08]
mov [var_C], eax
mov [var_4], ecx
cmp [player], 0
jz add_every_unit
mov eax, [ecx+0x14]
cmp eax, [player]
jnz loop_units // continue
add_every_unit:
}
byte* pl2 = (byte*)var_4;
retval.push_back(pl2);
__asm
{
jmp loop_units
exit_loop:
}
return retval;
}
void __declspec(naked) PickupFor(unsigned long pptr, unsigned long pthis)
{
__asm
{
push ebp
mov ebp, esp
mov esp, ebp
pop ebp
retn
}
}
unsigned long __declspec(naked) GetSpeed()
{
__asm
{
push ebp
mov ebp, esp
sub esp, 8
mov eax, 0x006D15A8
mov eax, [eax]
mov esp, ebp
pop ebp
retn
}
}
void __declspec(naked) SetSpeed(unsigned long newspeed)
{
__asm
{
push ebp
mov ebp, esp
sub esp, 8
mov eax, 0x006D15A8
mov ebx, [ebp+0x08]
mov [eax], ebx
mov edx, 0x00401D90
call edx
push [ebp+0x08]
mov ecx, eax
mov edx, 0x0048DC02
call edx
test eax, eax
jz nomessage
push 0
mov ecx, 0x006D15A8
push [ecx]
mov ecx, 0x006C3A08
mov edx, 0x0051D837
call edx
nomessage:
mov esp, ebp
pop ebp
retn
}
}
void __declspec(naked) ShutdownServer()
{
__asm
{
call upd_all
push 0
call zxmgr::KickAllSilent
push 0
mov edx, 0x005C1070 // __exit
call edx
}
}
unsigned long __declspec(naked) GetCurrentMapTime()
{
__asm
{
push ebp
mov ebp, esp
mov eax, 0x00642C2C
mov eax, [eax]
mov eax, [eax+0x254]
mov esp, ebp
pop ebp
retn
}
}
unsigned long __declspec(naked) GetTotalMapTime()
{
__asm
{
push ebp
mov ebp, esp
mov eax, 0x006D1634
push [eax]
mov ecx, 0x006D1618
mov edx, 0x00402880
call edx
mov eax, [eax]
mov esp, ebp
pop ebp
retn
}
}
void __declspec(naked) SetTotalMapTime(unsigned long value)
{
__asm
{
push ebp
mov ebp, esp
mov eax, 0x006D1634
push [eax]
mov ecx, 0x006D1618
mov edx, 0x00402880
call edx
mov ebx, [ebp+0x08]
mov [eax], ebx
mov esp, ebp
pop ebp
retn
}
}
void __declspec(naked) ResetMap()
{
__asm
{
push ebp
mov ebp, esp
sub esp, 8
mov edx, 0x00401D90
call edx
mov [ebp-0x08], eax // main window?
push 0
push 0
push 0x445
mov ecx, [ebp-0x08]
mov ecx, [ecx+0x3D0]
mov edx, [ebp-0x08]
mov eax, [edx+0x3D0]
mov edx, [eax]
call dword ptr [edx+0x48]
mov esp, ebp
pop ebp
retn
}
}
void __declspec(naked) MorphUnit(unsigned long unit, unsigned long kind)
{
__asm
{
push ebp
mov ebp, esp
mov esp, ebp
pop ebp
retn
}
}
void __declspec(naked) UpdateUnit(byte* unit, byte* player, unsigned long flags, unsigned long flags2, unsigned long flags3, unsigned long flags4)
{
__asm
{
push ebp
mov ebp, esp
push [ebp+0x1C]
push [ebp+0x18]
push [ebp+0x14]
push [ebp+0x10]
push [ebp+0x0C]
push [ebp+0x08]
mov ecx, 0x006C3A08
mov edx, 0x00519221
call edx
mov esp, ebp
pop ebp
retn
}
}
int __declspec(naked) GetUnitSize(byte* unit)
{
__asm
{
push ebp
mov ebp, esp
mov ecx, [ebp+0x08]
mov edx, [ecx]
call [edx+0x1C]
and eax, 0xFF
mov esp, ebp
pop ebp
retn
}
}
void MakeUnitNoClip(byte* unit)
{
*(byte**)(*(byte**)(unit + 0x1C0) + 5) = 0;
byte* phys = *(byte**)(unit + 0x10);
int x = phys[0];
int y = phys[1];
// clear unit radius
byte* someTable = *(byte**)(0x006B16A8);
*(byte**)(*(byte**)(unit + 0x10) + 8) = someTable;
int unitSize = zxmgr::GetUnitSize(unit);
// вот тут ¤ не помню что имел в виду. отреверсено из старого-нового сервера
if (someTable)
{
for (int i = x; i < x + unitSize; i++)
{
if (i >= 0 && i <= 255)
{
for (int j = y; j < y + unitSize; j++)
{
if (j >= 0 && j <= 255)
{
*(byte**)(someTable + ((j + 0x100) << 8) + i) = 0;
*(byte**)(someTable + ((j + 0x200) << 8) + i) = 0;
}
}
}
}
}
}
void __declspec(naked) CreateSack(const char* itemname, unsigned long x, unsigned long y, unsigned long money)
{
__asm
{
push ebp
mov ebp, esp
sub esp, 0x20
mov eax, 0x00642C2C
mov eax, [eax]
mov [ebp-0x14], eax
// allocate object
/*push 0x58
mov edx, 0x005DDF54
call edx // operator new(size)
mov [ebp-0x08], eax*/
push itemname
call ConstructItemN
mov [ebp-0x08], eax
/*push itemname
lea ecx, [ebp-0x04]
mov edx, 0x005DD8F8
call edx
lea ecx, [ebp-0x04]
push ecx
mov ecx, [ebp-0x08]
mov edx, 0x005480E3
call edx*/
// allocate sack object
push 0x24
mov edx, 0x005DDF54
call edx // operator new(size)
mov [ebp-0x0C], eax
mov ecx, [ebp-0x0C]
mov edx, 0x00551C0A
call edx
mov [ebp-0x0C], eax
push [ebp-0x08]
mov ecx, [ebp-0x0C]
mov edx, 0x00551FA3
call edx
// create the coords
push y
push x
lea ecx, [ebp-0x20]
mov edx, 0x0058A4B1
call edx
// create the sack itself
// ...
push 0
push money
push [ebp-0x0C] // sack
lea eax, [ebp-0x20]
push eax // coords
mov eax, [ebp-0x14]
mov eax, [eax+0x7C]
mov ecx, [eax+0x08]
mov edx, 0x00554460
call edx
mov esp, ebp
pop ebp
retn
}
}
void _stdcall GMLog(const char* format, ...)
{
va_list va;
va_start(va, format);
size_t count = (_vsnprintf(NULL, 0, format, va) + 1);
char* line = new char[count+1];
line[count] = 0;
_vsnprintf(line, count, format, va);
va_end(va);
std::vector<byte*> players = GetPlayers();
for (std::vector<byte*>::iterator it = players.begin(); it != players.end(); ++it)
{
byte* plr = (*it);
if (!plr) continue;
uint32_t rights = *(uint32_t*)(plr + 0x14);
if (CHECK_FLAG(rights, GMF_ANY)) zxmgr::SendMessageRaw(plr, line);
}
delete[] line;
}
void _stdcall ServerLog(const char* format, ...)
{
va_list va;
va_start(va, format);
size_t count = (_vsnprintf(NULL, 0, format, va) + 1);
char* line = new char[count+1];
line[count] = 0;
_vsnprintf(line, count, format, va);
va_end(va);
unsigned long ecxa;
unsigned long ecxb;
__asm
{
push ecx
mov ecx, esp
mov ecxa, esp
push line
mov edx, 0x005DD8F8
call edx
mov ecxb, eax
mov edx, 0x0043AA23
call edx
add esp, 4
}
delete[] line;
}
void __declspec(naked) Disconnect(byte* pptr)
{
__asm
{
push ebp
mov ebp, esp
mov eax, [ebp+0x08]
test eax, eax
jz endp
cmp dword ptr [eax+2Ch], 0 // AI
jnz endp
mov eax, [eax+0x38]
push eax
mov ecx, 0x00642C2C
mov ecx, [ecx]
mov edx, 0x004EE028
call edx
mov eax, [ebp+0x08]
xor ecx, ecx
mov cx, [eax+4]
push ecx
mov ecx, 0x006C3A08
mov edx, 0x00518544
call edx
push eax
mov ecx, 0x006C3A08
mov edx, 0x005170B6
call edx
mov ecx, 0x006C3A08
mov edx, 0x0051800F
call edx
/*mov ecx, 0x00642C2C
mov ecx, [ecx]
mov edx, [ecx]
dec edx
mov eax, [ebp+0x08]
mov [eax+0x0A50], edx
mov ecx, 0x006CDB24
mov ecx, [ecx]
mov edx, 0x00534DDD
call edx*/
endp:
mov esp, ebp
pop ebp
retn
}
}
unsigned long _stdcall GetTicks()
{
// number of milliseconds from the moment when system was started - Players[i].LastReturn...
return GetTickCount();
}
unsigned long _stdcall CreateUnit(const char* name)
{
//52931B
char* cst = new char[0x208];
unsigned long unit = 0;
__asm
{
mov ecx, [cst]
mov edx, 0x00528AEF
call edx
mov [unit], eax
test eax, eax
jz endp
lea eax, [name]
push eax
mov ecx, [unit]
mov edx, 0x0052931B
call edx
endp:
}
return unit;
}
void FreeUnit(unsigned long cptr)
{
__asm
{
mov ecx, [cptr]
mov edx, [ecx]
call [edx+0x04]
}
}
byte* GetNetworkStruct(byte* player)
{
if(!player) return NULL;
byte* retval = NULL;
unsigned long class_1 = 0;
unsigned long class_2 = 0;
__asm
{
xor ecx, ecx
mov eax, [player]
mov cx, word ptr [eax+4]
push ecx // player's order
mov ecx, 0x006C3A08 // some global struct related to players
mov edx, 0x00518544
call edx // network data?..
mov [class_1], eax // if it's NULL, then !IsConnected
test eax, eax
jz ret_0
mov ecx, [class_1]
mov edx, 0x0041F500
call edx
mov [class_2], eax // not class despite it's name
mov edx, [class_2]
and edx, 0x3FFF
push edx
mov ecx, 0x006C3A08
mov edx, 0x005185D5
call edx
mov [retval], eax // something in memory
ret_0:
}
return retval;
}
void NextMap()
{
byte* mainWnd = NULL;
__asm
{
// advance it
mov ecx, 0x006D1618
mov edx, 0x0041E7A0
call edx
mov ebx, 0x006D1634
add [ebx], 1
cmp [ebx], eax
jl nm_map_add
mov [ebx], 0
nm_map_add:
mov edx, 0x00401D90
call edx
mov [mainWnd], eax
push 0
mov ecx, 0x00642C2C
mov ecx, [ecx]
mov edx, 0x004F94C0
call edx
}
}
void PrevMap()
{
byte* mainWnd = NULL;
__asm
{
mov ecx, 0x006D1634
cmp [ecx], 0
ja pm_map_sub
mov edx, 0x006D1618
mov edx, 0x0041E7A0
call edx
test eax, eax
jg pm_map_sub
mov ecx, 0x006D1634
dec eax
mov [ecx], eax
jmp pm_map_cont
pm_map_sub:
sub [ecx], 1
pm_map_cont:
mov edx, 0x00401D90
call edx
mov [mainWnd], eax
push 0
mov ecx, 0x00642C2C
mov ecx, [ecx]
mov edx, 0x004F94C0
call edx
}
}
const char* CreateCString(const char* contents)
{
const char* cstring = NULL;
__asm
{
push [contents]
lea ecx, [cstring]
mov edx, 0x005DD8F8
call edx
}
return cstring;
}
void DeleteCString(const char* string)
{
__asm
{
lea ecx, [string]
mov edx, 0x005DD88A
call edx
}
}
byte* ConstructItemN(const char* definition)
{
if (!definition) return NULL;
return ConstructItem(definition);
}
byte* ConstructItem(std::string definition)
{
byte* item_pthis = NULL;
const char* cdefinition = CreateCString(definition.c_str());
__asm
{
lea eax, [cdefinition]
push eax