From 8cf5351f0b46a0a009387fbae5faead8b57b410a Mon Sep 17 00:00:00 2001 From: William JCM Date: Mon, 21 Nov 2022 19:03:18 +0100 Subject: [PATCH] Profile: use Logger. --- src/Profile/Profile.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/Profile/Profile.cpp b/src/Profile/Profile.cpp index 4082120..4e62fdc 100644 --- a/src/Profile/Profile.cpp +++ b/src/Profile/Profile.cpp @@ -20,6 +20,7 @@ #include #include "PropertyNames.h" +#include "../Logger/Logger.h" #include "../UESaveFile/Types/ArrayProperty.h" #include "../UESaveFile/Types/ResourceItemValue.h" #include "../UESaveFile/Types/IntProperty.h" @@ -33,6 +34,8 @@ using namespace Containers::Literals; Profile::Profile(Containers::StringView path): _profile(path) { + LOG_INFO_FORMAT("Reading profile at {}.", path); + if(!_profile.valid()) { _lastError = _profile.lastError(); _valid = false; @@ -85,35 +88,44 @@ auto Profile::account() const -> Containers::StringView { void Profile::refreshValues() { if(!_profile.reloadData()) { - _lastError = _profile.lastError(); + LOG_ERROR(_profile.lastError()); _valid = false; return; } if(_profile.saveType() != "/Game/Core/Save/bpSaveGameProfile.bpSaveGameProfile_C"_s) { - Utility::Error{} << _filename << "is not a valid profile save."; + LOG_ERROR_FORMAT("{} is not a valid profile save.", _filename); + _valid = false; + return; } + LOG_INFO("Getting the company name."); auto name_prop = _profile.at(PROFILE_NAME); if(!name_prop) { _lastError = "No company name in "_s + _filename; + LOG_ERROR(_lastError); _valid = false; return; } _name = name_prop->value; + LOG_INFO("Getting the active frame slot."); auto prop = _profile.at(PROFILE_ACTIVE_FRAME_SLOT); _activeFrameSlot = prop ? prop->value : 0; + LOG_INFO("Getting the credits."); prop = _profile.at(PROFILE_CREDITS); _credits = prop ? prop->value : 0; + LOG_INFO("Getting the story progress."); prop = _profile.at(PROFILE_STORY_PROGRESS); _storyProgress = prop ? prop->value : 0; + LOG_INFO("Getting the last mission ID."); prop = _profile.at(PROFILE_LAST_MISSION_ID); _lastMissionId = prop ? prop->value : 0; + LOG_INFO("Getting the materials."); _verseSteel = getResource(PROFILE_MATERIAL, VerseSteel); _undinium = getResource(PROFILE_MATERIAL, Undinium); _necriumAlloy = getResource(PROFILE_MATERIAL, NecriumAlloy); @@ -149,6 +161,7 @@ auto Profile::renameCompany(Containers::StringView new_name) -> bool { auto name_prop = _profile.at(PROFILE_NAME); if(!name_prop) { _lastError = "No company name in "_s + _filename; + LOG_ERROR(_lastError); _valid = false; return false; } @@ -177,6 +190,7 @@ auto Profile::setCredits(Int amount) -> bool { if(!credits_prop) { credits_prop = new IntProperty; credits_prop->name.emplace("Credit"_s); + credits_prop->valueLength = sizeof(Int); _profile.appendProperty(IntProperty::ptr{credits_prop}); } @@ -200,6 +214,7 @@ auto Profile::setStoryProgress(Int progress) -> bool { if(!story_progress_prop) { story_progress_prop = new IntProperty; story_progress_prop->name.emplace("StoryProgress"_s); + story_progress_prop->valueLength = sizeof(Int); _profile.appendProperty(IntProperty::ptr{story_progress_prop}); }