Move createCharacter inside the try block

This commit is contained in:
scrawl 2016-03-14 00:03:02 +01:00
parent a0cc9de088
commit 50acdf3e47

View file

@ -174,17 +174,18 @@ void MWState::StateManager::endGame()
void MWState::StateManager::saveGame (const std::string& description, const Slot *slot) void MWState::StateManager::saveGame (const std::string& description, const Slot *slot)
{ {
MWState::Character* character = getCurrentCharacter(); MWState::Character* character = getCurrentCharacter();
if (!character)
{
MWWorld::ConstPtr player = MWMechanics::getPlayer();
std::string name = player.get<ESM::NPC>()->mBase->mName;
character = mCharacterManager.createCharacter(name);
mCharacterManager.setCurrentCharacter(character);
}
try try
{ {
if (!character)
{
MWWorld::ConstPtr player = MWMechanics::getPlayer();
std::string name = player.get<ESM::NPC>()->mBase->mName;
character = mCharacterManager.createCharacter(name);
mCharacterManager.setCurrentCharacter(character);
}
ESM::SavedGame profile; ESM::SavedGame profile;
MWBase::World& world = *MWBase::Environment::get().getWorld(); MWBase::World& world = *MWBase::Environment::get().getWorld();
@ -299,7 +300,7 @@ void MWState::StateManager::saveGame (const std::string& description, const Slot
MWBase::Environment::get().getWindowManager()->interactiveMessageBox(error.str(), buttons); MWBase::Environment::get().getWindowManager()->interactiveMessageBox(error.str(), buttons);
// If no file was written, clean up the slot // If no file was written, clean up the slot
if (slot && !boost::filesystem::exists(slot->mPath)) if (character && slot && !boost::filesystem::exists(slot->mPath))
{ {
character->deleteSlot(slot); character->deleteSlot(slot);
character->cleanup(); character->cleanup();