From 2e97fe38ff1aad768cbe09a42f5f5d7ed82b2da0 Mon Sep 17 00:00:00 2001 From: NovaRain Date: Sun, 10 Oct 2021 07:19:46 +0800 Subject: [PATCH] Fixed JetWithdrawal in Drugs.ini conflict with fix in commit dfd810c Simplified the code in the previous commit. --- sfall/Modules/Animations.cpp | 7 +++---- sfall/Modules/BugFixes.cpp | 3 +++ sfall/Modules/Drugs.cpp | 7 ++++--- sfall/Modules/Drugs.h | 1 + 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/sfall/Modules/Animations.cpp b/sfall/Modules/Animations.cpp index 44aeb05e..1c3cecbc 100644 --- a/sfall/Modules/Animations.cpp +++ b/sfall/Modules/Animations.cpp @@ -497,10 +497,9 @@ static void __declspec(naked) obj_use_container_hook() { static const DWORD obj_use_container_ExitRet = 0x49D069; using namespace fo::Fields; __asm { - mov ebx, [ecx + currFrame]; // obj.cur_frm - cmp ebx, 1; // grave type containers in the open state? - je skip; // skip animation - jmp fo::funcoffs::register_begin_; // vanilla behavior + cmp dword ptr [ecx + currFrame], 1; // grave type containers in the open state? + je skip; // skip animation + jmp fo::funcoffs::register_begin_; // vanilla behavior skip: add esp, 4; cmp edi, ds:[FO_VAR_obj_dude]; diff --git a/sfall/Modules/BugFixes.cpp b/sfall/Modules/BugFixes.cpp index eabfa185..bf53021e 100644 --- a/sfall/Modules/BugFixes.cpp +++ b/sfall/Modules/BugFixes.cpp @@ -266,8 +266,11 @@ skip: static void __declspec(naked) item_wd_process_hack() { __asm { + cmp Drugs::JetWithdrawal, 1; + je skip; cmp esi, PERK_add_jet; // esi - queue_addict.perk je jetAddict; +skip: retn; jetAddict: push ecx; diff --git a/sfall/Modules/Drugs.cpp b/sfall/Modules/Drugs.cpp index 5ae956e6..ea585177 100644 --- a/sfall/Modules/Drugs.cpp +++ b/sfall/Modules/Drugs.cpp @@ -30,6 +30,7 @@ static int drugsCount = 0; static bool drugsReset = false; // true - need reset long Drugs::addictionGvarCount = 0; +bool Drugs::JetWithdrawal = false; sDrugs *drugs = nullptr; @@ -287,7 +288,7 @@ void Drugs::init() { dlog("Applying drugs patch...", DL_INIT); const char* iniDrugs = drugsFile.insert(0, ".\\").c_str(); - if (IniReader::GetInt("main", "JetWithdrawal", 0, iniDrugs) == 1) SafeWrite8(0x47A3A8, 0); + JetWithdrawal = (IniReader::GetInt("main", "JetWithdrawal", 0, iniDrugs) == 1); // SafeWrite8(0x47A3A8, 0); item_wd_process_ int count = IniReader::GetInt("main", "Count", 0, iniDrugs); if (count > 0) { @@ -334,8 +335,8 @@ void Drugs::init() { MakeCall(0x43C15C, list_karma_hack, 2); MakeCall(0x47A5B8, pid_to_gvar_hack, 1); MakeCall(0x47A50C, perform_withdrawal_start_hack); - SafeWrite32(0x47A523, 0x9090EBD1); // shr ebx, 1 (fix for trait drug addict) - SafeWrite8(0x47A527, CodeType::Nop); + SafeWrite32(0x47A523, 0x9090EBD1); // shr ebx, 1 (fix for trait drug addict perform_withdrawal_start_) + SafeWrite8(0x47A527, CodeType::Nop); // perform_withdrawal_start_ if (addictionGvarCount) { LoadGameHook::OnAfterGameInit() += CheckValidGvarNumber; diff --git a/sfall/Modules/Drugs.h b/sfall/Modules/Drugs.h index 5353365b..d09234ca 100644 --- a/sfall/Modules/Drugs.h +++ b/sfall/Modules/Drugs.h @@ -30,6 +30,7 @@ public: void exit() override; static long addictionGvarCount; + static bool JetWithdrawal; static long GetDrugCount(); static long GetDrugPid(long n);