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.
This commit is contained in:
Guillaume Jacquemin 2022-12-05 11:32:18 +01:00
parent 3c2cb001ff
commit 9c074c24bd
100 changed files with 751 additions and 815 deletions

View file

@ -25,8 +25,6 @@ using Utility::Debug;
using Utility::Warning; using Utility::Warning;
using Utility::Error; using Utility::Error;
using namespace Magnum;
Logger& Logger&
Logger::instance() { Logger::instance() {
static Logger logger; static Logger logger;
@ -89,7 +87,7 @@ Logger::log(EntryType type, StringView location, StringView message) {
d << "["_s << Debug::nospace << location << Debug::nospace << "]"; 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; d << Debug::nospace << " "_s << Debug::nospace;
} }

View file

@ -27,8 +27,6 @@
#include <Corrade/Containers/ArrayView.h> #include <Corrade/Containers/ArrayView.h>
#include <Corrade/Utility/Format.h> #include <Corrade/Utility/Format.h>
#include <Magnum/Types.h>
#include "EntryType.h" #include "EntryType.h"
using namespace Corrade; using namespace Corrade;
@ -37,8 +35,6 @@ using Containers::ArrayView;
using Containers::String; using Containers::String;
using Containers::StringView; using Containers::StringView;
using namespace Magnum;
using namespace Containers::Literals; using namespace Containers::Literals;
class Logger { class Logger {
@ -68,7 +64,7 @@ class Logger {
std::ofstream _logFile; std::ofstream _logFile;
#endif #endif
UnsignedInt _indentLevel = 0; std::uint32_t _indentLevel = 0;
std::mutex _logMutex{}; std::mutex _logMutex{};
}; };

View file

@ -16,15 +16,14 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <cstdint>
#include <map> #include <map>
#include <Corrade/Containers/StringView.h> #include <Corrade/Containers/StringView.h>
#include <Magnum/Types.h>
using namespace Corrade; using namespace Corrade;
using namespace Containers::Literals; using namespace Containers::Literals;
using namespace Magnum;
enum AccessorySize { enum AccessorySize {
S, S,
@ -38,7 +37,7 @@ struct AccessoryData{
AccessorySize size = AccessorySize::S; AccessorySize size = AccessorySize::S;
}; };
static const std::map<Int, AccessoryData> accessories { static const std::map<std::int32_t, AccessoryData> accessories {
// region Primitives // region Primitives
{1, {"Cube"_s, AccessorySize::S}}, {1, {"Cube"_s, AccessorySize::S}},
{2, {"Pentagon"_s, AccessorySize::S}}, {2, {"Pentagon"_s, AccessorySize::S}},

View file

@ -16,22 +16,21 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <cstdint>
#include <map> #include <map>
#include <Corrade/Containers/StringView.h> #include <Corrade/Containers/StringView.h>
#include <Magnum/Types.h>
using namespace Corrade; using namespace Corrade;
using namespace Containers::Literals; using namespace Containers::Literals;
using namespace Magnum;
struct ArmourSet { struct ArmourSet {
Containers::StringView name; Containers::StringView name;
bool neck_compatible; bool neck_compatible;
}; };
static const std::map<Int, ArmourSet> armour_sets { static const std::map<std::int32_t, ArmourSet> armour_sets {
{-1, {"<unequipped>"_s, true}}, {-1, {"<unequipped>"_s, true}},
{0, {"Vanguard"_s, true}}, {0, {"Vanguard"_s, true}},
{1, {"Assault Mk.I"_s, true}}, {1, {"Assault Mk.I"_s, true}},

View file

@ -20,13 +20,10 @@
#include <Corrade/Containers/StringView.h> #include <Corrade/Containers/StringView.h>
#include <Magnum/Types.h>
using namespace Corrade; using namespace Corrade;
using namespace Containers::Literals; using namespace Containers::Literals;
using namespace Magnum;
static const std::map<Int, Containers::StringView> mission_id_map {{ static const std::map<std::int32_t, Containers::StringView> mission_id_map {{
// Story missions // Story missions
{0x0064, "Mission 1 - Training"_s}, {0x0064, "Mission 1 - Training"_s},
{0x0065, "Mission 2 - Patrol Operation"_s}, {0x0065, "Mission 2 - Patrol Operation"_s},

View file

@ -19,14 +19,11 @@
#include <Corrade/Containers/Array.h> #include <Corrade/Containers/Array.h>
#include <Corrade/Containers/StringView.h> #include <Corrade/Containers/StringView.h>
#include <Magnum/Types.h>
using namespace Corrade; using namespace Corrade;
using namespace Containers::Literals; using namespace Containers::Literals;
using namespace Magnum;
struct StoryProgressPoint { struct StoryProgressPoint {
Int id; std::int32_t id;
Containers::StringView chapter; Containers::StringView chapter;
Containers::StringView point; Containers::StringView point;
Containers::StringView after = nullptr; Containers::StringView after = nullptr;

View file

@ -16,17 +16,16 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <cstdint>
#include <map> #include <map>
#include <Corrade/Containers/StringView.h> #include <Corrade/Containers/StringView.h>
#include <Magnum/Magnum.h>
using namespace Corrade; using namespace Corrade;
using namespace Containers::Literals; using namespace Containers::Literals;
using namespace Magnum;
extern const std::map<Int, Containers::StringView> style_names extern const std::map<std::int32_t, Containers::StringView> style_names
#ifdef STYLENAMES_DEFINITION #ifdef STYLENAMES_DEFINITION
{ {
{0, "Custom Style 1"_s}, {0, "Custom Style 1"_s},

View file

@ -15,19 +15,18 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <cstdint>
#include <map> #include <map>
#include <Corrade/Containers/StringView.h> #include <Corrade/Containers/StringView.h>
#include <Magnum/Types.h>
using namespace Corrade; using namespace Corrade;
using namespace Magnum;
using namespace Containers::Literals; using namespace Containers::Literals;
// region Melee // region Melee
static const std::map<Int, Containers::StringView> melee_grips { static const std::map<std::int32_t, Containers::StringView> melee_grips {
{0, "Combat Grip (1H)"_s}, {0, "Combat Grip (1H)"_s},
{1, "Knuckle Guard Grip (1H)"_s}, {1, "Knuckle Guard Grip (1H)"_s},
{2, "Dual Guard Grip (1H)"_s}, {2, "Dual Guard Grip (1H)"_s},
@ -78,7 +77,7 @@ static const std::map<Int, Containers::StringView> melee_grips {
{2404, "Arched Twin Blade (2H)"_s}, {2404, "Arched Twin Blade (2H)"_s},
}; };
static const std::map<Int, Containers::StringView> melee_assaulters { static const std::map<std::int32_t, Containers::StringView> melee_assaulters {
{0, "Long Metal Blade"_s}, {0, "Long Metal Blade"_s},
{1, "Long Assault Blade"_s}, {1, "Long Assault Blade"_s},
{2, "Long Fin Blade"_s}, {2, "Long Fin Blade"_s},
@ -172,7 +171,7 @@ static const std::map<Int, Containers::StringView> melee_assaulters {
// endregion // endregion
// region Shields // region Shields
static const std::map<Int, Containers::StringView> shield_handles { static const std::map<std::int32_t, Containers::StringView> shield_handles {
{0, "Balanced Handle"_s}, {0, "Balanced Handle"_s},
{1, "Expanded Handle"_s}, {1, "Expanded Handle"_s},
{2, "Lowguard Handle"_s}, {2, "Lowguard Handle"_s},
@ -191,7 +190,7 @@ static const std::map<Int, Containers::StringView> shield_handles {
{101, "Star Handle"_s}, {101, "Star Handle"_s},
}; };
static const std::map<Int, Containers::StringView> shield_shells { static const std::map<std::int32_t, Containers::StringView> shield_shells {
{0, "Balanced Shell"_s}, {0, "Balanced Shell"_s},
{1, "Compass Shell"_s}, {1, "Compass Shell"_s},
{2, "Uppoint Shell"_s}, {2, "Uppoint Shell"_s},
@ -212,7 +211,7 @@ static const std::map<Int, Containers::StringView> shield_shells {
// endregion // endregion
// region Bullet Shooters // region Bullet Shooters
static const std::map<Int, Containers::StringView> bshooter_triggers { static const std::map<std::int32_t, Containers::StringView> bshooter_triggers {
{0, "BL-Combat Trigger (1H)"_s}, {0, "BL-Combat Trigger (1H)"_s},
{1, "Light Machine Trigger (1H)"_s}, {1, "Light Machine Trigger (1H)"_s},
{2, "Tactical Trigger (1H)"_s}, {2, "Tactical Trigger (1H)"_s},
@ -230,7 +229,7 @@ static const std::map<Int, Containers::StringView> bshooter_triggers {
{199, "2H Base Trigger (2H)"_s}, {199, "2H Base Trigger (2H)"_s},
}; };
static const std::map<Int, Containers::StringView> bshooter_barrels { static const std::map<std::int32_t, Containers::StringView> bshooter_barrels {
{0, "BL-Combat Barrel (1 shot)"_s}, {0, "BL-Combat Barrel (1 shot)"_s},
{1, "Shock Absorb Barrel (1 shot) (Motion)"_s}, {1, "Shock Absorb Barrel (1 shot) (Motion)"_s},
{2, "Muzzlemod Barrel (1 shot)"_s}, {2, "Muzzlemod Barrel (1 shot)"_s},
@ -267,7 +266,7 @@ static const std::map<Int, Containers::StringView> bshooter_barrels {
// endregion // endregion
//region Energy Shooters //region Energy Shooters
static const std::map<Int, Containers::StringView> eshooter_triggers { static const std::map<std::int32_t, Containers::StringView> eshooter_triggers {
{0, "EN-Rifle Trigger (1H)"_s}, {0, "EN-Rifle Trigger (1H)"_s},
{1, "Underarm Trigger (1H)"_s}, {1, "Underarm Trigger (1H)"_s},
{2, "EN-Inverted Trigger (1H)"_s}, {2, "EN-Inverted Trigger (1H)"_s},
@ -285,7 +284,7 @@ static const std::map<Int, Containers::StringView> eshooter_triggers {
{199, "2H Base EnTrigger (2H)"_s}, {199, "2H Base EnTrigger (2H)"_s},
}; };
static const std::map<Int, Containers::StringView> eshooter_busters { static const std::map<std::int32_t, Containers::StringView> eshooter_busters {
{0, "EN-Combat Buster (1 shot)"_s}, {0, "EN-Combat Buster (1 shot)"_s},
{1, "Delta Cycler (1 shot) (Motion)"_s}, {1, "Delta Cycler (1 shot) (Motion)"_s},
{2, "EN-Longbarrel Buster (1 shot)"_s}, {2, "EN-Longbarrel Buster (1 shot)"_s},
@ -321,7 +320,7 @@ static const std::map<Int, Containers::StringView> eshooter_busters {
// endregion // endregion
// region Bullet Launchers // region Bullet Launchers
static const std::map<Int, Containers::StringView> blauncher_pods { static const std::map<std::int32_t, Containers::StringView> blauncher_pods {
{0, "BL-Delta Pack Launcher (Missile x12)"_s}, {0, "BL-Delta Pack Launcher (Missile x12)"_s},
{1, "BL-Twin Pack Launcher (Missile x12)"_s}, {1, "BL-Twin Pack Launcher (Missile x12)"_s},
{2, "Detector Launcher (Missile x12)"_s}, {2, "Detector Launcher (Missile x12)"_s},
@ -351,7 +350,7 @@ static const std::map<Int, Containers::StringView> blauncher_pods {
{399, "C Base Pod (Cluster x40)"_s}, {399, "C Base Pod (Cluster x40)"_s},
}; };
static const std::map<Int, Containers::StringView> blauncher_projectiles { static const std::map<std::int32_t, Containers::StringView> blauncher_projectiles {
{0, "Flathead Missile"_s}, {0, "Flathead Missile"_s},
{1, "Warhead Missile"_s}, {1, "Warhead Missile"_s},
{2, "Pointhead Missile"_s}, {2, "Pointhead Missile"_s},
@ -361,7 +360,7 @@ static const std::map<Int, Containers::StringView> blauncher_projectiles {
// endregion // endregion
// region Energy Launchers // region Energy Launchers
static const std::map<Int, Containers::StringView> elauncher_generators { static const std::map<std::int32_t, Containers::StringView> elauncher_generators {
{0, "Fly Unit"_s}, {0, "Fly Unit"_s},
{1, "Assault Unit (Motion)"_s}, {1, "Assault Unit (Motion)"_s},
{2, "Falcon Unit"_s}, {2, "Falcon Unit"_s},
@ -393,7 +392,7 @@ static const std::map<Int, Containers::StringView> elauncher_generators {
{99, "Base Generator"}, {99, "Base Generator"},
}; };
static const std::map<Int, Containers::StringView> elauncher_pods { static const std::map<std::int32_t, Containers::StringView> elauncher_pods {
{0, "EN-Dual Claw Launcher (Echo) (Motion)"_s}, {0, "EN-Dual Claw Launcher (Echo) (Motion)"_s},
{1, "EN-Assault Launcher (Echo)"_s}, {1, "EN-Assault Launcher (Echo)"_s},
{2, "EN-Tactical Launcher (Echo)"_s}, {2, "EN-Tactical Launcher (Echo)"_s},

View file

@ -25,9 +25,9 @@ using namespace Corrade;
using namespace Magnum; using namespace Magnum;
struct Accessory { struct Accessory {
Int attachIndex = -1; std::int32_t attachIndex = -1;
Int id = -1; std::int32_t id = -1;
Containers::StaticArray<2, Int> styles{ValueInit}; Containers::StaticArray<2, std::int32_t> styles{ValueInit};
Vector3 relativePosition{0.0f}; Vector3 relativePosition{0.0f};
Vector3 relativePositionOffset{0.0f}; Vector3 relativePositionOffset{0.0f};
Vector3 relativeRotation{0.0f}; Vector3 relativeRotation{0.0f};

View file

@ -19,13 +19,10 @@
#include <Corrade/Containers/Array.h> #include <Corrade/Containers/Array.h>
#include <Corrade/Containers/StaticArray.h> #include <Corrade/Containers/StaticArray.h>
#include <Magnum/Types.h>
#include "Decal.h" #include "Decal.h"
#include "Accessory.h" #include "Accessory.h"
using namespace Corrade; using namespace Corrade;
using namespace Magnum;
enum class ArmourSlot { enum class ArmourSlot {
#define c(enumerator, enumstr, name) enumerator, #define c(enumerator, enumstr, name) enumerator,
@ -35,8 +32,8 @@ enum class ArmourSlot {
struct ArmourPart { struct ArmourPart {
ArmourSlot slot = ArmourSlot::Face; ArmourSlot slot = ArmourSlot::Face;
Int id = 0; std::int32_t id = 0;
Containers::StaticArray<4, Int> styles{ValueInit}; Containers::StaticArray<4, std::int32_t> styles{ValueInit};
Containers::Array<Decal> decals; Containers::Array<Decal> decals;
Containers::Array<Accessory> accessories; Containers::Array<Accessory> accessories;
}; };

View file

@ -28,13 +28,13 @@ using namespace Magnum;
struct CustomStyle { struct CustomStyle {
Containers::String name; Containers::String name;
Color4 colour{0.0f}; Color4 colour{0.0f};
Float metallic = 0.5f; float metallic = 0.5f;
Float gloss = 0.5f; float gloss = 0.5f;
bool glow = false; bool glow = false;
Int patternId = 0; std::int32_t patternId = 0;
Float opacity = 0.5f; float opacity = 0.5f;
Vector2 offset{0.5f}; Vector2 offset{0.5f};
Float rotation = 0.0f; float rotation = 0.0f;
Float scale = 0.5f; float scale = 0.5f;
}; };

View file

@ -19,18 +19,19 @@
#include <Magnum/Magnum.h> #include <Magnum/Magnum.h>
#include <Magnum/Math/Color.h> #include <Magnum/Math/Color.h>
#include <Magnum/Math/Vector2.h> #include <Magnum/Math/Vector2.h>
#include <Magnum/Math/Vector3.h>
using namespace Magnum; using namespace Magnum;
struct Decal { struct Decal {
Int id = -1; std::int32_t id = -1;
Color4 colour{0.0f}; Color4 colour{0.0f};
Vector3 position{0.0f}; Vector3 position{0.0f};
Vector3 uAxis{0.0f}; Vector3 uAxis{0.0f};
Vector3 vAxis{0.0f}; Vector3 vAxis{0.0f};
Vector2 offset{0.5f}; Vector2 offset{0.5f};
Float scale = 0.5f; float scale = 0.5f;
Float rotation = 0.0f; float rotation = 0.0f;
bool flip = false; bool flip = false;
bool wrap = false; bool wrap = false;
}; };

View file

@ -16,17 +16,13 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <Magnum/Types.h>
using namespace Magnum;
struct Joints { struct Joints {
Float neck = 0.0f; float neck = 0.0f;
Float body = 0.0f; float body = 0.0f;
Float shoulders = 0.0f; float shoulders = 0.0f;
Float hips = 0.0f; float hips = 0.0f;
Float upperArms = 0.0f; float upperArms = 0.0f;
Float lowerArms = 0.0f; float lowerArms = 0.0f;
Float upperLegs = 0.0f; float upperLegs = 0.0f;
Float lowerLegs = 0.0f; float lowerLegs = 0.0f;
}; };

View file

@ -308,32 +308,32 @@ Mass::getTuning() {
} }
} }
Int& std::int32_t&
Mass::engine() { Mass::engine() {
return _tuning.engineId; return _tuning.engineId;
} }
Containers::ArrayView<Int> Containers::ArrayView<std::int32_t>
Mass::gears() { Mass::gears() {
return _tuning.gearIds; return _tuning.gearIds;
} }
Int& std::int32_t&
Mass::os() { Mass::os() {
return _tuning.osId; return _tuning.osId;
} }
Containers::ArrayView<Int> Containers::ArrayView<std::int32_t>
Mass::modules() { Mass::modules() {
return _tuning.moduleIds; return _tuning.moduleIds;
} }
Int& std::int32_t&
Mass::architecture() { Mass::architecture() {
return _tuning.archId; return _tuning.archId;
} }
Containers::ArrayView<Int> Containers::ArrayView<std::int32_t>
Mass::techs() { Mass::techs() {
return _tuning.techIds; return _tuning.techIds;
} }
@ -365,8 +365,9 @@ Mass::updateAccount(Containers::StringView new_account) {
} }
void void
Mass::getTuningCategory(Containers::StringView big_node_prop_name, Int& big_node_id, Mass::getTuningCategory(Containers::StringView big_node_prop_name, std::int32_t& big_node_id,
Containers::StringView small_nodes_prop_name, Containers::ArrayView<Int> small_nodes_ids) Containers::StringView small_nodes_prop_name,
Containers::ArrayView<std::int32_t> small_nodes_ids)
{ {
LOG_INFO_FORMAT("Getting tuning data ({}, {}).", big_node_prop_name, small_nodes_prop_name); 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; 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<IntProperty>(i); auto small_node_id = node_ids->at<IntProperty>(i);
CORRADE_INTERNAL_ASSERT(small_node_id); CORRADE_INTERNAL_ASSERT(small_node_id);
small_nodes_ids[i] = small_node_id->value; small_nodes_ids[i] = small_node_id->value;

View file

@ -64,7 +64,7 @@ class Mass {
Containers::StringView name(); Containers::StringView name();
bool setName(Containers::StringView new_name); bool setName(Containers::StringView new_name);
enum class State : UnsignedByte { enum class State: std::uint8_t {
Empty, Invalid, Valid Empty, Invalid, Valid
}; };
@ -77,7 +77,7 @@ class Mass {
void getJointSliders(); void getJointSliders();
bool writeJointSliders(); bool writeJointSliders();
Containers::ArrayView<Int> frameStyles(); Containers::ArrayView<std::int32_t> frameStyles();
void getFrameStyles(); void getFrameStyles();
bool writeFrameStyles(); bool writeFrameStyles();
@ -87,7 +87,7 @@ class Mass {
Containers::ArrayView<CustomStyle> frameCustomStyles(); Containers::ArrayView<CustomStyle> frameCustomStyles();
void getFrameCustomStyles(); void getFrameCustomStyles();
bool writeFrameCustomStyle(UnsignedLong index); bool writeFrameCustomStyle(std::size_t index);
Containers::ArrayView<ArmourPart> armourParts(); Containers::ArrayView<ArmourPart> armourParts();
void getArmourParts(); void getArmourParts();
@ -100,7 +100,7 @@ class Mass {
Containers::ArrayView<CustomStyle> armourCustomStyles(); Containers::ArrayView<CustomStyle> armourCustomStyles();
void getArmourCustomStyles(); void getArmourCustomStyles();
bool writeArmourCustomStyle(UnsignedLong index); bool writeArmourCustomStyle(std::size_t index);
Containers::ArrayView<Weapon> meleeWeapons(); Containers::ArrayView<Weapon> meleeWeapons();
void getMeleeWeapons(); void getMeleeWeapons();
@ -128,25 +128,25 @@ class Mass {
Containers::ArrayView<CustomStyle> globalStyles(); Containers::ArrayView<CustomStyle> globalStyles();
void getGlobalStyles(); void getGlobalStyles();
bool writeGlobalStyle(UnsignedLong index); bool writeGlobalStyle(std::size_t index);
void getTuning(); void getTuning();
Int& engine(); std::int32_t& engine();
Containers::ArrayView<Int> gears(); Containers::ArrayView<std::int32_t> gears();
Int& os(); std::int32_t& os();
Containers::ArrayView<Int> modules(); Containers::ArrayView<std::int32_t> modules();
Int& architecture(); std::int32_t& architecture();
Containers::ArrayView<Int> techs(); Containers::ArrayView<std::int32_t> techs();
Containers::StringView account(); Containers::StringView account();
bool updateAccount(Containers::StringView new_account); bool updateAccount(Containers::StringView new_account);
private: private:
void getCustomStyles(Containers::ArrayView<CustomStyle> styles, ArrayProperty* style_array); void getCustomStyles(Containers::ArrayView<CustomStyle> 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<Decal> decals, ArrayProperty* decal_array); void getDecals(Containers::ArrayView<Decal> decals, ArrayProperty* decal_array);
void writeDecals(Containers::ArrayView<Decal> decals, ArrayProperty* decal_array); void writeDecals(Containers::ArrayView<Decal> decals, ArrayProperty* decal_array);
@ -157,8 +157,9 @@ class Mass {
void getWeaponType(Containers::StringView prop_name, Containers::ArrayView<Weapon> weapon_array); void getWeaponType(Containers::StringView prop_name, Containers::ArrayView<Weapon> weapon_array);
bool writeWeaponType(Containers::StringView prop_name, Containers::ArrayView<Weapon> weapon_array); bool writeWeaponType(Containers::StringView prop_name, Containers::ArrayView<Weapon> weapon_array);
void getTuningCategory(Containers::StringView big_node_prop_name, Int& big_node_id, void getTuningCategory(Containers::StringView big_node_prop_name, std::int32_t& big_node_id,
Containers::StringView small_nodes_prop_name, Containers::ArrayView<Int> small_nodes_ids); Containers::StringView small_nodes_prop_name,
Containers::ArrayView<std::int32_t> small_nodes_ids);
Containers::Optional<UESaveFile> _mass; Containers::Optional<UESaveFile> _mass;
@ -174,7 +175,7 @@ class Mass {
struct { struct {
Joints joints{}; Joints joints{};
Containers::StaticArray<4, Int> styles{ValueInit}; Containers::StaticArray<4, std::int32_t> styles{ValueInit};
Color4 eyeFlare{0.0f}; Color4 eyeFlare{0.0f};
Containers::StaticArray<16, CustomStyle> customStyles; Containers::StaticArray<16, CustomStyle> customStyles;
} _frame; } _frame;
@ -198,14 +199,14 @@ class Mass {
Containers::Array<CustomStyle> _globalStyles; Containers::Array<CustomStyle> _globalStyles;
struct { struct {
Int engineId; std::int32_t engineId;
Containers::StaticArray<7, Int> gearIds; Containers::StaticArray<7, std::int32_t> gearIds;
Int osId; std::int32_t osId;
Containers::StaticArray<7, Int> moduleIds; Containers::StaticArray<7, std::int32_t> moduleIds;
Int archId; std::int32_t archId;
Containers::StaticArray<7, Int> techIds; Containers::StaticArray<7, std::int32_t> techIds;
} _tuning; } _tuning;
Containers::String _account; Containers::String _account;

View file

@ -59,7 +59,7 @@ Mass::getArmourParts() {
return; 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<GenericStructProperty>(i); auto part_prop = armour_array->at<GenericStructProperty>(i);
auto& part = _armour.parts[i]; auto& part = _armour.parts[i];
@ -89,7 +89,7 @@ Mass::getArmourParts() {
return; 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<IntProperty>(j)->value; part.styles[j] = part_styles->at<IntProperty>(j)->value;
} }
@ -152,7 +152,7 @@ Mass::writeArmourPart(ArmourSlot slot) {
GenericStructProperty* part_prop = nullptr; 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<GenericStructProperty>(i); part_prop = armour_array->at<GenericStructProperty>(i);
if(slot_str == part_prop->at<ByteProperty>(MASS_ARMOUR_SLOT)->enumValue) { if(slot_str == part_prop->at<ByteProperty>(MASS_ARMOUR_SLOT)->enumValue) {
break; break;
@ -178,7 +178,7 @@ Mass::writeArmourPart(ArmourSlot slot) {
part_prop->at<IntProperty>(MASS_ARMOUR_ID)->value = part.id; part_prop->at<IntProperty>(MASS_ARMOUR_ID)->value = part.id;
auto part_styles = part_prop->at<ArrayProperty>(MASS_ARMOUR_STYLES); auto part_styles = part_prop->at<ArrayProperty>(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<IntProperty>(i)->value = part.styles[i]; part_styles->at<IntProperty>(i)->value = part.styles[i];
} }
@ -238,7 +238,7 @@ Mass::getBulletLauncherAttachments() {
if(attach_array->items.size() == _weapons.bulletLaunchers.size() && if(attach_array->items.size() == _weapons.bulletLaunchers.size() &&
attach_array->items.size() == _armour.blAttachment.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<GenericStructProperty>(i); auto attachment_prop = attach_array->at<GenericStructProperty>(i);
auto& attachment = _armour.blAttachment[i]; auto& attachment = _armour.blAttachment[i];
@ -313,7 +313,7 @@ Mass::writeBulletLauncherAttachments() {
if(attach_array->items.size() == _weapons.bulletLaunchers.size() && if(attach_array->items.size() == _weapons.bulletLaunchers.size() &&
attach_array->items.size() == _armour.blAttachment.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<GenericStructProperty>(i); auto attachment_prop = attach_array->at<GenericStructProperty>(i);
auto& attachment = _armour.blAttachment[i]; auto& attachment = _armour.blAttachment[i];
@ -414,7 +414,7 @@ Mass::getArmourCustomStyles() {
} }
bool bool
Mass::writeArmourCustomStyle(UnsignedLong index) { Mass::writeArmourCustomStyle(std::size_t index) {
LOG_INFO_FORMAT("Writing custom armour style {}.", index); LOG_INFO_FORMAT("Writing custom armour style {}.", index);
if(index > _armour.customStyles.size()) { if(index > _armour.customStyles.size()) {

View file

@ -31,7 +31,7 @@ using namespace Containers::Literals;
void void
Mass::getDecals(Containers::ArrayView<Decal> decals, ArrayProperty* decal_array) { Mass::getDecals(Containers::ArrayView<Decal> 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<GenericStructProperty>(i); auto decal_prop = decal_array->at<GenericStructProperty>(i);
CORRADE_INTERNAL_ASSERT(decal_prop); CORRADE_INTERNAL_ASSERT(decal_prop);
auto& decal = decals[i]; auto& decal = decals[i];
@ -56,7 +56,7 @@ Mass::getDecals(Containers::ArrayView<Decal> decals, ArrayProperty* decal_array)
void void
Mass::writeDecals(Containers::ArrayView<Decal> decals, ArrayProperty* decal_array) { Mass::writeDecals(Containers::ArrayView<Decal> 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<GenericStructProperty>(i); auto decal_prop = decal_array->at<GenericStructProperty>(i);
CORRADE_INTERNAL_ASSERT(decal_prop); CORRADE_INTERNAL_ASSERT(decal_prop);
auto& decal = decals[i]; auto& decal = decals[i];
@ -91,7 +91,7 @@ Mass::writeDecals(Containers::ArrayView<Decal> decals, ArrayProperty* decal_arra
void void
Mass::getAccessories(Containers::ArrayView<Accessory> accessories, ArrayProperty* accessory_array) { Mass::getAccessories(Containers::ArrayView<Accessory> 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<GenericStructProperty>(i); auto acc_prop = accessory_array->at<GenericStructProperty>(i);
CORRADE_INTERNAL_ASSERT(acc_prop); CORRADE_INTERNAL_ASSERT(acc_prop);
auto& accessory = accessories[i]; auto& accessory = accessories[i];
@ -99,7 +99,7 @@ Mass::getAccessories(Containers::ArrayView<Accessory> accessories, ArrayProperty
accessory.attachIndex = acc_prop->at<IntProperty>(MASS_ACCESSORY_ATTACH_INDEX)->value; accessory.attachIndex = acc_prop->at<IntProperty>(MASS_ACCESSORY_ATTACH_INDEX)->value;
accessory.id = acc_prop->at<IntProperty>(MASS_ACCESSORY_ID)->value; accessory.id = acc_prop->at<IntProperty>(MASS_ACCESSORY_ID)->value;
auto acc_styles = acc_prop->at<ArrayProperty>(MASS_ACCESSORY_STYLES); auto acc_styles = acc_prop->at<ArrayProperty>(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<IntProperty>(j)->value; accessory.styles[j] = acc_styles->at<IntProperty>(j)->value;
} }
auto rel_pos_prop = acc_prop->at<VectorStructProperty>(MASS_ACCESSORY_RELPOS); auto rel_pos_prop = acc_prop->at<VectorStructProperty>(MASS_ACCESSORY_RELPOS);
@ -117,7 +117,7 @@ Mass::getAccessories(Containers::ArrayView<Accessory> accessories, ArrayProperty
void void
Mass::writeAccessories(Containers::ArrayView<Accessory> accessories, ArrayProperty* accs_array) { Mass::writeAccessories(Containers::ArrayView<Accessory> 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<GenericStructProperty>(i); auto acc_prop = accs_array->at<GenericStructProperty>(i);
CORRADE_INTERNAL_ASSERT(acc_prop); CORRADE_INTERNAL_ASSERT(acc_prop);
auto& accessory = accessories[i]; auto& accessory = accessories[i];
@ -125,7 +125,7 @@ Mass::writeAccessories(Containers::ArrayView<Accessory> accessories, ArrayProper
acc_prop->at<IntProperty>(MASS_ACCESSORY_ATTACH_INDEX)->value = accessory.attachIndex; acc_prop->at<IntProperty>(MASS_ACCESSORY_ATTACH_INDEX)->value = accessory.attachIndex;
acc_prop->at<IntProperty>(MASS_ACCESSORY_ID)->value = accessory.id; acc_prop->at<IntProperty>(MASS_ACCESSORY_ID)->value = accessory.id;
auto acc_styles = acc_prop->at<ArrayProperty>(MASS_ACCESSORY_STYLES); auto acc_styles = acc_prop->at<ArrayProperty>(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<IntProperty>(j)->value = accessory.styles[j]; acc_styles->at<IntProperty>(j)->value = accessory.styles[j];
} }
auto rel_pos_prop = acc_prop->at<VectorStructProperty>(MASS_ACCESSORY_RELPOS); auto rel_pos_prop = acc_prop->at<VectorStructProperty>(MASS_ACCESSORY_RELPOS);

View file

@ -184,7 +184,7 @@ Mass::writeJointSliders() {
return true; return true;
} }
Containers::ArrayView<Int> Containers::ArrayView<std::int32_t>
Mass::frameStyles() { Mass::frameStyles() {
return _frame.styles; return _frame.styles;
} }
@ -221,7 +221,7 @@ Mass::getFrameStyles() {
return; 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<IntProperty>(i)->value; _frame.styles[i] = frame_styles->at<IntProperty>(i)->value;
} }
} }
@ -254,7 +254,7 @@ Mass::writeFrameStyles() {
return false; 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<IntProperty>(i)->value = _frame.styles[i]; frame_styles->at<IntProperty>(i)->value = _frame.styles[i];
} }
@ -374,7 +374,7 @@ Mass::getFrameCustomStyles() {
} }
bool bool
Mass::writeFrameCustomStyle(UnsignedLong index) { Mass::writeFrameCustomStyle(std::size_t index) {
LOG_INFO_FORMAT("Writing frame custom style number {}.", index); LOG_INFO_FORMAT("Writing frame custom style number {}.", index);
if(index > _frame.customStyles.size()) { if(index > _frame.customStyles.size()) {

View file

@ -58,7 +58,7 @@ Mass::getGlobalStyles() {
} }
bool bool
Mass::writeGlobalStyle(UnsignedLong index) { Mass::writeGlobalStyle(std::size_t index) {
LOG_INFO_FORMAT("Writing global style number {}.", index); LOG_INFO_FORMAT("Writing global style number {}.", index);
if(index > _globalStyles.size()) { if(index > _globalStyles.size()) {
@ -88,7 +88,7 @@ Mass::writeGlobalStyle(UnsignedLong index) {
void void
Mass::getCustomStyles(Containers::ArrayView<CustomStyle> styles, ArrayProperty* style_array) { Mass::getCustomStyles(Containers::ArrayView<CustomStyle> 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<GenericStructProperty>(i); auto style_prop = style_array->at<GenericStructProperty>(i);
auto& style = styles[i]; auto& style = styles[i];
@ -111,7 +111,7 @@ Mass::getCustomStyles(Containers::ArrayView<CustomStyle> styles, ArrayProperty*
} }
bool 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) { if(!style_array) {
_lastError = "style_array is null."_s; _lastError = "style_array is null."_s;
LOG_ERROR(_lastError); LOG_ERROR(_lastError);

View file

@ -153,7 +153,7 @@ Mass::getWeaponType(Containers::StringView prop_name, Containers::ArrayView<Weap
return; return;
} }
for(UnsignedInt i = 0; i < weapon_array.size(); i++) { for(std::uint32_t i = 0; i < weapon_array.size(); i++) {
auto weapon_prop = prop->at<GenericStructProperty>(i); auto weapon_prop = prop->at<GenericStructProperty>(i);
auto& weapon = weapon_array[i]; auto& weapon = weapon_array[i];
@ -171,14 +171,14 @@ Mass::getWeaponType(Containers::StringView prop_name, Containers::ArrayView<Weap
auto parts_prop = weapon_prop->at<ArrayProperty>(MASS_WEAPON_ELEMENT); auto parts_prop = weapon_prop->at<ArrayProperty>(MASS_WEAPON_ELEMENT);
weapon.parts = Containers::Array<WeaponPart>{ValueInit, parts_prop->items.size()}; weapon.parts = Containers::Array<WeaponPart>{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<GenericStructProperty>(j); auto part_prop = parts_prop->at<GenericStructProperty>(j);
auto& part = weapon.parts[j]; auto& part = weapon.parts[j];
part.id = part_prop->at<IntProperty>(MASS_WEAPON_PART_ID)->value; part.id = part_prop->at<IntProperty>(MASS_WEAPON_PART_ID)->value;
auto part_styles = part_prop->at<ArrayProperty>(MASS_WEAPON_PART_STYLES); auto part_styles = part_prop->at<ArrayProperty>(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<IntProperty>(k)->value; part.styles[k] = part_styles->at<IntProperty>(k)->value;
} }
@ -268,7 +268,7 @@ Mass::writeWeaponType(Containers::StringView prop_name, Containers::ArrayView<We
return false; return false;
} }
for(UnsignedInt i = 0; i < weapon_array.size(); i++) { for(std::uint32_t i = 0; i < weapon_array.size(); i++) {
auto weapon_prop = prop->at<GenericStructProperty>(i); auto weapon_prop = prop->at<GenericStructProperty>(i);
auto& weapon = weapon_array[i]; auto& weapon = weapon_array[i];
@ -292,14 +292,14 @@ Mass::writeWeaponType(Containers::StringView prop_name, Containers::ArrayView<We
return false; return false;
} }
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<GenericStructProperty>(j); auto part_prop = parts_prop->at<GenericStructProperty>(j);
auto& part = weapon.parts[j]; auto& part = weapon.parts[j];
part_prop->at<IntProperty>(MASS_WEAPON_PART_ID)->value = part.id; part_prop->at<IntProperty>(MASS_WEAPON_PART_ID)->value = part.id;
auto part_styles = part_prop->at<ArrayProperty>(MASS_WEAPON_PART_STYLES); auto part_styles = part_prop->at<ArrayProperty>(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<IntProperty>(k)->value = part.styles[k]; part_styles->at<IntProperty>(k)->value = part.styles[k];
} }
@ -338,7 +338,7 @@ Mass::writeWeaponType(Containers::StringView prop_name, Containers::ArrayView<We
return false; return false;
} }
for(UnsignedInt j = 0; j < weapon.customStyles.size(); j++) { for(std::uint32_t j = 0; j < weapon.customStyles.size(); j++) {
writeCustomStyle(weapon.customStyles[j], j, custom_styles); writeCustomStyle(weapon.customStyles[j], j, custom_styles);
} }

View file

@ -20,7 +20,7 @@ Weapon::Weapon(const Weapon& other) {
name = other.name; name = other.name;
type = other.type; type = other.type;
parts = Containers::Array<WeaponPart>{other.parts.size()}; parts = Containers::Array<WeaponPart>{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]; parts[i] = other.parts[i];
} }
customStyles = other.customStyles; customStyles = other.customStyles;
@ -35,7 +35,7 @@ Weapon& Weapon::operator=(const Weapon& other) {
name = other.name; name = other.name;
type = other.type; type = other.type;
parts = Containers::Array<WeaponPart>{other.parts.size()}; parts = Containers::Array<WeaponPart>{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]; parts[i] = other.parts[i];
} }
customStyles = other.customStyles; customStyles = other.customStyles;

View file

@ -19,13 +19,10 @@
#include <Corrade/Containers/Array.h> #include <Corrade/Containers/Array.h>
#include <Corrade/Containers/StaticArray.h> #include <Corrade/Containers/StaticArray.h>
#include <Magnum/Types.h>
#include "Decal.h" #include "Decal.h"
#include "Accessory.h" #include "Accessory.h"
using namespace Corrade; using namespace Corrade;
using namespace Magnum;
struct WeaponPart { struct WeaponPart {
WeaponPart() = default; WeaponPart() = default;
@ -34,11 +31,11 @@ struct WeaponPart {
id = other.id; id = other.id;
styles = other.styles; styles = other.styles;
decals = Containers::Array<Decal>{other.decals.size()}; decals = Containers::Array<Decal>{other.decals.size()};
for(UnsignedInt i = 0; i < decals.size(); i++) { for(auto i = 0u; i < decals.size(); i++) {
decals[i] = other.decals[i]; decals[i] = other.decals[i];
} }
accessories = Containers::Array<Accessory>{other.accessories.size()}; accessories = Containers::Array<Accessory>{other.accessories.size()};
for(UnsignedInt i = 0; i < accessories.size(); i++) { for(auto i = 0u; i < accessories.size(); i++) {
accessories[i] = other.accessories[i]; accessories[i] = other.accessories[i];
} }
} }
@ -46,11 +43,11 @@ struct WeaponPart {
id = other.id; id = other.id;
styles = other.styles; styles = other.styles;
decals = Containers::Array<Decal>{other.decals.size()}; decals = Containers::Array<Decal>{other.decals.size()};
for(UnsignedInt i = 0; i < decals.size(); i++) { for(auto i = 0u; i < decals.size(); i++) {
decals[i] = other.decals[i]; decals[i] = other.decals[i];
} }
accessories = Containers::Array<Accessory>{other.accessories.size()}; accessories = Containers::Array<Accessory>{other.accessories.size()};
for(UnsignedInt i = 0; i < accessories.size(); i++) { for(auto i = 0u; i < accessories.size(); i++) {
accessories[i] = other.accessories[i]; accessories[i] = other.accessories[i];
} }
return *this; return *this;
@ -59,8 +56,8 @@ struct WeaponPart {
WeaponPart(WeaponPart&& other) = default; WeaponPart(WeaponPart&& other) = default;
WeaponPart& operator=(WeaponPart&& other) = default; WeaponPart& operator=(WeaponPart&& other) = default;
Int id = 0; std::int32_t id = 0;
Containers::StaticArray<4, Int> styles{ValueInit}; Containers::StaticArray<4, std::int32_t> styles{ValueInit};
Containers::Array<Decal> decals{}; Containers::Array<Decal> decals{};
Containers::Array<Accessory> accessories{}; Containers::Array<Accessory> accessories{};
}; };

View file

@ -30,7 +30,7 @@ MassManager::MassManager(Containers::StringView save_path, Containers::StringVie
_saveDirectory{save_path}, _account{account}, _demo{demo}, _stagingAreaDirectory{staging_dir} _saveDirectory{save_path}, _account{account}, _demo{demo}, _stagingAreaDirectory{staging_dir}
{ {
Containers::String mass_filename = ""; 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, mass_filename = Utility::Path::join(_saveDirectory,
Utility::format("{}Unit{:.2d}{}.sav", demo ? "Demo"_s : ""_s, i, _account)); Utility::format("{}Unit{:.2d}{}.sav", demo ? "Demo"_s : ""_s, i, _account));
new(&_hangars[i]) Mass{mass_filename}; new(&_hangars[i]) Mass{mass_filename};
@ -45,12 +45,12 @@ MassManager::lastError() {
} }
Mass& Mass&
MassManager::hangar(Int hangar) { MassManager::hangar(std::int32_t hangar) {
return _hangars[hangar]; return _hangars[hangar];
} }
void void
MassManager::refreshHangar(Int hangar) { MassManager::refreshHangar(std::int32_t hangar) {
if(hangar < 0 || hangar >= 32) { if(hangar < 0 || hangar >= 32) {
_lastError = "Hangar index out of range."; _lastError = "Hangar index out of range.";
LOG_ERROR(_lastError); LOG_ERROR(_lastError);
@ -64,7 +64,7 @@ MassManager::refreshHangar(Int hangar) {
} }
bool bool
MassManager::importMass(Containers::StringView staged_fn, Int hangar) { MassManager::importMass(Containers::StringView staged_fn, std::int32_t hangar) {
if(hangar < 0 || hangar >= 32) { if(hangar < 0 || hangar >= 32) {
_lastError = "Hangar index out of range."; _lastError = "Hangar index out of range.";
LOG_ERROR(_lastError); LOG_ERROR(_lastError);
@ -107,7 +107,7 @@ MassManager::importMass(Containers::StringView staged_fn, Int hangar) {
} }
bool bool
MassManager::exportMass(Int hangar) { MassManager::exportMass(std::int32_t hangar) {
if(hangar < 0 || hangar >= 32) { if(hangar < 0 || hangar >= 32) {
_lastError = "Hangar index out of range."_s; _lastError = "Hangar index out of range."_s;
LOG_ERROR(_lastError); LOG_ERROR(_lastError);
@ -134,7 +134,7 @@ MassManager::exportMass(Int hangar) {
} }
bool bool
MassManager::moveMass(Int source, Int destination) { MassManager::moveMass(std::int32_t source, std::int32_t destination) {
if(source < 0 || source >= 32) { if(source < 0 || source >= 32) {
_lastError = "Source hangar index out of range."_s; _lastError = "Source hangar index out of range."_s;
LOG_ERROR(_lastError); LOG_ERROR(_lastError);
@ -172,7 +172,7 @@ MassManager::moveMass(Int source, Int destination) {
} }
bool bool
MassManager::deleteMass(Int hangar) { MassManager::deleteMass(std::int32_t hangar) {
if(hangar < 0 || hangar >= 32) { if(hangar < 0 || hangar >= 32) {
_lastError = "Hangar index out of range."_s; _lastError = "Hangar index out of range."_s;
LOG_ERROR(_lastError); LOG_ERROR(_lastError);

View file

@ -189,24 +189,24 @@ Profile::renameCompany(Containers::StringView new_name) {
return true; return true;
} }
Int std::int32_t
Profile::activeFrameSlot() const { Profile::activeFrameSlot() const {
return _activeFrameSlot; return _activeFrameSlot;
} }
Int std::int32_t
Profile::credits() const { Profile::credits() const {
return _credits; return _credits;
} }
bool bool
Profile::setCredits(Int amount) { Profile::setCredits(std::int32_t amount) {
auto credits_prop = _profile.at<IntProperty>(PROFILE_CREDITS); auto credits_prop = _profile.at<IntProperty>(PROFILE_CREDITS);
if(!credits_prop) { if(!credits_prop) {
credits_prop = new IntProperty; credits_prop = new IntProperty;
credits_prop->name.emplace("Credit"_s); credits_prop->name.emplace("Credit"_s);
credits_prop->valueLength = sizeof(Int); credits_prop->valueLength = sizeof(std::int32_t);
_profile.appendProperty(IntProperty::ptr{credits_prop}); _profile.appendProperty(IntProperty::ptr{credits_prop});
} }
@ -220,19 +220,19 @@ Profile::setCredits(Int amount) {
return true; return true;
} }
Int std::int32_t
Profile::storyProgress() const { Profile::storyProgress() const {
return _storyProgress; return _storyProgress;
} }
bool bool
Profile::setStoryProgress(Int progress) { Profile::setStoryProgress(std::int32_t progress) {
auto story_progress_prop = _profile.at<IntProperty>("StoryProgress"_s); auto story_progress_prop = _profile.at<IntProperty>("StoryProgress"_s);
if(!story_progress_prop) { if(!story_progress_prop) {
story_progress_prop = new IntProperty; story_progress_prop = new IntProperty;
story_progress_prop->name.emplace("StoryProgress"_s); 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}); _profile.appendProperty(IntProperty::ptr{story_progress_prop});
} }
@ -246,252 +246,252 @@ Profile::setStoryProgress(Int progress) {
return true; return true;
} }
Int std::int32_t
Profile::lastMissionId() const { Profile::lastMissionId() const {
return _lastMissionId; return _lastMissionId;
} }
Int std::int32_t
Profile::verseSteel() const { Profile::verseSteel() const {
return _verseSteel; return _verseSteel;
} }
bool bool
Profile::setVerseSteel(Int amount) { Profile::setVerseSteel(std::int32_t amount) {
return setResource(PROFILE_MATERIAL, VerseSteel, amount); return setResource(PROFILE_MATERIAL, VerseSteel, amount);
} }
Int std::int32_t
Profile::undinium() const { Profile::undinium() const {
return _undinium; return _undinium;
} }
bool bool
Profile::setUndinium(Int amount) { Profile::setUndinium(std::int32_t amount) {
return setResource(PROFILE_MATERIAL, Undinium, amount); return setResource(PROFILE_MATERIAL, Undinium, amount);
} }
Int std::int32_t
Profile::necriumAlloy() const { Profile::necriumAlloy() const {
return _necriumAlloy; return _necriumAlloy;
} }
bool bool
Profile::setNecriumAlloy(Int amount) { Profile::setNecriumAlloy(std::int32_t amount) {
return setResource(PROFILE_MATERIAL, NecriumAlloy, amount); return setResource(PROFILE_MATERIAL, NecriumAlloy, amount);
} }
Int std::int32_t
Profile::lunarite() const { Profile::lunarite() const {
return _lunarite; return _lunarite;
} }
bool bool
Profile::setLunarite(Int amount) { Profile::setLunarite(std::int32_t amount) {
return setResource(PROFILE_MATERIAL, Lunarite, amount); return setResource(PROFILE_MATERIAL, Lunarite, amount);
} }
Int std::int32_t
Profile::asterite() const { Profile::asterite() const {
return _asterite; return _asterite;
} }
bool bool
Profile::setAsterite(Int amount) { Profile::setAsterite(std::int32_t amount) {
return setResource(PROFILE_MATERIAL, Asterite, amount); return setResource(PROFILE_MATERIAL, Asterite, amount);
} }
Int std::int32_t
Profile::halliteFragma() const { Profile::halliteFragma() const {
return _halliteFragma; return _halliteFragma;
} }
bool bool
Profile::setHalliteFragma(Int amount) { Profile::setHalliteFragma(std::int32_t amount) {
return setResource(PROFILE_MATERIAL, HalliteFragma, amount); return setResource(PROFILE_MATERIAL, HalliteFragma, amount);
} }
Int std::int32_t
Profile::ednil() const { Profile::ednil() const {
return _ednil; return _ednil;
} }
bool bool
Profile::setEdnil(Int amount) { Profile::setEdnil(std::int32_t amount) {
return setResource(PROFILE_MATERIAL, Ednil, amount); return setResource(PROFILE_MATERIAL, Ednil, amount);
} }
Int std::int32_t
Profile::nuflalt() const { Profile::nuflalt() const {
return _nuflalt; return _nuflalt;
} }
bool bool
Profile::setNuflalt(Int amount) { Profile::setNuflalt(std::int32_t amount) {
return setResource(PROFILE_MATERIAL, Nuflalt, amount); return setResource(PROFILE_MATERIAL, Nuflalt, amount);
} }
Int std::int32_t
Profile::aurelene() const { Profile::aurelene() const {
return _aurelene; return _aurelene;
} }
bool bool
Profile::setAurelene(Int amount) { Profile::setAurelene(std::int32_t amount) {
return setResource(PROFILE_MATERIAL, Aurelene, amount); return setResource(PROFILE_MATERIAL, Aurelene, amount);
} }
Int std::int32_t
Profile::soldus() const { Profile::soldus() const {
return _soldus; return _soldus;
} }
bool bool
Profile::setSoldus(Int amount) { Profile::setSoldus(std::int32_t amount) {
return setResource(PROFILE_MATERIAL, Soldus, amount); return setResource(PROFILE_MATERIAL, Soldus, amount);
} }
Int std::int32_t
Profile::synthesisedN() const { Profile::synthesisedN() const {
return _synthesisedN; return _synthesisedN;
} }
bool bool
Profile::setSynthesisedN(Int amount) { Profile::setSynthesisedN(std::int32_t amount) {
return setResource(PROFILE_MATERIAL, SynthesisedN, amount); return setResource(PROFILE_MATERIAL, SynthesisedN, amount);
} }
Int std::int32_t
Profile::nanoc() const { Profile::nanoc() const {
return _nanoc; return _nanoc;
} }
bool bool
Profile::setNanoc(Int amount) { Profile::setNanoc(std::int32_t amount) {
return setResource(PROFILE_MATERIAL, Nanoc, amount); return setResource(PROFILE_MATERIAL, Nanoc, amount);
} }
Int std::int32_t
Profile::alcarbonite() const { Profile::alcarbonite() const {
return _alcarbonite; return _alcarbonite;
} }
bool bool
Profile::setAlcarbonite(Int amount) { Profile::setAlcarbonite(std::int32_t amount) {
return setResource(PROFILE_MATERIAL, Alcarbonite, amount); return setResource(PROFILE_MATERIAL, Alcarbonite, amount);
} }
Int std::int32_t
Profile::keriphene() const { Profile::keriphene() const {
return _keriphene; return _keriphene;
} }
bool bool
Profile::setKeriphene(Int amount) { Profile::setKeriphene(std::int32_t amount) {
return setResource(PROFILE_MATERIAL, Keriphene, amount); return setResource(PROFILE_MATERIAL, Keriphene, amount);
} }
Int std::int32_t
Profile::nitinolCM() const { Profile::nitinolCM() const {
return _nitinolCM; return _nitinolCM;
} }
bool bool
Profile::setNitinolCM(Int amount) { Profile::setNitinolCM(std::int32_t amount) {
return setResource(PROFILE_MATERIAL, NitinolCM, amount); return setResource(PROFILE_MATERIAL, NitinolCM, amount);
} }
Int std::int32_t
Profile::quarkium() const { Profile::quarkium() const {
return _quarkium; return _quarkium;
} }
bool bool
Profile::setQuarkium(Int amount) { Profile::setQuarkium(std::int32_t amount) {
return setResource(PROFILE_MATERIAL, Quarkium, amount); return setResource(PROFILE_MATERIAL, Quarkium, amount);
} }
Int std::int32_t
Profile::alterene() const { Profile::alterene() const {
return _alterene; return _alterene;
} }
bool bool
Profile::setAlterene(Int amount) { Profile::setAlterene(std::int32_t amount) {
return setResource(PROFILE_MATERIAL, Alterene, amount); return setResource(PROFILE_MATERIAL, Alterene, amount);
} }
Int std::int32_t
Profile::cosmium() const { Profile::cosmium() const {
return _cosmium; return _cosmium;
} }
bool bool
Profile::setCosmium(Int amount) { Profile::setCosmium(std::int32_t amount) {
return setResource(PROFILE_MATERIAL, Cosmium, amount); return setResource(PROFILE_MATERIAL, Cosmium, amount);
} }
Int std::int32_t
Profile::mixedComposition() const { Profile::mixedComposition() const {
return _mixedComposition; return _mixedComposition;
} }
bool bool
Profile::setMixedComposition(Int amount) { Profile::setMixedComposition(std::int32_t amount) {
return setResource(PROFILE_QUARK_DATA, MixedComposition, amount); return setResource(PROFILE_QUARK_DATA, MixedComposition, amount);
} }
Int std::int32_t
Profile::voidResidue() const { Profile::voidResidue() const {
return _voidResidue; return _voidResidue;
} }
bool bool
Profile::setVoidResidue(Int amount) { Profile::setVoidResidue(std::int32_t amount) {
return setResource(PROFILE_QUARK_DATA, VoidResidue, amount); return setResource(PROFILE_QUARK_DATA, VoidResidue, amount);
} }
Int std::int32_t
Profile::muscularConstruction() const { Profile::muscularConstruction() const {
return _muscularConstruction; return _muscularConstruction;
} }
bool bool
Profile::setMuscularConstruction(Int amount) { Profile::setMuscularConstruction(std::int32_t amount) {
return setResource(PROFILE_QUARK_DATA, MuscularConstruction, amount); return setResource(PROFILE_QUARK_DATA, MuscularConstruction, amount);
} }
Int std::int32_t
Profile::mineralExoskeletology() const { Profile::mineralExoskeletology() const {
return _mineralExoskeletology; return _mineralExoskeletology;
} }
bool bool
Profile::setMineralExoskeletology(Int amount) { Profile::setMineralExoskeletology(std::int32_t amount) {
return setResource(PROFILE_QUARK_DATA, MineralExoskeletology, amount); return setResource(PROFILE_QUARK_DATA, MineralExoskeletology, amount);
} }
Int std::int32_t
Profile::carbonisedSkin() const { Profile::carbonisedSkin() const {
return _carbonisedSkin; return _carbonisedSkin;
} }
bool bool
Profile::setCarbonisedSkin(Int amount) { Profile::setCarbonisedSkin(std::int32_t amount) {
return setResource(PROFILE_QUARK_DATA, CarbonisedSkin, amount); return setResource(PROFILE_QUARK_DATA, CarbonisedSkin, amount);
} }
Int std::int32_t
Profile::isolatedVoidParticle() const { Profile::isolatedVoidParticle() const {
return _isolatedVoidParticle; return _isolatedVoidParticle;
} }
bool bool
Profile::setIsolatedVoidParticle(Int amount) { Profile::setIsolatedVoidParticle(std::int32_t amount) {
return setResource(PROFILE_QUARK_DATA, IsolatedVoidParticle, amount); return setResource(PROFILE_QUARK_DATA, IsolatedVoidParticle, amount);
} }
Int std::int32_t
Profile::getResource(Containers::StringView container, MaterialID id) { Profile::getResource(Containers::StringView container, MaterialID id) {
auto mats_prop = _profile.at<ArrayProperty>(container); auto mats_prop = _profile.at<ArrayProperty>(container);
@ -509,7 +509,7 @@ Profile::getResource(Containers::StringView container, MaterialID id) {
} }
bool 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<ArrayProperty>(container); auto mats_prop = _profile.at<ArrayProperty>(container);
if(!mats_prop) { if(!mats_prop) {

View file

@ -19,16 +19,13 @@
#include <Corrade/Containers/String.h> #include <Corrade/Containers/String.h>
#include <Corrade/Containers/StringView.h> #include <Corrade/Containers/StringView.h>
#include <Magnum/Magnum.h>
#include "../UESaveFile/UESaveFile.h" #include "../UESaveFile/UESaveFile.h"
#include "ResourceIDs.h" #include "ResourceIDs.h"
using namespace Corrade; using namespace Corrade;
using namespace Magnum;
enum class ProfileType : UnsignedByte { enum class ProfileType: std::uint8_t {
Demo, Demo,
FullGame FullGame
}; };
@ -37,14 +34,14 @@ class Profile {
public: public:
explicit Profile(Containers::StringView path); explicit Profile(Containers::StringView path);
auto valid() const -> bool; bool valid() const;
auto lastError() const -> Containers::StringView; auto lastError() const -> Containers::StringView;
auto filename() const -> Containers::StringView; auto filename() const -> Containers::StringView;
auto type() const -> ProfileType; ProfileType type() const;
auto isDemo() const -> bool; bool isDemo() const;
auto account() const -> Containers::StringView; auto account() const -> Containers::StringView;
@ -53,91 +50,91 @@ class Profile {
auto companyName() const -> Containers::StringView; auto companyName() const -> Containers::StringView;
bool renameCompany(Containers::StringView new_name); bool renameCompany(Containers::StringView new_name);
auto activeFrameSlot() const -> Int; std::int32_t activeFrameSlot() const;
auto credits() const -> Int; std::int32_t credits() const;
bool setCredits(Int credits); bool setCredits(std::int32_t credits);
auto storyProgress() const -> Int; std::int32_t storyProgress() const;
bool setStoryProgress(Int progress); bool setStoryProgress(std::int32_t progress);
auto lastMissionId() const -> Int; std::int32_t lastMissionId() const;
auto verseSteel() const -> Int; std::int32_t verseSteel() const;
bool setVerseSteel(Int amount); bool setVerseSteel(std::int32_t amount);
auto undinium() const -> Int; std::int32_t undinium() const;
bool setUndinium(Int amount); bool setUndinium(std::int32_t amount);
auto necriumAlloy() const -> Int; std::int32_t necriumAlloy() const;
bool setNecriumAlloy(Int amount); bool setNecriumAlloy(std::int32_t amount);
auto lunarite() const -> Int; std::int32_t lunarite() const;
bool setLunarite(Int amount); bool setLunarite(std::int32_t amount);
auto asterite() const -> Int; std::int32_t asterite() const;
bool setAsterite(Int amount); bool setAsterite(std::int32_t amount);
Int halliteFragma() const; std::int32_t halliteFragma() const;
bool setHalliteFragma(Int amount); bool setHalliteFragma(std::int32_t amount);
auto ednil() const -> Int; std::int32_t ednil() const;
bool setEdnil(Int amount); bool setEdnil(std::int32_t amount);
auto nuflalt() const -> Int; std::int32_t nuflalt() const;
bool setNuflalt(Int amount); bool setNuflalt(std::int32_t amount);
auto aurelene() const -> Int; std::int32_t aurelene() const;
bool setAurelene(Int amount); bool setAurelene(std::int32_t amount);
auto soldus() const -> Int; std::int32_t soldus() const;
bool setSoldus(Int amount); bool setSoldus(std::int32_t amount);
auto synthesisedN() const -> Int; std::int32_t synthesisedN() const;
bool setSynthesisedN(Int amount); bool setSynthesisedN(std::int32_t amount);
Int nanoc() const; std::int32_t nanoc() const;
bool setNanoc(Int amount); bool setNanoc(std::int32_t amount);
auto alcarbonite() const -> Int; std::int32_t alcarbonite() const;
bool setAlcarbonite(Int amount); bool setAlcarbonite(std::int32_t amount);
auto keriphene() const -> Int; std::int32_t keriphene() const;
bool setKeriphene(Int amount); bool setKeriphene(std::int32_t amount);
auto nitinolCM() const -> Int; std::int32_t nitinolCM() const;
bool setNitinolCM(Int amount); bool setNitinolCM(std::int32_t amount);
auto quarkium() const -> Int; std::int32_t quarkium() const;
bool setQuarkium(Int amount); bool setQuarkium(std::int32_t amount);
auto alterene() const -> Int; std::int32_t alterene() const;
bool setAlterene(Int amount); bool setAlterene(std::int32_t amount);
Int cosmium() const; std::int32_t cosmium() const;
bool setCosmium(Int amount); bool setCosmium(std::int32_t amount);
auto mixedComposition() const -> Int; std::int32_t mixedComposition() const;
bool setMixedComposition(Int amount); bool setMixedComposition(std::int32_t amount);
auto voidResidue() const -> Int; std::int32_t voidResidue() const;
bool setVoidResidue(Int amount); bool setVoidResidue(std::int32_t amount);
auto muscularConstruction() const -> Int; std::int32_t muscularConstruction() const;
bool setMuscularConstruction(Int amount); bool setMuscularConstruction(std::int32_t amount);
auto mineralExoskeletology() const -> Int; std::int32_t mineralExoskeletology() const;
bool setMineralExoskeletology(Int amount); bool setMineralExoskeletology(std::int32_t amount);
auto carbonisedSkin() const -> Int; std::int32_t carbonisedSkin() const;
bool setCarbonisedSkin(Int amount); bool setCarbonisedSkin(std::int32_t amount);
Int isolatedVoidParticle() const; std::int32_t isolatedVoidParticle() const;
bool setIsolatedVoidParticle(Int amount); bool setIsolatedVoidParticle(std::int32_t amount);
private: private:
Int getResource(Containers::StringView container, MaterialID id); std::int32_t getResource(Containers::StringView container, MaterialID id);
bool setResource(Containers::StringView container, MaterialID id, Int amount); bool setResource(Containers::StringView container, MaterialID id, std::int32_t amount);
Containers::String _filename; Containers::String _filename;
@ -146,38 +143,38 @@ class Profile {
UESaveFile _profile; UESaveFile _profile;
Containers::String _name; Containers::String _name;
Int _activeFrameSlot = 0; std::int32_t _activeFrameSlot = 0;
Int _credits = 0; std::int32_t _credits = 0;
Int _storyProgress = 0; std::int32_t _storyProgress = 0;
Int _lastMissionId = 0; std::int32_t _lastMissionId = 0;
Int _verseSteel = 0; std::int32_t _verseSteel = 0;
Int _undinium = 0; std::int32_t _undinium = 0;
Int _necriumAlloy = 0; std::int32_t _necriumAlloy = 0;
Int _lunarite = 0; std::int32_t _lunarite = 0;
Int _asterite = 0; std::int32_t _asterite = 0;
Int _halliteFragma = 0; std::int32_t _halliteFragma = 0;
Int _ednil = 0; std::int32_t _ednil = 0;
Int _nuflalt = 0; std::int32_t _nuflalt = 0;
Int _aurelene = 0; std::int32_t _aurelene = 0;
Int _soldus = 0; std::int32_t _soldus = 0;
Int _synthesisedN = 0; std::int32_t _synthesisedN = 0;
Int _nanoc = 0; std::int32_t _nanoc = 0;
Int _alcarbonite = 0; std::int32_t _alcarbonite = 0;
Int _keriphene = 0; std::int32_t _keriphene = 0;
Int _nitinolCM = 0; std::int32_t _nitinolCM = 0;
Int _quarkium = 0; std::int32_t _quarkium = 0;
Int _alterene = 0; std::int32_t _alterene = 0;
Int _cosmium = 0; std::int32_t _cosmium = 0;
Int _mixedComposition = 0; std::int32_t _mixedComposition = 0;
Int _voidResidue = 0; std::int32_t _voidResidue = 0;
Int _muscularConstruction = 0; std::int32_t _muscularConstruction = 0;
Int _mineralExoskeletology = 0; std::int32_t _mineralExoskeletology = 0;
Int _carbonisedSkin = 0; std::int32_t _carbonisedSkin = 0;
Int _isolatedVoidParticle = 0; std::int32_t _isolatedVoidParticle = 0;
Containers::String _account; Containers::String _account;

View file

@ -16,11 +16,7 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <Magnum/Types.h> enum MaterialID : std::int32_t {
using namespace Magnum;
enum MaterialID : Int {
VerseSteel = 0xC3500, VerseSteel = 0xC3500,
Undinium = 0xC3501, Undinium = 0xC3501,
NecriumAlloy = 0xC3502, NecriumAlloy = 0xC3502,

View file

@ -114,7 +114,7 @@ ProfileManager::deleteProfile(std::size_t index, bool delete_builds) {
} }
if(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", auto filename = Utility::format("{}Unit{:.2d}{}.sav",
_profiles[index].type() == ProfileType::Demo ? "Demo": "", _profiles[index].type() == ProfileType::Demo ? "Demo": "",
i, _profiles[index].account()); 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()); zip_set_archive_comment(zip, comment.data(), comment.size());
if(backup_builds) { 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", auto build_filename = Utility::format("{}Unit{:.2d}{}.sav",
profile.isDemo() ? "Demo"_s : ""_s, i, profile.isDemo() ? "Demo"_s : ""_s, i,
profile.account()); profile.account());
@ -247,7 +247,7 @@ ProfileManager::refreshBackups() {
Containers::ScopeGuard guard{zip, zip_close}; 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) { if(num_entries == 0) {
continue; continue;
@ -291,7 +291,7 @@ ProfileManager::refreshBackups() {
arrayReserve(backup.includedFiles, num_entries); 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)); 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}; 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) { while((bytes_read = zip_fread(zf, buf.data(), buf.size())) > 0) {
if(std::fwrite(buf.data(), sizeof(char), bytes_read, out) < static_cast<std::size_t>(bytes_read)) { if(std::fwrite(buf.data(), sizeof(char), bytes_read, out) < static_cast<std::size_t>(bytes_read)) {
_lastError = Utility::format(error_format.data(), file, "not enough bytes written."); _lastError = Utility::format(error_format.data(), file, "not enough bytes written.");

View file

@ -16,6 +16,8 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <cstdint>
#include <string> #include <string>
#include <Corrade/Containers/Array.h> #include <Corrade/Containers/Array.h>
@ -30,12 +32,12 @@ struct Backup {
Containers::String company; Containers::String company;
ProfileType type; ProfileType type;
struct { struct {
int year; std::int32_t year;
int month; std::int32_t month;
int day; std::int32_t day;
int hour; std::int32_t hour;
int minute; std::int32_t minute;
int second; std::int32_t second;
} timestamp; } timestamp;
Containers::Array<Containers::String> includedFiles; Containers::Array<Containers::String> includedFiles;
}; };

View file

@ -58,8 +58,6 @@ SaveTool::SaveTool(const Arguments& arguments):
LOG_INFO("Configuring OpenGL renderer."); LOG_INFO("Configuring OpenGL renderer.");
GL::Renderer::enable(GL::Renderer::Feature::Blending); GL::Renderer::enable(GL::Renderer::Feature::Blending);
GL::Renderer::enable(GL::Renderer::Feature::ScissorTest); 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::setBlendFunction(GL::Renderer::BlendFunction::SourceAlpha,
GL::Renderer::BlendFunction::OneMinusSourceAlpha); GL::Renderer::BlendFunction::OneMinusSourceAlpha);
GL::Renderer::setBlendEquation(GL::Renderer::BlendEquation::Add, GL::Renderer::setBlendEquation(GL::Renderer::BlendEquation::Add,
@ -79,7 +77,7 @@ SaveTool::SaveTool(const Arguments& arguments):
#endif #endif
LOG_INFO("Registering custom events."); 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_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error",
"SDL_RegisterEvents() failed in SaveTool::SaveTool(). Exiting...", window()); "SDL_RegisterEvents() failed in SaveTool::SaveTool(). Exiting...", window());
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
@ -116,7 +114,7 @@ SaveTool::SaveTool(const Arguments& arguments):
checkGameState(); checkGameState();
_gameCheckTimerId = SDL_AddTimer(2000, _gameCheckTimerId = SDL_AddTimer(2000,
[](UnsignedInt interval, void* param)->UnsignedInt{ [](std::uint32_t interval, void* param)->std::uint32_t{
static_cast<SaveTool*>(param)->checkGameState(); static_cast<SaveTool*>(param)->checkGameState();
return interval; return interval;
}, this); }, this);
@ -405,13 +403,13 @@ SaveTool::drawGameState() {
} }
void void
SaveTool::drawHelpMarker(Containers::StringView text, Float wrap_pos) { SaveTool::drawHelpMarker(Containers::StringView text, float wrap_pos) {
ImGui::TextUnformatted(ICON_FA_QUESTION_CIRCLE); ImGui::TextUnformatted(ICON_FA_QUESTION_CIRCLE);
drawTooltip(text, wrap_pos); drawTooltip(text, wrap_pos);
} }
void void
SaveTool::drawTooltip(Containers::StringView text, Float wrap_pos) { SaveTool::drawTooltip(Containers::StringView text, float wrap_pos) {
if(ImGui::IsItemHovered()){ if(ImGui::IsItemHovered()){
ImGui::BeginTooltip(); ImGui::BeginTooltip();
if(wrap_pos > 0.0f) { if(wrap_pos > 0.0f) {

View file

@ -77,20 +77,20 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener
void anyEvent(SDL_Event& event) override; void anyEvent(SDL_Event& event) override;
enum InitStatus: Int { enum InitStatus: std::int32_t {
InitSuccess, InitSuccess,
ProfileManagerFailure ProfileManagerFailure
}; };
void initEvent(SDL_Event& event); void initEvent(SDL_Event& event);
enum UpdateCheckStatus : Int { enum UpdateCheckStatus : std::int32_t {
CurlInitFailed = 0, CurlInitFailed = 0,
CurlError = 1, CurlError = 1,
CurlTimeout = 2, CurlTimeout = 2,
}; };
void updateCheckEvent(SDL_Event& event); void updateCheckEvent(SDL_Event& event);
enum FileEventType: Int { enum FileEventType: std::int32_t {
FileAdded = efsw::Action::Add, FileAdded = efsw::Action::Add,
FileDeleted = efsw::Action::Delete, FileDeleted = efsw::Action::Delete,
FileModified = efsw::Action::Modified, FileModified = efsw::Action::Modified,
@ -126,8 +126,8 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener
void drawGeneralInfo(); void drawGeneralInfo();
void drawResearchInventory(); void drawResearchInventory();
template<typename Getter, typename Setter> template<typename Getter, typename Setter>
void drawMaterialRow(Containers::StringView name, Int tier, Getter getter, Setter setter); void drawMaterialRow(Containers::StringView name, std::int32_t tier, Getter getter, Setter setter);
void drawUnavailableMaterialRow(Containers::StringView name, Int tier); void drawUnavailableMaterialRow(Containers::StringView name, std::int32_t tier);
void drawMassManager(); void drawMassManager();
ImGuiID drawDeleteMassPopup(int mass_index); ImGuiID drawDeleteMassPopup(int mass_index);
ImGuiID drawDeleteStagedMassPopup(Containers::StringView filename); ImGuiID drawDeleteStagedMassPopup(Containers::StringView filename);
@ -148,7 +148,7 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener
void drawTuning(); void drawTuning();
void drawDecalEditor(Decal& decal); void drawDecalEditor(Decal& decal);
void drawAccessoryEditor(Accessory& accessory, Containers::ArrayView<CustomStyle> style_view); void drawAccessoryEditor(Accessory& accessory, Containers::ArrayView<CustomStyle> style_view);
Containers::StringView getStyleName(Int id, Containers::ArrayView<CustomStyle> view); Containers::StringView getStyleName(std::int32_t id, Containers::ArrayView<CustomStyle> view);
enum DCSResult { enum DCSResult {
DCS_Fail, DCS_Fail,
@ -161,8 +161,8 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener
void drawGameState(); void drawGameState();
// Convenience wrappers over ImGui stuff // Convenience wrappers over ImGui stuff
void drawHelpMarker(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); void drawTooltip(Containers::StringView text, float wrap_pos = 0.0f);
bool drawCheckbox(Containers::StringView label, bool value); bool drawCheckbox(Containers::StringView label, bool value);
template<typename Functor, typename... Args> template<typename Functor, typename... Args>
@ -222,9 +222,9 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener
std::thread _initThread; std::thread _initThread;
std::thread _updateThread; std::thread _updateThread;
UnsignedInt _initEventId; std::uint32_t _initEventId;
UnsignedInt _updateEventId; std::uint32_t _updateEventId;
UnsignedInt _fileEventId; std::uint32_t _fileEventId;
Containers::String _lastError; Containers::String _lastError;
@ -240,7 +240,7 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener
//Containers::String _weaponsDir; //Containers::String _weaponsDir;
//Containers::String _stylesDir; //Containers::String _stylesDir;
enum class GameState : UnsignedByte { enum class GameState : std::uint8_t {
Unknown, NotRunning, Running Unknown, NotRunning, Running
} _gameState{GameState::Unknown}; } _gameState{GameState::Unknown};
@ -270,12 +270,12 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener
bool _jointsDirty{false}; bool _jointsDirty{false};
bool _stylesDirty{false}; bool _stylesDirty{false};
bool _eyeFlareDirty{false}; bool _eyeFlareDirty{false};
Containers::StaticArray<38, Int> _selectedArmourDecals{ValueInit}; Containers::StaticArray<38, std::int32_t> _selectedArmourDecals{ValueInit};
Containers::StaticArray<38, Int> _selectedArmourAccessories{ValueInit}; Containers::StaticArray<38, std::int32_t> _selectedArmourAccessories{ValueInit};
Int _selectedBLPlacement{0}; std::int32_t _selectedBLPlacement{0};
Int _selectedWeaponPart{0}; std::int32_t _selectedWeaponPart{0};
Int _selectedWeaponDecal{0}; std::int32_t _selectedWeaponDecal{0};
Int _selectedWeaponAccessory{0}; std::int32_t _selectedWeaponAccessory{0};
bool _meleeDirty{false}; bool _meleeDirty{false};
bool _shieldsDirty{false}; bool _shieldsDirty{false};
bool _bShootersDirty{false}; bool _bShootersDirty{false};

View file

@ -73,8 +73,8 @@ SaveTool::fileUpdateEvent(SDL_Event& event) {
Containers::String old_filename; Containers::String old_filename;
Int index = 0; std::int32_t index = 0;
Int old_index = 0; std::int32_t old_index = 0;
bool is_current_profile = filename == _currentProfile->filename(); bool is_current_profile = filename == _currentProfile->filename();
bool is_unit = filename.hasPrefix(_currentProfile->isDemo() ? "DemoUnit"_s : "Unit"_s); bool is_unit = filename.hasPrefix(_currentProfile->isDemo() ? "DemoUnit"_s : "Unit"_s);
if(is_unit) { if(is_unit) {

View file

@ -73,7 +73,7 @@ SaveTool::initialiseGui() {
font_config.FontDataOwnedByAtlas = false; font_config.FontDataOwnedByAtlas = false;
std::strcpy(font_config.Name, "Source Sans Pro"); std::strcpy(font_config.Name, "Source Sans Pro");
io.Fonts->AddFontFromMemoryTTF(const_cast<char*>(reg_font.data()), int(reg_font.size()), io.Fonts->AddFontFromMemoryTTF(const_cast<char*>(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); auto icon_font = _rs.getRaw(FONT_ICON_FILE_NAME_FAS);
static const ImWchar icon_range[] = { ICON_MIN_FA, ICON_MAX_FA, 0 }; 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.OversampleH = icon_config.OversampleV = 1;
icon_config.GlyphMinAdvanceX = 18.0f; icon_config.GlyphMinAdvanceX = 18.0f;
io.Fonts->AddFontFromMemoryTTF(const_cast<char*>(icon_font.data()), int(icon_font.size()), io.Fonts->AddFontFromMemoryTTF(const_cast<char*>(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); auto brand_font = _rs.getRaw(FONT_ICON_FILE_NAME_FAB);
static const ImWchar brand_range[] = { ICON_MIN_FAB, ICON_MAX_FAB, 0 }; static const ImWchar brand_range[] = { ICON_MIN_FAB, ICON_MAX_FAB, 0 };
io.Fonts->AddFontFromMemoryTTF(const_cast<char*>(brand_font.data()), int(brand_font.size()), io.Fonts->AddFontFromMemoryTTF(const_cast<char*>(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); auto mono_font = _rs.getRaw("SourceCodePro-Regular.ttf"_s);
ImVector<ImWchar> range; ImVector<ImWchar> 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.AddChar(u'š'); // This allows displaying Vladimír Vondruš' name in Corrade's and Magnum's licences.
builder.BuildRanges(&range); builder.BuildRanges(&range);
io.Fonts->AddFontFromMemoryTTF(const_cast<char*>(mono_font.data()), int(mono_font.size()), io.Fonts->AddFontFromMemoryTTF(const_cast<char*>(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()); _imgui = ImGuiIntegration::Context(*ImGui::GetCurrentContext(), windowSize());

View file

@ -31,7 +31,7 @@
void void
SaveTool::drawManager() { SaveTool::drawManager() {
ImGui::SetNextWindowPos({0.0f, ImGui::GetItemRectSize().y}, ImGuiCond_Always); 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); ImGuiCond_Always);
if(!ImGui::Begin("##MainWindow", nullptr, if(!ImGui::Begin("##MainWindow", nullptr,
ImGuiWindowFlags_NoDecoration|ImGuiWindowFlags_NoMove| 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.", drawTooltip("This is the last mission selected in the mission selection screen, not the last mission played.",
float(windowSize().x()) * 0.35f); 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::Dummy({ImGui::GetContentRegionAvail().x, ImGui::GetContentRegionAvail().y - footer_height_to_reserve});
ImGui::Separator(); ImGui::Separator();
@ -235,7 +235,7 @@ SaveTool::drawGeneralInfo() {
ImGui::SameLine(); ImGui::SameLine();
static Int credits; static std::int32_t credits;
if(drawUnsafeWidget([]{ return ImGui::Button("Edit credits"); })) { if(drawUnsafeWidget([]{ return ImGui::Button("Edit credits"); })) {
credits = _currentProfile->credits(); credits = _currentProfile->credits();
ImGui::OpenPopup("int_edit"); ImGui::OpenPopup("int_edit");
@ -302,22 +302,22 @@ SaveTool::drawResearchInventory() {
drawMaterialRow("Verse steel", 1, drawMaterialRow("Verse steel", 1,
[this]{ return _currentProfile->verseSteel(); }, [this]{ return _currentProfile->verseSteel(); },
[this](Int amount){ return _currentProfile->setVerseSteel(amount); }); [this](std::int32_t amount){ return _currentProfile->setVerseSteel(amount); });
drawMaterialRow("Undinium", 2, drawMaterialRow("Undinium", 2,
[this]{ return _currentProfile->undinium(); }, [this]{ return _currentProfile->undinium(); },
[this](Int amount){ return _currentProfile->setUndinium(amount); }); [this](std::int32_t amount){ return _currentProfile->setUndinium(amount); });
drawMaterialRow("Necrium alloy", 3, drawMaterialRow("Necrium alloy", 3,
[this]{ return _currentProfile->necriumAlloy(); }, [this]{ return _currentProfile->necriumAlloy(); },
[this](Int amount){ return _currentProfile->setNecriumAlloy(amount); }); [this](std::int32_t amount){ return _currentProfile->setNecriumAlloy(amount); });
drawMaterialRow("Lunarite", 4, drawMaterialRow("Lunarite", 4,
[this]{ return _currentProfile->lunarite(); }, [this]{ return _currentProfile->lunarite(); },
[this](Int amount){ return _currentProfile->setLunarite(amount); }); [this](std::int32_t amount){ return _currentProfile->setLunarite(amount); });
drawMaterialRow("Asterite", 5, drawMaterialRow("Asterite", 5,
[this]{ return _currentProfile->asterite(); }, [this]{ return _currentProfile->asterite(); },
[this](Int amount){ return _currentProfile->setAsterite(amount); }); [this](std::int32_t amount){ return _currentProfile->setAsterite(amount); });
drawMaterialRow("Hallite fragma", 6, drawMaterialRow("Hallite fragma", 6,
[this]{ return _currentProfile->halliteFragma(); }, [this]{ return _currentProfile->halliteFragma(); },
[this](Int amount){ return _currentProfile->setHalliteFragma(amount); }); [this](std::int32_t amount){ return _currentProfile->setHalliteFragma(amount); });
drawUnavailableMaterialRow("Unnoctinium", 7); drawUnavailableMaterialRow("Unnoctinium", 7);
ImGui::TableNextRow(ImGuiTableRowFlags_Headers); ImGui::TableNextRow(ImGuiTableRowFlags_Headers);
@ -326,22 +326,22 @@ SaveTool::drawResearchInventory() {
drawMaterialRow("Ednil", 1, drawMaterialRow("Ednil", 1,
[this]{ return _currentProfile->ednil(); }, [this]{ return _currentProfile->ednil(); },
[this](Int amount){ return _currentProfile->setEdnil(amount); }); [this](std::int32_t amount){ return _currentProfile->setEdnil(amount); });
drawMaterialRow("Nuflalt", 2, drawMaterialRow("Nuflalt", 2,
[this]{ return _currentProfile->nuflalt(); }, [this]{ return _currentProfile->nuflalt(); },
[this](Int amount){ return _currentProfile->setNuflalt(amount); }); [this](std::int32_t amount){ return _currentProfile->setNuflalt(amount); });
drawMaterialRow("Aurelene", 3, drawMaterialRow("Aurelene", 3,
[this]{ return _currentProfile->aurelene(); }, [this]{ return _currentProfile->aurelene(); },
[this](Int amount){ return _currentProfile->setAurelene(amount); }); [this](std::int32_t amount){ return _currentProfile->setAurelene(amount); });
drawMaterialRow("Soldus", 4, drawMaterialRow("Soldus", 4,
[this]{ return _currentProfile->soldus(); }, [this]{ return _currentProfile->soldus(); },
[this](Int amount){ return _currentProfile->setSoldus(amount); }); [this](std::int32_t amount){ return _currentProfile->setSoldus(amount); });
drawMaterialRow("Synthesized N", 5, drawMaterialRow("Synthesized N", 5,
[this]{ return _currentProfile->synthesisedN(); }, [this]{ return _currentProfile->synthesisedN(); },
[this](Int amount){ return _currentProfile->setSynthesisedN(amount); }); [this](std::int32_t amount){ return _currentProfile->setSynthesisedN(amount); });
drawMaterialRow("Nanoc", 6, drawMaterialRow("Nanoc", 6,
[this]{ return _currentProfile->nanoc(); }, [this]{ return _currentProfile->nanoc(); },
[this](Int amount){ return _currentProfile->setNanoc(amount); }); [this](std::int32_t amount){ return _currentProfile->setNanoc(amount); });
drawUnavailableMaterialRow("Abyssillite", 7); drawUnavailableMaterialRow("Abyssillite", 7);
ImGui::TableNextRow(ImGuiTableRowFlags_Headers); ImGui::TableNextRow(ImGuiTableRowFlags_Headers);
@ -350,22 +350,22 @@ SaveTool::drawResearchInventory() {
drawMaterialRow("Alcarbonite", 1, drawMaterialRow("Alcarbonite", 1,
[this]{ return _currentProfile->alcarbonite(); }, [this]{ return _currentProfile->alcarbonite(); },
[this](Int amount){ return _currentProfile->setAlcarbonite(amount); }); [this](std::int32_t amount){ return _currentProfile->setAlcarbonite(amount); });
drawMaterialRow("Keripehene", 2, drawMaterialRow("Keripehene", 2,
[this]{ return _currentProfile->keriphene(); }, [this]{ return _currentProfile->keriphene(); },
[this](Int amount){ return _currentProfile->setKeriphene(amount); }); [this](std::int32_t amount){ return _currentProfile->setKeriphene(amount); });
drawMaterialRow("Nitinol-CM", 3, drawMaterialRow("Nitinol-CM", 3,
[this]{ return _currentProfile->nitinolCM(); }, [this]{ return _currentProfile->nitinolCM(); },
[this](Int amount){ return _currentProfile->setNitinolCM(amount); }); [this](std::int32_t amount){ return _currentProfile->setNitinolCM(amount); });
drawMaterialRow("Quarkium", 4, drawMaterialRow("Quarkium", 4,
[this]{ return _currentProfile->quarkium(); }, [this]{ return _currentProfile->quarkium(); },
[this](Int amount){ return _currentProfile->setQuarkium(amount); }); [this](std::int32_t amount){ return _currentProfile->setQuarkium(amount); });
drawMaterialRow("Alterene", 5, drawMaterialRow("Alterene", 5,
[this]{ return _currentProfile->alterene(); }, [this]{ return _currentProfile->alterene(); },
[this](Int amount){ return _currentProfile->setAlterene(amount); }); [this](std::int32_t amount){ return _currentProfile->setAlterene(amount); });
drawMaterialRow("Cosmium", 6, drawMaterialRow("Cosmium", 6,
[this]{ return _currentProfile->cosmium(); }, [this]{ return _currentProfile->cosmium(); },
[this](Int amount){ return _currentProfile->setCosmium(amount); }); [this](std::int32_t amount){ return _currentProfile->setCosmium(amount); });
drawUnavailableMaterialRow("Purified quarkium", 7); drawUnavailableMaterialRow("Purified quarkium", 7);
ImGui::TableNextRow(ImGuiTableRowFlags_Headers); ImGui::TableNextRow(ImGuiTableRowFlags_Headers);
@ -374,22 +374,22 @@ SaveTool::drawResearchInventory() {
drawMaterialRow("Mixed composition", 1, drawMaterialRow("Mixed composition", 1,
[this]{ return _currentProfile->mixedComposition(); }, [this]{ return _currentProfile->mixedComposition(); },
[this](Int amount){ return _currentProfile->setMixedComposition(amount); }); [this](std::int32_t amount){ return _currentProfile->setMixedComposition(amount); });
drawMaterialRow("Void residue", 2, drawMaterialRow("Void residue", 2,
[this]{ return _currentProfile->voidResidue(); }, [this]{ return _currentProfile->voidResidue(); },
[this](Int amount){ return _currentProfile->setVoidResidue(amount); }); [this](std::int32_t amount){ return _currentProfile->setVoidResidue(amount); });
drawMaterialRow("Muscular construction", 3, drawMaterialRow("Muscular construction", 3,
[this]{ return _currentProfile->muscularConstruction(); }, [this]{ return _currentProfile->muscularConstruction(); },
[this](Int amount){ return _currentProfile->setMuscularConstruction(amount); }); [this](std::int32_t amount){ return _currentProfile->setMuscularConstruction(amount); });
drawMaterialRow("Mineral exoskeletology", 4, drawMaterialRow("Mineral exoskeletology", 4,
[this]{ return _currentProfile->mineralExoskeletology(); }, [this]{ return _currentProfile->mineralExoskeletology(); },
[this](Int amount){ return _currentProfile->setMineralExoskeletology(amount); }); [this](std::int32_t amount){ return _currentProfile->setMineralExoskeletology(amount); });
drawMaterialRow("Carbonized skin", 5, drawMaterialRow("Carbonized skin", 5,
[this]{ return _currentProfile->carbonisedSkin(); }, [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, drawMaterialRow("Isolated void particle", 6,
[this]{ return _currentProfile->isolatedVoidParticle(); }, [this]{ return _currentProfile->isolatedVoidParticle(); },
[this](Int amount){ return _currentProfile->setIsolatedVoidParticle(amount); }); [this](std::int32_t amount){ return _currentProfile->setIsolatedVoidParticle(amount); });
drawUnavailableMaterialRow("Weaponised physiology", 7); drawUnavailableMaterialRow("Weaponised physiology", 7);
ImGui::EndTable(); ImGui::EndTable();
@ -398,9 +398,9 @@ SaveTool::drawResearchInventory() {
template<typename Getter, typename Setter> template<typename Getter, typename Setter>
void void
SaveTool::drawMaterialRow(Containers::StringView name, Int tier, Getter getter, Setter setter) { SaveTool::drawMaterialRow(Containers::StringView name, std::int32_t tier, Getter getter, Setter setter) {
static_assert(std::is_same<decltype(getter()), Int>::value, "getter doesn't return an Int, and/or doesn't take zero arguments."); static_assert(std::is_same<decltype(getter()), std::int32_t>::value, "getter doesn't return an std::int32_t, and/or doesn't take zero arguments.");
static_assert(std::is_same<decltype(setter(0)), bool>::value, "setter doesn't return a bool, and/or doesn't take a single Int as an argument."); static_assert(std::is_same<decltype(setter(0)), bool>::value, "setter doesn't return a bool, and/or doesn't take a single std::int32_t as an argument.");
ImGui::TableNextRow(); ImGui::TableNextRow();
ImGui::TableSetColumnIndex(0); ImGui::TableSetColumnIndex(0);
@ -413,7 +413,7 @@ SaveTool::drawMaterialRow(Containers::StringView name, Int tier, Getter getter,
if(conf().cheatMode()) { if(conf().cheatMode()) {
ImGui::TableSetColumnIndex(3); ImGui::TableSetColumnIndex(3);
ImGui::PushID(name.data()); ImGui::PushID(name.data());
static Int var = 0; static std::int32_t var = 0;
if(drawUnsafeWidget(ImGui::SmallButton, ICON_FA_EDIT)) { if(drawUnsafeWidget(ImGui::SmallButton, ICON_FA_EDIT)) {
(var) = getter(); (var) = getter();
ImGui::OpenPopup("int_edit"); ImGui::OpenPopup("int_edit");
@ -433,7 +433,7 @@ SaveTool::drawMaterialRow(Containers::StringView name, Int tier, Getter getter,
} }
void void
SaveTool::drawUnavailableMaterialRow(Containers::StringView name, Int tier) { SaveTool::drawUnavailableMaterialRow(Containers::StringView name, std::int32_t tier) {
ImGui::TableNextRow(); ImGui::TableNextRow();
ImGui::TableSetColumnIndex(0); ImGui::TableSetColumnIndex(0);
ImGui::Text("T%i", tier); ImGui::Text("T%i", tier);

View file

@ -38,7 +38,7 @@ SaveTool::drawMassViewer() {
} }
ImGui::SetNextWindowPos({0.0f, ImGui::GetItemRectSize().y}, ImGuiCond_Always); 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); ImGuiCond_Always);
if(!ImGui::Begin("##MassViewer", nullptr, if(!ImGui::Begin("##MassViewer", nullptr,
ImGuiWindowFlags_NoDecoration|ImGuiWindowFlags_NoMove| ImGuiWindowFlags_NoDecoration|ImGuiWindowFlags_NoMove|
@ -86,8 +86,8 @@ SaveTool::drawMassViewer() {
_jointsDirty = false; _jointsDirty = false;
_stylesDirty = false; _stylesDirty = false;
_eyeFlareDirty = false; _eyeFlareDirty = false;
_selectedArmourDecals = Containers::StaticArray<38, Int>{ValueInit}; _selectedArmourDecals = Containers::StaticArray<38, std::int32_t>{ValueInit};
_selectedArmourAccessories = Containers::StaticArray<38, Int>{ValueInit}; _selectedArmourAccessories = Containers::StaticArray<38, std::int32_t>{ValueInit};
_selectedBLPlacement = 0; _selectedBLPlacement = 0;
_selectedWeaponPart = 0; _selectedWeaponPart = 0;
_selectedWeaponDecal = 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."); 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)); ImGui::PushID(int(i));
DCSResult result; DCSResult result;
result = drawCustomStyle(_currentMass->globalStyles()[i]); result = drawCustomStyle(_currentMass->globalStyles()[i]);
@ -225,7 +225,7 @@ SaveTool::drawTuning() {
ImGui::TableNextColumn(); ImGui::TableNextColumn();
ImGui::TextUnformatted("Gears"); 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::TableNextRow();
ImGui::TableNextColumn(); ImGui::TableNextColumn();
ImGui::Text("%i", _currentMass->gears()[i]); ImGui::Text("%i", _currentMass->gears()[i]);
@ -251,7 +251,7 @@ SaveTool::drawTuning() {
ImGui::TableNextColumn(); ImGui::TableNextColumn();
ImGui::TextUnformatted("Modules"); 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::TableNextRow();
ImGui::TableNextColumn(); ImGui::TableNextColumn();
ImGui::Text("%i", _currentMass->modules()[i]); ImGui::Text("%i", _currentMass->modules()[i]);
@ -277,7 +277,7 @@ SaveTool::drawTuning() {
ImGui::TableNextColumn(); ImGui::TableNextColumn();
ImGui::TextUnformatted("Techs"); 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::TableNextRow();
ImGui::TableNextColumn(); ImGui::TableNextColumn();
ImGui::Text("%i", _currentMass->techs()[i]); ImGui::Text("%i", _currentMass->techs()[i]);
@ -515,7 +515,7 @@ SaveTool::drawAccessoryEditor(Accessory& accessory, Containers::ArrayView<Custom
ImGui::SameLine(); ImGui::SameLine();
static Int tab = 0; static std::int32_t tab = 0;
static Containers::Optional<AccessorySize> size = Containers::NullOpt; static Containers::Optional<AccessorySize> size = Containers::NullOpt;
if(ImGui::SmallButton("Change")) { if(ImGui::SmallButton("Change")) {
ImGui::OpenPopup("##AccessoryPopup"); ImGui::OpenPopup("##AccessoryPopup");
@ -539,7 +539,7 @@ SaveTool::drawAccessoryEditor(Accessory& accessory, Containers::ArrayView<Custom
"L", "L",
"XL" "XL"
}; };
static const Float selectable_width = 90.0f; static const float selectable_width = 90.0f;
ImGui::PushStyleVar(ImGuiStyleVar_SelectableTextAlign, {0.5f, 0.0f}); ImGui::PushStyleVar(ImGuiStyleVar_SelectableTextAlign, {0.5f, 0.0f});
if(ImGui::Selectable("Primitives", tab == 0, ImGuiSelectableFlags_DontClosePopups, {selectable_width, 0.0f})) { if(ImGui::Selectable("Primitives", tab == 0, ImGuiSelectableFlags_DontClosePopups, {selectable_width, 0.0f})) {
@ -740,7 +740,7 @@ SaveTool::drawAccessoryEditor(Accessory& accessory, Containers::ArrayView<Custom
} }
Containers::StringView Containers::StringView
SaveTool::getStyleName(Int id, Containers::ArrayView<CustomStyle> view) { SaveTool::getStyleName(std::int32_t id, Containers::ArrayView<CustomStyle> view) {
if(id >= 0 && id <= 15) { if(id >= 0 && id <= 15) {
return view[id].name; return view[id].name;
} }

View file

@ -43,7 +43,7 @@ SaveTool::drawArmour() {
#undef c #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)); ImGui::PushID(int(i));
auto& part = _currentMass->armourParts()[i]; auto& part = _currentMass->armourParts()[i];
@ -53,10 +53,10 @@ SaveTool::drawArmour() {
std::memset(header, '\0', 129); std::memset(header, '\0', 129);
if(armour_sets.find(part.id) != armour_sets.cend()) { 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 { 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)) { if(ImGui::CollapsingHeader(header)) {
@ -64,7 +64,7 @@ SaveTool::drawArmour() {
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x * 0.491f); ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x * 0.491f);
if(ImGui::BeginListBox("##ChangePart")) { 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) { for(auto& set : armour_sets) {
if(ImGui::Selectable(set.second.name.data(), set.first == part.id, ImGuiSelectableFlags_SpanAvailWidth)) { if(ImGui::Selectable(set.second.name.data(), set.first == part.id, ImGuiSelectableFlags_SpanAvailWidth)) {
part.id = set.first; part.id = set.first;
@ -97,7 +97,7 @@ SaveTool::drawArmour() {
ImGui::TextUnformatted("Styles:"); ImGui::TextUnformatted("Styles:");
for(Int j = 0; j < 4; j++) { for(std::int32_t j = 0; j < 4; j++) {
drawAlignedText("Slot %d:", j + 1); drawAlignedText("Slot %d:", j + 1);
ImGui::SameLine(); ImGui::SameLine();
@ -125,7 +125,7 @@ SaveTool::drawArmour() {
ImGui::PushID("Decal"); ImGui::PushID("Decal");
drawAlignedText("Showing/editing 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::SameLine();
ImGui::RadioButton(std::to_string(j + 1).c_str(), &_selectedArmourDecals[i], int(j)); ImGui::RadioButton(std::to_string(j + 1).c_str(), &_selectedArmourDecals[i], int(j));
} }
@ -140,7 +140,7 @@ SaveTool::drawArmour() {
ImGui::PushID("Accessory"); ImGui::PushID("Accessory");
drawAlignedText("Showing/editing 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::SameLine();
ImGui::RadioButton(std::string{char(65 + j)}.c_str(), &_selectedArmourAccessories[i], int(j)); ImGui::RadioButton(std::string{char(65 + j)}.c_str(), &_selectedArmourAccessories[i], int(j));
} }
@ -200,9 +200,9 @@ SaveTool::drawArmour() {
drawAlignedText("Socket:"); drawAlignedText("Socket:");
ImGui::SameLine(); ImGui::SameLine();
if(ImGui::BeginCombo("##Socket", socket_labels[UnsignedInt(placement.socket)].data())) { if(ImGui::BeginCombo("##Socket", socket_labels[std::uint32_t(placement.socket)].data())) {
for(UnsignedInt i = 0; i < (sizeof(socket_labels) / sizeof(socket_labels[0])); i++) { for(std::uint32_t 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::Selectable(socket_labels[i].data(), i == std::uint32_t(placement.socket), ImGuiSelectableFlags_SpanAvailWidth)) {
placement.socket = static_cast<BulletLauncherSocket>(i); placement.socket = static_cast<BulletLauncherSocket>(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."); 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)); ImGui::PushID(int(i));
DCSResult result; DCSResult result;
result = drawCustomStyle(_currentMass->armourCustomStyles()[i]); result = drawCustomStyle(_currentMass->armourCustomStyles()[i]);

View file

@ -202,7 +202,7 @@ SaveTool::drawFrameStyles() {
return; return;
} }
for(Int i = 0; i < 4; i++) { for(std::int32_t i = 0; i < 4; i++) {
drawAlignedText("Slot %d:", i + 1); drawAlignedText("Slot %d:", i + 1);
ImGui::SameLine(); 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."); 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)); ImGui::PushID(int(i));
DCSResult result; DCSResult result;
result = drawCustomStyle(_currentMass->frameCustomStyles()[i]); result = drawCustomStyle(_currentMass->frameCustomStyles()[i]);

View file

@ -28,7 +28,7 @@ SaveTool::drawWeapons() {
return; 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(); ImGui::BeginGroup();
@ -265,7 +265,7 @@ SaveTool::drawWeaponCategory(Containers::StringView name, Containers::ArrayView<
ImGui::PushID(payload_type.data()); 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]; auto& weapon = weapons_view[i];
ImGui::TableNextRow(); ImGui::TableNextRow();
@ -277,7 +277,7 @@ SaveTool::drawWeaponCategory(Containers::StringView name, Containers::ArrayView<
_currentWeapon = &weapon; _currentWeapon = &weapon;
} }
if(ImGui::BeginDragDropSource()) { 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) { if(ImGui::GetIO().KeyCtrl) {
ImGui::Text("%s %i - %s (copy)", payload_tooltip.data(), i + 1, weapon.name.data()); ImGui::Text("%s %i - %s (copy)", payload_tooltip.data(), i + 1, weapon.name.data());
} }
@ -331,7 +331,7 @@ SaveTool::drawWeaponEditor(Weapon& weapon) {
#undef c #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(); ImGui::SameLine();
@ -428,8 +428,8 @@ SaveTool::drawWeaponEditor(Weapon& weapon) {
if(ImGui::CollapsingHeader("Weapon parts")) { if(ImGui::CollapsingHeader("Weapon parts")) {
drawAlignedText("Viewing/editing part:"); drawAlignedText("Viewing/editing part:");
for(Int i = 0; UnsignedLong(i) < weapon.parts.size(); i++) { for(std::int32_t i = 0; std::size_t(i) < weapon.parts.size(); i++) {
if(UnsignedLong(_selectedWeaponPart) >= weapon.parts.size()) { if(std::size_t(_selectedWeaponPart) >= weapon.parts.size()) {
_selectedWeaponPart = 0; _selectedWeaponPart = 0;
} }
ImGui::SameLine(); ImGui::SameLine();
@ -438,7 +438,7 @@ SaveTool::drawWeaponEditor(Weapon& weapon) {
auto& part = weapon.parts[_selectedWeaponPart]; auto& part = weapon.parts[_selectedWeaponPart];
const auto* map = [this, &weapon]()-> const std::map<Int, Containers::StringView>* { const auto* map = [this, &weapon]()-> const std::map<std::int32_t, Containers::StringView>* {
switch(weapon.type) { switch(weapon.type) {
case WeaponType::Melee: case WeaponType::Melee:
return _selectedWeaponPart == 0 ? &melee_grips : &melee_assaulters; return _selectedWeaponPart == 0 ? &melee_grips : &melee_assaulters;
@ -511,7 +511,7 @@ SaveTool::drawWeaponEditor(Weapon& weapon) {
if(ImGui::BeginChild("##PartDetails", {0.0f, 0.0f}, true)) { if(ImGui::BeginChild("##PartDetails", {0.0f, 0.0f}, true)) {
ImGui::TextUnformatted("Styles:"); ImGui::TextUnformatted("Styles:");
for(Int i = 0; i < 4; i++) { for(std::int32_t i = 0; i < 4; i++) {
drawAlignedText("Slot %d:", i + 1); drawAlignedText("Slot %d:", i + 1);
ImGui::SameLine(); ImGui::SameLine();
@ -537,7 +537,7 @@ SaveTool::drawWeaponEditor(Weapon& weapon) {
ImGui::PushID("Decal"); ImGui::PushID("Decal");
drawAlignedText("Showing/editing 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::SameLine();
ImGui::RadioButton(std::to_string(i + 1).c_str(), &_selectedWeaponDecal, int(i)); ImGui::RadioButton(std::to_string(i + 1).c_str(), &_selectedWeaponDecal, int(i));
} }
@ -552,7 +552,7 @@ SaveTool::drawWeaponEditor(Weapon& weapon) {
ImGui::PushID("Accessory"); ImGui::PushID("Accessory");
drawAlignedText("Showing/editing 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::SameLine();
ImGui::RadioButton(std::string{char(65 + i)}.c_str(), &_selectedWeaponAccessory, int(i)); ImGui::RadioButton(std::string{char(65 + i)}.c_str(), &_selectedWeaponAccessory, int(i));
} }

View file

@ -73,10 +73,10 @@ SaveTool::updateCheckEvent(SDL_Event& event) {
prerelease = true; prerelease = true;
} }
} }
Int fullVersion; std::int32_t fullVersion;
Int major = 0; std::int32_t major = 0;
Int minor = 0; std::int32_t minor = 0;
Int patch = 0; std::int32_t patch = 0;
bool prerelease = false; bool prerelease = false;
bool operator==(const Version& other) const { bool operator==(const Version& other) const {
@ -161,7 +161,7 @@ SaveTool::checkForUpdates() {
if(code == CURLE_OK) { if(code == CURLE_OK) {
long status = 0; long status = 0;
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &status); 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(); event.user.data1 = response_body.release();
} }
else if(code == CURLE_OPERATION_TIMEDOUT) { else if(code == CURLE_OPERATION_TIMEDOUT) {

View file

@ -113,7 +113,7 @@ SaveTool::drawMainMenu() {
ImGui::SameLine(); ImGui::SameLine();
ImGui::AlignTextToFramePadding(); ImGui::AlignTextToFramePadding();
drawHelpMarker("This gives access to save edition features that can be considered cheats.", 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())) { if(drawCheckbox("Advanced mode", conf().advancedMode())) {
conf().setAdvancedMode(!conf().advancedMode()); conf().setAdvancedMode(!conf().advancedMode());
@ -121,7 +121,7 @@ SaveTool::drawMainMenu() {
ImGui::SameLine(); ImGui::SameLine();
ImGui::AlignTextToFramePadding(); ImGui::AlignTextToFramePadding();
drawHelpMarker("This gives access to editing values that have unknown purposes or are undocumented.", 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())) { if(drawCheckbox("Check for updates on startup", conf().checkUpdatesOnStartup())) {
conf().setCheckUpdatesOnStartup(!conf().checkUpdatesOnStartup()); conf().setCheckUpdatesOnStartup(!conf().checkUpdatesOnStartup());

View file

@ -26,15 +26,15 @@
using namespace Containers::Literals; using namespace Containers::Literals;
constexpr UnsignedInt success_colour = 0xff67d23bu; constexpr std::uint32_t success_colour = 0xff67d23bu;
constexpr UnsignedInt info_colour = 0xffcc832fu; constexpr std::uint32_t info_colour = 0xffcc832fu;
constexpr UnsignedInt warning_colour = 0xff2fcfc7u; constexpr std::uint32_t warning_colour = 0xff2fcfc7u;
constexpr UnsignedInt error_colour = 0xff3134cdu; constexpr std::uint32_t error_colour = 0xff3134cdu;
constexpr UnsignedInt fade_time = 150; constexpr std::uint32_t fade_time = 150;
constexpr Float base_opacity = 1.0f; constexpr float base_opacity = 1.0f;
constexpr Vector2 padding{20.0f, 20.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): Toast::Toast(Type type, Containers::StringView message, std::chrono::milliseconds timeout):
_type{type}, _type{type},
@ -42,7 +42,7 @@ Toast::Toast(Type type, Containers::StringView message, std::chrono::millisecond
_timeout{timeout}, _timeout{timeout},
_creationTime{std::chrono::steady_clock::now()} _creationTime{std::chrono::steady_clock::now()}
{ {
_phaseTrack = Animation::Track<UnsignedInt, Phase>{{ _phaseTrack = Animation::Track<std::uint32_t, Phase>{{
{0, Phase::FadeIn}, {0, Phase::FadeIn},
{fade_time, Phase::Wait}, {fade_time, Phase::Wait},
{fade_time + timeout.count(), Phase::FadeOut}, {fade_time + timeout.count(), Phase::FadeOut},
@ -80,16 +80,16 @@ Toast::phase() {
return _phaseTrack.at(elapsedTime().count()); return _phaseTrack.at(elapsedTime().count());
} }
Float float
Toast::opacity() { Toast::opacity() {
Phase phase = this->phase(); Phase phase = this->phase();
Long elapsed_time = elapsedTime().count(); std::int64_t elapsed_time = elapsedTime().count();
if(phase == Phase::FadeIn) { if(phase == Phase::FadeIn) {
return Float(elapsed_time) / Float(fade_time); return float(elapsed_time) / float(fade_time);
} }
else if(phase == Phase::FadeOut) { 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; return 1.0f;
@ -107,9 +107,9 @@ ToastQueue::addToast(Toast::Type type, Containers::StringView message, std::chro
void void
ToastQueue::draw(Vector2i viewport_size) { 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]; Toast* current = &_toasts[i];
if(current->phase() == Toast::Phase::TimedOut) { if(current->phase() == Toast::Phase::TimedOut) {
@ -119,11 +119,12 @@ ToastQueue::draw(Vector2i viewport_size) {
Containers::String win_id = Utility::format("##Toast{}", i); 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::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, if(ImGui::Begin(win_id.data(), nullptr,
ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoDecoration| ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoDecoration|
ImGuiWindowFlags_NoInputs|ImGuiWindowFlags_NoNav|ImGuiWindowFlags_NoFocusOnAppearing)) ImGuiWindowFlags_NoInputs|ImGuiWindowFlags_NoNav|ImGuiWindowFlags_NoFocusOnAppearing))
@ -168,6 +169,6 @@ ToastQueue::draw(Vector2i viewport_size) {
} }
void void
ToastQueue::removeToast(Long index) { ToastQueue::removeToast(std::int64_t index) {
_toasts.erase(_toasts.begin() + index); _toasts.erase(_toasts.begin() + index);
} }

View file

@ -29,11 +29,11 @@ using namespace Magnum;
class Toast { class Toast {
public: public:
enum class Type : UnsignedByte { enum class Type: std::uint8_t {
Default, Success, Info, Warning, Error Default, Success, Info, Warning, Error
}; };
enum class Phase : UnsignedByte { enum class Phase: std::uint8_t {
FadeIn, Wait, FadeOut, TimedOut FadeIn, Wait, FadeOut, TimedOut
}; };
@ -58,14 +58,14 @@ class Toast {
Phase phase(); Phase phase();
Float opacity(); float opacity();
private: private:
Type _type{Type::Default}; Type _type{Type::Default};
Containers::String _message; Containers::String _message;
std::chrono::milliseconds _timeout; std::chrono::milliseconds _timeout;
std::chrono::steady_clock::time_point _creationTime; std::chrono::steady_clock::time_point _creationTime;
Animation::Track<UnsignedInt, Phase> _phaseTrack; Animation::Track<std::uint32_t, Phase> _phaseTrack;
}; };
class ToastQueue { class ToastQueue {
@ -78,7 +78,7 @@ class ToastQueue {
void draw(Vector2i viewport_size); void draw(Vector2i viewport_size);
private: private:
void removeToast(Long index); void removeToast(std::int64_t index);
std::vector<Toast> _toasts; std::vector<Toast> _toasts;
}; };

View file

@ -45,13 +45,13 @@ BinaryReader::eof() {
return std::feof(_file) != 0; return std::feof(_file) != 0;
} }
Long std::int64_t
BinaryReader::position() { BinaryReader::position() {
return _ftelli64(_file); return _ftelli64(_file);
} }
bool bool
BinaryReader::seek(Long position) { BinaryReader::seek(std::int64_t position) {
return _fseeki64(_file, position, SEEK_SET) == 0; return _fseeki64(_file, position, SEEK_SET) == 0;
} }
@ -67,53 +67,53 @@ BinaryReader::readChar(char& value) {
} }
bool bool
BinaryReader::readByte(Byte& value) { BinaryReader::readInt8(std::int8_t& value) {
return std::fread(&value, sizeof(Byte), 1, _file) == 1; return std::fread(&value, sizeof(std::int8_t), 1, _file) == 1;
} }
bool bool
BinaryReader::readUnsignedByte(UnsignedByte& value) { BinaryReader::readUint8(std::uint8_t& value) {
return std::fread(&value, sizeof(UnsignedByte), 1, _file) == 1; return std::fread(&value, sizeof(std::uint8_t), 1, _file) == 1;
} }
bool bool
BinaryReader::readShort(Short& value) { BinaryReader::readInt16(std::int16_t& value) {
return std::fread(&value, sizeof(Short), 1, _file) == 1; return std::fread(&value, sizeof(std::int16_t), 1, _file) == 1;
} }
bool bool
BinaryReader::readUnsignedShort(UnsignedShort& value) { BinaryReader::readUint16(std::uint16_t& value) {
return std::fread(&value, sizeof(UnsignedShort), 1, _file) == 1; return std::fread(&value, sizeof(std::uint16_t), 1, _file) == 1;
} }
bool bool
BinaryReader::readInt(Int& value) { BinaryReader::readInt32(std::int32_t& value) {
return std::fread(&value, sizeof(Int), 1, _file) == 1; return std::fread(&value, sizeof(std::int32_t), 1, _file) == 1;
} }
bool bool
BinaryReader::readUnsignedInt(UnsignedInt& value) { BinaryReader::readUint32(std::uint32_t& value) {
return std::fread(&value, sizeof(UnsignedInt), 1, _file) == 1; return std::fread(&value, sizeof(std::uint32_t), 1, _file) == 1;
} }
bool bool
BinaryReader::readLong(Long& value) { BinaryReader::readInt64(std::int64_t& value) {
return std::fread(&value, sizeof(Long), 1, _file) == 1; return std::fread(&value, sizeof(std::int64_t), 1, _file) == 1;
} }
bool bool
BinaryReader::readUnsignedLong(UnsignedLong& value) { BinaryReader::readUint64(std::uint64_t& value) {
return std::fread(&value, sizeof(UnsignedLong), 1, _file) == 1; return std::fread(&value, sizeof(std::uint64_t), 1, _file) == 1;
} }
bool bool
BinaryReader::readFloat(Float& value) { BinaryReader::readFloat(float& value) {
return std::fread(&value, sizeof(Float), 1, _file) == 1; return std::fread(&value, sizeof(float), 1, _file) == 1;
} }
bool bool
BinaryReader::readDouble(Double& value) { BinaryReader::readDouble(double& value) {
return std::fread(&value, sizeof(Double), 1, _file) == 1; return std::fread(&value, sizeof(double), 1, _file) == 1;
} }
bool bool
@ -127,8 +127,8 @@ BinaryReader::readArray(Containers::Array<char>& array, std::size_t count) {
bool bool
BinaryReader::readUEString(Containers::String& str) { BinaryReader::readUEString(Containers::String& str) {
UnsignedInt length = 0; std::uint32_t length = 0;
if(!readUnsignedInt(length) || length == 0) { if(!readUint32(length) || length == 0) {
return false; return false;
} }
@ -137,9 +137,9 @@ BinaryReader::readUEString(Containers::String& str) {
return std::fread(str.data(), sizeof(char), length, _file) == length; return std::fread(str.data(), sizeof(char), length, _file) == length;
} }
Int std::int32_t
BinaryReader::peekChar() { BinaryReader::peekChar() {
Int c; std::int32_t c;
c = std::fgetc(_file); c = std::fgetc(_file);
std::ungetc(c, _file); std::ungetc(c, _file);
return c; return c;

View file

@ -16,16 +16,14 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <cstdint>
#include <cstdio> #include <cstdio>
#include <Corrade/Containers/Containers.h> #include <Corrade/Containers/Containers.h>
#include <Corrade/Containers/StaticArray.h> #include <Corrade/Containers/StaticArray.h>
#include <Corrade/Containers/StringView.h> #include <Corrade/Containers/StringView.h>
#include <Magnum/Types.h>
using namespace Corrade; using namespace Corrade;
using namespace Magnum;
class BinaryReader { class BinaryReader {
public: public:
@ -34,23 +32,23 @@ class BinaryReader {
bool open(); bool open();
bool eof(); bool eof();
Long position(); std::int64_t position();
bool seek(Long position); bool seek(std::int64_t position);
void closeFile(); void closeFile();
bool readChar(char& value); bool readChar(char& value);
bool readByte(Byte& value); bool readInt8(std::int8_t& value);
bool readUnsignedByte(UnsignedByte& value); bool readUint8(std::uint8_t& value);
bool readShort(Short& value); bool readInt16(std::int16_t& value);
bool readUnsignedShort(UnsignedShort& value); bool readUint16(std::uint16_t& value);
bool readInt(Int& value); bool readInt32(std::int32_t& value);
bool readUnsignedInt(UnsignedInt& value); bool readUint32(std::uint32_t& value);
bool readLong(Long& value); bool readInt64(std::int64_t& value);
bool readUnsignedLong(UnsignedLong& value); bool readUint64(std::uint64_t& value);
bool readFloat(Float& value); bool readFloat(float& value);
bool readDouble(Double& value); bool readDouble(double& value);
bool readArray(Containers::Array<char>& array, std::size_t count); bool readArray(Containers::Array<char>& array, std::size_t count);
template<typename T> template<typename T>
@ -65,7 +63,7 @@ class BinaryReader {
bool readUEString(Containers::String& str); bool readUEString(Containers::String& str);
Int peekChar(); std::int32_t peekChar();
private: private:
std::FILE* _file = nullptr; std::FILE* _file = nullptr;

View file

@ -45,7 +45,7 @@ BinaryWriter::closeFile() {
_file = nullptr; _file = nullptr;
} }
Long std::int64_t
BinaryWriter::position() { BinaryWriter::position() {
return _ftelli64(_file); return _ftelli64(_file);
} }
@ -55,7 +55,7 @@ BinaryWriter::array() const {
return _data; return _data;
} }
UnsignedLong std::size_t
BinaryWriter::arrayPosition() const { BinaryWriter::arrayPosition() const {
return _index; return _index;
} }
@ -75,53 +75,53 @@ BinaryWriter::writeChar(char value) {
} }
bool bool
BinaryWriter::writeByte(Byte value) { BinaryWriter::writeInt8(std::int8_t value) {
return std::fwrite(&value, sizeof(Byte), 1, _file) == 1; return std::fwrite(&value, sizeof(std::int8_t), 1, _file) == 1;
} }
bool bool
BinaryWriter::writeUnsignedByte(UnsignedByte value) { BinaryWriter::writeUint8(std::uint8_t value) {
return std::fwrite(&value, sizeof(UnsignedByte), 1, _file) == 1; return std::fwrite(&value, sizeof(std::uint8_t), 1, _file) == 1;
} }
bool bool
BinaryWriter::writeShort(Short value) { BinaryWriter::writeInt16(std::int16_t value) {
return std::fwrite(&value, sizeof(Short), 1, _file) == 1; return std::fwrite(&value, sizeof(std::int16_t), 1, _file) == 1;
} }
bool bool
BinaryWriter::writeUnsignedShort(UnsignedShort value) { BinaryWriter::writeUint16(std::uint16_t value) {
return std::fwrite(&value, sizeof(UnsignedShort), 1, _file) == 1; return std::fwrite(&value, sizeof(std::uint16_t), 1, _file) == 1;
} }
bool bool
BinaryWriter::writeInt(Int value) { BinaryWriter::writeInt32(std::int32_t value) {
return std::fwrite(&value, sizeof(Int), 1, _file) == 1; return std::fwrite(&value, sizeof(std::int32_t), 1, _file) == 1;
} }
bool bool
BinaryWriter::writeUnsignedInt(UnsignedInt value) { BinaryWriter::writeUint32(std::uint32_t value) {
return std::fwrite(&value, sizeof(UnsignedInt), 1, _file) == 1; return std::fwrite(&value, sizeof(std::uint32_t), 1, _file) == 1;
} }
bool bool
BinaryWriter::writeLong(Long value) { BinaryWriter::writeInt64(std::int64_t value) {
return std::fwrite(&value, sizeof(Long), 1, _file) == 1; return std::fwrite(&value, sizeof(std::int64_t), 1, _file) == 1;
} }
bool bool
BinaryWriter::writeUnsignedLong(UnsignedLong value) { BinaryWriter::writeUint64(std::uint64_t value) {
return std::fwrite(&value, sizeof(UnsignedLong), 1, _file) == 1; return std::fwrite(&value, sizeof(std::uint64_t), 1, _file) == 1;
} }
bool bool
BinaryWriter::writeFloat(Float value) { BinaryWriter::writeFloat(float value) {
return std::fwrite(&value, sizeof(Float), 1, _file) == 1; return std::fwrite(&value, sizeof(float), 1, _file) == 1;
} }
bool bool
BinaryWriter::writeDouble(Double value) { BinaryWriter::writeDouble(double value) {
return std::fwrite(&value, sizeof(Double), 1, _file) == 1; return std::fwrite(&value, sizeof(double), 1, _file) == 1;
} }
bool bool
@ -140,7 +140,7 @@ BinaryWriter::writeUEString(Containers::StringView str) {
return false; return false;
} }
writeUnsignedInt(static_cast<UnsignedInt>(str.size()) + 1); writeUint32(static_cast<std::uint32_t>(str.size()) + 1);
if(str.size() > 0) { if(str.size() > 0) {
std::size_t count = std::fwrite(str.data(), sizeof(char), str.size(), _file); 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'); return writeChar('\0');
} }
UnsignedLong std::size_t
BinaryWriter::writeUEStringToArray(Containers::StringView value) { BinaryWriter::writeUEStringToArray(Containers::StringView value) {
return writeValueToArray<UnsignedInt>(UnsignedInt(value.size()) + 1u) + return writeValueToArray<std::uint32_t>(std::uint32_t(value.size()) + 1u) +
writeDataToArray(Containers::ArrayView<const char>{value}) + writeDataToArray(Containers::ArrayView<const char>{value}) +
writeValueToArray<char>('\0'); writeValueToArray<char>('\0');
} }

View file

@ -16,6 +16,7 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <cstdint>
#include <cstdio> #include <cstdio>
#include <Corrade/Containers/ArrayView.h> #include <Corrade/Containers/ArrayView.h>
@ -23,10 +24,7 @@
#include <Corrade/Containers/StaticArray.h> #include <Corrade/Containers/StaticArray.h>
#include <Corrade/Containers/StringView.h> #include <Corrade/Containers/StringView.h>
#include <Magnum/Types.h>
using namespace Corrade; using namespace Corrade;
using namespace Magnum;
class BinaryWriter { class BinaryWriter {
public: public:
@ -43,23 +41,23 @@ class BinaryWriter {
void closeFile(); void closeFile();
Long position(); std::int64_t position();
Containers::ArrayView<const char> array() const; Containers::ArrayView<const char> array() const;
UnsignedLong arrayPosition() const; std::size_t arrayPosition() const;
bool flushToFile(); bool flushToFile();
bool writeByte(Byte value);
bool writeChar(char value); bool writeChar(char value);
bool writeUnsignedByte(UnsignedByte value); bool writeInt8(std::int8_t value);
bool writeShort(Short value); bool writeUint8(std::uint8_t value);
bool writeUnsignedShort(UnsignedShort value); bool writeInt16(std::int16_t value);
bool writeInt(Int value); bool writeUint16(std::uint16_t value);
bool writeUnsignedInt(UnsignedInt value); bool writeInt32(std::int32_t value);
bool writeLong(Long value); bool writeUint32(std::uint32_t value);
bool writeUnsignedLong(UnsignedLong value); bool writeInt64(std::int64_t value);
bool writeFloat(Float value); bool writeUint64(std::uint64_t value);
bool writeDouble(Double value); bool writeFloat(float value);
bool writeDouble(double value);
bool writeArray(Containers::ArrayView<const char> array); bool writeArray(Containers::ArrayView<const char> array);
template<std::size_t size> template<std::size_t size>
bool writeString(const char(&str)[size]) { bool writeString(const char(&str)[size]) {
@ -74,30 +72,30 @@ class BinaryWriter {
bool writeUEString(Containers::StringView str); bool writeUEString(Containers::StringView str);
template<typename T, typename U = std::conditional_t<std::is_trivially_copyable<T>::value, T, T&>> template<typename T, typename U = std::conditional_t<std::is_trivially_copyable<T>::value, T, T&>>
UnsignedLong writeValueToArray(U value) { std::size_t writeValueToArray(U value) {
Containers::ArrayView<T> view{&value, 1}; Containers::ArrayView<T> view{&value, 1};
return writeDataToArray(view); return writeDataToArray(view);
} }
UnsignedLong writeUEStringToArray(Containers::StringView value); std::size_t writeUEStringToArray(Containers::StringView value);
template<typename T> template<typename T>
void writeValueToArrayAt(T& value, UnsignedLong position) { void writeValueToArrayAt(T& value, std::size_t position) {
Containers::ArrayView<T> view{&value, 1}; Containers::ArrayView<T> view{&value, 1};
writeDataToArrayAt(view, position); writeDataToArrayAt(view, position);
} }
template<typename T> template<typename T>
UnsignedLong writeDataToArray(Containers::ArrayView<T> view) { std::size_t writeDataToArray(Containers::ArrayView<T> view) {
arrayAppend(_data, Containers::arrayCast<const char>(view)); arrayAppend(_data, Containers::arrayCast<const char>(view));
_index += sizeof(T) * view.size(); _index += sizeof(T) * view.size();
return sizeof(T) * view.size(); return sizeof(T) * view.size();
} }
template<typename T> template<typename T>
void writeDataToArrayAt(Containers::ArrayView<T> view, UnsignedLong position) { void writeDataToArrayAt(Containers::ArrayView<T> view, std::size_t position) {
auto casted_view = Containers::arrayCast<const char>(view); auto casted_view = Containers::arrayCast<const char>(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]; _data[position + i] = casted_view[i];
} }
} }
@ -106,5 +104,5 @@ class BinaryWriter {
FILE* _file = nullptr; FILE* _file = nullptr;
Containers::Array<char> _data; Containers::Array<char> _data;
UnsignedLong _index = 0; std::size_t _index = 0;
}; };

View file

@ -93,8 +93,8 @@ PropertySerialiser::read(BinaryReader& reader) {
return nullptr; return nullptr;
} }
UnsignedLong value_length; std::size_t value_length;
if(!reader.readUnsignedLong(value_length)) { if(!reader.readUint64(value_length)) {
return nullptr; return nullptr;
} }
@ -102,7 +102,7 @@ PropertySerialiser::read(BinaryReader& reader) {
} }
UnrealPropertyBase::ptr 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) Containers::String name)
{ {
if(reader.peekChar() < 0 || reader.eof()) { if(reader.peekChar() < 0 || reader.eof()) {
@ -113,7 +113,7 @@ PropertySerialiser::readItem(BinaryReader& reader, Containers::String type, Unsi
} }
Containers::Array<UnrealPropertyBase::ptr> Containers::Array<UnrealPropertyBase::ptr>
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()) { if(reader.peekChar() < 0 || reader.eof()) {
return nullptr; return nullptr;
} }
@ -133,8 +133,8 @@ PropertySerialiser::readSet(BinaryReader& reader, Containers::StringView item_ty
return nullptr; return nullptr;
} }
UnsignedLong value_length; std::size_t value_length;
if(!reader.readUnsignedLong(value_length)) { if(!reader.readUint64(value_length)) {
return nullptr; return nullptr;
} }
@ -147,8 +147,8 @@ PropertySerialiser::readSet(BinaryReader& reader, Containers::StringView item_ty
} }
} }
else { else {
for(UnsignedInt i = 0; i < count; i++) { for(std::uint32_t i = 0; i < count; i++) {
auto item = readItem(reader, item_type, UnsignedLong(-1), ""); auto item = readItem(reader, item_type, std::size_t(-1), "");
arrayAppend(array, std::move(item)); arrayAppend(array, std::move(item));
} }
} }
@ -157,7 +157,7 @@ PropertySerialiser::readSet(BinaryReader& reader, Containers::StringView item_ty
} }
UnrealPropertyBase::ptr 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) BinaryReader& reader)
{ {
UnrealPropertyBase::ptr prop; 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, 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); auto serialiser = getSerialiser(item_type);
if(!serialiser) { if(!serialiser) {
@ -191,7 +191,7 @@ bool PropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, Containers::St
} }
bool 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<NoneProperty*>(prop.get())) { if(prop->name == "None" && prop->propertyType == "NoneProperty" && dynamic_cast<NoneProperty*>(prop.get())) {
bytes_written += writer.writeUEStringToArray(*prop->name); bytes_written += writer.writeUEStringToArray(*prop->name);
return true; 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->name);
bytes_written += writer.writeUEStringToArray(prop->propertyType); bytes_written += writer.writeUEStringToArray(prop->propertyType);
UnsignedLong value_length = 0; std::size_t value_length = 0;
UnsignedLong vl_position = writer.arrayPosition(); std::size_t vl_position = writer.arrayPosition();
bytes_written += writer.writeValueToArray<UnsignedLong>(value_length); bytes_written += writer.writeValueToArray<std::size_t>(value_length);
bool ret = serialise(prop, prop->propertyType, value_length, writer); bool ret = serialise(prop, prop->propertyType, value_length, writer);
@ -216,7 +216,7 @@ PropertySerialiser::write(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_wri
bool bool
PropertySerialiser::writeItem(UnrealPropertyBase::ptr& prop, Containers::StringView item_type, 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<NoneProperty*>(prop.get())) { if(prop->name == "None" && prop->propertyType == "NoneProperty" && dynamic_cast<NoneProperty*>(prop.get())) {
bytes_written += writer.writeUEStringToArray(*prop->name); bytes_written += writer.writeUEStringToArray(*prop->name);
@ -227,7 +227,7 @@ PropertySerialiser::writeItem(UnrealPropertyBase::ptr& prop, Containers::StringV
} }
bool PropertySerialiser::writeSet(Containers::ArrayView<UnrealPropertyBase::ptr> props, bool PropertySerialiser::writeSet(Containers::ArrayView<UnrealPropertyBase::ptr> 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); auto serialiser = getCollectionSerialiser(item_type);
if(serialiser) { if(serialiser) {

View file

@ -35,20 +35,20 @@ class PropertySerialiser {
static PropertySerialiser& instance(); static PropertySerialiser& instance();
UnrealPropertyBase::ptr read(BinaryReader& reader); 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::String name);
Containers::Array<UnrealPropertyBase::ptr> readSet(BinaryReader& reader, Containers::StringView item_type, Containers::Array<UnrealPropertyBase::ptr> readSet(BinaryReader& reader, Containers::StringView item_type,
UnsignedInt count); std::uint32_t count);
UnrealPropertyBase::ptr deserialise(Containers::String name, Containers::String type, UnsignedLong value_length, UnrealPropertyBase::ptr deserialise(Containers::String name, Containers::String type, std::size_t value_length,
BinaryReader& reader); 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); BinaryWriter& writer);
bool write(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer); bool write(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written, BinaryWriter& writer);
bool writeItem(UnrealPropertyBase::ptr& prop, Containers::StringView item_type, UnsignedLong& bytes_written, bool writeItem(UnrealPropertyBase::ptr& prop, Containers::StringView item_type, std::size_t& bytes_written,
BinaryWriter& writer); BinaryWriter& writer);
bool writeSet(Containers::ArrayView<UnrealPropertyBase::ptr> props, Containers::StringView item_type, bool writeSet(Containers::ArrayView<UnrealPropertyBase::ptr> props, Containers::StringView item_type,
UnsignedLong& bytes_written, BinaryWriter& writer); std::size_t& bytes_written, BinaryWriter& writer);
private: private:
PropertySerialiser(); PropertySerialiser();

View file

@ -21,12 +21,9 @@
#include <Corrade/Containers/Pointer.h> #include <Corrade/Containers/Pointer.h>
#include <Corrade/Containers/StringView.h> #include <Corrade/Containers/StringView.h>
#include <Magnum/Types.h>
#include "../Types/UnrealPropertyBase.h" #include "../Types/UnrealPropertyBase.h"
using namespace Corrade; using namespace Corrade;
using namespace Magnum;
class BinaryReader; class BinaryReader;
class BinaryWriter; class BinaryWriter;
@ -44,9 +41,9 @@ class AbstractUnrealCollectionPropertySerialiser {
virtual StringArrayView types() = 0; virtual StringArrayView types() = 0;
virtual PropertyArray deserialise(Containers::StringView name, Containers::StringView type, 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; PropertySerialiser& serialiser) = 0;
virtual auto serialise(Containers::ArrayView<UnrealPropertyBase::ptr> props, Containers::StringView item_type, virtual bool serialise(Containers::ArrayView<UnrealPropertyBase::ptr> props, Containers::StringView item_type,
UnsignedLong& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) -> bool = 0; std::size_t& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) = 0;
}; };

View file

@ -20,12 +20,9 @@
#include <Corrade/Containers/Pointer.h> #include <Corrade/Containers/Pointer.h>
#include <Corrade/Containers/StringView.h> #include <Corrade/Containers/StringView.h>
#include <Magnum/Types.h>
#include "../Types/UnrealPropertyBase.h" #include "../Types/UnrealPropertyBase.h"
using namespace Corrade; using namespace Corrade;
using namespace Magnum;
class BinaryReader; class BinaryReader;
class BinaryWriter; class BinaryWriter;
@ -42,9 +39,9 @@ class AbstractUnrealPropertySerialiser {
virtual StringArrayView types() = 0; virtual StringArrayView types() = 0;
virtual UnrealPropertyBase::ptr deserialise(Containers::StringView name, Containers::StringView type, 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; 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; PropertySerialiser& serialiser) = 0;
}; };

View file

@ -21,12 +21,9 @@
#include <Corrade/Containers/Pointer.h> #include <Corrade/Containers/Pointer.h>
#include <Corrade/Containers/StringView.h> #include <Corrade/Containers/StringView.h>
#include <Magnum/Types.h>
#include "../Types/UnrealPropertyBase.h" #include "../Types/UnrealPropertyBase.h"
using namespace Corrade; using namespace Corrade;
using namespace Magnum;
class BinaryReader; class BinaryReader;
class BinaryWriter; class BinaryWriter;
@ -41,6 +38,5 @@ class AbstractUnrealStructSerialiser {
virtual UnrealPropertyBase::ptr deserialise(BinaryReader& reader) = 0; virtual UnrealPropertyBase::ptr deserialise(BinaryReader& reader) = 0;
virtual bool serialise(UnrealPropertyBase::ptr& structProp, BinaryWriter& writer, virtual bool serialise(UnrealPropertyBase::ptr& structProp, BinaryWriter& writer, std::size_t& bytes_written) = 0;
UnsignedLong& bytes_written) = 0;
}; };

View file

@ -25,7 +25,7 @@
UnrealPropertyBase::ptr UnrealPropertyBase::ptr
ArrayPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type, ArrayPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type,
UnsignedLong value_length, BinaryReader& reader, std::size_t value_length, BinaryReader& reader,
PropertySerialiser& serialiser) PropertySerialiser& serialiser)
{ {
Containers::String item_type; Containers::String item_type;
@ -40,8 +40,8 @@ ArrayPropertySerialiser::deserialiseProperty(Containers::StringView name, Contai
return nullptr; return nullptr;
} }
UnsignedInt item_count; std::uint32_t item_count;
if(!reader.readUnsignedInt(item_count)) { if(!reader.readUint32(item_count)) {
LOG_ERROR_FORMAT("Couldn't read array property {}'s item count.", name); LOG_ERROR_FORMAT("Couldn't read array property {}'s item count.", name);
return nullptr; return nullptr;
} }
@ -54,7 +54,7 @@ ArrayPropertySerialiser::deserialiseProperty(Containers::StringView name, Contai
} }
bool bool
ArrayPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, ArrayPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written,
BinaryWriter& writer, PropertySerialiser& serialiser) BinaryWriter& writer, PropertySerialiser& serialiser)
{ {
auto array_prop = dynamic_cast<ArrayProperty*>(prop.get()); auto array_prop = dynamic_cast<ArrayProperty*>(prop.get());
@ -65,10 +65,10 @@ ArrayPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, Unsign
writer.writeUEStringToArray(array_prop->itemType); writer.writeUEStringToArray(array_prop->itemType);
writer.writeValueToArray<char>('\0'); writer.writeValueToArray<char>('\0');
bytes_written += writer.writeValueToArray<UnsignedInt>(UnsignedInt(array_prop->items.size())); bytes_written += writer.writeValueToArray<std::uint32_t>(std::uint32_t(array_prop->items.size()));
UnsignedLong start_pos = writer.arrayPosition(); std::size_t start_pos = writer.arrayPosition();
UnsignedLong dummy_bytes_written = 0; std::size_t dummy_bytes_written = 0;
bool ret = serialiser.writeSet(array_prop->items, array_prop->itemType, dummy_bytes_written, writer); bool ret = serialiser.writeSet(array_prop->items, array_prop->itemType, dummy_bytes_written, writer);
bytes_written += writer.arrayPosition() - start_pos; bytes_written += writer.arrayPosition() - start_pos;

View file

@ -18,14 +18,11 @@
#include <Corrade/Containers/StringView.h> #include <Corrade/Containers/StringView.h>
#include <Magnum/Types.h>
#include "UnrealPropertySerialiser.h" #include "UnrealPropertySerialiser.h"
#include "../Types/ArrayProperty.h" #include "../Types/ArrayProperty.h"
using namespace Corrade; using namespace Corrade;
using namespace Magnum;
class ArrayPropertySerialiser : public UnrealPropertySerialiser<ArrayProperty> { class ArrayPropertySerialiser : public UnrealPropertySerialiser<ArrayProperty> {
public: public:
@ -33,8 +30,8 @@ class ArrayPropertySerialiser : public UnrealPropertySerialiser<ArrayProperty> {
private: private:
UnrealPropertyBase::ptr deserialiseProperty(Containers::StringView name, Containers::StringView type, UnrealPropertyBase::ptr deserialiseProperty(Containers::StringView name, Containers::StringView type,
UnsignedLong value_length, BinaryReader& reader, std::size_t value_length, BinaryReader& reader,
PropertySerialiser& serialiser) override; 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; PropertySerialiser& serialiser) override;
}; };

View file

@ -28,7 +28,7 @@ BoolPropertySerialiser::types() {
} }
UnrealPropertyBase::ptr 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) BinaryReader& reader, PropertySerialiser& serialiser)
{ {
if(value_length != 0) { if(value_length != 0) {
@ -36,8 +36,8 @@ BoolPropertySerialiser::deserialise(Containers::StringView name, Containers::Str
return nullptr; return nullptr;
} }
Short value; std::int16_t value;
if(!reader.readShort(value)) { if(!reader.readInt16(value)) {
LOG_ERROR_FORMAT("Couldn't read bool property {}'s value.", name); LOG_ERROR_FORMAT("Couldn't read bool property {}'s value.", name);
return nullptr; return nullptr;
} }
@ -54,7 +54,7 @@ BoolPropertySerialiser::deserialise(Containers::StringView name, Containers::Str
} }
bool 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) PropertySerialiser& serialiser)
{ {
auto bool_prop = dynamic_cast<BoolProperty*>(prop.get()); auto bool_prop = dynamic_cast<BoolProperty*>(prop.get());
@ -63,7 +63,7 @@ BoolPropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& b
return false; return false;
} }
writer.writeValueToArray<Short>(Short(bool_prop->value)); writer.writeValueToArray<std::int16_t>(std::int16_t(bool_prop->value));
return true; return true;
} }

View file

@ -32,9 +32,9 @@ class BoolPropertySerialiser : public AbstractUnrealPropertySerialiser {
StringArrayView types() override; StringArrayView types() override;
UnrealPropertyBase::ptr deserialise(Containers::StringView name, Containers::StringView type, UnrealPropertyBase::ptr deserialise(Containers::StringView name, Containers::StringView type,
UnsignedLong value_length, BinaryReader& reader, std::size_t value_length, BinaryReader& reader,
PropertySerialiser& serialiser) override; 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; PropertySerialiser& serialiser) override;
}; };

View file

@ -28,12 +28,12 @@ BytePropertySerialiser::types() {
} }
UnrealPropertyBase::ptr 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) BinaryReader& reader, PropertySerialiser& serialiser)
{ {
auto prop = Containers::pointer<ByteProperty>(); auto prop = Containers::pointer<ByteProperty>();
if(value_length != UnsignedLong(-1)) { if(value_length != std::size_t(-1)) {
if(!reader.readUEString(prop->enumType)) { if(!reader.readUEString(prop->enumType)) {
LOG_ERROR_FORMAT("Couldn't read byte property {}'s enum type.", name); LOG_ERROR_FORMAT("Couldn't read byte property {}'s enum type.", name);
return nullptr; return nullptr;
@ -53,8 +53,8 @@ BytePropertySerialiser::deserialise(Containers::StringView name, Containers::Str
prop->valueLength = value_length; prop->valueLength = value_length;
//UnsignedInt count = 0; //std::uint32_t count = 0;
//if(!reader.readUnsignedInt(count)) { //if(!reader.readstd::uint32_t(count)) {
// return nullptr; // return nullptr;
//} //}
@ -66,7 +66,7 @@ BytePropertySerialiser::deserialise(Containers::StringView name, Containers::Str
} }
bool 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) PropertySerialiser& serialiser)
{ {
auto byte_prop = dynamic_cast<ByteProperty*>(prop.get()); auto byte_prop = dynamic_cast<ByteProperty*>(prop.get());
@ -76,10 +76,10 @@ BytePropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& b
} }
//writer.writeValueToArray<char>('\0'); //writer.writeValueToArray<char>('\0');
//bytes_written += writer.writeValueToArray<UnsignedInt>(byte_prop->value.size()); //bytes_written += writer.writeValueToArray<std::uint32_t>(byte_prop->value.size());
//bytes_written += writer.writeDataToArray<char>(byte_prop->value); //bytes_written += writer.writeDataToArray<char>(byte_prop->value);
if(byte_prop->valueLength != UnsignedLong(-1)) { if(byte_prop->valueLength != std::size_t(-1)) {
writer.writeUEStringToArray(byte_prop->enumType); writer.writeUEStringToArray(byte_prop->enumType);
writer.writeValueToArray<char>('\0'); writer.writeValueToArray<char>('\0');
} }

View file

@ -30,9 +30,9 @@ class BytePropertySerialiser : public AbstractUnrealPropertySerialiser {
StringArrayView types() override; StringArrayView types() override;
UnrealPropertyBase::ptr deserialise(Containers::StringView name, Containers::StringView type, UnrealPropertyBase::ptr deserialise(Containers::StringView name, Containers::StringView type,
UnsignedLong value_length, BinaryReader& reader, std::size_t value_length, BinaryReader& reader,
PropertySerialiser& serialiser) override; 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; PropertySerialiser& serialiser) override;
}; };

View file

@ -22,7 +22,7 @@
UnrealPropertyBase::ptr UnrealPropertyBase::ptr
ColourPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type, ColourPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type,
UnsignedLong value_length, BinaryReader& reader, std::size_t value_length, BinaryReader& reader,
PropertySerialiser& serialiser) PropertySerialiser& serialiser)
{ {
auto prop = Containers::pointer<ColourStructProperty>(); auto prop = Containers::pointer<ColourStructProperty>();
@ -38,7 +38,7 @@ ColourPropertySerialiser::deserialiseProperty(Containers::StringView name, Conta
} }
bool bool
ColourPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, ColourPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written,
BinaryWriter& writer, PropertySerialiser& serialiser) BinaryWriter& writer, PropertySerialiser& serialiser)
{ {
auto colour_prop = dynamic_cast<ColourStructProperty*>(prop.get()); auto colour_prop = dynamic_cast<ColourStructProperty*>(prop.get());
@ -47,10 +47,10 @@ ColourPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, Unsig
return false; return false;
} }
bytes_written += writer.writeValueToArray<Float>(colour_prop->r) + bytes_written += writer.writeValueToArray<float>(colour_prop->r) +
writer.writeValueToArray<Float>(colour_prop->g) + writer.writeValueToArray<float>(colour_prop->g) +
writer.writeValueToArray<Float>(colour_prop->b) + writer.writeValueToArray<float>(colour_prop->b) +
writer.writeValueToArray<Float>(colour_prop->a); writer.writeValueToArray<float>(colour_prop->a);
return true; return true;
} }

View file

@ -30,8 +30,8 @@ class ColourPropertySerialiser : public UnrealPropertySerialiser<ColourStructPro
private: private:
UnrealPropertyBase::ptr deserialiseProperty(Containers::StringView name, Containers::StringView type, UnrealPropertyBase::ptr deserialiseProperty(Containers::StringView name, Containers::StringView type,
UnsignedLong value_length, BinaryReader& reader, std::size_t value_length, BinaryReader& reader,
PropertySerialiser& serialiser) override; 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; PropertySerialiser& serialiser) override;
}; };

View file

@ -22,12 +22,12 @@
UnrealPropertyBase::ptr UnrealPropertyBase::ptr
DateTimePropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type, DateTimePropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type,
UnsignedLong value_length, BinaryReader& reader, std::size_t value_length, BinaryReader& reader,
PropertySerialiser& serialiser) PropertySerialiser& serialiser)
{ {
auto prop = Containers::pointer<DateTimeStructProperty>(); auto prop = Containers::pointer<DateTimeStructProperty>();
if(!reader.readUnsignedLong(prop->timestamp)) { if(!reader.readInt64(prop->timestamp)) {
LOG_ERROR_FORMAT("Couldn't read date/time property {}'s value.", name); LOG_ERROR_FORMAT("Couldn't read date/time property {}'s value.", name);
return nullptr; return nullptr;
} }
@ -36,7 +36,7 @@ DateTimePropertySerialiser::deserialiseProperty(Containers::StringView name, Con
} }
bool bool
DateTimePropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, DateTimePropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written,
BinaryWriter& writer, PropertySerialiser& serialiser) BinaryWriter& writer, PropertySerialiser& serialiser)
{ {
auto dt_prop = dynamic_cast<DateTimeStructProperty*>(prop.get()); auto dt_prop = dynamic_cast<DateTimeStructProperty*>(prop.get());
@ -45,7 +45,7 @@ DateTimePropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, Uns
return false; return false;
} }
bytes_written += writer.writeValueToArray<UnsignedLong>(dt_prop->timestamp); bytes_written += writer.writeValueToArray<std::int64_t>(dt_prop->timestamp);
return true; return true;
} }

View file

@ -28,8 +28,8 @@ class DateTimePropertySerialiser : public UnrealPropertySerialiser<DateTimeStruc
private: private:
UnrealPropertyBase::ptr deserialiseProperty(Containers::StringView name, Containers::StringView type, UnrealPropertyBase::ptr deserialiseProperty(Containers::StringView name, Containers::StringView type,
UnsignedLong value_length, BinaryReader& reader, std::size_t value_length, BinaryReader& reader,
PropertySerialiser& serialiser) override; 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; PropertySerialiser& serialiser) override;
}; };

View file

@ -28,7 +28,7 @@ EnumPropertySerialiser::types() {
} }
UnrealPropertyBase::ptr UnrealPropertyBase::ptr
EnumPropertySerialiser::deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length, EnumPropertySerialiser::deserialise(Containers::StringView name, Containers::StringView type, std::size_t value_length,
BinaryReader& reader, PropertySerialiser& serialiser) BinaryReader& reader, PropertySerialiser& serialiser)
{ {
auto prop = Containers::pointer<EnumProperty>(); auto prop = Containers::pointer<EnumProperty>();
@ -53,7 +53,7 @@ EnumPropertySerialiser::deserialise(Containers::StringView name, Containers::Str
} }
bool 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) PropertySerialiser& serialiser)
{ {
auto enum_prop = dynamic_cast<EnumProperty*>(prop.get()); auto enum_prop = dynamic_cast<EnumProperty*>(prop.get());

View file

@ -30,9 +30,9 @@ class EnumPropertySerialiser : public AbstractUnrealPropertySerialiser {
StringArrayView types() override; StringArrayView types() override;
UnrealPropertyBase::ptr deserialise(Containers::StringView name, Containers::StringView type, UnrealPropertyBase::ptr deserialise(Containers::StringView name, Containers::StringView type,
UnsignedLong value_length, BinaryReader& reader, std::size_t value_length, BinaryReader& reader,
PropertySerialiser& serialiser) override; 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; PropertySerialiser& serialiser) override;
}; };

View file

@ -29,7 +29,7 @@ FloatPropertySerialiser::types() {
UnrealPropertyBase::ptr UnrealPropertyBase::ptr
FloatPropertySerialiser::deserialise(Containers::StringView name, Containers::StringView type, 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<FloatProperty>(); auto prop = Containers::pointer<FloatProperty>();
@ -48,7 +48,7 @@ FloatPropertySerialiser::deserialise(Containers::StringView name, Containers::St
} }
bool 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) PropertySerialiser& serialiser)
{ {
auto float_prop = dynamic_cast<FloatProperty*>(prop.get()); auto float_prop = dynamic_cast<FloatProperty*>(prop.get());
@ -58,7 +58,7 @@ FloatPropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, UnsignedLong&
} }
writer.writeValueToArray<char>('\0'); writer.writeValueToArray<char>('\0');
bytes_written += writer.writeValueToArray<Float>(float_prop->value); bytes_written += writer.writeValueToArray<float>(float_prop->value);
return true; return true;
} }

View file

@ -30,9 +30,9 @@ class FloatPropertySerialiser : public AbstractUnrealPropertySerialiser {
StringArrayView types() override; StringArrayView types() override;
UnrealPropertyBase::ptr deserialise(Containers::StringView name, Containers::StringView type, UnrealPropertyBase::ptr deserialise(Containers::StringView name, Containers::StringView type,
UnsignedLong value_length, BinaryReader& reader, std::size_t value_length, BinaryReader& reader,
PropertySerialiser& serialiser) override; 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; PropertySerialiser& serialiser) override;
}; };

View file

@ -24,7 +24,7 @@ using namespace Containers::Literals;
UnrealPropertyBase::ptr UnrealPropertyBase::ptr
GuidPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type, GuidPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type,
UnsignedLong value_length, BinaryReader& reader, std::size_t value_length, BinaryReader& reader,
PropertySerialiser& serialiser) PropertySerialiser& serialiser)
{ {
auto prop = Containers::pointer<GuidStructProperty>(); auto prop = Containers::pointer<GuidStructProperty>();
@ -38,7 +38,7 @@ GuidPropertySerialiser::deserialiseProperty(Containers::StringView name, Contain
} }
bool bool
GuidPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, GuidPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written,
BinaryWriter& writer, PropertySerialiser& serialiser) BinaryWriter& writer, PropertySerialiser& serialiser)
{ {
auto guid_prop = dynamic_cast<GuidStructProperty*>(prop.get()); auto guid_prop = dynamic_cast<GuidStructProperty*>(prop.get());

View file

@ -28,8 +28,8 @@ class GuidPropertySerialiser : public UnrealPropertySerialiser<GuidStructPropert
private: private:
UnrealPropertyBase::ptr deserialiseProperty(Containers::StringView name, Containers::StringView type, UnrealPropertyBase::ptr deserialiseProperty(Containers::StringView name, Containers::StringView type,
UnsignedLong value_length, BinaryReader& reader, std::size_t value_length, BinaryReader& reader,
PropertySerialiser& serialiser) override; 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; PropertySerialiser& serialiser) override;
}; };

View file

@ -22,18 +22,18 @@
UnrealPropertyBase::ptr UnrealPropertyBase::ptr
IntPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type, IntPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type,
UnsignedLong value_length, BinaryReader& reader, std::size_t value_length, BinaryReader& reader,
PropertySerialiser& serialiser) PropertySerialiser& serialiser)
{ {
auto prop = Containers::pointer<IntProperty>(); auto prop = Containers::pointer<IntProperty>();
if(value_length == UnsignedLong(-1)) { if(value_length == std::size_t(-1)) {
if(!reader.readInt(prop->value)) { if(!reader.readInt32(prop->value)) {
LOG_ERROR("Couldn't read int property's value."); LOG_ERROR("Couldn't read int property's value.");
return nullptr; return nullptr;
} }
prop->valueLength = UnsignedLong(-1); prop->valueLength = std::size_t(-1);
return prop; return prop;
} }
@ -43,7 +43,7 @@ IntPropertySerialiser::deserialiseProperty(Containers::StringView name, Containe
return nullptr; return nullptr;
} }
if(!reader.readInt(prop->value)) { if(!reader.readInt32(prop->value)) {
LOG_ERROR_FORMAT("Couldn't read int property {}'s value.", name); LOG_ERROR_FORMAT("Couldn't read int property {}'s value.", name);
return nullptr; return nullptr;
} }
@ -54,7 +54,7 @@ IntPropertySerialiser::deserialiseProperty(Containers::StringView name, Containe
} }
bool bool
IntPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, IntPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written,
BinaryWriter& writer, PropertySerialiser& serialiser) BinaryWriter& writer, PropertySerialiser& serialiser)
{ {
auto int_prop = dynamic_cast<IntProperty*>(prop.get()); auto int_prop = dynamic_cast<IntProperty*>(prop.get());
@ -63,11 +63,11 @@ IntPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, Unsigned
return false; return false;
} }
if(prop->valueLength != UnsignedLong(-1)) { if(prop->valueLength != std::size_t(-1)) {
writer.writeValueToArray<char>('\0'); writer.writeValueToArray<char>('\0');
} }
bytes_written += writer.writeValueToArray<Int>(int_prop->value); bytes_written += writer.writeValueToArray<std::int32_t>(int_prop->value);
return true; return true;
} }

View file

@ -28,8 +28,8 @@ class IntPropertySerialiser : public UnrealPropertySerialiser<IntProperty> {
private: private:
UnrealPropertyBase::ptr deserialiseProperty(Containers::StringView name, Containers::StringView type, UnrealPropertyBase::ptr deserialiseProperty(Containers::StringView name, Containers::StringView type,
UnsignedLong value_length, BinaryReader& reader, std::size_t value_length, BinaryReader& reader,
PropertySerialiser& serialiser) override; 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; PropertySerialiser& serialiser) override;
}; };

View file

@ -26,7 +26,7 @@ using namespace Containers::Literals;
UnrealPropertyBase::ptr UnrealPropertyBase::ptr
MapPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type, MapPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type,
UnsignedLong value_length, BinaryReader& reader, std::size_t value_length, BinaryReader& reader,
PropertySerialiser& serialiser) PropertySerialiser& serialiser)
{ {
auto prop = Containers::pointer<MapProperty>(); auto prop = Containers::pointer<MapProperty>();
@ -47,14 +47,14 @@ MapPropertySerialiser::deserialiseProperty(Containers::StringView name, Containe
return nullptr; return nullptr;
} }
UnsignedInt null; std::uint32_t null;
if(!reader.readUnsignedInt(null) || null != 0u) { if(!reader.readUint32(null) || null != 0u) {
LOG_ERROR_FORMAT("Couldn't read a null int in map property {}.", name); LOG_ERROR_FORMAT("Couldn't read a null int in map property {}.", name);
return nullptr; return nullptr;
} }
UnsignedInt count; std::uint32_t count;
if(!reader.readUnsignedInt(count)) { if(!reader.readUint32(count)) {
LOG_ERROR_FORMAT("Couldn't read map property {}'s item count.", name); LOG_ERROR_FORMAT("Couldn't read map property {}'s item count.", name);
return nullptr; return nullptr;
} }
@ -64,7 +64,7 @@ MapPropertySerialiser::deserialiseProperty(Containers::StringView name, Containe
arrayReserve(prop->map, count); arrayReserve(prop->map, count);
for(UnsignedInt i = 0; i < count; i++) { for(std::uint32_t i = 0; i < count; i++) {
MapProperty::KeyValuePair pair; MapProperty::KeyValuePair pair;
if(prop->keyType == "IntProperty"_s || prop->keyType == "StrProperty"_s) { if(prop->keyType == "IntProperty"_s || prop->keyType == "StrProperty"_s) {
@ -109,7 +109,7 @@ MapPropertySerialiser::deserialiseProperty(Containers::StringView name, Containe
} }
bool bool
MapPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, MapPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written,
BinaryWriter& writer, PropertySerialiser& serialiser) BinaryWriter& writer, PropertySerialiser& serialiser)
{ {
auto map_prop = dynamic_cast<MapProperty*>(prop.get()); auto map_prop = dynamic_cast<MapProperty*>(prop.get());
@ -122,12 +122,12 @@ MapPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, Unsigned
writer.writeUEStringToArray(map_prop->valueType); writer.writeUEStringToArray(map_prop->valueType);
writer.writeValueToArray<char>('\0'); writer.writeValueToArray<char>('\0');
UnsignedLong value_start = writer.arrayPosition(); std::size_t value_start = writer.arrayPosition();
writer.writeValueToArray<UnsignedInt>(0u); writer.writeValueToArray<std::uint32_t>(0u);
writer.writeValueToArray<UnsignedInt>(UnsignedInt(map_prop->map.size())); writer.writeValueToArray<std::uint32_t>(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) { for(auto& pair : map_prop->map) {
if(!serialiser.writeItem(pair.key, map_prop->keyType, dummy_bytes_written, writer)) { if(!serialiser.writeItem(pair.key, map_prop->keyType, dummy_bytes_written, writer)) {
LOG_ERROR("Couldn't write a key."); LOG_ERROR("Couldn't write a key.");

View file

@ -28,8 +28,8 @@ class MapPropertySerialiser : public UnrealPropertySerialiser<MapProperty> {
private: private:
UnrealPropertyBase::ptr deserialiseProperty(Containers::StringView name, Containers::StringView type, UnrealPropertyBase::ptr deserialiseProperty(Containers::StringView name, Containers::StringView type,
UnsignedLong value_length, BinaryReader& reader, std::size_t value_length, BinaryReader& reader,
PropertySerialiser& serialiser) override; 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; PropertySerialiser& serialiser) override;
}; };

View file

@ -27,7 +27,7 @@ using namespace Containers::Literals;
UnrealPropertyBase::ptr UnrealPropertyBase::ptr
ResourcePropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type, ResourcePropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type,
UnsignedLong value_length, BinaryReader& reader, std::size_t value_length, BinaryReader& reader,
PropertySerialiser& serialiser) PropertySerialiser& serialiser)
{ {
auto prop = Containers::pointer<ResourceItemValue>(); auto prop = Containers::pointer<ResourceItemValue>();
@ -79,7 +79,7 @@ ResourcePropertySerialiser::deserialiseProperty(Containers::StringView name, Con
} }
bool bool
ResourcePropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, ResourcePropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written,
BinaryWriter& writer, PropertySerialiser& serialiser) BinaryWriter& writer, PropertySerialiser& serialiser)
{ {
auto res_prop = dynamic_cast<ResourceItemValue*>(prop.get()); auto res_prop = dynamic_cast<ResourceItemValue*>(prop.get());
@ -90,15 +90,15 @@ ResourcePropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, Uns
bytes_written += writer.writeUEStringToArray("ID_4_AAE08F17428E229EC7A2209F51081A21"_s) + bytes_written += writer.writeUEStringToArray("ID_4_AAE08F17428E229EC7A2209F51081A21"_s) +
writer.writeUEStringToArray("IntProperty"_s) + writer.writeUEStringToArray("IntProperty"_s) +
writer.writeValueToArray<UnsignedLong>(4ull) + writer.writeValueToArray<std::size_t>(4ull) +
writer.writeValueToArray<char>('\0') + writer.writeValueToArray<char>('\0') +
writer.writeValueToArray<Int>(res_prop->id); writer.writeValueToArray<std::int32_t>(res_prop->id);
bytes_written += writer.writeUEStringToArray("Quantity_3_560F09B5485C365D3041888910019CE3"_s) + bytes_written += writer.writeUEStringToArray("Quantity_3_560F09B5485C365D3041888910019CE3"_s) +
writer.writeUEStringToArray("IntProperty"_s) + writer.writeUEStringToArray("IntProperty"_s) +
writer.writeValueToArray<UnsignedLong>(4ull) + writer.writeValueToArray<std::size_t>(4ull) +
writer.writeValueToArray<char>('\0') + writer.writeValueToArray<char>('\0') +
writer.writeValueToArray<Int>(res_prop->quantity); writer.writeValueToArray<std::int32_t>(res_prop->quantity);
bytes_written += writer.writeUEStringToArray("None"_s); bytes_written += writer.writeUEStringToArray("None"_s);

View file

@ -28,8 +28,8 @@ class ResourcePropertySerialiser : public UnrealPropertySerialiser<ResourceItemV
private: private:
UnrealPropertyBase::ptr deserialiseProperty(Containers::StringView name, Containers::StringView type, UnrealPropertyBase::ptr deserialiseProperty(Containers::StringView name, Containers::StringView type,
UnsignedLong value_length, BinaryReader& reader, std::size_t value_length, BinaryReader& reader,
PropertySerialiser& serialiser) override; 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; PropertySerialiser& serialiser) override;
}; };

View file

@ -22,7 +22,7 @@
UnrealPropertyBase::ptr UnrealPropertyBase::ptr
RotatorPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type, RotatorPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type,
UnsignedLong value_length, BinaryReader& reader, std::size_t value_length, BinaryReader& reader,
PropertySerialiser& serialiser) PropertySerialiser& serialiser)
{ {
auto prop = Containers::pointer<RotatorStructProperty>(); auto prop = Containers::pointer<RotatorStructProperty>();
@ -36,7 +36,7 @@ RotatorPropertySerialiser::deserialiseProperty(Containers::StringView name, Cont
} }
bool bool
RotatorPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, RotatorPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written,
BinaryWriter& writer, PropertySerialiser& serialiser) BinaryWriter& writer, PropertySerialiser& serialiser)
{ {
auto rotator = dynamic_cast<RotatorStructProperty*>(prop.get()); auto rotator = dynamic_cast<RotatorStructProperty*>(prop.get());
@ -45,8 +45,8 @@ RotatorPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, Unsi
return false; return false;
} }
bytes_written += writer.writeValueToArray<Float>(rotator->x) + writer.writeValueToArray<Float>(rotator->y) + bytes_written += writer.writeValueToArray<float>(rotator->x) + writer.writeValueToArray<float>(rotator->y) +
writer.writeValueToArray<Float>(rotator->z); writer.writeValueToArray<float>(rotator->z);
return true; return true;
} }

View file

@ -28,8 +28,8 @@ class RotatorPropertySerialiser : public UnrealPropertySerialiser<RotatorStructP
private: private:
UnrealPropertyBase::ptr deserialiseProperty(Containers::StringView name, Containers::StringView type, UnrealPropertyBase::ptr deserialiseProperty(Containers::StringView name, Containers::StringView type,
UnsignedLong value_length, BinaryReader& reader, std::size_t value_length, BinaryReader& reader,
PropertySerialiser& serialiser) override; 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; PropertySerialiser& serialiser) override;
}; };

View file

@ -23,7 +23,7 @@
UnrealPropertyBase::ptr UnrealPropertyBase::ptr
SetPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type, SetPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type,
UnsignedLong value_length, BinaryReader& reader, std::size_t value_length, BinaryReader& reader,
PropertySerialiser& serialiser) PropertySerialiser& serialiser)
{ {
Containers::String item_type; Containers::String item_type;
@ -38,14 +38,14 @@ SetPropertySerialiser::deserialiseProperty(Containers::StringView name, Containe
return nullptr; return nullptr;
} }
UnsignedInt four_bytes; std::uint32_t four_bytes;
if(!reader.readUnsignedInt(four_bytes) || four_bytes != 0u) { if(!reader.readUint32(four_bytes) || four_bytes != 0u) {
LOG_ERROR_FORMAT("Couldn't read four null bytes in set property {}.", name); LOG_ERROR_FORMAT("Couldn't read four null bytes in set property {}.", name);
return nullptr; return nullptr;
} }
UnsignedInt item_count; std::uint32_t item_count;
if(!reader.readUnsignedInt(item_count)) { if(!reader.readUint32(item_count)) {
LOG_ERROR_FORMAT("Couldn't read set property {}'s item count.", name); LOG_ERROR_FORMAT("Couldn't read set property {}'s item count.", name);
return nullptr; return nullptr;
} }
@ -58,7 +58,7 @@ SetPropertySerialiser::deserialiseProperty(Containers::StringView name, Containe
} }
bool bool
SetPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, SetPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written,
BinaryWriter& writer, PropertySerialiser& serialiser) BinaryWriter& writer, PropertySerialiser& serialiser)
{ {
auto set_prop = dynamic_cast<SetProperty*>(prop.get()); auto set_prop = dynamic_cast<SetProperty*>(prop.get());
@ -70,11 +70,11 @@ SetPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, Unsigned
writer.writeUEStringToArray(set_prop->itemType); writer.writeUEStringToArray(set_prop->itemType);
writer.writeValueToArray<char>('\0'); writer.writeValueToArray<char>('\0');
bytes_written += writer.writeValueToArray<UnsignedInt>(0u); bytes_written += writer.writeValueToArray<std::uint32_t>(0u);
bytes_written += writer.writeValueToArray<UnsignedInt>(UnsignedInt(set_prop->items.size())); bytes_written += writer.writeValueToArray<std::uint32_t>(std::uint32_t(set_prop->items.size()));
UnsignedLong start_pos = writer.arrayPosition(); std::size_t start_pos = writer.arrayPosition();
UnsignedLong dummy_bytes_written = 0; std::size_t dummy_bytes_written = 0;
serialiser.writeSet(set_prop->items, set_prop->itemType, dummy_bytes_written, writer); serialiser.writeSet(set_prop->items, set_prop->itemType, dummy_bytes_written, writer);
bytes_written += writer.arrayPosition() - start_pos; bytes_written += writer.arrayPosition() - start_pos;

View file

@ -28,8 +28,8 @@ class SetPropertySerialiser : public UnrealPropertySerialiser<SetProperty> {
private: private:
UnrealPropertyBase::ptr deserialiseProperty(Containers::StringView name, Containers::StringView type, UnrealPropertyBase::ptr deserialiseProperty(Containers::StringView name, Containers::StringView type,
UnsignedLong value_length, BinaryReader& reader, std::size_t value_length, BinaryReader& reader,
PropertySerialiser& serialiser) override; 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; PropertySerialiser& serialiser) override;
}; };

View file

@ -31,11 +31,11 @@ StringPropertySerialiser::types() {
UnrealPropertyBase::ptr UnrealPropertyBase::ptr
StringPropertySerialiser::deserialise(Containers::StringView name, Containers::StringView type, 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<StringProperty>(type); auto prop = Containers::pointer<StringProperty>(type);
if(value_length != UnsignedLong(-1)) { if(value_length != std::size_t(-1)) {
char terminator; char terminator;
if(!reader.readChar(terminator) || terminator != '\0') { if(!reader.readChar(terminator) || terminator != '\0') {
LOG_ERROR_FORMAT("Couldn't read a null byte in string property {}.", name); 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 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) PropertySerialiser& serialiser)
{ {
auto str_prop = dynamic_cast<StringProperty*>(prop.get()); auto str_prop = dynamic_cast<StringProperty*>(prop.get());
@ -63,7 +63,7 @@ StringPropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, UnsignedLong&
return false; return false;
} }
if(str_prop->valueLength != UnsignedLong(-1)) { if(str_prop->valueLength != std::size_t(-1)) {
writer.writeValueToArray<char>('\0'); writer.writeValueToArray<char>('\0');
} }

View file

@ -30,9 +30,9 @@ class StringPropertySerialiser : public AbstractUnrealPropertySerialiser {
StringArrayView types() override; StringArrayView types() override;
UnrealPropertyBase::ptr deserialise(Containers::StringView name, Containers::StringView type, UnrealPropertyBase::ptr deserialise(Containers::StringView name, Containers::StringView type,
UnsignedLong value_length, BinaryReader& reader, std::size_t value_length, BinaryReader& reader,
PropertySerialiser& serialiser) override; 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; PropertySerialiser& serialiser) override;
}; };

View file

@ -33,8 +33,8 @@ StructSerialiser::types() {
} }
Containers::Array<UnrealPropertyBase::ptr> Containers::Array<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,
UnsignedInt count, BinaryReader& reader, PropertySerialiser& serialiser) std::uint32_t count, BinaryReader& reader, PropertySerialiser& serialiser)
{ {
Containers::String item_type; Containers::String item_type;
if(!reader.readUEString(item_type)) { if(!reader.readUEString(item_type)) {
@ -62,10 +62,10 @@ StructSerialiser::deserialise(Containers::StringView name, Containers::StringVie
prop->structGuid = std::move(guid); prop->structGuid = std::move(guid);
} }
else { else {
for(UnsignedInt i = 0; i < count; i++) { for(std::uint32_t i = 0; i < count; i++) {
auto prop = Containers::pointer<UnrealPropertyBase>(); auto prop = Containers::pointer<UnrealPropertyBase>();
prop = serialiser.readItem(reader, item_type, UnsignedLong(-1), name); prop = serialiser.readItem(reader, item_type, std::size_t(-1), name);
if(!prop) { if(!prop) {
prop = readStructValue(name, item_type, value_length, reader, serialiser); prop = readStructValue(name, item_type, value_length, reader, serialiser);
@ -86,7 +86,7 @@ StructSerialiser::deserialise(Containers::StringView name, Containers::StringVie
} }
UnrealPropertyBase::ptr 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) BinaryReader& reader, PropertySerialiser& serialiser)
{ {
Containers::String item_type; Containers::String item_type;
@ -125,12 +125,12 @@ StructSerialiser::deserialise(Containers::StringView name, Containers::StringVie
bool bool
StructSerialiser::serialise(Containers::ArrayView<UnrealPropertyBase::ptr> props, Containers::StringView item_type, StructSerialiser::serialise(Containers::ArrayView<UnrealPropertyBase::ptr> 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(*(props.front()->name));
bytes_written += writer.writeUEStringToArray(item_type); bytes_written += writer.writeUEStringToArray(item_type);
UnsignedLong vl_pos = writer.arrayPosition(); std::size_t vl_pos = writer.arrayPosition();
bytes_written += writer.writeValueToArray<UnsignedLong>(0ull); bytes_written += writer.writeValueToArray<std::size_t>(0ull);
auto struct_prop = dynamic_cast<StructProperty*>(props.front().get()); auto struct_prop = dynamic_cast<StructProperty*>(props.front().get());
if(!struct_prop) { if(!struct_prop) {
@ -142,9 +142,9 @@ StructSerialiser::serialise(Containers::ArrayView<UnrealPropertyBase::ptr> props
bytes_written += writer.writeDataToArray(arrayView(struct_prop->structGuid)); bytes_written += writer.writeDataToArray(arrayView(struct_prop->structGuid));
bytes_written += writer.writeValueToArray<char>('\0'); bytes_written += writer.writeValueToArray<char>('\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) { for(auto& prop : props) {
struct_prop = dynamic_cast<StructProperty*>(prop.get()); struct_prop = dynamic_cast<StructProperty*>(prop.get());
if(!struct_prop) { if(!struct_prop) {
@ -160,7 +160,7 @@ StructSerialiser::serialise(Containers::ArrayView<UnrealPropertyBase::ptr> props
} }
} }
UnsignedLong vl_stop = writer.arrayPosition() - vl_start; std::size_t vl_stop = writer.arrayPosition() - vl_start;
writer.writeValueToArrayAt(vl_stop, vl_pos); writer.writeValueToArrayAt(vl_stop, vl_pos);
bytes_written += vl_stop; bytes_written += vl_stop;
@ -168,7 +168,7 @@ StructSerialiser::serialise(Containers::ArrayView<UnrealPropertyBase::ptr> props
} }
bool 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) PropertySerialiser& serialiser)
{ {
auto struct_prop = dynamic_cast<StructProperty*>(prop.get()); auto struct_prop = dynamic_cast<StructProperty*>(prop.get());
@ -182,8 +182,8 @@ StructSerialiser::serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_w
writer.writeValueToArray<char>('\0'); writer.writeValueToArray<char>('\0');
if(!serialiser.writeItem(prop, struct_prop->structType, bytes_written, writer)) { if(!serialiser.writeItem(prop, struct_prop->structType, bytes_written, writer)) {
UnsignedLong dummy_bytes_written = 0; std::size_t dummy_bytes_written = 0;
UnsignedLong vl_start = writer.arrayPosition(); std::size_t vl_start = writer.arrayPosition();
if(!writeStructValue(struct_prop, dummy_bytes_written, writer, serialiser)) { if(!writeStructValue(struct_prop, dummy_bytes_written, writer, serialiser)) {
LOG_ERROR("Couldn't write the struct value."); LOG_ERROR("Couldn't write the struct value.");
return false; return false;
@ -195,7 +195,7 @@ StructSerialiser::serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_w
} }
StructProperty::ptr 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) BinaryReader& reader, PropertySerialiser& serialiser)
{ {
auto st_prop = Containers::pointer<GenericStructProperty>(); auto st_prop = Containers::pointer<GenericStructProperty>();
@ -219,7 +219,7 @@ StructSerialiser::readStructValue(Containers::StringView name, Containers::Strin
} }
bool bool
StructSerialiser::writeStructValue(StructProperty* prop, UnsignedLong& bytes_written, BinaryWriter& writer, StructSerialiser::writeStructValue(StructProperty* prop, std::size_t& bytes_written, BinaryWriter& writer,
PropertySerialiser& serialiser) PropertySerialiser& serialiser)
{ {
auto struct_prop = dynamic_cast<GenericStructProperty*>(prop); auto struct_prop = dynamic_cast<GenericStructProperty*>(prop);

View file

@ -31,21 +31,21 @@ class StructSerialiser : public AbstractUnrealPropertySerialiser, public Abstrac
StringArrayView types() override; StringArrayView types() override;
PropertyArray deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length, PropertyArray deserialise(Containers::StringView name, Containers::StringView type, std::size_t value_length,
UnsignedInt count, BinaryReader& reader, PropertySerialiser& serialiser) override; std::uint32_t count, BinaryReader& reader, PropertySerialiser& serialiser) override;
UnrealPropertyBase::ptr deserialise(Containers::StringView name, Containers::StringView type, UnrealPropertyBase::ptr deserialise(Containers::StringView name, Containers::StringView type,
UnsignedLong value_length, BinaryReader& reader, std::size_t value_length, BinaryReader& reader,
PropertySerialiser& serialiser) override; 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; 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; PropertySerialiser& serialiser) override;
private: private:
StructProperty::ptr readStructValue(Containers::StringView name, Containers::StringView type, StructProperty::ptr readStructValue(Containers::StringView name, Containers::StringView type,
UnsignedLong value_length, BinaryReader& reader, std::size_t value_length, BinaryReader& reader,
PropertySerialiser& serialiser); PropertySerialiser& serialiser);
bool writeStructValue(StructProperty* prop, UnsignedLong& bytes_written, BinaryWriter& writer, bool writeStructValue(StructProperty* prop, std::size_t& bytes_written, BinaryWriter& writer,
PropertySerialiser& serialiser); PropertySerialiser& serialiser);
} ; } ;

View file

@ -23,12 +23,12 @@
UnrealPropertyBase::ptr UnrealPropertyBase::ptr
TextPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type, TextPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type,
UnsignedLong value_length, BinaryReader& reader, std::size_t value_length, BinaryReader& reader,
PropertySerialiser& serialiser) PropertySerialiser& serialiser)
{ {
auto prop = Containers::pointer<TextProperty>(); auto prop = Containers::pointer<TextProperty>();
Long start_position = reader.position(); auto start_position = reader.position();
char terminator; char terminator;
if(!reader.readChar(terminator) || terminator != '\0') { if(!reader.readChar(terminator) || terminator != '\0') {
@ -62,7 +62,7 @@ TextPropertySerialiser::deserialiseProperty(Containers::StringView name, Contain
arrayAppend(prop->data, std::move(str)); arrayAppend(prop->data, std::move(str));
interval = reader.position() - start_position; interval = reader.position() - start_position;
} while(UnsignedLong(interval) < value_length); } while(std::size_t(interval) < value_length);
prop->value = prop->data.back(); prop->value = prop->data.back();
@ -70,7 +70,7 @@ TextPropertySerialiser::deserialiseProperty(Containers::StringView name, Contain
} }
bool bool
TextPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, TextPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written,
BinaryWriter& writer, PropertySerialiser& serialiser) BinaryWriter& writer, PropertySerialiser& serialiser)
{ {
auto text_prop = dynamic_cast<TextProperty*>(prop.get()); auto text_prop = dynamic_cast<TextProperty*>(prop.get());

View file

@ -28,8 +28,8 @@ class TextPropertySerialiser : public UnrealPropertySerialiser<TextProperty> {
private: private:
UnrealPropertyBase::ptr deserialiseProperty(Containers::StringView name, Containers::StringView type, UnrealPropertyBase::ptr deserialiseProperty(Containers::StringView name, Containers::StringView type,
UnsignedLong value_length, BinaryReader& reader, std::size_t value_length, BinaryReader& reader,
PropertySerialiser& serialiser) override; 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; PropertySerialiser& serialiser) override;
}; };

View file

@ -50,13 +50,13 @@ class UnrealPropertySerialiser : public AbstractUnrealPropertySerialiser {
} }
UnrealPropertyBase::ptr deserialise(Containers::StringView name, Containers::StringView type, UnrealPropertyBase::ptr deserialise(Containers::StringView name, Containers::StringView type,
UnsignedLong value_length, BinaryReader& reader, std::size_t value_length, BinaryReader& reader,
PropertySerialiser& serialiser) override PropertySerialiser& serialiser) override
{ {
return deserialiseProperty(name, type, value_length, reader, serialiser); 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 PropertySerialiser& serialiser) override
{ {
return serialiseProperty(prop, bytes_written, writer, serialiser); return serialiseProperty(prop, bytes_written, writer, serialiser);
@ -64,9 +64,9 @@ class UnrealPropertySerialiser : public AbstractUnrealPropertySerialiser {
private: private:
virtual UnrealPropertyBase::ptr deserialiseProperty(Containers::StringView name, Containers::StringView type, 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; 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; PropertySerialiser& serialiser) = 0;
}; };

View file

@ -22,7 +22,7 @@
UnrealPropertyBase::ptr UnrealPropertyBase::ptr
Vector2DPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type, Vector2DPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type,
UnsignedLong value_length, BinaryReader& reader, std::size_t value_length, BinaryReader& reader,
PropertySerialiser& serialiser) PropertySerialiser& serialiser)
{ {
auto prop = Containers::pointer<Vector2DStructProperty>(); auto prop = Containers::pointer<Vector2DStructProperty>();
@ -36,7 +36,7 @@ Vector2DPropertySerialiser::deserialiseProperty(Containers::StringView name, Con
} }
bool bool
Vector2DPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, Vector2DPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written,
BinaryWriter& writer, PropertySerialiser& serialiser) BinaryWriter& writer, PropertySerialiser& serialiser)
{ {
auto vector = dynamic_cast<Vector2DStructProperty*>(prop.get()); auto vector = dynamic_cast<Vector2DStructProperty*>(prop.get());
@ -45,7 +45,7 @@ Vector2DPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, Uns
return false; return false;
} }
bytes_written += writer.writeValueToArray<Float>(vector->x) + writer.writeValueToArray<Float>(vector->y); bytes_written += writer.writeValueToArray<float>(vector->x) + writer.writeValueToArray<float>(vector->y);
return true; return true;
} }

View file

@ -28,8 +28,8 @@ class Vector2DPropertySerialiser : public UnrealPropertySerialiser<Vector2DStruc
private: private:
UnrealPropertyBase::ptr deserialiseProperty(Containers::StringView name, Containers::StringView type, UnrealPropertyBase::ptr deserialiseProperty(Containers::StringView name, Containers::StringView type,
UnsignedLong value_length, BinaryReader& reader, std::size_t value_length, BinaryReader& reader,
PropertySerialiser& serialiser) override; 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; PropertySerialiser& serialiser) override;
}; };

View file

@ -22,7 +22,7 @@
UnrealPropertyBase::ptr UnrealPropertyBase::ptr
VectorPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type, VectorPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type,
UnsignedLong value_length, BinaryReader& reader, std::size_t value_length, BinaryReader& reader,
PropertySerialiser& serialiser) PropertySerialiser& serialiser)
{ {
auto prop = Containers::pointer<VectorStructProperty>(); auto prop = Containers::pointer<VectorStructProperty>();
@ -36,7 +36,7 @@ VectorPropertySerialiser::deserialiseProperty(Containers::StringView name, Conta
} }
bool bool
VectorPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, VectorPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, std::size_t& bytes_written,
BinaryWriter& writer, PropertySerialiser& serialiser) BinaryWriter& writer, PropertySerialiser& serialiser)
{ {
auto vector = dynamic_cast<VectorStructProperty*>(prop.get()); auto vector = dynamic_cast<VectorStructProperty*>(prop.get());
@ -45,8 +45,8 @@ VectorPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, Unsig
return false; return false;
} }
bytes_written += writer.writeValueToArray<Float>(vector->x) + writer.writeValueToArray<Float>(vector->y) + bytes_written += writer.writeValueToArray<float>(vector->x) + writer.writeValueToArray<float>(vector->y) +
writer.writeValueToArray<Float>(vector->z); writer.writeValueToArray<float>(vector->z);
return true; return true;
} }

View file

@ -28,8 +28,8 @@ class VectorPropertySerialiser : public UnrealPropertySerialiser<VectorStructPro
private: private:
UnrealPropertyBase::ptr deserialiseProperty(Containers::StringView name, Containers::StringView type, UnrealPropertyBase::ptr deserialiseProperty(Containers::StringView name, Containers::StringView type,
UnsignedLong value_length, BinaryReader& reader, std::size_t value_length, BinaryReader& reader,
PropertySerialiser& serialiser) override; 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; PropertySerialiser& serialiser) override;
}; };

View file

@ -29,5 +29,5 @@ struct ColourStructProperty : public StructProperty {
using namespace Containers::Literals; using namespace Containers::Literals;
structType = "LinearColor"_s; structType = "LinearColor"_s;
} }
Float r = 0.0f, g = 0.0f, b = 0.0f, a = 0.0f; float r = 0.0f, g = 0.0f, b = 0.0f, a = 0.0f;
}; };

View file

@ -19,12 +19,9 @@
#include <Corrade/Containers/Pointer.h> #include <Corrade/Containers/Pointer.h>
#include <Corrade/Containers/StringView.h> #include <Corrade/Containers/StringView.h>
#include <Magnum/Types.h>
#include "StructProperty.h" #include "StructProperty.h"
using namespace Corrade; using namespace Corrade;
using namespace Magnum;
struct DateTimeStructProperty : public StructProperty { struct DateTimeStructProperty : public StructProperty {
using ptr = Containers::Pointer<DateTimeStructProperty>; using ptr = Containers::Pointer<DateTimeStructProperty>;
@ -34,5 +31,5 @@ struct DateTimeStructProperty : public StructProperty {
structType = "DateTime"_s; structType = "DateTime"_s;
} }
UnsignedLong timestamp = 0; std::int64_t timestamp = 0;
}; };

View file

@ -19,14 +19,11 @@
#include <Corrade/Containers/Pointer.h> #include <Corrade/Containers/Pointer.h>
#include <Corrade/Containers/StringView.h> #include <Corrade/Containers/StringView.h>
#include <Magnum/Types.h>
#include "UnrealProperty.h" #include "UnrealProperty.h"
using namespace Corrade; using namespace Corrade;
using namespace Magnum;
struct FloatProperty : public UnrealProperty<Float> { struct FloatProperty : public UnrealProperty<float> {
using ptr = Containers::Pointer<FloatProperty>; using ptr = Containers::Pointer<FloatProperty>;
FloatProperty() { FloatProperty() {

View file

@ -23,7 +23,7 @@
using namespace Corrade; using namespace Corrade;
struct IntProperty : public UnrealProperty<Int> { struct IntProperty : public UnrealProperty<std::int32_t> {
using ptr = Containers::Pointer<IntProperty>; using ptr = Containers::Pointer<IntProperty>;
IntProperty() { IntProperty() {

View file

@ -19,12 +19,9 @@
#include <Corrade/Containers/Pointer.h> #include <Corrade/Containers/Pointer.h>
#include <Corrade/Containers/StringView.h> #include <Corrade/Containers/StringView.h>
#include <Magnum/Types.h>
#include "StructProperty.h" #include "StructProperty.h"
using namespace Corrade; using namespace Corrade;
using namespace Magnum;
struct ResourceItemValue : public StructProperty { struct ResourceItemValue : public StructProperty {
using ptr = Containers::Pointer<ResourceItemValue>; using ptr = Containers::Pointer<ResourceItemValue>;
@ -32,8 +29,12 @@ struct ResourceItemValue : public StructProperty {
ResourceItemValue() { ResourceItemValue() {
using namespace Containers::Literals; using namespace Containers::Literals;
structType = "sttResourceItemValue"_s; 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;
}; };

View file

@ -19,12 +19,9 @@
#include <Corrade/Containers/Pointer.h> #include <Corrade/Containers/Pointer.h>
#include <Corrade/Containers/StringView.h> #include <Corrade/Containers/StringView.h>
#include <Magnum/Types.h>
#include "StructProperty.h" #include "StructProperty.h"
using namespace Corrade; using namespace Corrade;
using namespace Magnum;
struct RotatorStructProperty : public StructProperty { struct RotatorStructProperty : public StructProperty {
using ptr = Containers::Pointer<RotatorStructProperty>; using ptr = Containers::Pointer<RotatorStructProperty>;
@ -34,5 +31,5 @@ struct RotatorStructProperty : public StructProperty {
structType = "Rotator"_s; structType = "Rotator"_s;
} }
Float x = 0.0f, y = 0.0f, z = 0.0f; float x = 0.0f, y = 0.0f, z = 0.0f;
}; };

View file

@ -16,14 +16,13 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <cstdint>
#include <Corrade/Containers/Optional.h> #include <Corrade/Containers/Optional.h>
#include <Corrade/Containers/Pointer.h> #include <Corrade/Containers/Pointer.h>
#include <Corrade/Containers/String.h> #include <Corrade/Containers/String.h>
#include <Magnum/Types.h>
using namespace Corrade; using namespace Corrade;
using namespace Magnum;
struct UnrealPropertyBase { struct UnrealPropertyBase {
using ptr = Containers::Pointer<UnrealPropertyBase>; using ptr = Containers::Pointer<UnrealPropertyBase>;
@ -32,5 +31,5 @@ struct UnrealPropertyBase {
Containers::Optional<Containers::String> name = Containers::NullOpt; Containers::Optional<Containers::String> name = Containers::NullOpt;
Containers::String propertyType; Containers::String propertyType;
UnsignedLong valueLength = 0; std::size_t valueLength = 0;
}; };

View file

@ -19,12 +19,9 @@
#include <Corrade/Containers/Pointer.h> #include <Corrade/Containers/Pointer.h>
#include <Corrade/Containers/StringView.h> #include <Corrade/Containers/StringView.h>
#include <Magnum/Types.h>
#include "StructProperty.h" #include "StructProperty.h"
using namespace Corrade; using namespace Corrade;
using namespace Magnum;
struct Vector2DStructProperty : public StructProperty { struct Vector2DStructProperty : public StructProperty {
using ptr = Containers::Pointer<Vector2DStructProperty>; using ptr = Containers::Pointer<Vector2DStructProperty>;
@ -34,5 +31,5 @@ struct Vector2DStructProperty : public StructProperty {
structType = "Vector2D"_s; structType = "Vector2D"_s;
} }
Float x = 0.0f, y = 0.0f; float x = 0.0f, y = 0.0f;
}; };

View file

@ -19,12 +19,9 @@
#include <Corrade/Containers/Pointer.h> #include <Corrade/Containers/Pointer.h>
#include <Corrade/Containers/StringView.h> #include <Corrade/Containers/StringView.h>
#include <Magnum/Types.h>
#include "StructProperty.h" #include "StructProperty.h"
using namespace Corrade; using namespace Corrade;
using namespace Magnum;
struct VectorStructProperty : public StructProperty { struct VectorStructProperty : public StructProperty {
using ptr = Containers::Pointer<VectorStructProperty>; using ptr = Containers::Pointer<VectorStructProperty>;
@ -34,5 +31,5 @@ struct VectorStructProperty : public StructProperty {
structType = "Vector"_s; structType = "Vector"_s;
} }
Float x = 0.0f, y = 0.0f, z = 0.0f; float x = 0.0f, y = 0.0f, z = 0.0f;
}; };

View file

@ -93,12 +93,12 @@ UESaveFile::saveToFile() {
} }
if(!writer.writeArray(arrayView(_magicBytes)) || if(!writer.writeArray(arrayView(_magicBytes)) ||
!writer.writeUnsignedInt(_saveVersion) || !writer.writeUint32(_saveVersion) ||
!writer.writeUnsignedInt(_packageVersion) || !writer.writeUint32(_packageVersion) ||
!writer.writeUnsignedShort(_engineVersion.major) || !writer.writeUint16(_engineVersion.major) ||
!writer.writeUnsignedShort(_engineVersion.minor) || !writer.writeUint16(_engineVersion.minor) ||
!writer.writeUnsignedShort(_engineVersion.patch) || !writer.writeUint16(_engineVersion.patch) ||
!writer.writeUnsignedInt(_engineVersion.build) || !writer.writeUint32(_engineVersion.build) ||
!writer.writeUEString(_engineVersion.buildId)) !writer.writeUEString(_engineVersion.buildId))
{ {
_lastError = "Couldn't write the header."_s; _lastError = "Couldn't write the header."_s;
@ -106,17 +106,17 @@ UESaveFile::saveToFile() {
return false; return false;
} }
if(!writer.writeUnsignedInt(_customFormatVersion) || if(!writer.writeUint32(_customFormatVersion) ||
!writer.writeUnsignedInt(_customFormatData.size())) !writer.writeUint32(_customFormatData.size()))
{ {
_lastError = "Couldn't write the custom format data."_s; _lastError = "Couldn't write the custom format data."_s;
LOG_ERROR(_lastError); LOG_ERROR(_lastError);
return false; 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}) || 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; _lastError = "Couldn't write the custom format data."_s;
LOG_ERROR(_lastError); LOG_ERROR(_lastError);
@ -131,7 +131,7 @@ UESaveFile::saveToFile() {
} }
for(auto& prop : _properties) { for(auto& prop : _properties) {
UnsignedLong bytes_written = 0; std::size_t bytes_written = 0;
if(!_propSerialiser->write(prop, bytes_written, writer)) { if(!_propSerialiser->write(prop, bytes_written, writer)) {
_lastError = "Couldn't write the property "_s + *prop->name + " to the array."_s; _lastError = "Couldn't write the property "_s + *prop->name + " to the array."_s;
LOG_ERROR(_lastError); LOG_ERROR(_lastError);
@ -145,7 +145,7 @@ UESaveFile::saveToFile() {
} }
} }
writer.writeUnsignedInt(0); writer.writeUint32(0u);
writer.closeFile(); writer.closeFile();
@ -197,12 +197,12 @@ UESaveFile::loadData() {
return; return;
} }
if(!reader.readUnsignedInt(_saveVersion) || if(!reader.readUint32(_saveVersion) ||
!reader.readUnsignedInt(_packageVersion) || !reader.readUint32(_packageVersion) ||
!reader.readUnsignedShort(_engineVersion.major) || !reader.readUint16(_engineVersion.major) ||
!reader.readUnsignedShort(_engineVersion.minor) || !reader.readUint16(_engineVersion.minor) ||
!reader.readUnsignedShort(_engineVersion.patch) || !reader.readUint16(_engineVersion.patch) ||
!reader.readUnsignedInt(_engineVersion.build) || !reader.readUint32(_engineVersion.build) ||
!reader.readUEString(_engineVersion.buildId)) !reader.readUEString(_engineVersion.buildId))
{ {
_lastError = "Couldn't read version data."; _lastError = "Couldn't read version data.";
@ -210,15 +210,15 @@ UESaveFile::loadData() {
return; return;
} }
if(!reader.readUnsignedInt(_customFormatVersion)) { if(!reader.readUint32(_customFormatVersion)) {
_lastError = "Couldn't read the custom format version."; _lastError = "Couldn't read the custom format version.";
LOG_ERROR(_lastError); LOG_ERROR(_lastError);
return; 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."; _lastError = "Couldn't read the custom format data size.";
LOG_ERROR(_lastError); LOG_ERROR(_lastError);
return; return;
@ -226,11 +226,11 @@ UESaveFile::loadData() {
_customFormatData = Containers::Array<CustomFormatDataEntry>{custom_format_data_size}; _customFormatData = Containers::Array<CustomFormatDataEntry>{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; CustomFormatDataEntry entry;
if(!reader.readStaticArray(entry.id) || if(!reader.readStaticArray(entry.id) ||
!reader.readInt(entry.value)) !reader.readInt32(entry.value))
{ {
_lastError = "Couldn't read the custom format data"; _lastError = "Couldn't read the custom format data";
LOG_ERROR(_lastError); LOG_ERROR(_lastError);

View file

@ -23,14 +23,11 @@
#include <Corrade/Containers/String.h> #include <Corrade/Containers/String.h>
#include <Corrade/Containers/StringView.h> #include <Corrade/Containers/StringView.h>
#include <Magnum/Magnum.h>
#include "Types/UnrealPropertyBase.h" #include "Types/UnrealPropertyBase.h"
#include "PropertySerialiser.h" #include "PropertySerialiser.h"
using namespace Corrade; using namespace Corrade;
using namespace Magnum;
class UESaveFile { class UESaveFile {
public: public:
@ -72,20 +69,20 @@ class UESaveFile {
Containers::StaticArray<4, char> _magicBytes{'G', 'V', 'A', 'S'}; Containers::StaticArray<4, char> _magicBytes{'G', 'V', 'A', 'S'};
UnsignedInt _saveVersion = 0; std::uint32_t _saveVersion = 0;
UnsignedInt _packageVersion = 0; std::uint32_t _packageVersion = 0;
struct { struct {
UnsignedShort major = 0; std::uint16_t major = 0;
UnsignedShort minor = 0; std::uint16_t minor = 0;
UnsignedShort patch = 0; std::uint16_t patch = 0;
UnsignedInt build = 0; std::uint32_t build = 0;
Containers::String buildId; Containers::String buildId;
} _engineVersion; } _engineVersion;
UnsignedInt _customFormatVersion = 0; std::uint32_t _customFormatVersion = 0;
struct CustomFormatDataEntry { struct CustomFormatDataEntry {
Containers::StaticArray<16, char> id; Containers::StaticArray<16, char> id;
Int value = 0; std::int32_t value = 0;
}; };
Containers::Array<CustomFormatDataEntry> _customFormatData; Containers::Array<CustomFormatDataEntry> _customFormatData;

View file

@ -16,35 +16,22 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <cstdint>
#include <Corrade/Containers/ArrayView.h> #include <Corrade/Containers/ArrayView.h>
#include <Corrade/Containers/StaticArray.h> #include <Corrade/Containers/StaticArray.h>
#include <Magnum/Types.h>
using namespace Corrade; using namespace Corrade;
using namespace Magnum;
struct Crc32 { namespace Crc32 {
static const Containers::StaticArray<256, UnsignedInt> table;
static auto update(UnsignedInt initial, Containers::ArrayView<const void> data) -> UnsignedInt { std::uint32_t update(std::uint32_t initial, Containers::ArrayView<const void> data) {
UnsignedInt c = initial ^ 0xFFFFFFFF; static const auto table = []{
auto u = Containers::arrayCast<const UnsignedByte>(data); std::uint32_t polynomial = 0xEDB88320u;
Containers::StaticArray<256, std::uint32_t> temp{ValueInit};
for(std::size_t i = 0; i < data.size(); ++i) { for(std::uint32_t i = 0; i < 256; i++) {
c = table[(c ^ u[i]) & 0xFF] ^ (c >> 8); std::uint32_t c = i;
}
return c ^ 0xFFFFFFFF;
}
};
const Containers::StaticArray<256, UnsignedInt> Crc32::table = []{
UnsignedInt polynomial = 0xEDB88320u;
Containers::StaticArray<256, UnsignedInt> temp{ValueInit};
for(UnsignedInt i = 0; i < 256; i++) {
UnsignedInt c = i;
for(std::size_t j = 0; j < 8; j++) { for(std::size_t j = 0; j < 8; j++) {
if(c & 1) { if(c & 1) {
@ -60,3 +47,16 @@ const Containers::StaticArray<256, UnsignedInt> Crc32::table = []{
return temp; return temp;
}(); }();
std::uint32_t c = initial ^ 0xFFFFFFFF;
auto u = Containers::arrayCast<const std::uint8_t>(data);
for(std::size_t i = 0; i < data.size(); ++i) {
c = table[(c ^ u[i]) & 0xFF] ^ (c >> 8);
}
return c ^ 0xFFFFFFFF;
}
} // Crc32

View file

@ -81,7 +81,7 @@ int main(int argc, char** argv) {
} }
SaveTool app({argc, argv}); SaveTool app({argc, argv});
Int result = app.exec(); int result = app.exec();
ReleaseMutex(mutex_handle); ReleaseMutex(mutex_handle);