flag game as ended when player dies

This commit is contained in:
Marc Zinnschlag 2013-11-18 15:38:08 +01:00
parent 82c8495338
commit f45cff8aff
4 changed files with 24 additions and 10 deletions

View file

@ -39,6 +39,8 @@ namespace MWBase
///< Start a new game.
///
/// \param bypass Skip new game mechanics.
virtual void endGame() = 0;
};
}

View file

@ -17,6 +17,7 @@
#include "../mwbase/environment.hpp"
#include "../mwbase/windowmanager.hpp"
#include "../mwbase/soundmanager.hpp"
#include "../mwbase/statemanager.hpp"
#include "npcstats.hpp"
#include "creaturestats.hpp"
@ -344,13 +345,14 @@ namespace MWMechanics
continue;
}
// If it's the player and God Mode is turned on, keep it alive
if(iter->first.getRefData().getHandle()=="player" &&
MWBase::Environment::get().getWorld()->getGodModeState())
if (iter->first.getRefData().getHandle()=="player")
{
MWMechanics::DynamicStat<float> stat(stats.getHealth());
// If it's the player and God Mode is turned on, keep it alive
if (MWBase::Environment::get().getWorld()->getGodModeState())
{
MWMechanics::DynamicStat<float> stat (stats.getHealth());
if(stat.getModified()<1)
if (stat.getModified()<1)
{
stat.setModified(1, 0);
stats.setHealth(stat);
@ -360,6 +362,9 @@ namespace MWMechanics
continue;
}
MWBase::Environment::get().getStateManager()->endGame();
}
if(iter->second->isDead())
continue;

View file

@ -46,3 +46,8 @@ void MWState::StateManager::newGame (bool bypass)
mState = State_Running;
}
void MWState::StateManager::endGame()
{
mState = State_Ended;
}

View file

@ -24,6 +24,8 @@ namespace MWState
///< Start a new game.
///
/// \param bypass Skip new game mechanics.
virtual void endGame();
};
}