Skip to content

Commit

Permalink
Plugins: Fix cases where object finder could return default objects
Browse files Browse the repository at this point in the history
  • Loading branch information
praydog committed Jun 19, 2024
1 parent 459eb1b commit 9ccb374
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/mods/PluginLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 9ccb374

Please sign in to comment.