diff --git a/src/Logger/Logger.h b/src/Logger/Logger.h index 7450754..370c08b 100644 --- a/src/Logger/Logger.h +++ b/src/Logger/Logger.h @@ -49,7 +49,7 @@ class Logger { Logger(Logger&&) = delete; Logger& operator=(Logger&&) = delete; - static auto instance() -> Logger&; + static Logger& instance(); void initialise(); @@ -73,7 +73,7 @@ class Logger { std::mutex _logMutex{}; }; -auto logger() -> Logger&; +Logger& logger(); #define LOG(entry_type, message) logger().lockMutex(); \ logger().log(EntryType::entry_type, \ diff --git a/src/Logger/MagnumLogBuffer.cpp b/src/Logger/MagnumLogBuffer.cpp index e2e3df9..6436009 100644 --- a/src/Logger/MagnumLogBuffer.cpp +++ b/src/Logger/MagnumLogBuffer.cpp @@ -16,7 +16,12 @@ #include "MagnumLogBuffer.h" -MagnumLogBuffer::MagnumLogBuffer(EntryType type): std::stringbuf(std::ios_base::out), _type{type} {} +MagnumLogBuffer::MagnumLogBuffer(EntryType type): + std::stringbuf(std::ios_base::out), + _type{type} +{ + //ctor +} MagnumLogBuffer::~MagnumLogBuffer() = default; diff --git a/src/Mass/Mass.cpp b/src/Mass/Mass.cpp index 2608948..98f064f 100644 --- a/src/Mass/Mass.cpp +++ b/src/Mass/Mass.cpp @@ -42,11 +42,13 @@ Mass::Mass(Containers::StringView path) { refreshValues(); } -auto Mass::lastError() -> Containers::StringView { +Containers::StringView +Mass::lastError() { return _lastError; } -auto Mass::getNameFromFile(Containers::StringView path) -> Containers::Optional { +Containers::Optional +Mass::getNameFromFile(Containers::StringView path) { if(!Utility::Path::exists(path)) { LOG_ERROR_FORMAT("{} couldn't be found.", path); return Containers::NullOpt; @@ -76,7 +78,8 @@ auto Mass::getNameFromFile(Containers::StringView path) -> Containers::Optional< return {name_prop->value}; } -void Mass::refreshValues() { +void +Mass::refreshValues() { LOG_INFO_FORMAT("Refreshing values for {}.", _filename); logger().lockMutex(); @@ -229,16 +232,19 @@ void Mass::refreshValues() { _state = State::Valid; } -auto Mass::filename() -> Containers::StringView { +Containers::StringView +Mass::filename() { return _filename; } -auto Mass::name() -> Containers::StringView { +Containers::StringView +Mass::name() { CORRADE_INTERNAL_ASSERT(_name); return *_name; } -auto Mass::setName(Containers::StringView new_name) -> bool { +bool +Mass::setName(Containers::StringView new_name) { _name = {new_name}; auto unit_data = _mass->at("UnitData"_s); @@ -267,19 +273,22 @@ auto Mass::setName(Containers::StringView new_name) -> bool { return true; } -auto Mass::state() -> State { +Mass::State +Mass::state() { return _state; } -auto Mass::dirty() const -> bool { +bool Mass::dirty() const { return _dirty; } -void Mass::setDirty(bool dirty) { +void +Mass::setDirty(bool dirty) { _dirty = dirty; } -void Mass::getTuning() { +void +Mass::getTuning() { getTuningCategory(MASS_ENGINE, _tuning.engineId, MASS_GEARS, _tuning.gearIds); if(_state == State::Invalid) { @@ -299,35 +308,43 @@ void Mass::getTuning() { } } -auto Mass::engine() -> Int& { +Int& +Mass::engine() { return _tuning.engineId; } -auto Mass::gears() -> Containers::ArrayView { +Containers::ArrayView +Mass::gears() { return _tuning.gearIds; } -auto Mass::os() -> Int& { +Int& +Mass::os() { return _tuning.osId; } -auto Mass::modules() -> Containers::ArrayView { +Containers::ArrayView +Mass::modules() { return _tuning.moduleIds; } -auto Mass::architecture() -> Int& { +Int& +Mass::architecture() { return _tuning.archId; } -auto Mass::techs() -> Containers::ArrayView { +Containers::ArrayView +Mass::techs() { return _tuning.techIds; } -auto Mass::account() -> Containers::StringView { +Containers::StringView +Mass::account() { return _account; } -auto Mass::updateAccount(Containers::StringView new_account) -> bool { +bool +Mass::updateAccount(Containers::StringView new_account) { _account = new_account; auto account = _mass->at(MASS_ACCOUNT); @@ -347,8 +364,9 @@ auto Mass::updateAccount(Containers::StringView new_account) -> bool { return true; } -void Mass::getTuningCategory(Containers::StringView big_node_prop_name, Int& big_node_id, - Containers::StringView small_nodes_prop_name, Containers::ArrayView small_nodes_ids) +void +Mass::getTuningCategory(Containers::StringView big_node_prop_name, Int& big_node_id, + Containers::StringView small_nodes_prop_name, Containers::ArrayView small_nodes_ids) { LOG_INFO_FORMAT("Getting tuning data ({}, {}).", big_node_prop_name, small_nodes_prop_name); diff --git a/src/Mass/Mass.h b/src/Mass/Mass.h index 733c07f..ed991c7 100644 --- a/src/Mass/Mass.h +++ b/src/Mass/Mass.h @@ -45,10 +45,6 @@ struct ArrayProperty; class Mass { public: - enum class State : UnsignedByte { - Empty, Invalid, Valid - }; - explicit Mass(Containers::StringView path); Mass(const Mass&) = delete; @@ -57,96 +53,100 @@ class Mass { Mass(Mass&&) = default; Mass& operator=(Mass&&) = default; - auto lastError() -> Containers::StringView; + Containers::StringView lastError(); - static auto getNameFromFile(Containers::StringView path) -> Containers::Optional; + static Containers::Optional getNameFromFile(Containers::StringView path); void refreshValues(); - auto filename() -> Containers::StringView; + Containers::StringView filename(); - auto name() -> Containers::StringView; - auto setName(Containers::StringView new_name) -> bool; + Containers::StringView name(); + bool setName(Containers::StringView new_name); - auto state() -> State; + enum class State : UnsignedByte { + Empty, Invalid, Valid + }; - auto dirty() const -> bool; + State state(); + + bool dirty() const; void setDirty(bool dirty = true); - auto jointSliders() -> Joints&; + Joints& jointSliders(); void getJointSliders(); - auto writeJointSliders() -> bool; + bool writeJointSliders(); - auto frameStyles() -> Containers::ArrayView; + Containers::ArrayView frameStyles(); void getFrameStyles(); - auto writeFrameStyles() -> bool; + bool writeFrameStyles(); - auto eyeFlareColour() -> Color4&; + Color4& eyeFlareColour(); void getEyeFlareColour(); - auto writeEyeFlareColour() -> bool; + bool writeEyeFlareColour(); - auto frameCustomStyles() -> Containers::ArrayView; + Containers::ArrayView frameCustomStyles(); void getFrameCustomStyles(); - auto writeFrameCustomStyle(UnsignedLong index) -> bool; + bool writeFrameCustomStyle(UnsignedLong index); - auto armourParts() -> Containers::ArrayView; + Containers::ArrayView armourParts(); void getArmourParts(); - auto writeArmourPart(ArmourSlot slot) -> bool; + bool writeArmourPart(ArmourSlot slot); - auto bulletLauncherAttachmentStyle() -> BulletLauncherAttachmentStyle&; - auto bulletLauncherAttachments() -> Containers::ArrayView; + BulletLauncherAttachmentStyle& bulletLauncherAttachmentStyle(); + Containers::ArrayView bulletLauncherAttachments(); void getBulletLauncherAttachments(); - auto writeBulletLauncherAttachments() -> bool; + bool writeBulletLauncherAttachments(); - auto armourCustomStyles() -> Containers::ArrayView; + Containers::ArrayView armourCustomStyles(); void getArmourCustomStyles(); - auto writeArmourCustomStyle(UnsignedLong index) -> bool; + bool writeArmourCustomStyle(UnsignedLong index); - auto meleeWeapons() -> Containers::ArrayView; + Containers::ArrayView meleeWeapons(); void getMeleeWeapons(); - auto writeMeleeWeapons() -> bool; + bool writeMeleeWeapons(); - auto shields() -> Containers::ArrayView; + Containers::ArrayView shields(); void getShields(); - auto writeShields() -> bool; + bool writeShields(); - auto bulletShooters() -> Containers::ArrayView; + Containers::ArrayView bulletShooters(); void getBulletShooters(); - auto writeBulletShooters() -> bool; + bool writeBulletShooters(); - auto energyShooters() -> Containers::ArrayView; + Containers::ArrayView energyShooters(); void getEnergyShooters(); - auto writeEnergyShooters() -> bool; + bool writeEnergyShooters(); - auto bulletLaunchers() -> Containers::ArrayView; + Containers::ArrayView bulletLaunchers(); void getBulletLaunchers(); - auto writeBulletLaunchers() -> bool; + bool writeBulletLaunchers(); - auto energyLaunchers() -> Containers::ArrayView; + Containers::ArrayView energyLaunchers(); void getEnergyLaunchers(); - auto writeEnergyLaunchers() -> bool; + bool writeEnergyLaunchers(); - auto globalStyles() -> Containers::ArrayView; + Containers::ArrayView globalStyles(); void getGlobalStyles(); - auto writeGlobalStyle(UnsignedLong index) -> bool; + bool writeGlobalStyle(UnsignedLong index); void getTuning(); - auto engine() -> Int&; - auto gears() -> Containers::ArrayView; + Int& engine(); + Containers::ArrayView gears(); - auto os() -> Int&; - auto modules() -> Containers::ArrayView; + Int& os(); + Containers::ArrayView modules(); - auto architecture() -> Int&; - auto techs() -> Containers::ArrayView; + Int& architecture(); + Containers::ArrayView techs(); - auto account() -> Containers::StringView; - auto updateAccount(Containers::StringView new_account) -> bool; + Containers::StringView account(); + bool updateAccount(Containers::StringView new_account); private: void getCustomStyles(Containers::ArrayView styles, ArrayProperty* style_array); - auto writeCustomStyle(const CustomStyle& style, UnsignedLong index, ArrayProperty* style_array) -> bool; + bool writeCustomStyle(const CustomStyle& style, UnsignedLong index, ArrayProperty* style_array); void getDecals(Containers::ArrayView decals, ArrayProperty* decal_array); void writeDecals(Containers::ArrayView decals, ArrayProperty* decal_array); @@ -155,7 +155,7 @@ class Mass { void writeAccessories(Containers::ArrayView accessories, ArrayProperty* accs_array); void getWeaponType(Containers::StringView prop_name, Containers::ArrayView weapon_array); - auto writeWeaponType(Containers::StringView prop_name, Containers::ArrayView weapon_array) -> bool; + bool writeWeaponType(Containers::StringView prop_name, Containers::ArrayView weapon_array); void getTuningCategory(Containers::StringView big_node_prop_name, Int& big_node_id, Containers::StringView small_nodes_prop_name, Containers::ArrayView small_nodes_ids); diff --git a/src/Mass/Mass_Armour.cpp b/src/Mass/Mass_Armour.cpp index 8af925a..4a656c6 100644 --- a/src/Mass/Mass_Armour.cpp +++ b/src/Mass/Mass_Armour.cpp @@ -29,11 +29,13 @@ using namespace Containers::Literals; -auto Mass::armourParts() -> Containers::ArrayView { +Containers::ArrayView +Mass::armourParts() { return _armour.parts; } -void Mass::getArmourParts() { +void +Mass::getArmourParts() { LOG_INFO("Getting armour parts."); auto unit_data = _mass->at(MASS_UNIT_DATA); @@ -117,7 +119,8 @@ void Mass::getArmourParts() { } } -auto Mass::writeArmourPart(ArmourSlot slot) -> bool { +bool +Mass::writeArmourPart(ArmourSlot slot) { LOG_INFO_FORMAT("Writing armour part in slot {}.", static_cast(slot)); auto& part = *std::find_if(_armour.parts.begin(), _armour.parts.end(), [&slot](const ArmourPart& part){ return slot == part.slot; }); @@ -195,15 +198,18 @@ auto Mass::writeArmourPart(ArmourSlot slot) -> bool { return true; } -auto Mass::bulletLauncherAttachmentStyle() -> BulletLauncherAttachmentStyle& { +BulletLauncherAttachmentStyle& +Mass::bulletLauncherAttachmentStyle() { return _armour.blAttachmentStyle; } -auto Mass::bulletLauncherAttachments() -> Containers::ArrayView { +Containers::ArrayView +Mass::bulletLauncherAttachments() { return _armour.blAttachment; } -void Mass::getBulletLauncherAttachments() { +void +Mass::getBulletLauncherAttachments() { LOG_INFO("Getting the bullet launcher attachment data."); auto unit_data = _mass->at(MASS_UNIT_DATA); @@ -274,7 +280,8 @@ void Mass::getBulletLauncherAttachments() { } } -auto Mass::writeBulletLauncherAttachments() -> bool { +bool +Mass::writeBulletLauncherAttachments() { LOG_INFO("Writing bullet launcher attachments."); auto unit_data = _mass->at(MASS_UNIT_DATA); @@ -373,11 +380,13 @@ auto Mass::writeBulletLauncherAttachments() -> bool { return true; } -auto Mass::armourCustomStyles() -> Containers::ArrayView { +Containers::ArrayView +Mass::armourCustomStyles() { return _armour.customStyles; } -void Mass::getArmourCustomStyles() { +void +Mass::getArmourCustomStyles() { LOG_INFO("Getting the custom armour styles."); auto unit_data = _mass->at(MASS_UNIT_DATA); @@ -404,7 +413,8 @@ void Mass::getArmourCustomStyles() { getCustomStyles(_armour.customStyles, armour_styles); } -auto Mass::writeArmourCustomStyle(UnsignedLong index) -> bool { +bool +Mass::writeArmourCustomStyle(UnsignedLong index) { LOG_INFO_FORMAT("Writing custom armour style {}.", index); if(index > _armour.customStyles.size()) { diff --git a/src/Mass/Mass_DecalsAccessories.cpp b/src/Mass/Mass_DecalsAccessories.cpp index acb987f..7b28d25 100644 --- a/src/Mass/Mass_DecalsAccessories.cpp +++ b/src/Mass/Mass_DecalsAccessories.cpp @@ -29,7 +29,8 @@ using namespace Containers::Literals; -void Mass::getDecals(Containers::ArrayView decals, ArrayProperty* decal_array) { +void +Mass::getDecals(Containers::ArrayView decals, ArrayProperty* decal_array) { for(UnsignedInt i = 0; i < decal_array->items.size(); i++) { auto decal_prop = decal_array->at(i); CORRADE_INTERNAL_ASSERT(decal_prop); @@ -53,7 +54,8 @@ void Mass::getDecals(Containers::ArrayView decals, ArrayProperty* decal_a } } -void Mass::writeDecals(Containers::ArrayView decals, ArrayProperty* decal_array) { +void +Mass::writeDecals(Containers::ArrayView decals, ArrayProperty* decal_array) { for(UnsignedInt i = 0; i < decal_array->items.size(); i++) { auto decal_prop = decal_array->at(i); CORRADE_INTERNAL_ASSERT(decal_prop); @@ -87,7 +89,8 @@ void Mass::writeDecals(Containers::ArrayView decals, ArrayProperty* decal } } -void Mass::getAccessories(Containers::ArrayView accessories, ArrayProperty* accessory_array) { +void +Mass::getAccessories(Containers::ArrayView accessories, ArrayProperty* accessory_array) { for(UnsignedInt i = 0; i < accessory_array->items.size(); i++) { auto acc_prop = accessory_array->at(i); CORRADE_INTERNAL_ASSERT(acc_prop); @@ -112,7 +115,8 @@ void Mass::getAccessories(Containers::ArrayView accessories, ArrayPro } } -void Mass::writeAccessories(Containers::ArrayView accessories, ArrayProperty* accs_array) { +void +Mass::writeAccessories(Containers::ArrayView accessories, ArrayProperty* accs_array) { for(UnsignedInt i = 0; i < accs_array->items.size(); i++) { auto acc_prop = accs_array->at(i); CORRADE_INTERNAL_ASSERT(acc_prop); diff --git a/src/Mass/Mass_Frame.cpp b/src/Mass/Mass_Frame.cpp index c585a19..77721d7 100644 --- a/src/Mass/Mass_Frame.cpp +++ b/src/Mass/Mass_Frame.cpp @@ -26,11 +26,13 @@ using namespace Containers::Literals; -auto Mass::jointSliders() -> Joints& { +Joints& +Mass::jointSliders() { return _frame.joints; } -void Mass::getJointSliders() { +void +Mass::getJointSliders() { LOG_INFO("Getting joint sliders."); auto unit_data = _mass->at(MASS_UNIT_DATA); @@ -65,7 +67,8 @@ void Mass::getJointSliders() { _frame.joints.lowerLegs = (length ? length->value : 0.0f); } -auto Mass::writeJointSliders() -> bool { +bool +Mass::writeJointSliders() { LOG_INFO("Writing joint sliders"); auto unit_data = _mass->at(MASS_UNIT_DATA); @@ -181,11 +184,13 @@ auto Mass::writeJointSliders() -> bool { return true; } -auto Mass::frameStyles() -> Containers::ArrayView { +Containers::ArrayView +Mass::frameStyles() { return _frame.styles; } -void Mass::getFrameStyles() { +void +Mass::getFrameStyles() { LOG_INFO("Getting frame styles."); auto unit_data = _mass->at(MASS_UNIT_DATA); @@ -221,7 +226,8 @@ void Mass::getFrameStyles() { } } -auto Mass::writeFrameStyles() -> bool { +bool +Mass::writeFrameStyles() { LOG_INFO("Writing frame styles."); auto unit_data = _mass->at(MASS_UNIT_DATA); @@ -260,11 +266,13 @@ auto Mass::writeFrameStyles() -> bool { return true; } -auto Mass::eyeFlareColour() -> Color4& { +Color4& +Mass::eyeFlareColour() { return _frame.eyeFlare; } -void Mass::getEyeFlareColour() { +void +Mass::getEyeFlareColour() { LOG_INFO("Getting the eye flare colour."); auto unit_data = _mass->at(MASS_UNIT_DATA); @@ -291,7 +299,8 @@ void Mass::getEyeFlareColour() { _frame.eyeFlare = Color4{eye_flare_prop->r, eye_flare_prop->g, eye_flare_prop->b, eye_flare_prop->a}; } -auto Mass::writeEyeFlareColour() -> bool { +bool +Mass::writeEyeFlareColour() { LOG_INFO("Writing the eye flare colour."); auto unit_data = _mass->at(MASS_UNIT_DATA); @@ -331,11 +340,13 @@ auto Mass::writeEyeFlareColour() -> bool { return true; } -auto Mass::frameCustomStyles() -> Containers::ArrayView { +Containers::ArrayView +Mass::frameCustomStyles() { return _frame.customStyles; } -void Mass::getFrameCustomStyles() { +void +Mass::getFrameCustomStyles() { LOG_INFO("Getting the frame's custom styles."); auto unit_data = _mass->at(MASS_UNIT_DATA); @@ -362,7 +373,8 @@ void Mass::getFrameCustomStyles() { getCustomStyles(_frame.customStyles, frame_styles); } -auto Mass::writeFrameCustomStyle(UnsignedLong index) -> bool { +bool +Mass::writeFrameCustomStyle(UnsignedLong index) { LOG_INFO_FORMAT("Writing frame custom style number {}.", index); if(index > _frame.customStyles.size()) { diff --git a/src/Mass/Mass_Styles.cpp b/src/Mass/Mass_Styles.cpp index 362a850..a5181ef 100644 --- a/src/Mass/Mass_Styles.cpp +++ b/src/Mass/Mass_Styles.cpp @@ -27,11 +27,13 @@ using namespace Containers::Literals; -auto Mass::globalStyles() -> Containers::ArrayView { +Containers::ArrayView +Mass::globalStyles() { return _globalStyles; } -void Mass::getGlobalStyles() { +void +Mass::getGlobalStyles() { LOG_INFO("Getting global styles."); auto unit_data = _mass->at(MASS_UNIT_DATA); @@ -55,7 +57,8 @@ void Mass::getGlobalStyles() { getCustomStyles(_globalStyles, global_styles); } -auto Mass::writeGlobalStyle(UnsignedLong index) -> bool { +bool +Mass::writeGlobalStyle(UnsignedLong index) { LOG_INFO_FORMAT("Writing global style number {}.", index); if(index > _globalStyles.size()) { @@ -83,7 +86,8 @@ auto Mass::writeGlobalStyle(UnsignedLong index) -> bool { return writeCustomStyle(_globalStyles[index], index, global_styles); } -void Mass::getCustomStyles(Containers::ArrayView styles, ArrayProperty* style_array) { +void +Mass::getCustomStyles(Containers::ArrayView styles, ArrayProperty* style_array) { for(UnsignedInt i = 0; i < style_array->items.size(); i++) { auto style_prop = style_array->at(i); auto& style = styles[i]; @@ -106,7 +110,8 @@ void Mass::getCustomStyles(Containers::ArrayView styles, ArrayPrope } } -auto Mass::writeCustomStyle(const CustomStyle& style, UnsignedLong index, ArrayProperty* style_array) -> bool { +bool +Mass::writeCustomStyle(const CustomStyle& style, UnsignedLong index, ArrayProperty* style_array) { if(!style_array) { _lastError = "style_array is null."_s; LOG_ERROR(_lastError); diff --git a/src/Mass/Mass_Weapons.cpp b/src/Mass/Mass_Weapons.cpp index 62826e6..a9ea9fe 100644 --- a/src/Mass/Mass_Weapons.cpp +++ b/src/Mass/Mass_Weapons.cpp @@ -28,91 +28,110 @@ using namespace Containers::Literals; -auto Mass::meleeWeapons() -> Containers::ArrayView { +Containers::ArrayView +Mass::meleeWeapons() { return _weapons.melee; } -void Mass::getMeleeWeapons() { +void +Mass::getMeleeWeapons() { LOG_INFO("Getting melee weapons."); getWeaponType(MASS_WEAPONS_MELEE, _weapons.melee); } -auto Mass::writeMeleeWeapons() -> bool { +bool +Mass::writeMeleeWeapons() { LOG_INFO("Writing melee weapons."); return writeWeaponType(MASS_WEAPONS_MELEE, _weapons.melee); } -auto Mass::shields() -> Containers::ArrayView { +Containers::ArrayView +Mass::shields() { return _weapons.shields; } -void Mass::getShields() { +void +Mass::getShields() { LOG_INFO("Getting shields."); getWeaponType(MASS_WEAPONS_SHIELD, _weapons.shields); } -auto Mass::writeShields() -> bool { +bool +Mass::writeShields() { LOG_INFO("Writing shields."); return writeWeaponType(MASS_WEAPONS_SHIELD, _weapons.shields); } -auto Mass::bulletShooters() -> Containers::ArrayView { +Containers::ArrayView +Mass::bulletShooters() { return _weapons.bulletShooters; } -void Mass::getBulletShooters() { +void +Mass::getBulletShooters() { LOG_INFO("Getting bullet shooters."); getWeaponType(MASS_WEAPONS_BSHOOTER, _weapons.bulletShooters); } -auto Mass::writeBulletShooters() -> bool { +bool +Mass::writeBulletShooters() { LOG_INFO("Writing bullet shooters."); return writeWeaponType(MASS_WEAPONS_BSHOOTER, _weapons.bulletShooters); } -auto Mass::energyShooters() -> Containers::ArrayView { +Containers::ArrayView +Mass::energyShooters() { return _weapons.energyShooters; } -void Mass::getEnergyShooters() { +void +Mass::getEnergyShooters() { LOG_INFO("Getting energy shooters."); getWeaponType(MASS_WEAPONS_ESHOOTER, _weapons.energyShooters); } -auto Mass::writeEnergyShooters() -> bool { +bool +Mass::writeEnergyShooters() { LOG_INFO("Writing energy shooters."); return writeWeaponType(MASS_WEAPONS_ESHOOTER, _weapons.energyShooters); } -auto Mass::bulletLaunchers() -> Containers::ArrayView { +Containers::ArrayView +Mass::bulletLaunchers() { return _weapons.bulletLaunchers; } -void Mass::getBulletLaunchers() { +void +Mass::getBulletLaunchers() { LOG_INFO("Getting bullet launchers."); getWeaponType(MASS_WEAPONS_BLAUNCHER, _weapons.bulletLaunchers); } -auto Mass::writeBulletLaunchers() -> bool { +bool +Mass::writeBulletLaunchers() { LOG_INFO("Writing bullet launchers."); return writeWeaponType(MASS_WEAPONS_BLAUNCHER, _weapons.bulletLaunchers); } -auto Mass::energyLaunchers() -> Containers::ArrayView { +Containers::ArrayView +Mass::energyLaunchers() { return _weapons.energyLaunchers; } -void Mass::getEnergyLaunchers() { +void +Mass::getEnergyLaunchers() { LOG_INFO("Getting energy launchers."); getWeaponType(MASS_WEAPONS_ELAUNCHER, _weapons.energyLaunchers); } -auto Mass::writeEnergyLaunchers() -> bool { +bool +Mass::writeEnergyLaunchers() { LOG_INFO("Writing energy launchers."); return writeWeaponType(MASS_WEAPONS_ELAUNCHER, _weapons.energyLaunchers); } -void Mass::getWeaponType(Containers::StringView prop_name, Containers::ArrayView weapon_array) { +void +Mass::getWeaponType(Containers::StringView prop_name, Containers::ArrayView weapon_array) { auto unit_data = _mass->at(MASS_UNIT_DATA); if(!unit_data) { LOG_ERROR_FORMAT("Couldn't find {} in {}.", MASS_UNIT_DATA, _filename); @@ -223,7 +242,8 @@ void Mass::getWeaponType(Containers::StringView prop_name, Containers::ArrayView } } -auto Mass::writeWeaponType(Containers::StringView prop_name, Containers::ArrayView weapon_array) -> bool { +bool +Mass::writeWeaponType(Containers::StringView prop_name, Containers::ArrayView weapon_array) { auto unit_data = _mass->at(MASS_UNIT_DATA); if(!unit_data) { _lastError = "No unit data in "_s + _filename; diff --git a/src/MassManager/MassManager.cpp b/src/MassManager/MassManager.cpp index 788a4ef..8bec3b5 100644 --- a/src/MassManager/MassManager.cpp +++ b/src/MassManager/MassManager.cpp @@ -39,15 +39,18 @@ MassManager::MassManager(Containers::StringView save_path, Containers::StringVie refreshStagedMasses(); } -auto MassManager::lastError() -> Containers::StringView { +Containers::StringView +MassManager::lastError() { return _lastError; } -auto MassManager::hangar(Int hangar) -> Mass& { +Mass& +MassManager::hangar(Int hangar) { return _hangars[hangar]; } -void MassManager::refreshHangar(Int hangar) { +void +MassManager::refreshHangar(Int hangar) { if(hangar < 0 || hangar >= 32) { _lastError = "Hangar index out of range."; LOG_ERROR(_lastError); @@ -60,7 +63,8 @@ void MassManager::refreshHangar(Int hangar) { _hangars[hangar] = Mass{mass_filename}; } -auto MassManager::importMass(Containers::StringView staged_fn, Int hangar) -> bool { +bool +MassManager::importMass(Containers::StringView staged_fn, Int hangar) { if(hangar < 0 || hangar >= 32) { _lastError = "Hangar index out of range."; LOG_ERROR(_lastError); @@ -102,7 +106,8 @@ auto MassManager::importMass(Containers::StringView staged_fn, Int hangar) -> bo return true; } -auto MassManager::exportMass(Int hangar) -> bool { +bool +MassManager::exportMass(Int hangar) { if(hangar < 0 || hangar >= 32) { _lastError = "Hangar index out of range."_s; LOG_ERROR(_lastError); @@ -128,7 +133,8 @@ auto MassManager::exportMass(Int hangar) -> bool { return true; } -auto MassManager::moveMass(Int source, Int destination) -> bool { +bool +MassManager::moveMass(Int source, Int destination) { if(source < 0 || source >= 32) { _lastError = "Source hangar index out of range."_s; LOG_ERROR(_lastError); @@ -165,7 +171,8 @@ auto MassManager::moveMass(Int source, Int destination) -> bool { return true; } -auto MassManager::deleteMass(Int hangar) -> bool { +bool +MassManager::deleteMass(Int hangar) { if(hangar < 0 || hangar >= 32) { _lastError = "Hangar index out of range."_s; LOG_ERROR(_lastError); @@ -181,11 +188,13 @@ auto MassManager::deleteMass(Int hangar) -> bool { return true; } -auto MassManager::stagedMasses() -> std::map const& { +const std::map& +MassManager::stagedMasses() { return _stagedMasses; } -void MassManager::refreshStagedMasses() { +void +MassManager::refreshStagedMasses() { _stagedMasses.clear(); using Utility::Path::ListFlag; @@ -217,7 +226,8 @@ void MassManager::refreshStagedMasses() { } } -void MassManager::refreshStagedMass(Containers::StringView filename) { +void +MassManager::refreshStagedMass(Containers::StringView filename) { LOG_INFO_FORMAT("Refreshing staged unit with filename {}.", filename); bool file_exists = Utility::Path::exists(Utility::Path::join(_stagingAreaDirectory, filename)); @@ -237,7 +247,8 @@ void MassManager::refreshStagedMass(Containers::StringView filename) { } } -auto MassManager::deleteStagedMass(Containers::StringView filename) -> bool { +bool +MassManager::deleteStagedMass(Containers::StringView filename) { if(_stagedMasses.find(filename) == _stagedMasses.cend()) { _lastError = "The file "_s + filename + " couldn't be found in the list of staged M.A.S.S.es."_s; LOG_ERROR(_lastError); diff --git a/src/MassManager/MassManager.h b/src/MassManager/MassManager.h index 330d98d..c3e495b 100644 --- a/src/MassManager/MassManager.h +++ b/src/MassManager/MassManager.h @@ -30,22 +30,22 @@ class MassManager { public: MassManager(Containers::StringView save_path, Containers::StringView account, bool demo, Containers::StringView staging_dir); - auto lastError() -> Containers::StringView; + Containers::StringView lastError(); - auto hangar(int hangar) -> Mass&; + Mass& hangar(int hangar); void refreshHangar(int hangar); - auto importMass(Containers::StringView staged_fn, int hangar) -> bool; - auto exportMass(int hangar) -> bool; + bool importMass(Containers::StringView staged_fn, int hangar); + bool exportMass(int hangar); - auto moveMass(int source, int destination) -> bool; - auto deleteMass(int hangar) -> bool; + bool moveMass(int source, int destination); + bool deleteMass(int hangar); - auto stagedMasses() -> std::map const&; + std::map const& stagedMasses(); void refreshStagedMasses(); void refreshStagedMass(Containers::StringView filename); - auto deleteStagedMass(Containers::StringView filename) -> bool; + bool deleteStagedMass(Containers::StringView filename); private: Containers::StringView _saveDirectory; diff --git a/src/Profile/Profile.cpp b/src/Profile/Profile.cpp index 706a88f..288e8cf 100644 --- a/src/Profile/Profile.cpp +++ b/src/Profile/Profile.cpp @@ -62,31 +62,38 @@ Profile::Profile(Containers::StringView path): refreshValues(); } -auto Profile::valid() const -> bool { +bool +Profile::valid() const { return _valid; } -auto Profile::lastError() const -> Containers::StringView { +Containers::StringView +Profile::lastError() const { return _lastError; } -auto Profile::filename() const -> Containers::StringView { +Containers::StringView +Profile::filename() const { return _filename; } -auto Profile::type() const -> ProfileType { +ProfileType +Profile::type() const { return _type; } -auto Profile::isDemo() const -> bool { +bool +Profile::isDemo() const { return _type == ProfileType::Demo; } -auto Profile::account() const -> Containers::StringView { +Containers::StringView +Profile::account() const { return _account; } -void Profile::refreshValues() { +void +Profile::refreshValues() { if(!_profile.reloadData()) { LOG_ERROR(_profile.lastError()); _valid = false; @@ -157,11 +164,13 @@ void Profile::refreshValues() { _valid = true; } -auto Profile::companyName() const -> Containers::StringView { +Containers::StringView +Profile::companyName() const { return _name; } -auto Profile::renameCompany(Containers::StringView new_name) -> bool { +bool +Profile::renameCompany(Containers::StringView new_name) { auto name_prop = _profile.at(PROFILE_NAME); if(!name_prop) { _lastError = "No company name in "_s + _filename; @@ -180,15 +189,18 @@ auto Profile::renameCompany(Containers::StringView new_name) -> bool { return true; } -auto Profile::activeFrameSlot() const -> Int { +Int +Profile::activeFrameSlot() const { return _activeFrameSlot; } -auto Profile::credits() const -> Int { +Int +Profile::credits() const { return _credits; } -auto Profile::setCredits(Int amount) -> bool { +bool +Profile::setCredits(Int amount) { auto credits_prop = _profile.at(PROFILE_CREDITS); if(!credits_prop) { @@ -208,11 +220,13 @@ auto Profile::setCredits(Int amount) -> bool { return true; } -auto Profile::storyProgress() const -> Int { +Int +Profile::storyProgress() const { return _storyProgress; } -auto Profile::setStoryProgress(Int progress) -> bool { +bool +Profile::setStoryProgress(Int progress) { auto story_progress_prop = _profile.at("StoryProgress"_s); if(!story_progress_prop) { @@ -232,47 +246,58 @@ auto Profile::setStoryProgress(Int progress) -> bool { return true; } -auto Profile::lastMissionId() const -> Int { +Int +Profile::lastMissionId() const { return _lastMissionId; } -auto Profile::verseSteel() const -> Int { +Int +Profile::verseSteel() const { return _verseSteel; } -auto Profile::setVerseSteel(Int amount) -> bool { +bool +Profile::setVerseSteel(Int amount) { return setResource(PROFILE_MATERIAL, VerseSteel, amount); } -auto Profile::undinium() const -> Int { +Int +Profile::undinium() const { return _undinium; } -auto Profile::setUndinium(Int amount) -> bool { +bool +Profile::setUndinium(Int amount) { return setResource(PROFILE_MATERIAL, Undinium, amount); } -auto Profile::necriumAlloy() const -> Int { +Int +Profile::necriumAlloy() const { return _necriumAlloy; } -auto Profile::setNecriumAlloy(Int amount) -> bool { +bool +Profile::setNecriumAlloy(Int amount) { return setResource(PROFILE_MATERIAL, NecriumAlloy, amount); } -auto Profile::lunarite() const -> Int { +Int +Profile::lunarite() const { return _lunarite; } -auto Profile::setLunarite(Int amount) -> bool { +bool +Profile::setLunarite(Int amount) { return setResource(PROFILE_MATERIAL, Lunarite, amount); } -auto Profile::asterite() const -> Int { +Int +Profile::asterite() const { return _asterite; } -auto Profile::setAsterite(Int amount) -> bool { +bool +Profile::setAsterite(Int amount) { return setResource(PROFILE_MATERIAL, Asterite, amount); } @@ -286,43 +311,53 @@ Profile::setHalliteFragma(Int amount) { return setResource(PROFILE_MATERIAL, HalliteFragma, amount); } -auto Profile::ednil() const -> Int { +Int +Profile::ednil() const { return _ednil; } -auto Profile::setEdnil(Int amount) -> bool { +bool +Profile::setEdnil(Int amount) { return setResource(PROFILE_MATERIAL, Ednil, amount); } -auto Profile::nuflalt() const -> Int { +Int +Profile::nuflalt() const { return _nuflalt; } -auto Profile::setNuflalt(Int amount) -> bool { +bool +Profile::setNuflalt(Int amount) { return setResource(PROFILE_MATERIAL, Nuflalt, amount); } -auto Profile::aurelene() const -> Int { +Int +Profile::aurelene() const { return _aurelene; } -auto Profile::setAurelene(Int amount) -> bool { +bool +Profile::setAurelene(Int amount) { return setResource(PROFILE_MATERIAL, Aurelene, amount); } -auto Profile::soldus() const -> Int { +Int +Profile::soldus() const { return _soldus; } -auto Profile::setSoldus(Int amount) -> bool { +bool +Profile::setSoldus(Int amount) { return setResource(PROFILE_MATERIAL, Soldus, amount); } -auto Profile::synthesisedN() const -> Int { +Int +Profile::synthesisedN() const { return _synthesisedN; } -auto Profile::setSynthesisedN(Int amount) -> bool { +bool +Profile::setSynthesisedN(Int amount) { return setResource(PROFILE_MATERIAL, SynthesisedN, amount); } @@ -336,43 +371,53 @@ Profile::setNanoc(Int amount) { return setResource(PROFILE_MATERIAL, Nanoc, amount); } -auto Profile::alcarbonite() const -> Int { +Int +Profile::alcarbonite() const { return _alcarbonite; } -auto Profile::setAlcarbonite(Int amount) -> bool { +bool +Profile::setAlcarbonite(Int amount) { return setResource(PROFILE_MATERIAL, Alcarbonite, amount); } -auto Profile::keriphene() const -> Int { +Int +Profile::keriphene() const { return _keriphene; } -auto Profile::setKeriphene(Int amount) -> bool { +bool +Profile::setKeriphene(Int amount) { return setResource(PROFILE_MATERIAL, Keriphene, amount); } -auto Profile::nitinolCM() const -> Int { +Int +Profile::nitinolCM() const { return _nitinolCM; } -auto Profile::setNitinolCM(Int amount) -> bool { +bool +Profile::setNitinolCM(Int amount) { return setResource(PROFILE_MATERIAL, NitinolCM, amount); } -auto Profile::quarkium() const -> Int { +Int +Profile::quarkium() const { return _quarkium; } -auto Profile::setQuarkium(Int amount) -> bool { +bool +Profile::setQuarkium(Int amount) { return setResource(PROFILE_MATERIAL, Quarkium, amount); } -auto Profile::alterene() const -> Int { +Int +Profile::alterene() const { return _alterene; } -auto Profile::setAlterene(Int amount) -> bool { +bool +Profile::setAlterene(Int amount) { return setResource(PROFILE_MATERIAL, Alterene, amount); } @@ -386,43 +431,53 @@ Profile::setCosmium(Int amount) { return setResource(PROFILE_MATERIAL, Cosmium, amount); } -auto Profile::mixedComposition() const -> Int { +Int +Profile::mixedComposition() const { return _mixedComposition; } -auto Profile::setMixedComposition(Int amount) -> bool { +bool +Profile::setMixedComposition(Int amount) { return setResource(PROFILE_QUARK_DATA, MixedComposition, amount); } -auto Profile::voidResidue() const -> Int { +Int +Profile::voidResidue() const { return _voidResidue; } -auto Profile::setVoidResidue(Int amount) -> bool { +bool +Profile::setVoidResidue(Int amount) { return setResource(PROFILE_QUARK_DATA, VoidResidue, amount); } -auto Profile::muscularConstruction() const -> Int { +Int +Profile::muscularConstruction() const { return _muscularConstruction; } -auto Profile::setMuscularConstruction(Int amount) -> bool { +bool +Profile::setMuscularConstruction(Int amount) { return setResource(PROFILE_QUARK_DATA, MuscularConstruction, amount); } -auto Profile::mineralExoskeletology() const -> Int { +Int +Profile::mineralExoskeletology() const { return _mineralExoskeletology; } -auto Profile::setMineralExoskeletology(Int amount) -> bool { +bool +Profile::setMineralExoskeletology(Int amount) { return setResource(PROFILE_QUARK_DATA, MineralExoskeletology, amount); } -auto Profile::carbonisedSkin() const -> Int { +Int +Profile::carbonisedSkin() const { return _carbonisedSkin; } -auto Profile::setCarbonisedSkin(Int amount) -> bool { +bool +Profile::setCarbonisedSkin(Int amount) { return setResource(PROFILE_QUARK_DATA, CarbonisedSkin, amount); } @@ -436,7 +491,8 @@ Profile::setIsolatedVoidParticle(Int amount) { return setResource(PROFILE_QUARK_DATA, IsolatedVoidParticle, amount); } -auto Profile::getResource(Containers::StringView container, MaterialID id) -> Int { +Int +Profile::getResource(Containers::StringView container, MaterialID id) { auto mats_prop = _profile.at(container); if(!mats_prop) { @@ -452,7 +508,8 @@ auto Profile::getResource(Containers::StringView container, MaterialID id) -> In return it != mats_prop->items.end() ? static_cast(it->get())->quantity : 0; } -auto Profile::setResource(Containers::StringView container, MaterialID id, Int amount) -> bool { +bool +Profile::setResource(Containers::StringView container, MaterialID id, Int amount) { auto mats_prop = _profile.at(container); if(!mats_prop) { diff --git a/src/Profile/Profile.h b/src/Profile/Profile.h index eede0fd..e861160 100644 --- a/src/Profile/Profile.h +++ b/src/Profile/Profile.h @@ -51,93 +51,93 @@ class Profile { void refreshValues(); auto companyName() const -> Containers::StringView; - auto renameCompany(Containers::StringView new_name) -> bool; + bool renameCompany(Containers::StringView new_name); auto activeFrameSlot() const -> Int; auto credits() const -> Int; - auto setCredits(Int credits) -> bool; + bool setCredits(Int credits); auto storyProgress() const -> Int; - auto setStoryProgress(Int progress) -> bool; + bool setStoryProgress(Int progress); auto lastMissionId() const -> Int; auto verseSteel() const -> Int; - auto setVerseSteel(Int amount) -> bool; + bool setVerseSteel(Int amount); auto undinium() const -> Int; - auto setUndinium(Int amount) -> bool; + bool setUndinium(Int amount); auto necriumAlloy() const -> Int; - auto setNecriumAlloy(Int amount) -> bool; + bool setNecriumAlloy(Int amount); auto lunarite() const -> Int; - auto setLunarite(Int amount) -> bool; + bool setLunarite(Int amount); auto asterite() const -> Int; - auto setAsterite(Int amount) -> bool; + bool setAsterite(Int amount); Int halliteFragma() const; bool setHalliteFragma(Int amount); auto ednil() const -> Int; - auto setEdnil(Int amount) -> bool; + bool setEdnil(Int amount); auto nuflalt() const -> Int; - auto setNuflalt(Int amount) -> bool; + bool setNuflalt(Int amount); auto aurelene() const -> Int; - auto setAurelene(Int amount) -> bool; + bool setAurelene(Int amount); auto soldus() const -> Int; - auto setSoldus(Int amount) -> bool; + bool setSoldus(Int amount); auto synthesisedN() const -> Int; - auto setSynthesisedN(Int amount) -> bool; + bool setSynthesisedN(Int amount); Int nanoc() const; bool setNanoc(Int amount); auto alcarbonite() const -> Int; - auto setAlcarbonite(Int amount) -> bool; + bool setAlcarbonite(Int amount); auto keriphene() const -> Int; - auto setKeriphene(Int amount) -> bool; + bool setKeriphene(Int amount); auto nitinolCM() const -> Int; - auto setNitinolCM(Int amount) -> bool; + bool setNitinolCM(Int amount); auto quarkium() const -> Int; - auto setQuarkium(Int amount) -> bool; + bool setQuarkium(Int amount); auto alterene() const -> Int; - auto setAlterene(Int amount) -> bool; + bool setAlterene(Int amount); Int cosmium() const; bool setCosmium(Int amount); auto mixedComposition() const -> Int; - auto setMixedComposition(Int amount) -> bool; + bool setMixedComposition(Int amount); auto voidResidue() const -> Int; - auto setVoidResidue(Int amount) -> bool; + bool setVoidResidue(Int amount); auto muscularConstruction() const -> Int; - auto setMuscularConstruction(Int amount) -> bool; + bool setMuscularConstruction(Int amount); auto mineralExoskeletology() const -> Int; - auto setMineralExoskeletology(Int amount) -> bool; + bool setMineralExoskeletology(Int amount); auto carbonisedSkin() const -> Int; - auto setCarbonisedSkin(Int amount) -> bool; + bool setCarbonisedSkin(Int amount); Int isolatedVoidParticle() const; bool setIsolatedVoidParticle(Int amount); private: - auto getResource(Containers::StringView container, MaterialID id) -> Int; - auto setResource(Containers::StringView container, MaterialID id, Int amount) -> bool; + Int getResource(Containers::StringView container, MaterialID id); + bool setResource(Containers::StringView container, MaterialID id, Int amount); Containers::String _filename; diff --git a/src/ProfileManager/ProfileManager.cpp b/src/ProfileManager/ProfileManager.cpp index 1b358a2..b6972ac 100644 --- a/src/ProfileManager/ProfileManager.cpp +++ b/src/ProfileManager/ProfileManager.cpp @@ -40,19 +40,23 @@ ProfileManager::ProfileManager(Containers::StringView save_dir, Containers::Stri _ready = refreshProfiles(); } -auto ProfileManager::ready() const -> bool { +bool +ProfileManager::ready() const { return _ready; } -auto ProfileManager::lastError() -> Containers::StringView { +Containers::StringView +ProfileManager::lastError() { return _lastError; } -auto ProfileManager::profiles() -> Containers::ArrayView { +Containers::ArrayView +ProfileManager::profiles() { return _profiles; } -auto ProfileManager::refreshProfiles() -> bool { +bool +ProfileManager::refreshProfiles() { LOG_INFO("Refreshing profiles."); _profiles = Containers::Array{}; @@ -93,11 +97,13 @@ auto ProfileManager::refreshProfiles() -> bool { return true; } -auto ProfileManager::getProfile(std::size_t index) -> Profile* { +Profile* +ProfileManager::getProfile(std::size_t index) { return index <= _profiles.size() ? &(_profiles[index]) : nullptr; } -auto ProfileManager::deleteProfile(std::size_t index, bool delete_builds) -> bool { +bool +ProfileManager::deleteProfile(std::size_t index, bool delete_builds) { if(!Utility::Path::remove(Utility::Path::join(_saveDirectory, _profiles[index].filename()))) { _lastError = Utility::format("Couldn't delete {} (filename: {}).", _profiles[index].companyName(), @@ -126,7 +132,8 @@ auto ProfileManager::deleteProfile(std::size_t index, bool delete_builds) -> boo return true; } -auto ProfileManager::backupProfile(std::size_t index, bool backup_builds) -> bool { +bool +ProfileManager::backupProfile(std::size_t index, bool backup_builds) { std::time_t timestamp = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now()); std::tm* time = std::localtime(×tamp); auto& profile = _profiles[index]; @@ -202,11 +209,13 @@ auto ProfileManager::backupProfile(std::size_t index, bool backup_builds) -> boo return true; } -auto ProfileManager::backups() -> Containers::ArrayView { +Containers::ArrayView +ProfileManager::backups() { return _backups; } -void ProfileManager::refreshBackups() { +void +ProfileManager::refreshBackups() { _backups = Containers::Array{}; using Utility::Path::ListFlag; @@ -290,7 +299,8 @@ void ProfileManager::refreshBackups() { } } -auto ProfileManager::deleteBackup(std::size_t index) -> bool { +bool +ProfileManager::deleteBackup(std::size_t index) { if(!Utility::Path::remove(Utility::Path::join(_backupsDirectory, _backups[index].filename))) { _lastError = "Couldn't delete " + _backups[index].filename; LOG_ERROR(_lastError); @@ -307,7 +317,8 @@ auto ProfileManager::deleteBackup(std::size_t index) -> bool { return true; } -auto ProfileManager::restoreBackup(std::size_t index) -> bool { +bool +ProfileManager::restoreBackup(std::size_t index) { const Backup& backup = _backups[index]; auto error_format = "Extraction of file {} failed: {}"_s; diff --git a/src/ProfileManager/ProfileManager.h b/src/ProfileManager/ProfileManager.h index 0fe9e11..56c5e0a 100644 --- a/src/ProfileManager/ProfileManager.h +++ b/src/ProfileManager/ProfileManager.h @@ -45,20 +45,20 @@ class ProfileManager { explicit ProfileManager(Containers::StringView save_dir, Containers::StringView backup_dir); auto ready() const -> bool; - auto lastError() -> Containers::StringView; + Containers::StringView lastError(); - auto profiles() -> Containers::ArrayView; - auto refreshProfiles() -> bool; + Containers::ArrayView profiles(); + bool refreshProfiles(); - auto getProfile(std::size_t index) -> Profile*; - auto deleteProfile(std::size_t index, bool delete_builds) -> bool; - auto backupProfile(std::size_t index, bool backup_builds) -> bool; + Profile* getProfile(std::size_t index); + bool deleteProfile(std::size_t index, bool delete_builds); + bool backupProfile(std::size_t index, bool backup_builds); - auto backups() -> Containers::ArrayView; + Containers::ArrayView backups(); void refreshBackups(); - auto deleteBackup(std::size_t index) -> bool; - auto restoreBackup(std::size_t index) -> bool; + bool deleteBackup(std::size_t index); + bool restoreBackup(std::size_t index); private: bool _ready = false; diff --git a/src/SaveTool/SaveTool.cpp b/src/SaveTool/SaveTool.cpp index a39d798..922e5e3 100644 --- a/src/SaveTool/SaveTool.cpp +++ b/src/SaveTool/SaveTool.cpp @@ -165,7 +165,8 @@ SaveTool::~SaveTool() { LOG_INFO("Exiting."); } -void SaveTool::drawEvent() { +void +SaveTool::drawEvent() { #ifdef SAVETOOL_DEBUG_BUILD tweak.update(); #endif @@ -185,45 +186,54 @@ void SaveTool::drawEvent() { _timeline.nextFrame(); } -void SaveTool::viewportEvent(ViewportEvent& event) { +void +SaveTool::viewportEvent(ViewportEvent& event) { GL::defaultFramebuffer.setViewport({{}, event.framebufferSize()}); const Vector2 size = Vector2{windowSize()}/dpiScaling(); _imgui.relayout(size, windowSize(), framebufferSize()); } -void SaveTool::keyPressEvent(KeyEvent& event) { +void +SaveTool::keyPressEvent(KeyEvent& event) { if(_imgui.handleKeyPressEvent(event)) return; } -void SaveTool::keyReleaseEvent(KeyEvent& event) { +void +SaveTool::keyReleaseEvent(KeyEvent& event) { if(_imgui.handleKeyReleaseEvent(event)) return; } -void SaveTool::mousePressEvent(MouseEvent& event) { +void +SaveTool::mousePressEvent(MouseEvent& event) { if(_imgui.handleMousePressEvent(event)) return; } -void SaveTool::mouseReleaseEvent(MouseEvent& event) { +void +SaveTool::mouseReleaseEvent(MouseEvent& event) { if(_imgui.handleMouseReleaseEvent(event)) return; } -void SaveTool::mouseMoveEvent(MouseMoveEvent& event) { +void +SaveTool::mouseMoveEvent(MouseMoveEvent& event) { if(_imgui.handleMouseMoveEvent(event)) return; } -void SaveTool::mouseScrollEvent(MouseScrollEvent& event) { +void +SaveTool::mouseScrollEvent(MouseScrollEvent& event) { if(_imgui.handleMouseScrollEvent(event)) { event.setAccepted(); return; } } -void SaveTool::textInputEvent(TextInputEvent& event) { +void +SaveTool::textInputEvent(TextInputEvent& event) { if(_imgui.handleTextInputEvent(event)) return; } -void SaveTool::anyEvent(SDL_Event& event) { +void +SaveTool::anyEvent(SDL_Event& event) { if(event.type == _initEventId) { initEvent(event); } @@ -235,7 +245,8 @@ void SaveTool::anyEvent(SDL_Event& event) { } } -void SaveTool::drawImGui() { +void +SaveTool::drawImGui() { _imgui.newFrame(); if(ImGui::GetIO().WantTextInput && !isTextInputActive()) { @@ -252,7 +263,8 @@ void SaveTool::drawImGui() { _imgui.drawFrame(); } -void SaveTool::drawGui() { +void +SaveTool::drawGui() { drawMainMenu(); switch(_uiState) { @@ -294,7 +306,8 @@ void SaveTool::drawGui() { _queue.draw(windowSize()); } -void SaveTool::drawDisclaimer() { +void +SaveTool::drawDisclaimer() { ImGui::SetNextWindowPos(ImVec2{Vector2{windowSize() / 2.0f}}, ImGuiCond_Always, center_pivot); if(ImGui::Begin("Disclaimer##DisclaimerWindow", nullptr, @@ -355,7 +368,8 @@ void SaveTool::drawDisclaimer() { ImGui::End(); } -void SaveTool::drawInitialisation() { +void +SaveTool::drawInitialisation() { ImGui::SetNextWindowPos(ImVec2{Vector2{windowSize() / 2.0f}}, ImGuiCond_Always, center_pivot); if(ImGui::BeginPopupModal("##InitPopup", nullptr, @@ -368,7 +382,8 @@ void SaveTool::drawInitialisation() { ImGui::OpenPopup("##InitPopup"); } -void SaveTool::drawGameState() { +void +SaveTool::drawGameState() { ImGui::TextUnformatted("Game state:"); ImGui::SameLine(); { @@ -389,12 +404,14 @@ void SaveTool::drawGameState() { } } -void SaveTool::drawHelpMarker(Containers::StringView text, Float wrap_pos) { +void +SaveTool::drawHelpMarker(Containers::StringView text, Float wrap_pos) { ImGui::TextUnformatted(ICON_FA_QUESTION_CIRCLE); drawTooltip(text, wrap_pos); } -void SaveTool::drawTooltip(Containers::StringView text, Float wrap_pos) { +void +SaveTool::drawTooltip(Containers::StringView text, Float wrap_pos) { if(ImGui::IsItemHovered()){ ImGui::BeginTooltip(); if(wrap_pos > 0.0f) { @@ -413,11 +430,13 @@ SaveTool::drawCheckbox(Containers::StringView label, bool value) { return ImGui::Checkbox(label.data(), &value); } -void SaveTool::openUri(Containers::StringView uri) { +void +SaveTool::openUri(Containers::StringView uri) { ShellExecuteW(nullptr, nullptr, Utility::Unicode::widen(uri.data()), nullptr, nullptr, SW_SHOWDEFAULT); } -void SaveTool::checkGameState() { +void +SaveTool::checkGameState() { WTS_PROCESS_INFOW* process_infos = nullptr; unsigned long process_count = 0; diff --git a/src/SaveTool/SaveTool.h b/src/SaveTool/SaveTool.h index decc9c7..2685921 100644 --- a/src/SaveTool/SaveTool.h +++ b/src/SaveTool/SaveTool.h @@ -103,8 +103,8 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener void initialiseConfiguration(); void initialiseGui(); void initialiseManager(); - auto initialiseToolDirectories() -> bool; - auto findGameDataDirectory() -> bool; + bool initialiseToolDirectories(); + bool findGameDataDirectory(); void initialiseMassManager(); void initialiseFileWatcher(); @@ -116,21 +116,21 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener void drawInitialisation(); void drawProfileManager(); - auto drawBackupListPopup() -> ImGuiID; - auto drawBackupProfilePopup(std::size_t profile_index) -> ImGuiID; - auto drawDeleteProfilePopup(std::size_t profile_index) -> ImGuiID; + ImGuiID drawBackupListPopup(); + ImGuiID drawBackupProfilePopup(std::size_t profile_index); + ImGuiID drawDeleteProfilePopup(std::size_t profile_index); void drawManager(); - auto drawIntEditPopup(int* value_to_edit, int max) -> bool; - auto drawRenamePopup(Containers::ArrayView name_view) -> bool; + bool drawIntEditPopup(int* value_to_edit, int max); + bool drawRenamePopup(Containers::ArrayView name_view); void drawGeneralInfo(); void drawResearchInventory(); template void drawMaterialRow(Containers::StringView name, Int tier, Getter getter, Setter setter); void drawUnavailableMaterialRow(Containers::StringView name, Int tier); void drawMassManager(); - auto drawDeleteMassPopup(int mass_index) -> ImGuiID; - auto drawDeleteStagedMassPopup(Containers::StringView filename) -> ImGuiID; + ImGuiID drawDeleteMassPopup(int mass_index); + ImGuiID drawDeleteStagedMassPopup(Containers::StringView filename); void drawMassViewer(); void drawFrameInfo(); @@ -148,14 +148,14 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener void drawTuning(); void drawDecalEditor(Decal& decal); void drawAccessoryEditor(Accessory& accessory, Containers::ArrayView style_view); - auto getStyleName(Int id, Containers::ArrayView view) -> Containers::StringView; + Containers::StringView getStyleName(Int id, Containers::ArrayView view); enum DCSResult { DCS_Fail, DCS_ResetStyle, DCS_Save }; - auto drawCustomStyle(CustomStyle& style) -> DCSResult; + DCSResult drawCustomStyle(CustomStyle& style); void drawAbout(); void drawGameState(); @@ -166,7 +166,7 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener bool drawCheckbox(Containers::StringView label, bool value); template - auto drawUnsafeWidget(Functor func, Args... args) -> bool { + bool drawUnsafeWidget(Functor func, Args... args) { GameState game_state = _gameState; // Copying the value to reduce the risk of a data race. ImGui::BeginDisabled(game_state != GameState::NotRunning); bool result = func(std::forward(args)...); diff --git a/src/SaveTool/SaveTool_FileWatcher.cpp b/src/SaveTool/SaveTool_FileWatcher.cpp index 42a3fcd..37cbd02 100644 --- a/src/SaveTool/SaveTool_FileWatcher.cpp +++ b/src/SaveTool/SaveTool_FileWatcher.cpp @@ -26,11 +26,12 @@ #include "SaveTool.h" -void SaveTool::handleFileAction(efsw::WatchID watch_id, - const std::string&, - const std::string& filename, - efsw::Action action, - std::string old_filename) +void +SaveTool::handleFileAction(efsw::WatchID watch_id, + const std::string&, + const std::string& filename, + efsw::Action action, + std::string old_filename) { SDL_Event event; SDL_zero(event); @@ -60,7 +61,8 @@ void SaveTool::handleFileAction(efsw::WatchID watch_id, SDL_PushEvent(&event); } -void SaveTool::fileUpdateEvent(SDL_Event& event) { +void +SaveTool::fileUpdateEvent(SDL_Event& event) { Containers::String filename{static_cast(event.user.data1), std::strlen(static_cast(event.user.data1)), nullptr}; @@ -83,7 +85,7 @@ void SaveTool::fileUpdateEvent(SDL_Event& event) { if(event.user.code == FileMoved) { old_filename = Containers::String{static_cast(event.user.data2), std::strlen(static_cast(event.user.data2)), nullptr}; old_index = ((old_filename[_currentProfile->isDemo() ? 8 : 4] - 0x30) * 10) + - (old_filename[_currentProfile->isDemo() ? 9 : 5] - 0x30); + (old_filename[_currentProfile->isDemo() ? 9 : 5] - 0x30); } switch(event.user.code) { diff --git a/src/SaveTool/SaveTool_Initialisation.cpp b/src/SaveTool/SaveTool_Initialisation.cpp index ad1ec60..1142d1f 100644 --- a/src/SaveTool/SaveTool_Initialisation.cpp +++ b/src/SaveTool/SaveTool_Initialisation.cpp @@ -31,7 +31,8 @@ #include "SaveTool.h" -void SaveTool::initEvent(SDL_Event& event) { +void +SaveTool::initEvent(SDL_Event& event) { _initThread.join(); switch(event.user.code) { @@ -49,14 +50,16 @@ void SaveTool::initEvent(SDL_Event& event) { } } -void SaveTool::initialiseConfiguration() { +void +SaveTool::initialiseConfiguration() { LOG_INFO("Reading configuration file."); setSwapInterval(conf().swapInterval()); setMinimalLoopPeriod(0); } -void SaveTool::initialiseGui() { +void +SaveTool::initialiseGui() { LOG_INFO("Initialising Dear ImGui."); ImGui::CreateContext(); @@ -108,7 +111,8 @@ void SaveTool::initialiseGui() { style.Colors[ImGuiCol_WindowBg] = ImColor(0xff1f1f1f); } -void SaveTool::initialiseManager() { +void +SaveTool::initialiseManager() { LOG_INFO("Initialising the profile manager."); SDL_Event event; @@ -126,7 +130,8 @@ void SaveTool::initialiseManager() { SDL_PushEvent(&event); } -auto SaveTool::initialiseToolDirectories() -> bool { +auto +SaveTool::initialiseToolDirectories() -> bool { LOG_INFO("Initialising Save Tool directories."); _backupsDir = Utility::Path::join(Utility::Path::split(*Utility::Path::executableLocation()).first(), "backups"); @@ -187,7 +192,8 @@ auto SaveTool::initialiseToolDirectories() -> bool { return true; } -auto SaveTool::findGameDataDirectory() -> bool { +auto +SaveTool::findGameDataDirectory() -> bool { LOG_INFO("Searching for the game's save directory."); wchar_t* localappdata_path = nullptr; @@ -213,12 +219,14 @@ auto SaveTool::findGameDataDirectory() -> bool { return true; } -void SaveTool::initialiseMassManager() { +void +SaveTool::initialiseMassManager() { LOG_INFO("Initialising the M.A.S.S. manager."); _massManager.emplace(_saveDir, _currentProfile->account(), _currentProfile->isDemo(), _stagingDir); } -void SaveTool::initialiseFileWatcher() { +void +SaveTool::initialiseFileWatcher() { LOG_INFO("Initialising the file watcher."); _fileWatcher.emplace(); _watchIDs[SaveDir] = _fileWatcher->addWatch(_saveDir, this, false); diff --git a/src/SaveTool/SaveTool_MainManager.cpp b/src/SaveTool/SaveTool_MainManager.cpp index d8736d8..671763a 100644 --- a/src/SaveTool/SaveTool_MainManager.cpp +++ b/src/SaveTool/SaveTool_MainManager.cpp @@ -28,7 +28,8 @@ #include "SaveTool.h" -void SaveTool::drawManager() { +void +SaveTool::drawManager() { ImGui::SetNextWindowPos({0.0f, ImGui::GetItemRectSize().y}, ImGuiCond_Always); ImGui::SetNextWindowSize({Float(windowSize().x()), Float(windowSize().y()) - ImGui::GetItemRectSize().y}, ImGuiCond_Always); @@ -95,7 +96,8 @@ void SaveTool::drawManager() { ImGui::End(); } -auto SaveTool::drawIntEditPopup(int* value_to_edit, int max) -> bool { +bool +SaveTool::drawIntEditPopup(int* value_to_edit, int max) { bool apply = false; if(ImGui::BeginPopup("int_edit")) { ImGui::Text("Please enter a value between 0 and %i:", max); @@ -118,7 +120,8 @@ auto SaveTool::drawIntEditPopup(int* value_to_edit, int max) -> bool { return apply; } -auto SaveTool::drawRenamePopup(Containers::ArrayView name_view) -> bool { +bool +SaveTool::drawRenamePopup(Containers::ArrayView name_view) { bool apply = false; if(ImGui::BeginPopup("name_edit")) { ImGui::TextUnformatted("Please enter a new name. Conditions:"); @@ -170,7 +173,8 @@ auto SaveTool::drawRenamePopup(Containers::ArrayView name_view) -> bool { return apply; } -void SaveTool::drawGeneralInfo() { +void +SaveTool::drawGeneralInfo() { if(!_currentProfile) { return; } @@ -278,7 +282,8 @@ void SaveTool::drawGeneralInfo() { } } -void SaveTool::drawResearchInventory() { +void +SaveTool::drawResearchInventory() { if(!_currentProfile) { return; } @@ -392,7 +397,8 @@ void SaveTool::drawResearchInventory() { } template -void SaveTool::drawMaterialRow(Containers::StringView name, Int tier, Getter getter, Setter setter) { +void +SaveTool::drawMaterialRow(Containers::StringView name, Int tier, Getter getter, Setter setter) { static_assert(std::is_same::value, "getter doesn't return an Int, and/or doesn't take zero arguments."); static_assert(std::is_same::value, "setter doesn't return a bool, and/or doesn't take a single Int as an argument."); @@ -426,7 +432,8 @@ void SaveTool::drawMaterialRow(Containers::StringView name, Int tier, Getter get } } -void SaveTool::drawUnavailableMaterialRow(Containers::StringView name, Int tier) { +void +SaveTool::drawUnavailableMaterialRow(Containers::StringView name, Int tier) { ImGui::TableNextRow(); ImGui::TableSetColumnIndex(0); ImGui::Text("T%i", tier); @@ -436,7 +443,8 @@ void SaveTool::drawUnavailableMaterialRow(Containers::StringView name, Int tier) ImGui::TextDisabled("Unavailable as of game version " SUPPORTED_GAME_VERSION); } -void SaveTool::drawMassManager() { +void +SaveTool::drawMassManager() { if(!_massManager) { return; } @@ -633,7 +641,8 @@ void SaveTool::drawMassManager() { drawDeleteStagedMassPopup(staged_mass_to_delete); } -auto SaveTool::drawDeleteMassPopup(int mass_index) -> ImGuiID { +ImGuiID +SaveTool::drawDeleteMassPopup(int mass_index) { if(!ImGui::BeginPopupModal("Confirmation##DeleteMassConfirmation", nullptr, ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoCollapse|ImGuiWindowFlags_NoMove)) { @@ -689,7 +698,8 @@ auto SaveTool::drawDeleteMassPopup(int mass_index) -> ImGuiID { return 0; } -auto SaveTool::drawDeleteStagedMassPopup(Containers::StringView filename) -> ImGuiID { +ImGuiID +SaveTool::drawDeleteStagedMassPopup(Containers::StringView filename) { if(!ImGui::BeginPopupModal("Confirmation##DeleteStagedMassConfirmation", nullptr, ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoCollapse|ImGuiWindowFlags_NoMove)) { diff --git a/src/SaveTool/SaveTool_MassViewer.cpp b/src/SaveTool/SaveTool_MassViewer.cpp index 5bc6e36..f1256cf 100644 --- a/src/SaveTool/SaveTool_MassViewer.cpp +++ b/src/SaveTool/SaveTool_MassViewer.cpp @@ -27,7 +27,8 @@ #include "SaveTool.h" -void SaveTool::drawMassViewer() { +void +SaveTool::drawMassViewer() { if(!_currentMass || _currentMass->state() != Mass::State::Valid) { _currentMass = nullptr; _currentWeapon = nullptr; @@ -154,7 +155,8 @@ void SaveTool::drawMassViewer() { ImGui::End(); } -void SaveTool::drawGlobalStyles() { +void +SaveTool::drawGlobalStyles() { if(!_currentMass || _currentMass->state() != Mass::State::Valid) { return; } @@ -190,7 +192,8 @@ void SaveTool::drawGlobalStyles() { ImGui::EndChild(); } -void SaveTool::drawTuning() { +void +SaveTool::drawTuning() { if(!_currentMass || _currentMass->state() != Mass::State::Valid) { return; } @@ -286,7 +289,8 @@ void SaveTool::drawTuning() { ImGui::EndTable(); } -auto SaveTool::drawCustomStyle(CustomStyle& style) -> DCSResult { +SaveTool::DCSResult +SaveTool::drawCustomStyle(CustomStyle& style) { if(!_currentMass || _currentMass->state() != Mass::State::Valid) { return DCS_Fail; } @@ -391,7 +395,8 @@ auto SaveTool::drawCustomStyle(CustomStyle& style) -> DCSResult { return return_value; } -void SaveTool::drawDecalEditor(Decal& decal) { +void +SaveTool::drawDecalEditor(Decal& decal) { ImGui::Text("ID: %i", decal.id); if(ImGui::BeginTable("##DecalTable", conf().advancedMode() ? 2 : 1, ImGuiTableFlags_BordersInnerV)) { @@ -495,7 +500,8 @@ void SaveTool::drawDecalEditor(Decal& decal) { } } -void SaveTool::drawAccessoryEditor(Accessory& accessory, Containers::ArrayView style_view) { +void +SaveTool::drawAccessoryEditor(Accessory& accessory, Containers::ArrayView style_view) { if(accessory.id < 1) { ImGui::TextUnformatted("Accessory: "); } @@ -733,7 +739,8 @@ void SaveTool::drawAccessoryEditor(Accessory& accessory, Containers::ArrayView view) -> Containers::StringView { +Containers::StringView +SaveTool::getStyleName(Int id, Containers::ArrayView view) { if(id >= 0 && id <= 15) { return view[id].name; } diff --git a/src/SaveTool/SaveTool_MassViewer_Armour.cpp b/src/SaveTool/SaveTool_MassViewer_Armour.cpp index 6f5aeb4..5c21698 100644 --- a/src/SaveTool/SaveTool_MassViewer_Armour.cpp +++ b/src/SaveTool/SaveTool_MassViewer_Armour.cpp @@ -21,7 +21,8 @@ #include "SaveTool.h" -void SaveTool::drawArmour() { +void +SaveTool::drawArmour() { if(!_currentMass || _currentMass->state() != Mass::State::Valid) { return; } @@ -288,7 +289,8 @@ void SaveTool::drawArmour() { ImGui::EndChild(); } -void SaveTool::drawCustomArmourStyles() { +void +SaveTool::drawCustomArmourStyles() { if(!_currentMass || _currentMass->state() != Mass::State::Valid) { return; } diff --git a/src/SaveTool/SaveTool_MassViewer_Frame.cpp b/src/SaveTool/SaveTool_MassViewer_Frame.cpp index a648c90..bbcf609 100644 --- a/src/SaveTool/SaveTool_MassViewer_Frame.cpp +++ b/src/SaveTool/SaveTool_MassViewer_Frame.cpp @@ -15,12 +15,12 @@ // along with this program. If not, see . #include "../FontAwesome/IconsFontAwesome5.h" - #include "../Maps/StyleNames.h" #include "SaveTool.h" -void SaveTool::drawFrameInfo() { +void +SaveTool::drawFrameInfo() { if(!_currentMass || _currentMass->state() != Mass::State::Valid) { return; } @@ -73,7 +73,8 @@ void SaveTool::drawFrameInfo() { ImGui::EndChild(); } -void SaveTool::drawJointSliders() { +void +SaveTool::drawJointSliders() { if(!_currentMass || _currentMass->state() != Mass::State::Valid) { return; } @@ -195,7 +196,8 @@ void SaveTool::drawJointSliders() { } } -void SaveTool::drawFrameStyles() { +void +SaveTool::drawFrameStyles() { if(!_currentMass || _currentMass->state() != Mass::State::Valid) { return; } @@ -245,7 +247,8 @@ void SaveTool::drawFrameStyles() { } } -void SaveTool::drawEyeColourPicker() { +void +SaveTool::drawEyeColourPicker() { if(!_currentMass || _currentMass->state() != Mass::State::Valid) { return; } @@ -278,7 +281,8 @@ void SaveTool::drawEyeColourPicker() { } } -void SaveTool::drawCustomFrameStyles() { +void +SaveTool::drawCustomFrameStyles() { if(!_currentMass || _currentMass->state() != Mass::State::Valid) { return; } diff --git a/src/SaveTool/SaveTool_MassViewer_Weapons.cpp b/src/SaveTool/SaveTool_MassViewer_Weapons.cpp index 909712f..2bbcd3a 100644 --- a/src/SaveTool/SaveTool_MassViewer_Weapons.cpp +++ b/src/SaveTool/SaveTool_MassViewer_Weapons.cpp @@ -21,7 +21,8 @@ #include "SaveTool.h" -void SaveTool::drawWeapons() { +void +SaveTool::drawWeapons() { if(!_currentMass || _currentMass->state() != Mass::State::Valid) { _currentWeapon = nullptr; return; @@ -254,8 +255,9 @@ void SaveTool::drawWeapons() { ImGui::EndGroup(); } -void SaveTool::drawWeaponCategory(Containers::StringView name, Containers::ArrayView weapons_view, bool& dirty, - Containers::StringView payload_type, Containers::StringView payload_tooltip) +void +SaveTool::drawWeaponCategory(Containers::StringView name, Containers::ArrayView weapons_view, bool& dirty, + Containers::StringView payload_type, Containers::StringView payload_tooltip) { ImGui::TableNextRow(ImGuiTableRowFlags_Headers); ImGui::TableNextColumn(); @@ -317,7 +319,8 @@ void SaveTool::drawWeaponCategory(Containers::StringView name, Containers::Array ImGui::PopID(); } -void SaveTool::drawWeaponEditor(Weapon& weapon) { +void +SaveTool::drawWeaponEditor(Weapon& weapon) { if(!_currentMass || _currentMass->state() != Mass::State::Valid || !_currentWeapon) { return; } diff --git a/src/SaveTool/SaveTool_ProfileManager.cpp b/src/SaveTool/SaveTool_ProfileManager.cpp index 89b7bdf..0ce5262 100644 --- a/src/SaveTool/SaveTool_ProfileManager.cpp +++ b/src/SaveTool/SaveTool_ProfileManager.cpp @@ -24,7 +24,8 @@ extern const ImVec2 center_pivot; -void SaveTool::drawProfileManager() { +void +SaveTool::drawProfileManager() { static std::size_t profile_index = 0; ImGui::SetNextWindowPos(ImVec2{Vector2{windowSize() / 2.0f}}, ImGuiCond_Always, center_pivot); @@ -125,7 +126,8 @@ void SaveTool::drawProfileManager() { ImGui::End(); } -auto SaveTool::drawBackupListPopup() -> ImGuiID { +ImGuiID +SaveTool::drawBackupListPopup() { ImGui::SetNextWindowPos(ImVec2{Vector2{windowSize() / 2.0f}}, ImGuiCond_Always, center_pivot); if(!ImGui::BeginPopupModal("Backups##BackupsModal", nullptr, ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoCollapse|ImGuiWindowFlags_NoMove)) @@ -324,7 +326,8 @@ auto SaveTool::drawBackupListPopup() -> ImGuiID { return 0; } -auto SaveTool::drawBackupProfilePopup(std::size_t profile_index) -> ImGuiID { +ImGuiID +SaveTool::drawBackupProfilePopup(std::size_t profile_index) { if(!ImGui::BeginPopupModal("Include builds ?##IncludeBuildsDialog", nullptr, ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoCollapse|ImGuiWindowFlags_NoMove)) { @@ -368,7 +371,8 @@ auto SaveTool::drawBackupProfilePopup(std::size_t profile_index) -> ImGuiID { return 0; } -auto SaveTool::drawDeleteProfilePopup(std::size_t profile_index) -> ImGuiID { +ImGuiID +SaveTool::drawDeleteProfilePopup(std::size_t profile_index) { if(!ImGui::BeginPopupModal("Confirmation##DeleteProfileConfirmation", nullptr, ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoCollapse|ImGuiWindowFlags_NoMove)) { diff --git a/src/SaveTool/SaveTool_UpdateChecker.cpp b/src/SaveTool/SaveTool_UpdateChecker.cpp index 768b330..0716744 100644 --- a/src/SaveTool/SaveTool_UpdateChecker.cpp +++ b/src/SaveTool/SaveTool_UpdateChecker.cpp @@ -24,7 +24,8 @@ #include "SaveTool.h" -void SaveTool::updateCheckEvent(SDL_Event& event) { +void +SaveTool::updateCheckEvent(SDL_Event& event) { _updateThread.join(); if(event.user.code == CurlInitFailed) { @@ -123,13 +124,16 @@ void SaveTool::updateCheckEvent(SDL_Event& event) { } } -inline auto writeData(char* ptr, std::size_t size, std::size_t nmemb, Containers::String* buf)-> std::size_t { +inline +std::size_t +writeData(char* ptr, std::size_t size, std::size_t nmemb, Containers::String* buf) { if(!ptr || !buf) return 0; (*buf) = Utility::format("{}{}", *buf, Containers::StringView{ptr, size * nmemb}); return size * nmemb; } -void SaveTool::checkForUpdates() { +void +SaveTool::checkForUpdates() { SDL_Event event; SDL_zero(event); event.type = _updateEventId; diff --git a/src/SaveTool/SaveTool_drawAbout.cpp b/src/SaveTool/SaveTool_drawAbout.cpp index 1904d1b..9c1927f 100644 --- a/src/SaveTool/SaveTool_drawAbout.cpp +++ b/src/SaveTool/SaveTool_drawAbout.cpp @@ -31,7 +31,8 @@ extern const ImVec2 center_pivot; -void SaveTool::drawAbout() { +void +SaveTool::drawAbout() { ImGui::SetNextWindowPos(ImVec2{Vector2{windowSize() / 2.0f}}, ImGuiCond_Always, center_pivot); ImGui::SetNextWindowSize({float(windowSize().x()) * 0.8f, float(windowSize().y()) * 0.75f}, ImGuiCond_Always); @@ -88,7 +89,7 @@ void SaveTool::drawAbout() { if(ImGui::BeginChild("##GPL", {0.0f, float(windowSize().y()) * 0.3f}, true)) { static auto licence = _rs.getRaw("COPYING"); ImGui::PushFont(ImGui::GetIO().Fonts->Fonts[1]); - ImGui::TextEx(licence.data(), licence.data() + licence.size(), ImGuiTextFlags_None); + ImGui::TextUnformatted(licence.begin(), licence.end()); ImGui::PopFont(); } ImGui::EndChild(); @@ -117,7 +118,7 @@ void SaveTool::drawAbout() { static auto corrade_licence = _rs.getRaw("COPYING.Corrade"); if(ImGui::BeginChild("##CorradeLicence", {0.0f, float(windowSize().y()) * 0.3f}, true)) { ImGui::PushFont(ImGui::GetIO().Fonts->Fonts[1]); - ImGui::TextEx(corrade_licence.data(), corrade_licence.data() + corrade_licence.size(), ImGuiTextFlags_None); + ImGui::TextUnformatted(corrade_licence.begin(), corrade_licence.end()); ImGui::PopFont(); } ImGui::EndChild(); @@ -145,7 +146,7 @@ void SaveTool::drawAbout() { static auto magnum_licence = _rs.getRaw("COPYING.Magnum"); if(ImGui::BeginChild("##MagnumLicence", {0.0f, float(windowSize().y()) * 0.3f}, true)) { ImGui::PushFont(ImGui::GetIO().Fonts->Fonts[1]); - ImGui::TextEx(magnum_licence.data(), magnum_licence.data() + magnum_licence.size(), ImGuiTextFlags_None); + ImGui::TextUnformatted(magnum_licence.begin(), magnum_licence.end()); ImGui::PopFont(); } ImGui::EndChild(); @@ -171,7 +172,7 @@ void SaveTool::drawAbout() { static auto imgui_licence = _rs.getRaw("LICENSE.ImGui"); if(ImGui::BeginChild("##ImGuiLicence", {0.0f, float(windowSize().y()) * 0.3f}, true)) { ImGui::PushFont(ImGui::GetIO().Fonts->Fonts[1]); - ImGui::TextEx(imgui_licence.data(), imgui_licence.data() + imgui_licence.size(), ImGuiTextFlags_None); + ImGui::TextUnformatted(imgui_licence.begin(), imgui_licence.end()); ImGui::PopFont(); } ImGui::EndChild(); @@ -197,7 +198,7 @@ void SaveTool::drawAbout() { static auto sdl_licence = _rs.getRaw("LICENSE.SDL"); if(ImGui::BeginChild("##SDLLicence", {0.0f, float(windowSize().y()) * 0.3f}, true)) { ImGui::PushFont(ImGui::GetIO().Fonts->Fonts[1]); - ImGui::TextEx(sdl_licence.data(), sdl_licence.data() + sdl_licence.size(), ImGuiTextFlags_None); + ImGui::TextUnformatted(sdl_licence.begin(), sdl_licence.end()); ImGui::PopFont(); } ImGui::EndChild(); @@ -223,7 +224,7 @@ void SaveTool::drawAbout() { static auto libzip_licence = _rs.getRaw("LICENSE.libzip"); if(ImGui::BeginChild("##libzipLicence", {0.0f, float(windowSize().y()) * 0.3f}, true)) { ImGui::PushFont(ImGui::GetIO().Fonts->Fonts[1]); - ImGui::TextEx(libzip_licence.data(), libzip_licence.data() + libzip_licence.size(), ImGuiTextFlags_None); + ImGui::TextUnformatted(libzip_licence.begin(), libzip_licence.end()); ImGui::PopFont(); } ImGui::EndChild(); @@ -248,7 +249,7 @@ void SaveTool::drawAbout() { static auto efsw_licence = _rs.getRaw("LICENSE.efsw"); if(ImGui::BeginChild("##efswLicence", {0.0f, float(windowSize().y()) * 0.3f}, true)) { ImGui::PushFont(ImGui::GetIO().Fonts->Fonts[1]); - ImGui::TextEx(efsw_licence.data(), efsw_licence.data() + efsw_licence.size(), ImGuiTextFlags_None); + ImGui::TextUnformatted(efsw_licence.begin(), efsw_licence.end()); ImGui::PopFont(); } ImGui::EndChild(); @@ -274,7 +275,7 @@ void SaveTool::drawAbout() { static auto curl_licence = _rs.getRaw("LICENSE.curl"); if(ImGui::BeginChild("##libcurlLicence", {0.0f, float(windowSize().y()) * 0.3f}, true)) { ImGui::PushFont(ImGui::GetIO().Fonts->Fonts[1]); - ImGui::TextEx(curl_licence.data(), curl_licence.data() + curl_licence.size(), ImGuiTextFlags_None); + ImGui::TextUnformatted(curl_licence.begin(), curl_licence.end()); ImGui::PopFont(); } ImGui::EndChild(); diff --git a/src/SaveTool/SaveTool_drawMainMenu.cpp b/src/SaveTool/SaveTool_drawMainMenu.cpp index b6e47ae..400c608 100644 --- a/src/SaveTool/SaveTool_drawMainMenu.cpp +++ b/src/SaveTool/SaveTool_drawMainMenu.cpp @@ -22,7 +22,8 @@ #include "SaveTool.h" -void SaveTool::drawMainMenu() { +void +SaveTool::drawMainMenu() { if(!ImGui::BeginMainMenuBar()) { return; } diff --git a/src/ToastQueue/ToastQueue.cpp b/src/ToastQueue/ToastQueue.cpp index d0902d7..df92ec8 100644 --- a/src/ToastQueue/ToastQueue.cpp +++ b/src/ToastQueue/ToastQueue.cpp @@ -37,41 +37,51 @@ constexpr Vector2 padding{20.0f, 20.0f}; constexpr Float toast_spacing = 10.0f; Toast::Toast(Type type, Containers::StringView message, std::chrono::milliseconds timeout): - _type{type}, _message{message}, _timeout{timeout}, _creationTime{std::chrono::steady_clock::now()} + _type{type}, + _message{message}, + _timeout{timeout}, + _creationTime{std::chrono::steady_clock::now()} { _phaseTrack = Animation::Track{{ - {0, Phase::FadeIn}, - {fade_time, Phase::Wait}, - {fade_time + timeout.count(), Phase::FadeOut}, + {0, Phase::FadeIn}, + {fade_time, Phase::Wait}, + {fade_time + timeout.count(), Phase::FadeOut}, {(fade_time * 2) + timeout.count(), Phase::TimedOut} }, Math::select, Animation::Extrapolation::Constant}; } -auto Toast::type() -> Type { +Toast::Type +Toast::type() { return _type; } -auto Toast::message() -> Containers::StringView { +Containers::StringView +Toast::message() { return _message; } -auto Toast::timeout() -> std::chrono::milliseconds { +std::chrono::milliseconds +Toast::timeout() { return _timeout; } -auto Toast::creationTime() -> std::chrono::steady_clock::time_point { +std::chrono::steady_clock::time_point +Toast::creationTime() { return _creationTime; } -auto Toast::elapsedTime() -> std::chrono::milliseconds { +std::chrono::milliseconds +Toast::elapsedTime() { return std::chrono::duration_cast(std::chrono::steady_clock::now() - _creationTime); } -auto Toast::phase() -> Phase { +Toast::Phase +Toast::phase() { return _phaseTrack.at(elapsedTime().count()); } -auto Toast::opacity() -> Float { +Float +Toast::opacity() { Phase phase = this->phase(); Long elapsed_time = elapsedTime().count(); @@ -85,15 +95,18 @@ auto Toast::opacity() -> Float { return 1.0f; } -void ToastQueue::addToast(Toast&& toast) { +void +ToastQueue::addToast(Toast&& toast) { _toasts.push_back(std::move(toast)); } -void ToastQueue::addToast(Toast::Type type, Containers::StringView message, std::chrono::milliseconds timeout) { +void +ToastQueue::addToast(Toast::Type type, Containers::StringView message, std::chrono::milliseconds timeout) { _toasts.emplace_back(type, message, timeout); } -void ToastQueue::draw(Vector2i viewport_size) { +void +ToastQueue::draw(Vector2i viewport_size) { Float height = 0.0f; for(UnsignedInt i = 0; i < _toasts.size(); i++) { @@ -154,6 +167,7 @@ void ToastQueue::draw(Vector2i viewport_size) { } } -void ToastQueue::removeToast(Long index) { +void +ToastQueue::removeToast(Long index) { _toasts.erase(_toasts.begin() + index); } diff --git a/src/ToastQueue/ToastQueue.h b/src/ToastQueue/ToastQueue.h index fe0fc42..5c5365e 100644 --- a/src/ToastQueue/ToastQueue.h +++ b/src/ToastQueue/ToastQueue.h @@ -46,19 +46,19 @@ class Toast { Toast(Toast&& other) = default; Toast& operator=(Toast&& other) = default; - auto type() -> Type; + Type type(); - auto message() -> Containers::StringView; + Containers::StringView message(); - auto timeout() -> std::chrono::milliseconds; + std::chrono::milliseconds timeout(); - auto creationTime() -> std::chrono::steady_clock::time_point; + std::chrono::steady_clock::time_point creationTime(); - auto elapsedTime() -> std::chrono::milliseconds; + std::chrono::milliseconds elapsedTime(); - auto phase() -> Phase; + Phase phase(); - auto opacity() -> Float; + Float opacity(); private: Type _type{Type::Default}; diff --git a/src/UESaveFile/BinaryReader.cpp b/src/UESaveFile/BinaryReader.cpp index f1d88a5..c0ae9b2 100644 --- a/src/UESaveFile/BinaryReader.cpp +++ b/src/UESaveFile/BinaryReader.cpp @@ -35,72 +35,89 @@ BinaryReader::~BinaryReader() { closeFile(); } -auto BinaryReader::open() -> bool { +bool +BinaryReader::open() { return _file; } -auto BinaryReader::eof() -> bool { +bool +BinaryReader::eof() { return std::feof(_file) != 0; } -auto BinaryReader::position() -> Long { +Long +BinaryReader::position() { return _ftelli64(_file); } -auto BinaryReader::seek(Long position) -> bool { +bool +BinaryReader::seek(Long position) { return _fseeki64(_file, position, SEEK_SET) == 0; } -void BinaryReader::closeFile() { +void +BinaryReader::closeFile() { std::fclose(_file); _file = nullptr; } -auto BinaryReader::readChar(char& value) -> bool { +bool +BinaryReader::readChar(char& value) { return std::fread(&value, sizeof(char), 1, _file) == 1; } -auto BinaryReader::readByte(Byte& value) -> bool { +bool +BinaryReader::readByte(Byte& value) { return std::fread(&value, sizeof(Byte), 1, _file) == 1; } -auto BinaryReader::readUnsignedByte(UnsignedByte& value) -> bool { +bool +BinaryReader::readUnsignedByte(UnsignedByte& value) { return std::fread(&value, sizeof(UnsignedByte), 1, _file) == 1; } -auto BinaryReader::readShort(Short& value) -> bool { +bool +BinaryReader::readShort(Short& value) { return std::fread(&value, sizeof(Short), 1, _file) == 1; } -auto BinaryReader::readUnsignedShort(UnsignedShort& value) -> bool { +bool +BinaryReader::readUnsignedShort(UnsignedShort& value) { return std::fread(&value, sizeof(UnsignedShort), 1, _file) == 1; } -auto BinaryReader::readInt(Int& value) -> bool { +bool +BinaryReader::readInt(Int& value) { return std::fread(&value, sizeof(Int), 1, _file) == 1; } -auto BinaryReader::readUnsignedInt(UnsignedInt& value) -> bool { +bool +BinaryReader::readUnsignedInt(UnsignedInt& value) { return std::fread(&value, sizeof(UnsignedInt), 1, _file) == 1; } -auto BinaryReader::readLong(Long& value) -> bool { +bool +BinaryReader::readLong(Long& value) { return std::fread(&value, sizeof(Long), 1, _file) == 1; } -auto BinaryReader::readUnsignedLong(UnsignedLong& value) -> bool { +bool +BinaryReader::readUnsignedLong(UnsignedLong& value) { return std::fread(&value, sizeof(UnsignedLong), 1, _file) == 1; } -auto BinaryReader::readFloat(Float& value) -> bool { +bool +BinaryReader::readFloat(Float& value) { return std::fread(&value, sizeof(Float), 1, _file) == 1; } -auto BinaryReader::readDouble(Double& value) -> bool { +bool +BinaryReader::readDouble(Double& value) { return std::fread(&value, sizeof(Double), 1, _file) == 1; } -auto BinaryReader::readArray(Containers::Array& array, std::size_t count) -> bool { +bool +BinaryReader::readArray(Containers::Array& array, std::size_t count) { if(array.size() < count) { array = Containers::Array{ValueInit, count}; } @@ -108,7 +125,8 @@ auto BinaryReader::readArray(Containers::Array& array, std::size_t count) return std::fread(array.data(), sizeof(char), count, _file) == count; } -auto BinaryReader::readUEString(Containers::String& str) -> bool { +bool +BinaryReader::readUEString(Containers::String& str) { UnsignedInt length = 0; if(!readUnsignedInt(length) || length == 0) { return false; @@ -119,7 +137,8 @@ auto BinaryReader::readUEString(Containers::String& str) -> bool { return std::fread(str.data(), sizeof(char), length, _file) == length; } -auto BinaryReader::peekChar() -> Int { +Int +BinaryReader::peekChar() { Int c; c = std::fgetc(_file); std::ungetc(c, _file); diff --git a/src/UESaveFile/BinaryReader.h b/src/UESaveFile/BinaryReader.h index d43df8a..e945938 100644 --- a/src/UESaveFile/BinaryReader.h +++ b/src/UESaveFile/BinaryReader.h @@ -32,40 +32,40 @@ class BinaryReader { explicit BinaryReader(Containers::StringView filename); ~BinaryReader(); - auto open() -> bool; - auto eof() -> bool; - auto position() -> Long; + bool open(); + bool eof(); + Long position(); - auto seek(Long position) -> bool; + bool seek(Long position); void closeFile(); - auto readChar(char& value) -> bool; - auto readByte(Byte& value) -> bool; - auto readUnsignedByte(UnsignedByte& value) -> bool; - auto readShort(Short& value) -> bool; - auto readUnsignedShort(UnsignedShort& value) -> bool; - auto readInt(Int& value) -> bool; - auto readUnsignedInt(UnsignedInt& value) -> bool; - auto readLong(Long& value) -> bool; - auto readUnsignedLong(UnsignedLong& value) -> bool; - auto readFloat(Float& value) -> bool; - auto readDouble(Double& value) -> bool; - auto readArray(Containers::Array& array, std::size_t count) -> bool; + bool readChar(char& value); + bool readByte(Byte& value); + bool readUnsignedByte(UnsignedByte& value); + bool readShort(Short& value); + bool readUnsignedShort(UnsignedShort& value); + bool readInt(Int& value); + bool readUnsignedInt(UnsignedInt& value); + bool readLong(Long& value); + bool readUnsignedLong(UnsignedLong& value); + bool readFloat(Float& value); + bool readDouble(Double& value); + bool readArray(Containers::Array& array, std::size_t count); template - auto readValue(T& value) -> bool { + bool readValue(T& value) { return fread(&value, sizeof(T), 1, _file) == sizeof(T); } template - auto readStaticArray(Containers::StaticArray& array) -> bool { + bool readStaticArray(Containers::StaticArray& array) { return std::fread(array.data(), sizeof(char), S, _file) == S; } - auto readUEString(Containers::String& str) -> bool; + bool readUEString(Containers::String& str); - auto peekChar() -> Int; + Int peekChar(); private: std::FILE* _file = nullptr; diff --git a/src/UESaveFile/BinaryWriter.cpp b/src/UESaveFile/BinaryWriter.cpp index 10fa76d..a5a2e15 100644 --- a/src/UESaveFile/BinaryWriter.cpp +++ b/src/UESaveFile/BinaryWriter.cpp @@ -33,29 +33,35 @@ BinaryWriter::~BinaryWriter() { closeFile(); } -auto BinaryWriter::open() -> bool { +bool +BinaryWriter::open() { return _file; } -void BinaryWriter::closeFile() { +void +BinaryWriter::closeFile() { std::fflush(_file); std::fclose(_file); _file = nullptr; } -auto BinaryWriter::position() -> Long { +Long +BinaryWriter::position() { return _ftelli64(_file); } -auto BinaryWriter::array() const -> Containers::ArrayView { +Containers::ArrayView +BinaryWriter::array() const { return _data; } -auto BinaryWriter::arrayPosition() const -> UnsignedLong { +UnsignedLong +BinaryWriter::arrayPosition() const { return _index; } -auto BinaryWriter::flushToFile() -> bool { +bool +BinaryWriter::flushToFile() { bool ret = writeArray(_data); std::fflush(_file); _data = Containers::Array{}; @@ -63,51 +69,63 @@ auto BinaryWriter::flushToFile() -> bool { return ret; } -auto BinaryWriter::writeChar(char value) -> bool { +bool +BinaryWriter::writeChar(char value) { return std::fwrite(&value, sizeof(char), 1, _file) == 1; } -auto BinaryWriter::writeByte(Byte value) -> bool { +bool +BinaryWriter::writeByte(Byte value) { return std::fwrite(&value, sizeof(Byte), 1, _file) == 1; } -auto BinaryWriter::writeUnsignedByte(UnsignedByte value) -> bool { +bool +BinaryWriter::writeUnsignedByte(UnsignedByte value) { return std::fwrite(&value, sizeof(UnsignedByte), 1, _file) == 1; } -auto BinaryWriter::writeShort(Short value) -> bool { +bool +BinaryWriter::writeShort(Short value) { return std::fwrite(&value, sizeof(Short), 1, _file) == 1; } -auto BinaryWriter::writeUnsignedShort(UnsignedShort value) -> bool { +bool +BinaryWriter::writeUnsignedShort(UnsignedShort value) { return std::fwrite(&value, sizeof(UnsignedShort), 1, _file) == 1; } -auto BinaryWriter::writeInt(Int value) -> bool { +bool +BinaryWriter::writeInt(Int value) { return std::fwrite(&value, sizeof(Int), 1, _file) == 1; } -auto BinaryWriter::writeUnsignedInt(UnsignedInt value) -> bool { +bool +BinaryWriter::writeUnsignedInt(UnsignedInt value) { return std::fwrite(&value, sizeof(UnsignedInt), 1, _file) == 1; } -auto BinaryWriter::writeLong(Long value) -> bool { +bool +BinaryWriter::writeLong(Long value) { return std::fwrite(&value, sizeof(Long), 1, _file) == 1; } -auto BinaryWriter::writeUnsignedLong(UnsignedLong value) -> bool { +bool +BinaryWriter::writeUnsignedLong(UnsignedLong value) { return std::fwrite(&value, sizeof(UnsignedLong), 1, _file) == 1; } -auto BinaryWriter::writeFloat(Float value) -> bool { +bool +BinaryWriter::writeFloat(Float value) { return std::fwrite(&value, sizeof(Float), 1, _file) == 1; } -auto BinaryWriter::writeDouble(Double value) -> bool { +bool +BinaryWriter::writeDouble(Double value) { return std::fwrite(&value, sizeof(Double), 1, _file) == 1; } -auto BinaryWriter::writeArray(Containers::ArrayView array) -> bool { +bool +BinaryWriter::writeArray(Containers::ArrayView array) { if(array.size() == 0) { return false; } @@ -115,7 +133,8 @@ auto BinaryWriter::writeArray(Containers::ArrayView array) -> bool { return std::fwrite(array.data(), sizeof(char), array.size(), _file) == array.size(); } -auto BinaryWriter::writeUEString(Containers::StringView str) -> bool { +bool +BinaryWriter::writeUEString(Containers::StringView str) { if(str.size() > UINT32_MAX) { LOG_ERROR_FORMAT("String is too big. Expected size() < UINT32_MAX, got {} instead.", str.size()); return false; @@ -132,7 +151,8 @@ auto BinaryWriter::writeUEString(Containers::StringView str) -> bool { return writeChar('\0'); } -auto BinaryWriter::writeUEStringToArray(Containers::StringView value) -> UnsignedLong { +UnsignedLong +BinaryWriter::writeUEStringToArray(Containers::StringView value) { return writeValueToArray(UnsignedInt(value.size()) + 1u) + writeDataToArray(Containers::ArrayView{value}) + writeValueToArray('\0'); diff --git a/src/UESaveFile/BinaryWriter.h b/src/UESaveFile/BinaryWriter.h index efdc4ed..4921f1e 100644 --- a/src/UESaveFile/BinaryWriter.h +++ b/src/UESaveFile/BinaryWriter.h @@ -39,47 +39,47 @@ class BinaryWriter { BinaryWriter(BinaryWriter&& other) = default; BinaryWriter& operator=(BinaryWriter&& other) = default; - auto open() -> bool; + bool open(); void closeFile(); - auto position() -> Long; + Long position(); - auto array() const -> Containers::ArrayView; - auto arrayPosition() const -> UnsignedLong; - auto flushToFile() -> bool; + Containers::ArrayView array() const; + UnsignedLong arrayPosition() const; + bool flushToFile(); - auto writeByte(Byte value) -> bool; - auto writeChar(char value) -> bool; - auto writeUnsignedByte(UnsignedByte value) -> bool; - auto writeShort(Short value) -> bool; - auto writeUnsignedShort(UnsignedShort value) -> bool; - auto writeInt(Int value) -> bool; - auto writeUnsignedInt(UnsignedInt value) -> bool; - auto writeLong(Long value) -> bool; - auto writeUnsignedLong(UnsignedLong value) -> bool; - auto writeFloat(Float value) -> bool; - auto writeDouble(Double value) -> bool; - auto writeArray(Containers::ArrayView array) -> bool; + bool writeByte(Byte value); + bool writeChar(char value); + bool writeUnsignedByte(UnsignedByte value); + bool writeShort(Short value); + bool writeUnsignedShort(UnsignedShort value); + bool writeInt(Int value); + bool writeUnsignedInt(UnsignedInt value); + bool writeLong(Long value); + bool writeUnsignedLong(UnsignedLong value); + bool writeFloat(Float value); + bool writeDouble(Double value); + bool writeArray(Containers::ArrayView array); template - auto writeString(const char(&str)[size]) -> bool { + bool writeString(const char(&str)[size]) { return writeArray({str, size - 1}); } template - auto writeStaticArray(Containers::StaticArrayView array) -> bool { + bool writeStaticArray(Containers::StaticArrayView array) { return std::fwrite(array.data(), sizeof(char), S, _file) == S; } - auto writeUEString(Containers::StringView str) -> bool; + bool writeUEString(Containers::StringView str); template::value, T, T&>> - auto writeValueToArray(U value) -> UnsignedLong { + UnsignedLong writeValueToArray(U value) { Containers::ArrayView view{&value, 1}; return writeDataToArray(view); } - auto writeUEStringToArray(Containers::StringView value) -> UnsignedLong; + UnsignedLong writeUEStringToArray(Containers::StringView value); template void writeValueToArrayAt(T& value, UnsignedLong position) { @@ -88,7 +88,7 @@ class BinaryWriter { } template - auto writeDataToArray(Containers::ArrayView view) -> UnsignedLong { + UnsignedLong writeDataToArray(Containers::ArrayView view) { arrayAppend(_data, Containers::arrayCast(view)); _index += sizeof(T) * view.size(); return sizeof(T) * view.size(); diff --git a/src/UESaveFile/Debug.cpp b/src/UESaveFile/Debug.cpp index 31bc2ab..d10a752 100644 --- a/src/UESaveFile/Debug.cpp +++ b/src/UESaveFile/Debug.cpp @@ -22,17 +22,20 @@ #include "Debug.h" -Utility::Debug& operator<<(Utility::Debug& debug, const ArrayProperty* prop) { +Utility::Debug& +operator<<(Utility::Debug& debug, const ArrayProperty* prop) { return debug << (*prop->name) << Utility::Debug::nospace << ":" << prop->propertyType << "of" << prop->items.size() << prop->itemType; } -Utility::Debug& operator<<(Utility::Debug& debug, const SetProperty* prop) { +Utility::Debug& +operator<<(Utility::Debug& debug, const SetProperty* prop) { return debug << (*prop->name) << Utility::Debug::nospace << ":" << prop->propertyType << "of" << prop->items.size() << prop->itemType; } -Utility::Debug& operator<<(Utility::Debug& debug, const GenericStructProperty* prop) { +Utility::Debug& +operator<<(Utility::Debug& debug, const GenericStructProperty* prop) { debug << (*prop->name) << Utility::Debug::nospace << ":" << prop->structType << "(" << Utility::Debug::nospace << prop->propertyType << Utility::Debug::nospace << ") Contents:"; @@ -42,7 +45,8 @@ Utility::Debug& operator<<(Utility::Debug& debug, const GenericStructProperty* p return debug; } -Utility::Debug& operator<<(Utility::Debug& debug, const StructProperty* prop) { +Utility::Debug& +operator<<(Utility::Debug& debug, const StructProperty* prop) { auto cast = dynamic_cast(prop); if(cast) { return debug << cast; @@ -52,7 +56,8 @@ Utility::Debug& operator<<(Utility::Debug& debug, const StructProperty* prop) { prop->structType << "(" << Utility::Debug::nospace << prop->propertyType << Utility::Debug::nospace << ")"; } -Utility::Debug& operator<<(Utility::Debug& debug, const UnrealPropertyBase* prop) { +Utility::Debug& +operator<<(Utility::Debug& debug, const UnrealPropertyBase* prop) { if(prop->propertyType == "ArrayProperty") { auto array_prop = dynamic_cast(prop); if(array_prop) { diff --git a/src/UESaveFile/PropertySerialiser.cpp b/src/UESaveFile/PropertySerialiser.cpp index 77e8e4a..775189f 100644 --- a/src/UESaveFile/PropertySerialiser.cpp +++ b/src/UESaveFile/PropertySerialiser.cpp @@ -67,12 +67,14 @@ PropertySerialiser::PropertySerialiser() { arrayAppend(_collectionSerialisers, Containers::pointer()); } -auto PropertySerialiser::instance() -> PropertySerialiser& { +PropertySerialiser& +PropertySerialiser::instance() { static PropertySerialiser serialiser; return serialiser; } -auto PropertySerialiser::read(BinaryReader& reader) -> UnrealPropertyBase::ptr { +UnrealPropertyBase::ptr +PropertySerialiser::read(BinaryReader& reader) { if(reader.peekChar() < 0 || reader.eof()) { return nullptr; } @@ -99,8 +101,10 @@ auto PropertySerialiser::read(BinaryReader& reader) -> UnrealPropertyBase::ptr { return deserialise(std::move(name), std::move(type), value_length, reader); } -auto PropertySerialiser::readItem(BinaryReader& reader, Containers::String type, UnsignedLong value_length, - Containers::String name) -> UnrealPropertyBase::ptr { +UnrealPropertyBase::ptr +PropertySerialiser::readItem(BinaryReader& reader, Containers::String type, UnsignedLong value_length, + Containers::String name) +{ if(reader.peekChar() < 0 || reader.eof()) { return nullptr; } @@ -108,9 +112,8 @@ auto PropertySerialiser::readItem(BinaryReader& reader, Containers::String type, return deserialise(std::move(name), std::move(type), value_length, reader); } -auto PropertySerialiser::readSet(BinaryReader& reader, Containers::StringView item_type, - UnsignedInt count) -> Containers::Array -{ +Containers::Array +PropertySerialiser::readSet(BinaryReader& reader, Containers::StringView item_type, UnsignedInt count) { if(reader.peekChar() < 0 || reader.eof()) { return nullptr; } @@ -153,8 +156,9 @@ auto PropertySerialiser::readSet(BinaryReader& reader, Containers::StringView it return array; } -auto PropertySerialiser::deserialise(Containers::String name, Containers::String type, UnsignedLong value_length, - BinaryReader& reader) -> UnrealPropertyBase::ptr +UnrealPropertyBase::ptr +PropertySerialiser::deserialise(Containers::String name, Containers::String type, UnsignedLong value_length, + BinaryReader& reader) { UnrealPropertyBase::ptr prop; auto serialiser = getSerialiser(type); @@ -176,8 +180,8 @@ auto PropertySerialiser::deserialise(Containers::String name, Containers::String return prop; } -auto PropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, Containers::StringView item_type, - UnsignedLong& bytes_written, BinaryWriter& writer) -> bool +bool PropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, Containers::StringView item_type, + UnsignedLong& bytes_written, BinaryWriter& writer) { auto serialiser = getSerialiser(item_type); if(!serialiser) { @@ -186,7 +190,8 @@ auto PropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, Containers::St return serialiser->serialise(prop, bytes_written, writer, *this); } -auto PropertySerialiser::write(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer) -> bool { +bool +PropertySerialiser::write(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer) { if(prop->name == "None" && prop->propertyType == "NoneProperty" && dynamic_cast(prop.get())) { bytes_written += writer.writeUEStringToArray(*prop->name); return true; @@ -209,8 +214,9 @@ auto PropertySerialiser::write(UnrealPropertyBase::ptr& prop, UnsignedLong& byte return ret; } -auto PropertySerialiser::writeItem(UnrealPropertyBase::ptr& prop, Containers::StringView item_type, - UnsignedLong& bytes_written, BinaryWriter& writer) -> bool +bool +PropertySerialiser::writeItem(UnrealPropertyBase::ptr& prop, Containers::StringView item_type, + UnsignedLong& bytes_written, BinaryWriter& writer) { if(prop->name == "None" && prop->propertyType == "NoneProperty" && dynamic_cast(prop.get())) { bytes_written += writer.writeUEStringToArray(*prop->name); @@ -220,9 +226,8 @@ auto PropertySerialiser::writeItem(UnrealPropertyBase::ptr& prop, Containers::St return serialise(prop, item_type, bytes_written, writer); } -auto PropertySerialiser::writeSet(Containers::ArrayView props, - Containers::StringView item_type, UnsignedLong& bytes_written, - BinaryWriter& writer) -> bool +bool PropertySerialiser::writeSet(Containers::ArrayView props, + Containers::StringView item_type, UnsignedLong& bytes_written, BinaryWriter& writer) { auto serialiser = getCollectionSerialiser(item_type); if(serialiser) { @@ -239,7 +244,8 @@ auto PropertySerialiser::writeSet(Containers::ArrayView } } -auto PropertySerialiser::getSerialiser(Containers::StringView item_type) -> AbstractUnrealPropertySerialiser* { +AbstractUnrealPropertySerialiser* +PropertySerialiser::getSerialiser(Containers::StringView item_type) { for(auto& item : _serialisers) { for(auto serialiser_type : item->types()) { if(item_type == serialiser_type) { @@ -251,7 +257,8 @@ auto PropertySerialiser::getSerialiser(Containers::StringView item_type) -> Abst return nullptr; } -auto PropertySerialiser::getCollectionSerialiser(Containers::StringView item_type) -> AbstractUnrealCollectionPropertySerialiser* { +AbstractUnrealCollectionPropertySerialiser* +PropertySerialiser::getCollectionSerialiser(Containers::StringView item_type) { for(auto& item : _collectionSerialisers) { for(Containers::StringView serialiser_type : item->types()) { if(item_type == serialiser_type) { diff --git a/src/UESaveFile/PropertySerialiser.h b/src/UESaveFile/PropertySerialiser.h index 67a1aed..579e527 100644 --- a/src/UESaveFile/PropertySerialiser.h +++ b/src/UESaveFile/PropertySerialiser.h @@ -32,28 +32,29 @@ class BinaryWriter; class PropertySerialiser { public: - static auto instance() -> PropertySerialiser&; + static PropertySerialiser& instance(); - auto read(BinaryReader& reader) -> UnrealPropertyBase::ptr; - auto readItem(BinaryReader& reader, Containers::String type, UnsignedLong value_length, - Containers::String name) -> UnrealPropertyBase::ptr; - auto readSet(BinaryReader& reader, Containers::StringView item_type, UnsignedInt count) -> Containers::Array; - auto deserialise(Containers::String name, Containers::String type, UnsignedLong value_length, - BinaryReader& reader) -> UnrealPropertyBase::ptr; + UnrealPropertyBase::ptr read(BinaryReader& reader); + UnrealPropertyBase::ptr readItem(BinaryReader& reader, Containers::String type, UnsignedLong value_length, + Containers::String name); + Containers::Array readSet(BinaryReader& reader, Containers::StringView item_type, + UnsignedInt count); + UnrealPropertyBase::ptr deserialise(Containers::String name, Containers::String type, UnsignedLong value_length, + BinaryReader& reader); - auto serialise(UnrealPropertyBase::ptr& prop, Containers::StringView item_type, UnsignedLong& bytes_written, - BinaryWriter& writer) -> bool; - auto write(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer) -> bool; - auto writeItem(UnrealPropertyBase::ptr& prop, Containers::StringView item_type, UnsignedLong& bytes_written, - BinaryWriter& writer) -> bool; - auto writeSet(Containers::ArrayView props, Containers::StringView item_type, - UnsignedLong& bytes_written, BinaryWriter& writer) -> bool; + bool serialise(UnrealPropertyBase::ptr& prop, Containers::StringView item_type, UnsignedLong& bytes_written, + BinaryWriter& writer); + bool write(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer); + bool writeItem(UnrealPropertyBase::ptr& prop, Containers::StringView item_type, UnsignedLong& bytes_written, + BinaryWriter& writer); + bool writeSet(Containers::ArrayView props, Containers::StringView item_type, + UnsignedLong& bytes_written, BinaryWriter& writer); private: PropertySerialiser(); - auto getSerialiser(Containers::StringView item_type) -> AbstractUnrealPropertySerialiser*; - auto getCollectionSerialiser(Containers::StringView item_type) -> AbstractUnrealCollectionPropertySerialiser*; + AbstractUnrealPropertySerialiser* getSerialiser(Containers::StringView item_type); + AbstractUnrealCollectionPropertySerialiser* getCollectionSerialiser(Containers::StringView item_type); Containers::Array _serialisers; Containers::Array _collectionSerialisers; diff --git a/src/UESaveFile/Serialisers/AbstractUnrealCollectionPropertySerialiser.h b/src/UESaveFile/Serialisers/AbstractUnrealCollectionPropertySerialiser.h index ffa273d..a798222 100644 --- a/src/UESaveFile/Serialisers/AbstractUnrealCollectionPropertySerialiser.h +++ b/src/UESaveFile/Serialisers/AbstractUnrealCollectionPropertySerialiser.h @@ -32,17 +32,20 @@ class BinaryReader; class BinaryWriter; class PropertySerialiser; +using PropertyArray = Containers::Array; +using PropertyArrayView = Containers::ArrayView; + class AbstractUnrealCollectionPropertySerialiser { public: using ptr = Containers::Pointer; virtual ~AbstractUnrealCollectionPropertySerialiser() = default; - virtual auto types() -> Containers::ArrayView = 0; + virtual StringArrayView types() = 0; - virtual auto deserialise(Containers::StringView name, Containers::StringView type, - UnsignedLong value_length, UnsignedInt count, BinaryReader& reader, - PropertySerialiser& serialiser) -> Containers::Array = 0; + virtual PropertyArray deserialise(Containers::StringView name, Containers::StringView type, + UnsignedLong value_length, UnsignedInt count, BinaryReader& reader, + PropertySerialiser& serialiser) = 0; virtual auto serialise(Containers::ArrayView props, Containers::StringView item_type, UnsignedLong& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) -> bool = 0; diff --git a/src/UESaveFile/Serialisers/AbstractUnrealPropertySerialiser.h b/src/UESaveFile/Serialisers/AbstractUnrealPropertySerialiser.h index 0ddbfd1..cd68b5e 100644 --- a/src/UESaveFile/Serialisers/AbstractUnrealPropertySerialiser.h +++ b/src/UESaveFile/Serialisers/AbstractUnrealPropertySerialiser.h @@ -31,17 +31,20 @@ class BinaryReader; class BinaryWriter; class PropertySerialiser; +using StringArrayView = Containers::ArrayView; + class AbstractUnrealPropertySerialiser { public: using ptr = Containers::Pointer; virtual ~AbstractUnrealPropertySerialiser() = default; - virtual auto types() -> Containers::ArrayView = 0; + virtual StringArrayView types() = 0; - virtual auto deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length, - BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr = 0; + virtual UnrealPropertyBase::ptr deserialise(Containers::StringView name, Containers::StringView type, + UnsignedLong value_length, BinaryReader& reader, + PropertySerialiser& serialiser) = 0; - virtual auto serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, - PropertySerialiser& serialiser) -> bool = 0; + virtual bool serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, + PropertySerialiser& serialiser) = 0; }; diff --git a/src/UESaveFile/Serialisers/AbstractUnrealStructSerialiser.h b/src/UESaveFile/Serialisers/AbstractUnrealStructSerialiser.h index 7e62fc6..c7e9827 100644 --- a/src/UESaveFile/Serialisers/AbstractUnrealStructSerialiser.h +++ b/src/UESaveFile/Serialisers/AbstractUnrealStructSerialiser.h @@ -37,10 +37,10 @@ class AbstractUnrealStructSerialiser { virtual ~AbstractUnrealStructSerialiser() = default; - virtual auto supportsType(Containers::StringView type) -> bool = 0; + virtual bool supportsType(Containers::StringView type) = 0; - virtual auto deserialise(BinaryReader& reader) -> UnrealPropertyBase::ptr = 0; + virtual UnrealPropertyBase::ptr deserialise(BinaryReader& reader) = 0; - virtual auto serialise(UnrealPropertyBase::ptr& structProp, BinaryWriter& writer, - UnsignedLong& bytes_written) -> bool = 0; + virtual bool serialise(UnrealPropertyBase::ptr& structProp, BinaryWriter& writer, + UnsignedLong& bytes_written) = 0; }; diff --git a/src/UESaveFile/Serialisers/ArrayPropertySerialiser.cpp b/src/UESaveFile/Serialisers/ArrayPropertySerialiser.cpp index d2efbb8..1b06824 100644 --- a/src/UESaveFile/Serialisers/ArrayPropertySerialiser.cpp +++ b/src/UESaveFile/Serialisers/ArrayPropertySerialiser.cpp @@ -23,9 +23,10 @@ #include "ArrayPropertySerialiser.h" -auto ArrayPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type, - UnsignedLong value_length, BinaryReader& reader, - PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr +UnrealPropertyBase::ptr +ArrayPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type, + UnsignedLong value_length, BinaryReader& reader, + PropertySerialiser& serialiser) { Containers::String item_type; if(!reader.readUEString(item_type)) { @@ -52,8 +53,9 @@ auto ArrayPropertySerialiser::deserialiseProperty(Containers::StringView name, C return prop; } -auto ArrayPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, - BinaryWriter& writer, PropertySerialiser& serialiser) -> bool +bool +ArrayPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, + BinaryWriter& writer, PropertySerialiser& serialiser) { auto array_prop = dynamic_cast(prop.get()); if(!array_prop) { diff --git a/src/UESaveFile/Serialisers/ArrayPropertySerialiser.h b/src/UESaveFile/Serialisers/ArrayPropertySerialiser.h index f9b0334..7d7eef1 100644 --- a/src/UESaveFile/Serialisers/ArrayPropertySerialiser.h +++ b/src/UESaveFile/Serialisers/ArrayPropertySerialiser.h @@ -32,8 +32,9 @@ class ArrayPropertySerialiser : public UnrealPropertySerialiser { using ptr = Containers::Pointer; private: - auto deserialiseProperty(Containers::StringView name, Containers::StringView type, UnsignedLong value_length, - BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override; - auto serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, - PropertySerialiser& serialiser) -> bool override; + UnrealPropertyBase::ptr deserialiseProperty(Containers::StringView name, Containers::StringView type, + UnsignedLong value_length, BinaryReader& reader, + PropertySerialiser& serialiser) override; + bool serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, + PropertySerialiser& serialiser) override; }; diff --git a/src/UESaveFile/Serialisers/BoolPropertySerialiser.cpp b/src/UESaveFile/Serialisers/BoolPropertySerialiser.cpp index 7f9e6cc..b4b689b 100644 --- a/src/UESaveFile/Serialisers/BoolPropertySerialiser.cpp +++ b/src/UESaveFile/Serialisers/BoolPropertySerialiser.cpp @@ -20,15 +20,16 @@ #include "BoolPropertySerialiser.h" -auto BoolPropertySerialiser::types() -> Containers::ArrayView { +StringArrayView +BoolPropertySerialiser::types() { using namespace Containers::Literals; static const Containers::Array types{InPlaceInit, {"BoolProperty"_s}}; return types; } -auto BoolPropertySerialiser::deserialise(Containers::StringView name, Containers::StringView type, - UnsignedLong value_length, BinaryReader& reader, - PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr +UnrealPropertyBase::ptr +BoolPropertySerialiser::deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length, + BinaryReader& reader, PropertySerialiser& serialiser) { if(value_length != 0) { LOG_ERROR_FORMAT("Invalid value length for bool property {}. Expected 0, got {} instead.", name, value_length); @@ -52,8 +53,9 @@ auto BoolPropertySerialiser::deserialise(Containers::StringView name, Containers return prop; } -auto BoolPropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, - BinaryWriter& writer, PropertySerialiser& serialiser) -> bool +bool +BoolPropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, + PropertySerialiser& serialiser) { auto bool_prop = dynamic_cast(prop.get()); if(!bool_prop) { diff --git a/src/UESaveFile/Serialisers/BoolPropertySerialiser.h b/src/UESaveFile/Serialisers/BoolPropertySerialiser.h index ddbbf85..2507313 100644 --- a/src/UESaveFile/Serialisers/BoolPropertySerialiser.h +++ b/src/UESaveFile/Serialisers/BoolPropertySerialiser.h @@ -29,11 +29,12 @@ class BoolPropertySerialiser : public AbstractUnrealPropertySerialiser { public: using ptr = Containers::Pointer; - auto types() -> Containers::ArrayView override; + StringArrayView types() override; - auto deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length, - BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override; + UnrealPropertyBase::ptr deserialise(Containers::StringView name, Containers::StringView type, + UnsignedLong value_length, BinaryReader& reader, + PropertySerialiser& serialiser) override; - auto serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, - PropertySerialiser& serialiser) -> bool override; + bool serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, + PropertySerialiser& serialiser) override; }; diff --git a/src/UESaveFile/Serialisers/BytePropertySerialiser.cpp b/src/UESaveFile/Serialisers/BytePropertySerialiser.cpp index eb24db1..fed7309 100644 --- a/src/UESaveFile/Serialisers/BytePropertySerialiser.cpp +++ b/src/UESaveFile/Serialisers/BytePropertySerialiser.cpp @@ -20,15 +20,16 @@ #include "BytePropertySerialiser.h" -auto BytePropertySerialiser::types() -> Containers::ArrayView { +StringArrayView +BytePropertySerialiser::types() { using namespace Containers::Literals; static const Containers::Array types{InPlaceInit, {"ByteProperty"_s}}; return types; } -auto BytePropertySerialiser::deserialise(Containers::StringView name, Containers::StringView type, - UnsignedLong value_length, BinaryReader& reader, - PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr +UnrealPropertyBase::ptr +BytePropertySerialiser::deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length, + BinaryReader& reader, PropertySerialiser& serialiser) { auto prop = Containers::pointer(); @@ -64,8 +65,9 @@ auto BytePropertySerialiser::deserialise(Containers::StringView name, Containers return prop; } -auto BytePropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, - BinaryWriter& writer, PropertySerialiser& serialiser) -> bool +bool +BytePropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, + PropertySerialiser& serialiser) { auto byte_prop = dynamic_cast(prop.get()); if(!byte_prop) { diff --git a/src/UESaveFile/Serialisers/BytePropertySerialiser.h b/src/UESaveFile/Serialisers/BytePropertySerialiser.h index 74b7205..4e1ff71 100644 --- a/src/UESaveFile/Serialisers/BytePropertySerialiser.h +++ b/src/UESaveFile/Serialisers/BytePropertySerialiser.h @@ -27,11 +27,12 @@ class BytePropertySerialiser : public AbstractUnrealPropertySerialiser { public: using ptr = Containers::Pointer; - auto types() -> Containers::ArrayView override; + StringArrayView types() override; - auto deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length, - BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override; + UnrealPropertyBase::ptr deserialise(Containers::StringView name, Containers::StringView type, + UnsignedLong value_length, BinaryReader& reader, + PropertySerialiser& serialiser) override; - auto serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, - PropertySerialiser& serialiser) -> bool override; + bool serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, + PropertySerialiser& serialiser) override; }; diff --git a/src/UESaveFile/Serialisers/ColourPropertySerialiser.cpp b/src/UESaveFile/Serialisers/ColourPropertySerialiser.cpp index d90035f..4972cd7 100644 --- a/src/UESaveFile/Serialisers/ColourPropertySerialiser.cpp +++ b/src/UESaveFile/Serialisers/ColourPropertySerialiser.cpp @@ -20,9 +20,10 @@ #include "ColourPropertySerialiser.h" -auto ColourPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type, - UnsignedLong value_length, BinaryReader& reader, - PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr +UnrealPropertyBase::ptr +ColourPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type, + UnsignedLong value_length, BinaryReader& reader, + PropertySerialiser& serialiser) { auto prop = Containers::pointer(); @@ -36,8 +37,9 @@ auto ColourPropertySerialiser::deserialiseProperty(Containers::StringView name, return prop; } -auto ColourPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, - BinaryWriter& writer, PropertySerialiser& serialiser) -> bool +bool +ColourPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, + BinaryWriter& writer, PropertySerialiser& serialiser) { auto colour_prop = dynamic_cast(prop.get()); if(!colour_prop) { @@ -45,8 +47,10 @@ auto ColourPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, return false; } - bytes_written += writer.writeValueToArray(colour_prop->r) + writer.writeValueToArray(colour_prop->g) + - writer.writeValueToArray(colour_prop->b) + writer.writeValueToArray(colour_prop->a); + bytes_written += writer.writeValueToArray(colour_prop->r) + + writer.writeValueToArray(colour_prop->g) + + writer.writeValueToArray(colour_prop->b) + + writer.writeValueToArray(colour_prop->a); return true; } diff --git a/src/UESaveFile/Serialisers/ColourPropertySerialiser.h b/src/UESaveFile/Serialisers/ColourPropertySerialiser.h index d14dd1f..f137eee 100644 --- a/src/UESaveFile/Serialisers/ColourPropertySerialiser.h +++ b/src/UESaveFile/Serialisers/ColourPropertySerialiser.h @@ -29,8 +29,9 @@ class ColourPropertySerialiser : public UnrealPropertySerialiser; private: - auto deserialiseProperty(Containers::StringView name, Containers::StringView type, UnsignedLong value_length, - BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override; - auto serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, - PropertySerialiser& serialiser) -> bool override; + UnrealPropertyBase::ptr deserialiseProperty(Containers::StringView name, Containers::StringView type, + UnsignedLong value_length, BinaryReader& reader, + PropertySerialiser& serialiser) override; + bool serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, + PropertySerialiser& serialiser) override; }; diff --git a/src/UESaveFile/Serialisers/DateTimePropertySerialiser.cpp b/src/UESaveFile/Serialisers/DateTimePropertySerialiser.cpp index 6e32666..09187cd 100644 --- a/src/UESaveFile/Serialisers/DateTimePropertySerialiser.cpp +++ b/src/UESaveFile/Serialisers/DateTimePropertySerialiser.cpp @@ -20,9 +20,10 @@ #include "DateTimePropertySerialiser.h" -auto DateTimePropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type, - UnsignedLong value_length, BinaryReader& reader, - PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr +UnrealPropertyBase::ptr +DateTimePropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type, + UnsignedLong value_length, BinaryReader& reader, + PropertySerialiser& serialiser) { auto prop = Containers::pointer(); @@ -34,8 +35,9 @@ auto DateTimePropertySerialiser::deserialiseProperty(Containers::StringView name return prop; } -auto DateTimePropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, - BinaryWriter& writer, PropertySerialiser& serialiser) -> bool +bool +DateTimePropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, + BinaryWriter& writer, PropertySerialiser& serialiser) { auto dt_prop = dynamic_cast(prop.get()); if(!dt_prop) { diff --git a/src/UESaveFile/Serialisers/DateTimePropertySerialiser.h b/src/UESaveFile/Serialisers/DateTimePropertySerialiser.h index 51db914..78e3bfd 100644 --- a/src/UESaveFile/Serialisers/DateTimePropertySerialiser.h +++ b/src/UESaveFile/Serialisers/DateTimePropertySerialiser.h @@ -27,8 +27,9 @@ class DateTimePropertySerialiser : public UnrealPropertySerialiser; private: - auto deserialiseProperty(Containers::StringView name, Containers::StringView type, UnsignedLong value_length, - BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override; - auto serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, - PropertySerialiser& serialiser) -> bool override; + UnrealPropertyBase::ptr deserialiseProperty(Containers::StringView name, Containers::StringView type, + UnsignedLong value_length, BinaryReader& reader, + PropertySerialiser& serialiser) override; + bool serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, + PropertySerialiser& serialiser) override; }; diff --git a/src/UESaveFile/Serialisers/EnumPropertySerialiser.cpp b/src/UESaveFile/Serialisers/EnumPropertySerialiser.cpp index 4cb5835..191d5e4 100644 --- a/src/UESaveFile/Serialisers/EnumPropertySerialiser.cpp +++ b/src/UESaveFile/Serialisers/EnumPropertySerialiser.cpp @@ -20,15 +20,16 @@ #include "EnumPropertySerialiser.h" -auto EnumPropertySerialiser::types() -> Containers::ArrayView { +StringArrayView +EnumPropertySerialiser::types() { using namespace Containers::Literals; static const Containers::Array types{InPlaceInit, {"EnumProperty"_s}}; return types; } -auto EnumPropertySerialiser::deserialise(Containers::StringView name, Containers::StringView type, - UnsignedLong value_length, BinaryReader& reader, - PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr +UnrealPropertyBase::ptr +EnumPropertySerialiser::deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length, + BinaryReader& reader, PropertySerialiser& serialiser) { auto prop = Containers::pointer(); @@ -51,8 +52,9 @@ auto EnumPropertySerialiser::deserialise(Containers::StringView name, Containers return prop; } -auto EnumPropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, - BinaryWriter& writer, PropertySerialiser& serialiser) -> bool +bool +EnumPropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, + PropertySerialiser& serialiser) { auto enum_prop = dynamic_cast(prop.get()); if(!enum_prop) { diff --git a/src/UESaveFile/Serialisers/EnumPropertySerialiser.h b/src/UESaveFile/Serialisers/EnumPropertySerialiser.h index 57b821b..c2874a3 100644 --- a/src/UESaveFile/Serialisers/EnumPropertySerialiser.h +++ b/src/UESaveFile/Serialisers/EnumPropertySerialiser.h @@ -27,11 +27,12 @@ class EnumPropertySerialiser : public AbstractUnrealPropertySerialiser { public: using ptr = Containers::Pointer; - auto types() -> Containers::ArrayView override; + StringArrayView types() override; - auto deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length, - BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override; + UnrealPropertyBase::ptr deserialise(Containers::StringView name, Containers::StringView type, + UnsignedLong value_length, BinaryReader& reader, + PropertySerialiser& serialiser) override; - auto serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, - PropertySerialiser& serialiser) -> bool override; + bool serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, + PropertySerialiser& serialiser) override; }; diff --git a/src/UESaveFile/Serialisers/FloatPropertySerialiser.cpp b/src/UESaveFile/Serialisers/FloatPropertySerialiser.cpp index 4134f94..0d229d9 100644 --- a/src/UESaveFile/Serialisers/FloatPropertySerialiser.cpp +++ b/src/UESaveFile/Serialisers/FloatPropertySerialiser.cpp @@ -20,15 +20,16 @@ #include "FloatPropertySerialiser.h" -auto FloatPropertySerialiser::types() -> Containers::ArrayView { +StringArrayView +FloatPropertySerialiser::types() { using namespace Containers::Literals; static const Containers::Array types{InPlaceInit, {"FloatProperty"_s}}; return types; } -auto FloatPropertySerialiser::deserialise(Containers::StringView name, Containers::StringView type, - UnsignedLong value_length, BinaryReader& reader, - PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr +UnrealPropertyBase::ptr +FloatPropertySerialiser::deserialise(Containers::StringView name, Containers::StringView type, + UnsignedLong value_length, BinaryReader& reader, PropertySerialiser& serialiser) { auto prop = Containers::pointer(); @@ -46,8 +47,9 @@ auto FloatPropertySerialiser::deserialise(Containers::StringView name, Container return prop; } -auto FloatPropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, - BinaryWriter& writer, PropertySerialiser& serialiser) -> bool +bool +FloatPropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, + PropertySerialiser& serialiser) { auto float_prop = dynamic_cast(prop.get()); if(!float_prop) { diff --git a/src/UESaveFile/Serialisers/FloatPropertySerialiser.h b/src/UESaveFile/Serialisers/FloatPropertySerialiser.h index d09d31b..9ec5741 100644 --- a/src/UESaveFile/Serialisers/FloatPropertySerialiser.h +++ b/src/UESaveFile/Serialisers/FloatPropertySerialiser.h @@ -27,11 +27,12 @@ class FloatPropertySerialiser : public AbstractUnrealPropertySerialiser { public: using ptr = Containers::Pointer; - auto types() -> Containers::ArrayView override; + StringArrayView types() override; - auto deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length, - BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override; + UnrealPropertyBase::ptr deserialise(Containers::StringView name, Containers::StringView type, + UnsignedLong value_length, BinaryReader& reader, + PropertySerialiser& serialiser) override; - auto serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, - PropertySerialiser& serialiser) -> bool override; + bool serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, + PropertySerialiser& serialiser) override; }; diff --git a/src/UESaveFile/Serialisers/GuidPropertySerialiser.cpp b/src/UESaveFile/Serialisers/GuidPropertySerialiser.cpp index dd0036b..d70aefa 100644 --- a/src/UESaveFile/Serialisers/GuidPropertySerialiser.cpp +++ b/src/UESaveFile/Serialisers/GuidPropertySerialiser.cpp @@ -22,9 +22,10 @@ using namespace Containers::Literals; -auto GuidPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type, - UnsignedLong value_length, BinaryReader& reader, - PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr +UnrealPropertyBase::ptr +GuidPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type, + UnsignedLong value_length, BinaryReader& reader, + PropertySerialiser& serialiser) { auto prop = Containers::pointer(); @@ -36,8 +37,9 @@ auto GuidPropertySerialiser::deserialiseProperty(Containers::StringView name, Co return prop; } -auto GuidPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, - BinaryWriter& writer, PropertySerialiser& serialiser) -> bool +bool +GuidPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, + BinaryWriter& writer, PropertySerialiser& serialiser) { auto guid_prop = dynamic_cast(prop.get()); if(!guid_prop) { diff --git a/src/UESaveFile/Serialisers/GuidPropertySerialiser.h b/src/UESaveFile/Serialisers/GuidPropertySerialiser.h index 33f7d8c..6094f83 100644 --- a/src/UESaveFile/Serialisers/GuidPropertySerialiser.h +++ b/src/UESaveFile/Serialisers/GuidPropertySerialiser.h @@ -27,8 +27,9 @@ class GuidPropertySerialiser : public UnrealPropertySerialiser; private: - auto deserialiseProperty(Containers::StringView name, Containers::StringView type, UnsignedLong value_length, - BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override; - auto serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, - PropertySerialiser& serialiser) -> bool override; + UnrealPropertyBase::ptr deserialiseProperty(Containers::StringView name, Containers::StringView type, + UnsignedLong value_length, BinaryReader& reader, + PropertySerialiser& serialiser) override; + bool serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, + PropertySerialiser& serialiser) override; }; diff --git a/src/UESaveFile/Serialisers/IntPropertySerialiser.cpp b/src/UESaveFile/Serialisers/IntPropertySerialiser.cpp index 3c2e50f..074e670 100644 --- a/src/UESaveFile/Serialisers/IntPropertySerialiser.cpp +++ b/src/UESaveFile/Serialisers/IntPropertySerialiser.cpp @@ -20,9 +20,10 @@ #include "IntPropertySerialiser.h" -auto IntPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type, - UnsignedLong value_length, BinaryReader& reader, - PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr +UnrealPropertyBase::ptr +IntPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type, + UnsignedLong value_length, BinaryReader& reader, + PropertySerialiser& serialiser) { auto prop = Containers::pointer(); @@ -52,8 +53,9 @@ auto IntPropertySerialiser::deserialiseProperty(Containers::StringView name, Con return prop; } -auto IntPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, - BinaryWriter& writer, PropertySerialiser& serialiser) -> bool +bool +IntPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, + BinaryWriter& writer, PropertySerialiser& serialiser) { auto int_prop = dynamic_cast(prop.get()); if(!int_prop) { diff --git a/src/UESaveFile/Serialisers/IntPropertySerialiser.h b/src/UESaveFile/Serialisers/IntPropertySerialiser.h index 4dc9f88..6b8ef46 100644 --- a/src/UESaveFile/Serialisers/IntPropertySerialiser.h +++ b/src/UESaveFile/Serialisers/IntPropertySerialiser.h @@ -27,8 +27,9 @@ class IntPropertySerialiser : public UnrealPropertySerialiser { using ptr = Containers::Pointer; private: - auto deserialiseProperty(Containers::StringView name, Containers::StringView type, UnsignedLong value_length, - BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override; - auto serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, - PropertySerialiser& serialiser) -> bool override; + UnrealPropertyBase::ptr deserialiseProperty(Containers::StringView name, Containers::StringView type, + UnsignedLong value_length, BinaryReader& reader, + PropertySerialiser& serialiser) override; + bool serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, + PropertySerialiser& serialiser) override; }; diff --git a/src/UESaveFile/Serialisers/MapPropertySerialiser.cpp b/src/UESaveFile/Serialisers/MapPropertySerialiser.cpp index 35a9055..7692575 100644 --- a/src/UESaveFile/Serialisers/MapPropertySerialiser.cpp +++ b/src/UESaveFile/Serialisers/MapPropertySerialiser.cpp @@ -24,9 +24,10 @@ using namespace Containers::Literals; -auto MapPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type, - UnsignedLong value_length, BinaryReader& reader, - PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr +UnrealPropertyBase::ptr +MapPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type, + UnsignedLong value_length, BinaryReader& reader, + PropertySerialiser& serialiser) { auto prop = Containers::pointer(); @@ -107,8 +108,9 @@ auto MapPropertySerialiser::deserialiseProperty(Containers::StringView name, Con return prop; } -auto MapPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, - BinaryWriter& writer, PropertySerialiser& serialiser) -> bool +bool +MapPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, + BinaryWriter& writer, PropertySerialiser& serialiser) { auto map_prop = dynamic_cast(prop.get()); if(!map_prop) { diff --git a/src/UESaveFile/Serialisers/MapPropertySerialiser.h b/src/UESaveFile/Serialisers/MapPropertySerialiser.h index e8ebaba..c6150aa 100644 --- a/src/UESaveFile/Serialisers/MapPropertySerialiser.h +++ b/src/UESaveFile/Serialisers/MapPropertySerialiser.h @@ -27,8 +27,9 @@ class MapPropertySerialiser : public UnrealPropertySerialiser { using ptr = Containers::Pointer; private: - auto deserialiseProperty(Containers::StringView name, Containers::StringView type, UnsignedLong value_length, - BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override; - auto serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, - PropertySerialiser& serialiser) -> bool override; + UnrealPropertyBase::ptr deserialiseProperty(Containers::StringView name, Containers::StringView type, + UnsignedLong value_length, BinaryReader& reader, + PropertySerialiser& serialiser) override; + bool serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, + PropertySerialiser& serialiser) override; }; diff --git a/src/UESaveFile/Serialisers/ResourcePropertySerialiser.cpp b/src/UESaveFile/Serialisers/ResourcePropertySerialiser.cpp index 6113c11..9a2ee48 100644 --- a/src/UESaveFile/Serialisers/ResourcePropertySerialiser.cpp +++ b/src/UESaveFile/Serialisers/ResourcePropertySerialiser.cpp @@ -25,9 +25,10 @@ using namespace Containers::Literals; -auto ResourcePropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type, - UnsignedLong value_length, BinaryReader& reader, - PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr +UnrealPropertyBase::ptr +ResourcePropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type, + UnsignedLong value_length, BinaryReader& reader, + PropertySerialiser& serialiser) { auto prop = Containers::pointer(); @@ -77,8 +78,9 @@ auto ResourcePropertySerialiser::deserialiseProperty(Containers::StringView name return prop; } -auto ResourcePropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, - BinaryWriter& writer, PropertySerialiser& serialiser) -> bool +bool +ResourcePropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, + BinaryWriter& writer, PropertySerialiser& serialiser) { auto res_prop = dynamic_cast(prop.get()); if(!res_prop) { diff --git a/src/UESaveFile/Serialisers/ResourcePropertySerialiser.h b/src/UESaveFile/Serialisers/ResourcePropertySerialiser.h index bccd012..8053327 100644 --- a/src/UESaveFile/Serialisers/ResourcePropertySerialiser.h +++ b/src/UESaveFile/Serialisers/ResourcePropertySerialiser.h @@ -27,8 +27,9 @@ class ResourcePropertySerialiser : public UnrealPropertySerialiser; private: - auto deserialiseProperty(Containers::StringView name, Containers::StringView type, UnsignedLong value_length, - BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override; - auto serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, - PropertySerialiser& serialiser) -> bool override; + UnrealPropertyBase::ptr deserialiseProperty(Containers::StringView name, Containers::StringView type, + UnsignedLong value_length, BinaryReader& reader, + PropertySerialiser& serialiser) override; + bool serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, + PropertySerialiser& serialiser) override; }; diff --git a/src/UESaveFile/Serialisers/RotatorPropertySerialiser.cpp b/src/UESaveFile/Serialisers/RotatorPropertySerialiser.cpp index ecd125d..3ea30d4 100644 --- a/src/UESaveFile/Serialisers/RotatorPropertySerialiser.cpp +++ b/src/UESaveFile/Serialisers/RotatorPropertySerialiser.cpp @@ -20,9 +20,10 @@ #include "RotatorPropertySerialiser.h" -auto RotatorPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type, - UnsignedLong value_length, BinaryReader& reader, - PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr +UnrealPropertyBase::ptr +RotatorPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type, + UnsignedLong value_length, BinaryReader& reader, + PropertySerialiser& serialiser) { auto prop = Containers::pointer(); @@ -34,8 +35,9 @@ auto RotatorPropertySerialiser::deserialiseProperty(Containers::StringView name, return prop; } -auto RotatorPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, - BinaryWriter& writer, PropertySerialiser& serialiser) -> bool +bool +RotatorPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, + BinaryWriter& writer, PropertySerialiser& serialiser) { auto rotator = dynamic_cast(prop.get()); if(!rotator) { diff --git a/src/UESaveFile/Serialisers/RotatorPropertySerialiser.h b/src/UESaveFile/Serialisers/RotatorPropertySerialiser.h index eec73c9..1ef9349 100644 --- a/src/UESaveFile/Serialisers/RotatorPropertySerialiser.h +++ b/src/UESaveFile/Serialisers/RotatorPropertySerialiser.h @@ -27,8 +27,9 @@ class RotatorPropertySerialiser : public UnrealPropertySerialiser; private: - auto deserialiseProperty(Containers::StringView name, Containers::StringView type, UnsignedLong value_length, - BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override; - auto serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, - PropertySerialiser& serialiser) -> bool override; + UnrealPropertyBase::ptr deserialiseProperty(Containers::StringView name, Containers::StringView type, + UnsignedLong value_length, BinaryReader& reader, + PropertySerialiser& serialiser) override; + bool serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, + PropertySerialiser& serialiser) override; }; diff --git a/src/UESaveFile/Serialisers/SetPropertySerialiser.cpp b/src/UESaveFile/Serialisers/SetPropertySerialiser.cpp index cfa9bd0..2c10211 100644 --- a/src/UESaveFile/Serialisers/SetPropertySerialiser.cpp +++ b/src/UESaveFile/Serialisers/SetPropertySerialiser.cpp @@ -21,9 +21,10 @@ #include "SetPropertySerialiser.h" -auto SetPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type, - UnsignedLong value_length, BinaryReader& reader, - PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr +UnrealPropertyBase::ptr +SetPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type, + UnsignedLong value_length, BinaryReader& reader, + PropertySerialiser& serialiser) { Containers::String item_type; if(!reader.readUEString(item_type)) { @@ -56,8 +57,9 @@ auto SetPropertySerialiser::deserialiseProperty(Containers::StringView name, Con return prop; } -auto SetPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, - BinaryWriter& writer, PropertySerialiser& serialiser) -> bool +bool +SetPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, + BinaryWriter& writer, PropertySerialiser& serialiser) { auto set_prop = dynamic_cast(prop.get()); if(!set_prop) { diff --git a/src/UESaveFile/Serialisers/SetPropertySerialiser.h b/src/UESaveFile/Serialisers/SetPropertySerialiser.h index 8bfddee..84ed8e5 100644 --- a/src/UESaveFile/Serialisers/SetPropertySerialiser.h +++ b/src/UESaveFile/Serialisers/SetPropertySerialiser.h @@ -27,8 +27,9 @@ class SetPropertySerialiser : public UnrealPropertySerialiser { using ptr = Containers::Pointer; private: - auto deserialiseProperty(Containers::StringView name, Containers::StringView type, UnsignedLong value_length, - BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override; - auto serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, - PropertySerialiser& serialiser) -> bool override; + UnrealPropertyBase::ptr deserialiseProperty(Containers::StringView name, Containers::StringView type, + UnsignedLong value_length, BinaryReader& reader, + PropertySerialiser& serialiser) override; + bool serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, + PropertySerialiser& serialiser) override; }; diff --git a/src/UESaveFile/Serialisers/StringPropertySerialiser.cpp b/src/UESaveFile/Serialisers/StringPropertySerialiser.cpp index 3cb4208..4c5f210 100644 --- a/src/UESaveFile/Serialisers/StringPropertySerialiser.cpp +++ b/src/UESaveFile/Serialisers/StringPropertySerialiser.cpp @@ -20,17 +20,18 @@ #include "StringPropertySerialiser.h" -auto StringPropertySerialiser::types() -> Containers::ArrayView { +StringArrayView +StringPropertySerialiser::types() { using namespace Containers::Literals; - static const Containers::Array types{InPlaceInit, - {"NameProperty"_s, "StrProperty"_s, - "SoftObjectProperty"_s, "ObjectProperty"_s}}; + static const Containers::Array types{InPlaceInit, { + "NameProperty"_s, "StrProperty"_s, "SoftObjectProperty"_s, "ObjectProperty"_s + }}; return types; } -auto StringPropertySerialiser::deserialise(Containers::StringView name, Containers::StringView type, - UnsignedLong value_length, BinaryReader& reader, - PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr +UnrealPropertyBase::ptr +StringPropertySerialiser::deserialise(Containers::StringView name, Containers::StringView type, + UnsignedLong value_length, BinaryReader& reader, PropertySerialiser& serialiser) { auto prop = Containers::pointer(type); @@ -52,8 +53,9 @@ auto StringPropertySerialiser::deserialise(Containers::StringView name, Containe return prop; } -auto StringPropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, - BinaryWriter& writer, PropertySerialiser& serialiser) -> bool +bool +StringPropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, + PropertySerialiser& serialiser) { auto str_prop = dynamic_cast(prop.get()); if(!str_prop) { diff --git a/src/UESaveFile/Serialisers/StringPropertySerialiser.h b/src/UESaveFile/Serialisers/StringPropertySerialiser.h index 5965bcf..685dfbf 100644 --- a/src/UESaveFile/Serialisers/StringPropertySerialiser.h +++ b/src/UESaveFile/Serialisers/StringPropertySerialiser.h @@ -27,11 +27,12 @@ class StringPropertySerialiser : public AbstractUnrealPropertySerialiser { public: using ptr = Containers::Pointer; - auto types() -> Containers::ArrayView override; + StringArrayView types() override; - auto deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length, - BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override; + UnrealPropertyBase::ptr deserialise(Containers::StringView name, Containers::StringView type, + UnsignedLong value_length, BinaryReader& reader, + PropertySerialiser& serialiser) override; - auto serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, - PropertySerialiser& serialiser) -> bool override; + bool serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, + PropertySerialiser& serialiser) override; }; diff --git a/src/UESaveFile/Serialisers/StructSerialiser.cpp b/src/UESaveFile/Serialisers/StructSerialiser.cpp index 95001b7..fe2e306 100644 --- a/src/UESaveFile/Serialisers/StructSerialiser.cpp +++ b/src/UESaveFile/Serialisers/StructSerialiser.cpp @@ -25,14 +25,16 @@ #include "StructSerialiser.h" -auto StructSerialiser::types() -> Containers::ArrayView { +StringArrayView +StructSerialiser::types() { using namespace Containers::Literals; static const Containers::Array types{InPlaceInit, {"StructProperty"_s}}; return types; } -auto StructSerialiser::deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length, - UnsignedInt count, BinaryReader& reader, PropertySerialiser& serialiser) -> Containers::Array +Containers::Array +StructSerialiser::deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length, + UnsignedInt count, BinaryReader& reader, PropertySerialiser& serialiser) { Containers::String item_type; if(!reader.readUEString(item_type)) { @@ -83,8 +85,9 @@ auto StructSerialiser::deserialise(Containers::StringView name, Containers::Stri return array; } -auto StructSerialiser::deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length, - BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr +UnrealPropertyBase::ptr +StructSerialiser::deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length, + BinaryReader& reader, PropertySerialiser& serialiser) { Containers::String item_type; if(!reader.readUEString(item_type)) { @@ -120,8 +123,9 @@ auto StructSerialiser::deserialise(Containers::StringView name, Containers::Stri return prop; } -auto StructSerialiser::serialise(Containers::ArrayView props, Containers::StringView item_type, - UnsignedLong& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) -> bool +bool +StructSerialiser::serialise(Containers::ArrayView props, Containers::StringView item_type, + UnsignedLong& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) { bytes_written += writer.writeUEStringToArray(*(props.front()->name)); bytes_written += writer.writeUEStringToArray(item_type); @@ -163,8 +167,9 @@ auto StructSerialiser::serialise(Containers::ArrayView return true; } -auto StructSerialiser::serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, - BinaryWriter& writer, PropertySerialiser& serialiser) -> bool +bool +StructSerialiser::serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, + PropertySerialiser& serialiser) { auto struct_prop = dynamic_cast(prop.get()); if(!struct_prop) { @@ -189,8 +194,9 @@ auto StructSerialiser::serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& by return true; } -auto StructSerialiser::readStructValue(Containers::StringView name, Containers::StringView type, UnsignedLong value_length, - BinaryReader& reader, PropertySerialiser& serialiser) -> StructProperty::ptr +StructProperty::ptr +StructSerialiser::readStructValue(Containers::StringView name, Containers::StringView type, UnsignedLong value_length, + BinaryReader& reader, PropertySerialiser& serialiser) { auto st_prop = Containers::pointer(); st_prop->structType = type; @@ -212,8 +218,9 @@ auto StructSerialiser::readStructValue(Containers::StringView name, Containers:: return st_prop; } -auto StructSerialiser::writeStructValue(StructProperty* prop, UnsignedLong& bytes_written, - BinaryWriter& writer, PropertySerialiser& serialiser) -> bool +bool +StructSerialiser::writeStructValue(StructProperty* prop, UnsignedLong& bytes_written, BinaryWriter& writer, + PropertySerialiser& serialiser) { auto struct_prop = dynamic_cast(prop); if(!struct_prop) { diff --git a/src/UESaveFile/Serialisers/StructSerialiser.h b/src/UESaveFile/Serialisers/StructSerialiser.h index 81efcc0..2de192d 100644 --- a/src/UESaveFile/Serialisers/StructSerialiser.h +++ b/src/UESaveFile/Serialisers/StructSerialiser.h @@ -29,20 +29,23 @@ class StructSerialiser : public AbstractUnrealPropertySerialiser, public Abstrac public: using ptr = Containers::Pointer; - auto types() -> Containers::ArrayView override; + StringArrayView types() override; - auto deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length, - UnsignedInt count, BinaryReader& reader, PropertySerialiser& serialiser) -> Containers::Array override; - auto deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length, - BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override; + PropertyArray deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length, + UnsignedInt count, BinaryReader& reader, PropertySerialiser& serialiser) override; + UnrealPropertyBase::ptr deserialise(Containers::StringView name, Containers::StringView type, + UnsignedLong value_length, BinaryReader& reader, + PropertySerialiser& serialiser) override; - auto serialise(Containers::ArrayView props, Containers::StringView item_type, - UnsignedLong& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) -> bool override; - auto serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, - BinaryWriter& writer, PropertySerialiser& serialiser) -> bool override; + bool serialise(PropertyArrayView props, Containers::StringView item_type, UnsignedLong& bytes_written, + BinaryWriter& writer, PropertySerialiser& serialiser) override; + bool serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, + PropertySerialiser& serialiser) override; private: - auto readStructValue(Containers::StringView name, Containers::StringView type, UnsignedLong value_length, - BinaryReader& reader, PropertySerialiser& serialiser) -> StructProperty::ptr; - auto writeStructValue(StructProperty* prop, UnsignedLong& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) -> bool; -}; + StructProperty::ptr readStructValue(Containers::StringView name, Containers::StringView type, + UnsignedLong value_length, BinaryReader& reader, + PropertySerialiser& serialiser); + bool writeStructValue(StructProperty* prop, UnsignedLong& bytes_written, BinaryWriter& writer, + PropertySerialiser& serialiser); +} ; diff --git a/src/UESaveFile/Serialisers/TextPropertySerialiser.cpp b/src/UESaveFile/Serialisers/TextPropertySerialiser.cpp index 89d9af0..a3e2329 100644 --- a/src/UESaveFile/Serialisers/TextPropertySerialiser.cpp +++ b/src/UESaveFile/Serialisers/TextPropertySerialiser.cpp @@ -21,9 +21,10 @@ #include "TextPropertySerialiser.h" -auto TextPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type, - UnsignedLong value_length, BinaryReader& reader, - PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr +UnrealPropertyBase::ptr +TextPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type, + UnsignedLong value_length, BinaryReader& reader, + PropertySerialiser& serialiser) { auto prop = Containers::pointer(); @@ -68,8 +69,9 @@ auto TextPropertySerialiser::deserialiseProperty(Containers::StringView name, Co return prop; } -auto TextPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, - BinaryWriter& writer, PropertySerialiser& serialiser) -> bool +bool +TextPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, + BinaryWriter& writer, PropertySerialiser& serialiser) { auto text_prop = dynamic_cast(prop.get()); diff --git a/src/UESaveFile/Serialisers/TextPropertySerialiser.h b/src/UESaveFile/Serialisers/TextPropertySerialiser.h index 0938936..08e1028 100644 --- a/src/UESaveFile/Serialisers/TextPropertySerialiser.h +++ b/src/UESaveFile/Serialisers/TextPropertySerialiser.h @@ -27,8 +27,9 @@ class TextPropertySerialiser : public UnrealPropertySerialiser { using ptr = Containers::Pointer; private: - auto deserialiseProperty(Containers::StringView name, Containers::StringView type, UnsignedLong value_length, - BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override; - auto serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, - PropertySerialiser& serialiser) -> bool override; + UnrealPropertyBase::ptr deserialiseProperty(Containers::StringView name, Containers::StringView type, + UnsignedLong value_length, BinaryReader& reader, + PropertySerialiser& serialiser) override; + bool serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, + PropertySerialiser& serialiser) override; }; diff --git a/src/UESaveFile/Serialisers/UnrealPropertySerialiser.h b/src/UESaveFile/Serialisers/UnrealPropertySerialiser.h index e3fcdb6..763d18f 100644 --- a/src/UESaveFile/Serialisers/UnrealPropertySerialiser.h +++ b/src/UESaveFile/Serialisers/UnrealPropertySerialiser.h @@ -27,17 +27,19 @@ template class UnrealPropertySerialiser : public AbstractUnrealPropertySerialiser { - static_assert(std::is_base_of::value, "T must be derived from UnrealPropertyBase."); + static_assert(std::is_base_of::value, "T must be derived from UnrealPropertyBase."); public: using ptr = Containers::Pointer>; - auto types() -> Containers::ArrayView override { + StringArrayView types() override { static const Containers::Array types = []{ Containers::Array array; Containers::Pointer p(new T); if(std::is_base_of::value) { - array = Containers::Array{InPlaceInit, {dynamic_cast(p.get())->structType}}; + array = Containers::Array{InPlaceInit, { + dynamic_cast(p.get())->structType + }}; } else { array = Containers::Array{InPlaceInit, {p->propertyType}}; @@ -47,23 +49,24 @@ class UnrealPropertySerialiser : public AbstractUnrealPropertySerialiser { return types; } - auto deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length, - BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override + UnrealPropertyBase::ptr deserialise(Containers::StringView name, Containers::StringView type, + UnsignedLong value_length, BinaryReader& reader, + PropertySerialiser& serialiser) override { return deserialiseProperty(name, type, value_length, reader, serialiser); } - auto serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, - PropertySerialiser& serialiser) -> bool override + bool serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, + PropertySerialiser& serialiser) override { return serialiseProperty(prop, bytes_written, writer, serialiser); } private: - virtual auto deserialiseProperty(Containers::StringView name, Containers::StringView type, - UnsignedLong value_length, BinaryReader& reader, - PropertySerialiser& serialiser) -> typename UnrealPropertyBase::ptr = 0; + virtual UnrealPropertyBase::ptr deserialiseProperty(Containers::StringView name, Containers::StringView type, + UnsignedLong value_length, BinaryReader& reader, + PropertySerialiser& serialiser) = 0; - virtual auto serialiseProperty(typename UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, - BinaryWriter& writer, PropertySerialiser& serialiser) -> bool = 0; + virtual bool serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, + PropertySerialiser& serialiser) = 0; }; diff --git a/src/UESaveFile/Serialisers/Vector2DPropertySerialiser.cpp b/src/UESaveFile/Serialisers/Vector2DPropertySerialiser.cpp index ef002c7..872e767 100644 --- a/src/UESaveFile/Serialisers/Vector2DPropertySerialiser.cpp +++ b/src/UESaveFile/Serialisers/Vector2DPropertySerialiser.cpp @@ -20,9 +20,10 @@ #include "Vector2DPropertySerialiser.h" -auto Vector2DPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type, - UnsignedLong value_length, BinaryReader& reader, - PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr +UnrealPropertyBase::ptr +Vector2DPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type, + UnsignedLong value_length, BinaryReader& reader, + PropertySerialiser& serialiser) { auto prop = Containers::pointer(); @@ -34,8 +35,9 @@ auto Vector2DPropertySerialiser::deserialiseProperty(Containers::StringView name return prop; } -auto Vector2DPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, - BinaryWriter& writer, PropertySerialiser& serialiser) -> bool +bool +Vector2DPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, + BinaryWriter& writer, PropertySerialiser& serialiser) { auto vector = dynamic_cast(prop.get()); if(!vector) { diff --git a/src/UESaveFile/Serialisers/Vector2DPropertySerialiser.h b/src/UESaveFile/Serialisers/Vector2DPropertySerialiser.h index faa1682..f6de167 100644 --- a/src/UESaveFile/Serialisers/Vector2DPropertySerialiser.h +++ b/src/UESaveFile/Serialisers/Vector2DPropertySerialiser.h @@ -27,8 +27,9 @@ class Vector2DPropertySerialiser : public UnrealPropertySerialiser; private: - auto deserialiseProperty(Containers::StringView name, Containers::StringView type, UnsignedLong value_length, - BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override; - auto serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, - PropertySerialiser& serialiser) -> bool override; + UnrealPropertyBase::ptr deserialiseProperty(Containers::StringView name, Containers::StringView type, + UnsignedLong value_length, BinaryReader& reader, + PropertySerialiser& serialiser) override; + bool serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, + PropertySerialiser& serialiser) override; }; diff --git a/src/UESaveFile/Serialisers/VectorPropertySerialiser.cpp b/src/UESaveFile/Serialisers/VectorPropertySerialiser.cpp index 97bd0a8..738914d 100644 --- a/src/UESaveFile/Serialisers/VectorPropertySerialiser.cpp +++ b/src/UESaveFile/Serialisers/VectorPropertySerialiser.cpp @@ -20,9 +20,10 @@ #include "VectorPropertySerialiser.h" -auto VectorPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type, - UnsignedLong value_length, BinaryReader& reader, - PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr +UnrealPropertyBase::ptr +VectorPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type, + UnsignedLong value_length, BinaryReader& reader, + PropertySerialiser& serialiser) { auto prop = Containers::pointer(); @@ -34,8 +35,9 @@ auto VectorPropertySerialiser::deserialiseProperty(Containers::StringView name, return prop; } -auto VectorPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, - BinaryWriter& writer, PropertySerialiser& serialiser) -> bool +bool +VectorPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, + BinaryWriter& writer, PropertySerialiser& serialiser) { auto vector = dynamic_cast(prop.get()); if(!vector) { diff --git a/src/UESaveFile/Serialisers/VectorPropertySerialiser.h b/src/UESaveFile/Serialisers/VectorPropertySerialiser.h index 8a8cc7e..85d2920 100644 --- a/src/UESaveFile/Serialisers/VectorPropertySerialiser.h +++ b/src/UESaveFile/Serialisers/VectorPropertySerialiser.h @@ -27,8 +27,9 @@ class VectorPropertySerialiser : public UnrealPropertySerialiser; private: - auto deserialiseProperty(Containers::StringView name, Containers::StringView type, UnsignedLong value_length, - BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override; - auto serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, - PropertySerialiser& serialiser) -> bool override; + UnrealPropertyBase::ptr deserialiseProperty(Containers::StringView name, Containers::StringView type, + UnsignedLong value_length, BinaryReader& reader, + PropertySerialiser& serialiser) override; + bool serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, + PropertySerialiser& serialiser) override; }; diff --git a/src/UESaveFile/Types/GenericStructProperty.h b/src/UESaveFile/Types/GenericStructProperty.h index 9c76828..6472fd0 100644 --- a/src/UESaveFile/Types/GenericStructProperty.h +++ b/src/UESaveFile/Types/GenericStructProperty.h @@ -45,7 +45,7 @@ struct GenericStructProperty : public StructProperty { atMove(Containers::StringView name) { for(auto& item : properties) { if(item && item->name == name) { - return Containers::Pointer{static_cast(item.release())}; + return Containers::pointerCast(std::move(item)); } } return nullptr; diff --git a/src/UESaveFile/UESaveFile.cpp b/src/UESaveFile/UESaveFile.cpp index 44942ba..51d5684 100644 --- a/src/UESaveFile/UESaveFile.cpp +++ b/src/UESaveFile/UESaveFile.cpp @@ -33,15 +33,18 @@ UESaveFile::UESaveFile(Containers::String filepath): loadData(); } -auto UESaveFile::valid() const -> bool { +bool +UESaveFile::valid() const { return _valid; } -auto UESaveFile::lastError() const -> Containers::StringView { +Containers::StringView +UESaveFile::lastError() const { return _lastError; } -auto UESaveFile::reloadData() -> bool { +bool +UESaveFile::reloadData() { if(_noReloadAfterSave) { _noReloadAfterSave = false; return valid(); @@ -52,21 +55,25 @@ auto UESaveFile::reloadData() -> bool { return valid(); } -auto UESaveFile::saveType() -> Containers::StringView { +Containers::StringView +UESaveFile::saveType() { return _saveType; } -void UESaveFile::appendProperty(UnrealPropertyBase::ptr prop) { +void +UESaveFile::appendProperty(UnrealPropertyBase::ptr prop) { auto none_prop = std::move(_properties.back()); _properties.back() = std::move(prop); arrayAppend(_properties, std::move(none_prop)); } -auto UESaveFile::props() -> Containers::ArrayView { +Containers::ArrayView +UESaveFile::props() { return _properties; } -auto UESaveFile::saveToFile() -> bool { +bool +UESaveFile::saveToFile() { LOG_INFO_FORMAT("Writing to {}.", _filepath); bool temp_file = _filepath.hasSuffix(".tmp"); @@ -155,7 +162,8 @@ auto UESaveFile::saveToFile() -> bool { return true; } -void UESaveFile::loadData() { +void +UESaveFile::loadData() { LOG_INFO_FORMAT("Reading data from {}.", _filepath); _valid = false; diff --git a/src/UESaveFile/UESaveFile.h b/src/UESaveFile/UESaveFile.h index a281369..8ed3476 100644 --- a/src/UESaveFile/UESaveFile.h +++ b/src/UESaveFile/UESaveFile.h @@ -36,12 +36,12 @@ class UESaveFile { public: explicit UESaveFile(Containers::String filepath); - auto valid() const -> bool; - auto lastError() const -> Containers::StringView; + bool valid() const; + Containers::StringView lastError() const; - auto reloadData() -> bool; + bool reloadData(); - auto saveType() -> Containers::StringView; + Containers::StringView saveType(); template std::enable_if_t::value, T*> @@ -56,9 +56,9 @@ class UESaveFile { void appendProperty(UnrealPropertyBase::ptr prop); - auto props() -> Containers::ArrayView; + Containers::ArrayView props(); - auto saveToFile() -> bool; + bool saveToFile(); private: void loadData();