diff --git a/apps/openmw/mwstate/charactermanager.cpp b/apps/openmw/mwstate/charactermanager.cpp index 22192c355..f2d031576 100644 --- a/apps/openmw/mwstate/charactermanager.cpp +++ b/apps/openmw/mwstate/charactermanager.cpp @@ -101,15 +101,16 @@ std::list::iterator MWState::CharacterManager::findCharacter void MWState::CharacterManager::setCurrentCharacter (const Character *character) { - std::list::iterator it = findCharacter(character); + if (!character) + mCurrent = NULL; + else + { + std::list::iterator it = findCharacter(character); - mCurrent = &*it; + mCurrent = &*it; + } } -void MWState::CharacterManager::clearCurrentCharacter() -{ - mCurrent = 0; -} std::list::const_iterator MWState::CharacterManager::begin() const { diff --git a/apps/openmw/mwstate/charactermanager.hpp b/apps/openmw/mwstate/charactermanager.hpp index c44c10b5a..64f71af99 100644 --- a/apps/openmw/mwstate/charactermanager.hpp +++ b/apps/openmw/mwstate/charactermanager.hpp @@ -43,8 +43,6 @@ namespace MWState void setCurrentCharacter (const Character *character); - void clearCurrentCharacter(); - std::list::const_iterator begin() const; std::list::const_iterator end() const; diff --git a/apps/openmw/mwstate/statemanagerimp.cpp b/apps/openmw/mwstate/statemanagerimp.cpp index 1bf97cb7e..1759cdf54 100644 --- a/apps/openmw/mwstate/statemanagerimp.cpp +++ b/apps/openmw/mwstate/statemanagerimp.cpp @@ -54,7 +54,7 @@ void MWState::StateManager::cleanup (bool force) MWBase::Environment::get().getMechanicsManager()->clear(); mState = State_NoGame; - mCharacterManager.clearCurrentCharacter(); + mCharacterManager.setCurrentCharacter(NULL); mTimePlayed = 0; MWMechanics::CreatureStats::cleanup(); @@ -333,19 +333,8 @@ void MWState::StateManager::loadGame(const std::string& filepath) } } - // have to peek into the save file to get the player name - ESM::ESMReader reader; - reader.open (filepath); - if (reader.getRecName()!=ESM::REC_SAVE) - return; // invalid save file -> ignore - reader.getRecHeader(); - ESM::SavedGame profile; - profile.load (reader); - reader.close(); - - MWState::Character* character = mCharacterManager.getCurrentCharacter(true, profile.mPlayerName); + MWState::Character* character = getCurrentCharacter(false); loadGame(character, filepath); - mTimePlayed = profile.mTimePlayed; } void MWState::StateManager::loadGame (const Character *character, const std::string& filepath) @@ -470,7 +459,8 @@ void MWState::StateManager::loadGame (const Character *character, const std::str mState = State_Running; - Settings::Manager::setString ("character", "Saves", + if (character) + Settings::Manager::setString ("character", "Saves", character->getPath().filename().string()); MWBase::Environment::get().getWindowManager()->setNewGame(false);