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:37:36 +08:00
parent 8a7d9cbd78
commit 8bb660ff11
5 changed files with 77 additions and 25 deletions
+4 -1
View File
@@ -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
+69 -3
View File
@@ -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);
}
+1
View File
@@ -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
-18
View File
@@ -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() {
+3 -3
View File
@@ -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