From 8bb660ff1138b0bc400b5f63167513cc3308fe49 Mon Sep 17 00:00:00 2001 From: NovaRain Date: Sat, 22 Feb 2020 15:37:36 +0800 Subject: [PATCH] Fixed the player's money not being displayed after barter (#286) Restored TownMapHotkeysFix option. Updated version number. --- artifacts/ddraw.ini | 5 ++- sfall/BugFixes.cpp | 72 +++++++++++++++++++++++++++++++++++++++++-- sfall/FalloutEngine.h | 1 + sfall/Interface.cpp | 18 ----------- sfall/version.h | 6 ++-- 5 files changed, 77 insertions(+), 25 deletions(-) diff --git a/artifacts/ddraw.ini b/artifacts/ddraw.ini index 2b785c23..51b7608f 100644 --- a/artifacts/ddraw.ini +++ b/artifacts/ddraw.ini @@ -1,5 +1,5 @@ ;sfall configuration settings -;v3.8.23 +;v3.8.24 [Main] ;Change to 1 if you want to use command line args to tell sfall to use another ini file. @@ -315,6 +315,9 @@ DamageFormula=0 ;Prevents you from using 0 to escape from dialogue at any time. DialogueFix=1 +;Prevents you from using number keys to enter unvisited areas on a town map +TownMapHotkeysFix=1 + ;Set to 1 to disable the horrigan encounter DisableHorrigan=0 diff --git a/sfall/BugFixes.cpp b/sfall/BugFixes.cpp index ddb77509..ea0ce9f7 100644 --- a/sfall/BugFixes.cpp +++ b/sfall/BugFixes.cpp @@ -2506,10 +2506,70 @@ look: } } +static void FixCreateBarterButton() { + const long artID = OBJ_TYPE_INTRFACE << 24; + *(BYTE**)_dialog_red_button_up_buf = ArtPtrLockData(artID | 96, 0 ,0, (DWORD*)_dialog_red_button_up_key); + *(BYTE**)_dialog_red_button_down_buf = ArtPtrLockData(artID | 95, 0 ,0, (DWORD*)_dialog_red_button_down_key); +} + +static void __declspec(naked) gdialog_window_create_hook() { + __asm { + call art_ptr_unlock_; + cmp dword ptr ds:[_dialog_red_button_down_buf], 0; + jz FixCreateBarterButton; + retn; + } +} + +static void __declspec(naked) gdialog_bk_hook() { + __asm { + xor ebp, ebp; + mov eax, ds:[_curr_font_num]; + cmp eax, 101; + je skip0; + mov ebp, eax; + mov eax, 101; // set font + call text_font_; +skip0: + mov eax, ds:[_obj_dude]; + call item_caps_total_; + push eax; // caps + push 0x502B1C; // fmt: $%d + lea eax, textBuf; + push eax; + call sprintf_; + add esp, 3 * 4; + lea eax, textBuf; + call ds:[_text_width]; + mov edx, 60; // max width + mov ebx, eax; // ebx - textWidth + cmp eax, edx; + cmova ebx, edx; + movzx eax, ds:[_GreenColor]; + or eax, 0x7000000; // print flags + push eax; + mov eax, ebx; + mov ecx, 38; // x + push 36; // y + sar eax, 1; + sub ecx, eax; // x shift + lea edx, textBuf; + mov eax, ds:[_dialogueWindow]; + call win_print_; + test ebp, ebp; + jz skip1; + mov eax, ebp; + call text_font_; +skip1: + mov eax, edi; + jmp win_show_; + } +} + void BugFixesInit() { #ifndef NDEBUG - if (isDebug && (iniGetInt("Debugging", "BugFixes", 1, ddrawIniDef) == 0)) return; + if (iniGetInt("Debugging", "BugFixes", 1, ddrawIniDef) == 0) return; #endif // Fix vanilla negate operator for float values @@ -3114,11 +3174,11 @@ void BugFixesInit() MakeCall(0x4C03AA, wmWorldMap_hack, 2); // Fix to prevent using number keys to enter unvisited areas on a town map - //if (GetConfigInt("Misc", "TownMapHotkeysFix", 1)) { + if (GetConfigInt("Misc", "TownMapHotkeysFix", 1)) { dlog("Applying town map hotkeys patch.", DL_INIT); MakeCall(0x4C495A, wmTownMapFunc_hack, 1); dlogr(" Done", DL_INIT); - //} + } // Fix for combat not ending automatically when there are no hostile critters MakeCall(0x422CF3, combat_should_end_hack); @@ -3161,4 +3221,10 @@ void BugFixesInit() SafeWrite8(0x4123F2, 0x64); // protoId BlockCall(0x4123F3); MakeCall(0x4123F8, action_loot_container_hack, 1); + + // Fix for the barter button on the dialog window not animating until after leaving the barter screen + HookCall(0x44A77C, gdialog_window_create_hook); + + // Fix for the player's money not being displayed in the dialog window after leaving the barter/combat control interface + HookCall(0x447ACD, gdialog_bk_hook); } diff --git a/sfall/FalloutEngine.h b/sfall/FalloutEngine.h index be07dca7..c9820042 100644 --- a/sfall/FalloutEngine.h +++ b/sfall/FalloutEngine.h @@ -79,6 +79,7 @@ #define _dialogue_state 0x518714 #define _dialogue_switch_mode 0x518718 #define _dialogueBackWindow 0x518740 +#define _dialogueWindow 0x518744 #define _display_win 0x631E4C #define _displayMapList 0x41B560 #define _dropped_explosive 0x5190E0 diff --git a/sfall/Interface.cpp b/sfall/Interface.cpp index 5dd8bbad..42a4c46d 100644 --- a/sfall/Interface.cpp +++ b/sfall/Interface.cpp @@ -511,21 +511,6 @@ void InterfaceGmouseHandleHook() { HookCall(0x44C018, gmouse_handle_event_hook); // replaces hack function from HRP } -static void FixCreateBarterButton() { - const long artID = OBJ_TYPE_INTRFACE << 24; - *(BYTE**)_dialog_red_button_up_buf = ArtPtrLockData(artID | 96, 0 ,0, (DWORD*)_dialog_red_button_up_key); - *(BYTE**)_dialog_red_button_down_buf = ArtPtrLockData(artID | 95, 0 ,0, (DWORD*)_dialog_red_button_down_key); -} - -static void __declspec(naked) gdialog_window_create_hook() { - __asm { - call art_ptr_unlock_; - cmp dword ptr ds:[_dialog_red_button_down_buf], 0; - jz FixCreateBarterButton; - retn; - } -} - void Interface_OnGameLoad() { dots.clear(); } @@ -540,9 +525,6 @@ void InterfaceInit() { // ScriptWindow - prevents the player from moving when clicking on the window if the 'Transparent' flag is not set HookCall(0x44B737, gmouse_bk_process_hook); // InterfaceGmouseHandleHook will be run before game initialization - - // Fix for the barter button on the dialog window not animating until after leaving the barter screen - HookCall(0x44A77C, gdialog_window_create_hook); } void InterfaceExit() { diff --git a/sfall/version.h b/sfall/version.h index 7d0ff4d3..ba4bf014 100644 --- a/sfall/version.h +++ b/sfall/version.h @@ -24,11 +24,11 @@ #define VERSION_MAJOR 3 #define VERSION_MINOR 8 -#define VERSION_BUILD 23 +#define VERSION_BUILD 24 #define VERSION_REV 0 #ifdef WIN2K -#define VERSION_STRING "3.8.23 win2k" +#define VERSION_STRING "3.8.24 win2k" #else -#define VERSION_STRING "3.8.23" +#define VERSION_STRING "3.8.24" #endif