From ce3369071437dd03648be02385a2462f2d85f2b9 Mon Sep 17 00:00:00 2001 From: "Mr.Stalin" Date: Tue, 12 Oct 2021 22:02:14 +0300 Subject: [PATCH] Minor editing. --- sfall/Game/inventory.cpp | 4 ++-- sfall/Game/skills.cpp | 4 ++-- sfall/Game/stats.cpp | 4 ++-- sfall/Logging.cpp | 20 ++++++++++++++++++++ sfall/Logging.h | 3 +++ sfall/Modules/Animations.cpp | 2 +- sfall/main.cpp | 8 +++----- 7 files changed, 33 insertions(+), 12 deletions(-) diff --git a/sfall/Game/inventory.cpp b/sfall/Game/inventory.cpp index c16d3f359..40b974543 100644 --- a/sfall/Game/inventory.cpp +++ b/sfall/Game/inventory.cpp @@ -164,7 +164,7 @@ DWORD __stdcall Inventory::adjust_fid() { return fo::var::i_fid; } -static void __declspec(naked) adjust_fid_hack() { +static void __declspec(naked) adjust_fid_replacement() { __asm { push ecx; push edx; @@ -177,7 +177,7 @@ static void __declspec(naked) adjust_fid_hack() { void Inventory::init() { // Replace functions - sf::MakeJump(fo::funcoffs::adjust_fid_, adjust_fid_hack); // 0x4716E8 + sf::MakeJump(fo::funcoffs::adjust_fid_, adjust_fid_replacement); // 0x4716E8 //sf::MakeJump(fo::funcoffs::item_weight_, item_weight_hack); // 0x477B88 } diff --git a/sfall/Game/skills.cpp b/sfall/Game/skills.cpp index 6e5fe01b7..c00c84349 100644 --- a/sfall/Game/skills.cpp +++ b/sfall/Game/skills.cpp @@ -38,7 +38,7 @@ int __stdcall Skills::trait_adjust_skill(DWORD skillID) { return result; } -static void __declspec(naked) trait_adjust_skill_hack() { +static void __declspec(naked) trait_adjust_skill_replacement() { __asm { push edx; push ecx; @@ -52,7 +52,7 @@ static void __declspec(naked) trait_adjust_skill_hack() { void Skills::init() { // Replace functions - sf::MakeJump(fo::funcoffs::trait_adjust_skill_, trait_adjust_skill_hack); // 0x4B40FC + sf::MakeJump(fo::funcoffs::trait_adjust_skill_, trait_adjust_skill_replacement); // 0x4B40FC } } \ No newline at end of file diff --git a/sfall/Game/stats.cpp b/sfall/Game/stats.cpp index 38636d08f..f161102af 100644 --- a/sfall/Game/stats.cpp +++ b/sfall/Game/stats.cpp @@ -107,7 +107,7 @@ int __stdcall Stats::trait_adjust_stat(DWORD statID) { return result; } -static void __declspec(naked) trait_adjust_stat_hack() { +static void __declspec(naked) trait_adjust_stat_replacement() { __asm { push edx; push ecx; @@ -121,7 +121,7 @@ static void __declspec(naked) trait_adjust_stat_hack() { void Stats::init() { // Replace functions - sf::MakeJump(fo::funcoffs::trait_adjust_stat_, trait_adjust_stat_hack); // 0x4B3C7C + sf::MakeJump(fo::funcoffs::trait_adjust_stat_, trait_adjust_stat_replacement); // 0x4B3C7C // Fix the carry weight penalty of the Small Frame trait not being applied to bonus Strength points smallFrameTraitFix = (sf::IniReader::GetConfigInt("Misc", "SmallFrameFix", 0) > 0); diff --git a/sfall/Logging.cpp b/sfall/Logging.cpp index 4de953f9c..e402565a7 100644 --- a/sfall/Logging.cpp +++ b/sfall/Logging.cpp @@ -29,6 +29,18 @@ namespace sfall static int DebugTypes = 0; static std::ofstream Log; +void dlog(const char* a) { + Log << a; + Log.flush(); +} + +void dlog(const char* a, int type) { + if (isDebug && (type == DL_MAIN || (type & DebugTypes))) { + Log << a; + Log.flush(); + } +} + void dlog(const std::string& a, int type) { if (isDebug && (type == DL_MAIN || (type & DebugTypes))) { Log << a; @@ -36,6 +48,13 @@ void dlog(const std::string& a, int type) { } } +void dlogr(const char* a, int type) { + if (isDebug && (type == DL_MAIN || (type & DebugTypes))) { + Log << a << "\n"; + Log.flush(); + } +} + void dlogr(const std::string& a, int type) { if (isDebug && (type == DL_MAIN || (type & DebugTypes))) { Log << a << "\n"; @@ -83,6 +102,7 @@ void devlog_f(...) {} void LoggingInit() { Log.open("sfall-log.txt", std::ios_base::out | std::ios_base::trunc); + if (IniReader::GetIntDefaultConfig("Debugging", "Init", 0)) { DebugTypes |= DL_INIT; } diff --git a/sfall/Logging.h b/sfall/Logging.h index 43b66a014..e3837039f 100644 --- a/sfall/Logging.h +++ b/sfall/Logging.h @@ -30,7 +30,10 @@ namespace sfall { +void dlog(const char*); +void dlog(const char*, int type); void dlog(const std::string&, int type); +void dlogr(const char*, int type); void dlogr(const std::string&, int type); void dlog_f(const char* fmt, int type, ...); void dlogh(const char* fmt, long, long, long); diff --git a/sfall/Modules/Animations.cpp b/sfall/Modules/Animations.cpp index 178c5e3b7..146a389df 100644 --- a/sfall/Modules/Animations.cpp +++ b/sfall/Modules/Animations.cpp @@ -515,7 +515,7 @@ static void __declspec(naked) action_get_an_object_hack() { xor edi, edi; retn; // request loot container default: - mov edi, 2; + mov edi, 2; // set current frame test edi, edi; retn; } diff --git a/sfall/main.cpp b/sfall/main.cpp index 9188a7ace..37b5bc8a3 100644 --- a/sfall/main.cpp +++ b/sfall/main.cpp @@ -223,13 +223,11 @@ static void SfallInit() { if (!CRC(filepath)) return; + LoggingInit(); + if (!ddraw.dll) dlog("Error: Cannot load the original ddraw.dll library.\n"); + // enabling debugging features isDebug = (IniReader::GetIntDefaultConfig("Debugging", "Enable", 0) != 0); - //if (isDebug) { - LoggingInit(); - if (!ddraw.dll) dlog("Error: Cannot load the original ddraw.dll library.\n", DL_MAIN); - //} - if (!isDebug || !IniReader::GetIntDefaultConfig("Debugging", "SkipCompatModeCheck", 0)) { int is64bit; typedef int (__stdcall *chk64bitproc)(HANDLE, int*);