Skip to content

Commit

Permalink
Merge pull request #630 from UE4SS-RE/LuaTArray
Browse files Browse the repository at this point in the history
  • Loading branch information
narknon authored Aug 27, 2024
2 parents fb8c324 + c73b56b commit f3dfd82
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions UE4SS/src/LuaType/LuaUObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -745,15 +745,14 @@ namespace RC::LuaType

size_t array_element_size = inner->GetElementSize();

unsigned char* array{};
auto array = new(params.data) Unreal::FScriptArray{};
size_t table_length = lua_rawlen(params.lua.get_lua_state(), 1);
bool has_elements = table_length > 0;

size_t element_index{0};

if (has_elements)
{
array = new unsigned char[array_property->GetElementSize() * table_length];

params.lua.for_each_in_table([&](LuaMadeSimple::LuaTableReference table) -> bool {
// Skip this table entry if the key wasn't numerical, who knows what the user put in their script
Expand All @@ -763,10 +762,11 @@ namespace RC::LuaType
}

params.lua.insert_value(-2);
array->AddZeroed(1, inner->GetSize(), inner->GetMinAlignment());
const PusherParams pusher_params{.operation = Operation::Set,
.lua = params.lua,
.base = static_cast<Unreal::UObject*>(static_cast<void*>(array)), // Base is the start of the params struct
.data = &array[array_element_size * element_index],
.base = static_cast<Unreal::UObject*>(array->GetData()), // Base is the start of the params struct
.data = &static_cast<uint8_t*>(array->GetData())[array_element_size * element_index],
.property = inner};
StaticState::m_property_value_pushers[name_comparison_index](pusher_params);

Expand Down

0 comments on commit f3dfd82

Please sign in to comment.