mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-25 06:35:30 +00:00
some clean up for the cleanup code
This commit is contained in:
parent
35e8e23037
commit
5aea6ef80f
@ -17,6 +17,18 @@
|
||||
|
||||
#include "../mwmechanics/npcstats.hpp"
|
||||
|
||||
void MWState::StateManager::cleanup()
|
||||
{
|
||||
if (mState!=State_NoGame)
|
||||
{
|
||||
MWBase::Environment::get().getDialogueManager()->clear();
|
||||
MWBase::Environment::get().getJournal()->clear();
|
||||
mState = State_NoGame;
|
||||
mCharacterManager.clearCurrentCharacter();
|
||||
mTimePlayed = 0;
|
||||
}
|
||||
}
|
||||
|
||||
MWState::StateManager::StateManager (const boost::filesystem::path& saves, const std::string& game)
|
||||
: mQuitRequest (false), mState (State_NoGame), mCharacterManager (saves, game), mTimePlayed (0)
|
||||
{
|
||||
@ -40,18 +52,10 @@ MWState::StateManager::State MWState::StateManager::getState() const
|
||||
|
||||
void MWState::StateManager::newGame (bool bypass)
|
||||
{
|
||||
if (mState!=State_NoGame)
|
||||
{
|
||||
MWBase::Environment::get().getDialogueManager()->clear();
|
||||
MWBase::Environment::get().getJournal()->clear();
|
||||
mState = State_NoGame;
|
||||
mCharacterManager.clearCurrentCharacter();
|
||||
mTimePlayed = 0;
|
||||
}
|
||||
cleanup();
|
||||
|
||||
if (!bypass)
|
||||
{
|
||||
/// \todo extract cleanup code
|
||||
MWBase::Environment::get().getWorld()->startNewGame();
|
||||
MWBase::Environment::get().getWindowManager()->setNewGame (true);
|
||||
}
|
||||
@ -99,6 +103,9 @@ void MWState::StateManager::saveGame (const std::string& description, const Slot
|
||||
writer.startRecord ("SAVE");
|
||||
slot->mProfile.save (writer);
|
||||
writer.endRecord ("SAVE");
|
||||
|
||||
/// \todo write saved game data
|
||||
|
||||
writer.close();
|
||||
|
||||
Settings::Manager::setString ("character", "Saves",
|
||||
@ -107,13 +114,7 @@ void MWState::StateManager::saveGame (const std::string& description, const Slot
|
||||
|
||||
void MWState::StateManager::loadGame (const Character *character, const Slot *slot)
|
||||
{
|
||||
if (mState!=State_NoGame)
|
||||
{
|
||||
MWBase::Environment::get().getDialogueManager()->clear();
|
||||
MWBase::Environment::get().getJournal()->clear();
|
||||
mState = State_NoGame;
|
||||
mCharacterManager.clearCurrentCharacter();
|
||||
}
|
||||
cleanup();
|
||||
|
||||
mTimePlayed = slot->mProfile.mTimePlayed;
|
||||
|
||||
|
@ -16,6 +16,10 @@ namespace MWState
|
||||
CharacterManager mCharacterManager;
|
||||
double mTimePlayed;
|
||||
|
||||
private:
|
||||
|
||||
void cleanup();
|
||||
|
||||
public:
|
||||
|
||||
StateManager (const boost::filesystem::path& saves, const std::string& game);
|
||||
|
@ -290,7 +290,6 @@ namespace MWWorld
|
||||
pos.rot[2] = 0;
|
||||
mWorldScene->changeToExteriorCell(pos);
|
||||
|
||||
|
||||
// enable collision
|
||||
if(!mPhysics->toggleCollisionMode())
|
||||
mPhysics->toggleCollisionMode();
|
||||
@ -300,6 +299,7 @@ namespace MWWorld
|
||||
|
||||
// global variables
|
||||
delete mGlobalVariables;
|
||||
mGlobalVariables = 0;
|
||||
mGlobalVariables = new Globals (mStore);
|
||||
|
||||
// set new game mark
|
||||
@ -308,6 +308,7 @@ namespace MWWorld
|
||||
|
||||
// we don't want old weather to persist on a new game
|
||||
delete mWeatherManager;
|
||||
mWeatherManager = 0;
|
||||
mWeatherManager = new MWWorld::WeatherManager(mRendering,&mFallback);
|
||||
|
||||
MWBase::Environment::get().getScriptManager()->resetGlobalScripts();
|
||||
|
Loading…
x
Reference in New Issue
Block a user