Skip to content

Commit 17afecf

Browse files
committed
Added a safeguard to stat_level engine function
(ref. fallout2-ce/fallout2-ce#76) Unified the naming style of return addr variables for some ASM code.
1 parent 74dca89 commit 17afecf

File tree

6 files changed

+26
-17
lines changed

6 files changed

+26
-17
lines changed

sfall/Modules/BugFixes.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,7 +1054,7 @@ static __declspec(naked) void MultiHexRetargetTileFix() {
10541054
}
10551055

10561056
static __declspec(naked) void MultiHexCombatMoveFix() {
1057-
static const DWORD ai_move_steps_closer_move_object_ret = 0x42A192;
1057+
static const DWORD ai_move_steps_closer_move_object_Ret = 0x42A192;
10581058
__asm {
10591059
test [edi + flags + 1], 0x08; // is target multihex?
10601060
jnz multiHex;
@@ -1068,12 +1068,12 @@ static __declspec(naked) void MultiHexCombatMoveFix() {
10681068
retn; // tilenums are not equal, always move to tile
10691069
moveToObject:
10701070
add esp, 4;
1071-
jmp ai_move_steps_closer_move_object_ret; // move to object
1071+
jmp ai_move_steps_closer_move_object_Ret; // move to object
10721072
}
10731073
}
10741074

10751075
static __declspec(naked) void MultiHexCombatRunFix() {
1076-
static const DWORD ai_move_steps_closer_run_object_ret = 0x42A169;
1076+
static const DWORD ai_move_steps_closer_run_object_Ret = 0x42A169;
10771077
__asm {
10781078
test [edi + flags + 1], 0x08; // is target multihex?
10791079
jnz multiHex;
@@ -1087,7 +1087,7 @@ static __declspec(naked) void MultiHexCombatRunFix() {
10871087
retn; // tilenums are not equal, always run to tile
10881088
runToObject:
10891089
add esp, 4;
1090-
jmp ai_move_steps_closer_run_object_ret; // run to object
1090+
jmp ai_move_steps_closer_run_object_Ret; // run to object
10911091
}
10921092
}
10931093

@@ -2070,15 +2070,15 @@ static __declspec(naked) void inven_find_id_hack() {
20702070
}
20712071

20722072
static __declspec(naked) void op_start_gdialog_hack() {
2073-
static const DWORD op_start_gdialog_ret = 0x456F4B;
2073+
static const DWORD op_start_gdialog_Ret = 0x456F4B;
20742074
__asm {
20752075
cmp eax, -1; // check mood arg
20762076
jnz useMood;
20772077
mov eax, dword ptr [esp + 0x3C - 0x30 + 4]; // fix dialog_target (overwritten engine code)
20782078
retn;
20792079
useMood:
20802080
add esp, 4; // Destroy the return address
2081-
jmp op_start_gdialog_ret;
2081+
jmp op_start_gdialog_Ret;
20822082
}
20832083
}
20842084

sfall/Modules/DebugEditor.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,12 +298,12 @@ void RunDebugEditor() {
298298
}
299299

300300
static __declspec(naked) void dbg_error_hack() {
301-
static const DWORD dbg_error_ret = 0x453FD8;
301+
static const DWORD dbg_error_Ret = 0x453FD8;
302302
__asm {
303303
cmp ebx, 1;
304304
je hide;
305305
sub esp, 0x104;
306-
jmp dbg_error_ret;
306+
jmp dbg_error_Ret;
307307
hide:
308308
pop esi;
309309
pop ecx;

sfall/Modules/Interface.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,13 +164,13 @@ static __declspec(naked) void intface_init_hack() {
164164
}
165165

166166
static __declspec(naked) void intface_update_move_points_hack() {
167-
static const DWORD intface_update_move_points_ret = 0x45EE3E;
167+
static const DWORD intface_update_move_points_Ret = 0x45EE3E;
168168
__asm {
169169
mov eax, 16 * 9
170170
push eax;
171171
push 5;
172172
push eax;
173-
jmp intface_update_move_points_ret;
173+
jmp intface_update_move_points_Ret;
174174
}
175175
}
176176

sfall/Modules/Stats.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,22 @@ static struct StatFormula {
5252
static fo::GameObject* cCritter;
5353

5454
static __declspec(naked) void stat_level_hack() {
55+
static const DWORD stat_level_Ret = 0x4AEF93;
5556
using namespace fo;
57+
using namespace Fields;
5658
__asm {
59+
mov esi, [eax + protoId];
60+
shr esi, 24;
61+
cmp esi, OBJ_TYPE_CRITTER;
62+
jne skip; // only critters have stats
5763
mov cCritter, eax;
5864
// overwritten engine code
5965
mov esi, edx;
6066
cmp edx, STAT_current_hp;
6167
retn;
68+
skip:
69+
add esp, 4;
70+
jmp stat_level_Ret;
6271
}
6372
}
6473

sfall/Modules/SubModules/ObjectName.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ const char* __stdcall ObjectName::GetName(fo::GameObject* object) {
5151
}
5252

5353
static __declspec(naked) void critter_name_hack() {
54-
static DWORD critter_name_hack_ret = 0x42D125;
54+
static DWORD critter_name_hack_Ret = 0x42D125;
5555
using namespace fo::Fields;
5656
__asm {
5757
push ebx; // object
@@ -62,12 +62,12 @@ static __declspec(naked) void critter_name_hack() {
6262
retn;
6363
override:
6464
add esp, 4;
65-
jmp critter_name_hack_ret;
65+
jmp critter_name_hack_Ret;
6666
}
6767
}
6868

6969
static __declspec(naked) void critter_name_hack_check() {
70-
static DWORD critter_name_hack_ret = 0x42D12F;
70+
static DWORD critter_name_hack_Ret = 0x42D12F;
7171
using namespace fo::Fields;
7272
__asm {
7373
mov ecx, [ebx + scriptId];
@@ -77,7 +77,7 @@ static __declspec(naked) void critter_name_hack_check() {
7777
jne default;
7878
add esp, 4;
7979
mov eax, ds:[FO_VAR_name_critter];
80-
jmp critter_name_hack_ret;
80+
jmp critter_name_hack_Ret;
8181
checkScrIdx:
8282
mov ecx, [ebx + scriptIndex];
8383
cmp ecx, -1; // no inherited script index
@@ -86,7 +86,7 @@ static __declspec(naked) void critter_name_hack_check() {
8686
jne end;
8787
add esp, 4;
8888
mov eax, ds:[FO_VAR_name_critter];
89-
jmp critter_name_hack_ret;
89+
jmp critter_name_hack_Ret;
9090
default:
9191
mov ecx, [ebx + scriptIndex];
9292
end:

sfall/Modules/Unarmed.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ static long __fastcall get_unarmed_damage(fo::GameObject* source, fo::AttackType
309309
}
310310

311311
static __declspec(naked) void item_w_damage_hack() {
312-
static DWORD item_w_damage_hack_ret = 0x478553;
312+
static DWORD item_w_damage_hack_Ret = 0x478553;
313313
__asm {
314314
lea eax, [esp + 4]; // min_DMG
315315
lea edx, [esp + 0]; // max_DMG
@@ -320,7 +320,7 @@ static __declspec(naked) void item_w_damage_hack() {
320320
call get_unarmed_damage;
321321
mov ebx, eax; // bonus
322322
pop ecx;
323-
jmp item_w_damage_hack_ret;
323+
jmp item_w_damage_hack_Ret;
324324
}
325325
}
326326

0 commit comments

Comments
 (0)