From 847e07e88dbfde890c4e3a0e025d3811c018895a Mon Sep 17 00:00:00 2001 From: William JCM Date: Mon, 5 Dec 2022 11:32:18 +0100 Subject: [PATCH] Update coding style. Magnum's type names are fine, but I'd rather limit what depends on Magnum as much as possible. Vector types are still allowed, though. No way I'll write my own. --- src/Logger/Logger.cpp | 4 +- src/Logger/Logger.h | 6 +- src/Maps/Accessories.h | 7 +- src/Maps/ArmourSets.h | 7 +- src/Maps/LastMissionId.h | 5 +- src/Maps/StoryProgress.h | 5 +- src/Maps/StyleNames.h | 7 +- src/Maps/WeaponParts.h | 29 ++- src/Mass/Accessory.h | 6 +- src/Mass/ArmourPart.h | 7 +- src/Mass/CustomStyle.h | 12 +- src/Mass/Decal.h | 7 +- src/Mass/Joints.h | 20 +- src/Mass/Mass.cpp | 19 +- src/Mass/Mass.h | 43 +++-- src/Mass/Mass_Armour.cpp | 14 +- src/Mass/Mass_DecalsAccessories.cpp | 12 +- src/Mass/Mass_Frame.cpp | 8 +- src/Mass/Mass_Styles.cpp | 6 +- src/Mass/Mass_Weapons.cpp | 14 +- src/Mass/Weapon.cpp | 4 +- src/Mass/WeaponPart.h | 15 +- src/MassManager/MassManager.cpp | 14 +- src/Profile/Profile.cpp | 116 ++++++------ src/Profile/Profile.h | 179 +++++++++--------- src/Profile/ResourceIDs.h | 6 +- src/ProfileManager/ProfileManager.cpp | 10 +- src/ProfileManager/ProfileManager.h | 14 +- src/SaveTool/SaveTool.cpp | 10 +- src/SaveTool/SaveTool.h | 36 ++-- src/SaveTool/SaveTool_FileWatcher.cpp | 4 +- src/SaveTool/SaveTool_Initialisation.cpp | 8 +- src/SaveTool/SaveTool_MainManager.cpp | 64 +++---- src/SaveTool/SaveTool_MassViewer.cpp | 20 +- src/SaveTool/SaveTool_MassViewer_Armour.cpp | 22 +-- src/SaveTool/SaveTool_MassViewer_Frame.cpp | 4 +- src/SaveTool/SaveTool_MassViewer_Weapons.cpp | 20 +- src/SaveTool/SaveTool_UpdateChecker.cpp | 10 +- src/SaveTool/SaveTool_drawMainMenu.cpp | 4 +- src/ToastQueue/ToastQueue.cpp | 35 ++-- src/ToastQueue/ToastQueue.h | 10 +- src/UESaveFile/BinaryReader.cpp | 52 ++--- src/UESaveFile/BinaryReader.h | 30 ++- src/UESaveFile/BinaryWriter.cpp | 50 ++--- src/UESaveFile/BinaryWriter.h | 42 ++-- src/UESaveFile/PropertySerialiser.cpp | 32 ++-- src/UESaveFile/PropertySerialiser.h | 14 +- ...stractUnrealCollectionPropertySerialiser.h | 9 +- .../AbstractUnrealPropertySerialiser.h | 7 +- .../AbstractUnrealStructSerialiser.h | 6 +- .../Serialisers/ArrayPropertySerialiser.cpp | 14 +- .../Serialisers/ArrayPropertySerialiser.h | 7 +- .../Serialisers/BoolPropertySerialiser.cpp | 10 +- .../Serialisers/BoolPropertySerialiser.h | 4 +- .../Serialisers/BytePropertySerialiser.cpp | 14 +- .../Serialisers/BytePropertySerialiser.h | 4 +- .../Serialisers/ColourPropertySerialiser.cpp | 12 +- .../Serialisers/ColourPropertySerialiser.h | 4 +- .../DateTimePropertySerialiser.cpp | 8 +- .../Serialisers/DateTimePropertySerialiser.h | 4 +- .../Serialisers/EnumPropertySerialiser.cpp | 4 +- .../Serialisers/EnumPropertySerialiser.h | 4 +- .../Serialisers/FloatPropertySerialiser.cpp | 6 +- .../Serialisers/FloatPropertySerialiser.h | 4 +- .../Serialisers/GuidPropertySerialiser.cpp | 4 +- .../Serialisers/GuidPropertySerialiser.h | 4 +- .../Serialisers/IntPropertySerialiser.cpp | 16 +- .../Serialisers/IntPropertySerialiser.h | 4 +- .../Serialisers/MapPropertySerialiser.cpp | 22 +-- .../Serialisers/MapPropertySerialiser.h | 4 +- .../ResourcePropertySerialiser.cpp | 12 +- .../Serialisers/ResourcePropertySerialiser.h | 4 +- .../Serialisers/RotatorPropertySerialiser.cpp | 8 +- .../Serialisers/RotatorPropertySerialiser.h | 4 +- .../Serialisers/SetPropertySerialiser.cpp | 20 +- .../Serialisers/SetPropertySerialiser.h | 4 +- .../Serialisers/StringPropertySerialiser.cpp | 8 +- .../Serialisers/StringPropertySerialiser.h | 4 +- .../Serialisers/StructSerialiser.cpp | 32 ++-- src/UESaveFile/Serialisers/StructSerialiser.h | 14 +- .../Serialisers/TextPropertySerialiser.cpp | 8 +- .../Serialisers/TextPropertySerialiser.h | 4 +- .../Serialisers/UnrealPropertySerialiser.h | 8 +- .../Vector2DPropertySerialiser.cpp | 6 +- .../Serialisers/Vector2DPropertySerialiser.h | 4 +- .../Serialisers/VectorPropertySerialiser.cpp | 8 +- .../Serialisers/VectorPropertySerialiser.h | 4 +- src/UESaveFile/Types/ColourStructProperty.h | 2 +- src/UESaveFile/Types/DateTimeStructProperty.h | 5 +- src/UESaveFile/Types/FloatProperty.h | 5 +- src/UESaveFile/Types/IntProperty.h | 2 +- src/UESaveFile/Types/ResourceItemValue.h | 11 +- src/UESaveFile/Types/RotatorStructProperty.h | 5 +- src/UESaveFile/Types/UnrealPropertyBase.h | 7 +- src/UESaveFile/Types/Vector2DStructProperty.h | 5 +- src/UESaveFile/Types/VectorStructProperty.h | 5 +- src/UESaveFile/UESaveFile.cpp | 48 ++--- src/UESaveFile/UESaveFile.h | 19 +- src/Utilities/Crc32.h | 60 +++--- src/main.cpp | 2 +- 100 files changed, 751 insertions(+), 815 deletions(-) diff --git a/src/Logger/Logger.cpp b/src/Logger/Logger.cpp index b8f5cd4..7ae0f9d 100644 --- a/src/Logger/Logger.cpp +++ b/src/Logger/Logger.cpp @@ -25,8 +25,6 @@ using Utility::Debug; using Utility::Warning; using Utility::Error; -using namespace Magnum; - Logger& Logger::instance() { static Logger logger; @@ -89,7 +87,7 @@ Logger::log(EntryType type, StringView location, StringView message) { d << "["_s << Debug::nospace << location << Debug::nospace << "]"; - for(UnsignedInt i = 0; i < _indentLevel; i++) { + for(auto i = 0u; i < _indentLevel; i++) { d << Debug::nospace << " "_s << Debug::nospace; } diff --git a/src/Logger/Logger.h b/src/Logger/Logger.h index 370c08b..9bb793b 100644 --- a/src/Logger/Logger.h +++ b/src/Logger/Logger.h @@ -27,8 +27,6 @@ #include #include -#include - #include "EntryType.h" using namespace Corrade; @@ -37,8 +35,6 @@ using Containers::ArrayView; using Containers::String; using Containers::StringView; -using namespace Magnum; - using namespace Containers::Literals; class Logger { @@ -68,7 +64,7 @@ class Logger { std::ofstream _logFile; #endif - UnsignedInt _indentLevel = 0; + std::uint32_t _indentLevel = 0; std::mutex _logMutex{}; }; diff --git a/src/Maps/Accessories.h b/src/Maps/Accessories.h index 5b3ebbb..61b664a 100644 --- a/src/Maps/Accessories.h +++ b/src/Maps/Accessories.h @@ -16,15 +16,14 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . +#include + #include #include -#include - using namespace Corrade; using namespace Containers::Literals; -using namespace Magnum; enum AccessorySize { S, @@ -38,7 +37,7 @@ struct AccessoryData{ AccessorySize size = AccessorySize::S; }; -static const std::map accessories { +static const std::map accessories { // region Primitives {1, {"Cube"_s, AccessorySize::S}}, {2, {"Pentagon"_s, AccessorySize::S}}, diff --git a/src/Maps/ArmourSets.h b/src/Maps/ArmourSets.h index 8051709..167c471 100644 --- a/src/Maps/ArmourSets.h +++ b/src/Maps/ArmourSets.h @@ -16,22 +16,21 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . +#include + #include #include -#include - using namespace Corrade; using namespace Containers::Literals; -using namespace Magnum; struct ArmourSet { Containers::StringView name; bool neck_compatible; }; -static const std::map armour_sets { +static const std::map armour_sets { {-1, {""_s, true}}, {0, {"Vanguard"_s, true}}, {1, {"Assault Mk.I"_s, true}}, diff --git a/src/Maps/LastMissionId.h b/src/Maps/LastMissionId.h index 4cbdd23..bcc60d3 100644 --- a/src/Maps/LastMissionId.h +++ b/src/Maps/LastMissionId.h @@ -20,13 +20,10 @@ #include -#include - using namespace Corrade; using namespace Containers::Literals; -using namespace Magnum; -static const std::map mission_id_map {{ +static const std::map mission_id_map {{ // Story missions {0x0064, "Mission 1 - Training"_s}, {0x0065, "Mission 2 - Patrol Operation"_s}, diff --git a/src/Maps/StoryProgress.h b/src/Maps/StoryProgress.h index 2e9e28d..040aa01 100644 --- a/src/Maps/StoryProgress.h +++ b/src/Maps/StoryProgress.h @@ -19,14 +19,11 @@ #include #include -#include - using namespace Corrade; using namespace Containers::Literals; -using namespace Magnum; struct StoryProgressPoint { - Int id; + std::int32_t id; Containers::StringView chapter; Containers::StringView point; Containers::StringView after = nullptr; diff --git a/src/Maps/StyleNames.h b/src/Maps/StyleNames.h index e62188f..675a117 100644 --- a/src/Maps/StyleNames.h +++ b/src/Maps/StyleNames.h @@ -16,17 +16,16 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . +#include + #include #include -#include - using namespace Corrade; using namespace Containers::Literals; -using namespace Magnum; -extern const std::map style_names +extern const std::map style_names #ifdef STYLENAMES_DEFINITION { {0, "Custom Style 1"_s}, diff --git a/src/Maps/WeaponParts.h b/src/Maps/WeaponParts.h index 3455943..8de7269 100644 --- a/src/Maps/WeaponParts.h +++ b/src/Maps/WeaponParts.h @@ -15,19 +15,18 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . +#include + #include #include -#include - using namespace Corrade; -using namespace Magnum; using namespace Containers::Literals; // region Melee -static const std::map melee_grips { +static const std::map melee_grips { {0, "Combat Grip (1H)"_s}, {1, "Knuckle Guard Grip (1H)"_s}, {2, "Dual Guard Grip (1H)"_s}, @@ -78,7 +77,7 @@ static const std::map melee_grips { {2404, "Arched Twin Blade (2H)"_s}, }; -static const std::map melee_assaulters { +static const std::map melee_assaulters { {0, "Long Metal Blade"_s}, {1, "Long Assault Blade"_s}, {2, "Long Fin Blade"_s}, @@ -172,7 +171,7 @@ static const std::map melee_assaulters { // endregion // region Shields -static const std::map shield_handles { +static const std::map shield_handles { {0, "Balanced Handle"_s}, {1, "Expanded Handle"_s}, {2, "Lowguard Handle"_s}, @@ -191,7 +190,7 @@ static const std::map shield_handles { {101, "Star Handle"_s}, }; -static const std::map shield_shells { +static const std::map shield_shells { {0, "Balanced Shell"_s}, {1, "Compass Shell"_s}, {2, "Uppoint Shell"_s}, @@ -212,7 +211,7 @@ static const std::map shield_shells { // endregion // region Bullet Shooters -static const std::map bshooter_triggers { +static const std::map bshooter_triggers { {0, "BL-Combat Trigger (1H)"_s}, {1, "Light Machine Trigger (1H)"_s}, {2, "Tactical Trigger (1H)"_s}, @@ -230,7 +229,7 @@ static const std::map bshooter_triggers { {199, "2H Base Trigger (2H)"_s}, }; -static const std::map bshooter_barrels { +static const std::map bshooter_barrels { {0, "BL-Combat Barrel (1 shot)"_s}, {1, "Shock Absorb Barrel (1 shot) (Motion)"_s}, {2, "Muzzlemod Barrel (1 shot)"_s}, @@ -267,7 +266,7 @@ static const std::map bshooter_barrels { // endregion //region Energy Shooters -static const std::map eshooter_triggers { +static const std::map eshooter_triggers { {0, "EN-Rifle Trigger (1H)"_s}, {1, "Underarm Trigger (1H)"_s}, {2, "EN-Inverted Trigger (1H)"_s}, @@ -285,7 +284,7 @@ static const std::map eshooter_triggers { {199, "2H Base EnTrigger (2H)"_s}, }; -static const std::map eshooter_busters { +static const std::map eshooter_busters { {0, "EN-Combat Buster (1 shot)"_s}, {1, "Delta Cycler (1 shot) (Motion)"_s}, {2, "EN-Longbarrel Buster (1 shot)"_s}, @@ -321,7 +320,7 @@ static const std::map eshooter_busters { // endregion // region Bullet Launchers -static const std::map blauncher_pods { +static const std::map blauncher_pods { {0, "BL-Delta Pack Launcher (Missile x12)"_s}, {1, "BL-Twin Pack Launcher (Missile x12)"_s}, {2, "Detector Launcher (Missile x12)"_s}, @@ -351,7 +350,7 @@ static const std::map blauncher_pods { {399, "C Base Pod (Cluster x40)"_s}, }; -static const std::map blauncher_projectiles { +static const std::map blauncher_projectiles { {0, "Flathead Missile"_s}, {1, "Warhead Missile"_s}, {2, "Pointhead Missile"_s}, @@ -361,7 +360,7 @@ static const std::map blauncher_projectiles { // endregion // region Energy Launchers -static const std::map elauncher_generators { +static const std::map elauncher_generators { {0, "Fly Unit"_s}, {1, "Assault Unit (Motion)"_s}, {2, "Falcon Unit"_s}, @@ -393,7 +392,7 @@ static const std::map elauncher_generators { {99, "Base Generator"}, }; -static const std::map elauncher_pods { +static const std::map elauncher_pods { {0, "EN-Dual Claw Launcher (Echo) (Motion)"_s}, {1, "EN-Assault Launcher (Echo)"_s}, {2, "EN-Tactical Launcher (Echo)"_s}, diff --git a/src/Mass/Accessory.h b/src/Mass/Accessory.h index cca271d..4f326f4 100644 --- a/src/Mass/Accessory.h +++ b/src/Mass/Accessory.h @@ -25,9 +25,9 @@ using namespace Corrade; using namespace Magnum; struct Accessory { - Int attachIndex = -1; - Int id = -1; - Containers::StaticArray<2, Int> styles{ValueInit}; + std::int32_t attachIndex = -1; + std::int32_t id = -1; + Containers::StaticArray<2, std::int32_t> styles{ValueInit}; Vector3 relativePosition{0.0f}; Vector3 relativePositionOffset{0.0f}; Vector3 relativeRotation{0.0f}; diff --git a/src/Mass/ArmourPart.h b/src/Mass/ArmourPart.h index 9f7a96c..c30dc79 100644 --- a/src/Mass/ArmourPart.h +++ b/src/Mass/ArmourPart.h @@ -19,13 +19,10 @@ #include #include -#include - #include "Decal.h" #include "Accessory.h" using namespace Corrade; -using namespace Magnum; enum class ArmourSlot { #define c(enumerator, enumstr, name) enumerator, @@ -35,8 +32,8 @@ enum class ArmourSlot { struct ArmourPart { ArmourSlot slot = ArmourSlot::Face; - Int id = 0; - Containers::StaticArray<4, Int> styles{ValueInit}; + std::int32_t id = 0; + Containers::StaticArray<4, std::int32_t> styles{ValueInit}; Containers::Array decals; Containers::Array accessories; }; diff --git a/src/Mass/CustomStyle.h b/src/Mass/CustomStyle.h index 7fcc9c3..8dbc832 100644 --- a/src/Mass/CustomStyle.h +++ b/src/Mass/CustomStyle.h @@ -28,13 +28,13 @@ using namespace Magnum; struct CustomStyle { Containers::String name; Color4 colour{0.0f}; - Float metallic = 0.5f; - Float gloss = 0.5f; + float metallic = 0.5f; + float gloss = 0.5f; bool glow = false; - Int patternId = 0; - Float opacity = 0.5f; + std::int32_t patternId = 0; + float opacity = 0.5f; Vector2 offset{0.5f}; - Float rotation = 0.0f; - Float scale = 0.5f; + float rotation = 0.0f; + float scale = 0.5f; }; diff --git a/src/Mass/Decal.h b/src/Mass/Decal.h index 3758b75..727147b 100644 --- a/src/Mass/Decal.h +++ b/src/Mass/Decal.h @@ -19,18 +19,19 @@ #include #include #include +#include using namespace Magnum; struct Decal { - Int id = -1; + std::int32_t id = -1; Color4 colour{0.0f}; Vector3 position{0.0f}; Vector3 uAxis{0.0f}; Vector3 vAxis{0.0f}; Vector2 offset{0.5f}; - Float scale = 0.5f; - Float rotation = 0.0f; + float scale = 0.5f; + float rotation = 0.0f; bool flip = false; bool wrap = false; }; diff --git a/src/Mass/Joints.h b/src/Mass/Joints.h index 8cc58c2..a1c358e 100644 --- a/src/Mass/Joints.h +++ b/src/Mass/Joints.h @@ -16,17 +16,13 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -#include - -using namespace Magnum; - struct Joints { - Float neck = 0.0f; - Float body = 0.0f; - Float shoulders = 0.0f; - Float hips = 0.0f; - Float upperArms = 0.0f; - Float lowerArms = 0.0f; - Float upperLegs = 0.0f; - Float lowerLegs = 0.0f; + float neck = 0.0f; + float body = 0.0f; + float shoulders = 0.0f; + float hips = 0.0f; + float upperArms = 0.0f; + float lowerArms = 0.0f; + float upperLegs = 0.0f; + float lowerLegs = 0.0f; }; diff --git a/src/Mass/Mass.cpp b/src/Mass/Mass.cpp index 98f064f..d585c74 100644 --- a/src/Mass/Mass.cpp +++ b/src/Mass/Mass.cpp @@ -308,32 +308,32 @@ Mass::getTuning() { } } -Int& +std::int32_t& Mass::engine() { return _tuning.engineId; } -Containers::ArrayView +Containers::ArrayView Mass::gears() { return _tuning.gearIds; } -Int& +std::int32_t& Mass::os() { return _tuning.osId; } -Containers::ArrayView +Containers::ArrayView Mass::modules() { return _tuning.moduleIds; } -Int& +std::int32_t& Mass::architecture() { return _tuning.archId; } -Containers::ArrayView +Containers::ArrayView Mass::techs() { return _tuning.techIds; } @@ -365,8 +365,9 @@ Mass::updateAccount(Containers::StringView new_account) { } void -Mass::getTuningCategory(Containers::StringView big_node_prop_name, Int& big_node_id, - Containers::StringView small_nodes_prop_name, Containers::ArrayView small_nodes_ids) +Mass::getTuningCategory(Containers::StringView big_node_prop_name, std::int32_t& 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); @@ -392,7 +393,7 @@ Mass::getTuningCategory(Containers::StringView big_node_prop_name, Int& big_node return; } - for(UnsignedInt i = 0; i < small_nodes_ids.size(); i++) { + for(std::uint32_t i = 0; i < small_nodes_ids.size(); i++) { auto small_node_id = node_ids->at(i); CORRADE_INTERNAL_ASSERT(small_node_id); small_nodes_ids[i] = small_node_id->value; diff --git a/src/Mass/Mass.h b/src/Mass/Mass.h index ed991c7..74292ec 100644 --- a/src/Mass/Mass.h +++ b/src/Mass/Mass.h @@ -64,7 +64,7 @@ class Mass { Containers::StringView name(); bool setName(Containers::StringView new_name); - enum class State : UnsignedByte { + enum class State: std::uint8_t { Empty, Invalid, Valid }; @@ -77,7 +77,7 @@ class Mass { void getJointSliders(); bool writeJointSliders(); - Containers::ArrayView frameStyles(); + Containers::ArrayView frameStyles(); void getFrameStyles(); bool writeFrameStyles(); @@ -87,7 +87,7 @@ class Mass { Containers::ArrayView frameCustomStyles(); void getFrameCustomStyles(); - bool writeFrameCustomStyle(UnsignedLong index); + bool writeFrameCustomStyle(std::size_t index); Containers::ArrayView armourParts(); void getArmourParts(); @@ -100,7 +100,7 @@ class Mass { Containers::ArrayView armourCustomStyles(); void getArmourCustomStyles(); - bool writeArmourCustomStyle(UnsignedLong index); + bool writeArmourCustomStyle(std::size_t index); Containers::ArrayView meleeWeapons(); void getMeleeWeapons(); @@ -128,25 +128,25 @@ class Mass { Containers::ArrayView globalStyles(); void getGlobalStyles(); - bool writeGlobalStyle(UnsignedLong index); + bool writeGlobalStyle(std::size_t index); void getTuning(); - Int& engine(); - Containers::ArrayView gears(); + std::int32_t& engine(); + Containers::ArrayView gears(); - Int& os(); - Containers::ArrayView modules(); + std::int32_t& os(); + Containers::ArrayView modules(); - Int& architecture(); - Containers::ArrayView techs(); + std::int32_t& architecture(); + Containers::ArrayView techs(); Containers::StringView account(); bool updateAccount(Containers::StringView new_account); private: void getCustomStyles(Containers::ArrayView styles, ArrayProperty* style_array); - bool writeCustomStyle(const CustomStyle& style, UnsignedLong index, ArrayProperty* style_array); + bool writeCustomStyle(const CustomStyle& style, std::size_t index, ArrayProperty* style_array); void getDecals(Containers::ArrayView decals, ArrayProperty* decal_array); void writeDecals(Containers::ArrayView decals, ArrayProperty* decal_array); @@ -157,8 +157,9 @@ class Mass { void getWeaponType(Containers::StringView prop_name, Containers::ArrayView weapon_array); 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); + void getTuningCategory(Containers::StringView big_node_prop_name, std::int32_t& big_node_id, + Containers::StringView small_nodes_prop_name, + Containers::ArrayView small_nodes_ids); Containers::Optional _mass; @@ -174,7 +175,7 @@ class Mass { struct { Joints joints{}; - Containers::StaticArray<4, Int> styles{ValueInit}; + Containers::StaticArray<4, std::int32_t> styles{ValueInit}; Color4 eyeFlare{0.0f}; Containers::StaticArray<16, CustomStyle> customStyles; } _frame; @@ -198,14 +199,14 @@ class Mass { Containers::Array _globalStyles; struct { - Int engineId; - Containers::StaticArray<7, Int> gearIds; + std::int32_t engineId; + Containers::StaticArray<7, std::int32_t> gearIds; - Int osId; - Containers::StaticArray<7, Int> moduleIds; + std::int32_t osId; + Containers::StaticArray<7, std::int32_t> moduleIds; - Int archId; - Containers::StaticArray<7, Int> techIds; + std::int32_t archId; + Containers::StaticArray<7, std::int32_t> techIds; } _tuning; Containers::String _account; diff --git a/src/Mass/Mass_Armour.cpp b/src/Mass/Mass_Armour.cpp index 4a656c6..5450319 100644 --- a/src/Mass/Mass_Armour.cpp +++ b/src/Mass/Mass_Armour.cpp @@ -59,7 +59,7 @@ Mass::getArmourParts() { return; } - for(UnsignedInt i = 0; i < armour_array->items.size(); i++) { + for(std::uint32_t i = 0; i < armour_array->items.size(); i++) { auto part_prop = armour_array->at(i); auto& part = _armour.parts[i]; @@ -89,7 +89,7 @@ Mass::getArmourParts() { return; } - for(UnsignedInt j = 0; j < part_styles->items.size(); j++) { + for(std::uint32_t j = 0; j < part_styles->items.size(); j++) { part.styles[j] = part_styles->at(j)->value; } @@ -152,7 +152,7 @@ Mass::writeArmourPart(ArmourSlot slot) { GenericStructProperty* part_prop = nullptr; - for(UnsignedInt i = 0; i < armour_array->items.size(); i++) { + for(std::uint32_t i = 0; i < armour_array->items.size(); i++) { part_prop = armour_array->at(i); if(slot_str == part_prop->at(MASS_ARMOUR_SLOT)->enumValue) { break; @@ -178,7 +178,7 @@ Mass::writeArmourPart(ArmourSlot slot) { part_prop->at(MASS_ARMOUR_ID)->value = part.id; auto part_styles = part_prop->at(MASS_ARMOUR_STYLES); - for(UnsignedInt i = 0; i < part.styles.size(); i++) { + for(std::uint32_t i = 0; i < part.styles.size(); i++) { part_styles->at(i)->value = part.styles[i]; } @@ -238,7 +238,7 @@ Mass::getBulletLauncherAttachments() { if(attach_array->items.size() == _weapons.bulletLaunchers.size() && attach_array->items.size() == _armour.blAttachment.size()) { - for(UnsignedInt i = 0; i < attach_array->items.size(); i++) { + for(std::uint32_t i = 0; i < attach_array->items.size(); i++) { auto attachment_prop = attach_array->at(i); auto& attachment = _armour.blAttachment[i]; @@ -313,7 +313,7 @@ Mass::writeBulletLauncherAttachments() { if(attach_array->items.size() == _weapons.bulletLaunchers.size() && attach_array->items.size() == _armour.blAttachment.size()) { - for(UnsignedInt i = 0; i < attach_array->items.size(); i++) { + for(std::uint32_t i = 0; i < attach_array->items.size(); i++) { auto attachment_prop = attach_array->at(i); auto& attachment = _armour.blAttachment[i]; @@ -414,7 +414,7 @@ Mass::getArmourCustomStyles() { } bool -Mass::writeArmourCustomStyle(UnsignedLong index) { +Mass::writeArmourCustomStyle(std::size_t 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 7b28d25..dfb8d00 100644 --- a/src/Mass/Mass_DecalsAccessories.cpp +++ b/src/Mass/Mass_DecalsAccessories.cpp @@ -31,7 +31,7 @@ using namespace Containers::Literals; void Mass::getDecals(Containers::ArrayView decals, ArrayProperty* decal_array) { - for(UnsignedInt i = 0; i < decal_array->items.size(); i++) { + for(std::uint32_t i = 0; i < decal_array->items.size(); i++) { auto decal_prop = decal_array->at(i); CORRADE_INTERNAL_ASSERT(decal_prop); auto& decal = decals[i]; @@ -56,7 +56,7 @@ Mass::getDecals(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++) { + for(std::uint32_t i = 0; i < decal_array->items.size(); i++) { auto decal_prop = decal_array->at(i); CORRADE_INTERNAL_ASSERT(decal_prop); auto& decal = decals[i]; @@ -91,7 +91,7 @@ Mass::writeDecals(Containers::ArrayView decals, ArrayProperty* decal_arra void Mass::getAccessories(Containers::ArrayView accessories, ArrayProperty* accessory_array) { - for(UnsignedInt i = 0; i < accessory_array->items.size(); i++) { + for(std::uint32_t i = 0; i < accessory_array->items.size(); i++) { auto acc_prop = accessory_array->at(i); CORRADE_INTERNAL_ASSERT(acc_prop); auto& accessory = accessories[i]; @@ -99,7 +99,7 @@ Mass::getAccessories(Containers::ArrayView accessories, ArrayProperty accessory.attachIndex = acc_prop->at(MASS_ACCESSORY_ATTACH_INDEX)->value; accessory.id = acc_prop->at(MASS_ACCESSORY_ID)->value; auto acc_styles = acc_prop->at(MASS_ACCESSORY_STYLES); - for(UnsignedInt j = 0; j < acc_styles->items.size(); j++) { + for(std::uint32_t j = 0; j < acc_styles->items.size(); j++) { accessory.styles[j] = acc_styles->at(j)->value; } auto rel_pos_prop = acc_prop->at(MASS_ACCESSORY_RELPOS); @@ -117,7 +117,7 @@ Mass::getAccessories(Containers::ArrayView accessories, ArrayProperty void Mass::writeAccessories(Containers::ArrayView accessories, ArrayProperty* accs_array) { - for(UnsignedInt i = 0; i < accs_array->items.size(); i++) { + for(std::uint32_t i = 0; i < accs_array->items.size(); i++) { auto acc_prop = accs_array->at(i); CORRADE_INTERNAL_ASSERT(acc_prop); auto& accessory = accessories[i]; @@ -125,7 +125,7 @@ Mass::writeAccessories(Containers::ArrayView accessories, ArrayProper acc_prop->at(MASS_ACCESSORY_ATTACH_INDEX)->value = accessory.attachIndex; acc_prop->at(MASS_ACCESSORY_ID)->value = accessory.id; auto acc_styles = acc_prop->at(MASS_ACCESSORY_STYLES); - for(UnsignedInt j = 0; j < acc_styles->items.size(); j++) { + for(std::uint32_t j = 0; j < acc_styles->items.size(); j++) { acc_styles->at(j)->value = accessory.styles[j]; } auto rel_pos_prop = acc_prop->at(MASS_ACCESSORY_RELPOS); diff --git a/src/Mass/Mass_Frame.cpp b/src/Mass/Mass_Frame.cpp index 77721d7..02f3546 100644 --- a/src/Mass/Mass_Frame.cpp +++ b/src/Mass/Mass_Frame.cpp @@ -184,7 +184,7 @@ Mass::writeJointSliders() { return true; } -Containers::ArrayView +Containers::ArrayView Mass::frameStyles() { return _frame.styles; } @@ -221,7 +221,7 @@ Mass::getFrameStyles() { return; } - for(UnsignedInt i = 0; i < frame_styles->items.size(); i++) { + for(std::uint32_t i = 0; i < frame_styles->items.size(); i++) { _frame.styles[i] = frame_styles->at(i)->value; } } @@ -254,7 +254,7 @@ Mass::writeFrameStyles() { return false; } - for(UnsignedInt i = 0; i < frame_styles->items.size(); i++) { + for(std::uint32_t i = 0; i < frame_styles->items.size(); i++) { frame_styles->at(i)->value = _frame.styles[i]; } @@ -374,7 +374,7 @@ Mass::getFrameCustomStyles() { } bool -Mass::writeFrameCustomStyle(UnsignedLong index) { +Mass::writeFrameCustomStyle(std::size_t 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 a5181ef..6aeaaf1 100644 --- a/src/Mass/Mass_Styles.cpp +++ b/src/Mass/Mass_Styles.cpp @@ -58,7 +58,7 @@ Mass::getGlobalStyles() { } bool -Mass::writeGlobalStyle(UnsignedLong index) { +Mass::writeGlobalStyle(std::size_t index) { LOG_INFO_FORMAT("Writing global style number {}.", index); if(index > _globalStyles.size()) { @@ -88,7 +88,7 @@ Mass::writeGlobalStyle(UnsignedLong index) { void Mass::getCustomStyles(Containers::ArrayView styles, ArrayProperty* style_array) { - for(UnsignedInt i = 0; i < style_array->items.size(); i++) { + for(std::uint32_t i = 0; i < style_array->items.size(); i++) { auto style_prop = style_array->at(i); auto& style = styles[i]; @@ -111,7 +111,7 @@ Mass::getCustomStyles(Containers::ArrayView styles, ArrayProperty* } bool -Mass::writeCustomStyle(const CustomStyle& style, UnsignedLong index, ArrayProperty* style_array) { +Mass::writeCustomStyle(const CustomStyle& style, std::size_t 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 a9ea9fe..ae64965 100644 --- a/src/Mass/Mass_Weapons.cpp +++ b/src/Mass/Mass_Weapons.cpp @@ -153,7 +153,7 @@ Mass::getWeaponType(Containers::StringView prop_name, Containers::ArrayViewat(i); auto& weapon = weapon_array[i]; @@ -171,14 +171,14 @@ Mass::getWeaponType(Containers::StringView prop_name, Containers::ArrayViewat(MASS_WEAPON_ELEMENT); weapon.parts = Containers::Array{ValueInit, parts_prop->items.size()}; - for(UnsignedInt j = 0; j < parts_prop->items.size(); j++) { + for(std::uint32_t j = 0; j < parts_prop->items.size(); j++) { auto part_prop = parts_prop->at(j); auto& part = weapon.parts[j]; part.id = part_prop->at(MASS_WEAPON_PART_ID)->value; auto part_styles = part_prop->at(MASS_WEAPON_PART_STYLES); - for(UnsignedInt k = 0; k < part_styles->items.size(); k++) { + for(std::uint32_t k = 0; k < part_styles->items.size(); k++) { part.styles[k] = part_styles->at(k)->value; } @@ -268,7 +268,7 @@ Mass::writeWeaponType(Containers::StringView prop_name, Containers::ArrayViewat(i); auto& weapon = weapon_array[i]; @@ -292,14 +292,14 @@ Mass::writeWeaponType(Containers::StringView prop_name, Containers::ArrayViewitems.size(); j++) { + for(std::uint32_t j = 0; j < parts_prop->items.size(); j++) { auto part_prop = parts_prop->at(j); auto& part = weapon.parts[j]; part_prop->at(MASS_WEAPON_PART_ID)->value = part.id; auto part_styles = part_prop->at(MASS_WEAPON_PART_STYLES); - for(UnsignedInt k = 0; k < part_styles->items.size(); k++) { + for(std::uint32_t k = 0; k < part_styles->items.size(); k++) { part_styles->at(k)->value = part.styles[k]; } @@ -338,7 +338,7 @@ Mass::writeWeaponType(Containers::StringView prop_name, Containers::ArrayView{other.parts.size()}; - for(UnsignedInt i = 0; i < parts.size(); i++) { + for(std::uint32_t i = 0; i < parts.size(); i++) { parts[i] = other.parts[i]; } customStyles = other.customStyles; @@ -35,7 +35,7 @@ Weapon& Weapon::operator=(const Weapon& other) { name = other.name; type = other.type; parts = Containers::Array{other.parts.size()}; - for(UnsignedInt i = 0; i < parts.size(); i++) { + for(std::uint32_t i = 0; i < parts.size(); i++) { parts[i] = other.parts[i]; } customStyles = other.customStyles; diff --git a/src/Mass/WeaponPart.h b/src/Mass/WeaponPart.h index 227b5af..406e23b 100644 --- a/src/Mass/WeaponPart.h +++ b/src/Mass/WeaponPart.h @@ -19,13 +19,10 @@ #include #include -#include - #include "Decal.h" #include "Accessory.h" using namespace Corrade; -using namespace Magnum; struct WeaponPart { WeaponPart() = default; @@ -34,11 +31,11 @@ struct WeaponPart { id = other.id; styles = other.styles; decals = Containers::Array{other.decals.size()}; - for(UnsignedInt i = 0; i < decals.size(); i++) { + for(auto i = 0u; i < decals.size(); i++) { decals[i] = other.decals[i]; } accessories = Containers::Array{other.accessories.size()}; - for(UnsignedInt i = 0; i < accessories.size(); i++) { + for(auto i = 0u; i < accessories.size(); i++) { accessories[i] = other.accessories[i]; } } @@ -46,11 +43,11 @@ struct WeaponPart { id = other.id; styles = other.styles; decals = Containers::Array{other.decals.size()}; - for(UnsignedInt i = 0; i < decals.size(); i++) { + for(auto i = 0u; i < decals.size(); i++) { decals[i] = other.decals[i]; } accessories = Containers::Array{other.accessories.size()}; - for(UnsignedInt i = 0; i < accessories.size(); i++) { + for(auto i = 0u; i < accessories.size(); i++) { accessories[i] = other.accessories[i]; } return *this; @@ -59,8 +56,8 @@ struct WeaponPart { WeaponPart(WeaponPart&& other) = default; WeaponPart& operator=(WeaponPart&& other) = default; - Int id = 0; - Containers::StaticArray<4, Int> styles{ValueInit}; + std::int32_t id = 0; + Containers::StaticArray<4, std::int32_t> styles{ValueInit}; Containers::Array decals{}; Containers::Array accessories{}; }; diff --git a/src/MassManager/MassManager.cpp b/src/MassManager/MassManager.cpp index 8bec3b5..0b94d6c 100644 --- a/src/MassManager/MassManager.cpp +++ b/src/MassManager/MassManager.cpp @@ -30,7 +30,7 @@ MassManager::MassManager(Containers::StringView save_path, Containers::StringVie _saveDirectory{save_path}, _account{account}, _demo{demo}, _stagingAreaDirectory{staging_dir} { Containers::String mass_filename = ""; - for(UnsignedInt i = 0; i < _hangars.size(); i++) { + for(std::uint32_t i = 0; i < _hangars.size(); i++) { mass_filename = Utility::Path::join(_saveDirectory, Utility::format("{}Unit{:.2d}{}.sav", demo ? "Demo"_s : ""_s, i, _account)); new(&_hangars[i]) Mass{mass_filename}; @@ -45,12 +45,12 @@ MassManager::lastError() { } Mass& -MassManager::hangar(Int hangar) { +MassManager::hangar(std::int32_t hangar) { return _hangars[hangar]; } void -MassManager::refreshHangar(Int hangar) { +MassManager::refreshHangar(std::int32_t hangar) { if(hangar < 0 || hangar >= 32) { _lastError = "Hangar index out of range."; LOG_ERROR(_lastError); @@ -64,7 +64,7 @@ MassManager::refreshHangar(Int hangar) { } bool -MassManager::importMass(Containers::StringView staged_fn, Int hangar) { +MassManager::importMass(Containers::StringView staged_fn, std::int32_t hangar) { if(hangar < 0 || hangar >= 32) { _lastError = "Hangar index out of range."; LOG_ERROR(_lastError); @@ -107,7 +107,7 @@ MassManager::importMass(Containers::StringView staged_fn, Int hangar) { } bool -MassManager::exportMass(Int hangar) { +MassManager::exportMass(std::int32_t hangar) { if(hangar < 0 || hangar >= 32) { _lastError = "Hangar index out of range."_s; LOG_ERROR(_lastError); @@ -134,7 +134,7 @@ MassManager::exportMass(Int hangar) { } bool -MassManager::moveMass(Int source, Int destination) { +MassManager::moveMass(std::int32_t source, std::int32_t destination) { if(source < 0 || source >= 32) { _lastError = "Source hangar index out of range."_s; LOG_ERROR(_lastError); @@ -172,7 +172,7 @@ MassManager::moveMass(Int source, Int destination) { } bool -MassManager::deleteMass(Int hangar) { +MassManager::deleteMass(std::int32_t hangar) { if(hangar < 0 || hangar >= 32) { _lastError = "Hangar index out of range."_s; LOG_ERROR(_lastError); diff --git a/src/Profile/Profile.cpp b/src/Profile/Profile.cpp index b14baff..5bd3428 100644 --- a/src/Profile/Profile.cpp +++ b/src/Profile/Profile.cpp @@ -189,24 +189,24 @@ Profile::renameCompany(Containers::StringView new_name) { return true; } -Int +std::int32_t Profile::activeFrameSlot() const { return _activeFrameSlot; } -Int +std::int32_t Profile::credits() const { return _credits; } bool -Profile::setCredits(Int amount) { +Profile::setCredits(std::int32_t amount) { auto credits_prop = _profile.at(PROFILE_CREDITS); if(!credits_prop) { credits_prop = new IntProperty; credits_prop->name.emplace("Credit"_s); - credits_prop->valueLength = sizeof(Int); + credits_prop->valueLength = sizeof(std::int32_t); _profile.appendProperty(IntProperty::ptr{credits_prop}); } @@ -220,19 +220,19 @@ Profile::setCredits(Int amount) { return true; } -Int +std::int32_t Profile::storyProgress() const { return _storyProgress; } bool -Profile::setStoryProgress(Int progress) { +Profile::setStoryProgress(std::int32_t progress) { auto story_progress_prop = _profile.at("StoryProgress"_s); if(!story_progress_prop) { story_progress_prop = new IntProperty; story_progress_prop->name.emplace("StoryProgress"_s); - story_progress_prop->valueLength = sizeof(Int); + story_progress_prop->valueLength = sizeof(std::int32_t); _profile.appendProperty(IntProperty::ptr{story_progress_prop}); } @@ -246,252 +246,252 @@ Profile::setStoryProgress(Int progress) { return true; } -Int +std::int32_t Profile::lastMissionId() const { return _lastMissionId; } -Int +std::int32_t Profile::verseSteel() const { return _verseSteel; } bool -Profile::setVerseSteel(Int amount) { +Profile::setVerseSteel(std::int32_t amount) { return setResource(PROFILE_MATERIAL, VerseSteel, amount); } -Int +std::int32_t Profile::undinium() const { return _undinium; } bool -Profile::setUndinium(Int amount) { +Profile::setUndinium(std::int32_t amount) { return setResource(PROFILE_MATERIAL, Undinium, amount); } -Int +std::int32_t Profile::necriumAlloy() const { return _necriumAlloy; } bool -Profile::setNecriumAlloy(Int amount) { +Profile::setNecriumAlloy(std::int32_t amount) { return setResource(PROFILE_MATERIAL, NecriumAlloy, amount); } -Int +std::int32_t Profile::lunarite() const { return _lunarite; } bool -Profile::setLunarite(Int amount) { +Profile::setLunarite(std::int32_t amount) { return setResource(PROFILE_MATERIAL, Lunarite, amount); } -Int +std::int32_t Profile::asterite() const { return _asterite; } bool -Profile::setAsterite(Int amount) { +Profile::setAsterite(std::int32_t amount) { return setResource(PROFILE_MATERIAL, Asterite, amount); } -Int +std::int32_t Profile::halliteFragma() const { return _halliteFragma; } bool -Profile::setHalliteFragma(Int amount) { +Profile::setHalliteFragma(std::int32_t amount) { return setResource(PROFILE_MATERIAL, HalliteFragma, amount); } -Int +std::int32_t Profile::ednil() const { return _ednil; } bool -Profile::setEdnil(Int amount) { +Profile::setEdnil(std::int32_t amount) { return setResource(PROFILE_MATERIAL, Ednil, amount); } -Int +std::int32_t Profile::nuflalt() const { return _nuflalt; } bool -Profile::setNuflalt(Int amount) { +Profile::setNuflalt(std::int32_t amount) { return setResource(PROFILE_MATERIAL, Nuflalt, amount); } -Int +std::int32_t Profile::aurelene() const { return _aurelene; } bool -Profile::setAurelene(Int amount) { +Profile::setAurelene(std::int32_t amount) { return setResource(PROFILE_MATERIAL, Aurelene, amount); } -Int +std::int32_t Profile::soldus() const { return _soldus; } bool -Profile::setSoldus(Int amount) { +Profile::setSoldus(std::int32_t amount) { return setResource(PROFILE_MATERIAL, Soldus, amount); } -Int +std::int32_t Profile::synthesisedN() const { return _synthesisedN; } bool -Profile::setSynthesisedN(Int amount) { +Profile::setSynthesisedN(std::int32_t amount) { return setResource(PROFILE_MATERIAL, SynthesisedN, amount); } -Int +std::int32_t Profile::nanoc() const { return _nanoc; } bool -Profile::setNanoc(Int amount) { +Profile::setNanoc(std::int32_t amount) { return setResource(PROFILE_MATERIAL, Nanoc, amount); } -Int +std::int32_t Profile::alcarbonite() const { return _alcarbonite; } bool -Profile::setAlcarbonite(Int amount) { +Profile::setAlcarbonite(std::int32_t amount) { return setResource(PROFILE_MATERIAL, Alcarbonite, amount); } -Int +std::int32_t Profile::keriphene() const { return _keriphene; } bool -Profile::setKeriphene(Int amount) { +Profile::setKeriphene(std::int32_t amount) { return setResource(PROFILE_MATERIAL, Keriphene, amount); } -Int +std::int32_t Profile::nitinolCM() const { return _nitinolCM; } bool -Profile::setNitinolCM(Int amount) { +Profile::setNitinolCM(std::int32_t amount) { return setResource(PROFILE_MATERIAL, NitinolCM, amount); } -Int +std::int32_t Profile::quarkium() const { return _quarkium; } bool -Profile::setQuarkium(Int amount) { +Profile::setQuarkium(std::int32_t amount) { return setResource(PROFILE_MATERIAL, Quarkium, amount); } -Int +std::int32_t Profile::alterene() const { return _alterene; } bool -Profile::setAlterene(Int amount) { +Profile::setAlterene(std::int32_t amount) { return setResource(PROFILE_MATERIAL, Alterene, amount); } -Int +std::int32_t Profile::cosmium() const { return _cosmium; } bool -Profile::setCosmium(Int amount) { +Profile::setCosmium(std::int32_t amount) { return setResource(PROFILE_MATERIAL, Cosmium, amount); } -Int +std::int32_t Profile::mixedComposition() const { return _mixedComposition; } bool -Profile::setMixedComposition(Int amount) { +Profile::setMixedComposition(std::int32_t amount) { return setResource(PROFILE_QUARK_DATA, MixedComposition, amount); } -Int +std::int32_t Profile::voidResidue() const { return _voidResidue; } bool -Profile::setVoidResidue(Int amount) { +Profile::setVoidResidue(std::int32_t amount) { return setResource(PROFILE_QUARK_DATA, VoidResidue, amount); } -Int +std::int32_t Profile::muscularConstruction() const { return _muscularConstruction; } bool -Profile::setMuscularConstruction(Int amount) { +Profile::setMuscularConstruction(std::int32_t amount) { return setResource(PROFILE_QUARK_DATA, MuscularConstruction, amount); } -Int +std::int32_t Profile::mineralExoskeletology() const { return _mineralExoskeletology; } bool -Profile::setMineralExoskeletology(Int amount) { +Profile::setMineralExoskeletology(std::int32_t amount) { return setResource(PROFILE_QUARK_DATA, MineralExoskeletology, amount); } -Int +std::int32_t Profile::carbonisedSkin() const { return _carbonisedSkin; } bool -Profile::setCarbonisedSkin(Int amount) { +Profile::setCarbonisedSkin(std::int32_t amount) { return setResource(PROFILE_QUARK_DATA, CarbonisedSkin, amount); } -Int +std::int32_t Profile::isolatedVoidParticle() const { return _isolatedVoidParticle; } bool -Profile::setIsolatedVoidParticle(Int amount) { +Profile::setIsolatedVoidParticle(std::int32_t amount) { return setResource(PROFILE_QUARK_DATA, IsolatedVoidParticle, amount); } -Int +std::int32_t Profile::getResource(Containers::StringView container, MaterialID id) { auto mats_prop = _profile.at(container); @@ -509,7 +509,7 @@ Profile::getResource(Containers::StringView container, MaterialID id) { } bool -Profile::setResource(Containers::StringView container, MaterialID id, Int amount) { +Profile::setResource(Containers::StringView container, MaterialID id, std::int32_t amount) { auto mats_prop = _profile.at(container); if(!mats_prop) { diff --git a/src/Profile/Profile.h b/src/Profile/Profile.h index e861160..2539de9 100644 --- a/src/Profile/Profile.h +++ b/src/Profile/Profile.h @@ -19,16 +19,13 @@ #include #include -#include - #include "../UESaveFile/UESaveFile.h" #include "ResourceIDs.h" using namespace Corrade; -using namespace Magnum; -enum class ProfileType : UnsignedByte { +enum class ProfileType: std::uint8_t { Demo, FullGame }; @@ -37,14 +34,14 @@ class Profile { public: explicit Profile(Containers::StringView path); - auto valid() const -> bool; + bool valid() const; auto lastError() const -> Containers::StringView; auto filename() const -> Containers::StringView; - auto type() const -> ProfileType; - auto isDemo() const -> bool; + ProfileType type() const; + bool isDemo() const; auto account() const -> Containers::StringView; @@ -53,91 +50,91 @@ class Profile { auto companyName() const -> Containers::StringView; bool renameCompany(Containers::StringView new_name); - auto activeFrameSlot() const -> Int; + std::int32_t activeFrameSlot() const; - auto credits() const -> Int; - bool setCredits(Int credits); + std::int32_t credits() const; + bool setCredits(std::int32_t credits); - auto storyProgress() const -> Int; - bool setStoryProgress(Int progress); + std::int32_t storyProgress() const; + bool setStoryProgress(std::int32_t progress); - auto lastMissionId() const -> Int; + std::int32_t lastMissionId() const; - auto verseSteel() const -> Int; - bool setVerseSteel(Int amount); + std::int32_t verseSteel() const; + bool setVerseSteel(std::int32_t amount); - auto undinium() const -> Int; - bool setUndinium(Int amount); + std::int32_t undinium() const; + bool setUndinium(std::int32_t amount); - auto necriumAlloy() const -> Int; - bool setNecriumAlloy(Int amount); + std::int32_t necriumAlloy() const; + bool setNecriumAlloy(std::int32_t amount); - auto lunarite() const -> Int; - bool setLunarite(Int amount); + std::int32_t lunarite() const; + bool setLunarite(std::int32_t amount); - auto asterite() const -> Int; - bool setAsterite(Int amount); + std::int32_t asterite() const; + bool setAsterite(std::int32_t amount); - Int halliteFragma() const; - bool setHalliteFragma(Int amount); + std::int32_t halliteFragma() const; + bool setHalliteFragma(std::int32_t amount); - auto ednil() const -> Int; - bool setEdnil(Int amount); + std::int32_t ednil() const; + bool setEdnil(std::int32_t amount); - auto nuflalt() const -> Int; - bool setNuflalt(Int amount); + std::int32_t nuflalt() const; + bool setNuflalt(std::int32_t amount); - auto aurelene() const -> Int; - bool setAurelene(Int amount); + std::int32_t aurelene() const; + bool setAurelene(std::int32_t amount); - auto soldus() const -> Int; - bool setSoldus(Int amount); + std::int32_t soldus() const; + bool setSoldus(std::int32_t amount); - auto synthesisedN() const -> Int; - bool setSynthesisedN(Int amount); + std::int32_t synthesisedN() const; + bool setSynthesisedN(std::int32_t amount); - Int nanoc() const; - bool setNanoc(Int amount); + std::int32_t nanoc() const; + bool setNanoc(std::int32_t amount); - auto alcarbonite() const -> Int; - bool setAlcarbonite(Int amount); + std::int32_t alcarbonite() const; + bool setAlcarbonite(std::int32_t amount); - auto keriphene() const -> Int; - bool setKeriphene(Int amount); + std::int32_t keriphene() const; + bool setKeriphene(std::int32_t amount); - auto nitinolCM() const -> Int; - bool setNitinolCM(Int amount); + std::int32_t nitinolCM() const; + bool setNitinolCM(std::int32_t amount); - auto quarkium() const -> Int; - bool setQuarkium(Int amount); + std::int32_t quarkium() const; + bool setQuarkium(std::int32_t amount); - auto alterene() const -> Int; - bool setAlterene(Int amount); + std::int32_t alterene() const; + bool setAlterene(std::int32_t amount); - Int cosmium() const; - bool setCosmium(Int amount); + std::int32_t cosmium() const; + bool setCosmium(std::int32_t amount); - auto mixedComposition() const -> Int; - bool setMixedComposition(Int amount); + std::int32_t mixedComposition() const; + bool setMixedComposition(std::int32_t amount); - auto voidResidue() const -> Int; - bool setVoidResidue(Int amount); + std::int32_t voidResidue() const; + bool setVoidResidue(std::int32_t amount); - auto muscularConstruction() const -> Int; - bool setMuscularConstruction(Int amount); + std::int32_t muscularConstruction() const; + bool setMuscularConstruction(std::int32_t amount); - auto mineralExoskeletology() const -> Int; - bool setMineralExoskeletology(Int amount); + std::int32_t mineralExoskeletology() const; + bool setMineralExoskeletology(std::int32_t amount); - auto carbonisedSkin() const -> Int; - bool setCarbonisedSkin(Int amount); + std::int32_t carbonisedSkin() const; + bool setCarbonisedSkin(std::int32_t amount); - Int isolatedVoidParticle() const; - bool setIsolatedVoidParticle(Int amount); + std::int32_t isolatedVoidParticle() const; + bool setIsolatedVoidParticle(std::int32_t amount); private: - Int getResource(Containers::StringView container, MaterialID id); - bool setResource(Containers::StringView container, MaterialID id, Int amount); + std::int32_t getResource(Containers::StringView container, MaterialID id); + bool setResource(Containers::StringView container, MaterialID id, std::int32_t amount); Containers::String _filename; @@ -146,38 +143,38 @@ class Profile { UESaveFile _profile; Containers::String _name; - Int _activeFrameSlot = 0; - Int _credits = 0; - Int _storyProgress = 0; - Int _lastMissionId = 0; + std::int32_t _activeFrameSlot = 0; + std::int32_t _credits = 0; + std::int32_t _storyProgress = 0; + std::int32_t _lastMissionId = 0; - Int _verseSteel = 0; - Int _undinium = 0; - Int _necriumAlloy = 0; - Int _lunarite = 0; - Int _asterite = 0; - Int _halliteFragma = 0; + std::int32_t _verseSteel = 0; + std::int32_t _undinium = 0; + std::int32_t _necriumAlloy = 0; + std::int32_t _lunarite = 0; + std::int32_t _asterite = 0; + std::int32_t _halliteFragma = 0; - Int _ednil = 0; - Int _nuflalt = 0; - Int _aurelene = 0; - Int _soldus = 0; - Int _synthesisedN = 0; - Int _nanoc = 0; + std::int32_t _ednil = 0; + std::int32_t _nuflalt = 0; + std::int32_t _aurelene = 0; + std::int32_t _soldus = 0; + std::int32_t _synthesisedN = 0; + std::int32_t _nanoc = 0; - Int _alcarbonite = 0; - Int _keriphene = 0; - Int _nitinolCM = 0; - Int _quarkium = 0; - Int _alterene = 0; - Int _cosmium = 0; + std::int32_t _alcarbonite = 0; + std::int32_t _keriphene = 0; + std::int32_t _nitinolCM = 0; + std::int32_t _quarkium = 0; + std::int32_t _alterene = 0; + std::int32_t _cosmium = 0; - Int _mixedComposition = 0; - Int _voidResidue = 0; - Int _muscularConstruction = 0; - Int _mineralExoskeletology = 0; - Int _carbonisedSkin = 0; - Int _isolatedVoidParticle = 0; + std::int32_t _mixedComposition = 0; + std::int32_t _voidResidue = 0; + std::int32_t _muscularConstruction = 0; + std::int32_t _mineralExoskeletology = 0; + std::int32_t _carbonisedSkin = 0; + std::int32_t _isolatedVoidParticle = 0; Containers::String _account; diff --git a/src/Profile/ResourceIDs.h b/src/Profile/ResourceIDs.h index 3b03d11..fdaf506 100644 --- a/src/Profile/ResourceIDs.h +++ b/src/Profile/ResourceIDs.h @@ -16,11 +16,7 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -#include - -using namespace Magnum; - -enum MaterialID : Int { +enum MaterialID : std::int32_t { VerseSteel = 0xC3500, Undinium = 0xC3501, NecriumAlloy = 0xC3502, diff --git a/src/ProfileManager/ProfileManager.cpp b/src/ProfileManager/ProfileManager.cpp index b6972ac..622b066 100644 --- a/src/ProfileManager/ProfileManager.cpp +++ b/src/ProfileManager/ProfileManager.cpp @@ -114,7 +114,7 @@ ProfileManager::deleteProfile(std::size_t index, bool delete_builds) { } if(delete_builds) { - for(UnsignedByte i = 0; i < 32; ++i) { + for(std::uint8_t i = 0; i < 32; ++i) { auto filename = Utility::format("{}Unit{:.2d}{}.sav", _profiles[index].type() == ProfileType::Demo ? "Demo": "", i, _profiles[index].account()); @@ -176,7 +176,7 @@ ProfileManager::backupProfile(std::size_t index, bool backup_builds) { zip_set_archive_comment(zip, comment.data(), comment.size()); if(backup_builds) { - for(UnsignedByte i = 0; i < 32; ++i) { + for(std::uint8_t i = 0; i < 32; ++i) { auto build_filename = Utility::format("{}Unit{:.2d}{}.sav", profile.isDemo() ? "Demo"_s : ""_s, i, profile.account()); @@ -247,7 +247,7 @@ ProfileManager::refreshBackups() { Containers::ScopeGuard guard{zip, zip_close}; - Long num_entries = zip_get_num_entries(zip, ZIP_FL_UNCHANGED); + auto num_entries = zip_get_num_entries(zip, ZIP_FL_UNCHANGED); if(num_entries == 0) { continue; @@ -291,7 +291,7 @@ ProfileManager::refreshBackups() { arrayReserve(backup.includedFiles, num_entries); - for(Long i = 0; i < num_entries; i++) { + for(auto i = 0; i < num_entries; i++) { arrayAppend(backup.includedFiles, InPlaceInit, zip_get_name(zip, i, ZIP_FL_UNCHANGED)); } @@ -358,7 +358,7 @@ ProfileManager::restoreBackup(std::size_t index) { Containers::StaticArray<8192, char> buf{ValueInit}; - Long bytes_read = 0; + auto bytes_read = 0l; while((bytes_read = zip_fread(zf, buf.data(), buf.size())) > 0) { if(std::fwrite(buf.data(), sizeof(char), bytes_read, out) < static_cast(bytes_read)) { _lastError = Utility::format(error_format.data(), file, "not enough bytes written."); diff --git a/src/ProfileManager/ProfileManager.h b/src/ProfileManager/ProfileManager.h index 56c5e0a..a7b8212 100644 --- a/src/ProfileManager/ProfileManager.h +++ b/src/ProfileManager/ProfileManager.h @@ -16,6 +16,8 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . +#include + #include #include @@ -30,12 +32,12 @@ struct Backup { Containers::String company; ProfileType type; struct { - int year; - int month; - int day; - int hour; - int minute; - int second; + std::int32_t year; + std::int32_t month; + std::int32_t day; + std::int32_t hour; + std::int32_t minute; + std::int32_t second; } timestamp; Containers::Array includedFiles; }; diff --git a/src/SaveTool/SaveTool.cpp b/src/SaveTool/SaveTool.cpp index 922e5e3..8ba92ee 100644 --- a/src/SaveTool/SaveTool.cpp +++ b/src/SaveTool/SaveTool.cpp @@ -58,8 +58,6 @@ SaveTool::SaveTool(const Arguments& arguments): LOG_INFO("Configuring OpenGL renderer."); GL::Renderer::enable(GL::Renderer::Feature::Blending); GL::Renderer::enable(GL::Renderer::Feature::ScissorTest); - GL::Renderer::disable(GL::Renderer::Feature::FaceCulling); - GL::Renderer::disable(GL::Renderer::Feature::DepthTest); GL::Renderer::setBlendFunction(GL::Renderer::BlendFunction::SourceAlpha, GL::Renderer::BlendFunction::OneMinusSourceAlpha); GL::Renderer::setBlendEquation(GL::Renderer::BlendEquation::Add, @@ -79,7 +77,7 @@ SaveTool::SaveTool(const Arguments& arguments): #endif LOG_INFO("Registering custom events."); - if((_initEventId = SDL_RegisterEvents(3)) == UnsignedInt(-1)) { + if((_initEventId = SDL_RegisterEvents(3)) == std::uint32_t(-1)) { SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error", "SDL_RegisterEvents() failed in SaveTool::SaveTool(). Exiting...", window()); exit(EXIT_FAILURE); @@ -116,7 +114,7 @@ SaveTool::SaveTool(const Arguments& arguments): checkGameState(); _gameCheckTimerId = SDL_AddTimer(2000, - [](UnsignedInt interval, void* param)->UnsignedInt{ + [](std::uint32_t interval, void* param)->std::uint32_t{ static_cast(param)->checkGameState(); return interval; }, this); @@ -405,13 +403,13 @@ SaveTool::drawGameState() { } void -SaveTool::drawHelpMarker(Containers::StringView text, Float wrap_pos) { +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) { +SaveTool::drawTooltip(Containers::StringView text, float wrap_pos) { if(ImGui::IsItemHovered()){ ImGui::BeginTooltip(); if(wrap_pos > 0.0f) { diff --git a/src/SaveTool/SaveTool.h b/src/SaveTool/SaveTool.h index 2685921..df4ee27 100644 --- a/src/SaveTool/SaveTool.h +++ b/src/SaveTool/SaveTool.h @@ -77,20 +77,20 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener void anyEvent(SDL_Event& event) override; - enum InitStatus: Int { + enum InitStatus: std::int32_t { InitSuccess, ProfileManagerFailure }; void initEvent(SDL_Event& event); - enum UpdateCheckStatus : Int { + enum UpdateCheckStatus : std::int32_t { CurlInitFailed = 0, CurlError = 1, CurlTimeout = 2, }; void updateCheckEvent(SDL_Event& event); - enum FileEventType: Int { + enum FileEventType: std::int32_t { FileAdded = efsw::Action::Add, FileDeleted = efsw::Action::Delete, FileModified = efsw::Action::Modified, @@ -126,8 +126,8 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener void drawGeneralInfo(); void drawResearchInventory(); template - void drawMaterialRow(Containers::StringView name, Int tier, Getter getter, Setter setter); - void drawUnavailableMaterialRow(Containers::StringView name, Int tier); + void drawMaterialRow(Containers::StringView name, std::int32_t tier, Getter getter, Setter setter); + void drawUnavailableMaterialRow(Containers::StringView name, std::int32_t tier); void drawMassManager(); ImGuiID drawDeleteMassPopup(int mass_index); ImGuiID drawDeleteStagedMassPopup(Containers::StringView filename); @@ -148,7 +148,7 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener void drawTuning(); void drawDecalEditor(Decal& decal); void drawAccessoryEditor(Accessory& accessory, Containers::ArrayView style_view); - Containers::StringView getStyleName(Int id, Containers::ArrayView view); + Containers::StringView getStyleName(std::int32_t id, Containers::ArrayView view); enum DCSResult { DCS_Fail, @@ -161,8 +161,8 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener void drawGameState(); // Convenience wrappers over ImGui stuff - void drawHelpMarker(Containers::StringView text, Float wrap_pos = 0.0f); - void drawTooltip(Containers::StringView text, Float wrap_pos = 0.0f); + void drawHelpMarker(Containers::StringView text, float wrap_pos = 0.0f); + void drawTooltip(Containers::StringView text, float wrap_pos = 0.0f); bool drawCheckbox(Containers::StringView label, bool value); template @@ -222,9 +222,9 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener std::thread _initThread; std::thread _updateThread; - UnsignedInt _initEventId; - UnsignedInt _updateEventId; - UnsignedInt _fileEventId; + std::uint32_t _initEventId; + std::uint32_t _updateEventId; + std::uint32_t _fileEventId; Containers::String _lastError; @@ -240,7 +240,7 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener //Containers::String _weaponsDir; //Containers::String _stylesDir; - enum class GameState : UnsignedByte { + enum class GameState : std::uint8_t { Unknown, NotRunning, Running } _gameState{GameState::Unknown}; @@ -270,12 +270,12 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener bool _jointsDirty{false}; bool _stylesDirty{false}; bool _eyeFlareDirty{false}; - Containers::StaticArray<38, Int> _selectedArmourDecals{ValueInit}; - Containers::StaticArray<38, Int> _selectedArmourAccessories{ValueInit}; - Int _selectedBLPlacement{0}; - Int _selectedWeaponPart{0}; - Int _selectedWeaponDecal{0}; - Int _selectedWeaponAccessory{0}; + Containers::StaticArray<38, std::int32_t> _selectedArmourDecals{ValueInit}; + Containers::StaticArray<38, std::int32_t> _selectedArmourAccessories{ValueInit}; + std::int32_t _selectedBLPlacement{0}; + std::int32_t _selectedWeaponPart{0}; + std::int32_t _selectedWeaponDecal{0}; + std::int32_t _selectedWeaponAccessory{0}; bool _meleeDirty{false}; bool _shieldsDirty{false}; bool _bShootersDirty{false}; diff --git a/src/SaveTool/SaveTool_FileWatcher.cpp b/src/SaveTool/SaveTool_FileWatcher.cpp index 37cbd02..d9325fa 100644 --- a/src/SaveTool/SaveTool_FileWatcher.cpp +++ b/src/SaveTool/SaveTool_FileWatcher.cpp @@ -73,8 +73,8 @@ SaveTool::fileUpdateEvent(SDL_Event& event) { Containers::String old_filename; - Int index = 0; - Int old_index = 0; + std::int32_t index = 0; + std::int32_t old_index = 0; bool is_current_profile = filename == _currentProfile->filename(); bool is_unit = filename.hasPrefix(_currentProfile->isDemo() ? "DemoUnit"_s : "Unit"_s); if(is_unit) { diff --git a/src/SaveTool/SaveTool_Initialisation.cpp b/src/SaveTool/SaveTool_Initialisation.cpp index 1142d1f..e14bb2b 100644 --- a/src/SaveTool/SaveTool_Initialisation.cpp +++ b/src/SaveTool/SaveTool_Initialisation.cpp @@ -73,7 +73,7 @@ SaveTool::initialiseGui() { font_config.FontDataOwnedByAtlas = false; std::strcpy(font_config.Name, "Source Sans Pro"); io.Fonts->AddFontFromMemoryTTF(const_cast(reg_font.data()), int(reg_font.size()), - 20.0f * Float(framebufferSize().x()) / size.x(), &font_config); + 20.0f * float(framebufferSize().x()) / size.x(), &font_config); auto icon_font = _rs.getRaw(FONT_ICON_FILE_NAME_FAS); static const ImWchar icon_range[] = { ICON_MIN_FA, ICON_MAX_FA, 0 }; @@ -84,12 +84,12 @@ SaveTool::initialiseGui() { icon_config.OversampleH = icon_config.OversampleV = 1; icon_config.GlyphMinAdvanceX = 18.0f; io.Fonts->AddFontFromMemoryTTF(const_cast(icon_font.data()), int(icon_font.size()), - 16.0f * Float(framebufferSize().x()) / size.x(), &icon_config, icon_range); + 16.0f * float(framebufferSize().x()) / size.x(), &icon_config, icon_range); auto brand_font = _rs.getRaw(FONT_ICON_FILE_NAME_FAB); static const ImWchar brand_range[] = { ICON_MIN_FAB, ICON_MAX_FAB, 0 }; io.Fonts->AddFontFromMemoryTTF(const_cast(brand_font.data()), int(brand_font.size()), - 16.0f * Float(framebufferSize().x()) / size.x(), &icon_config, brand_range); + 16.0f * float(framebufferSize().x()) / size.x(), &icon_config, brand_range); auto mono_font = _rs.getRaw("SourceCodePro-Regular.ttf"_s); ImVector range; @@ -98,7 +98,7 @@ SaveTool::initialiseGui() { builder.AddChar(u'š'); // This allows displaying Vladimír Vondruš' name in Corrade's and Magnum's licences. builder.BuildRanges(&range); io.Fonts->AddFontFromMemoryTTF(const_cast(mono_font.data()), int(mono_font.size()), - 18.0f * Float(framebufferSize().x()) / size.x(), &font_config, range.Data); + 18.0f * float(framebufferSize().x()) / size.x(), &font_config, range.Data); _imgui = ImGuiIntegration::Context(*ImGui::GetCurrentContext(), windowSize()); diff --git a/src/SaveTool/SaveTool_MainManager.cpp b/src/SaveTool/SaveTool_MainManager.cpp index 671763a..ff7a90c 100644 --- a/src/SaveTool/SaveTool_MainManager.cpp +++ b/src/SaveTool/SaveTool_MainManager.cpp @@ -31,7 +31,7 @@ void SaveTool::drawManager() { ImGui::SetNextWindowPos({0.0f, ImGui::GetItemRectSize().y}, ImGuiCond_Always); - ImGui::SetNextWindowSize({Float(windowSize().x()), Float(windowSize().y()) - ImGui::GetItemRectSize().y}, + ImGui::SetNextWindowSize({float(windowSize().x()), float(windowSize().y()) - ImGui::GetItemRectSize().y}, ImGuiCond_Always); if(!ImGui::Begin("##MainWindow", nullptr, ImGuiWindowFlags_NoDecoration|ImGuiWindowFlags_NoMove| @@ -210,7 +210,7 @@ SaveTool::drawGeneralInfo() { drawTooltip("This is the last mission selected in the mission selection screen, not the last mission played.", float(windowSize().x()) * 0.35f); - const Float footer_height_to_reserve = ImGui::GetStyle().ItemSpacing.y + ImGui::GetFrameHeightWithSpacing(); + const float footer_height_to_reserve = ImGui::GetStyle().ItemSpacing.y + ImGui::GetFrameHeightWithSpacing(); ImGui::Dummy({ImGui::GetContentRegionAvail().x, ImGui::GetContentRegionAvail().y - footer_height_to_reserve}); ImGui::Separator(); @@ -235,7 +235,7 @@ SaveTool::drawGeneralInfo() { ImGui::SameLine(); - static Int credits; + static std::int32_t credits; if(drawUnsafeWidget([]{ return ImGui::Button("Edit credits"); })) { credits = _currentProfile->credits(); ImGui::OpenPopup("int_edit"); @@ -302,22 +302,22 @@ SaveTool::drawResearchInventory() { drawMaterialRow("Verse steel", 1, [this]{ return _currentProfile->verseSteel(); }, - [this](Int amount){ return _currentProfile->setVerseSteel(amount); }); + [this](std::int32_t amount){ return _currentProfile->setVerseSteel(amount); }); drawMaterialRow("Undinium", 2, [this]{ return _currentProfile->undinium(); }, - [this](Int amount){ return _currentProfile->setUndinium(amount); }); + [this](std::int32_t amount){ return _currentProfile->setUndinium(amount); }); drawMaterialRow("Necrium alloy", 3, [this]{ return _currentProfile->necriumAlloy(); }, - [this](Int amount){ return _currentProfile->setNecriumAlloy(amount); }); + [this](std::int32_t amount){ return _currentProfile->setNecriumAlloy(amount); }); drawMaterialRow("Lunarite", 4, [this]{ return _currentProfile->lunarite(); }, - [this](Int amount){ return _currentProfile->setLunarite(amount); }); + [this](std::int32_t amount){ return _currentProfile->setLunarite(amount); }); drawMaterialRow("Asterite", 5, [this]{ return _currentProfile->asterite(); }, - [this](Int amount){ return _currentProfile->setAsterite(amount); }); + [this](std::int32_t amount){ return _currentProfile->setAsterite(amount); }); drawMaterialRow("Hallite fragma", 6, [this]{ return _currentProfile->halliteFragma(); }, - [this](Int amount){ return _currentProfile->setHalliteFragma(amount); }); + [this](std::int32_t amount){ return _currentProfile->setHalliteFragma(amount); }); drawUnavailableMaterialRow("Unnoctinium", 7); ImGui::TableNextRow(ImGuiTableRowFlags_Headers); @@ -326,22 +326,22 @@ SaveTool::drawResearchInventory() { drawMaterialRow("Ednil", 1, [this]{ return _currentProfile->ednil(); }, - [this](Int amount){ return _currentProfile->setEdnil(amount); }); + [this](std::int32_t amount){ return _currentProfile->setEdnil(amount); }); drawMaterialRow("Nuflalt", 2, [this]{ return _currentProfile->nuflalt(); }, - [this](Int amount){ return _currentProfile->setNuflalt(amount); }); + [this](std::int32_t amount){ return _currentProfile->setNuflalt(amount); }); drawMaterialRow("Aurelene", 3, [this]{ return _currentProfile->aurelene(); }, - [this](Int amount){ return _currentProfile->setAurelene(amount); }); + [this](std::int32_t amount){ return _currentProfile->setAurelene(amount); }); drawMaterialRow("Soldus", 4, [this]{ return _currentProfile->soldus(); }, - [this](Int amount){ return _currentProfile->setSoldus(amount); }); + [this](std::int32_t amount){ return _currentProfile->setSoldus(amount); }); drawMaterialRow("Synthesized N", 5, [this]{ return _currentProfile->synthesisedN(); }, - [this](Int amount){ return _currentProfile->setSynthesisedN(amount); }); + [this](std::int32_t amount){ return _currentProfile->setSynthesisedN(amount); }); drawMaterialRow("Nanoc", 6, [this]{ return _currentProfile->nanoc(); }, - [this](Int amount){ return _currentProfile->setNanoc(amount); }); + [this](std::int32_t amount){ return _currentProfile->setNanoc(amount); }); drawUnavailableMaterialRow("Abyssillite", 7); ImGui::TableNextRow(ImGuiTableRowFlags_Headers); @@ -350,22 +350,22 @@ SaveTool::drawResearchInventory() { drawMaterialRow("Alcarbonite", 1, [this]{ return _currentProfile->alcarbonite(); }, - [this](Int amount){ return _currentProfile->setAlcarbonite(amount); }); + [this](std::int32_t amount){ return _currentProfile->setAlcarbonite(amount); }); drawMaterialRow("Keripehene", 2, [this]{ return _currentProfile->keriphene(); }, - [this](Int amount){ return _currentProfile->setKeriphene(amount); }); + [this](std::int32_t amount){ return _currentProfile->setKeriphene(amount); }); drawMaterialRow("Nitinol-CM", 3, [this]{ return _currentProfile->nitinolCM(); }, - [this](Int amount){ return _currentProfile->setNitinolCM(amount); }); + [this](std::int32_t amount){ return _currentProfile->setNitinolCM(amount); }); drawMaterialRow("Quarkium", 4, [this]{ return _currentProfile->quarkium(); }, - [this](Int amount){ return _currentProfile->setQuarkium(amount); }); + [this](std::int32_t amount){ return _currentProfile->setQuarkium(amount); }); drawMaterialRow("Alterene", 5, [this]{ return _currentProfile->alterene(); }, - [this](Int amount){ return _currentProfile->setAlterene(amount); }); + [this](std::int32_t amount){ return _currentProfile->setAlterene(amount); }); drawMaterialRow("Cosmium", 6, [this]{ return _currentProfile->cosmium(); }, - [this](Int amount){ return _currentProfile->setCosmium(amount); }); + [this](std::int32_t amount){ return _currentProfile->setCosmium(amount); }); drawUnavailableMaterialRow("Purified quarkium", 7); ImGui::TableNextRow(ImGuiTableRowFlags_Headers); @@ -374,22 +374,22 @@ SaveTool::drawResearchInventory() { drawMaterialRow("Mixed composition", 1, [this]{ return _currentProfile->mixedComposition(); }, - [this](Int amount){ return _currentProfile->setMixedComposition(amount); }); + [this](std::int32_t amount){ return _currentProfile->setMixedComposition(amount); }); drawMaterialRow("Void residue", 2, [this]{ return _currentProfile->voidResidue(); }, - [this](Int amount){ return _currentProfile->setVoidResidue(amount); }); + [this](std::int32_t amount){ return _currentProfile->setVoidResidue(amount); }); drawMaterialRow("Muscular construction", 3, [this]{ return _currentProfile->muscularConstruction(); }, - [this](Int amount){ return _currentProfile->setMuscularConstruction(amount); }); + [this](std::int32_t amount){ return _currentProfile->setMuscularConstruction(amount); }); drawMaterialRow("Mineral exoskeletology", 4, [this]{ return _currentProfile->mineralExoskeletology(); }, - [this](Int amount){ return _currentProfile->setMineralExoskeletology(amount); }); + [this](std::int32_t amount){ return _currentProfile->setMineralExoskeletology(amount); }); drawMaterialRow("Carbonized skin", 5, [this]{ return _currentProfile->carbonisedSkin(); }, - [this](Int amount){ return _currentProfile->setCarbonisedSkin(amount); }); + [this](std::int32_t amount){ return _currentProfile->setCarbonisedSkin(amount); }); drawMaterialRow("Isolated void particle", 6, [this]{ return _currentProfile->isolatedVoidParticle(); }, - [this](Int amount){ return _currentProfile->setIsolatedVoidParticle(amount); }); + [this](std::int32_t amount){ return _currentProfile->setIsolatedVoidParticle(amount); }); drawUnavailableMaterialRow("Weaponised physiology", 7); ImGui::EndTable(); @@ -398,9 +398,9 @@ SaveTool::drawResearchInventory() { template 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."); +SaveTool::drawMaterialRow(Containers::StringView name, std::int32_t tier, Getter getter, Setter setter) { + static_assert(std::is_same::value, "getter doesn't return an std::int32_t, 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 std::int32_t as an argument."); ImGui::TableNextRow(); ImGui::TableSetColumnIndex(0); @@ -413,7 +413,7 @@ SaveTool::drawMaterialRow(Containers::StringView name, Int tier, Getter getter, if(conf().cheatMode()) { ImGui::TableSetColumnIndex(3); ImGui::PushID(name.data()); - static Int var = 0; + static std::int32_t var = 0; if(drawUnsafeWidget(ImGui::SmallButton, ICON_FA_EDIT)) { (var) = getter(); ImGui::OpenPopup("int_edit"); @@ -433,7 +433,7 @@ SaveTool::drawMaterialRow(Containers::StringView name, Int tier, Getter getter, } void -SaveTool::drawUnavailableMaterialRow(Containers::StringView name, Int tier) { +SaveTool::drawUnavailableMaterialRow(Containers::StringView name, std::int32_t tier) { ImGui::TableNextRow(); ImGui::TableSetColumnIndex(0); ImGui::Text("T%i", tier); diff --git a/src/SaveTool/SaveTool_MassViewer.cpp b/src/SaveTool/SaveTool_MassViewer.cpp index f1256cf..5ec3f0c 100644 --- a/src/SaveTool/SaveTool_MassViewer.cpp +++ b/src/SaveTool/SaveTool_MassViewer.cpp @@ -38,7 +38,7 @@ SaveTool::drawMassViewer() { } ImGui::SetNextWindowPos({0.0f, ImGui::GetItemRectSize().y}, ImGuiCond_Always); - ImGui::SetNextWindowSize({Float(windowSize().x()), Float(windowSize().y()) - ImGui::GetItemRectSize().y}, + ImGui::SetNextWindowSize({float(windowSize().x()), float(windowSize().y()) - ImGui::GetItemRectSize().y}, ImGuiCond_Always); if(!ImGui::Begin("##MassViewer", nullptr, ImGuiWindowFlags_NoDecoration|ImGuiWindowFlags_NoMove| @@ -86,8 +86,8 @@ SaveTool::drawMassViewer() { _jointsDirty = false; _stylesDirty = false; _eyeFlareDirty = false; - _selectedArmourDecals = Containers::StaticArray<38, Int>{ValueInit}; - _selectedArmourAccessories = Containers::StaticArray<38, Int>{ValueInit}; + _selectedArmourDecals = Containers::StaticArray<38, std::int32_t>{ValueInit}; + _selectedArmourAccessories = Containers::StaticArray<38, std::int32_t>{ValueInit}; _selectedBLPlacement = 0; _selectedWeaponPart = 0; _selectedWeaponDecal = 0; @@ -168,7 +168,7 @@ SaveTool::drawGlobalStyles() { ImGui::TextWrapped("In-game values are multiplied by 100. For example, 0.500 here is equal to 50 in-game."); - for(UnsignedInt i = 0; i < _currentMass->globalStyles().size(); i++) { + for(std::uint32_t i = 0; i < _currentMass->globalStyles().size(); i++) { ImGui::PushID(int(i)); DCSResult result; result = drawCustomStyle(_currentMass->globalStyles()[i]); @@ -225,7 +225,7 @@ SaveTool::drawTuning() { ImGui::TableNextColumn(); ImGui::TextUnformatted("Gears"); - for(UnsignedInt i = 0; i < _currentMass->gears().size(); i++) { + for(std::uint32_t i = 0; i < _currentMass->gears().size(); i++) { ImGui::TableNextRow(); ImGui::TableNextColumn(); ImGui::Text("%i", _currentMass->gears()[i]); @@ -251,7 +251,7 @@ SaveTool::drawTuning() { ImGui::TableNextColumn(); ImGui::TextUnformatted("Modules"); - for(UnsignedInt i = 0; i < _currentMass->modules().size(); i++) { + for(std::uint32_t i = 0; i < _currentMass->modules().size(); i++) { ImGui::TableNextRow(); ImGui::TableNextColumn(); ImGui::Text("%i", _currentMass->modules()[i]); @@ -277,7 +277,7 @@ SaveTool::drawTuning() { ImGui::TableNextColumn(); ImGui::TextUnformatted("Techs"); - for(UnsignedInt i = 0; i < _currentMass->techs().size(); i++) { + for(std::uint32_t i = 0; i < _currentMass->techs().size(); i++) { ImGui::TableNextRow(); ImGui::TableNextColumn(); ImGui::Text("%i", _currentMass->techs()[i]); @@ -515,7 +515,7 @@ SaveTool::drawAccessoryEditor(Accessory& accessory, Containers::ArrayView size = Containers::NullOpt; if(ImGui::SmallButton("Change")) { ImGui::OpenPopup("##AccessoryPopup"); @@ -539,7 +539,7 @@ SaveTool::drawAccessoryEditor(Accessory& accessory, Containers::ArrayView view) { +SaveTool::getStyleName(std::int32_t 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 5c21698..76d9459 100644 --- a/src/SaveTool/SaveTool_MassViewer_Armour.cpp +++ b/src/SaveTool/SaveTool_MassViewer_Armour.cpp @@ -43,7 +43,7 @@ SaveTool::drawArmour() { #undef c }; - for(UnsignedInt i = 0; i < _currentMass->armourParts().size(); i++) { + for(std::uint32_t i = 0; i < _currentMass->armourParts().size(); i++) { ImGui::PushID(int(i)); auto& part = _currentMass->armourParts()[i]; @@ -53,10 +53,10 @@ SaveTool::drawArmour() { std::memset(header, '\0', 129); if(armour_sets.find(part.id) != armour_sets.cend()) { - std::snprintf(header, 128, "%s: %s###%u", slot_labels[UnsignedInt(part.slot)].data(), armour_sets.at(part.id).name.data(), UnsignedInt(part.slot)); + std::snprintf(header, 128, "%s: %s###%u", slot_labels[std::uint32_t(part.slot)].data(), armour_sets.at(part.id).name.data(), std::uint32_t(part.slot)); } else { - std::snprintf(header, 128, "%s: %i###%u", slot_labels[UnsignedInt(part.slot)].data(), part.id, UnsignedInt(part.slot)); + std::snprintf(header, 128, "%s: %i###%u", slot_labels[std::uint32_t(part.slot)].data(), part.id, std::uint32_t(part.slot)); } if(ImGui::CollapsingHeader(header)) { @@ -64,7 +64,7 @@ SaveTool::drawArmour() { ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x * 0.491f); if(ImGui::BeginListBox("##ChangePart")) { - if(std::strncmp("Neck", slot_labels[UnsignedInt(part.slot)].data(), 4) != 0) { + if(std::strncmp("Neck", slot_labels[std::uint32_t(part.slot)].data(), 4) != 0) { for(auto& set : armour_sets) { if(ImGui::Selectable(set.second.name.data(), set.first == part.id, ImGuiSelectableFlags_SpanAvailWidth)) { part.id = set.first; @@ -97,7 +97,7 @@ SaveTool::drawArmour() { ImGui::TextUnformatted("Styles:"); - for(Int j = 0; j < 4; j++) { + for(std::int32_t j = 0; j < 4; j++) { drawAlignedText("Slot %d:", j + 1); ImGui::SameLine(); @@ -125,7 +125,7 @@ SaveTool::drawArmour() { ImGui::PushID("Decal"); drawAlignedText("Showing/editing decal"); - for(UnsignedInt j = 0; j < part.decals.size(); j++) { + for(std::uint32_t j = 0; j < part.decals.size(); j++) { ImGui::SameLine(); ImGui::RadioButton(std::to_string(j + 1).c_str(), &_selectedArmourDecals[i], int(j)); } @@ -140,7 +140,7 @@ SaveTool::drawArmour() { ImGui::PushID("Accessory"); drawAlignedText("Showing/editing accessory"); - for(UnsignedInt j = 0; j < part.accessories.size(); j++) { + for(std::uint32_t j = 0; j < part.accessories.size(); j++) { ImGui::SameLine(); ImGui::RadioButton(std::string{char(65 + j)}.c_str(), &_selectedArmourAccessories[i], int(j)); } @@ -200,9 +200,9 @@ SaveTool::drawArmour() { drawAlignedText("Socket:"); ImGui::SameLine(); - if(ImGui::BeginCombo("##Socket", socket_labels[UnsignedInt(placement.socket)].data())) { - for(UnsignedInt i = 0; i < (sizeof(socket_labels) / sizeof(socket_labels[0])); i++) { - if(ImGui::Selectable(socket_labels[i].data(), i == UnsignedInt(placement.socket), ImGuiSelectableFlags_SpanAvailWidth)) { + if(ImGui::BeginCombo("##Socket", socket_labels[std::uint32_t(placement.socket)].data())) { + for(std::uint32_t i = 0; i < (sizeof(socket_labels) / sizeof(socket_labels[0])); i++) { + if(ImGui::Selectable(socket_labels[i].data(), i == std::uint32_t(placement.socket), ImGuiSelectableFlags_SpanAvailWidth)) { placement.socket = static_cast(i); } } @@ -302,7 +302,7 @@ SaveTool::drawCustomArmourStyles() { ImGui::TextWrapped("In-game values are multiplied by 100. For example, 0.500 here is equal to 50 in-game."); - for(UnsignedInt i = 0; i < _currentMass->armourCustomStyles().size(); i++) { + for(std::uint32_t i = 0; i < _currentMass->armourCustomStyles().size(); i++) { ImGui::PushID(int(i)); DCSResult result; result = drawCustomStyle(_currentMass->armourCustomStyles()[i]); diff --git a/src/SaveTool/SaveTool_MassViewer_Frame.cpp b/src/SaveTool/SaveTool_MassViewer_Frame.cpp index bbcf609..61948b6 100644 --- a/src/SaveTool/SaveTool_MassViewer_Frame.cpp +++ b/src/SaveTool/SaveTool_MassViewer_Frame.cpp @@ -202,7 +202,7 @@ SaveTool::drawFrameStyles() { return; } - for(Int i = 0; i < 4; i++) { + for(std::int32_t i = 0; i < 4; i++) { drawAlignedText("Slot %d:", i + 1); ImGui::SameLine(); @@ -294,7 +294,7 @@ SaveTool::drawCustomFrameStyles() { ImGui::TextWrapped("In-game values are multiplied by 100. For example, 0.500 here is equal to 50 in-game."); - for(UnsignedInt i = 0; i < _currentMass->frameCustomStyles().size(); i++) { + for(std::uint32_t i = 0; i < _currentMass->frameCustomStyles().size(); i++) { ImGui::PushID(int(i)); DCSResult result; result = drawCustomStyle(_currentMass->frameCustomStyles()[i]); diff --git a/src/SaveTool/SaveTool_MassViewer_Weapons.cpp b/src/SaveTool/SaveTool_MassViewer_Weapons.cpp index 2bbcd3a..7e48de1 100644 --- a/src/SaveTool/SaveTool_MassViewer_Weapons.cpp +++ b/src/SaveTool/SaveTool_MassViewer_Weapons.cpp @@ -28,7 +28,7 @@ SaveTool::drawWeapons() { return; } - const Float footer_height_to_reserve = ImGui::GetStyle().ItemSpacing.y + ImGui::GetFrameHeightWithSpacing(); + const float footer_height_to_reserve = ImGui::GetStyle().ItemSpacing.y + ImGui::GetFrameHeightWithSpacing(); ImGui::BeginGroup(); @@ -265,7 +265,7 @@ SaveTool::drawWeaponCategory(Containers::StringView name, Containers::ArrayView< ImGui::PushID(payload_type.data()); - for(UnsignedInt i = 0; i < weapons_view.size(); i++) { + for(std::uint32_t i = 0; i < weapons_view.size(); i++) { auto& weapon = weapons_view[i]; ImGui::TableNextRow(); @@ -277,7 +277,7 @@ SaveTool::drawWeaponCategory(Containers::StringView name, Containers::ArrayView< _currentWeapon = &weapon; } if(ImGui::BeginDragDropSource()) { - ImGui::SetDragDropPayload(payload_type.data(), &i, sizeof(UnsignedInt)); + ImGui::SetDragDropPayload(payload_type.data(), &i, sizeof(std::uint32_t)); if(ImGui::GetIO().KeyCtrl) { ImGui::Text("%s %i - %s (copy)", payload_tooltip.data(), i + 1, weapon.name.data()); } @@ -331,7 +331,7 @@ SaveTool::drawWeaponEditor(Weapon& weapon) { #undef c }; - drawAlignedText("%s: %s", labels[UnsignedInt(weapon.type)].data(), weapon.name.data()); + drawAlignedText("%s: %s", labels[std::uint32_t(weapon.type)].data(), weapon.name.data()); ImGui::SameLine(); @@ -428,8 +428,8 @@ SaveTool::drawWeaponEditor(Weapon& weapon) { if(ImGui::CollapsingHeader("Weapon parts")) { drawAlignedText("Viewing/editing part:"); - for(Int i = 0; UnsignedLong(i) < weapon.parts.size(); i++) { - if(UnsignedLong(_selectedWeaponPart) >= weapon.parts.size()) { + for(std::int32_t i = 0; std::size_t(i) < weapon.parts.size(); i++) { + if(std::size_t(_selectedWeaponPart) >= weapon.parts.size()) { _selectedWeaponPart = 0; } ImGui::SameLine(); @@ -438,7 +438,7 @@ SaveTool::drawWeaponEditor(Weapon& weapon) { auto& part = weapon.parts[_selectedWeaponPart]; - const auto* map = [this, &weapon]()-> const std::map* { + const auto* map = [this, &weapon]()-> const std::map* { switch(weapon.type) { case WeaponType::Melee: return _selectedWeaponPart == 0 ? &melee_grips : &melee_assaulters; @@ -511,7 +511,7 @@ SaveTool::drawWeaponEditor(Weapon& weapon) { if(ImGui::BeginChild("##PartDetails", {0.0f, 0.0f}, true)) { ImGui::TextUnformatted("Styles:"); - for(Int i = 0; i < 4; i++) { + for(std::int32_t i = 0; i < 4; i++) { drawAlignedText("Slot %d:", i + 1); ImGui::SameLine(); @@ -537,7 +537,7 @@ SaveTool::drawWeaponEditor(Weapon& weapon) { ImGui::PushID("Decal"); drawAlignedText("Showing/editing decal"); - for(UnsignedLong i = 0; i < part.decals.size(); i++) { + for(std::size_t i = 0; i < part.decals.size(); i++) { ImGui::SameLine(); ImGui::RadioButton(std::to_string(i + 1).c_str(), &_selectedWeaponDecal, int(i)); } @@ -552,7 +552,7 @@ SaveTool::drawWeaponEditor(Weapon& weapon) { ImGui::PushID("Accessory"); drawAlignedText("Showing/editing accessory"); - for(UnsignedLong i = 0; i < part.accessories.size(); i++) { + for(std::size_t i = 0; i < part.accessories.size(); i++) { ImGui::SameLine(); ImGui::RadioButton(std::string{char(65 + i)}.c_str(), &_selectedWeaponAccessory, int(i)); } diff --git a/src/SaveTool/SaveTool_UpdateChecker.cpp b/src/SaveTool/SaveTool_UpdateChecker.cpp index 0716744..dc42443 100644 --- a/src/SaveTool/SaveTool_UpdateChecker.cpp +++ b/src/SaveTool/SaveTool_UpdateChecker.cpp @@ -73,10 +73,10 @@ SaveTool::updateCheckEvent(SDL_Event& event) { prerelease = true; } } - Int fullVersion; - Int major = 0; - Int minor = 0; - Int patch = 0; + std::int32_t fullVersion; + std::int32_t major = 0; + std::int32_t minor = 0; + std::int32_t patch = 0; bool prerelease = false; bool operator==(const Version& other) const { @@ -161,7 +161,7 @@ SaveTool::checkForUpdates() { if(code == CURLE_OK) { long status = 0; curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &status); - event.user.code = Int(status); + event.user.code = std::int32_t(status); event.user.data1 = response_body.release(); } else if(code == CURLE_OPERATION_TIMEDOUT) { diff --git a/src/SaveTool/SaveTool_drawMainMenu.cpp b/src/SaveTool/SaveTool_drawMainMenu.cpp index 400c608..b204087 100644 --- a/src/SaveTool/SaveTool_drawMainMenu.cpp +++ b/src/SaveTool/SaveTool_drawMainMenu.cpp @@ -113,7 +113,7 @@ SaveTool::drawMainMenu() { ImGui::SameLine(); ImGui::AlignTextToFramePadding(); drawHelpMarker("This gives access to save edition features that can be considered cheats.", - Float(windowSize().x()) * 0.4f); + float(windowSize().x()) * 0.4f); if(drawCheckbox("Advanced mode", conf().advancedMode())) { conf().setAdvancedMode(!conf().advancedMode()); @@ -121,7 +121,7 @@ SaveTool::drawMainMenu() { ImGui::SameLine(); ImGui::AlignTextToFramePadding(); drawHelpMarker("This gives access to editing values that have unknown purposes or are undocumented.", - Float(windowSize().x()) * 0.4f); + float(windowSize().x()) * 0.4f); if(drawCheckbox("Check for updates on startup", conf().checkUpdatesOnStartup())) { conf().setCheckUpdatesOnStartup(!conf().checkUpdatesOnStartup()); diff --git a/src/ToastQueue/ToastQueue.cpp b/src/ToastQueue/ToastQueue.cpp index df92ec8..0459c97 100644 --- a/src/ToastQueue/ToastQueue.cpp +++ b/src/ToastQueue/ToastQueue.cpp @@ -26,15 +26,15 @@ using namespace Containers::Literals; -constexpr UnsignedInt success_colour = 0xff67d23bu; -constexpr UnsignedInt info_colour = 0xffcc832fu; -constexpr UnsignedInt warning_colour = 0xff2fcfc7u; -constexpr UnsignedInt error_colour = 0xff3134cdu; +constexpr std::uint32_t success_colour = 0xff67d23bu; +constexpr std::uint32_t info_colour = 0xffcc832fu; +constexpr std::uint32_t warning_colour = 0xff2fcfc7u; +constexpr std::uint32_t error_colour = 0xff3134cdu; -constexpr UnsignedInt fade_time = 150; -constexpr Float base_opacity = 1.0f; +constexpr std::uint32_t fade_time = 150; +constexpr float base_opacity = 1.0f; constexpr Vector2 padding{20.0f, 20.0f}; -constexpr Float toast_spacing = 10.0f; +constexpr float toast_spacing = 10.0f; Toast::Toast(Type type, Containers::StringView message, std::chrono::milliseconds timeout): _type{type}, @@ -42,7 +42,7 @@ Toast::Toast(Type type, Containers::StringView message, std::chrono::millisecond _timeout{timeout}, _creationTime{std::chrono::steady_clock::now()} { - _phaseTrack = Animation::Track{{ + _phaseTrack = Animation::Track{{ {0, Phase::FadeIn}, {fade_time, Phase::Wait}, {fade_time + timeout.count(), Phase::FadeOut}, @@ -80,16 +80,16 @@ Toast::phase() { return _phaseTrack.at(elapsedTime().count()); } -Float +float Toast::opacity() { Phase phase = this->phase(); - Long elapsed_time = elapsedTime().count(); + std::int64_t elapsed_time = elapsedTime().count(); if(phase == Phase::FadeIn) { - return Float(elapsed_time) / Float(fade_time); + return float(elapsed_time) / float(fade_time); } else if(phase == Phase::FadeOut) { - return 1.0f - ((Float(elapsed_time) - Float(fade_time) - Float(_timeout.count())) / Float(fade_time)); + return 1.0f - ((float(elapsed_time) - float(fade_time) - float(_timeout.count())) / float(fade_time)); } return 1.0f; @@ -107,9 +107,9 @@ ToastQueue::addToast(Toast::Type type, Containers::StringView message, std::chro void ToastQueue::draw(Vector2i viewport_size) { - Float height = 0.0f; + float height = 0.0f; - for(UnsignedInt i = 0; i < _toasts.size(); i++) { + for(std::uint32_t i = 0; i < _toasts.size(); i++) { Toast* current = &_toasts[i]; if(current->phase() == Toast::Phase::TimedOut) { @@ -119,11 +119,12 @@ ToastQueue::draw(Vector2i viewport_size) { Containers::String win_id = Utility::format("##Toast{}", i); - Float opacity = base_opacity * current->opacity(); + float opacity = base_opacity * current->opacity(); ImGui::PushStyleVar(ImGuiStyleVar_Alpha, opacity); - ImGui::SetNextWindowPos({viewport_size.x() - padding.x(), viewport_size.y() - padding.y() - height}, ImGuiCond_Always, {1.0f, 1.0f}); + ImGui::SetNextWindowPos({float(viewport_size.x()) - padding.x(), float(viewport_size.y()) - padding.y() - height}, + ImGuiCond_Always, {1.0f, 1.0f}); if(ImGui::Begin(win_id.data(), nullptr, ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoDecoration| ImGuiWindowFlags_NoInputs|ImGuiWindowFlags_NoNav|ImGuiWindowFlags_NoFocusOnAppearing)) @@ -168,6 +169,6 @@ ToastQueue::draw(Vector2i viewport_size) { } void -ToastQueue::removeToast(Long index) { +ToastQueue::removeToast(std::int64_t index) { _toasts.erase(_toasts.begin() + index); } diff --git a/src/ToastQueue/ToastQueue.h b/src/ToastQueue/ToastQueue.h index 5c5365e..b141662 100644 --- a/src/ToastQueue/ToastQueue.h +++ b/src/ToastQueue/ToastQueue.h @@ -29,11 +29,11 @@ using namespace Magnum; class Toast { public: - enum class Type : UnsignedByte { + enum class Type: std::uint8_t { Default, Success, Info, Warning, Error }; - enum class Phase : UnsignedByte { + enum class Phase: std::uint8_t { FadeIn, Wait, FadeOut, TimedOut }; @@ -58,14 +58,14 @@ class Toast { Phase phase(); - Float opacity(); + float opacity(); private: Type _type{Type::Default}; Containers::String _message; std::chrono::milliseconds _timeout; std::chrono::steady_clock::time_point _creationTime; - Animation::Track _phaseTrack; + Animation::Track _phaseTrack; }; class ToastQueue { @@ -78,7 +78,7 @@ class ToastQueue { void draw(Vector2i viewport_size); private: - void removeToast(Long index); + void removeToast(std::int64_t index); std::vector _toasts; }; diff --git a/src/UESaveFile/BinaryReader.cpp b/src/UESaveFile/BinaryReader.cpp index c0ae9b2..6610ec2 100644 --- a/src/UESaveFile/BinaryReader.cpp +++ b/src/UESaveFile/BinaryReader.cpp @@ -45,13 +45,13 @@ BinaryReader::eof() { return std::feof(_file) != 0; } -Long +std::int64_t BinaryReader::position() { return _ftelli64(_file); } bool -BinaryReader::seek(Long position) { +BinaryReader::seek(std::int64_t position) { return _fseeki64(_file, position, SEEK_SET) == 0; } @@ -67,53 +67,53 @@ BinaryReader::readChar(char& value) { } bool -BinaryReader::readByte(Byte& value) { - return std::fread(&value, sizeof(Byte), 1, _file) == 1; +BinaryReader::readInt8(std::int8_t& value) { + return std::fread(&value, sizeof(std::int8_t), 1, _file) == 1; } bool -BinaryReader::readUnsignedByte(UnsignedByte& value) { - return std::fread(&value, sizeof(UnsignedByte), 1, _file) == 1; +BinaryReader::readUint8(std::uint8_t& value) { + return std::fread(&value, sizeof(std::uint8_t), 1, _file) == 1; } bool -BinaryReader::readShort(Short& value) { - return std::fread(&value, sizeof(Short), 1, _file) == 1; +BinaryReader::readInt16(std::int16_t& value) { + return std::fread(&value, sizeof(std::int16_t), 1, _file) == 1; } bool -BinaryReader::readUnsignedShort(UnsignedShort& value) { - return std::fread(&value, sizeof(UnsignedShort), 1, _file) == 1; +BinaryReader::readUint16(std::uint16_t& value) { + return std::fread(&value, sizeof(std::uint16_t), 1, _file) == 1; } bool -BinaryReader::readInt(Int& value) { - return std::fread(&value, sizeof(Int), 1, _file) == 1; +BinaryReader::readInt32(std::int32_t& value) { + return std::fread(&value, sizeof(std::int32_t), 1, _file) == 1; } bool -BinaryReader::readUnsignedInt(UnsignedInt& value) { - return std::fread(&value, sizeof(UnsignedInt), 1, _file) == 1; +BinaryReader::readUint32(std::uint32_t& value) { + return std::fread(&value, sizeof(std::uint32_t), 1, _file) == 1; } bool -BinaryReader::readLong(Long& value) { - return std::fread(&value, sizeof(Long), 1, _file) == 1; +BinaryReader::readInt64(std::int64_t& value) { + return std::fread(&value, sizeof(std::int64_t), 1, _file) == 1; } bool -BinaryReader::readUnsignedLong(UnsignedLong& value) { - return std::fread(&value, sizeof(UnsignedLong), 1, _file) == 1; +BinaryReader::readUint64(std::uint64_t& value) { + return std::fread(&value, sizeof(std::uint64_t), 1, _file) == 1; } bool -BinaryReader::readFloat(Float& value) { - return std::fread(&value, sizeof(Float), 1, _file) == 1; +BinaryReader::readFloat(float& value) { + return std::fread(&value, sizeof(float), 1, _file) == 1; } bool -BinaryReader::readDouble(Double& value) { - return std::fread(&value, sizeof(Double), 1, _file) == 1; +BinaryReader::readDouble(double& value) { + return std::fread(&value, sizeof(double), 1, _file) == 1; } bool @@ -127,8 +127,8 @@ BinaryReader::readArray(Containers::Array& array, std::size_t count) { bool BinaryReader::readUEString(Containers::String& str) { - UnsignedInt length = 0; - if(!readUnsignedInt(length) || length == 0) { + std::uint32_t length = 0; + if(!readUint32(length) || length == 0) { return false; } @@ -137,9 +137,9 @@ BinaryReader::readUEString(Containers::String& str) { return std::fread(str.data(), sizeof(char), length, _file) == length; } -Int +std::int32_t BinaryReader::peekChar() { - Int c; + std::int32_t c; c = std::fgetc(_file); std::ungetc(c, _file); return c; diff --git a/src/UESaveFile/BinaryReader.h b/src/UESaveFile/BinaryReader.h index e945938..46915f4 100644 --- a/src/UESaveFile/BinaryReader.h +++ b/src/UESaveFile/BinaryReader.h @@ -16,16 +16,14 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . +#include #include #include #include #include -#include - using namespace Corrade; -using namespace Magnum; class BinaryReader { public: @@ -34,23 +32,23 @@ class BinaryReader { bool open(); bool eof(); - Long position(); + std::int64_t position(); - bool seek(Long position); + bool seek(std::int64_t position); void closeFile(); 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 readInt8(std::int8_t& value); + bool readUint8(std::uint8_t& value); + bool readInt16(std::int16_t& value); + bool readUint16(std::uint16_t& value); + bool readInt32(std::int32_t& value); + bool readUint32(std::uint32_t& value); + bool readInt64(std::int64_t& value); + bool readUint64(std::uint64_t& value); + bool readFloat(float& value); + bool readDouble(double& value); bool readArray(Containers::Array& array, std::size_t count); template @@ -65,7 +63,7 @@ class BinaryReader { bool readUEString(Containers::String& str); - Int peekChar(); + std::int32_t peekChar(); private: std::FILE* _file = nullptr; diff --git a/src/UESaveFile/BinaryWriter.cpp b/src/UESaveFile/BinaryWriter.cpp index a5a2e15..ce55642 100644 --- a/src/UESaveFile/BinaryWriter.cpp +++ b/src/UESaveFile/BinaryWriter.cpp @@ -45,7 +45,7 @@ BinaryWriter::closeFile() { _file = nullptr; } -Long +std::int64_t BinaryWriter::position() { return _ftelli64(_file); } @@ -55,7 +55,7 @@ BinaryWriter::array() const { return _data; } -UnsignedLong +std::size_t BinaryWriter::arrayPosition() const { return _index; } @@ -75,53 +75,53 @@ BinaryWriter::writeChar(char value) { } bool -BinaryWriter::writeByte(Byte value) { - return std::fwrite(&value, sizeof(Byte), 1, _file) == 1; +BinaryWriter::writeInt8(std::int8_t value) { + return std::fwrite(&value, sizeof(std::int8_t), 1, _file) == 1; } bool -BinaryWriter::writeUnsignedByte(UnsignedByte value) { - return std::fwrite(&value, sizeof(UnsignedByte), 1, _file) == 1; +BinaryWriter::writeUint8(std::uint8_t value) { + return std::fwrite(&value, sizeof(std::uint8_t), 1, _file) == 1; } bool -BinaryWriter::writeShort(Short value) { - return std::fwrite(&value, sizeof(Short), 1, _file) == 1; +BinaryWriter::writeInt16(std::int16_t value) { + return std::fwrite(&value, sizeof(std::int16_t), 1, _file) == 1; } bool -BinaryWriter::writeUnsignedShort(UnsignedShort value) { - return std::fwrite(&value, sizeof(UnsignedShort), 1, _file) == 1; +BinaryWriter::writeUint16(std::uint16_t value) { + return std::fwrite(&value, sizeof(std::uint16_t), 1, _file) == 1; } bool -BinaryWriter::writeInt(Int value) { - return std::fwrite(&value, sizeof(Int), 1, _file) == 1; +BinaryWriter::writeInt32(std::int32_t value) { + return std::fwrite(&value, sizeof(std::int32_t), 1, _file) == 1; } bool -BinaryWriter::writeUnsignedInt(UnsignedInt value) { - return std::fwrite(&value, sizeof(UnsignedInt), 1, _file) == 1; +BinaryWriter::writeUint32(std::uint32_t value) { + return std::fwrite(&value, sizeof(std::uint32_t), 1, _file) == 1; } bool -BinaryWriter::writeLong(Long value) { - return std::fwrite(&value, sizeof(Long), 1, _file) == 1; +BinaryWriter::writeInt64(std::int64_t value) { + return std::fwrite(&value, sizeof(std::int64_t), 1, _file) == 1; } bool -BinaryWriter::writeUnsignedLong(UnsignedLong value) { - return std::fwrite(&value, sizeof(UnsignedLong), 1, _file) == 1; +BinaryWriter::writeUint64(std::uint64_t value) { + return std::fwrite(&value, sizeof(std::uint64_t), 1, _file) == 1; } bool -BinaryWriter::writeFloat(Float value) { - return std::fwrite(&value, sizeof(Float), 1, _file) == 1; +BinaryWriter::writeFloat(float value) { + return std::fwrite(&value, sizeof(float), 1, _file) == 1; } bool -BinaryWriter::writeDouble(Double value) { - return std::fwrite(&value, sizeof(Double), 1, _file) == 1; +BinaryWriter::writeDouble(double value) { + return std::fwrite(&value, sizeof(double), 1, _file) == 1; } bool @@ -140,7 +140,7 @@ BinaryWriter::writeUEString(Containers::StringView str) { return false; } - writeUnsignedInt(static_cast(str.size()) + 1); + writeUint32(static_cast(str.size()) + 1); if(str.size() > 0) { std::size_t count = std::fwrite(str.data(), sizeof(char), str.size(), _file); @@ -151,9 +151,9 @@ BinaryWriter::writeUEString(Containers::StringView str) { return writeChar('\0'); } -UnsignedLong +std::size_t BinaryWriter::writeUEStringToArray(Containers::StringView value) { - return writeValueToArray(UnsignedInt(value.size()) + 1u) + + return writeValueToArray(std::uint32_t(value.size()) + 1u) + writeDataToArray(Containers::ArrayView{value}) + writeValueToArray('\0'); } diff --git a/src/UESaveFile/BinaryWriter.h b/src/UESaveFile/BinaryWriter.h index 4921f1e..a479c69 100644 --- a/src/UESaveFile/BinaryWriter.h +++ b/src/UESaveFile/BinaryWriter.h @@ -16,6 +16,7 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . +#include #include #include @@ -23,10 +24,7 @@ #include #include -#include - using namespace Corrade; -using namespace Magnum; class BinaryWriter { public: @@ -43,23 +41,23 @@ class BinaryWriter { void closeFile(); - Long position(); + std::int64_t position(); Containers::ArrayView array() const; - UnsignedLong arrayPosition() const; + std::size_t arrayPosition() const; bool flushToFile(); - 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 writeInt8(std::int8_t value); + bool writeUint8(std::uint8_t value); + bool writeInt16(std::int16_t value); + bool writeUint16(std::uint16_t value); + bool writeInt32(std::int32_t value); + bool writeUint32(std::uint32_t value); + bool writeInt64(std::int64_t value); + bool writeUint64(std::uint64_t value); + bool writeFloat(float value); + bool writeDouble(double value); bool writeArray(Containers::ArrayView array); template bool writeString(const char(&str)[size]) { @@ -74,30 +72,30 @@ class BinaryWriter { bool writeUEString(Containers::StringView str); template::value, T, T&>> - UnsignedLong writeValueToArray(U value) { + std::size_t writeValueToArray(U value) { Containers::ArrayView view{&value, 1}; return writeDataToArray(view); } - UnsignedLong writeUEStringToArray(Containers::StringView value); + std::size_t writeUEStringToArray(Containers::StringView value); template - void writeValueToArrayAt(T& value, UnsignedLong position) { + void writeValueToArrayAt(T& value, std::size_t position) { Containers::ArrayView view{&value, 1}; writeDataToArrayAt(view, position); } template - UnsignedLong writeDataToArray(Containers::ArrayView view) { + std::size_t writeDataToArray(Containers::ArrayView view) { arrayAppend(_data, Containers::arrayCast(view)); _index += sizeof(T) * view.size(); return sizeof(T) * view.size(); } template - void writeDataToArrayAt(Containers::ArrayView view, UnsignedLong position) { + void writeDataToArrayAt(Containers::ArrayView view, std::size_t position) { auto casted_view = Containers::arrayCast(view); - for(UnsignedLong i = 0; i < casted_view.size(); i++) { + for(std::size_t i = 0; i < casted_view.size(); i++) { _data[position + i] = casted_view[i]; } } @@ -106,5 +104,5 @@ class BinaryWriter { FILE* _file = nullptr; Containers::Array _data; - UnsignedLong _index = 0; + std::size_t _index = 0; }; diff --git a/src/UESaveFile/PropertySerialiser.cpp b/src/UESaveFile/PropertySerialiser.cpp index 775189f..41e3d47 100644 --- a/src/UESaveFile/PropertySerialiser.cpp +++ b/src/UESaveFile/PropertySerialiser.cpp @@ -93,8 +93,8 @@ PropertySerialiser::read(BinaryReader& reader) { return nullptr; } - UnsignedLong value_length; - if(!reader.readUnsignedLong(value_length)) { + std::size_t value_length; + if(!reader.readUint64(value_length)) { return nullptr; } @@ -102,7 +102,7 @@ PropertySerialiser::read(BinaryReader& reader) { } UnrealPropertyBase::ptr -PropertySerialiser::readItem(BinaryReader& reader, Containers::String type, UnsignedLong value_length, +PropertySerialiser::readItem(BinaryReader& reader, Containers::String type, std::size_t value_length, Containers::String name) { if(reader.peekChar() < 0 || reader.eof()) { @@ -113,7 +113,7 @@ PropertySerialiser::readItem(BinaryReader& reader, Containers::String type, Unsi } Containers::Array -PropertySerialiser::readSet(BinaryReader& reader, Containers::StringView item_type, UnsignedInt count) { +PropertySerialiser::readSet(BinaryReader& reader, Containers::StringView item_type, std::uint32_t count) { if(reader.peekChar() < 0 || reader.eof()) { return nullptr; } @@ -133,8 +133,8 @@ PropertySerialiser::readSet(BinaryReader& reader, Containers::StringView item_ty return nullptr; } - UnsignedLong value_length; - if(!reader.readUnsignedLong(value_length)) { + std::size_t value_length; + if(!reader.readUint64(value_length)) { return nullptr; } @@ -147,8 +147,8 @@ PropertySerialiser::readSet(BinaryReader& reader, Containers::StringView item_ty } } else { - for(UnsignedInt i = 0; i < count; i++) { - auto item = readItem(reader, item_type, UnsignedLong(-1), ""); + for(std::uint32_t i = 0; i < count; i++) { + auto item = readItem(reader, item_type, std::size_t(-1), ""); arrayAppend(array, std::move(item)); } } @@ -157,7 +157,7 @@ PropertySerialiser::readSet(BinaryReader& reader, Containers::StringView item_ty } UnrealPropertyBase::ptr -PropertySerialiser::deserialise(Containers::String name, Containers::String type, UnsignedLong value_length, +PropertySerialiser::deserialise(Containers::String name, Containers::String type, std::size_t value_length, BinaryReader& reader) { UnrealPropertyBase::ptr prop; @@ -181,7 +181,7 @@ PropertySerialiser::deserialise(Containers::String name, Containers::String type } bool PropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, Containers::StringView item_type, - UnsignedLong& bytes_written, BinaryWriter& writer) + std::size_t& bytes_written, BinaryWriter& writer) { auto serialiser = getSerialiser(item_type); if(!serialiser) { @@ -191,7 +191,7 @@ bool PropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, Containers::St } bool -PropertySerialiser::write(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer) { +PropertySerialiser::write(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer) { if(prop->name == "None" && prop->propertyType == "NoneProperty" && dynamic_cast(prop.get())) { bytes_written += writer.writeUEStringToArray(*prop->name); return true; @@ -200,10 +200,10 @@ PropertySerialiser::write(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_wri bytes_written += writer.writeUEStringToArray(*prop->name); bytes_written += writer.writeUEStringToArray(prop->propertyType); - UnsignedLong value_length = 0; - UnsignedLong vl_position = writer.arrayPosition(); + std::size_t value_length = 0; + std::size_t vl_position = writer.arrayPosition(); - bytes_written += writer.writeValueToArray(value_length); + bytes_written += writer.writeValueToArray(value_length); bool ret = serialise(prop, prop->propertyType, value_length, writer); @@ -216,7 +216,7 @@ PropertySerialiser::write(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_wri bool PropertySerialiser::writeItem(UnrealPropertyBase::ptr& prop, Containers::StringView item_type, - UnsignedLong& bytes_written, BinaryWriter& writer) + std::size_t& bytes_written, BinaryWriter& writer) { if(prop->name == "None" && prop->propertyType == "NoneProperty" && dynamic_cast(prop.get())) { bytes_written += writer.writeUEStringToArray(*prop->name); @@ -227,7 +227,7 @@ PropertySerialiser::writeItem(UnrealPropertyBase::ptr& prop, Containers::StringV } bool PropertySerialiser::writeSet(Containers::ArrayView props, - Containers::StringView item_type, UnsignedLong& bytes_written, BinaryWriter& writer) + Containers::StringView item_type, std::size_t& bytes_written, BinaryWriter& writer) { auto serialiser = getCollectionSerialiser(item_type); if(serialiser) { diff --git a/src/UESaveFile/PropertySerialiser.h b/src/UESaveFile/PropertySerialiser.h index 579e527..b726a2d 100644 --- a/src/UESaveFile/PropertySerialiser.h +++ b/src/UESaveFile/PropertySerialiser.h @@ -35,20 +35,20 @@ class PropertySerialiser { static PropertySerialiser& instance(); UnrealPropertyBase::ptr read(BinaryReader& reader); - UnrealPropertyBase::ptr readItem(BinaryReader& reader, Containers::String type, UnsignedLong value_length, + UnrealPropertyBase::ptr readItem(BinaryReader& reader, Containers::String type, std::size_t 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, + std::uint32_t count); + UnrealPropertyBase::ptr deserialise(Containers::String name, Containers::String type, std::size_t value_length, BinaryReader& reader); - bool serialise(UnrealPropertyBase::ptr& prop, Containers::StringView item_type, UnsignedLong& bytes_written, + bool serialise(UnrealPropertyBase::ptr& prop, Containers::StringView item_type, std::size_t& 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, + bool write(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer); + bool writeItem(UnrealPropertyBase::ptr& prop, Containers::StringView item_type, std::size_t& bytes_written, BinaryWriter& writer); bool writeSet(Containers::ArrayView props, Containers::StringView item_type, - UnsignedLong& bytes_written, BinaryWriter& writer); + std::size_t& bytes_written, BinaryWriter& writer); private: PropertySerialiser(); diff --git a/src/UESaveFile/Serialisers/AbstractUnrealCollectionPropertySerialiser.h b/src/UESaveFile/Serialisers/AbstractUnrealCollectionPropertySerialiser.h index a798222..61dd1c9 100644 --- a/src/UESaveFile/Serialisers/AbstractUnrealCollectionPropertySerialiser.h +++ b/src/UESaveFile/Serialisers/AbstractUnrealCollectionPropertySerialiser.h @@ -21,12 +21,9 @@ #include #include -#include - #include "../Types/UnrealPropertyBase.h" using namespace Corrade; -using namespace Magnum; class BinaryReader; class BinaryWriter; @@ -44,9 +41,9 @@ class AbstractUnrealCollectionPropertySerialiser { virtual StringArrayView types() = 0; virtual PropertyArray deserialise(Containers::StringView name, Containers::StringView type, - UnsignedLong value_length, UnsignedInt count, BinaryReader& reader, + std::size_t value_length, std::uint32_t 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; + virtual bool serialise(Containers::ArrayView props, Containers::StringView item_type, + std::size_t& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) = 0; }; diff --git a/src/UESaveFile/Serialisers/AbstractUnrealPropertySerialiser.h b/src/UESaveFile/Serialisers/AbstractUnrealPropertySerialiser.h index cd68b5e..bf6dac4 100644 --- a/src/UESaveFile/Serialisers/AbstractUnrealPropertySerialiser.h +++ b/src/UESaveFile/Serialisers/AbstractUnrealPropertySerialiser.h @@ -20,12 +20,9 @@ #include #include -#include - #include "../Types/UnrealPropertyBase.h" using namespace Corrade; -using namespace Magnum; class BinaryReader; class BinaryWriter; @@ -42,9 +39,9 @@ class AbstractUnrealPropertySerialiser { virtual StringArrayView types() = 0; virtual UnrealPropertyBase::ptr deserialise(Containers::StringView name, Containers::StringView type, - UnsignedLong value_length, BinaryReader& reader, + std::size_t value_length, BinaryReader& reader, PropertySerialiser& serialiser) = 0; - virtual bool serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, + virtual bool serialise(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) = 0; }; diff --git a/src/UESaveFile/Serialisers/AbstractUnrealStructSerialiser.h b/src/UESaveFile/Serialisers/AbstractUnrealStructSerialiser.h index c7e9827..3db3909 100644 --- a/src/UESaveFile/Serialisers/AbstractUnrealStructSerialiser.h +++ b/src/UESaveFile/Serialisers/AbstractUnrealStructSerialiser.h @@ -21,12 +21,9 @@ #include #include -#include - #include "../Types/UnrealPropertyBase.h" using namespace Corrade; -using namespace Magnum; class BinaryReader; class BinaryWriter; @@ -41,6 +38,5 @@ class AbstractUnrealStructSerialiser { virtual UnrealPropertyBase::ptr deserialise(BinaryReader& reader) = 0; - virtual bool serialise(UnrealPropertyBase::ptr& structProp, BinaryWriter& writer, - UnsignedLong& bytes_written) = 0; + virtual bool serialise(UnrealPropertyBase::ptr& structProp, BinaryWriter& writer, std::size_t& bytes_written) = 0; }; diff --git a/src/UESaveFile/Serialisers/ArrayPropertySerialiser.cpp b/src/UESaveFile/Serialisers/ArrayPropertySerialiser.cpp index 1b06824..b106d28 100644 --- a/src/UESaveFile/Serialisers/ArrayPropertySerialiser.cpp +++ b/src/UESaveFile/Serialisers/ArrayPropertySerialiser.cpp @@ -25,7 +25,7 @@ UnrealPropertyBase::ptr ArrayPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type, - UnsignedLong value_length, BinaryReader& reader, + std::size_t value_length, BinaryReader& reader, PropertySerialiser& serialiser) { Containers::String item_type; @@ -40,8 +40,8 @@ ArrayPropertySerialiser::deserialiseProperty(Containers::StringView name, Contai return nullptr; } - UnsignedInt item_count; - if(!reader.readUnsignedInt(item_count)) { + std::uint32_t item_count; + if(!reader.readUint32(item_count)) { LOG_ERROR_FORMAT("Couldn't read array property {}'s item count.", name); return nullptr; } @@ -54,7 +54,7 @@ ArrayPropertySerialiser::deserialiseProperty(Containers::StringView name, Contai } bool -ArrayPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, +ArrayPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) { auto array_prop = dynamic_cast(prop.get()); @@ -65,10 +65,10 @@ ArrayPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, Unsign writer.writeUEStringToArray(array_prop->itemType); writer.writeValueToArray('\0'); - bytes_written += writer.writeValueToArray(UnsignedInt(array_prop->items.size())); + bytes_written += writer.writeValueToArray(std::uint32_t(array_prop->items.size())); - UnsignedLong start_pos = writer.arrayPosition(); - UnsignedLong dummy_bytes_written = 0; + std::size_t start_pos = writer.arrayPosition(); + std::size_t dummy_bytes_written = 0; bool ret = serialiser.writeSet(array_prop->items, array_prop->itemType, dummy_bytes_written, writer); bytes_written += writer.arrayPosition() - start_pos; diff --git a/src/UESaveFile/Serialisers/ArrayPropertySerialiser.h b/src/UESaveFile/Serialisers/ArrayPropertySerialiser.h index 7d7eef1..7480ff5 100644 --- a/src/UESaveFile/Serialisers/ArrayPropertySerialiser.h +++ b/src/UESaveFile/Serialisers/ArrayPropertySerialiser.h @@ -18,14 +18,11 @@ #include -#include - #include "UnrealPropertySerialiser.h" #include "../Types/ArrayProperty.h" using namespace Corrade; -using namespace Magnum; class ArrayPropertySerialiser : public UnrealPropertySerialiser { public: @@ -33,8 +30,8 @@ class ArrayPropertySerialiser : public UnrealPropertySerialiser { private: UnrealPropertyBase::ptr deserialiseProperty(Containers::StringView name, Containers::StringView type, - UnsignedLong value_length, BinaryReader& reader, + std::size_t value_length, BinaryReader& reader, PropertySerialiser& serialiser) override; - bool serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, + bool serialiseProperty(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) override; }; diff --git a/src/UESaveFile/Serialisers/BoolPropertySerialiser.cpp b/src/UESaveFile/Serialisers/BoolPropertySerialiser.cpp index b4b689b..b2cbfcb 100644 --- a/src/UESaveFile/Serialisers/BoolPropertySerialiser.cpp +++ b/src/UESaveFile/Serialisers/BoolPropertySerialiser.cpp @@ -28,7 +28,7 @@ BoolPropertySerialiser::types() { } UnrealPropertyBase::ptr -BoolPropertySerialiser::deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length, +BoolPropertySerialiser::deserialise(Containers::StringView name, Containers::StringView type, std::size_t value_length, BinaryReader& reader, PropertySerialiser& serialiser) { if(value_length != 0) { @@ -36,8 +36,8 @@ BoolPropertySerialiser::deserialise(Containers::StringView name, Containers::Str return nullptr; } - Short value; - if(!reader.readShort(value)) { + std::int16_t value; + if(!reader.readInt16(value)) { LOG_ERROR_FORMAT("Couldn't read bool property {}'s value.", name); return nullptr; } @@ -54,7 +54,7 @@ BoolPropertySerialiser::deserialise(Containers::StringView name, Containers::Str } bool -BoolPropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, +BoolPropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) { auto bool_prop = dynamic_cast(prop.get()); @@ -63,7 +63,7 @@ BoolPropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& b return false; } - writer.writeValueToArray(Short(bool_prop->value)); + writer.writeValueToArray(std::int16_t(bool_prop->value)); return true; } diff --git a/src/UESaveFile/Serialisers/BoolPropertySerialiser.h b/src/UESaveFile/Serialisers/BoolPropertySerialiser.h index 2507313..163cf9d 100644 --- a/src/UESaveFile/Serialisers/BoolPropertySerialiser.h +++ b/src/UESaveFile/Serialisers/BoolPropertySerialiser.h @@ -32,9 +32,9 @@ class BoolPropertySerialiser : public AbstractUnrealPropertySerialiser { StringArrayView types() override; UnrealPropertyBase::ptr deserialise(Containers::StringView name, Containers::StringView type, - UnsignedLong value_length, BinaryReader& reader, + std::size_t value_length, BinaryReader& reader, PropertySerialiser& serialiser) override; - bool serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, + bool serialise(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) override; }; diff --git a/src/UESaveFile/Serialisers/BytePropertySerialiser.cpp b/src/UESaveFile/Serialisers/BytePropertySerialiser.cpp index fed7309..a5a1f94 100644 --- a/src/UESaveFile/Serialisers/BytePropertySerialiser.cpp +++ b/src/UESaveFile/Serialisers/BytePropertySerialiser.cpp @@ -28,12 +28,12 @@ BytePropertySerialiser::types() { } UnrealPropertyBase::ptr -BytePropertySerialiser::deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length, +BytePropertySerialiser::deserialise(Containers::StringView name, Containers::StringView type, std::size_t value_length, BinaryReader& reader, PropertySerialiser& serialiser) { auto prop = Containers::pointer(); - if(value_length != UnsignedLong(-1)) { + if(value_length != std::size_t(-1)) { if(!reader.readUEString(prop->enumType)) { LOG_ERROR_FORMAT("Couldn't read byte property {}'s enum type.", name); return nullptr; @@ -53,8 +53,8 @@ BytePropertySerialiser::deserialise(Containers::StringView name, Containers::Str prop->valueLength = value_length; - //UnsignedInt count = 0; - //if(!reader.readUnsignedInt(count)) { + //std::uint32_t count = 0; + //if(!reader.readstd::uint32_t(count)) { // return nullptr; //} @@ -66,7 +66,7 @@ BytePropertySerialiser::deserialise(Containers::StringView name, Containers::Str } bool -BytePropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, +BytePropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) { auto byte_prop = dynamic_cast(prop.get()); @@ -76,10 +76,10 @@ BytePropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& b } //writer.writeValueToArray('\0'); - //bytes_written += writer.writeValueToArray(byte_prop->value.size()); + //bytes_written += writer.writeValueToArray(byte_prop->value.size()); //bytes_written += writer.writeDataToArray(byte_prop->value); - if(byte_prop->valueLength != UnsignedLong(-1)) { + if(byte_prop->valueLength != std::size_t(-1)) { writer.writeUEStringToArray(byte_prop->enumType); writer.writeValueToArray('\0'); } diff --git a/src/UESaveFile/Serialisers/BytePropertySerialiser.h b/src/UESaveFile/Serialisers/BytePropertySerialiser.h index 4e1ff71..b8775ad 100644 --- a/src/UESaveFile/Serialisers/BytePropertySerialiser.h +++ b/src/UESaveFile/Serialisers/BytePropertySerialiser.h @@ -30,9 +30,9 @@ class BytePropertySerialiser : public AbstractUnrealPropertySerialiser { StringArrayView types() override; UnrealPropertyBase::ptr deserialise(Containers::StringView name, Containers::StringView type, - UnsignedLong value_length, BinaryReader& reader, + std::size_t value_length, BinaryReader& reader, PropertySerialiser& serialiser) override; - bool serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, + bool serialise(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) override; }; diff --git a/src/UESaveFile/Serialisers/ColourPropertySerialiser.cpp b/src/UESaveFile/Serialisers/ColourPropertySerialiser.cpp index 4972cd7..df0000d 100644 --- a/src/UESaveFile/Serialisers/ColourPropertySerialiser.cpp +++ b/src/UESaveFile/Serialisers/ColourPropertySerialiser.cpp @@ -22,7 +22,7 @@ UnrealPropertyBase::ptr ColourPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type, - UnsignedLong value_length, BinaryReader& reader, + std::size_t value_length, BinaryReader& reader, PropertySerialiser& serialiser) { auto prop = Containers::pointer(); @@ -38,7 +38,7 @@ ColourPropertySerialiser::deserialiseProperty(Containers::StringView name, Conta } bool -ColourPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, +ColourPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) { auto colour_prop = dynamic_cast(prop.get()); @@ -47,10 +47,10 @@ ColourPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, Unsig 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 f137eee..4cc375b 100644 --- a/src/UESaveFile/Serialisers/ColourPropertySerialiser.h +++ b/src/UESaveFile/Serialisers/ColourPropertySerialiser.h @@ -30,8 +30,8 @@ class ColourPropertySerialiser : public UnrealPropertySerialiser(); - if(!reader.readUnsignedLong(prop->timestamp)) { + if(!reader.readInt64(prop->timestamp)) { LOG_ERROR_FORMAT("Couldn't read date/time property {}'s value.", name); return nullptr; } @@ -36,7 +36,7 @@ DateTimePropertySerialiser::deserialiseProperty(Containers::StringView name, Con } bool -DateTimePropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, +DateTimePropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) { auto dt_prop = dynamic_cast(prop.get()); @@ -45,7 +45,7 @@ DateTimePropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, Uns return false; } - bytes_written += writer.writeValueToArray(dt_prop->timestamp); + bytes_written += writer.writeValueToArray(dt_prop->timestamp); return true; } diff --git a/src/UESaveFile/Serialisers/DateTimePropertySerialiser.h b/src/UESaveFile/Serialisers/DateTimePropertySerialiser.h index 78e3bfd..54e71b4 100644 --- a/src/UESaveFile/Serialisers/DateTimePropertySerialiser.h +++ b/src/UESaveFile/Serialisers/DateTimePropertySerialiser.h @@ -28,8 +28,8 @@ class DateTimePropertySerialiser : public UnrealPropertySerialiser(); @@ -53,7 +53,7 @@ EnumPropertySerialiser::deserialise(Containers::StringView name, Containers::Str } bool -EnumPropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, +EnumPropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) { auto enum_prop = dynamic_cast(prop.get()); diff --git a/src/UESaveFile/Serialisers/EnumPropertySerialiser.h b/src/UESaveFile/Serialisers/EnumPropertySerialiser.h index c2874a3..67a6ab8 100644 --- a/src/UESaveFile/Serialisers/EnumPropertySerialiser.h +++ b/src/UESaveFile/Serialisers/EnumPropertySerialiser.h @@ -30,9 +30,9 @@ class EnumPropertySerialiser : public AbstractUnrealPropertySerialiser { StringArrayView types() override; UnrealPropertyBase::ptr deserialise(Containers::StringView name, Containers::StringView type, - UnsignedLong value_length, BinaryReader& reader, + std::size_t value_length, BinaryReader& reader, PropertySerialiser& serialiser) override; - bool serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, + bool serialise(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) override; }; diff --git a/src/UESaveFile/Serialisers/FloatPropertySerialiser.cpp b/src/UESaveFile/Serialisers/FloatPropertySerialiser.cpp index 0d229d9..5d2a2cf 100644 --- a/src/UESaveFile/Serialisers/FloatPropertySerialiser.cpp +++ b/src/UESaveFile/Serialisers/FloatPropertySerialiser.cpp @@ -29,7 +29,7 @@ FloatPropertySerialiser::types() { UnrealPropertyBase::ptr FloatPropertySerialiser::deserialise(Containers::StringView name, Containers::StringView type, - UnsignedLong value_length, BinaryReader& reader, PropertySerialiser& serialiser) + std::size_t value_length, BinaryReader& reader, PropertySerialiser& serialiser) { auto prop = Containers::pointer(); @@ -48,7 +48,7 @@ FloatPropertySerialiser::deserialise(Containers::StringView name, Containers::St } bool -FloatPropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, +FloatPropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) { auto float_prop = dynamic_cast(prop.get()); @@ -58,7 +58,7 @@ FloatPropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& } writer.writeValueToArray('\0'); - bytes_written += writer.writeValueToArray(float_prop->value); + bytes_written += writer.writeValueToArray(float_prop->value); return true; } diff --git a/src/UESaveFile/Serialisers/FloatPropertySerialiser.h b/src/UESaveFile/Serialisers/FloatPropertySerialiser.h index 9ec5741..d1dea25 100644 --- a/src/UESaveFile/Serialisers/FloatPropertySerialiser.h +++ b/src/UESaveFile/Serialisers/FloatPropertySerialiser.h @@ -30,9 +30,9 @@ class FloatPropertySerialiser : public AbstractUnrealPropertySerialiser { StringArrayView types() override; UnrealPropertyBase::ptr deserialise(Containers::StringView name, Containers::StringView type, - UnsignedLong value_length, BinaryReader& reader, + std::size_t value_length, BinaryReader& reader, PropertySerialiser& serialiser) override; - bool serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, + bool serialise(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) override; }; diff --git a/src/UESaveFile/Serialisers/GuidPropertySerialiser.cpp b/src/UESaveFile/Serialisers/GuidPropertySerialiser.cpp index d70aefa..811196b 100644 --- a/src/UESaveFile/Serialisers/GuidPropertySerialiser.cpp +++ b/src/UESaveFile/Serialisers/GuidPropertySerialiser.cpp @@ -24,7 +24,7 @@ using namespace Containers::Literals; UnrealPropertyBase::ptr GuidPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type, - UnsignedLong value_length, BinaryReader& reader, + std::size_t value_length, BinaryReader& reader, PropertySerialiser& serialiser) { auto prop = Containers::pointer(); @@ -38,7 +38,7 @@ GuidPropertySerialiser::deserialiseProperty(Containers::StringView name, Contain } bool -GuidPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, +GuidPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) { auto guid_prop = dynamic_cast(prop.get()); diff --git a/src/UESaveFile/Serialisers/GuidPropertySerialiser.h b/src/UESaveFile/Serialisers/GuidPropertySerialiser.h index 6094f83..506986e 100644 --- a/src/UESaveFile/Serialisers/GuidPropertySerialiser.h +++ b/src/UESaveFile/Serialisers/GuidPropertySerialiser.h @@ -28,8 +28,8 @@ class GuidPropertySerialiser : public UnrealPropertySerialiser(); - if(value_length == UnsignedLong(-1)) { - if(!reader.readInt(prop->value)) { + if(value_length == std::size_t(-1)) { + if(!reader.readInt32(prop->value)) { LOG_ERROR("Couldn't read int property's value."); return nullptr; } - prop->valueLength = UnsignedLong(-1); + prop->valueLength = std::size_t(-1); return prop; } @@ -43,7 +43,7 @@ IntPropertySerialiser::deserialiseProperty(Containers::StringView name, Containe return nullptr; } - if(!reader.readInt(prop->value)) { + if(!reader.readInt32(prop->value)) { LOG_ERROR_FORMAT("Couldn't read int property {}'s value.", name); return nullptr; } @@ -54,7 +54,7 @@ IntPropertySerialiser::deserialiseProperty(Containers::StringView name, Containe } bool -IntPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, +IntPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) { auto int_prop = dynamic_cast(prop.get()); @@ -63,11 +63,11 @@ IntPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, Unsigned return false; } - if(prop->valueLength != UnsignedLong(-1)) { + if(prop->valueLength != std::size_t(-1)) { writer.writeValueToArray('\0'); } - bytes_written += writer.writeValueToArray(int_prop->value); + bytes_written += writer.writeValueToArray(int_prop->value); return true; } diff --git a/src/UESaveFile/Serialisers/IntPropertySerialiser.h b/src/UESaveFile/Serialisers/IntPropertySerialiser.h index 6b8ef46..2d05b40 100644 --- a/src/UESaveFile/Serialisers/IntPropertySerialiser.h +++ b/src/UESaveFile/Serialisers/IntPropertySerialiser.h @@ -28,8 +28,8 @@ class IntPropertySerialiser : public UnrealPropertySerialiser { private: UnrealPropertyBase::ptr deserialiseProperty(Containers::StringView name, Containers::StringView type, - UnsignedLong value_length, BinaryReader& reader, + std::size_t value_length, BinaryReader& reader, PropertySerialiser& serialiser) override; - bool serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, + bool serialiseProperty(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) override; }; diff --git a/src/UESaveFile/Serialisers/MapPropertySerialiser.cpp b/src/UESaveFile/Serialisers/MapPropertySerialiser.cpp index 7692575..0baa805 100644 --- a/src/UESaveFile/Serialisers/MapPropertySerialiser.cpp +++ b/src/UESaveFile/Serialisers/MapPropertySerialiser.cpp @@ -26,7 +26,7 @@ using namespace Containers::Literals; UnrealPropertyBase::ptr MapPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type, - UnsignedLong value_length, BinaryReader& reader, + std::size_t value_length, BinaryReader& reader, PropertySerialiser& serialiser) { auto prop = Containers::pointer(); @@ -47,14 +47,14 @@ MapPropertySerialiser::deserialiseProperty(Containers::StringView name, Containe return nullptr; } - UnsignedInt null; - if(!reader.readUnsignedInt(null) || null != 0u) { + std::uint32_t null; + if(!reader.readUint32(null) || null != 0u) { LOG_ERROR_FORMAT("Couldn't read a null int in map property {}.", name); return nullptr; } - UnsignedInt count; - if(!reader.readUnsignedInt(count)) { + std::uint32_t count; + if(!reader.readUint32(count)) { LOG_ERROR_FORMAT("Couldn't read map property {}'s item count.", name); return nullptr; } @@ -64,7 +64,7 @@ MapPropertySerialiser::deserialiseProperty(Containers::StringView name, Containe arrayReserve(prop->map, count); - for(UnsignedInt i = 0; i < count; i++) { + for(std::uint32_t i = 0; i < count; i++) { MapProperty::KeyValuePair pair; if(prop->keyType == "IntProperty"_s || prop->keyType == "StrProperty"_s) { @@ -109,7 +109,7 @@ MapPropertySerialiser::deserialiseProperty(Containers::StringView name, Containe } bool -MapPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, +MapPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) { auto map_prop = dynamic_cast(prop.get()); @@ -122,12 +122,12 @@ MapPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, Unsigned writer.writeUEStringToArray(map_prop->valueType); writer.writeValueToArray('\0'); - UnsignedLong value_start = writer.arrayPosition(); - writer.writeValueToArray(0u); + std::size_t value_start = writer.arrayPosition(); + writer.writeValueToArray(0u); - writer.writeValueToArray(UnsignedInt(map_prop->map.size())); + writer.writeValueToArray(std::uint32_t(map_prop->map.size())); - UnsignedLong dummy_bytes_written = 0; + std::size_t dummy_bytes_written = 0; for(auto& pair : map_prop->map) { if(!serialiser.writeItem(pair.key, map_prop->keyType, dummy_bytes_written, writer)) { LOG_ERROR("Couldn't write a key."); diff --git a/src/UESaveFile/Serialisers/MapPropertySerialiser.h b/src/UESaveFile/Serialisers/MapPropertySerialiser.h index c6150aa..447a0e9 100644 --- a/src/UESaveFile/Serialisers/MapPropertySerialiser.h +++ b/src/UESaveFile/Serialisers/MapPropertySerialiser.h @@ -28,8 +28,8 @@ class MapPropertySerialiser : public UnrealPropertySerialiser { private: UnrealPropertyBase::ptr deserialiseProperty(Containers::StringView name, Containers::StringView type, - UnsignedLong value_length, BinaryReader& reader, + std::size_t value_length, BinaryReader& reader, PropertySerialiser& serialiser) override; - bool serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, + bool serialiseProperty(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) override; }; diff --git a/src/UESaveFile/Serialisers/ResourcePropertySerialiser.cpp b/src/UESaveFile/Serialisers/ResourcePropertySerialiser.cpp index 9a2ee48..23915ac 100644 --- a/src/UESaveFile/Serialisers/ResourcePropertySerialiser.cpp +++ b/src/UESaveFile/Serialisers/ResourcePropertySerialiser.cpp @@ -27,7 +27,7 @@ using namespace Containers::Literals; UnrealPropertyBase::ptr ResourcePropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type, - UnsignedLong value_length, BinaryReader& reader, + std::size_t value_length, BinaryReader& reader, PropertySerialiser& serialiser) { auto prop = Containers::pointer(); @@ -79,7 +79,7 @@ ResourcePropertySerialiser::deserialiseProperty(Containers::StringView name, Con } bool -ResourcePropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, +ResourcePropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) { auto res_prop = dynamic_cast(prop.get()); @@ -90,15 +90,15 @@ ResourcePropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, Uns bytes_written += writer.writeUEStringToArray("ID_4_AAE08F17428E229EC7A2209F51081A21"_s) + writer.writeUEStringToArray("IntProperty"_s) + - writer.writeValueToArray(4ull) + + writer.writeValueToArray(4ull) + writer.writeValueToArray('\0') + - writer.writeValueToArray(res_prop->id); + writer.writeValueToArray(res_prop->id); bytes_written += writer.writeUEStringToArray("Quantity_3_560F09B5485C365D3041888910019CE3"_s) + writer.writeUEStringToArray("IntProperty"_s) + - writer.writeValueToArray(4ull) + + writer.writeValueToArray(4ull) + writer.writeValueToArray('\0') + - writer.writeValueToArray(res_prop->quantity); + writer.writeValueToArray(res_prop->quantity); bytes_written += writer.writeUEStringToArray("None"_s); diff --git a/src/UESaveFile/Serialisers/ResourcePropertySerialiser.h b/src/UESaveFile/Serialisers/ResourcePropertySerialiser.h index 8053327..488f769 100644 --- a/src/UESaveFile/Serialisers/ResourcePropertySerialiser.h +++ b/src/UESaveFile/Serialisers/ResourcePropertySerialiser.h @@ -28,8 +28,8 @@ class ResourcePropertySerialiser : public UnrealPropertySerialiser(); @@ -36,7 +36,7 @@ RotatorPropertySerialiser::deserialiseProperty(Containers::StringView name, Cont } bool -RotatorPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, +RotatorPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) { auto rotator = dynamic_cast(prop.get()); @@ -45,8 +45,8 @@ RotatorPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, Unsi return false; } - bytes_written += writer.writeValueToArray(rotator->x) + writer.writeValueToArray(rotator->y) + - writer.writeValueToArray(rotator->z); + bytes_written += writer.writeValueToArray(rotator->x) + writer.writeValueToArray(rotator->y) + + writer.writeValueToArray(rotator->z); return true; } diff --git a/src/UESaveFile/Serialisers/RotatorPropertySerialiser.h b/src/UESaveFile/Serialisers/RotatorPropertySerialiser.h index 1ef9349..08d7714 100644 --- a/src/UESaveFile/Serialisers/RotatorPropertySerialiser.h +++ b/src/UESaveFile/Serialisers/RotatorPropertySerialiser.h @@ -28,8 +28,8 @@ class RotatorPropertySerialiser : public UnrealPropertySerialiser(prop.get()); @@ -70,11 +70,11 @@ SetPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, Unsigned writer.writeUEStringToArray(set_prop->itemType); writer.writeValueToArray('\0'); - bytes_written += writer.writeValueToArray(0u); - bytes_written += writer.writeValueToArray(UnsignedInt(set_prop->items.size())); + bytes_written += writer.writeValueToArray(0u); + bytes_written += writer.writeValueToArray(std::uint32_t(set_prop->items.size())); - UnsignedLong start_pos = writer.arrayPosition(); - UnsignedLong dummy_bytes_written = 0; + std::size_t start_pos = writer.arrayPosition(); + std::size_t dummy_bytes_written = 0; serialiser.writeSet(set_prop->items, set_prop->itemType, dummy_bytes_written, writer); bytes_written += writer.arrayPosition() - start_pos; diff --git a/src/UESaveFile/Serialisers/SetPropertySerialiser.h b/src/UESaveFile/Serialisers/SetPropertySerialiser.h index 84ed8e5..1bec9b8 100644 --- a/src/UESaveFile/Serialisers/SetPropertySerialiser.h +++ b/src/UESaveFile/Serialisers/SetPropertySerialiser.h @@ -28,8 +28,8 @@ class SetPropertySerialiser : public UnrealPropertySerialiser { private: UnrealPropertyBase::ptr deserialiseProperty(Containers::StringView name, Containers::StringView type, - UnsignedLong value_length, BinaryReader& reader, + std::size_t value_length, BinaryReader& reader, PropertySerialiser& serialiser) override; - bool serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, + bool serialiseProperty(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) override; }; diff --git a/src/UESaveFile/Serialisers/StringPropertySerialiser.cpp b/src/UESaveFile/Serialisers/StringPropertySerialiser.cpp index 4c5f210..d645cfc 100644 --- a/src/UESaveFile/Serialisers/StringPropertySerialiser.cpp +++ b/src/UESaveFile/Serialisers/StringPropertySerialiser.cpp @@ -31,11 +31,11 @@ StringPropertySerialiser::types() { UnrealPropertyBase::ptr StringPropertySerialiser::deserialise(Containers::StringView name, Containers::StringView type, - UnsignedLong value_length, BinaryReader& reader, PropertySerialiser& serialiser) + std::size_t value_length, BinaryReader& reader, PropertySerialiser& serialiser) { auto prop = Containers::pointer(type); - if(value_length != UnsignedLong(-1)) { + if(value_length != std::size_t(-1)) { char terminator; if(!reader.readChar(terminator) || terminator != '\0') { LOG_ERROR_FORMAT("Couldn't read a null byte in string property {}.", name); @@ -54,7 +54,7 @@ StringPropertySerialiser::deserialise(Containers::StringView name, Containers::S } bool -StringPropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, +StringPropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) { auto str_prop = dynamic_cast(prop.get()); @@ -63,7 +63,7 @@ StringPropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& return false; } - if(str_prop->valueLength != UnsignedLong(-1)) { + if(str_prop->valueLength != std::size_t(-1)) { writer.writeValueToArray('\0'); } diff --git a/src/UESaveFile/Serialisers/StringPropertySerialiser.h b/src/UESaveFile/Serialisers/StringPropertySerialiser.h index 685dfbf..779a086 100644 --- a/src/UESaveFile/Serialisers/StringPropertySerialiser.h +++ b/src/UESaveFile/Serialisers/StringPropertySerialiser.h @@ -30,9 +30,9 @@ class StringPropertySerialiser : public AbstractUnrealPropertySerialiser { StringArrayView types() override; UnrealPropertyBase::ptr deserialise(Containers::StringView name, Containers::StringView type, - UnsignedLong value_length, BinaryReader& reader, + std::size_t value_length, BinaryReader& reader, PropertySerialiser& serialiser) override; - bool serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, + bool serialise(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) override; }; diff --git a/src/UESaveFile/Serialisers/StructSerialiser.cpp b/src/UESaveFile/Serialisers/StructSerialiser.cpp index fe2e306..3c628cf 100644 --- a/src/UESaveFile/Serialisers/StructSerialiser.cpp +++ b/src/UESaveFile/Serialisers/StructSerialiser.cpp @@ -33,8 +33,8 @@ StructSerialiser::types() { } Containers::Array -StructSerialiser::deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length, - UnsignedInt count, BinaryReader& reader, PropertySerialiser& serialiser) +StructSerialiser::deserialise(Containers::StringView name, Containers::StringView type, std::size_t value_length, + std::uint32_t count, BinaryReader& reader, PropertySerialiser& serialiser) { Containers::String item_type; if(!reader.readUEString(item_type)) { @@ -62,10 +62,10 @@ StructSerialiser::deserialise(Containers::StringView name, Containers::StringVie prop->structGuid = std::move(guid); } else { - for(UnsignedInt i = 0; i < count; i++) { + for(std::uint32_t i = 0; i < count; i++) { auto prop = Containers::pointer(); - prop = serialiser.readItem(reader, item_type, UnsignedLong(-1), name); + prop = serialiser.readItem(reader, item_type, std::size_t(-1), name); if(!prop) { prop = readStructValue(name, item_type, value_length, reader, serialiser); @@ -86,7 +86,7 @@ StructSerialiser::deserialise(Containers::StringView name, Containers::StringVie } UnrealPropertyBase::ptr -StructSerialiser::deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length, +StructSerialiser::deserialise(Containers::StringView name, Containers::StringView type, std::size_t value_length, BinaryReader& reader, PropertySerialiser& serialiser) { Containers::String item_type; @@ -125,12 +125,12 @@ StructSerialiser::deserialise(Containers::StringView name, Containers::StringVie bool StructSerialiser::serialise(Containers::ArrayView props, Containers::StringView item_type, - UnsignedLong& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) + std::size_t& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) { bytes_written += writer.writeUEStringToArray(*(props.front()->name)); bytes_written += writer.writeUEStringToArray(item_type); - UnsignedLong vl_pos = writer.arrayPosition(); - bytes_written += writer.writeValueToArray(0ull); + std::size_t vl_pos = writer.arrayPosition(); + bytes_written += writer.writeValueToArray(0ull); auto struct_prop = dynamic_cast(props.front().get()); if(!struct_prop) { @@ -142,9 +142,9 @@ StructSerialiser::serialise(Containers::ArrayView props bytes_written += writer.writeDataToArray(arrayView(struct_prop->structGuid)); bytes_written += writer.writeValueToArray('\0'); - UnsignedLong vl_start = writer.arrayPosition(); + std::size_t vl_start = writer.arrayPosition(); - UnsignedLong bytes_written_here = 0; + std::size_t bytes_written_here = 0; for(auto& prop : props) { struct_prop = dynamic_cast(prop.get()); if(!struct_prop) { @@ -160,7 +160,7 @@ StructSerialiser::serialise(Containers::ArrayView props } } - UnsignedLong vl_stop = writer.arrayPosition() - vl_start; + std::size_t vl_stop = writer.arrayPosition() - vl_start; writer.writeValueToArrayAt(vl_stop, vl_pos); bytes_written += vl_stop; @@ -168,7 +168,7 @@ StructSerialiser::serialise(Containers::ArrayView props } bool -StructSerialiser::serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, +StructSerialiser::serialise(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) { auto struct_prop = dynamic_cast(prop.get()); @@ -182,8 +182,8 @@ StructSerialiser::serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_w writer.writeValueToArray('\0'); if(!serialiser.writeItem(prop, struct_prop->structType, bytes_written, writer)) { - UnsignedLong dummy_bytes_written = 0; - UnsignedLong vl_start = writer.arrayPosition(); + std::size_t dummy_bytes_written = 0; + std::size_t vl_start = writer.arrayPosition(); if(!writeStructValue(struct_prop, dummy_bytes_written, writer, serialiser)) { LOG_ERROR("Couldn't write the struct value."); return false; @@ -195,7 +195,7 @@ StructSerialiser::serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_w } StructProperty::ptr -StructSerialiser::readStructValue(Containers::StringView name, Containers::StringView type, UnsignedLong value_length, +StructSerialiser::readStructValue(Containers::StringView name, Containers::StringView type, std::size_t value_length, BinaryReader& reader, PropertySerialiser& serialiser) { auto st_prop = Containers::pointer(); @@ -219,7 +219,7 @@ StructSerialiser::readStructValue(Containers::StringView name, Containers::Strin } bool -StructSerialiser::writeStructValue(StructProperty* prop, UnsignedLong& bytes_written, BinaryWriter& writer, +StructSerialiser::writeStructValue(StructProperty* prop, std::size_t& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) { auto struct_prop = dynamic_cast(prop); diff --git a/src/UESaveFile/Serialisers/StructSerialiser.h b/src/UESaveFile/Serialisers/StructSerialiser.h index 2de192d..96d6cab 100644 --- a/src/UESaveFile/Serialisers/StructSerialiser.h +++ b/src/UESaveFile/Serialisers/StructSerialiser.h @@ -31,21 +31,21 @@ class StructSerialiser : public AbstractUnrealPropertySerialiser, public Abstrac StringArrayView types() override; - PropertyArray deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length, - UnsignedInt count, BinaryReader& reader, PropertySerialiser& serialiser) override; + PropertyArray deserialise(Containers::StringView name, Containers::StringView type, std::size_t value_length, + std::uint32_t count, BinaryReader& reader, PropertySerialiser& serialiser) override; UnrealPropertyBase::ptr deserialise(Containers::StringView name, Containers::StringView type, - UnsignedLong value_length, BinaryReader& reader, + std::size_t value_length, BinaryReader& reader, PropertySerialiser& serialiser) override; - bool serialise(PropertyArrayView props, Containers::StringView item_type, UnsignedLong& bytes_written, + bool serialise(PropertyArrayView props, Containers::StringView item_type, std::size_t& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) override; - bool serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, + bool serialise(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) override; private: StructProperty::ptr readStructValue(Containers::StringView name, Containers::StringView type, - UnsignedLong value_length, BinaryReader& reader, + std::size_t value_length, BinaryReader& reader, PropertySerialiser& serialiser); - bool writeStructValue(StructProperty* prop, UnsignedLong& bytes_written, BinaryWriter& writer, + bool writeStructValue(StructProperty* prop, std::size_t& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser); } ; diff --git a/src/UESaveFile/Serialisers/TextPropertySerialiser.cpp b/src/UESaveFile/Serialisers/TextPropertySerialiser.cpp index a3e2329..09698ab 100644 --- a/src/UESaveFile/Serialisers/TextPropertySerialiser.cpp +++ b/src/UESaveFile/Serialisers/TextPropertySerialiser.cpp @@ -23,12 +23,12 @@ UnrealPropertyBase::ptr TextPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type, - UnsignedLong value_length, BinaryReader& reader, + std::size_t value_length, BinaryReader& reader, PropertySerialiser& serialiser) { auto prop = Containers::pointer(); - Long start_position = reader.position(); + auto start_position = reader.position(); char terminator; if(!reader.readChar(terminator) || terminator != '\0') { @@ -62,7 +62,7 @@ TextPropertySerialiser::deserialiseProperty(Containers::StringView name, Contain arrayAppend(prop->data, std::move(str)); interval = reader.position() - start_position; - } while(UnsignedLong(interval) < value_length); + } while(std::size_t(interval) < value_length); prop->value = prop->data.back(); @@ -70,7 +70,7 @@ TextPropertySerialiser::deserialiseProperty(Containers::StringView name, Contain } bool -TextPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, +TextPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, std::size_t& 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 08e1028..f349326 100644 --- a/src/UESaveFile/Serialisers/TextPropertySerialiser.h +++ b/src/UESaveFile/Serialisers/TextPropertySerialiser.h @@ -28,8 +28,8 @@ class TextPropertySerialiser : public UnrealPropertySerialiser { private: UnrealPropertyBase::ptr deserialiseProperty(Containers::StringView name, Containers::StringView type, - UnsignedLong value_length, BinaryReader& reader, + std::size_t value_length, BinaryReader& reader, PropertySerialiser& serialiser) override; - bool serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, + bool serialiseProperty(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) override; }; diff --git a/src/UESaveFile/Serialisers/UnrealPropertySerialiser.h b/src/UESaveFile/Serialisers/UnrealPropertySerialiser.h index 763d18f..1d3a7ab 100644 --- a/src/UESaveFile/Serialisers/UnrealPropertySerialiser.h +++ b/src/UESaveFile/Serialisers/UnrealPropertySerialiser.h @@ -50,13 +50,13 @@ class UnrealPropertySerialiser : public AbstractUnrealPropertySerialiser { } UnrealPropertyBase::ptr deserialise(Containers::StringView name, Containers::StringView type, - UnsignedLong value_length, BinaryReader& reader, + std::size_t value_length, BinaryReader& reader, PropertySerialiser& serialiser) override { return deserialiseProperty(name, type, value_length, reader, serialiser); } - bool serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, + bool serialise(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) override { return serialiseProperty(prop, bytes_written, writer, serialiser); @@ -64,9 +64,9 @@ class UnrealPropertySerialiser : public AbstractUnrealPropertySerialiser { private: virtual UnrealPropertyBase::ptr deserialiseProperty(Containers::StringView name, Containers::StringView type, - UnsignedLong value_length, BinaryReader& reader, + std::size_t value_length, BinaryReader& reader, PropertySerialiser& serialiser) = 0; - virtual bool serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, + virtual bool serialiseProperty(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) = 0; }; diff --git a/src/UESaveFile/Serialisers/Vector2DPropertySerialiser.cpp b/src/UESaveFile/Serialisers/Vector2DPropertySerialiser.cpp index 872e767..c42d3f9 100644 --- a/src/UESaveFile/Serialisers/Vector2DPropertySerialiser.cpp +++ b/src/UESaveFile/Serialisers/Vector2DPropertySerialiser.cpp @@ -22,7 +22,7 @@ UnrealPropertyBase::ptr Vector2DPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type, - UnsignedLong value_length, BinaryReader& reader, + std::size_t value_length, BinaryReader& reader, PropertySerialiser& serialiser) { auto prop = Containers::pointer(); @@ -36,7 +36,7 @@ Vector2DPropertySerialiser::deserialiseProperty(Containers::StringView name, Con } bool -Vector2DPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, +Vector2DPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) { auto vector = dynamic_cast(prop.get()); @@ -45,7 +45,7 @@ Vector2DPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, Uns return false; } - bytes_written += writer.writeValueToArray(vector->x) + writer.writeValueToArray(vector->y); + bytes_written += writer.writeValueToArray(vector->x) + writer.writeValueToArray(vector->y); return true; } diff --git a/src/UESaveFile/Serialisers/Vector2DPropertySerialiser.h b/src/UESaveFile/Serialisers/Vector2DPropertySerialiser.h index f6de167..b31ea51 100644 --- a/src/UESaveFile/Serialisers/Vector2DPropertySerialiser.h +++ b/src/UESaveFile/Serialisers/Vector2DPropertySerialiser.h @@ -28,8 +28,8 @@ class Vector2DPropertySerialiser : public UnrealPropertySerialiser(); @@ -36,7 +36,7 @@ VectorPropertySerialiser::deserialiseProperty(Containers::StringView name, Conta } bool -VectorPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, +VectorPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) { auto vector = dynamic_cast(prop.get()); @@ -45,8 +45,8 @@ VectorPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, Unsig return false; } - bytes_written += writer.writeValueToArray(vector->x) + writer.writeValueToArray(vector->y) + - writer.writeValueToArray(vector->z); + bytes_written += writer.writeValueToArray(vector->x) + writer.writeValueToArray(vector->y) + + writer.writeValueToArray(vector->z); return true; } diff --git a/src/UESaveFile/Serialisers/VectorPropertySerialiser.h b/src/UESaveFile/Serialisers/VectorPropertySerialiser.h index 85d2920..12b9526 100644 --- a/src/UESaveFile/Serialisers/VectorPropertySerialiser.h +++ b/src/UESaveFile/Serialisers/VectorPropertySerialiser.h @@ -28,8 +28,8 @@ class VectorPropertySerialiser : public UnrealPropertySerialiser #include -#include - #include "StructProperty.h" using namespace Corrade; -using namespace Magnum; struct DateTimeStructProperty : public StructProperty { using ptr = Containers::Pointer; @@ -34,5 +31,5 @@ struct DateTimeStructProperty : public StructProperty { structType = "DateTime"_s; } - UnsignedLong timestamp = 0; + std::int64_t timestamp = 0; }; diff --git a/src/UESaveFile/Types/FloatProperty.h b/src/UESaveFile/Types/FloatProperty.h index 6f23ca9..83dfe59 100644 --- a/src/UESaveFile/Types/FloatProperty.h +++ b/src/UESaveFile/Types/FloatProperty.h @@ -19,14 +19,11 @@ #include #include -#include - #include "UnrealProperty.h" using namespace Corrade; -using namespace Magnum; -struct FloatProperty : public UnrealProperty { +struct FloatProperty : public UnrealProperty { using ptr = Containers::Pointer; FloatProperty() { diff --git a/src/UESaveFile/Types/IntProperty.h b/src/UESaveFile/Types/IntProperty.h index 8b231cf..b381136 100644 --- a/src/UESaveFile/Types/IntProperty.h +++ b/src/UESaveFile/Types/IntProperty.h @@ -23,7 +23,7 @@ using namespace Corrade; -struct IntProperty : public UnrealProperty { +struct IntProperty : public UnrealProperty { using ptr = Containers::Pointer; IntProperty() { diff --git a/src/UESaveFile/Types/ResourceItemValue.h b/src/UESaveFile/Types/ResourceItemValue.h index e4b7c17..16ed5f2 100644 --- a/src/UESaveFile/Types/ResourceItemValue.h +++ b/src/UESaveFile/Types/ResourceItemValue.h @@ -19,12 +19,9 @@ #include #include -#include - #include "StructProperty.h" using namespace Corrade; -using namespace Magnum; struct ResourceItemValue : public StructProperty { using ptr = Containers::Pointer; @@ -32,8 +29,12 @@ struct ResourceItemValue : public StructProperty { ResourceItemValue() { using namespace Containers::Literals; structType = "sttResourceItemValue"_s; - structGuid = Containers::StaticArray<16, char>{'\xB7', '\xA7', '\x77', '\xAB', '\xD3', '\x1B', '\xA6', '\x43', '\xAF', '\x42', '\xE5', '\x9E', '\xBF', '\xFD', '\x37', '\x55'}; + structGuid = Containers::StaticArray<16, char>{ + '\xB7', '\xA7', '\x77', '\xAB', '\xD3', '\x1B', '\xA6', '\x43', + '\xAF', '\x42', '\xE5', '\x9E', '\xBF', '\xFD', '\x37', '\x55' + }; } - Int id = 0, quantity = 0; + std::int32_t id = 0; + std::int32_t quantity = 0; }; diff --git a/src/UESaveFile/Types/RotatorStructProperty.h b/src/UESaveFile/Types/RotatorStructProperty.h index eb001c8..5a21991 100644 --- a/src/UESaveFile/Types/RotatorStructProperty.h +++ b/src/UESaveFile/Types/RotatorStructProperty.h @@ -19,12 +19,9 @@ #include #include -#include - #include "StructProperty.h" using namespace Corrade; -using namespace Magnum; struct RotatorStructProperty : public StructProperty { using ptr = Containers::Pointer; @@ -34,5 +31,5 @@ struct RotatorStructProperty : public StructProperty { structType = "Rotator"_s; } - Float x = 0.0f, y = 0.0f, z = 0.0f; + float x = 0.0f, y = 0.0f, z = 0.0f; }; diff --git a/src/UESaveFile/Types/UnrealPropertyBase.h b/src/UESaveFile/Types/UnrealPropertyBase.h index 47d8e52..acaf8fd 100644 --- a/src/UESaveFile/Types/UnrealPropertyBase.h +++ b/src/UESaveFile/Types/UnrealPropertyBase.h @@ -16,14 +16,13 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . +#include + #include #include #include -#include - using namespace Corrade; -using namespace Magnum; struct UnrealPropertyBase { using ptr = Containers::Pointer; @@ -32,5 +31,5 @@ struct UnrealPropertyBase { Containers::Optional name = Containers::NullOpt; Containers::String propertyType; - UnsignedLong valueLength = 0; + std::size_t valueLength = 0; }; diff --git a/src/UESaveFile/Types/Vector2DStructProperty.h b/src/UESaveFile/Types/Vector2DStructProperty.h index 057bfd9..17b02b7 100644 --- a/src/UESaveFile/Types/Vector2DStructProperty.h +++ b/src/UESaveFile/Types/Vector2DStructProperty.h @@ -19,12 +19,9 @@ #include #include -#include - #include "StructProperty.h" using namespace Corrade; -using namespace Magnum; struct Vector2DStructProperty : public StructProperty { using ptr = Containers::Pointer; @@ -34,5 +31,5 @@ struct Vector2DStructProperty : public StructProperty { structType = "Vector2D"_s; } - Float x = 0.0f, y = 0.0f; + float x = 0.0f, y = 0.0f; }; diff --git a/src/UESaveFile/Types/VectorStructProperty.h b/src/UESaveFile/Types/VectorStructProperty.h index b753c11..4189ab1 100644 --- a/src/UESaveFile/Types/VectorStructProperty.h +++ b/src/UESaveFile/Types/VectorStructProperty.h @@ -19,12 +19,9 @@ #include #include -#include - #include "StructProperty.h" using namespace Corrade; -using namespace Magnum; struct VectorStructProperty : public StructProperty { using ptr = Containers::Pointer; @@ -34,5 +31,5 @@ struct VectorStructProperty : public StructProperty { structType = "Vector"_s; } - Float x = 0.0f, y = 0.0f, z = 0.0f; + float x = 0.0f, y = 0.0f, z = 0.0f; }; diff --git a/src/UESaveFile/UESaveFile.cpp b/src/UESaveFile/UESaveFile.cpp index 51d5684..d754540 100644 --- a/src/UESaveFile/UESaveFile.cpp +++ b/src/UESaveFile/UESaveFile.cpp @@ -92,13 +92,13 @@ UESaveFile::saveToFile() { return false; } - if(!writer.writeArray(arrayView(_magicBytes)) || - !writer.writeUnsignedInt(_saveVersion) || - !writer.writeUnsignedInt(_packageVersion) || - !writer.writeUnsignedShort(_engineVersion.major) || - !writer.writeUnsignedShort(_engineVersion.minor) || - !writer.writeUnsignedShort(_engineVersion.patch) || - !writer.writeUnsignedInt(_engineVersion.build) || + if(!writer.writeArray(arrayView(_magicBytes)) || + !writer.writeUint32(_saveVersion) || + !writer.writeUint32(_packageVersion) || + !writer.writeUint16(_engineVersion.major) || + !writer.writeUint16(_engineVersion.minor) || + !writer.writeUint16(_engineVersion.patch) || + !writer.writeUint32(_engineVersion.build) || !writer.writeUEString(_engineVersion.buildId)) { _lastError = "Couldn't write the header."_s; @@ -106,17 +106,17 @@ UESaveFile::saveToFile() { return false; } - if(!writer.writeUnsignedInt(_customFormatVersion) || - !writer.writeUnsignedInt(_customFormatData.size())) + if(!writer.writeUint32(_customFormatVersion) || + !writer.writeUint32(_customFormatData.size())) { _lastError = "Couldn't write the custom format data."_s; LOG_ERROR(_lastError); return false; } - for(UnsignedLong i = 0; i < _customFormatData.size(); i++) { + for(std::size_t i = 0; i < _customFormatData.size(); i++) { if(!writer.writeStaticArray(Containers::StaticArrayView<16, const char>{_customFormatData[i].id}) || - !writer.writeUnsignedInt(_customFormatData[i].value)) + !writer.writeUint32(_customFormatData[i].value)) { _lastError = "Couldn't write the custom format data."_s; LOG_ERROR(_lastError); @@ -131,7 +131,7 @@ UESaveFile::saveToFile() { } for(auto& prop : _properties) { - UnsignedLong bytes_written = 0; + std::size_t bytes_written = 0; if(!_propSerialiser->write(prop, bytes_written, writer)) { _lastError = "Couldn't write the property "_s + *prop->name + " to the array."_s; LOG_ERROR(_lastError); @@ -145,7 +145,7 @@ UESaveFile::saveToFile() { } } - writer.writeUnsignedInt(0); + writer.writeUint32(0u); writer.closeFile(); @@ -197,12 +197,12 @@ UESaveFile::loadData() { return; } - if(!reader.readUnsignedInt(_saveVersion) || - !reader.readUnsignedInt(_packageVersion) || - !reader.readUnsignedShort(_engineVersion.major) || - !reader.readUnsignedShort(_engineVersion.minor) || - !reader.readUnsignedShort(_engineVersion.patch) || - !reader.readUnsignedInt(_engineVersion.build) || + if(!reader.readUint32(_saveVersion) || + !reader.readUint32(_packageVersion) || + !reader.readUint16(_engineVersion.major) || + !reader.readUint16(_engineVersion.minor) || + !reader.readUint16(_engineVersion.patch) || + !reader.readUint32(_engineVersion.build) || !reader.readUEString(_engineVersion.buildId)) { _lastError = "Couldn't read version data."; @@ -210,15 +210,15 @@ UESaveFile::loadData() { return; } - if(!reader.readUnsignedInt(_customFormatVersion)) { + if(!reader.readUint32(_customFormatVersion)) { _lastError = "Couldn't read the custom format version."; LOG_ERROR(_lastError); return; } - UnsignedInt custom_format_data_size = 0; + std::uint32_t custom_format_data_size = 0; - if(!reader.readUnsignedInt(custom_format_data_size)) { + if(!reader.readUint32(custom_format_data_size)) { _lastError = "Couldn't read the custom format data size."; LOG_ERROR(_lastError); return; @@ -226,11 +226,11 @@ UESaveFile::loadData() { _customFormatData = Containers::Array{custom_format_data_size}; - for(UnsignedInt i = 0; i < custom_format_data_size; i++) { + for(std::uint32_t i = 0; i < custom_format_data_size; i++) { CustomFormatDataEntry entry; if(!reader.readStaticArray(entry.id) || - !reader.readInt(entry.value)) + !reader.readInt32(entry.value)) { _lastError = "Couldn't read the custom format data"; LOG_ERROR(_lastError); diff --git a/src/UESaveFile/UESaveFile.h b/src/UESaveFile/UESaveFile.h index 8ed3476..91798e9 100644 --- a/src/UESaveFile/UESaveFile.h +++ b/src/UESaveFile/UESaveFile.h @@ -23,14 +23,11 @@ #include #include -#include - #include "Types/UnrealPropertyBase.h" #include "PropertySerialiser.h" using namespace Corrade; -using namespace Magnum; class UESaveFile { public: @@ -72,20 +69,20 @@ class UESaveFile { Containers::StaticArray<4, char> _magicBytes{'G', 'V', 'A', 'S'}; - UnsignedInt _saveVersion = 0; - UnsignedInt _packageVersion = 0; + std::uint32_t _saveVersion = 0; + std::uint32_t _packageVersion = 0; struct { - UnsignedShort major = 0; - UnsignedShort minor = 0; - UnsignedShort patch = 0; - UnsignedInt build = 0; + std::uint16_t major = 0; + std::uint16_t minor = 0; + std::uint16_t patch = 0; + std::uint32_t build = 0; Containers::String buildId; } _engineVersion; - UnsignedInt _customFormatVersion = 0; + std::uint32_t _customFormatVersion = 0; struct CustomFormatDataEntry { Containers::StaticArray<16, char> id; - Int value = 0; + std::int32_t value = 0; }; Containers::Array _customFormatData; diff --git a/src/Utilities/Crc32.h b/src/Utilities/Crc32.h index e6babd6..6937f28 100644 --- a/src/Utilities/Crc32.h +++ b/src/Utilities/Crc32.h @@ -16,47 +16,47 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . +#include + #include #include -#include - using namespace Corrade; -using namespace Magnum; -struct Crc32 { - static const Containers::StaticArray<256, UnsignedInt> table; +namespace Crc32 { - static auto update(UnsignedInt initial, Containers::ArrayView data) -> UnsignedInt { - UnsignedInt c = initial ^ 0xFFFFFFFF; - auto u = Containers::arrayCast(data); +std::uint32_t update(std::uint32_t initial, Containers::ArrayView data) { + static const auto table = []{ + std::uint32_t polynomial = 0xEDB88320u; + Containers::StaticArray<256, std::uint32_t> temp{ValueInit}; - for(std::size_t i = 0; i < data.size(); ++i) { - c = table[(c ^ u[i]) & 0xFF] ^ (c >> 8); + for(std::uint32_t i = 0; i < 256; i++) { + std::uint32_t c = i; + + for(std::size_t j = 0; j < 8; j++) { + if(c & 1) { + c = polynomial ^ (c >> 1); + } + else { + c >>= 1; + } + } + + temp[i] = c; } - return c ^ 0xFFFFFFFF; - } -}; + return temp; + }(); -const Containers::StaticArray<256, UnsignedInt> Crc32::table = []{ - UnsignedInt polynomial = 0xEDB88320u; - Containers::StaticArray<256, UnsignedInt> temp{ValueInit}; + std::uint32_t c = initial ^ 0xFFFFFFFF; - for(UnsignedInt i = 0; i < 256; i++) { - UnsignedInt c = i; + auto u = Containers::arrayCast(data); - for(std::size_t j = 0; j < 8; j++) { - if(c & 1) { - c = polynomial ^ (c >> 1); - } - else { - c >>= 1; - } - } - - temp[i] = c; + for(std::size_t i = 0; i < data.size(); ++i) { + c = table[(c ^ u[i]) & 0xFF] ^ (c >> 8); } - return temp; -}(); + return c ^ 0xFFFFFFFF; +} + +} // Crc32 diff --git a/src/main.cpp b/src/main.cpp index 5af499f..20e1be1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -81,7 +81,7 @@ int main(int argc, char** argv) { } SaveTool app({argc, argv}); - Int result = app.exec(); + int result = app.exec(); ReleaseMutex(mutex_handle);