1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-20 07:53:51 +00:00
openmw-tes3mp/apps/openmw/mwstate/quicksavemanager.cpp

39 lines
946 B
C++
Raw Normal View History

#include "quicksavemanager.hpp"
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
void MWState::QuickSaveManager::visitSave(const Slot *saveSlot)
{
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
bool MWState::QuickSaveManager::isOldestSave(const Slot *compare)
{
if(mOldestSlotVisited == NULL)
return true;
2018-01-13 01:02:43 +00:00
return (compare->mTimeStamp <= mOldestSlotVisited->mTimeStamp);
}
2018-01-13 01:02:43 +00:00
bool MWState::QuickSaveManager::shouldCreateNewSlot()
{
return (mSlotsVisited < mMaxSaves);
}
2018-01-13 01:02:43 +00:00
const MWState::Slot *MWState::QuickSaveManager::getNextQuickSaveSlot()
{
if(shouldCreateNewSlot())
return NULL;
2018-01-13 01:02:43 +00:00
return mOldestSlotVisited;
}