Compare commits
No commits in common. "76e36791d734ed9d822017138a3207ff56d37e7b" and "0826d4aedeadd2dfb5c9307de5a2b6599cb6bb15" have entirely different histories.
76e36791d7
...
0826d4aede
14 changed files with 1044 additions and 453 deletions
|
@ -52,8 +52,6 @@ add_library(UESaveFile STATIC EXCLUDE_FROM_ALL
|
|||
UESaveFile/Serialisers/IntPropertySerialiser.cpp
|
||||
UESaveFile/Serialisers/MapPropertySerialiser.h
|
||||
UESaveFile/Serialisers/MapPropertySerialiser.cpp
|
||||
UESaveFile/Serialisers/ResourcePropertySerialiser.h
|
||||
UESaveFile/Serialisers/ResourcePropertySerialiser.cpp
|
||||
UESaveFile/Serialisers/RotatorPropertySerialiser.h
|
||||
UESaveFile/Serialisers/RotatorPropertySerialiser.cpp
|
||||
UESaveFile/Serialisers/StringPropertySerialiser.h
|
||||
|
@ -86,7 +84,6 @@ add_library(UESaveFile STATIC EXCLUDE_FROM_ALL
|
|||
UESaveFile/Types/SetProperty.h
|
||||
UESaveFile/Types/StringProperty.h
|
||||
UESaveFile/Types/StructProperty.h
|
||||
UESaveFile/Types/ResourceItemValue.h
|
||||
UESaveFile/Types/TextProperty.h
|
||||
UESaveFile/Types/UnrealProperty.h
|
||||
UESaveFile/Types/UnrealPropertyBase.h
|
||||
|
|
94
src/Profile/Locators.h
Normal file
94
src/Profile/Locators.h
Normal file
|
@ -0,0 +1,94 @@
|
|||
#pragma once
|
||||
|
||||
// MassBuilderSaveTool
|
||||
// Copyright (C) 2021 Guillaume Jacquemin
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
constexpr char company_name_locator[] = "CompanyName\0\f\0\0\0StrProperty";
|
||||
constexpr char active_slot_locator[] = "ActiveFrameSlot\0\f\0\0\0IntProperty";
|
||||
constexpr char credits_locator[] = "Credit\0\f\0\0\0IntProperty";
|
||||
constexpr char story_progress_locator[] = "StoryProgress\0\f\0\0\0IntProperty";
|
||||
constexpr char last_mission_id_locator[] = "LastMissionID\0\f\0\0\0IntProperty";
|
||||
|
||||
constexpr char verse_steel_locator[] =
|
||||
"ID_4_AAE08F17428E229EC7A2209F51081A21\0\f\0\0\0IntProperty\0\x04\0\0\0\0\0\0\0\0\x00\x35\f\0,\0\0\0"
|
||||
"Quantity_3_560F09B5485C365D3041888910019CE3\0\f\0\0\0IntProperty";
|
||||
constexpr char undinium_locator[] =
|
||||
"ID_4_AAE08F17428E229EC7A2209F51081A21\0\f\0\0\0IntProperty\0\x04\0\0\0\0\0\0\0\0\x01\x35\f\0,\0\0\0"
|
||||
"Quantity_3_560F09B5485C365D3041888910019CE3\0\f\0\0\0IntProperty";
|
||||
constexpr char necrium_alloy_locator[] =
|
||||
"ID_4_AAE08F17428E229EC7A2209F51081A21\0\f\0\0\0IntProperty\0\x04\0\0\0\0\0\0\0\0\x02\x35\f\0,\0\0\0"
|
||||
"Quantity_3_560F09B5485C365D3041888910019CE3\0\f\0\0\0IntProperty";
|
||||
constexpr char lunarite_locator[] =
|
||||
"ID_4_AAE08F17428E229EC7A2209F51081A21\0\f\0\0\0IntProperty\0\x04\0\0\0\0\0\0\0\0\x03\x35\f\0,\0\0\0"
|
||||
"Quantity_3_560F09B5485C365D3041888910019CE3\0\f\0\0\0IntProperty";
|
||||
constexpr char asterite_locator[] =
|
||||
"ID_4_AAE08F17428E229EC7A2209F51081A21\0\f\0\0\0IntProperty\0\x04\0\0\0\0\0\0\0\0\x04\x35\f\0,\0\0\0"
|
||||
"Quantity_3_560F09B5485C365D3041888910019CE3\0\f\0\0\0IntProperty";
|
||||
|
||||
constexpr char ednil_locator[] =
|
||||
"ID_4_AAE08F17428E229EC7A2209F51081A21\0\f\0\0\0IntProperty\0\x04\0\0\0\0\0\0\0\0\x0a\x35\f\0,\0\0\0"
|
||||
"Quantity_3_560F09B5485C365D3041888910019CE3\0\f\0\0\0IntProperty";
|
||||
constexpr char nuflalt_locator[] =
|
||||
"ID_4_AAE08F17428E229EC7A2209F51081A21\0\f\0\0\0IntProperty\0\x04\0\0\0\0\0\0\0\0\x0b\x35\f\0,\0\0\0"
|
||||
"Quantity_3_560F09B5485C365D3041888910019CE3\0\f\0\0\0IntProperty";
|
||||
constexpr char aurelene_locator[] =
|
||||
"ID_4_AAE08F17428E229EC7A2209F51081A21\0\f\0\0\0IntProperty\0\x04\0\0\0\0\0\0\0\0\f\x35\f\0,\0\0\0"
|
||||
"Quantity_3_560F09B5485C365D3041888910019CE3\0\f\0\0\0IntProperty";
|
||||
constexpr char soldus_locator[] =
|
||||
"ID_4_AAE08F17428E229EC7A2209F51081A21\0\f\0\0\0IntProperty\0\x04\0\0\0\0\0\0\0\0\x0d\x35\f\0,\0\0\0"
|
||||
"Quantity_3_560F09B5485C365D3041888910019CE3\0\f\0\0\0IntProperty";
|
||||
constexpr char synthesized_n_locator[] =
|
||||
"ID_4_AAE08F17428E229EC7A2209F51081A21\0\f\0\0\0IntProperty\0\x04\0\0\0\0\0\0\0\0\x0e\x35\f\0,\0\0\0"
|
||||
"Quantity_3_560F09B5485C365D3041888910019CE3\0\f\0\0\0IntProperty";
|
||||
|
||||
constexpr char alcarbonite_locator[] =
|
||||
"ID_4_AAE08F17428E229EC7A2209F51081A21\0\f\0\0\0IntProperty\0\x04\0\0\0\0\0\0\0\0\x14\x35\f\0,\0\0\0"
|
||||
"Quantity_3_560F09B5485C365D3041888910019CE3\0\f\0\0\0IntProperty";
|
||||
constexpr char keriphene_locator[] =
|
||||
"ID_4_AAE08F17428E229EC7A2209F51081A21\0\f\0\0\0IntProperty\0\x04\0\0\0\0\0\0\0\0\x15\x35\f\0,\0\0\0"
|
||||
"Quantity_3_560F09B5485C365D3041888910019CE3\0\f\0\0\0IntProperty";
|
||||
constexpr char nitinol_cm_locator[] =
|
||||
"ID_4_AAE08F17428E229EC7A2209F51081A21\0\f\0\0\0IntProperty\0\x04\0\0\0\0\0\0\0\0\x16\x35\f\0,\0\0\0"
|
||||
"Quantity_3_560F09B5485C365D3041888910019CE3\0\f\0\0\0IntProperty";
|
||||
constexpr char quarkium_locator[] =
|
||||
"ID_4_AAE08F17428E229EC7A2209F51081A21\0\f\0\0\0IntProperty\0\x04\0\0\0\0\0\0\0\0\x17\x35\f\0,\0\0\0"
|
||||
"Quantity_3_560F09B5485C365D3041888910019CE3\0\f\0\0\0IntProperty";
|
||||
constexpr char alterene_locator[] =
|
||||
"ID_4_AAE08F17428E229EC7A2209F51081A21\0\f\0\0\0IntProperty\0\x04\0\0\0\0\0\0\0\0\x18\x35\f\0,\0\0\0"
|
||||
"Quantity_3_560F09B5485C365D3041888910019CE3\0\f\0\0\0IntProperty";
|
||||
|
||||
constexpr char mixed_composition_locator[] =
|
||||
"ID_4_AAE08F17428E229EC7A2209F51081A21\0\f\0\0\0IntProperty\0\x04\0\0\0\0\0\0\0\0\xa0\xbb\x0d\0,\0\0\0"
|
||||
"Quantity_3_560F09B5485C365D3041888910019CE3\0\f\0\0\0IntProperty";
|
||||
constexpr char void_residue_locator[] =
|
||||
"ID_4_AAE08F17428E229EC7A2209F51081A21\0\f\0\0\0IntProperty\0\x04\0\0\0\0\0\0\0\0\xa1\xbb\x0d\0,\0\0\0"
|
||||
"Quantity_3_560F09B5485C365D3041888910019CE3\0\f\0\0\0IntProperty";
|
||||
constexpr char muscular_construction_locator[] =
|
||||
"ID_4_AAE08F17428E229EC7A2209F51081A21\0\f\0\0\0IntProperty\0\x04\0\0\0\0\0\0\0\0\xa2\xbb\x0d\0,\0\0\0"
|
||||
"Quantity_3_560F09B5485C365D3041888910019CE3\0\f\0\0\0IntProperty";
|
||||
constexpr char mineral_exoskeletology_locator[] =
|
||||
"ID_4_AAE08F17428E229EC7A2209F51081A21\0\f\0\0\0IntProperty\0\x04\0\0\0\0\0\0\0\0\xa3\xbb\x0d\0,\0\0\0"
|
||||
"Quantity_3_560F09B5485C365D3041888910019CE3\0\f\0\0\0IntProperty";
|
||||
constexpr char carbonized_skin_locator[] =
|
||||
"ID_4_AAE08F17428E229EC7A2209F51081A21\0\f\0\0\0IntProperty\0\x04\0\0\0\0\0\0\0\0\xa4\xbb\x0d\0,\0\0\0"
|
||||
"Quantity_3_560F09B5485C365D3041888910019CE3\0\f\0\0\0IntProperty";
|
||||
|
||||
constexpr char engine_inventory_locator[] = "InventoryEngine\0\x0e\0\0\0ArrayProperty";
|
||||
constexpr char gear_inventory_locator[] = "InventoryGear\0\x0e\0\0\0ArrayProperty";
|
||||
constexpr char os_inventory_locator[] = "InventoryOS\0\x0e\0\0\0ArrayProperty";
|
||||
constexpr char module_inventory_locator[] = "InventoryModule\0\x0e\0\0\0ArrayProperty";
|
||||
constexpr char arch_inventory_locator[] = "InventoryArchitect\0\x0e\0\0\0ArrayProperty";
|
||||
constexpr char tech_inventory_locator[] = "InventoryTech\0\x0e\0\0\0ArrayProperty";
|
File diff suppressed because it is too large
Load diff
|
@ -20,8 +20,6 @@
|
|||
|
||||
#include <Magnum/Magnum.h>
|
||||
|
||||
#include "../UESaveFile/UESaveFile.h"
|
||||
|
||||
using namespace Magnum;
|
||||
|
||||
enum class ProfileType : UnsignedByte {
|
||||
|
@ -45,92 +43,144 @@ class Profile {
|
|||
|
||||
void refreshValues();
|
||||
|
||||
auto companyName() -> std::string const&;
|
||||
auto companyName() const -> std::string const&;
|
||||
auto getCompanyName() -> std::string const&;
|
||||
auto renameCompany(const std::string& new_name) -> bool;
|
||||
|
||||
auto activeFrameSlot() -> Int;
|
||||
auto activeFrameSlot() const -> Int;
|
||||
auto getActiveFrameSlot() -> Int;
|
||||
|
||||
auto credits() -> Int;
|
||||
auto credits() const -> Int;
|
||||
auto getCredits() -> Int;
|
||||
auto setCredits(Int credits) -> bool;
|
||||
|
||||
auto storyProgress() -> Int;
|
||||
auto storyProgress() const -> Int;
|
||||
auto getStoryProgress() -> Int;
|
||||
auto setStoryProgress(Int progress) -> bool;
|
||||
|
||||
auto lastMissionId() -> Int;
|
||||
auto lastMissionId() const -> Int;
|
||||
auto getLastMissionId() -> Int;
|
||||
|
||||
auto verseSteel() -> Int;
|
||||
auto verseSteel() const -> Int;
|
||||
auto getVerseSteel() -> Int;
|
||||
auto setVerseSteel(Int amount) -> bool;
|
||||
|
||||
auto undinium() -> Int;
|
||||
auto undinium() const -> Int;
|
||||
auto getUndinium() -> Int;
|
||||
auto setUndinium(Int amount) -> bool;
|
||||
|
||||
auto necriumAlloy() -> Int;
|
||||
auto necriumAlloy() const -> Int;
|
||||
auto getNecriumAlloy() -> Int;
|
||||
auto setNecriumAlloy(Int amount) -> bool;
|
||||
|
||||
auto lunarite() -> Int;
|
||||
auto lunarite() const -> Int;
|
||||
auto getLunarite() -> Int;
|
||||
auto setLunarite(Int amount) -> bool;
|
||||
|
||||
auto asterite() -> Int;
|
||||
auto asterite() const -> Int;
|
||||
auto getAsterite() -> Int;
|
||||
auto setAsterite(Int amount) -> bool;
|
||||
|
||||
auto ednil() -> Int;
|
||||
auto ednil() const -> Int;
|
||||
auto getEdnil() -> Int;
|
||||
auto setEdnil(Int amount) -> bool;
|
||||
|
||||
auto nuflalt() -> Int;
|
||||
auto nuflalt() const -> Int;
|
||||
auto getNuflalt() -> Int;
|
||||
auto setNuflalt(Int amount) -> bool;
|
||||
|
||||
auto aurelene() -> Int;
|
||||
auto aurelene() const -> Int;
|
||||
auto getAurelene() -> Int;
|
||||
auto setAurelene(Int amount) -> bool;
|
||||
|
||||
auto soldus() -> Int;
|
||||
auto soldus() const -> Int;
|
||||
auto getSoldus() -> Int;
|
||||
auto setSoldus(Int amount) -> bool;
|
||||
|
||||
auto synthesizedN() -> Int;
|
||||
auto synthesizedN() const -> Int;
|
||||
auto getSynthesizedN() -> Int;
|
||||
auto setSynthesizedN(Int amount) -> bool;
|
||||
|
||||
auto alcarbonite() -> Int;
|
||||
auto alcarbonite() const -> Int;
|
||||
auto getAlcarbonite() -> Int;
|
||||
auto setAlcarbonite(Int amount) -> bool;
|
||||
|
||||
auto keriphene() -> Int;
|
||||
auto keriphene() const -> Int;
|
||||
auto getKeriphene() -> Int;
|
||||
auto setKeriphene(Int amount) -> bool;
|
||||
|
||||
auto nitinolCM() -> Int;
|
||||
auto nitinolCM() const -> Int;
|
||||
auto getNitinolCM() -> Int;
|
||||
auto setNitinolCM(Int amount) -> bool;
|
||||
|
||||
auto quarkium() -> Int;
|
||||
auto quarkium() const -> Int;
|
||||
auto getQuarkium() -> Int;
|
||||
auto setQuarkium(Int amount) -> bool;
|
||||
|
||||
auto alterene() -> Int;
|
||||
auto alterene() const -> Int;
|
||||
auto getAlterene() -> Int;
|
||||
auto setAlterene(Int amount) -> bool;
|
||||
|
||||
auto mixedComposition() -> Int;
|
||||
auto mixedComposition() const -> Int;
|
||||
auto getMixedComposition() -> Int;
|
||||
auto setMixedComposition(Int amount) -> bool;
|
||||
|
||||
auto voidResidue() -> Int;
|
||||
auto voidResidue() const -> Int;
|
||||
auto getVoidResidue() -> Int;
|
||||
auto setVoidResidue(Int amount) -> bool;
|
||||
|
||||
auto muscularConstruction() -> Int;
|
||||
auto muscularConstruction() const -> Int;
|
||||
auto getMuscularConstruction() -> Int;
|
||||
auto setMuscularConstruction(Int amount) -> bool;
|
||||
|
||||
auto mineralExoskeletology() -> Int;
|
||||
auto mineralExoskeletology() const -> Int;
|
||||
auto getMineralExoskeletology() -> Int;
|
||||
auto setMineralExoskeletology(Int amount) -> bool;
|
||||
|
||||
auto carbonizedSkin() -> Int;
|
||||
auto carbonizedSkin() const -> Int;
|
||||
auto getCarbonizedSkin() -> Int;
|
||||
auto setCarbonizedSkin(Int amount) -> bool;
|
||||
|
||||
private:
|
||||
auto resource(const char* container, Int id) -> Int;
|
||||
auto setResource(const char* container, Int id, Int amount) -> bool;
|
||||
|
||||
std::string _profileDirectory;
|
||||
std::string _filename;
|
||||
|
||||
ProfileType _type;
|
||||
|
||||
UESaveFile _profile;
|
||||
|
||||
std::string _steamId;
|
||||
|
||||
bool _valid = false;
|
||||
std::string _lastError;
|
||||
|
||||
std::string _companyName;
|
||||
|
||||
Int _activeFrameSlot = 0;
|
||||
|
||||
Int _credits;
|
||||
|
||||
Int _storyProgress;
|
||||
|
||||
Int _lastMissionId;
|
||||
|
||||
Int _verseSteel;
|
||||
Int _undinium;
|
||||
Int _necriumAlloy;
|
||||
Int _lunarite;
|
||||
Int _asterite;
|
||||
Int _ednil;
|
||||
Int _nuflalt;
|
||||
Int _aurelene;
|
||||
Int _soldus;
|
||||
Int _synthesizedN;
|
||||
Int _alcarbonite;
|
||||
Int _keriphene;
|
||||
Int _nitinolCM;
|
||||
Int _quarkium;
|
||||
Int _alterene;
|
||||
|
||||
Int _mixedComposition;
|
||||
Int _voidResidue;
|
||||
Int _muscularConstruction;
|
||||
Int _mineralExoskeletology;
|
||||
Int _carbonizedSkin;
|
||||
};
|
||||
|
|
|
@ -31,6 +31,8 @@
|
|||
|
||||
#include "ProfileManager.h"
|
||||
|
||||
using namespace Corrade;
|
||||
|
||||
ProfileManager::ProfileManager(const std::string& save_dir, const std::string& backup_dir):
|
||||
_saveDirectory{save_dir},
|
||||
_backupsDirectory{backup_dir}
|
||||
|
@ -46,12 +48,12 @@ auto ProfileManager::lastError() -> std::string const& {
|
|||
return _lastError;
|
||||
}
|
||||
|
||||
auto ProfileManager::profiles() -> Containers::ArrayView<Profile> {
|
||||
auto ProfileManager::profiles() -> std::vector<Profile> const& {
|
||||
return _profiles;
|
||||
}
|
||||
|
||||
auto ProfileManager::refreshProfiles() -> bool {
|
||||
_profiles = Containers::Array<Profile>{};
|
||||
_profiles.clear();
|
||||
|
||||
using Utility::Directory::Flag;
|
||||
std::vector<std::string> files = Utility::Directory::list(_saveDirectory, Flag::SkipSpecial|Flag::SkipDirectories|Flag::SkipDotAndDotDot);
|
||||
|
@ -72,7 +74,7 @@ auto ProfileManager::refreshProfiles() -> bool {
|
|||
continue;
|
||||
}
|
||||
|
||||
arrayAppend(_profiles, std::move(profile));
|
||||
_profiles.push_back(std::move(profile));
|
||||
}
|
||||
|
||||
if(_profiles.empty()) {
|
||||
|
@ -84,14 +86,14 @@ auto ProfileManager::refreshProfiles() -> bool {
|
|||
}
|
||||
|
||||
auto ProfileManager::getProfile(std::size_t index) -> Profile* {
|
||||
return index <= _profiles.size() ? &(_profiles[index]) : nullptr;
|
||||
return &(_profiles.at(index));
|
||||
}
|
||||
|
||||
auto ProfileManager::deleteProfile(std::size_t index, bool delete_builds) -> bool {
|
||||
if(!Utility::Directory::rm(Utility::Directory::join(_saveDirectory, _profiles[index].filename()))) {
|
||||
if(!Utility::Directory::rm(Utility::Directory::join(_saveDirectory, _profiles.at(index).filename()))) {
|
||||
_lastError = Utility::formatString("Couldn't delete {} (filename: {}).",
|
||||
_profiles[index].companyName(),
|
||||
_profiles[index].filename());
|
||||
_profiles.at(index).companyName(),
|
||||
_profiles.at(index).filename());
|
||||
refreshProfiles();
|
||||
return false;
|
||||
}
|
||||
|
@ -99,18 +101,13 @@ auto ProfileManager::deleteProfile(std::size_t index, bool delete_builds) -> boo
|
|||
if(delete_builds) {
|
||||
for(UnsignedByte i = 0; i < 32; ++i) {
|
||||
std::string filename = Utility::formatString("{}Unit{:.2d}{}.sav",
|
||||
_profiles[index].type() == ProfileType::Demo ? "Demo": "",
|
||||
i, _profiles[index].steamId());
|
||||
_profiles.at(index).type() == ProfileType::Demo ? "Demo": "",
|
||||
i, _profiles.at(index).steamId());
|
||||
Utility::Directory::rm(Utility::Directory::join(_saveDirectory, filename));
|
||||
}
|
||||
}
|
||||
|
||||
std::string file = _profiles[index].filename();
|
||||
auto it = std::remove_if(_profiles.begin(), _profiles.end(), [&file](Profile& profile){return profile.filename() == file;});
|
||||
|
||||
if(it != _profiles.end()) {
|
||||
arrayRemoveSuffix(_profiles, 1);
|
||||
}
|
||||
_profiles.erase(_profiles.cbegin() + index);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -120,7 +117,7 @@ auto ProfileManager::backupProfile(std::size_t index, bool backup_builds) -> boo
|
|||
std::tm* time = std::localtime(×tamp);
|
||||
|
||||
std::string filename = Utility::formatString("{}_{}{:.2d}{:.2d}_{:.2d}{:.2d}{:.2d}.mbprofbackup",
|
||||
Utility::String::replaceAll(_profiles[index].companyName(), " ", "_"),
|
||||
Utility::String::replaceAll(_profiles.at(index).companyName(), " ", "_"),
|
||||
time->tm_year + 1900, time->tm_mon + 1, time->tm_mday,
|
||||
time->tm_hour, time->tm_min, time->tm_sec);
|
||||
|
||||
|
@ -133,21 +130,21 @@ auto ProfileManager::backupProfile(std::size_t index, bool backup_builds) -> boo
|
|||
return false;
|
||||
}
|
||||
|
||||
zip_source_t* profile_source = zip_source_file(zip, Utility::Directory::toNativeSeparators(Utility::Directory::join(_saveDirectory, _profiles[index].filename())).c_str(), 0, 0);
|
||||
zip_source_t* profile_source = zip_source_file(zip, Utility::Directory::toNativeSeparators(Utility::Directory::join(_saveDirectory, _profiles.at(index).filename())).c_str(), 0, 0);
|
||||
if(profile_source == nullptr) {
|
||||
_lastError = zip_strerror(zip);
|
||||
zip_source_free(profile_source);
|
||||
return false;
|
||||
}
|
||||
|
||||
if(zip_file_add(zip, _profiles[index].filename().c_str(), profile_source, ZIP_FL_ENC_UTF_8) == -1) {
|
||||
if(zip_file_add(zip, _profiles.at(index).filename().c_str(), profile_source, ZIP_FL_ENC_UTF_8) == -1) {
|
||||
_lastError = zip_strerror(zip);
|
||||
zip_source_free(profile_source);
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string comment = Utility::String::join({_profiles[index].companyName(),
|
||||
_profiles[index].type() == ProfileType::Demo ? "demo" : "full",
|
||||
std::string comment = Utility::String::join({_profiles.at(index).companyName(),
|
||||
_profiles.at(index).type() == ProfileType::Demo ? "demo" : "full",
|
||||
Utility::formatString("{}-{:.2d}-{:.2d}-{:.2d}-{:.2d}-{:.2d}",
|
||||
time->tm_year + 1900, time->tm_mon + 1, time->tm_mday,
|
||||
time->tm_hour, time->tm_min, time->tm_sec)
|
||||
|
@ -157,8 +154,8 @@ auto ProfileManager::backupProfile(std::size_t index, bool backup_builds) -> boo
|
|||
if(backup_builds) {
|
||||
for(UnsignedByte i = 0; i < 32; ++i) {
|
||||
std::string build_filename = Utility::formatString("{}Unit{:.2d}{}.sav",
|
||||
_profiles[index].type() == ProfileType::Demo ? "Demo": "",
|
||||
i, _profiles[index].steamId());
|
||||
_profiles.at(index).type() == ProfileType::Demo ? "Demo": "",
|
||||
i, _profiles.at(index).steamId());
|
||||
|
||||
if(!Utility::Directory::exists(Utility::Directory::join(_saveDirectory, build_filename))) {
|
||||
continue;
|
||||
|
@ -187,12 +184,12 @@ auto ProfileManager::backupProfile(std::size_t index, bool backup_builds) -> boo
|
|||
return true;
|
||||
}
|
||||
|
||||
auto ProfileManager::backups() -> Containers::ArrayView<Backup> {
|
||||
auto ProfileManager::backups() -> std::vector<Backup> const& {
|
||||
return _backups;
|
||||
}
|
||||
|
||||
void ProfileManager::refreshBackups() {
|
||||
_backups = Containers::Array<Backup>{};
|
||||
_backups.clear();
|
||||
|
||||
using Utility::Directory::Flag;
|
||||
std::vector<std::string> files = Utility::Directory::list(_backupsDirectory, Flag::SkipSpecial|Flag::SkipDirectories|Flag::SkipDotAndDotDot);
|
||||
|
@ -258,34 +255,29 @@ void ProfileManager::refreshBackups() {
|
|||
continue;
|
||||
}
|
||||
|
||||
arrayReserve(backup.includedFiles, num_entries);
|
||||
backup.includedFiles.reserve(num_entries);
|
||||
|
||||
for(Long i = 0; i < num_entries; i++) {
|
||||
arrayAppend(backup.includedFiles, InPlaceInit, zip_get_name(zip, i, ZIP_FL_UNCHANGED));
|
||||
backup.includedFiles.emplace_back(zip_get_name(zip, i, ZIP_FL_UNCHANGED));
|
||||
}
|
||||
|
||||
arrayAppend(_backups, std::move(backup));
|
||||
_backups.push_back(std::move(backup));
|
||||
}
|
||||
}
|
||||
|
||||
auto ProfileManager::deleteBackup(std::size_t index) -> bool {
|
||||
if(!Utility::Directory::rm(Utility::Directory::join(_backupsDirectory, _backups[index].filename))) {
|
||||
_lastError = "Couldn't delete " + _backups[index].filename;
|
||||
if(!Utility::Directory::rm(Utility::Directory::join(_backupsDirectory, _backups.at(index).filename))) {
|
||||
_lastError = "Couldn't delete " + _backups.at(index).filename;
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string file = _backups[index].filename;
|
||||
auto it = std::remove_if(_backups.begin(), _backups.end(), [&file](Backup& backup){return backup.filename == file;});
|
||||
|
||||
if(it != _backups.end()) {
|
||||
arrayRemoveSuffix(_backups, 1);
|
||||
}
|
||||
_backups.erase(_backups.begin() + index);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
auto ProfileManager::restoreBackup(std::size_t index) -> bool {
|
||||
const Backup& backup = _backups[index];
|
||||
const Backup& backup = _backups.at(index);
|
||||
|
||||
static const char* error_format = "Extraction of file {} failed: {}";
|
||||
|
||||
|
|
|
@ -17,13 +17,10 @@
|
|||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <Corrade/Containers/Array.h>
|
||||
#include <vector>
|
||||
|
||||
#include "../Profile/Profile.h"
|
||||
|
||||
using namespace Corrade;
|
||||
|
||||
struct Backup {
|
||||
std::string filename;
|
||||
std::string company;
|
||||
|
@ -36,7 +33,7 @@ struct Backup {
|
|||
int minute;
|
||||
int second;
|
||||
} timestamp;
|
||||
Containers::Array<std::string> includedFiles;
|
||||
std::vector<std::string> includedFiles;
|
||||
};
|
||||
|
||||
class ProfileManager {
|
||||
|
@ -46,14 +43,14 @@ class ProfileManager {
|
|||
auto ready() const -> bool;
|
||||
auto lastError() -> std::string const&;
|
||||
|
||||
auto profiles() -> Containers::ArrayView<Profile>;
|
||||
auto profiles() -> std::vector<Profile> const&;
|
||||
auto refreshProfiles() -> bool;
|
||||
|
||||
auto getProfile(std::size_t index) -> Profile*;
|
||||
auto deleteProfile(std::size_t index, bool delete_builds) -> bool;
|
||||
auto backupProfile(std::size_t index, bool backup_builds) -> bool;
|
||||
|
||||
auto backups() -> Containers::ArrayView<Backup>;
|
||||
auto backups() -> std::vector<Backup> const&;
|
||||
void refreshBackups();
|
||||
|
||||
auto deleteBackup(std::size_t index) -> bool;
|
||||
|
@ -66,6 +63,6 @@ class ProfileManager {
|
|||
const std::string& _saveDirectory;
|
||||
const std::string& _backupsDirectory;
|
||||
|
||||
Containers::Array<Profile> _profiles;
|
||||
Containers::Array<Backup> _backups;
|
||||
std::vector<Profile> _profiles;
|
||||
std::vector<Backup> _backups;
|
||||
};
|
||||
|
|
|
@ -81,7 +81,7 @@ void SaveTool::drawProfileManager() {
|
|||
|
||||
ImGui::TableSetColumnIndex(0);
|
||||
ImGui::PushID(i);
|
||||
if(ImGui::Selectable(_profileManager->profiles()[i].companyName().c_str(), false,
|
||||
if(ImGui::Selectable(_profileManager->profiles().at(i).companyName().c_str(), false,
|
||||
ImGuiSelectableFlags_SpanAllColumns|ImGuiSelectableFlags_AllowItemOverlap))
|
||||
{
|
||||
_currentProfile = _profileManager->getProfile(i);
|
||||
|
@ -90,7 +90,7 @@ void SaveTool::drawProfileManager() {
|
|||
}
|
||||
|
||||
ImGui::TableSetColumnIndex(1);
|
||||
ImGui::TextUnformatted(_profileManager->profiles()[i].type() == ProfileType::Demo ? "Demo" : "Full");
|
||||
ImGui::TextUnformatted(_profileManager->profiles().at(i).type() == ProfileType::Demo ? "Demo" : "Full");
|
||||
|
||||
ImGui::TableSetColumnIndex(2);
|
||||
if(ImGui::SmallButton(ICON_FA_FILE_ARCHIVE)) {
|
||||
|
@ -132,13 +132,13 @@ auto SaveTool::drawBackupListPopup() -> ImGuiID {
|
|||
{
|
||||
ImGui::PushTextWrapPos(windowSize().x() * 0.40f);
|
||||
ImGui::Text("Are you sure you want to restore the %s backup from %.4i-%.2i-%.2i %.2i:%.2i:%.2i ? Any existing data will be overwritten.",
|
||||
_profileManager->backups()[backup_index].company.c_str(),
|
||||
_profileManager->backups()[backup_index].timestamp.year,
|
||||
_profileManager->backups()[backup_index].timestamp.month,
|
||||
_profileManager->backups()[backup_index].timestamp.day,
|
||||
_profileManager->backups()[backup_index].timestamp.hour,
|
||||
_profileManager->backups()[backup_index].timestamp.minute,
|
||||
_profileManager->backups()[backup_index].timestamp.second);
|
||||
_profileManager->backups().at(backup_index).company.c_str(),
|
||||
_profileManager->backups().at(backup_index).timestamp.year,
|
||||
_profileManager->backups().at(backup_index).timestamp.month,
|
||||
_profileManager->backups().at(backup_index).timestamp.day,
|
||||
_profileManager->backups().at(backup_index).timestamp.hour,
|
||||
_profileManager->backups().at(backup_index).timestamp.minute,
|
||||
_profileManager->backups().at(backup_index).timestamp.second);
|
||||
ImGui::PopTextWrapPos();
|
||||
|
||||
if(ImGui::BeginTable("##RestoreBackupLayout", 2)) {
|
||||
|
@ -172,13 +172,13 @@ auto SaveTool::drawBackupListPopup() -> ImGuiID {
|
|||
{
|
||||
ImGui::PushTextWrapPos(windowSize().x() * 0.40f);
|
||||
ImGui::Text("Are you sure you want to delete the %s backup from %.4i-%.2i-%.2i %.2i:%.2i:%.2i ? This operation is irreversible.",
|
||||
_profileManager->backups()[backup_index].company.c_str(),
|
||||
_profileManager->backups()[backup_index].timestamp.year,
|
||||
_profileManager->backups()[backup_index].timestamp.month,
|
||||
_profileManager->backups()[backup_index].timestamp.day,
|
||||
_profileManager->backups()[backup_index].timestamp.hour,
|
||||
_profileManager->backups()[backup_index].timestamp.minute,
|
||||
_profileManager->backups()[backup_index].timestamp.second);
|
||||
_profileManager->backups().at(backup_index).company.c_str(),
|
||||
_profileManager->backups().at(backup_index).timestamp.year,
|
||||
_profileManager->backups().at(backup_index).timestamp.month,
|
||||
_profileManager->backups().at(backup_index).timestamp.day,
|
||||
_profileManager->backups().at(backup_index).timestamp.hour,
|
||||
_profileManager->backups().at(backup_index).timestamp.minute,
|
||||
_profileManager->backups().at(backup_index).timestamp.second);
|
||||
ImGui::PopTextWrapPos();
|
||||
|
||||
if(ImGui::BeginTable("##DeleteBackupLayout", 2)) {
|
||||
|
@ -251,10 +251,10 @@ auto SaveTool::drawBackupListPopup() -> ImGuiID {
|
|||
ImGui::TableNextRow();
|
||||
|
||||
ImGui::TableSetColumnIndex(0);
|
||||
ImGui::TextUnformatted(_profileManager->backups()[i].company.c_str());
|
||||
ImGui::TextUnformatted(_profileManager->backups().at(i).company.c_str());
|
||||
if(ImGui::IsItemHovered()) {
|
||||
ImGui::BeginTooltip();
|
||||
for(const auto& file : _profileManager->backups()[i].includedFiles) {
|
||||
for(const auto& file : _profileManager->backups().at(i).includedFiles) {
|
||||
ImGui::TextUnformatted(file.c_str());
|
||||
}
|
||||
ImGui::EndTooltip();
|
||||
|
@ -262,15 +262,15 @@ auto SaveTool::drawBackupListPopup() -> ImGuiID {
|
|||
|
||||
ImGui::TableSetColumnIndex(1);
|
||||
ImGui::Text("%.4i-%.2i-%.2i %.2i:%.2i:%.2i",
|
||||
_profileManager->backups()[i].timestamp.year,
|
||||
_profileManager->backups()[i].timestamp.month,
|
||||
_profileManager->backups()[i].timestamp.day,
|
||||
_profileManager->backups()[i].timestamp.hour,
|
||||
_profileManager->backups()[i].timestamp.minute,
|
||||
_profileManager->backups()[i].timestamp.second);
|
||||
_profileManager->backups().at(i).timestamp.year,
|
||||
_profileManager->backups().at(i).timestamp.month,
|
||||
_profileManager->backups().at(i).timestamp.day,
|
||||
_profileManager->backups().at(i).timestamp.hour,
|
||||
_profileManager->backups().at(i).timestamp.minute,
|
||||
_profileManager->backups().at(i).timestamp.second);
|
||||
|
||||
ImGui::TableSetColumnIndex(2);
|
||||
ImGui::TextUnformatted(_profileManager->backups()[i].type == ProfileType::Demo ? "Demo" : "Full");
|
||||
ImGui::TextUnformatted(_profileManager->backups().at(i).type == ProfileType::Demo ? "Demo" : "Full");
|
||||
|
||||
ImGui::TableSetColumnIndex(3);
|
||||
ImGui::PushID(i);
|
||||
|
@ -363,8 +363,8 @@ auto SaveTool::drawDeleteProfilePopup(std::size_t profile_index) -> ImGuiID {
|
|||
|
||||
ImGui::PushTextWrapPos(windowSize().x() * 0.40f);
|
||||
ImGui::Text("Are you sure you want to delete the %s %s profile ? This operation is irreversible.",
|
||||
_profileManager->profiles()[profile_index].companyName().c_str(),
|
||||
_profileManager->profiles()[profile_index].type() == ProfileType::Demo ? "demo" : "full game");
|
||||
_profileManager->profiles().at(profile_index).companyName().c_str(),
|
||||
_profileManager->profiles().at(profile_index).type() == ProfileType::Demo ? "demo" : "full game");
|
||||
ImGui::PopTextWrapPos();
|
||||
|
||||
if(ImGui::BeginTable("##DeleteProfileLayout", 2)) {
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
#include "Serialisers/GuidPropertySerialiser.h"
|
||||
#include "Serialisers/IntPropertySerialiser.h"
|
||||
#include "Serialisers/MapPropertySerialiser.h"
|
||||
#include "Serialisers/ResourcePropertySerialiser.h"
|
||||
#include "Serialisers/RotatorPropertySerialiser.h"
|
||||
#include "Serialisers/StringPropertySerialiser.h"
|
||||
#include "Serialisers/SetPropertySerialiser.h"
|
||||
|
@ -54,7 +53,6 @@ PropertySerialiser::PropertySerialiser() {
|
|||
arrayAppend(_serialisers, Containers::pointer<GuidPropertySerialiser>());
|
||||
arrayAppend(_serialisers, Containers::pointer<IntPropertySerialiser>());
|
||||
arrayAppend(_serialisers, Containers::pointer<MapPropertySerialiser>());
|
||||
arrayAppend(_serialisers, Containers::pointer<ResourcePropertySerialiser>());
|
||||
arrayAppend(_serialisers, Containers::pointer<RotatorPropertySerialiser>());
|
||||
arrayAppend(_serialisers, Containers::pointer<StringPropertySerialiser>());
|
||||
arrayAppend(_serialisers, Containers::pointer<SetPropertySerialiser>());
|
||||
|
|
|
@ -1,103 +0,0 @@
|
|||
// MassBuilderSaveTool
|
||||
// Copyright (C) 2021 Guillaume Jacquemin
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
#include "../BinaryReader.h"
|
||||
#include "../BinaryWriter.h"
|
||||
#include "../PropertySerialiser.h"
|
||||
|
||||
#include "../Types/IntProperty.h"
|
||||
#include "../Types/NoneProperty.h"
|
||||
|
||||
#include "ResourcePropertySerialiser.h"
|
||||
|
||||
auto ResourcePropertySerialiser::deserialiseProperty(const std::string& name, const std::string& type, UnsignedLong value_length,
|
||||
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr
|
||||
{
|
||||
auto prop = Containers::pointer<ResourceItemValue>();
|
||||
|
||||
std::string str;
|
||||
if(!reader.readUEString(str) || str != "ID_4_AAE08F17428E229EC7A2209F51081A21") {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if(!reader.readUEString(str) || str != "IntProperty") {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if(!reader.readUnsignedLong(value_length) || value_length != 4ull) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
char terminator;
|
||||
if(!reader.readChar(terminator) || terminator != '\0') {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if(!reader.readInt(prop->id)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if(!reader.readUEString(str) || str != "Quantity_3_560F09B5485C365D3041888910019CE3") {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if(!reader.readUEString(str) || str != "IntProperty") {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if(!reader.readUnsignedLong(value_length) || value_length != 4ull) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if(!reader.readChar(terminator) || terminator != '\0') {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if(!reader.readInt(prop->quantity)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if(!reader.readUEString(str) || str != "None") {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return prop;
|
||||
}
|
||||
|
||||
auto ResourcePropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written,
|
||||
BinaryWriter& writer, PropertySerialiser& serialiser) -> bool
|
||||
{
|
||||
auto res_prop = dynamic_cast<ResourceItemValue*>(prop.get());
|
||||
if(!res_prop) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bytes_written += writer.writeUEStringToArray("ID_4_AAE08F17428E229EC7A2209F51081A21") +
|
||||
writer.writeUEStringToArray("IntProperty") +
|
||||
writer.writeValueToArray<UnsignedLong>(4ull) +
|
||||
writer.writeValueToArray<char>('\0') +
|
||||
writer.writeValueToArray<Int>(res_prop->id);
|
||||
|
||||
bytes_written += writer.writeUEStringToArray("Quantity_3_560F09B5485C365D3041888910019CE3") +
|
||||
writer.writeUEStringToArray("IntProperty") +
|
||||
writer.writeValueToArray<UnsignedLong>(4ull) +
|
||||
writer.writeValueToArray<char>('\0') +
|
||||
writer.writeValueToArray<Int>(res_prop->quantity);
|
||||
|
||||
bytes_written += writer.writeUEStringToArray("None");
|
||||
|
||||
return true;
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
// MassBuilderSaveTool
|
||||
// Copyright (C) 2021 Guillaume Jacquemin
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
#include "UnrealPropertySerialiser.h"
|
||||
|
||||
#include "../Types/ResourceItemValue.h"
|
||||
|
||||
class ResourcePropertySerialiser : public UnrealPropertySerialiser<ResourceItemValue> {
|
||||
public:
|
||||
using ptr = Containers::Pointer<ResourcePropertySerialiser>;
|
||||
|
||||
private:
|
||||
auto deserialiseProperty(const std::string& name, const std::string& type, UnsignedLong value_length, BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override;
|
||||
auto serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) -> bool override;
|
||||
};
|
|
@ -55,19 +55,13 @@ auto StructSerialiser::deserialise(const std::string& name, const std::string& t
|
|||
}
|
||||
else {
|
||||
for(UnsignedInt i = 0; i < count; i++) {
|
||||
auto prop = Containers::pointer<UnrealPropertyBase>();
|
||||
|
||||
prop = serialiser.readItem(reader, item_type, UnsignedLong(-1), name);
|
||||
|
||||
if(!prop) {
|
||||
prop = readStructValue(name, item_type, value_length, reader, serialiser);
|
||||
}
|
||||
auto prop = readStructValue(name, item_type, value_length, reader, serialiser);
|
||||
|
||||
if(!prop) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static_cast<StructProperty*>(prop.get())->structGuid = guid;
|
||||
prop->structGuid = guid;
|
||||
|
||||
arrayAppend(array, std::move(prop));
|
||||
}
|
||||
|
@ -137,12 +131,10 @@ auto StructSerialiser::serialise(Containers::ArrayView<UnrealPropertyBase::ptr>
|
|||
return false;
|
||||
}
|
||||
|
||||
if(!serialiser.writeItem(prop, struct_prop->structType, bytes_written_here, writer)) {
|
||||
if(!writeStructValue(struct_prop, bytes_written_here, writer, serialiser)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
UnsignedLong vl_stop = writer.arrayPosition() - vl_start;
|
||||
writer.writeValueToArrayAt(vl_stop, vl_pos);
|
||||
|
|
|
@ -1,30 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
// MassBuilderSaveTool
|
||||
// Copyright (C) 2021 Guillaume Jacquemin
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
#include "StructProperty.h"
|
||||
|
||||
struct ResourceItemValue : public StructProperty {
|
||||
using ptr = Containers::Pointer<ResourceItemValue>;
|
||||
|
||||
ResourceItemValue() {
|
||||
structType = "sttResourceItemValue";
|
||||
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;
|
||||
};
|
|
@ -47,12 +47,6 @@ auto UESaveFile::reloadData() -> bool {
|
|||
return valid();
|
||||
}
|
||||
|
||||
void UESaveFile::appendProperty(UnrealPropertyBase::ptr prop) {
|
||||
auto none_prop = std::move(_properties.back());
|
||||
_properties.back() = std::move(prop);
|
||||
arrayAppend(_properties, std::move(none_prop));
|
||||
}
|
||||
|
||||
auto UESaveFile::props() -> Containers::ArrayView<UnrealPropertyBase::ptr> {
|
||||
return _properties;
|
||||
}
|
||||
|
@ -61,7 +55,6 @@ auto UESaveFile::saveToFile() -> bool {
|
|||
BinaryWriter writer{_filepath + ".tmp"};
|
||||
|
||||
if(!writer.open()) {
|
||||
_lastError = "Couldn't open the file for saving.";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -74,14 +67,12 @@ auto UESaveFile::saveToFile() -> bool {
|
|||
!writer.writeUnsignedInt(_engineVersion.build) ||
|
||||
!writer.writeUEString(_engineVersion.buildId))
|
||||
{
|
||||
_lastError = "Couldn't write the header.";
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!writer.writeUnsignedInt(_customFormatVersion) ||
|
||||
!writer.writeUnsignedInt(_customFormatData.size()))
|
||||
{
|
||||
_lastError = "Couldn't write the header.";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -89,25 +80,21 @@ auto UESaveFile::saveToFile() -> bool {
|
|||
if(!writer.writeStaticArray(Containers::StaticArrayView<16, const char>{_customFormatData[i].id}) ||
|
||||
!writer.writeUnsignedInt(_customFormatData[i].value))
|
||||
{
|
||||
_lastError = "Couldn't write the header.";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if(!writer.writeUEString(_saveType)) {
|
||||
_lastError = "Couldn't write the header.";
|
||||
return false;
|
||||
}
|
||||
|
||||
for(auto& prop : _properties) {
|
||||
UnsignedLong bytes_written = 0;
|
||||
if(!_propSerialiser.write(prop, bytes_written, writer)) {
|
||||
_lastError = "Couldn't write the property " + *prop->name + " to the array.";
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!writer.flushToFile()) {
|
||||
_lastError = "Couldn't write the property " + *prop->name + " to the file.";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -210,9 +197,5 @@ void UESaveFile::loadData() {
|
|||
arrayAppend(_properties, std::move(prop));
|
||||
}
|
||||
|
||||
if(_properties.back()->name != "None" && _properties.back()->propertyType != "NoneProperty") {
|
||||
return;
|
||||
}
|
||||
|
||||
_valid = true;
|
||||
}
|
||||
|
|
|
@ -51,8 +51,6 @@ class UESaveFile {
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
void appendProperty(UnrealPropertyBase::ptr prop);
|
||||
|
||||
auto props() -> Containers::ArrayView<UnrealPropertyBase::ptr>;
|
||||
|
||||
auto saveToFile() -> bool;
|
||||
|
|
Loading…
Reference in a new issue