Use unsigned integer types for QuickSave indices

0.6.3
Daniel Vukelich 7 years ago
parent f09fd6795c
commit 3af8f63895

@ -2,7 +2,7 @@
#include <sstream>
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);
}

@ -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)

Loading…
Cancel
Save