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()); } } }