From 3bdd989a509fd5d1b56c86ed7db3604583407ace Mon Sep 17 00:00:00 2001 From: Daniel Vukelich Date: Tue, 13 Feb 2018 21:01:15 -0500 Subject: [PATCH] Remove numeric quicksave slot IDs When multiple quicksaves occurred in quick succession, the numeric order of the saves could not be guaranteed. To prevent players from getting confused as to why their saves appear out of order, don't number them. --- apps/openmw/mwstate/quicksavemanager.cpp | 49 +----------------------- apps/openmw/mwstate/quicksavemanager.hpp | 9 +---- apps/openmw/mwstate/statemanagerimp.cpp | 2 +- 3 files changed, 3 insertions(+), 57 deletions(-) diff --git a/apps/openmw/mwstate/quicksavemanager.cpp b/apps/openmw/mwstate/quicksavemanager.cpp index e49f376d6..4bae9e674 100644 --- a/apps/openmw/mwstate/quicksavemanager.cpp +++ b/apps/openmw/mwstate/quicksavemanager.cpp @@ -1,27 +1,20 @@ #include "quicksavemanager.hpp" -#include - MWState::QuickSaveManager::QuickSaveManager(std::string &saveName, unsigned int maxSaves) { this->mSaveName = saveName; this->mMaxSaves = maxSaves; this->mOldestSlotVisited = NULL; - this->mOldestSlotId = 0; this->mSlotsVisited = 0; } void MWState::QuickSaveManager::visitSave(const Slot *saveSlot) { - unsigned int slotId; - if(tryExtractSlotId(saveSlot->mProfile.mDescription, slotId)) + if(mSaveName == saveSlot->mProfile.mDescription) { ++mSlotsVisited; if(isOldestSave(saveSlot)) - { mOldestSlotVisited = saveSlot; - mOldestSlotId = slotId; - } } } @@ -32,29 +25,6 @@ bool MWState::QuickSaveManager::isOldestSave(const Slot *compare) return (compare->mTimeStamp <= mOldestSlotVisited->mTimeStamp); } -bool MWState::QuickSaveManager::tryExtractSlotId(const std::string &slotName, unsigned int &extractedId) -{ - std::istringstream formattedExtractor(slotName); - - std::string nameToTest; - formattedExtractor >> nameToTest; - if(nameToTest == mSaveName) - { - //Only try to extract the id if maxSaves > 1 - //With maxSaves == 1, we don't append the slotId to the name - if(formattedExtractor >> extractedId) - return (isSlotIdValid(extractedId)); - else if(mMaxSaves == 1) - return formattedExtractor.eof(); - } - return false; -} - -bool MWState::QuickSaveManager::isSlotIdValid(unsigned int slotId) -{ - return (slotId > 0 && slotId <= mMaxSaves); -} - bool MWState::QuickSaveManager::shouldCreateNewSlot() { return (mSlotsVisited < mMaxSaves); @@ -66,20 +36,3 @@ const MWState::Slot *MWState::QuickSaveManager::getNextQuickSaveSlot() return NULL; return mOldestSlotVisited; } - -std::string MWState::QuickSaveManager::getNextQuickSaveName() -{ - std::ostringstream nameFormatter; - nameFormatter << mSaveName; - //Only print the number if there will be more than 1 - if(mMaxSaves > 1) - nameFormatter << " " << calcNextSlotId(); - return nameFormatter.str(); -} - -int MWState::QuickSaveManager::calcNextSlotId() -{ - if(shouldCreateNewSlot()) - return (mSlotsVisited + 1); - return mOldestSlotId; -} diff --git a/apps/openmw/mwstate/quicksavemanager.hpp b/apps/openmw/mwstate/quicksavemanager.hpp index abe7ef426..e52cd609f 100644 --- a/apps/openmw/mwstate/quicksavemanager.hpp +++ b/apps/openmw/mwstate/quicksavemanager.hpp @@ -11,20 +11,16 @@ namespace MWState{ std::string mSaveName; unsigned int mMaxSaves; unsigned int mSlotsVisited; - unsigned int mOldestSlotId; const Slot *mOldestSlotVisited; private: - bool tryExtractSlotId(const std::string &slotName, unsigned int &extractedIdll); - bool isSlotIdValid(unsigned int slotId); bool shouldCreateNewSlot(); bool isOldestSave(const Slot *compare); - int calcNextSlotId(); public: QuickSaveManager(std::string &saveName, unsigned int maxSaves); ///< A utility class to manage multiple quicksave slots /// /// \param saveName The name of the save ("QuickSave", "AutoSave", etc) - /// \param maxSaves The maximum number of save slots to use before recycling old ones + /// \param maxSaves The maximum number of save slots to create before recycling old ones void visitSave(const Slot *saveSlot); ///< Visits the given \a slot \a @@ -33,9 +29,6 @@ namespace MWState{ ///< Get the slot that the next quicksave should use. /// ///\return Either the oldest quicksave slot visited, or NULL if a new slot can be made - - std::string getNextQuickSaveName(); - ///< Get the name that the next quicksave should use ("QuickSave 1", "AutoSave 10", etc) }; } diff --git a/apps/openmw/mwstate/statemanagerimp.cpp b/apps/openmw/mwstate/statemanagerimp.cpp index 5b126cbb5..c1bb589e8 100644 --- a/apps/openmw/mwstate/statemanagerimp.cpp +++ b/apps/openmw/mwstate/statemanagerimp.cpp @@ -344,7 +344,7 @@ void MWState::StateManager::quickSave (std::string name) //Once all the saves have been visited, the save finder can tell us which //one to replace (or create) - saveGame(saveFinder.getNextQuickSaveName(), saveFinder.getNextQuickSaveSlot()); + saveGame(name, saveFinder.getNextQuickSaveSlot()); } void MWState::StateManager::loadGame(const std::string& filepath)