From 93f89471096a10494cd47a892a39059685e31ac0 Mon Sep 17 00:00:00 2001 From: praydog Date: Sat, 12 Oct 2024 10:32:58 -0700 Subject: [PATCH] UObjectHook: Add support for viewing TArrays of StructProperty types --- src/mods/UObjectHook.cpp | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/mods/UObjectHook.cpp b/src/mods/UObjectHook.cpp index 967eacce..206d9e4a 100644 --- a/src/mods/UObjectHook.cpp +++ b/src/mods/UObjectHook.cpp @@ -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*)((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;