Skip to content

Commit

Permalink
UObjectHook: Add support for viewing TArrays of StructProperty types
Browse files Browse the repository at this point in the history
  • Loading branch information
praydog committed Oct 12, 2024
1 parent b71dd05 commit 93f8947
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions src/mods/UObjectHook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3499,7 +3499,45 @@ void UObjectHook::ui_handle_array_property(void* addr, sdk::FArrayProperty* prop

break;
}
case "StructProperty"_fnv:
{
// Not really an array of void* but we will skip over individual elements
// using pointer arithmetic.
const auto& array_obj = *(sdk::TArray<void*>*)((uintptr_t)addr + prop->get_offset());

if (array_obj.data == nullptr || array_obj.count == 0) {
ImGui::Text("Empty array");
return;
}

const auto struct_prop = (sdk::FStructProperty*)inner;
const auto strukt = struct_prop->get_struct();

if (strukt == nullptr) {
ImGui::Text("Cannot determine struct type");
return;
}

auto element_size = strukt->get_struct_size();

if (element_size == 0) {
element_size = strukt->get_properties_size();

if (element_size == 0) {
ImGui::Text("Cannot determine struct size");
return;
}
}

for (size_t i = 0; i < array_obj.count; ++i) try {
auto element = (void*)((uintptr_t)array_obj.data + (i * element_size));
ui_handle_struct(element, strukt);
} catch(...) {
ImGui::Text("Failed to display element %d", i);
}

break;
}
default:
ImGui::Text("Array of %s (unsupported)", inner_c_type.data());
break;
Expand Down

0 comments on commit 93f8947

Please sign in to comment.