Fixed issues with picking Tag! or Mutate! perk if there are unused perks

* their windows keep reappearing when picking other perks, can cause
various issues or even crashes.
This commit is contained in:
NovaRain
2024-09-01 12:21:34 +08:00
parent edb7673045
commit 58b645a108
2 changed files with 45 additions and 0 deletions
@@ -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)
+44
View File
@@ -3453,6 +3453,45 @@ skip:
}
}
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;
@@ -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
}
}