Don't create the save directory on loading a game

This prevents empty directories being created when loading a save file outside of the saves directory with the --load-savegame switch.
move
scrawl 9 years ago
parent d7c7bb850b
commit 426a6fdcc2

@ -101,15 +101,16 @@ std::list<MWState::Character>::iterator MWState::CharacterManager::findCharacter
void MWState::CharacterManager::setCurrentCharacter (const Character *character) void MWState::CharacterManager::setCurrentCharacter (const Character *character)
{ {
std::list<Character>::iterator it = findCharacter(character); if (!character)
mCurrent = NULL;
else
{
std::list<Character>::iterator it = findCharacter(character);
mCurrent = &*it; mCurrent = &*it;
}
} }
void MWState::CharacterManager::clearCurrentCharacter()
{
mCurrent = 0;
}
std::list<MWState::Character>::const_iterator MWState::CharacterManager::begin() const std::list<MWState::Character>::const_iterator MWState::CharacterManager::begin() const
{ {

@ -43,8 +43,6 @@ namespace MWState
void setCurrentCharacter (const Character *character); void setCurrentCharacter (const Character *character);
void clearCurrentCharacter();
std::list<Character>::const_iterator begin() const; std::list<Character>::const_iterator begin() const;
std::list<Character>::const_iterator end() const; std::list<Character>::const_iterator end() const;

@ -54,7 +54,7 @@ void MWState::StateManager::cleanup (bool force)
MWBase::Environment::get().getMechanicsManager()->clear(); MWBase::Environment::get().getMechanicsManager()->clear();
mState = State_NoGame; mState = State_NoGame;
mCharacterManager.clearCurrentCharacter(); mCharacterManager.setCurrentCharacter(NULL);
mTimePlayed = 0; mTimePlayed = 0;
MWMechanics::CreatureStats::cleanup(); 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 MWState::Character* character = getCurrentCharacter(false);
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);
loadGame(character, filepath); loadGame(character, filepath);
mTimePlayed = profile.mTimePlayed;
} }
void MWState::StateManager::loadGame (const Character *character, const std::string& filepath) 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; mState = State_Running;
Settings::Manager::setString ("character", "Saves", if (character)
Settings::Manager::setString ("character", "Saves",
character->getPath().filename().string()); character->getPath().filename().string());
MWBase::Environment::get().getWindowManager()->setNewGame(false); MWBase::Environment::get().getWindowManager()->setNewGame(false);

Loading…
Cancel
Save