StructSerialiser: fix serialisation of array'd structs.

Not all of them are generic structs, after all.
This commit is contained in:
Guillaume Jacquemin 2021-09-23 18:24:55 +02:00
parent b8b156a724
commit d3d065c945

View file

@ -55,13 +55,19 @@ auto StructSerialiser::deserialise(const std::string& name, const std::string& t
}
else {
for(UnsignedInt i = 0; i < count; i++) {
auto prop = readStructValue(name, item_type, value_length, reader, serialiser);
auto prop = Containers::pointer<UnrealPropertyBase>();
prop = serialiser.readItem(reader, item_type, UnsignedLong(-1), name);
if(!prop) {
prop = readStructValue(name, item_type, value_length, reader, serialiser);
}
if(!prop) {
return nullptr;
}
prop->structGuid = guid;
static_cast<StructProperty*>(prop.get())->structGuid = guid;
arrayAppend(array, std::move(prop));
}
@ -131,8 +137,10 @@ auto StructSerialiser::serialise(Containers::ArrayView<UnrealPropertyBase::ptr>
return false;
}
if(!writeStructValue(struct_prop, bytes_written_here, writer, serialiser)) {
return false;
if(!serialiser.writeItem(prop, struct_prop->structType, bytes_written_here, writer)) {
if(!writeStructValue(struct_prop, bytes_written_here, writer, serialiser)) {
return false;
}
}
}