Skip to content

Commit

Permalink
Fixed issues with picking Tag! or Mutate! perk if there are unused perks
Browse files Browse the repository at this point in the history
* their windows keep reappearing when picking other perks, can cause
various issues or even crashes.
  • Loading branch information
NovaRain committed Sep 1, 2024
1 parent edb7673 commit 58b645a
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
1 change: 1 addition & 0 deletions sfall/FalloutEngine/FunctionOffsets_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ FUNC(GNW_text_width_, 0x4D5B60)
FUNC(GNW_win_refresh_, 0x4D6FD8)
FUNC(GameMap2Slot_, 0x47F510)
FUNC(GetComment_, 0x47ED5C)
FUNC(GetMutateTrait_, 0x43D38C)
FUNC(GetSlotList_, 0x47E5D0)
FUNC(IncGamma_, 0x4928E4)
FUNC(Index2RGB_, 0x4C72D5)
Expand Down
44 changes: 44 additions & 0 deletions sfall/Modules/BugFixes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3453,6 +3453,45 @@ static __declspec(naked) void op_using_skill_hack() {
}
}

static bool pickedTag = false;
static bool pickedMutate = false;

static __declspec(naked) void perks_dialog_hook_tag() {
static const DWORD perks_dialog_tag_Ret = 0x43C9C5;
__asm {
cmp pickedTag, 0;
jne skip;
call fo::funcoffs::Add4thTagSkill_;
mov pickedTag, al;
retn;
skip:
add esp, 4;
jmp perks_dialog_tag_Ret;
}
}

static __declspec(naked) void perks_dialog_hook_mutate() {
static const DWORD perks_dialog_mutate_Ret = 0x43CA04;
__asm {
cmp pickedMutate, 0;
jne skip;
call fo::funcoffs::GetMutateTrait_;
mov pickedMutate, al;
retn;
skip:
add esp, 4;
jmp perks_dialog_mutate_Ret;
}
}

static __declspec(naked) void editor_design_hook() {
__asm { // eax = 0
mov pickedTag, al;
mov pickedMutate, al;
jmp fo::funcoffs::intface_update_hit_points_;
}
}

void BugFixes::init() {
#ifndef NDEBUG
LoadGameHook::OnBeforeGameClose() += PrintAddrList;
Expand Down Expand Up @@ -4277,6 +4316,11 @@ void BugFixes::init() {
// Fix for object_fix_weapon_ammo_ engine function not checking "misc" type items
SafeWrite8(0x48916B, 0x41); // jnz 0x4891AD
SafeWrite8(0x4891C8, CodeType::JumpShort); // jmp 0x4891E9 (skip proto data correction)

// Fix to prevent the windows of Tag! and Mutate! perks from reappearing when there are still unused perks
HookCall(0x43C9A0, perks_dialog_hook_tag);
HookCall(0x43C9E2, perks_dialog_hook_mutate);
HookCall(0x4329D1, editor_design_hook); // reset flags on exiting the character screen
}

}

0 comments on commit 58b645a

Please sign in to comment.