2018-01-13 01:02:43 +00:00
|
|
|
#include "quicksavemanager.hpp"
|
|
|
|
|
2018-01-18 02:43:30 +00:00
|
|
|
MWState::QuickSaveManager::QuickSaveManager(std::string &saveName, unsigned int maxSaves)
|
2018-01-13 01:02:43 +00:00
|
|
|
{
|
|
|
|
this->mSaveName = saveName;
|
|
|
|
this->mMaxSaves = maxSaves;
|
|
|
|
this->mOldestSlotVisited = NULL;
|
|
|
|
this->mSlotsVisited = 0;
|
2018-01-13 01:02:43 +00:00
|
|
|
}
|
|
|
|
|
2018-01-13 01:02:43 +00:00
|
|
|
void MWState::QuickSaveManager::visitSave(const Slot *saveSlot)
|
|
|
|
{
|
2018-02-14 02:01:15 +00:00
|
|
|
if(mSaveName == saveSlot->mProfile.mDescription)
|
2018-01-13 01:02:43 +00:00
|
|
|
{
|
|
|
|
++mSlotsVisited;
|
|
|
|
if(isOldestSave(saveSlot))
|
|
|
|
mOldestSlotVisited = saveSlot;
|
2018-01-13 01:02:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-13 01:02:43 +00:00
|
|
|
bool MWState::QuickSaveManager::isOldestSave(const Slot *compare)
|
|
|
|
{
|
|
|
|
if(mOldestSlotVisited == NULL)
|
2018-01-13 01:02:43 +00:00
|
|
|
return true;
|
2018-01-13 01:02:43 +00:00
|
|
|
return (compare->mTimeStamp <= mOldestSlotVisited->mTimeStamp);
|
2018-01-13 01:02:43 +00:00
|
|
|
}
|
|
|
|
|
2018-01-13 01:02:43 +00:00
|
|
|
bool MWState::QuickSaveManager::shouldCreateNewSlot()
|
|
|
|
{
|
|
|
|
return (mSlotsVisited < mMaxSaves);
|
2018-01-13 01:02:43 +00:00
|
|
|
}
|
|
|
|
|
2018-01-13 01:02:43 +00:00
|
|
|
const MWState::Slot *MWState::QuickSaveManager::getNextQuickSaveSlot()
|
|
|
|
{
|
2018-01-13 01:02:43 +00:00
|
|
|
if(shouldCreateNewSlot())
|
|
|
|
return NULL;
|
2018-01-13 01:02:43 +00:00
|
|
|
return mOldestSlotVisited;
|
2018-01-13 01:02:43 +00:00
|
|
|
}
|