From f45cff8aff4d8bf29fd0a3200f78bb565cda0cb5 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Mon, 18 Nov 2013 15:38:08 +0100 Subject: [PATCH] flag game as ended when player dies --- apps/openmw/mwbase/statemanager.hpp | 2 ++ apps/openmw/mwmechanics/actors.cpp | 25 +++++++++++++++---------- apps/openmw/mwstate/statemanagerimp.cpp | 5 +++++ apps/openmw/mwstate/statemanagerimp.hpp | 2 ++ 4 files changed, 24 insertions(+), 10 deletions(-) diff --git a/apps/openmw/mwbase/statemanager.hpp b/apps/openmw/mwbase/statemanager.hpp index 4fd1a297d0..74fcc3f7ad 100644 --- a/apps/openmw/mwbase/statemanager.hpp +++ b/apps/openmw/mwbase/statemanager.hpp @@ -39,6 +39,8 @@ namespace MWBase ///< Start a new game. /// /// \param bypass Skip new game mechanics. + + virtual void endGame() = 0; }; } diff --git a/apps/openmw/mwmechanics/actors.cpp b/apps/openmw/mwmechanics/actors.cpp index 3d52ce8e69..cc431a7b04 100644 --- a/apps/openmw/mwmechanics/actors.cpp +++ b/apps/openmw/mwmechanics/actors.cpp @@ -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,20 +345,24 @@ 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 stat(stats.getHealth()); - - if(stat.getModified()<1) + // If it's the player and God Mode is turned on, keep it alive + if (MWBase::Environment::get().getWorld()->getGodModeState()) { - stat.setModified(1, 0); - stats.setHealth(stat); + MWMechanics::DynamicStat stat (stats.getHealth()); + + if (stat.getModified()<1) + { + stat.setModified(1, 0); + stats.setHealth(stat); + } + + stats.resurrect(); + continue; } - stats.resurrect(); - continue; + MWBase::Environment::get().getStateManager()->endGame(); } if(iter->second->isDead()) diff --git a/apps/openmw/mwstate/statemanagerimp.cpp b/apps/openmw/mwstate/statemanagerimp.cpp index c4cd45c8eb..66a44872c4 100644 --- a/apps/openmw/mwstate/statemanagerimp.cpp +++ b/apps/openmw/mwstate/statemanagerimp.cpp @@ -46,3 +46,8 @@ void MWState::StateManager::newGame (bool bypass) mState = State_Running; } + +void MWState::StateManager::endGame() +{ + mState = State_Ended; +} diff --git a/apps/openmw/mwstate/statemanagerimp.hpp b/apps/openmw/mwstate/statemanagerimp.hpp index 078a899b23..007a9b1369 100644 --- a/apps/openmw/mwstate/statemanagerimp.hpp +++ b/apps/openmw/mwstate/statemanagerimp.hpp @@ -24,6 +24,8 @@ namespace MWState ///< Start a new game. /// /// \param bypass Skip new game mechanics. + + virtual void endGame(); }; }