Compare commits

..

No commits in common. "10becfdc318da4ce8e42909fa5a9eb29a63a5c94" and "de07b760d04996384c704cd002eb94901ef810cf" have entirely different histories.

4 changed files with 20 additions and 21 deletions

View file

@ -134,7 +134,7 @@ auto PropertySerialiser::readSet(BinaryReader& reader, const std::string& item_t
} }
else { else {
for(UnsignedInt i = 0; i < count; i++) { for(UnsignedInt i = 0; i < count; i++) {
auto item = readItem(reader, item_type, UnsignedLong(-1), ""); auto item = readItem(reader, item_type, -1, "");
arrayAppend(array, std::move(item)); arrayAppend(array, std::move(item));
} }
} }

View file

@ -26,8 +26,7 @@ struct GenericStructProperty : public StructProperty {
using ptr = Containers::Pointer<GenericStructProperty>; using ptr = Containers::Pointer<GenericStructProperty>;
template<typename T> template<typename T>
std::enable_if_t<std::is_base_of<UnrealPropertyBase, T>::value, T*> auto at(const std::string& name) -> T* {
at(const std::string& name) {
for(auto& item : properties) { for(auto& item : properties) {
if(item->name == name) { if(item->name == name) {
return static_cast<T*>(item.get()); return static_cast<T*>(item.get());

View file

@ -43,6 +43,15 @@ auto UESaveFile::reloadData() -> bool {
return valid(); return valid();
} }
auto UESaveFile::at(const std::string& name) -> UnrealPropertyBase* {
for(auto& prop : _properties) {
if(*(prop->name) == name) {
return prop.get();
}
}
return nullptr;
}
auto UESaveFile::props() -> Containers::ArrayView<UnrealPropertyBase::ptr> { auto UESaveFile::props() -> Containers::ArrayView<UnrealPropertyBase::ptr> {
return _properties; return _properties;
} }
@ -54,7 +63,7 @@ auto UESaveFile::saveToFile() -> bool {
return false; return false;
} }
if(!writer.writeArray(arrayView(_magicBytes)) || if(!writer.writeStaticArray(staticArrayView(_magicBytes)) ||
!writer.writeUnsignedInt(_saveVersion) || !writer.writeUnsignedInt(_saveVersion) ||
!writer.writeUnsignedInt(_packageVersion) || !writer.writeUnsignedInt(_packageVersion) ||
!writer.writeUnsignedShort(_engineVersion.major) || !writer.writeUnsignedShort(_engineVersion.major) ||

View file

@ -40,16 +40,7 @@ class UESaveFile {
auto reloadData() -> bool; auto reloadData() -> bool;
template<typename T> auto at(const std::string& name) -> UnrealPropertyBase*;
std::enable_if_t<std::is_base_of<UnrealPropertyBase, T>::value, T*>
at(const std::string& name) {
for(auto& prop : _properties) {
if(prop->name == name) {
return static_cast<T*>(prop.get());
}
}
return nullptr;
}
auto props() -> Containers::ArrayView<UnrealPropertyBase::ptr>; auto props() -> Containers::ArrayView<UnrealPropertyBase::ptr>;
@ -63,7 +54,7 @@ class UESaveFile {
std::string _filepath; std::string _filepath;
Containers::StaticArray<4, char> _magicBytes{'G', 'V', 'A', 'S'}; const Containers::StaticArray<4, char> _magicBytes{'G', 'V', 'A', 'S'};
UnsignedInt _saveVersion = 0; UnsignedInt _saveVersion = 0;
UnsignedInt _packageVersion = 0; UnsignedInt _packageVersion = 0;