From 36f2d5c07df8f8748ce5fefdc300f2c37d5021e8 Mon Sep 17 00:00:00 2001 From: Dennis Soemers Date: Sun, 9 Apr 2023 17:16:45 +0200 Subject: [PATCH] hopefully VR fix --- CMakeLists.txt | 2 +- include/OnContainerChangedEventHandler.h | 26 ++++++++++++++++++------ include/version.h | 4 ++-- vcpkg.json | 2 +- 4 files changed, 24 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5d74156..4c98219 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,7 +6,7 @@ message("Using toolchain file ${CMAKE_TOOLCHAIN_FILE}.") ######################################################################################################################## project( PAPER - VERSION 2.2.0 + VERSION 2.2.1 DESCRIPTION "The PAper Papyrus ExtendeR. Plugin to expose new functions and events to Skyrim's 'Papyrus' scripting language. " LANGUAGES CXX) set(CMAKE_CXX_STANDARD 23) diff --git a/include/OnContainerChangedEventHandler.h b/include/OnContainerChangedEventHandler.h index 0a3c948..9b31fae 100644 --- a/include/OnContainerChangedEventHandler.h +++ b/include/OnContainerChangedEventHandler.h @@ -6,6 +6,13 @@ namespace OnContainerChangedEvents { #pragma warning(push) #pragma warning(disable : 4251) + // Retrieve manual offset for edge cases CLIB-NG does not account for yet + // Thanks to Nightfallstorm! + template + T GetManualRelocateMemberVariable(void* object, REL::VariantOffset offset) { + return *(reinterpret_cast((uintptr_t)object + offset.offset())); + } + /** * Data for an event to be processed. */ @@ -95,11 +102,18 @@ namespace OnContainerChangedEvents { virtual bool matchesFilter(RE::VMHandle handle) override { auto vm = RE::SkyrimVM::GetSingleton(); - vm->InventoryEventFilterMapLock.Lock(); + auto inventoryEventFilterMapLock = + GetManualRelocateMemberVariable(vm, REL::VariantOffset(0x8940, 0x8940, 0x8960)); + + inventoryEventFilterMapLock.Lock(); + + const auto& inventoryEventFilterMap = + GetManualRelocateMemberVariable>( + vm, REL::VariantOffset(0x8948, 0x8948, 0x8968)); RE::SkyrimVM::InventoryEventFilterLists* filterLists = nullptr; - auto it = vm->InventoryEventFilterMap.find(handle); - if (it != vm->InventoryEventFilterMap.end()) { + auto it = inventoryEventFilterMap.find(handle); + if (it != inventoryEventFilterMap.end()) { filterLists = it->second; } @@ -107,18 +121,18 @@ namespace OnContainerChangedEvents { // Have filters, so need at least one of our items to match for (auto baseObj : baseItems) { if (OnContainerChangedEventHandler::ItemPassesInventoryFilterLists(baseObj->formID, filterLists)) { - vm->InventoryEventFilterMapLock.Unlock(); + inventoryEventFilterMapLock.Unlock(); return true; } } } else { // No filters, so anything matches - vm->InventoryEventFilterMapLock.Unlock(); + inventoryEventFilterMapLock.Unlock(); return true; } // Have filters but none matched, so return false - vm->InventoryEventFilterMapLock.Unlock(); + inventoryEventFilterMapLock.Unlock(); return false; } }; diff --git a/include/version.h b/include/version.h index 7a7238c..0ed77b1 100644 --- a/include/version.h +++ b/include/version.h @@ -5,7 +5,7 @@ // // Instead, edit the template in /cmake/version.h.in -#define PROJECT_VER 2.2.0 +#define PROJECT_VER 2.2.1 #define PROJECT_VER_MAJOR 2 #define PROJECT_VER_MINOR 2 -#define PROJECT_VER_PATCH 0 +#define PROJECT_VER_PATCH 1 diff --git a/vcpkg.json b/vcpkg.json index 640c4d2..64fe210 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -1,7 +1,7 @@ { "$schema": "https://raw.githubusercontent.com/microsoft/vcpkg/master/scripts/vcpkg.schema.json", "name": "paper-plugin", - "version-string": "2.2.0", + "version-string": "2.2.1", "port-version": 0, "description": "The PAper Papyrus ExtendeR. Plugin to expose new functions and events to Skyrim's 'Papyrus' scripting language.", "license": "Apache-2.0",