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,6 +174,9 @@ void MWState::StateManager::endGame()
void MWState::StateManager::saveGame (const std::string& description, const Slot *slot)
{
MWState::Character* character = getCurrentCharacter();
try
{
if (!character)
{
MWWorld::ConstPtr player = MWMechanics::getPlayer();
@ -183,8 +186,6 @@ void MWState::StateManager::saveGame (const std::string& description, const Slot
mCharacterManager.setCurrentCharacter(character);
}
try
{
ESM::SavedGame profile;
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);
// 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->cleanup();