Don't call loadGame() from within the MWMechanics::Actors update sequence

actorid
scrawl 11 years ago
parent 1b5301eec0
commit 49e26415be

@ -91,6 +91,9 @@ bool OMW::Engine::frameRenderingQueued (const Ogre::FrameEvent& evt)
bool paused = MWBase::Environment::get().getWindowManager()->isGuiMode();
// update game state
MWBase::Environment::get().getStateManager()->update (frametime);
if (MWBase::Environment::get().getStateManager()->getState()==
MWBase::StateManager::State_Running)
{
@ -110,9 +113,6 @@ bool OMW::Engine::frameRenderingQueued (const Ogre::FrameEvent& evt)
if (!paused)
MWBase::Environment::get().getWorld()->advanceTime(
frametime*MWBase::Environment::get().getWorld()->getTimeScaleFactor()/3600);
// update game state
MWBase::Environment::get().getStateManager()->update (frametime);
}

@ -1244,7 +1244,6 @@ bool CharacterController::kill()
//player's death animation is over
if( mPtr.getRefData().getHandle()=="player" && !isAnimPlaying(mCurrentDeath) )
{
MWWorld::Class::get(mPtr).getCreatureStats(mPtr).setHealth(0);
MWBase::Environment::get().getStateManager()->askLoadRecent();
}
return false;

@ -111,23 +111,6 @@ void MWState::StateManager::askLoadRecent()
mAskLoadRecent = true;
}
}
else
{
int iButton = MWBase::Environment::get().getWindowManager()->readPressedButton();
if(iButton==0)
{
mAskLoadRecent = false;
//Load last saved game for current character
MWState::Character *curCharacter = getCurrentCharacter();
MWState::Slot lastSave = *curCharacter->begin();
loadGame(curCharacter, &lastSave);
}
else if(iButton==1)
{
mAskLoadRecent = false;
MWBase::Environment::get().getWindowManager()->pushGuiMode (MWGui::GM_MainMenu);
}
}
}
MWState::StateManager::State MWState::StateManager::getState() const
@ -340,4 +323,23 @@ MWState::StateManager::CharacterIterator MWState::StateManager::characterEnd()
void MWState::StateManager::update (float duration)
{
mTimePlayed += duration;
// Note: It would be nicer to trigger this from InputManager, i.e. the very beginning of the frame update.
if (mAskLoadRecent)
{
int iButton = MWBase::Environment::get().getWindowManager()->readPressedButton();
if(iButton==0)
{
mAskLoadRecent = false;
//Load last saved game for current character
MWState::Character *curCharacter = getCurrentCharacter();
MWState::Slot lastSave = *curCharacter->begin();
loadGame(curCharacter, &lastSave);
}
else if(iButton==1)
{
mAskLoadRecent = false;
MWBase::Environment::get().getWindowManager()->pushGuiMode (MWGui::GM_MainMenu);
}
}
}

Loading…
Cancel
Save