Serialisers: use Logger.

This commit is contained in:
Guillaume Jacquemin 2022-11-24 09:12:41 +01:00
parent 393ec4a372
commit d0a3375d7a
18 changed files with 116 additions and 50 deletions

View file

@ -160,6 +160,7 @@ auto PropertySerialiser::deserialise(Containers::String name, Containers::String
auto serialiser = getSerialiser(type);
if(serialiser == nullptr) {
LOG_ERROR_FORMAT("No valid serialiser found for property type {}.", type);
return nullptr;
}
@ -181,6 +182,7 @@ auto PropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, Containers::St
{
auto serialiser = getSerialiser(item_type);
if(!serialiser) {
LOG_ERROR_FORMAT("No valid serialiser found for property type {}.", item_type);
return false;
}
return serialiser->serialise(prop, bytes_written, writer, *this);

View file

@ -19,6 +19,7 @@
#include "../BinaryReader.h"
#include "../BinaryWriter.h"
#include "../PropertySerialiser.h"
#include "../../Logger/Logger.h"
#include "ArrayPropertySerialiser.h"
@ -28,16 +29,19 @@ auto ArrayPropertySerialiser::deserialiseProperty(Containers::StringView name, C
{
Containers::String item_type;
if(!reader.readUEString(item_type)) {
LOG_ERROR_FORMAT("Couldn't read the item type of array property {}.", name);
return nullptr;
}
char terminator;
if(!reader.readChar(terminator) || terminator != '\0') {
LOG_ERROR_FORMAT("Couldn't read a null byte in array property {}.", name);
return nullptr;
}
UnsignedInt item_count;
if(!reader.readUnsignedInt(item_count)) {
LOG_ERROR_FORMAT("Couldn't read array property {}'s item count.", name);
return nullptr;
}
@ -53,6 +57,7 @@ auto ArrayPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, U
{
auto array_prop = dynamic_cast<ArrayProperty*>(prop.get());
if(!array_prop) {
LOG_ERROR("The property is not a valid array property.");
return false;
}

View file

@ -16,6 +16,7 @@
#include "../BinaryReader.h"
#include "../BinaryWriter.h"
#include "../../Logger/Logger.h"
#include "BoolPropertySerialiser.h"
@ -30,15 +31,18 @@ auto BoolPropertySerialiser::deserialise(Containers::StringView name, Containers
PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr
{
if(value_length != 0) {
LOG_ERROR_FORMAT("Invalid value length for bool property {}. Expected 0, got {} instead.", name, value_length);
return nullptr;
}
Short value;
if(!reader.readShort(value)) {
LOG_ERROR_FORMAT("Couldn't read bool property {}'s value.", name);
return nullptr;
}
if(value > 1 || value < 0) {
LOG_ERROR_FORMAT("Bool property {}'s value is invalid. Expected 1 or 0, got {} instead.", name, value);
return nullptr;
}
@ -52,8 +56,8 @@ auto BoolPropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, UnsignedLo
BinaryWriter& writer, PropertySerialiser& serialiser) -> bool
{
auto bool_prop = dynamic_cast<BoolProperty*>(prop.get());
if(!bool_prop) {
LOG_ERROR("The property is not a valid bool property.");
return false;
}

View file

@ -16,6 +16,7 @@
#include "../BinaryReader.h"
#include "../BinaryWriter.h"
#include "../../Logger/Logger.h"
#include "BytePropertySerialiser.h"
@ -33,16 +34,19 @@ auto BytePropertySerialiser::deserialise(Containers::StringView name, Containers
if(value_length != UnsignedLong(-1)) {
if(!reader.readUEString(prop->enumType)) {
LOG_ERROR_FORMAT("Couldn't read byte property {}'s enum type.", name);
return nullptr;
}
char terminator;
if(!reader.readChar(terminator) || terminator != '\0') {
LOG_ERROR_FORMAT("Couldn't read a null byte in byte property {}.", name);
return nullptr;
}
}
if(!reader.readUEString(prop->enumValue)) {
LOG_ERROR("Couldn't read byte property's enum value.");
return nullptr;
}
@ -64,8 +68,8 @@ auto BytePropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, UnsignedLo
BinaryWriter& writer, PropertySerialiser& serialiser) -> bool
{
auto byte_prop = dynamic_cast<ByteProperty*>(prop.get());
if(!byte_prop) {
LOG_ERROR("The property is not a valid byte property.");
return false;
}

View file

@ -16,6 +16,7 @@
#include "../BinaryReader.h"
#include "../BinaryWriter.h"
#include "../../Logger/Logger.h"
#include "ColourPropertySerialiser.h"
@ -28,6 +29,7 @@ auto ColourPropertySerialiser::deserialiseProperty(Containers::StringView name,
if(!reader.readFloat(prop->r) || !reader.readFloat(prop->g) ||
!reader.readFloat(prop->b) || !reader.readFloat(prop->a))
{
LOG_ERROR_FORMAT("Couldn't read colour property {}'s value.", name);
return nullptr;
}
@ -38,8 +40,8 @@ auto ColourPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop,
BinaryWriter& writer, PropertySerialiser& serialiser) -> bool
{
auto colour_prop = dynamic_cast<ColourStructProperty*>(prop.get());
if(!colour_prop) {
LOG_ERROR("The property is not a valid colour property.");
return false;
}

View file

@ -16,6 +16,7 @@
#include "../BinaryReader.h"
#include "../BinaryWriter.h"
#include "../../Logger/Logger.h"
#include "DateTimePropertySerialiser.h"
@ -26,6 +27,7 @@ auto DateTimePropertySerialiser::deserialiseProperty(Containers::StringView name
auto prop = Containers::pointer<DateTimeStructProperty>();
if(!reader.readUnsignedLong(prop->timestamp)) {
LOG_ERROR_FORMAT("Couldn't read date/time property {}'s value.", name);
return nullptr;
}
@ -36,8 +38,8 @@ auto DateTimePropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop
BinaryWriter& writer, PropertySerialiser& serialiser) -> bool
{
auto dt_prop = dynamic_cast<DateTimeStructProperty*>(prop.get());
if(!dt_prop) {
LOG_ERROR("The property is not a valid date/time property.");
return false;
}

View file

@ -16,6 +16,7 @@
#include "../BinaryReader.h"
#include "../BinaryWriter.h"
#include "../../Logger/Logger.h"
#include "EnumPropertySerialiser.h"
@ -32,15 +33,18 @@ auto EnumPropertySerialiser::deserialise(Containers::StringView name, Containers
auto prop = Containers::pointer<EnumProperty>();
if(!reader.readUEString(prop->enumType)) {
LOG_ERROR_FORMAT("Couldn't read enum property {}'s enum type.", name);
return nullptr;
}
char terminator;
if(!reader.readChar(terminator) || terminator != '\0') {
LOG_ERROR_FORMAT("Couldn't read a null byte in enum property {}.", name);
return nullptr;
}
if(!reader.readUEString(prop->value)) {
LOG_ERROR_FORMAT("Couldn't read enum property {}'s enum value.", name);
return nullptr;
}
@ -51,8 +55,8 @@ auto EnumPropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, UnsignedLo
BinaryWriter& writer, PropertySerialiser& serialiser) -> bool
{
auto enum_prop = dynamic_cast<EnumProperty*>(prop.get());
if(!enum_prop) {
LOG_ERROR("The property is not a valid enum property.");
return false;
}

View file

@ -16,6 +16,7 @@
#include "../BinaryReader.h"
#include "../BinaryWriter.h"
#include "../../Logger/Logger.h"
#include "FloatPropertySerialiser.h"
@ -33,10 +34,12 @@ auto FloatPropertySerialiser::deserialise(Containers::StringView name, Container
char terminator;
if(!reader.readChar(terminator) || terminator != '\0') {
LOG_ERROR_FORMAT("Couldn't read a null byte in float property {}.", name);
return nullptr;
}
if(!reader.readFloat(prop->value)) {
LOG_ERROR_FORMAT("Couldn't read float property {}'s value.", name);
return nullptr;
}
@ -47,8 +50,8 @@ auto FloatPropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, UnsignedL
BinaryWriter& writer, PropertySerialiser& serialiser) -> bool
{
auto float_prop = dynamic_cast<FloatProperty*>(prop.get());
if(!float_prop) {
LOG_ERROR("The property is not a valid float property.");
return false;
}

View file

@ -16,6 +16,7 @@
#include "../BinaryReader.h"
#include "../BinaryWriter.h"
#include "../../Logger/Logger.h"
#include "GuidPropertySerialiser.h"
@ -28,7 +29,7 @@ auto GuidPropertySerialiser::deserialiseProperty(Containers::StringView name, Co
auto prop = Containers::pointer<GuidStructProperty>();
if(!reader.readStaticArray(prop->guid)) {
Utility::Error{} << "Couldn't read GUID in"_s << __func__;
LOG_ERROR_FORMAT("Couldn't read GUID property {}'s value.", name);
return nullptr;
}
@ -39,8 +40,8 @@ auto GuidPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, Un
BinaryWriter& writer, PropertySerialiser& serialiser) -> bool
{
auto guid_prop = dynamic_cast<GuidStructProperty*>(prop.get());
if(!guid_prop) {
LOG_ERROR("The property is not a valid byte property.");
return false;
}

View file

@ -16,6 +16,7 @@
#include "../BinaryReader.h"
#include "../BinaryWriter.h"
#include "../../Logger/Logger.h"
#include "IntPropertySerialiser.h"
@ -27,6 +28,7 @@ auto IntPropertySerialiser::deserialiseProperty(Containers::StringView name, Con
if(value_length == UnsignedLong(-1)) {
if(!reader.readInt(prop->value)) {
LOG_ERROR("Couldn't read int property's value.");
return nullptr;
}
@ -36,10 +38,12 @@ auto IntPropertySerialiser::deserialiseProperty(Containers::StringView name, Con
char terminator;
if(!reader.readChar(terminator) || terminator != '\0') {
LOG_ERROR_FORMAT("Couldn't read a null byte in int property {}.", name);
return nullptr;
}
if(!reader.readInt(prop->value)) {
LOG_ERROR_FORMAT("Couldn't read int property {}'s value.", name);
return nullptr;
}
@ -52,8 +56,8 @@ auto IntPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, Uns
BinaryWriter& writer, PropertySerialiser& serialiser) -> bool
{
auto int_prop = dynamic_cast<IntProperty*>(prop.get());
if(!int_prop) {
LOG_ERROR("The property is not a valid int property.");
return false;
}

View file

@ -17,8 +17,8 @@
#include "../BinaryReader.h"
#include "../BinaryWriter.h"
#include "../PropertySerialiser.h"
#include "../Types/NoneProperty.h"
#include "../../Logger/Logger.h"
#include "MapPropertySerialiser.h"
@ -31,25 +31,30 @@ auto MapPropertySerialiser::deserialiseProperty(Containers::StringView name, Con
auto prop = Containers::pointer<MapProperty>();
if(!reader.readUEString(prop->keyType)) {
LOG_ERROR_FORMAT("Couldn't read map property {}'s key type.", name);
return nullptr;
}
if(!reader.readUEString(prop->valueType)) {
LOG_ERROR_FORMAT("Couldn't read map property {}'s value type.", name);
return nullptr;
}
char terminator;
if(!reader.readChar(terminator) || terminator != '\0') {
LOG_ERROR_FORMAT("Couldn't read a null byte in map property {}.", name);
return nullptr;
}
UnsignedInt null;
if(!reader.readUnsignedInt(null) || null != 0u) {
LOG_ERROR_FORMAT("Couldn't read a null int in map property {}.", name);
return nullptr;
}
UnsignedInt count;
if(!reader.readUnsignedInt(count)) {
LOG_ERROR_FORMAT("Couldn't read map property {}'s item count.", name);
return nullptr;
}
@ -64,10 +69,12 @@ auto MapPropertySerialiser::deserialiseProperty(Containers::StringView name, Con
if(prop->keyType == "IntProperty"_s || prop->keyType == "StrProperty"_s) {
pair.key = serialiser.readItem(reader, prop->keyType, -1, name);
if(pair.key == nullptr) {
LOG_ERROR_FORMAT("Couldn't read a valid key in map property {}.", name);
return nullptr;
}
}
else { // Add other branches depending on key type, should more maps appear in the future.
LOG_ERROR_FORMAT("Key type {} not implemented.", prop->keyType);
return nullptr;
}
@ -105,6 +112,7 @@ auto MapPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, Uns
{
auto map_prop = dynamic_cast<MapProperty*>(prop.get());
if(!map_prop) {
LOG_ERROR("The property is not a valid map property.");
return false;
}
@ -120,17 +128,20 @@ auto MapPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, Uns
UnsignedLong dummy_bytes_written = 0;
for(auto& pair : map_prop->map) {
if(!serialiser.writeItem(pair.key, map_prop->keyType, dummy_bytes_written, writer)) {
LOG_ERROR("Couldn't write a key.");
return false;
}
for(auto& value : pair.values) {
if(map_prop->valueType == "StructProperty"_s) {
if(!serialiser.write(value, dummy_bytes_written, writer)) {
LOG_ERROR("Couldn't write a value.");
return false;
}
}
else {
if(!serialiser.writeItem(value, map_prop->valueType, dummy_bytes_written, writer)) {
LOG_ERROR("Couldn't write a value.");
return false;
}
}

View file

@ -17,9 +17,9 @@
#include "../BinaryReader.h"
#include "../BinaryWriter.h"
#include "../PropertySerialiser.h"
#include "../Types/IntProperty.h"
#include "../Types/NoneProperty.h"
#include "../../Logger/Logger.h"
#include "ResourcePropertySerialiser.h"
@ -31,49 +31,46 @@ auto ResourcePropertySerialiser::deserialiseProperty(Containers::StringView name
{
auto prop = Containers::pointer<ResourceItemValue>();
Containers::String str;
if(!reader.readUEString(str) || str != "ID_4_AAE08F17428E229EC7A2209F51081A21"_s) {
auto id_prop = serialiser.read(reader);
if(!id_prop) {
LOG_ERROR("Couldn't read the ID property."_s);
return nullptr;
}
if(!reader.readUEString(str) || str != "IntProperty"_s) {
if((*id_prop->name) != "ID_4_AAE08F17428E229EC7A2209F51081A21"_s ||
id_prop->propertyType != "IntProperty"_s ||
dynamic_cast<IntProperty*>(id_prop.get()) == nullptr)
{
LOG_ERROR("The ID property is invalid."_s);
return nullptr;
}
if(!reader.readUnsignedLong(value_length) || value_length != 4ull) {
prop->id = dynamic_cast<IntProperty*>(id_prop.get())->value;
auto value_prop = serialiser.read(reader);
if(!value_prop) {
LOG_ERROR("Couldn't read the value property."_s);
return nullptr;
}
char terminator;
if(!reader.readChar(terminator) || terminator != '\0') {
if((*value_prop->name) != "Quantity_3_560F09B5485C365D3041888910019CE3"_s ||
value_prop->propertyType != "IntProperty"_s ||
dynamic_cast<IntProperty*>(value_prop.get()) == nullptr)
{
LOG_ERROR("The value property is invalid."_s);
return nullptr;
}
if(!reader.readInt(prop->id)) {
return nullptr;
}
prop->quantity = dynamic_cast<IntProperty*>(value_prop.get())->value;
if(!reader.readUEString(str) || str != "Quantity_3_560F09B5485C365D3041888910019CE3"_s) {
return nullptr;
}
auto none_prop = serialiser.read(reader);
if(!reader.readUEString(str) || str != "IntProperty"_s) {
return nullptr;
}
if(!reader.readUnsignedLong(value_length) || value_length != 4ull) {
return nullptr;
}
if(!reader.readChar(terminator) || terminator != '\0') {
return nullptr;
}
if(!reader.readInt(prop->quantity)) {
return nullptr;
}
if(!reader.readUEString(str) || str != "None"_s) {
if(!none_prop ||
(*none_prop->name) != "None"_s ||
none_prop->propertyType != "NoneProperty"_s ||
!dynamic_cast<NoneProperty*>(none_prop.get()))
{
LOG_ERROR("Couldn't find a terminating NoneProperty."_s);
return nullptr;
}
@ -85,6 +82,7 @@ auto ResourcePropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop
{
auto res_prop = dynamic_cast<ResourceItemValue*>(prop.get());
if(!res_prop) {
LOG_ERROR("The property is not a valid ResourceItemValue property.");
return false;
}

View file

@ -16,6 +16,7 @@
#include "../BinaryReader.h"
#include "../BinaryWriter.h"
#include "../../Logger/Logger.h"
#include "RotatorPropertySerialiser.h"
@ -26,6 +27,7 @@ auto RotatorPropertySerialiser::deserialiseProperty(Containers::StringView name,
auto prop = Containers::pointer<RotatorStructProperty>();
if(!reader.readFloat(prop->x) || !reader.readFloat(prop->y) || !reader.readFloat(prop->z)) {
LOG_ERROR_FORMAT("Couldn't read rotator property {}'s value.", name);
return nullptr;
}
@ -36,8 +38,8 @@ auto RotatorPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop,
BinaryWriter& writer, PropertySerialiser& serialiser) -> bool
{
auto rotator = dynamic_cast<RotatorStructProperty*>(prop.get());
if(!rotator) {
LOG_ERROR("The property is not a valid rotator property.");
return false;
}

View file

@ -17,6 +17,7 @@
#include "../BinaryReader.h"
#include "../BinaryWriter.h"
#include "../PropertySerialiser.h"
#include "../../Logger/Logger.h"
#include "SetPropertySerialiser.h"
@ -26,21 +27,25 @@ auto SetPropertySerialiser::deserialiseProperty(Containers::StringView name, Con
{
Containers::String item_type;
if(!reader.readUEString(item_type)) {
LOG_ERROR_FORMAT("Couldn't read set property {}'s item type.", name);
return nullptr;
}
char terminator;
if(!reader.readChar(terminator) || terminator != '\0') {
LOG_ERROR_FORMAT("Couldn't read a null byte in set property {}.", name);
return nullptr;
}
UnsignedInt four_bytes;
if(!reader.readUnsignedInt(four_bytes) || four_bytes != 0u) {
LOG_ERROR_FORMAT("Couldn't read four null bytes in set property {}.", name);
return nullptr;
}
UnsignedInt item_count;
if(!reader.readUnsignedInt(item_count)) {
LOG_ERROR_FORMAT("Couldn't read set property {}'s item count.", name);
return nullptr;
}
@ -56,6 +61,7 @@ auto SetPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, Uns
{
auto set_prop = dynamic_cast<SetProperty*>(prop.get());
if(!set_prop) {
LOG_ERROR("The property is not a valid set property.");
return false;
}

View file

@ -16,6 +16,7 @@
#include "../BinaryReader.h"
#include "../BinaryWriter.h"
#include "../../Logger/Logger.h"
#include "StringPropertySerialiser.h"
@ -36,11 +37,13 @@ auto StringPropertySerialiser::deserialise(Containers::StringView name, Containe
if(value_length != UnsignedLong(-1)) {
char terminator;
if(!reader.readChar(terminator) || terminator != '\0') {
LOG_ERROR_FORMAT("Couldn't read a null byte in string property {}.", name);
return nullptr;
}
}
if(!reader.readUEString(prop->value)) {
LOG_ERROR_FORMAT("Couldn't read string property {}'s value.", name);
return nullptr;
}
@ -53,8 +56,8 @@ auto StringPropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, Unsigned
BinaryWriter& writer, PropertySerialiser& serialiser) -> bool
{
auto str_prop = dynamic_cast<StringProperty*>(prop.get());
if(!str_prop) {
LOG_ERROR("The property is not a valid string property.");
return false;
}

View file

@ -19,9 +19,9 @@
#include "../BinaryReader.h"
#include "../BinaryWriter.h"
#include "../PropertySerialiser.h"
#include "../Types/GenericStructProperty.h"
#include "../Types/NoneProperty.h"
#include "../../Logger/Logger.h"
#include "StructSerialiser.h"
@ -36,16 +36,19 @@ auto StructSerialiser::deserialise(Containers::StringView name, Containers::Stri
{
Containers::String item_type;
if(!reader.readUEString(item_type)) {
LOG_ERROR_FORMAT("Couldn't read struct property {}'s item type.", name);
return nullptr;
}
Containers::StaticArray<16, char> guid{ValueInit};
if(!reader.readStaticArray(guid)) {
LOG_ERROR_FORMAT("Couldn't read struct property {}'s GUID.", name);
return nullptr;
}
char terminator;
if(!reader.readChar(terminator) || terminator != '\0') {
LOG_ERROR_FORMAT("Couldn't read a null byte in struct property {}.", name);
return nullptr;
}
@ -67,10 +70,11 @@ auto StructSerialiser::deserialise(Containers::StringView name, Containers::Stri
}
if(!prop) {
LOG_ERROR("Invalid property");
return nullptr;
}
static_cast<StructProperty*>(prop.get())->structGuid = guid;
dynamic_cast<StructProperty*>(prop.get())->structGuid = guid;
arrayAppend(array, std::move(prop));
}
@ -84,20 +88,23 @@ auto StructSerialiser::deserialise(Containers::StringView name, Containers::Stri
{
Containers::String item_type;
if(!reader.readUEString(item_type)) {
LOG_ERROR_FORMAT("Couldn't read struct property {}'s item type.", name);
return nullptr;
}
if(item_type == "None") {
return Containers::pointer<NoneProperty>();
return NoneProperty::ptr{};
}
Containers::StaticArray<16, char> guid{ValueInit};
if(!reader.readStaticArray(guid)) {
LOG_ERROR_FORMAT("Couldn't read struct property {}'s GUID.", name);
return nullptr;
}
char terminator;
if(!reader.readChar(terminator) || terminator != '\0') {
LOG_ERROR_FORMAT("Couldn't read a null byte in byte property {}.", name);
return nullptr;
}
@ -123,6 +130,7 @@ auto StructSerialiser::serialise(Containers::ArrayView<UnrealPropertyBase::ptr>
auto struct_prop = dynamic_cast<StructProperty*>(props.front().get());
if(!struct_prop) {
LOG_ERROR("The property is not a valid struct property.");
return false;
}
@ -135,13 +143,14 @@ auto StructSerialiser::serialise(Containers::ArrayView<UnrealPropertyBase::ptr>
UnsignedLong bytes_written_here = 0;
for(auto& prop : props) {
struct_prop = dynamic_cast<StructProperty*>(prop.get());
if(!struct_prop) {
LOG_ERROR("The property is not a valid struct property.");
return false;
}
if(!serialiser.writeItem(prop, struct_prop->structType, bytes_written_here, writer)) {
if(!writeStructValue(struct_prop, bytes_written_here, writer, serialiser)) {
LOG_ERROR("Couldn't write the struct value.");
return false;
}
}
@ -158,8 +167,8 @@ auto StructSerialiser::serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& by
BinaryWriter& writer, PropertySerialiser& serialiser) -> bool
{
auto struct_prop = dynamic_cast<StructProperty*>(prop.get());
if(!struct_prop) {
LOG_ERROR("The property is not a valid struct property.");
return false;
}
@ -171,6 +180,7 @@ auto StructSerialiser::serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& by
UnsignedLong dummy_bytes_written = 0;
UnsignedLong vl_start = writer.arrayPosition();
if(!writeStructValue(struct_prop, dummy_bytes_written, writer, serialiser)) {
LOG_ERROR("Couldn't write the struct value.");
return false;
}
bytes_written += writer.arrayPosition() - vl_start;
@ -206,13 +216,14 @@ auto StructSerialiser::writeStructValue(StructProperty* prop, UnsignedLong& byte
BinaryWriter& writer, PropertySerialiser& serialiser) -> bool
{
auto struct_prop = dynamic_cast<GenericStructProperty*>(prop);
if(!struct_prop) {
LOG_ERROR("The property is not a valid struct property.");
return false;
}
for(auto& item : struct_prop->properties) {
if(!serialiser.write(item, bytes_written, writer)) {
LOG_ERROR("Couldn't write the struct's data.");
return false;
}
}

View file

@ -16,6 +16,7 @@
#include "../BinaryReader.h"
#include "../BinaryWriter.h"
#include "../../Logger/Logger.h"
#include "Vector2DPropertySerialiser.h"
@ -26,6 +27,7 @@ auto Vector2DPropertySerialiser::deserialiseProperty(Containers::StringView name
auto prop = Containers::pointer<Vector2DStructProperty>();
if(!reader.readFloat(prop->x) || !reader.readFloat(prop->y)) {
LOG_ERROR_FORMAT("Couldn't read 2D vector property {}'s value.", name);
return nullptr;
}
@ -36,8 +38,8 @@ auto Vector2DPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop
BinaryWriter& writer, PropertySerialiser& serialiser) -> bool
{
auto vector = dynamic_cast<Vector2DStructProperty*>(prop.get());
if(!vector) {
LOG_ERROR("The property is not a valid 2D vector property.");
return false;
}

View file

@ -16,6 +16,7 @@
#include "../BinaryReader.h"
#include "../BinaryWriter.h"
#include "../../Logger/Logger.h"
#include "VectorPropertySerialiser.h"
@ -26,6 +27,7 @@ auto VectorPropertySerialiser::deserialiseProperty(Containers::StringView name,
auto prop = Containers::pointer<VectorStructProperty>();
if(!reader.readFloat(prop->x) || !reader.readFloat(prop->y) || !reader.readFloat(prop->z)) {
LOG_ERROR_FORMAT("Couldn't read vector property {}'s value.", name);
return nullptr;
}
@ -36,8 +38,8 @@ auto VectorPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop,
BinaryWriter& writer, PropertySerialiser& serialiser) -> bool
{
auto vector = dynamic_cast<VectorStructProperty*>(prop.get());
if(!vector) {
LOG_ERROR("The property is not a valid vector property.");
return false;
}