Skip to content

Commit

Permalink
Quick patch to enable weather edid patch for 1170+
Browse files Browse the repository at this point in the history
powerof3 committed Dec 19, 2024
1 parent 162925f commit f971120
Showing 2 changed files with 28 additions and 4 deletions.
28 changes: 26 additions & 2 deletions src/Fixes/CacheEditorIDs.cpp
Original file line number Diff line number Diff line change
@@ -4,6 +4,26 @@
//Cache skipped formEditorIDs
namespace Fixes::CacheFormEditorIDs
{
const char* GetGameVersionImpl()
{
using func_t = decltype(&GetGameVersionImpl);
static REL::Relocation<func_t> func{ RELOCATION_ID(15485, 15650) };
return func();
}

REL::Version GetGameVersion()
{
std::stringstream ss(GetGameVersionImpl());
std::string token;
std::array<std::uint16_t, 4> version{};

for (std::size_t i = 0; i < 4 && std::getline(ss, token, '.'); ++i) {
version[i] = static_cast<std::uint16_t>(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<RE::BGSLensFlare, SetFormEditorID>();

#ifdef SKYRIM_AE
REL::Relocation<std::uintptr_t> target{ RELOCATION_ID(0, 20396), 0x403 }; //TESWeather::Load
stl::write_thunk_call<TESFile_GetChunkData>(target.address());
if (GetGameVersion() >= SKSE::RUNTIME_LATEST) {
REL::Relocation<std::uintptr_t> target{ RELOCATION_ID(0, 20396), 0x403 }; //TESWeather::Load
stl::write_thunk_call<TESFile_GetChunkData>(target.address());

logger::info("\t\tInstalled TESWeather editorID patch"sv);
}
#endif

logger::info("\t\tInstalled editorID cache"sv);
4 changes: 2 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
@@ -99,8 +99,8 @@ void InitializeLog()

auto log = std::make_shared<spdlog::logger>("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);

0 comments on commit f971120

Please sign in to comment.