diff --git a/src/Profile/Profile.cpp b/src/Profile/Profile.cpp index d1998ae..0cc993e 100644 --- a/src/Profile/Profile.cpp +++ b/src/Profile/Profile.cpp @@ -36,7 +36,6 @@ using namespace Corrade; Profile::Profile(const std::string& path): _profile(path) { - _profileDirectory = Utility::Directory::path(path); _filename = Utility::Directory::filename(path); if(Utility::String::beginsWith(_filename, "Demo")) { @@ -46,7 +45,14 @@ Profile::Profile(const std::string& path): _type = ProfileType::FullGame; } - _steamId = Utility::String::ltrim(Utility::String::rtrim(_filename, ".sav"), (_type == ProfileType::Demo ? "Demo" : "") + std::string{"Profile"}); + _account = Utility::String::ltrim(Utility::String::rtrim(_filename, ".sav"), (_type == ProfileType::Demo ? "Demo" : "") + std::string{"Profile"}); + + if(Utility::String::beginsWith(_account, "PMCSlot")) { + _version = ProfileVersion::Normal; + } + else { + _version = ProfileVersion::Legacy; + } refreshValues(); @@ -69,8 +75,12 @@ auto Profile::type() const -> ProfileType { return _type; } -auto Profile::steamId() const -> std::string const& { - return _steamId; +auto Profile::version() const -> ProfileVersion { + return _version; +} + +auto Profile::account() const -> std::string const& { + return _account; } void Profile::refreshValues() { diff --git a/src/Profile/Profile.h b/src/Profile/Profile.h index 1759e36..9a4c900 100644 --- a/src/Profile/Profile.h +++ b/src/Profile/Profile.h @@ -29,6 +29,11 @@ enum class ProfileType : UnsignedByte { FullGame }; +enum class ProfileVersion : UnsignedByte { + Legacy, // pre-0.8 + Normal // 0.8 and later +}; + class Profile { public: explicit Profile(const std::string& path); @@ -41,7 +46,9 @@ class Profile { auto type() const -> ProfileType; - auto steamId() const -> std::string const&; + auto version() const -> ProfileVersion; + + auto account() const -> std::string const&; void refreshValues(); @@ -122,10 +129,10 @@ class Profile { auto getResource(const char* container, Int id) -> Int; auto setResource(const char* container, Int id, Int amount) -> bool; - std::string _profileDirectory; std::string _filename; ProfileType _type; + ProfileVersion _version; UESaveFile _profile; @@ -159,7 +166,7 @@ class Profile { Int _mineralExoskeletology = 0; Int _carbonisedSkin = 0; - std::string _steamId; + std::string _account; bool _valid = false; std::string _lastError; diff --git a/src/ProfileManager/ProfileManager.cpp b/src/ProfileManager/ProfileManager.cpp index 57da93a..e86cecb 100644 --- a/src/ProfileManager/ProfileManager.cpp +++ b/src/ProfileManager/ProfileManager.cpp @@ -100,7 +100,7 @@ auto ProfileManager::deleteProfile(std::size_t index, bool delete_builds) -> boo 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()); + i, _profiles[index].account()); Utility::Directory::rm(Utility::Directory::join(_saveDirectory, filename)); } } @@ -158,7 +158,7 @@ auto ProfileManager::backupProfile(std::size_t index, bool backup_builds) -> boo 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()); + i, _profiles[index].account()); if(!Utility::Directory::exists(Utility::Directory::join(_saveDirectory, build_filename))) { continue; diff --git a/src/SaveTool/SaveTool.cpp b/src/SaveTool/SaveTool.cpp index 84cdc8f..7689f34 100644 --- a/src/SaveTool/SaveTool.cpp +++ b/src/SaveTool/SaveTool.cpp @@ -227,7 +227,7 @@ void SaveTool::handleFileAction(efsw::WatchID watch_id, switch(action) { case efsw::Actions::Add: - if(Utility::String::endsWith(filename, _currentProfile->steamId() + ".sav")) { + if(Utility::String::endsWith(filename, _currentProfile->account() + ".sav")) { if(Utility::String::beginsWith(filename, Utility::formatString("{}Unit", _currentProfile->type() == ProfileType::Demo ? "Demo" : ""))) { int index = ((filename[_currentProfile->type() == ProfileType::Demo ? 8 : 4] - 0x30) * 10) + (filename[_currentProfile->type() == ProfileType::Demo ? 9 : 5] - 0x30); @@ -241,7 +241,7 @@ void SaveTool::handleFileAction(efsw::WatchID watch_id, } break; case efsw::Actions::Delete: - if(Utility::String::endsWith(filename, _currentProfile->steamId() + ".sav")) { + if(Utility::String::endsWith(filename, _currentProfile->account() + ".sav")) { if(Utility::String::beginsWith(filename, Utility::formatString("{}Unit", _currentProfile->type() == ProfileType::Demo ? "Demo" : ""))) { int index = ((filename[_currentProfile->type() == ProfileType::Demo ? 8 : 4] - 0x30) * 10) + (filename[_currentProfile->type() == ProfileType::Demo ? 9 : 5] - 0x30); @@ -255,7 +255,7 @@ void SaveTool::handleFileAction(efsw::WatchID watch_id, if(filename == _currentProfile->filename()) { _currentProfile->refreshValues(); } - else if(Utility::String::endsWith(filename, _currentProfile->steamId() + ".sav")) { + else if(Utility::String::endsWith(filename, _currentProfile->account() + ".sav")) { if(Utility::String::beginsWith(filename, Utility::formatString("{}Unit", _currentProfile->type() == ProfileType::Demo ? "Demo" : ""))) { int index = ((filename[_currentProfile->type() == ProfileType::Demo ? 8 : 4] - 0x30) * 10) + (filename[_currentProfile->type() == ProfileType::Demo ? 9 : 5] - 0x30); @@ -273,7 +273,7 @@ void SaveTool::handleFileAction(efsw::WatchID watch_id, } break; case efsw::Actions::Moved: - if(Utility::String::endsWith(filename, _currentProfile->steamId() + ".sav")) { + if(Utility::String::endsWith(filename, _currentProfile->account() + ".sav")) { if(Utility::String::endsWith(old_filename, ".tmp")) { is_moved_after_save = true; return; @@ -582,7 +582,7 @@ auto SaveTool::findGameDataDirectory() -> bool { void SaveTool::initialiseMassManager() { _massManager.emplace(_saveDir, - _currentProfile->steamId(), + _currentProfile->account(), _currentProfile->type() == ProfileType::Demo, _stagingDir);