Skip to content

Commit

Permalink
Fixed the player's money not being displayed after barter (#286)
Browse files Browse the repository at this point in the history
Restored TownMapHotkeysFix option.

Updated version number.
  • Loading branch information
NovaRain committed Feb 22, 2020
1 parent e5eb5cc commit 4487bbf
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 24 deletions.
5 changes: 4 additions & 1 deletion artifacts/ddraw.ini
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions sfall/FalloutEngine/VariableOffsets.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
72 changes: 69 additions & 3 deletions sfall/Modules/BugFixes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2519,11 +2519,71 @@ static void __declspec(naked) action_loot_container_hack() {
}
}

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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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 changes: 0 additions & 18 deletions sfall/Modules/Interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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() {
Expand Down
4 changes: 2 additions & 2 deletions sfall/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"

0 comments on commit 4487bbf

Please sign in to comment.