Skip to content

Commit

Permalink
Plugins: Activate UObjectHook if any functions are called
Browse files Browse the repository at this point in the history
  • Loading branch information
praydog committed Jun 28, 2024
1 parent 6eecdb9 commit 3d59cc8
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/mods/PluginLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 3d59cc8

Please # to comment.