-
Notifications
You must be signed in to change notification settings - Fork 0
/
age2_x2.cpp
2805 lines (2391 loc) · 62.9 KB
/
age2_x2.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
/*
--- X2-ADDON :: PROGRAMM-MODIFIKATIONEN ---
Semikola in Assembler-Bereichen dienen nur der korrekten Funktion der automatischen Einrückung...
Rücksprungadressen (call-Befehl!) werden vom Stack genommen bei der Ausführung, um Zugriff auf den "Original-Stack" zu haben, d.h. es müssen nicht immer erst 4 Byte vom Stackpointer abgezogen werden.
*/
/* INCLUDES */
// Codecave-Funktionen
#include "functions.h"
/* GLOBALE VARIABLEN */
// Hilfsvariable zum Löschen von Stackeinträgen.
DWORD _garbage = 0;
// Spezifiziert den Bekehrungsmodus.
// -> 0: Normal bekehren
// -> 1: Unendliche Bekehrung (Lamaismus-Technologie)
// -> 2: "Belohnung" nach Bekehrung eines Transport-/Handelsschiffs (Prise-Technologie)
// -> 3: "Belohnung" nach Bekehrung eines Kriegsschiffs (Prise-Technologie)
// Auf diese Variable wird nur innerhalb eines Funktionsdurchlaufs zugegriffen, es sind also keine Zugriffskonflikte zu erwarten.
BYTE _conversionModeFlag = 0;
// Gibt an, ob der Bekehrungswiderstandsfaktor für bestimmte Schiffstypen angewandt werden soll (Finkennetze-Technologie).
// -> 0: Nicht anwenden
// -> 1: Zwischenwert, noch nicht anwenden
// -> 2: Anwenden
BYTE _conversionResistForSpecificShips;
// Sprungziele.
DWORD _funcUnknown1 = 0x004C05B0;
DWORD _funcGetString = 0x00562CB0; // Ruft offenbar einen String aus den Language-DLLs ab?
DWORD _funcFormatString = 0x0061442B; // Scheint zwei Strings mithilfe eines Formatstrings zu kombinieren?
DWORD _funcComboBoxCreateEntry1 = 0x00550840; // Erstellt einen Eintrag in einer gegebenen ComboBox?
DWORD _funcComboBoxCreateEntry2 = 0x00550870; // Erstellt einen Eintrag in einer gegebenen ComboBox?
DWORD _funcUnknown2 = 0x00457F90;
DWORD _funcFloatToInt = 0x006139E4; // Konvertiert den obersten Float in der FPU in einen Int-Wert in EAX.
DWORD _funcUnknown3 = 0x00403996;
DWORD _funcUnknown4 = 0x004038ED;
DWORD _funcUnknown5 = 0x00403A2E;
DWORD _funcUnknown6 = 0x0040244D;
DWORD _funcCreateButton = 0x00520620; // Erstellt einen neuen Einheiten-Interface-Button.
// Zeitalter-Konstanten.
float RESEARCH_ID_DUNKEL = 105.0f;
float RESEARCH_ID_FEUDAL = 101.0f;
float RESEARCH_ID_RITTER = 102.0f;
float RESEARCH_ID_IMPERIAL = 103.0f;
float RESEARCH_ID_RENAISSANCE = 104.0f;
// Zeitalter-Konstanten für Zeitalter-Ressource.
float AGE_RESOURCE_DUNKEL = 0.0f;
float AGE_RESOURCE_FEUDAL = 1.0f;
float AGE_RESOURCE_RITTER = 2.0f;
float AGE_RESOURCE_IMPERIAL = 3.0f;
float AGE_RESOURCE_RENAISSANCE = 4.0f;
// Bekehrungszeit-Summand für Finkennetze-Technologie.
float CONVERSION_TIME_SUMMAND_FINK_NETS = 6.0f;
// Hilfskonstanten für Floating-Point-Operationen.
float FLOAT_0 = 0.0f;
float FLOAT_1 = 1.0f;
// Vergrößerter Puffer für Language-DLL-Strings.
static char _newLanguageDllStringBuffer[768];
// Die Adressen, wo das Hauptspiel und der UserPatch die Adresse des Language-DLL-String-Puffers fest einprogrammiert haben => müssen alle ersetzt werden
// Die Adressen sind aus Gründen der einfacheren Aktualisierbarkeit allesamt 1 Byte zu klein (Opcode).
DWORD _hardcodedLanguageDllStringBufferAddresses[] =
{
// age2_x1
0x00562CE9,
0x00562CF4,
// UserPatch
0x007B329B,
0x007B32B9,
0x007B330A,
0x007C4397,
0x007C43B0,
0x007C7064,
0x007C70D3,
0x007C70E3,
0x007C7232,
0x007C7257,
0x007C7268,
0x007C728D,
0x007C729E,
0x007C72C3,
0x007C72ED,
0x007C73A1,
0x007C73B0,
0x007C73F9,
0x007C743F,
0x007C745C,
0x007C747D,
0x007C7B3B,
0x007C800A,
0x007C8014,
0x007C8254,
0x007C8273,
0x007C8285,
0x007CBF70,
0x007CBF7E,
0x007D8FB4,
0x007D8FBE,
0x007D8FCF,
0x007E25E0,
0x007E794B,
0x007E797D,
0x007EB449,
0x007EB45C,
0x007EB5A5,
0x007EDEED,
0x007EDF0B,
0x007EDF21
};
/* CODECAVE-FUNKTIONEN */
// Codecave-Funktion.
// Erweitert die Selbstheilung des Berserkers auf weitere Einheiten.
DWORD _retAddr_ExtendSelfHealing = 0;
__declspec(naked) void CC_ExtendSelfHealing()
{
__asm
{
// Rücksprungadresse vom Stack holen und sichern
pop _retAddr_ExtendSelfHealing;
// Sicherheitshalber EAX sichern
push eax;
// Berserker
cmp ax, 692;
je id_found;
// Elite-Berserker
cmp ax, 694;
je id_found;
// Amazone
cmp ax, 903;
je id_found;
// Drachentöter
cmp ax, 966;
je id_found;
// Shaolin
cmp ax, 930;
je id_found;
cmp ax, 1123;
je id_found;
// Elite-Shaolin
cmp ax, 932;
je id_found;
cmp ax, 1124;
je id_found;
// Für Upgrade-Einheiten ist ID2 interessant
mov ax, [edx + 0x12];
// Selbstheilender Mönch
cmp ax, 1088;
je id_found;
// ID nicht gefunden, al auf 0 setzen
xor al, al;
// Zum Ende springen
jmp end;
id_found:
// al auf 1 setzen, d.h. ID gefunden
mov al, 1;
end:
// Ergebnisvergleich von al durchführen (Gleichheit => ID gefunden)
cmp al, 0x01;
// EAX wiederherstellen
pop eax;
// Rücksprungadresse wieder auf den Stack legen
push _retAddr_ExtendSelfHealing;
// Fertig
ret;
};
}
// Codecave-Funktion.
// Fügt dem Shaolin den Heil-Button hinzu.
DWORD _retAddr_CreateShaolinHealingButton = 0;
__declspec(naked) void CC_CreateShaolinHealingButton()
{
__asm
{
// Rücksprungadresse vom Stack holen und sichern
pop _retAddr_CreateShaolinHealingButton;
// ID holen
mov eax, [ecx + 0x08];
mov ax, [eax + 0x10];
// Shaolin?
cmp ax, 930;
je create_shaolin_healing_button;
cmp ax, 932;
je create_shaolin_healing_button;
cmp ax, 1123;
je create_shaolin_healing_button;
cmp ax, 1124;
jne end;
create_shaolin_healing_button:
// Button erstellen
push 0x00;
push 0x00;
push 0x00;
push 0x00;
push 0x00;
push 0xFFFFFFFF;
push 4924; // Hilfetext
push 0x00;
push 28; // Code
push 15; // Heilen-Icon
push 14; // Unten rechts in der Ecke platzieren
mov eax, [esi + 0x00001020];
push eax;
mov edi, ecx;
mov ecx, esi;
call _funcCreateButton;
mov ecx, edi;
end:
// Überschriebene Befehle ausführen
mov eax, [esp + 0x20];
xor edi, edi;
// Rücksprungadresse wieder auf den Stack legen
push _retAddr_CreateShaolinHealingButton;
// Fertig
ret;
};
}
// Codecave - Funktion.
// Erlaubt die Ausführung der Heiltätigkeit beim Shaolin.
DWORD _retAddr_EnableShaolinHealingAbility = 0;
__declspec(naked) void CC_EnableShaolinHealingAbility()
{
__asm
{
// Rücksprungadresse vom Stack holen und sichern
pop _retAddr_EnableShaolinHealingAbility;
// Überschriebenen Sprung durchführen
je end;
// Shaolin?
cmp word ptr[ecx + 0x10], 930;
je end;
cmp word ptr[ecx + 0x10], 932;
je end;
cmp word ptr[ecx + 0x10], 1123;
je end;
cmp word ptr[ecx + 0x10], 1124;
je end;
no_match:
// Zu Standard-Behandlung springen
push 0x00434CDF;
ret;
end:
// Rücksprungadresse wieder auf den Stack legen
push _retAddr_EnableShaolinHealingAbility;
// Fertig
ret;
};
}
// Codecave - Funktion.
// Sorgt dafür, dass der Shaolin trotz Heilfunktion weiterhin Kämpfen zugewiesen kann.
DWORD _retAddr_KeepShaolinFightingAbility = 0;
__declspec(naked) void CC_KeepShaolinFightingAbility()
{
__asm
{
// Rücksprungadresse vom Stack holen und sichern
pop _retAddr_KeepShaolinFightingAbility;
// ID holen
mov ecx, [esp + 0x30];
mov cx, [ecx + 0x10];
// Shaolin?
cmp cx, 930;
je end;
cmp cx, 932;
je end;
cmp cx, 1123;
je end;
cmp cx, 1124;
je end;
no_match:
// Programmverlauf normal fortsetzen, überschriebene Befehle ausführen
xor ecx, ecx;
movsx esi, [eax + 0x08];
push _retAddr_KeepShaolinFightingAbility;
ret;
end:
// Register in richtigen Zustand bringen
mov ecx, [esp + 0x30];
movsx ax, [ecx + 0x16];
mov ebp, [esp + 0x2C];
// Zu anderweitiger Behandlung springen
push 0x00434CDF;
// Fertig
ret;
};
}
// Codecave-Funktion.
// Setzt das Heilflag beim Shaolin und löscht das Angriffsflag bei den Transportkutschen.
DWORD _retAddr_SetShaolinHealingFlagAndRemoveTransportCartAttackFlag = 0;
__declspec(naked) void CC_SetShaolinHealingFlagAndRemoveTransportCartAttackFlag()
{
__asm
{
// Rücksprungadresse vom Stack holen und sichern
pop _retAddr_SetShaolinHealingFlagAndRemoveTransportCartAttackFlag;
// Shaolin?
cmp word ptr[ebx + 0x10], 930;
je add_healing_flag;
cmp word ptr[ebx + 0x10], 932;
je add_healing_flag;
cmp word ptr[ebx + 0x10], 1123;
je add_healing_flag;
cmp word ptr[ebx + 0x10], 1124;
je add_healing_flag;
// Transportkutsche?
cmp word ptr[ebx + 0x10], 954;
je remove_attack_flag;
cmp word ptr[ebx + 0x10], 1076;
jne end;
remove_attack_flag:
// Flag löschen
and dl, 0xFE;
// Restliche Abfragen überspringen, treffen eh nicht mehr zu
push 0x0045AD59;
ret;
add_healing_flag:
// Flag setzen
or dl, 0x10;
// Restliche Abfragen überspringen
push 0x0045AD59;
ret;
end:
// Überschriebenen Befehl ausführen
cmp word ptr[ebx + 0x10], 0x0D;
// Rücksprungadresse wieder auf den Stack legen
push _retAddr_SetShaolinHealingFlagAndRemoveTransportCartAttackFlag;
// Fertig
ret;
};
}
// Codecave-Funktion.
// Führt beim Shaolin bei gescheiteter Auto-Attack-Zielfindung die Auto-Heal-Zielfindung aus.
DWORD _retAddr_EnableShaolinAutoHeal = 0;
__declspec(naked) void CC_EnableShaolinAutoHeal()
{
__asm
{
// Rücksprungadresse vom Stack holen und sichern
pop _retAddr_EnableShaolinAutoHeal;
// Auto-Attack-Rückgabewert -1 (keine Einheit gefunden)?
cmp edi, -1;
jne end;
// ID holen
mov eax, dword ptr[esi + 0x04]; // this->UnitInstance
mov eax, dword ptr[eax + 0x08]; // this->UnitInstance->UnitData
mov ax, word ptr[eax + 0x10]; // this->UnitInstance->UnitData->ID1
// Shaolin?
cmp ax, 930;
je run_auto_heal;
cmp ax, 932;
je run_auto_heal;
cmp ax, 1123;
je run_auto_heal;
cmp ax, 1124;
jne end;
run_auto_heal:
// VTable-Adresse austauschen (andere Klasse)
mov dword ptr[esi], 0x00638DE8;
// Entsprechende virtuelle Funktion für automatische Heilung aufrufen
push 1;
mov ecx, esi;
mov edx, [ecx];
call dword ptr[edx + 0xDC];
// VTable-Adresse zurücksetzen, falls keine Heilung zustandegekommen
cmp eax, 6; // 5, falls keine Heilung
je return_function;
mov dword ptr[esi], 0x0063919C;
return_function:
// Rückgabewert liegt bereits in EAX
pop edi;
pop esi;
add esp, 0x0C;
retn 4;
end:
// Überschriebenen Befehl ausführen
cmp dword ptr[esi + 0x28], 0x02C7;
// Rücksprungadresse wieder auf den Stack legen
push _retAddr_EnableShaolinAutoHeal;
// Fertig
ret;
};
}
// Codecave-Funktion.
// Überschreibt einen Patch vom UserPatch. Sorgt für einen korrekten Zielfindungsradius beim Heilen, verhindert jedoch das Weglaufen des Shaolins.
DWORD _retAddr_PatchShaolinAutoHealDistanceCalculation = 0;
__declspec(naked) void CC_PatchShaolinAutoHealDistanceCalculation()
{
__asm
{
// Rücksprungadresse vom Stack holen und sichern
pop _retAddr_PatchShaolinAutoHealDistanceCalculation;
// Einheiteninstanz abrufen
mov ecx, dword ptr[esi + 0x04]; // this->UnitInstance
// Grunddistanz laden (Ressource #90 der Spieler-Civ)
mov eax, dword ptr[ecx + 0x0C]; // this->UnitInstance->PlayerData
mov eax, dword ptr[eax + 0xA8]; // this->UnitInstance->PlayerData->CivResources
fld dword ptr[eax + 360]; // this->UnitInstance->PlayerData->CivResources[90] (float-Array)
// ID holen
mov eax, dword ptr[ecx + 0x08]; // this->UnitInstance->UnitData
mov ax, word ptr[eax + 0x10]; // this->UnitInstance->UnitData->ID1
// Shaolin?
cmp ax, 930;
je end;
cmp ax, 932;
je end;
cmp ax, 1123;
je end;
cmp ax, 1124;
je end;
add_walk_range:
// Extra-Reichweite zum "Hinlaufen" addieren
fadd FLOAT_1;
end:
// Reichweitenwert speichern
fstp dword ptr[esp + 0x18];
// Überschriebenen Befehl ausführen
mov ecx, esi;
// Rücksprungadresse wieder auf den Stack legen
push _retAddr_PatchShaolinAutoHealDistanceCalculation;
// Fertig
ret;
};
}
// Codecave-Funktion.
// Führt beim Shaolin bei gescheiteter Auto-Attack-Zielfindung die Auto-Heal-Zielfindung aus.
// TODO: ID-Test notwendig? Erstmal auskommentiert, bei Fehlern wieder einkommentieren.
DWORD _retAddr_PatchShaolinHealAssignmentBehaviour = 0;
__declspec(naked) void CC_PatchShaolinHealAssignmentBehaviour()
{
__asm
{
// Rücksprungadresse vom Stack holen und sichern
pop _retAddr_PatchShaolinHealAssignmentBehaviour;
// ID holen
mov ecx, dword ptr[esi + 0x08]; // this->UnitInstance (in ECX, da für VTable-Austausch noch notwendig)
/*
mov eax, dword ptr[ecx + 0x08]; // this->UnitInstance->UnitData
mov ax, word ptr[ecx + 0x10]; // this->UnitInstance->UnitData->ID1
// Shaolin?
cmp ax, 930;
je set_behaviour_vtable;
cmp ax, 932;
je set_behaviour_vtable;
cmp ax, 1123;
je set_behaviour_vtable;
cmp ax, 1124;
jne end;
*/
set_behaviour_vtable:
// VTable-Adresse austauschen (andere Klasse)
mov eax, dword ptr[ecx + 0x6C];
mov dword ptr[eax], 0x00638DE8;
end:
// Überschriebenene Befehle ausführen
mov ecx, dword ptr[esp + 0x0C];
mov eax, esi;
// Rücksprungadresse wieder auf den Stack legen
push _retAddr_PatchShaolinHealAssignmentBehaviour;
// Fertig
ret;
};
}
// Codecave-Funktion.
// Sorgt dafür, dass der Shaolin bei abgebrochener Heilung (Einheit hat sich entfernt o.ä.) wieder in den korrekten Ausgangszustand wechselt.
DWORD _retAddr_EnableShaolinAutoHealEnd = 0;
__declspec(naked) void CC_EnableShaolinAutoHealEnd()
{
__asm
{
// Rücksprungadresse vom Stack holen und sichern
pop _retAddr_EnableShaolinAutoHealEnd;
// ID holen
mov edx, dword ptr[esi + 0x04]; // this->UnitInstance
mov edx, dword ptr[edx + 0x08]; // this->UnitInstance->UnitData
mov dx, word ptr[edx + 0x10]; // this->UnitInstance->UnitData->ID1
// Shaolin?
cmp dx, 930;
je end_auto_heal;
cmp dx, 932;
je end_auto_heal;
cmp dx, 1123;
je end_auto_heal;
cmp dx, 1124;
jne default_function_call;
end_auto_heal:
// VTable-Adresse austauschen (andere Klasse)
//mov dword ptr[esi], 0x00638DE8;
// Überschriebenen Funktionsaufruf durchführen
call dword ptr[eax + 0xD8];
// VTable-Adresse zurücksetzen, falls keine Einheit mehr geheilt wird
mov edx, dword ptr[esi + 0x34]; // this->InteractionUnitInstanceId
cmp edx, -1;
jne end;
mov dword ptr[esi], 0x0063919C;
// Fertig, zum Ende
jmp end;
default_function_call:
// Überschriebenen Funktionsaufruf durchführen
call dword ptr[eax + 0xD8];
end:
// Rücksprungadresse wieder auf den Stack legen
push _retAddr_EnableShaolinAutoHealEnd;
// Fertig
ret;
};
}
// Codecave-Funktion.
// Ändert die ID-Abfrage zur Reliquienablage im Kloster (EAX-Version).
DWORD _retAddr_UpdateRelicDepositId1 = 0;
__declspec(naked) void CC_UpdateRelicDepositId1()
{
__asm
{
// Rücksprungadresse vom Stack holen und sichern
pop _retAddr_UpdateRelicDepositId1;
// Basiseinheit Steinkreis?
cmp word ptr[eax + 0x14], 866;
// Rücksprungadresse wieder auf den Stack legen
push _retAddr_UpdateRelicDepositId1;
// Fertig
ret;
};
}
// Codecave-Funktion.
// Ändert die ID-Abfrage zur Reliquienablage im Kloster (ECX-Version).
DWORD _retAddr_UpdateRelicDepositId2 = 0;
__declspec(naked) void CC_UpdateRelicDepositId2()
{
__asm
{
// Rücksprungadresse vom Stack holen und sichern
pop _retAddr_UpdateRelicDepositId2;
// Basiseinheit Steinkreis?
cmp word ptr[ecx + 0x14], 866;
// Rücksprungadresse wieder auf den Stack legen
push _retAddr_UpdateRelicDepositId2;
// Fertig
ret;
};
}
// Codecave-Funktion.
// Ändert die ID-Abfrage zur Reliquienablage im Kloster (EDX-Version).
DWORD _retAddr_UpdateRelicDepositId3 = 0;
__declspec(naked) void CC_UpdateRelicDepositId3()
{
__asm
{
// Rücksprungadresse vom Stack holen und sichern
pop _retAddr_UpdateRelicDepositId3;
// Basiseinheit Steinkreis?
cmp word ptr[edx + 0x14], 866;
// Rücksprungadresse wieder auf den Stack legen
push _retAddr_UpdateRelicDepositId3;
// Fertig
ret;
};
}
// Codecave-Funktion.
// Ändert die ID-Abfrage zur Reliquienablage im Kloster (Cursor-Abfrage).
DWORD _retAddr_UpdateRelicDepositId4 = 0;
__declspec(naked) void CC_UpdateRelicDepositId4()
{
__asm
{
// Rücksprungadresse vom Stack holen und sichern
pop _retAddr_UpdateRelicDepositId4;
// Einheit Steinkreis?
cmp ebx, 866;
je found;
// Einheit Kloster?
cmp ebx, 30;
je found;
cmp ebx, 31;
je found;
cmp ebx, 32;
je found;
cmp ebx, 104;
jne not_found;
found:
// Gefunden, direkt zu Cursorzuweisung hinspringen
push 0x0045B851;
ret;
not_found:
// Rücksprungadresse wieder auf den Stack legen
push _retAddr_UpdateRelicDepositId4;
// Fertig
ret;
};
}
// Codecave-Funktion.
// Ändert die Basis-ID des Reliquiengold-Gebäudes vom Kloster zum Steinkreis. Eine direkte Änderung der ID ist nicht möglich, da die neue ID 1 Byte breiter ist.
// TODO: Nach ID-Finalisierung vielleicht nicht mehr? Wäre gut, da evtl. hohe Performance-Auswirkung.
__declspec(naked) void CC_UpdateRelicDepositId5()
{
__asm
{
// Überschriebenen Befehl mit korrekter ID ausführen
mov eax, dword ptr[esi + 0x08];
cmp word ptr[eax + 0x10], 866;
ret;
};
}
// Codecave-Funktion.
// Aktiviert die zweite Gebäude-Seite für gegebene Gebäude.
DWORD _retAddr_EnableSecondBuildingPage = 0;
__declspec(naked) void CC_EnableSecondBuildingPage()
{
__asm
{
// Rücksprungadresse vom Stack holen und sichern
pop _retAddr_EnableSecondBuildingPage;
// Hafen
hafen:
cmp word ptr[edx + 0x10], 45;
jne kloster;
// Zeitalter-ID abrufen
mov eax, [edi + 0x0C];
mov ecx, [eax + 0x000000A8];
fld dword ptr[ecx + 0x18];
// Zeitalter prüfen
fcomp AGE_RESOURCE_DUNKEL;
fnstsw ax;
test ah, 0x41;
jne end;
// Button erstellen!
jmp create_button;
// Kloster/Steinkreis
kloster:
cmp word ptr[edx + 0x10], 866;
jne festung;
// Zeitalter-ID abrufen
mov eax, [edi + 0x0C];
mov ecx, [eax + 0x000000A8];
fld dword ptr[ecx + 0x18];
// Zeitalter prüfen
fcomp AGE_RESOURCE_RITTER;
fnstsw ax;
test ah, 0x41;
jne end;
// Button erstellen!
jmp create_button;
// Festung
festung:
cmp word ptr[edx + 0x10], 82;
jne end;
// Zeitalter-ID abrufen
mov eax, [edi + 0x0C];
mov ecx, [eax + 0x000000A8];
fld dword ptr[ecx + 0x18];
// Zeitalter prüfen
fcomp AGE_RESOURCE_IMPERIAL;
fnstsw ax;
test ah, 0x41;
jne end;
// Button erstellen
create_button:
push 0x00;
push 0x00;
mov edx, [esi + 0x00001020];
push 0x00;
push 0x00;
push 0x00;
push 0xFF;
push 0x00001336; // Hilfetext
push 0x00;
push 0x000000AA;
push 0x20; // Pfeil-Icon
push 0x0E; // Unten rechts in der Ecke platzieren
push edx;
mov ecx, esi;
call _funcCreateButton;
end:
// Rücksprungadresse wieder auf den Stack legen
push _retAddr_EnableSecondBuildingPage;
// Fertig
ret;
};
}
// Codecave-Funktion.
// Aktiviert die Ausladefunktion für die Transportkutsche. Das Verhalten ist dasselbe wie bei Rammen, jedoch mit anderem Icon.
DWORD _retAddr_TransportCartUnloadIcon = 0;
__declspec(naked) void CC_TransportCartUnloadIcon()
{
__asm
{
// Rücksprungadresse vom Stack holen und sichern
pop _retAddr_TransportCartUnloadIcon;
mov edx, [esp + 0x14];
xor ebx, ebx;
mov eax, [edx + 0x00000268];
test eax, eax;
jle cancel;
mov eax, edx;
lea edi, [eax + 0x000001C4];
begin:
mov ecx, [edi];
test ecx, ecx;
je label1;
mov edx, [ecx + 0x08];
// Transportschiff-ID?
cmp word ptr[edx + 0x10], 545;
je branch_ship;
// Transportkutsche-ID?
cmp word ptr[edx + 0x10], 954;
je branch_cart;
cmp word ptr[edx + 0x10], 1076;
je branch_cart;
jmp label1;
// Block für das Transportschiff
branch_ship:
mov eax, [ecx];
call dword ptr[eax + 0x00000218]; // Prüft, ob Schiff Ladung hat
test eax, eax;
jg create_button_ship;
jmp label1;
// Block für die Transportkutsche
branch_cart:
mov eax, [ecx];
call dword ptr[eax + 0x00000218]; // Prüft, ob Kutsche Ladung hat
test eax, eax;
jg create_button_cart;
label1:
mov ecx, [esp + 0x14];
inc ebx;
add edi, 0x04;
cmp ebx, [ecx + 0x00000268];
jnge begin;
jmp cancel;
// Transportschiff-Button erstellen
create_button_ship:
mov ecx, [esp + 0x18];
push 0x00;
push 0x00;
push 0x00;
push 0x00;
push 0x00;
push 0xFF;
push 4907;
mov eax, ecx;
push 0x00;
inc ecx;
push 0x07;
push 0x11;
jmp end;
// Transportkutsche-Button erstellen
create_button_cart:
mov ecx, [esp + 0x18];
push 0x00;
push 0x00;
push 0x00;
push 0x00;
push 0x00;
push 0xFF;
push 4948;
mov eax, ecx;
push 0x00;
inc ecx;
push 0xAC; // Command-Code
push 0x45; // Icon-ID
jmp end;
// Abbrechen (falsche ID o.ä.)
cancel:
mov _retAddr_TransportCartUnloadIcon, 0x00525FDF;
end:
// Rücksprungadresse wieder auf den Stack legen
push _retAddr_TransportCartUnloadIcon;
// Fertig
ret;
};
}
// Codecave-Funktion.
// Aktiviert das Steg-Symbol, wenn eine Einheit in die Kutsche geladen werden kann.
DWORD _retAddr_TransportCartLoadCommand = 0;
__declspec(naked) void CC_TransportCartLoadCommand()
{
__asm
{
// Rücksprungadresse vom Stack holen und sichern
pop _retAddr_TransportCartLoadCommand;
// Rammbock?
cmp ax, 35;
je end;
// Sturmbock?
cmp ax, 422;
je end;
// Belagerungsramme?
cmp eax, 548;
je end;
// Kleine Transportkutsche?
cmp ax, 954;
je end;
// Große Transportkutsche?
cmp ax, 1076;
je end;
// Nicht gefunden, woanders hinspringen
mov _retAddr_TransportCartLoadCommand, 0x0045B29B;
end:
// Rücksprungadresse wieder auf den Stack legen
push _retAddr_TransportCartLoadCommand;
// Fertig
ret;
};
}
// Codecave-Funktion.
// Unterdrückt die Auto-Attack bei den Transportkutschen.
__declspec(naked) void CC_DisableTransportCartAutoAttack()
{
__asm
{
// Rücksprungadresse vom Stack holen und verwerfen
pop _garbage;
// Einheiten-ID abrufen
mov eax, [esi + 0x04]; // this->UnitInstance
mov eax, [eax + 0x08]; // this->UnitInstance->UnitData
// Kleine Transportkutsche
cmp word ptr[eax + 0x10], 954; // this->UnitInstance->UnitData->ID1
je disable_auto_attack;
// Große Transportkutsche
cmp word ptr[eax + 0x10], 1076;
jne end;
disable_auto_attack:
// Überschriebenen Befehl ausführen
mov[esp + 0x14], 4;
// Restliche Anweisungen überspringen
push 0x005EFA7B;
ret;
end:
// Überschriebene Befehle ausführen
mov eax, 4;
cmp edi, eax;
mov[esp + 0x14], eax;
// Fertig
push 0x005EF6F3;
ret;
};
}
// Codecave-Funktion.
//
DWORD _retAddr_Renaissance1 = 0;