From f971120870bd1afa42ede629781032bf26433022 Mon Sep 17 00:00:00 2001 From: powerof3 Date: Fri, 20 Dec 2024 00:42:21 +0530 Subject: [PATCH] Quick patch to enable weather edid patch for 1170+ --- src/Fixes/CacheEditorIDs.cpp | 28 ++++++++++++++++++++++++++-- src/main.cpp | 4 ++-- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/src/Fixes/CacheEditorIDs.cpp b/src/Fixes/CacheEditorIDs.cpp index cf75e77..9467074 100644 --- a/src/Fixes/CacheEditorIDs.cpp +++ b/src/Fixes/CacheEditorIDs.cpp @@ -4,6 +4,26 @@ //Cache skipped formEditorIDs namespace Fixes::CacheFormEditorIDs { + const char* GetGameVersionImpl() + { + using func_t = decltype(&GetGameVersionImpl); + static REL::Relocation func{ RELOCATION_ID(15485, 15650) }; + return func(); + } + + REL::Version GetGameVersion() + { + std::stringstream ss(GetGameVersionImpl()); + std::string token; + std::array version{}; + + for (std::size_t i = 0; i < 4 && std::getline(ss, token, '.'); ++i) { + version[i] = static_cast(std::stoi(token)); + } + + return REL::Version(version); + } + struct SetFormEditorID { static bool thunk(RE::TESForm* a_this, const char* a_str) @@ -208,8 +228,12 @@ namespace Fixes::CacheFormEditorIDs stl::write_vfunc(); #ifdef SKYRIM_AE - REL::Relocation target{ RELOCATION_ID(0, 20396), 0x403 }; //TESWeather::Load - stl::write_thunk_call(target.address()); + if (GetGameVersion() >= SKSE::RUNTIME_LATEST) { + REL::Relocation target{ RELOCATION_ID(0, 20396), 0x403 }; //TESWeather::Load + stl::write_thunk_call(target.address()); + + logger::info("\t\tInstalled TESWeather editorID patch"sv); + } #endif logger::info("\t\tInstalled editorID cache"sv); diff --git a/src/main.cpp b/src/main.cpp index b11fbf9..4e822d5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -99,8 +99,8 @@ void InitializeLog() auto log = std::make_shared("global log"s, std::move(sink)); - log->set_level(spdlog::level::debug); - log->flush_on(spdlog::level::debug); + log->set_level(spdlog::level::info); + log->flush_on(spdlog::level::info); spdlog::set_default_logger(std::move(log)); spdlog::set_pattern("[%H:%M:%S:%e] %v"s);