1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-02-22 03:40:49 +00:00

fixed handling of characters without a valid slot

This commit is contained in:
Marc Zinnschlag 2013-11-24 15:05:00 +01:00
parent 18a3b38fb4
commit 7efac4c9a5
3 changed files with 10 additions and 15 deletions

View File

@ -63,8 +63,6 @@ namespace MWBase
/// \note \a slot must belong to \a character. /// \note \a slot must belong to \a character.
virtual MWState::Character *getCurrentCharacter() = 0; virtual MWState::Character *getCurrentCharacter() = 0;
///< \attention Do not call this function to check if there is a current character.
/// Instead, assume there is a character if getState() == Running.
virtual CharacterIterator characterBegin() = 0; virtual CharacterIterator characterBegin() = 0;
///< Any call to SaveGame and getCurrentCharacter can invalidate the returned ///< Any call to SaveGame and getCurrentCharacter can invalidate the returned

View File

@ -89,23 +89,22 @@ namespace MWGui
if (mgr->characterBegin() == mgr->characterEnd()) if (mgr->characterBegin() == mgr->characterEnd())
return; return;
// If we are running, there must be a current character mCurrentCharacter = mgr->getCurrentCharacter();
if (mgr->getState() == MWBase::StateManager::State_Running)
{
mCurrentCharacter = mgr->getCurrentCharacter();
}
mCharacterSelection->removeAllItems(); mCharacterSelection->removeAllItems();
for (MWBase::StateManager::CharacterIterator it = mgr->characterBegin(); it != mgr->characterEnd(); ++it) for (MWBase::StateManager::CharacterIterator it = mgr->characterBegin(); it != mgr->characterEnd(); ++it)
{ {
std::stringstream title; if (it->begin()!=it->end())
title << it->getSignature().mPlayerName; {
title << " (Level " << it->getSignature().mPlayerLevel << " " << it->getSignature().mPlayerClass << ")"; std::stringstream title;
title << it->getSignature().mPlayerName;
title << " (Level " << it->getSignature().mPlayerLevel << " " << it->getSignature().mPlayerClass << ")";
mCharacterSelection->addItem (title.str()); mCharacterSelection->addItem (title.str());
if (mCurrentCharacter == &*it) if (mgr->getCurrentCharacter() == &*it)
mCharacterSelection->setIndexSelected(mCharacterSelection->getItemCount()-1); mCharacterSelection->setIndexSelected(mCharacterSelection->getItemCount()-1);
}
} }
fillSaveList(); fillSaveList();

View File

@ -43,8 +43,6 @@ namespace MWState
/// \note \a slot must belong to \a character. /// \note \a slot must belong to \a character.
virtual Character *getCurrentCharacter(); virtual Character *getCurrentCharacter();
///< \attention Do not call this function to check if there is a current character. Use
/// characterBegin()!=characterEnd() instead.
virtual CharacterIterator characterBegin(); virtual CharacterIterator characterBegin();
///< Any call to SaveGame and getCurrentCharacter can invalidate the returned ///< Any call to SaveGame and getCurrentCharacter can invalidate the returned