mirror of
https://github.com/sfall-team/sfall.git
synced 2026-07-27 16:52:34 -07:00
Fixed issues related to negative weapon ammo
(ref. alexbatalov/fallout2-ce#443) Fixed freeze when reloading an overloaded weapon via the interface bar.
This commit is contained in:
@@ -211,6 +211,7 @@
|
||||
#define FO_VAR_main_window 0x5194F0
|
||||
#define FO_VAR_main_window_buf 0x5194F4
|
||||
#define FO_VAR_map_elevation 0x519578
|
||||
#define FO_VAR_map_flags 0x631D7C
|
||||
#define FO_VAR_map_global_vars 0x51956C
|
||||
#define FO_VAR_map_name 0x631D58
|
||||
#define FO_VAR_map_number 0x631D88
|
||||
|
||||
@@ -136,6 +136,7 @@ VAR_(main_ctd, fo::ComputeAttackResult)
|
||||
VAR_(main_death_voiceover_done, DWORD)
|
||||
VAR_(main_window, DWORD)
|
||||
VAR_(map_elevation, DWORD)
|
||||
VAR_(map_flags, DWORD)
|
||||
VAR_(map_global_vars, long*) // array
|
||||
VAR_(map_number, DWORD)
|
||||
VAR_(master_db_handle, fo::PathNode*)
|
||||
|
||||
@@ -246,7 +246,10 @@ static __declspec(naked) void item_w_mp_cost_replacement() {
|
||||
|
||||
// Simplified implementation of item_w_curr_ammo_ engine function
|
||||
long __fastcall Items::item_w_curr_ammo(fo::GameObject* item) {
|
||||
if (item) return item->item.charges;
|
||||
if (item) {
|
||||
if (item->item.charges < 0) item->item.charges = 0; // fix negative ammo
|
||||
return item->item.charges;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -4329,6 +4329,10 @@ void BugFixes::init() {
|
||||
HookCall(0x43C9A0, perks_dialog_hook_tag);
|
||||
HookCall(0x43C9E2, perks_dialog_hook_mutate);
|
||||
HookCall(0x4329D1, editor_design_hook); // reset flags on exiting the character screen
|
||||
|
||||
// Fix to prevent the game from hanging when reloading a weapon overloaded with ammo via the interface bar
|
||||
SafeWrite8(0x4787A2, 0x8D); // jz > jge (item_w_try_reload_)
|
||||
SafeWrite8(0x45F5BD, 0x7E); // jz > jle (intface_toggle_item_state_)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1050,6 +1050,8 @@ static __declspec(naked) void intface_update_ammo_lights_hack() {
|
||||
mov eax, 70; // 70 - full ammo bar
|
||||
cmp edx, eax;
|
||||
cmovg edx, eax;
|
||||
cmp edx, ebx; // ebx = 0 (empty ammo bar)
|
||||
cmovl edx, ebx;
|
||||
mov eax, ammoBarXPos; // overwritten engine code
|
||||
retn;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user