From f80b9144d6bac29797f90053b8dc8475318b9bfb Mon Sep 17 00:00:00 2001 From: alandtse Date: Sat, 16 Dec 2023 05:28:44 +0000 Subject: [PATCH 1/2] maintenance --- include/RE/I/InterfaceStrings.h | 4 ++-- include/RE/T/TES.h | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/RE/I/InterfaceStrings.h b/include/RE/I/InterfaceStrings.h index 1880700b3..49681d864 100644 --- a/include/RE/I/InterfaceStrings.h +++ b/include/RE/I/InterfaceStrings.h @@ -116,7 +116,7 @@ namespace RE # else static_assert(sizeof(InterfaceStrings) == 0x260); # endif -# else +#else static_assert(sizeof(InterfaceStrings) == 0x2A8); -# endif +#endif } diff --git a/include/RE/T/TES.h b/include/RE/T/TES.h index 84f7cd436..fc8c0325d 100644 --- a/include/RE/T/TES.h +++ b/include/RE/T/TES.h @@ -166,11 +166,11 @@ namespace RE KEEP_FOR_RE() }; #ifndef SKYRIMVR -#ifndef SKYRIM_SUPPORT_AE +# ifndef SKYRIM_SUPPORT_AE static_assert(sizeof(TES) == 0x2B8); -#else +# else static_assert(sizeof(TES) == 0x2C0); -#endif +# endif #else static_assert(sizeof(TES) == 0x2B8); #endif From 6089216a56af68f4527932ec96bf2f76ac864346 Mon Sep 17 00:00:00 2001 From: Alan Tse Date: Mon, 18 Dec 2023 01:46:09 -0800 Subject: [PATCH 2/2] feat: expose VRcompiledFileCollection This allows commonlib mods to determine if SkyrimVRESL is active by checking for nullptr. This also allows porting of CommonLibSSE mods that directly access compiledFileCollection to use the VR equivalent. --- include/RE/T/TESDataHandler.h | 7 ++++--- src/RE/T/TESDataHandler.cpp | 8 +++----- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/include/RE/T/TESDataHandler.h b/include/RE/T/TESDataHandler.h index aa97b2e17..05ed30154 100644 --- a/include/RE/T/TESDataHandler.h +++ b/include/RE/T/TESDataHandler.h @@ -39,7 +39,8 @@ namespace RE class TESDataHandler : public BSTSingletonSDM { public: - static TESDataHandler* GetSingleton(bool a_VRESL = true); + inline static RE::TESFileCollection* VRcompiledFileCollection = nullptr; // used by SkyrimVRESL to store pointer to VR version + static TESDataHandler* GetSingleton(bool a_VRESL = true); bool AddFormToDataHandler(TESForm* a_form); @@ -100,9 +101,9 @@ namespace RE TESRegionDataManager* regionDataManager; // DB0 InventoryChanges* merchantInventory; // DB8 #else - std::uint32_t loadedModCount; // D70 + std::uint32_t loadedModCount; // D70 this should be avoided if SkyrimVRESL is available std::uint32_t pad14; // D74 - TESFile* loadedMods[0xFF]; // D78 + TESFile* loadedMods[0xFF]; // D78 this should be avoided if SkyrimVRESL is available bool masterSave; // 1570 bool blockSave; // 1571 bool saveLoadGame; // 1572 diff --git a/src/RE/T/TESDataHandler.cpp b/src/RE/T/TESDataHandler.cpp index 6de1e29af..2fc4e718c 100644 --- a/src/RE/T/TESDataHandler.cpp +++ b/src/RE/T/TESDataHandler.cpp @@ -5,18 +5,16 @@ namespace RE { - static const RE::TESFileCollection* VRcompiledFileCollection = nullptr; - TESDataHandler* TESDataHandler::GetSingleton(bool a_VRESL) { REL::Relocation singleton{ Offset::TESDataHandler::Singleton }; #ifdef SKYRIMVR - if (a_VRESL) { + if (a_VRESL && !TESDataHandler::VRcompiledFileCollection) { const auto VRhandle = WinAPI::GetModuleHandle("skyrimvresl"); - if (!VRcompiledFileCollection) { + if (VRhandle != NULL) { const auto GetCompiledFileCollection = reinterpret_cast(WinAPI::GetProcAddress(VRhandle, "GetCompiledFileCollectionExtern")); if (GetCompiledFileCollection != nullptr) { - VRcompiledFileCollection = GetCompiledFileCollection(); + TESDataHandler::VRcompiledFileCollection = const_cast(GetCompiledFileCollection()); } } }