1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-02-24 20:09:43 +00:00

character signatures

This commit is contained in:
Marc Zinnschlag 2013-11-21 11:18:56 +01:00
parent cbbdf390ad
commit 5ba56a5ea5
2 changed files with 24 additions and 0 deletions

View file

@ -108,4 +108,23 @@ MWState::Character::SlotIterator MWState::Character::begin() const
MWState::Character::SlotIterator MWState::Character::end() const
{
return mSlots.rend();
}
ESM::SavedGame MWState::Character::getSignature() const
{
if (mSlots.empty())
throw std::logic_error ("character signature not available");
std::vector<Slot>::const_iterator iter (mSlots.begin());
Slot slot = *iter;
for (++iter; iter!=mSlots.end(); ++iter)
if (iter->mProfile.mPlayerLevel>slot.mProfile.mPlayerLevel)
slot = *iter;
else if (iter->mProfile.mPlayerLevel==slot.mProfile.mPlayerLevel &&
iter->mTimeStamp>slot.mTimeStamp)
slot = *iter;
return slot.mProfile;
}

View file

@ -50,6 +50,11 @@ namespace MWState
///< First slot is the most recent. Other slots follow in descending order of save date.
SlotIterator end() const;
ESM::SavedGame getSignature() const;
///< Return signature information for this character.
///
/// \todo attention This function must not be called if there are no slots.
};
}