From 3d59cc84a04531e276114b3831fecd41105905ce Mon Sep 17 00:00:00 2001 From: praydog Date: Fri, 28 Jun 2024 07:50:27 -0700 Subject: [PATCH] Plugins: Activate UObjectHook if any functions are called --- src/mods/PluginLoader.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/mods/PluginLoader.cpp b/src/mods/PluginLoader.cpp index c6b96456..6277eed3 100644 --- a/src/mods/PluginLoader.cpp +++ b/src/mods/PluginLoader.cpp @@ -474,11 +474,17 @@ namespace uobjecthook { } bool exists(UEVR_UObjectHandle obj) { - return UObjectHook::get()->exists((sdk::UObject*)obj); + auto& instance = UObjectHook::get(); + instance->activate(); + + return instance->exists((sdk::UObject*)obj); } int get_objects_by_class(UEVR_UClassHandle klass, UEVR_UObjectHandle* out_objects, unsigned int max_objects, bool allow_default) { - const auto objects = UObjectHook::get()->get_objects_by_class((sdk::UClass*)klass); + auto& instance = UObjectHook::get(); + instance->activate(); + + const auto objects = instance->get_objects_by_class((sdk::UClass*)klass); if (objects.empty()) { return 0; @@ -515,7 +521,10 @@ namespace uobjecthook { } UEVR_UObjectHandle get_first_object_by_class(UEVR_UClassHandle klass, bool allow_default) { - const auto objects = UObjectHook::get()->get_objects_by_class((sdk::UClass*)klass); + auto& instance = UObjectHook::get(); + instance->activate(); + + const auto objects = instance->get_objects_by_class((sdk::UClass*)klass); if (objects.empty()) { return nullptr;