diff --git a/apps/openmw/mwstate/character.cpp b/apps/openmw/mwstate/character.cpp index 660af7d891..54d2b9dd81 100644 --- a/apps/openmw/mwstate/character.cpp +++ b/apps/openmw/mwstate/character.cpp @@ -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::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; } \ No newline at end of file diff --git a/apps/openmw/mwstate/character.hpp b/apps/openmw/mwstate/character.hpp index a6cb6fa6d1..676c04680f 100644 --- a/apps/openmw/mwstate/character.hpp +++ b/apps/openmw/mwstate/character.hpp @@ -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. }; }