From 9ccb3740aa5c1a99f5faf30d9ce0ade79e74a855 Mon Sep 17 00:00:00 2001 From: praydog Date: Wed, 19 Jun 2024 15:53:15 -0700 Subject: [PATCH] Plugins: Fix cases where object finder could return default objects --- src/mods/PluginLoader.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/mods/PluginLoader.cpp b/src/mods/PluginLoader.cpp index 6ecbbb09..35215e9e 100644 --- a/src/mods/PluginLoader.cpp +++ b/src/mods/PluginLoader.cpp @@ -483,12 +483,14 @@ namespace uobjecthook { return 0; } - const auto default_object = ((sdk::UClass*)klass)->get_class_default_object(); - unsigned int i = 0; for (auto&& obj : objects) { - if (!allow_default && obj == default_object) { - continue; + if (!allow_default) { + const auto c = obj->get_class(); + + if (c == nullptr || c->get_class_default_object() == obj) { + continue; + } } if (i < max_objects && out_objects != nullptr) { @@ -522,12 +524,14 @@ namespace uobjecthook { return (UEVR_UObjectHandle)*objects.begin(); } - const auto default_object = ((sdk::UClass*)klass)->get_class_default_object(); - for (auto&& obj : objects) { - if (obj != default_object) { - return (UEVR_UObjectHandle)obj; + const auto c = obj->get_class(); + + if (c == nullptr || c->get_class_default_object() == obj) { + continue; } + + return (UEVR_UObjectHandle)obj; } return (UEVR_UObjectHandle)nullptr;