Fixed the player's money not being displayed after barter (#286)

Restored TownMapHotkeysFix option.

Updated version number.
This commit is contained in:
NovaRain
2020-02-22 15:31:17 +08:00
parent e5eb5cc275
commit 4487bbfeba
5 changed files with 76 additions and 24 deletions
+4 -1
View File
@@ -1,5 +1,5 @@
;sfall configuration settings
;v4.2.3
;v4.2.4
[Main]
;Change to 1 if you want to use command line args to tell sfall to use another ini file.
@@ -332,6 +332,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
+1
View File
@@ -57,6 +57,7 @@
#define FO_VAR_dialogue_state 0x518714
#define FO_VAR_dialogue_switch_mode 0x518718
#define FO_VAR_dialogueBackWindow 0x518740
#define FO_VAR_dialogueWindow 0x518744
#define FO_VAR_display_win 0x631E4C
#define FO_VAR_displayMapList 0x41B560
#define FO_VAR_dropped_explosive 0x5190E0
+69 -3
View File
@@ -2519,11 +2519,71 @@ look:
}
}
static void FixCreateBarterButton() {
const long artID = fo::OBJ_TYPE_INTRFACE << 24;
*(BYTE**)FO_VAR_dialog_red_button_up_buf = fo::func::art_ptr_lock_data(artID | 96, 0 ,0, (DWORD*)FO_VAR_dialog_red_button_up_key);
*(BYTE**)FO_VAR_dialog_red_button_down_buf = fo::func::art_ptr_lock_data(artID | 95, 0 ,0, (DWORD*)FO_VAR_dialog_red_button_down_key);
}
static void __declspec(naked) gdialog_window_create_hook() {
__asm {
call fo::funcoffs::art_ptr_unlock_;
cmp dword ptr ds:[FO_VAR_dialog_red_button_down_buf], 0;
jz FixCreateBarterButton;
retn;
}
}
static void __declspec(naked) gdialog_bk_hook() {
__asm {
xor ebp, ebp;
mov eax, ds:[FO_VAR_curr_font_num];
cmp eax, 101;
je skip0;
mov ebp, eax;
mov eax, 101; // set font
call fo::funcoffs::text_font_;
skip0:
mov eax, ds:[FO_VAR_obj_dude];
call fo::funcoffs::item_caps_total_;
push eax; // caps
push 0x502B1C; // fmt: $%d
lea eax, textBuf;
push eax;
call fo::funcoffs::sprintf_;
add esp, 3 * 4;
lea eax, textBuf;
call ds:[FO_VAR_text_width];
mov edx, 60; // max width
mov ebx, eax; // ebx - textWidth
cmp eax, edx;
cmova ebx, edx;
movzx eax, ds:[FO_VAR_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:[FO_VAR_dialogueWindow];
call fo::funcoffs::win_print_;
test ebp, ebp;
jz skip1;
mov eax, ebp;
call fo::funcoffs::text_font_;
skip1:
mov eax, edi;
jmp fo::funcoffs::win_show_;
}
}
void BugFixes::init()
{
#ifndef NDEBUG
LoadGameHook::OnBeforeGameClose() += PrintAddrList;
if (isDebug && (iniGetInt("Debugging", "BugFixes", 1, ::sfall::ddrawIni) == 0)) return;
if (iniGetInt("Debugging", "BugFixes", 1, ::sfall::ddrawIni) == 0) return;
#endif
// Missing game initialization
@@ -3133,11 +3193,11 @@ void BugFixes::init()
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);
@@ -3180,6 +3240,12 @@ void BugFixes::init()
SafeWrite8(0x4123F2, CommonObj::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);
}
}
-18
View File
@@ -869,21 +869,6 @@ static void __declspec(naked) gmouse_bk_process_hook() {
}
}
static void FixCreateBarterButton() {
const long artID = fo::OBJ_TYPE_INTRFACE << 24;
*(BYTE**)FO_VAR_dialog_red_button_up_buf = fo::func::art_ptr_lock_data(artID | 96, 0 ,0, (DWORD*)FO_VAR_dialog_red_button_up_key);
*(BYTE**)FO_VAR_dialog_red_button_down_buf = fo::func::art_ptr_lock_data(artID | 95, 0 ,0, (DWORD*)FO_VAR_dialog_red_button_down_key);
}
static void __declspec(naked) gdialog_window_create_hook() {
__asm {
call fo::funcoffs::art_ptr_unlock_;
cmp dword ptr ds:[FO_VAR_dialog_red_button_down_buf], 0;
jz FixCreateBarterButton;
retn;
}
}
void Interface::init() {
if (GetConfigInt("Interface", "ActionPointsBar", 0)) {
ActionPointsBarPatch();
@@ -900,9 +885,6 @@ void Interface::init() {
if (hrpVersionValid) IFACE_BAR_MODE = *(BYTE*)HRPAddress(0x1006EB0C) != 0;
HookCall(0x44C018, gmouse_handle_event_hook); // replaces hack function from HRP
};
// Fix for the barter button on the dialog window not animating until after leaving the barter screen
HookCall(0x44A77C, gdialog_window_create_hook);
}
void Interface::exit() {
+2 -2
View File
@@ -24,7 +24,7 @@
#define VERSION_MAJOR 4
#define VERSION_MINOR 2
#define VERSION_BUILD 3
#define VERSION_BUILD 4
#define VERSION_REV 0
#define VERSION_STRING "4.2.3"
#define VERSION_STRING "4.2.4"