|
4 | 4 | //Cache skipped formEditorIDs |
5 | 5 | namespace Fixes::CacheFormEditorIDs |
6 | 6 | { |
| 7 | + const char* GetGameVersionImpl() |
| 8 | + { |
| 9 | + using func_t = decltype(&GetGameVersionImpl); |
| 10 | + static REL::Relocation<func_t> func{ RELOCATION_ID(15485, 15650) }; |
| 11 | + return func(); |
| 12 | + } |
| 13 | + |
| 14 | + REL::Version GetGameVersion() |
| 15 | + { |
| 16 | + std::stringstream ss(GetGameVersionImpl()); |
| 17 | + std::string token; |
| 18 | + std::array<std::uint16_t, 4> version{}; |
| 19 | + |
| 20 | + for (std::size_t i = 0; i < 4 && std::getline(ss, token, '.'); ++i) { |
| 21 | + version[i] = static_cast<std::uint16_t>(std::stoi(token)); |
| 22 | + } |
| 23 | + |
| 24 | + return REL::Version(version); |
| 25 | + } |
| 26 | + |
7 | 27 | struct SetFormEditorID |
8 | 28 | { |
9 | 29 | static bool thunk(RE::TESForm* a_this, const char* a_str) |
@@ -208,8 +228,12 @@ namespace Fixes::CacheFormEditorIDs |
208 | 228 | stl::write_vfunc<RE::BGSLensFlare, SetFormEditorID>(); |
209 | 229 |
|
210 | 230 | #ifdef SKYRIM_AE |
211 | | - REL::Relocation<std::uintptr_t> target{ RELOCATION_ID(0, 20396), 0x403 }; //TESWeather::Load |
212 | | - stl::write_thunk_call<TESFile_GetChunkData>(target.address()); |
| 231 | + if (GetGameVersion() >= SKSE::RUNTIME_LATEST) { |
| 232 | + REL::Relocation<std::uintptr_t> target{ RELOCATION_ID(0, 20396), 0x403 }; //TESWeather::Load |
| 233 | + stl::write_thunk_call<TESFile_GetChunkData>(target.address()); |
| 234 | + |
| 235 | + logger::info("\t\tInstalled TESWeather editorID patch"sv); |
| 236 | + } |
213 | 237 | #endif |
214 | 238 |
|
215 | 239 | logger::info("\t\tInstalled editorID cache"sv); |
|
0 commit comments