mirror of
https://github.com/sfall-team/sfall.git
synced 2026-07-27 16:52:34 -07:00
Fixed duplicate sound in the "Move Items" and "Set Timer" windows
* happens when clicking the "Done" button. Fixed crash when a critter with a powered melee/unarmed weapon runs out of ammo and there is ammo nearby. Minor code optimization to Interface.cpp, use spare ecx register instead of the stack for eax value.
This commit is contained in:
@@ -3559,6 +3559,32 @@ static __declspec(naked) void editor_design_hook() {
|
||||
}
|
||||
}
|
||||
|
||||
static __declspec(naked) void do_move_timer_hook() {
|
||||
__asm {
|
||||
cmp dword ptr ds:[FO_VAR_mouse_buttons], 0; // mouse clicked?
|
||||
jne skip;
|
||||
jmp fo::funcoffs::gsound_play_sfx_file_;
|
||||
skip:
|
||||
retn;
|
||||
}
|
||||
}
|
||||
|
||||
// Add a null pointer check to item_w_can_reload_ engine function
|
||||
static __declspec(naked) void item_w_can_reload_hack() {
|
||||
static const DWORD item_w_can_reload_Ret = 0x47890F;
|
||||
__asm {
|
||||
test eax, eax; // weapon
|
||||
jz skip;
|
||||
// overwritten engine code
|
||||
mov ecx, edx;
|
||||
mov edx, [eax + protoId];
|
||||
retn;
|
||||
skip:
|
||||
add esp, 4;
|
||||
jmp item_w_can_reload_Ret;
|
||||
}
|
||||
}
|
||||
|
||||
void BugFixes::init() {
|
||||
#ifndef NDEBUG
|
||||
LoadGameHook::OnBeforeGameClose() += PrintAddrList;
|
||||
@@ -3625,7 +3651,7 @@ void BugFixes::init() {
|
||||
SafeWrite32(0x497E8E, 0x90909090);
|
||||
// Fix for extra hidden buttons below the location list in the Status section
|
||||
MakeCall(0x497D52, PipStatus_hack, 5);
|
||||
// Fix for double click sound when selecting a location in the Status section
|
||||
// Fix for the duplicate click sound when selecting a location in the Status section
|
||||
BlockCall(0x497F52); // block gsound_play_sfx_file_ (PipStatus_)
|
||||
|
||||
// Fix for "Too Many Items" bug
|
||||
@@ -4406,6 +4432,12 @@ void BugFixes::init() {
|
||||
|
||||
// Fix to prevent out-of-bounds selection in the file list when loading a character file
|
||||
SafeWriteBatch<BYTE>(0x7C, {0x41E690, 0x41E69C}); // jle > jl (file_dialog_)
|
||||
|
||||
// Fix for the duplicate click sound for the "Done" button in the "Move Items" and "Set Timer" windows
|
||||
HookCall(0x476914, do_move_timer_hook);
|
||||
|
||||
// Fix crash when a critter with a powered melee/unarmed weapon runs out of ammo and there is ammo nearby
|
||||
MakeCall(0x47887B, item_w_can_reload_hack);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -841,21 +841,21 @@ static __declspec(naked) void wmInterfaceInit_hook() {
|
||||
__asm {
|
||||
pop retAddr;
|
||||
call fo::funcoffs::win_register_button_;
|
||||
push eax;
|
||||
mov ecx, eax; // save button ID
|
||||
mov ebx, fo::funcoffs::gsound_red_butt_release_;
|
||||
mov edx, fo::funcoffs::gsound_red_butt_press_;
|
||||
call fo::funcoffs::win_register_button_sound_func_;
|
||||
pop eax;
|
||||
mov eax, ecx; // restore
|
||||
jmp retAddr;
|
||||
}
|
||||
}
|
||||
|
||||
static __declspec(naked) void wmWorldMap_hook() {
|
||||
__asm {
|
||||
push eax;
|
||||
mov ecx, eax; // save xpos
|
||||
mov eax, 0x503E14; // 'ib1p1xx1'
|
||||
call fo::funcoffs::gsound_play_sfx_file_;
|
||||
pop eax;
|
||||
mov eax, ecx; // restore
|
||||
jmp fo::funcoffs::wmPartyInitWalking_;
|
||||
}
|
||||
}
|
||||
@@ -872,11 +872,11 @@ static __declspec(naked) void wmDrawCursorStopped_hack_hotspot() {
|
||||
static __declspec(naked) void wmTownMapInit_hack() {
|
||||
__asm {
|
||||
mov dword ptr ds:[edi + 0x672DD8], eax; // _wmTownMapButtonId
|
||||
push eax;
|
||||
mov ecx, eax; // save button ID
|
||||
mov edx, fo::funcoffs::gsound_med_butt_press_;
|
||||
xor ebx, ebx; // no button release sfx
|
||||
call fo::funcoffs::win_register_button_sound_func_;
|
||||
pop eax;
|
||||
mov eax, ecx; // restore
|
||||
retn;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user