1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-20 14:23:53 +00:00

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

This commit is contained in:
scrawl 2014-01-25 22:20:46 +01:00
parent 1b5301eec0
commit 49e26415be
3 changed files with 22 additions and 21 deletions

View file

@ -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);
}

View file

@ -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;

View file

@ -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);
}
}
}