From f603fe23e174eac4115309c07456c0ea20229f07 Mon Sep 17 00:00:00 2001 From: pv Date: Fri, 1 Mar 2024 10:24:44 +0300 Subject: [PATCH 1/4] Fix ResourceAsyncReference --- src/reverse/ResourceAsyncReference.cpp | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/reverse/ResourceAsyncReference.cpp b/src/reverse/ResourceAsyncReference.cpp index 5c597a05..351ae45c 100644 --- a/src/reverse/ResourceAsyncReference.cpp +++ b/src/reverse/ResourceAsyncReference.cpp @@ -13,18 +13,12 @@ ResourceAsyncReference::ResourceAsyncReference( uint64_t ResourceAsyncReference::Hash(const std::string& aPath) { - // Should probably be moved to RED4ext.SDK after fixing RED4ext::RaRef - // Needs normalization - // 1) all lower case - // 2) / becomes \ - // 3) /\/\\ becomes \ - - return RED4ext::FNV1a64(aPath.c_str()); + return RED4ext::ResourcePath(aPath.c_str()); } RED4ext::ScriptInstance ResourceAsyncReference::GetHandle() const { - return const_cast*>(&m_reference); + return nullptr; } RED4ext::ScriptInstance ResourceAsyncReference::GetValuePtr() const @@ -46,7 +40,7 @@ sol::object ResourceAsyncReference::GetLuaHash() const RED4ext::CStackType stackType; stackType.type = s_uint64Type; - stackType.value = GetHandle(); + stackType.value = const_cast*>(&m_reference); return Converter::ToLua(stackType, lockedState); } From 1f5ee2e6028d3359c09690f0c8950a00e029949b Mon Sep 17 00:00:00 2001 From: pv Date: Fri, 1 Mar 2024 10:25:12 +0300 Subject: [PATCH 2/4] Fix GameOptions hook address --- src/reverse/Addresses.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/reverse/Addresses.h b/src/reverse/Addresses.h index 352a3217..2a9eab36 100644 --- a/src/reverse/Addresses.h +++ b/src/reverse/Addresses.h @@ -20,7 +20,7 @@ constexpr uint32_t CInitializationState_OnTick = 2447710505UL; constexpr uint32_t CPatches_BoundaryTeleport = 887623293UL; constexpr uint32_t CPatches_IntroMovie = 4056423627UL; constexpr uint32_t CPatches_Vignette = 1592528795UL; -constexpr uint32_t CPatches_OptionsInit = 2920158527UL; +constexpr uint32_t CPatches_OptionsInit = 4089777341UL; // Config::IConfigVar::Register #pragma endregion #pragma region CPhotoMode From eeb767962e656a9af073fde605325329a16f6d76 Mon Sep 17 00:00:00 2001 From: pv Date: Fri, 1 Mar 2024 10:26:33 +0300 Subject: [PATCH 3/4] Disable GameOptions printing to console on modify --- src/scripting/GameOptions.cpp | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/src/scripting/GameOptions.cpp b/src/scripting/GameOptions.cpp index 90e0663f..9e9a6d6d 100644 --- a/src/scripting/GameOptions.cpp +++ b/src/scripting/GameOptions.cpp @@ -220,9 +220,7 @@ void GameOptions::Set(const std::string& category, const std::string& name, cons return; const auto consoleLogger = spdlog::get("scripting"); - if (option->Set(value)) - consoleLogger->info(option->GetInfo()); - else + if (!option->Set(value)) { if (option->GetType() == GameOption::kString) consoleLogger->error("Failed to set game option '{}/{}', can't set string options right now.", category, name); @@ -238,9 +236,7 @@ void GameOptions::SetBool(const std::string& category, const std::string& name, return; const auto consoleLogger = spdlog::get("scripting"); - if (option->SetBool(value)) - consoleLogger->info(option->GetInfo()); - else + if (!option->SetBool(value)) { if (option->GetType() != GameOption::kBoolean) consoleLogger->error("Failed to set game option '{}/{}', not a boolean.", category, name); @@ -256,9 +252,7 @@ void GameOptions::SetInt(const std::string& category, const std::string& name, i return; const auto consoleLogger = spdlog::get("scripting"); - if (option->SetInt(value)) - consoleLogger->info(option->GetInfo()); - else + if (!option->SetInt(value)) { if (option->GetType() != GameOption::kInteger && option->GetType() != GameOption::kColor) consoleLogger->error("Failed to set game option '{}/{}', not an integer.", category, name); @@ -274,9 +268,7 @@ void GameOptions::SetFloat(const std::string& category, const std::string& name, return; const auto consoleLogger = spdlog::get("scripting"); - if (option->SetFloat(value)) - consoleLogger->info(option->GetInfo()); - else + if (!option->SetFloat(value)) { if (option->GetType() != GameOption::kFloat) consoleLogger->error("Failed to set game option '{}/{}', not a float.", category, name); @@ -292,9 +284,7 @@ void GameOptions::Toggle(const std::string& category, const std::string& name) return; const auto consoleLogger = spdlog::get("scripting"); - if (option->Toggle()) - consoleLogger->info(option->GetInfo()); - else + if (!option->Toggle()) { if (option->GetType() != GameOption::kBoolean) consoleLogger->error("Failed to set game option '{}/{}', not a boolean.", category, name); From d685ab15fe04f4d0a73850bd31fc7760244b9915 Mon Sep 17 00:00:00 2001 From: pv Date: Fri, 1 Mar 2024 10:41:36 +0300 Subject: [PATCH 4/4] Fix spawner address --- src/reverse/Addresses.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/reverse/Addresses.h b/src/reverse/Addresses.h index 2a9eab36..ac68dff1 100644 --- a/src/reverse/Addresses.h +++ b/src/reverse/Addresses.h @@ -24,7 +24,7 @@ constexpr uint32_t CPatches_OptionsInit = 4089777341UL; // Config::IConfigVar::R #pragma endregion #pragma region CPhotoMode -constexpr uint32_t CPhotoMode_SetRecordID = 2826047827UL; +constexpr uint32_t CPhotoMode_SetRecordID = 4052428712UL; #pragma endregion #pragma region CRenderGlobal