From 3af8f63895c94e1a0268720be0680af83130954b Mon Sep 17 00:00:00 2001 From: Daniel Vukelich Date: Wed, 17 Jan 2018 21:43:30 -0500 Subject: [PATCH] Use unsigned integer types for QuickSave indices --- apps/openmw/mwstate/quicksavemanager.cpp | 8 ++++---- apps/openmw/mwstate/quicksavemanager.hpp | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/apps/openmw/mwstate/quicksavemanager.cpp b/apps/openmw/mwstate/quicksavemanager.cpp index 1457f7075..e49f376d6 100644 --- a/apps/openmw/mwstate/quicksavemanager.cpp +++ b/apps/openmw/mwstate/quicksavemanager.cpp @@ -2,7 +2,7 @@ #include -MWState::QuickSaveManager::QuickSaveManager(std::string &saveName, int maxSaves) +MWState::QuickSaveManager::QuickSaveManager(std::string &saveName, unsigned int maxSaves) { this->mSaveName = saveName; this->mMaxSaves = maxSaves; @@ -13,7 +13,7 @@ MWState::QuickSaveManager::QuickSaveManager(std::string &saveName, int maxSaves) void MWState::QuickSaveManager::visitSave(const Slot *saveSlot) { - int slotId; + unsigned int slotId; if(tryExtractSlotId(saveSlot->mProfile.mDescription, slotId)) { ++mSlotsVisited; @@ -32,7 +32,7 @@ bool MWState::QuickSaveManager::isOldestSave(const Slot *compare) return (compare->mTimeStamp <= mOldestSlotVisited->mTimeStamp); } -bool MWState::QuickSaveManager::tryExtractSlotId(const std::string &slotName, int &extractedId) +bool MWState::QuickSaveManager::tryExtractSlotId(const std::string &slotName, unsigned int &extractedId) { std::istringstream formattedExtractor(slotName); @@ -50,7 +50,7 @@ bool MWState::QuickSaveManager::tryExtractSlotId(const std::string &slotName, in return false; } -bool MWState::QuickSaveManager::isSlotIdValid(int slotId) +bool MWState::QuickSaveManager::isSlotIdValid(unsigned int slotId) { return (slotId > 0 && slotId <= mMaxSaves); } diff --git a/apps/openmw/mwstate/quicksavemanager.hpp b/apps/openmw/mwstate/quicksavemanager.hpp index 6a06171d9..abe7ef426 100644 --- a/apps/openmw/mwstate/quicksavemanager.hpp +++ b/apps/openmw/mwstate/quicksavemanager.hpp @@ -9,18 +9,18 @@ namespace MWState{ class QuickSaveManager{ std::string mSaveName; - int mMaxSaves; - int mSlotsVisited; - int mOldestSlotId; + unsigned int mMaxSaves; + unsigned int mSlotsVisited; + unsigned int mOldestSlotId; const Slot *mOldestSlotVisited; private: - bool tryExtractSlotId(const std::string &slotName, int &extractedIdll); - bool isSlotIdValid(int slotId); + 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, int maxSaves); + 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)