forked from teamnwah/openmw-tes3coop
first round of cleaning up world cleanup
This commit is contained in:
parent
63721682f6
commit
537b2efe8e
6 changed files with 38 additions and 20 deletions
|
@ -96,6 +96,8 @@ namespace MWBase
|
|||
|
||||
virtual void startNewGame() = 0;
|
||||
|
||||
virtual void clear() = 0;
|
||||
|
||||
virtual OEngine::Render::Fader* getFader() = 0;
|
||||
///< \ŧodo remove this function. Rendering details should not be exposed.
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ void MWState::StateManager::cleanup()
|
|||
{
|
||||
MWBase::Environment::get().getDialogueManager()->clear();
|
||||
MWBase::Environment::get().getJournal()->clear();
|
||||
MWBase::Environment::get().getWorld()->clear();
|
||||
mState = State_NoGame;
|
||||
mCharacterManager.clearCurrentCharacter();
|
||||
mTimePlayed = 0;
|
||||
|
|
|
@ -32,6 +32,17 @@ namespace MWWorld
|
|||
mCustomData = 0;
|
||||
}
|
||||
|
||||
RefData::RefData()
|
||||
: mBaseNode(0), mHasLocals (false), mEnabled (true), mCount (1), mCustomData (0)
|
||||
{
|
||||
for (int i=0; i<3; ++i)
|
||||
{
|
||||
mLocalRotation.rot[i] = 0;
|
||||
mPosition.pos[i] = 0;
|
||||
mPosition.rot[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
RefData::RefData (const ESM::CellRef& cellRef)
|
||||
: mBaseNode(0), mHasLocals (false), mEnabled (true), mCount (1), mPosition (cellRef.mPos),
|
||||
mCustomData (0)
|
||||
|
@ -88,7 +99,7 @@ namespace MWWorld
|
|||
static const std::string empty;
|
||||
return empty;
|
||||
}
|
||||
|
||||
|
||||
return mBaseNode->getName();
|
||||
}
|
||||
|
||||
|
@ -120,7 +131,7 @@ namespace MWWorld
|
|||
{
|
||||
if(count == 0)
|
||||
MWBase::Environment::get().getWorld()->removeRefScript(this);
|
||||
|
||||
|
||||
mCount = count;
|
||||
}
|
||||
|
||||
|
|
|
@ -48,6 +48,8 @@ namespace MWWorld
|
|||
|
||||
public:
|
||||
|
||||
RefData();
|
||||
|
||||
/// @param cellRef Used to copy constant data such as position into this class where it can
|
||||
/// be altered without effecting the original data. This makes it possible
|
||||
/// to reset the position as the orignal data is still held in the CellRef
|
||||
|
|
|
@ -258,26 +258,12 @@ namespace MWWorld
|
|||
|
||||
void World::startNewGame()
|
||||
{
|
||||
mWorldScene->changeToVoid();
|
||||
|
||||
mStore.clearDynamic();
|
||||
mStore.setUp();
|
||||
|
||||
mCells.clear();
|
||||
|
||||
// Rebuild player
|
||||
setupPlayer();
|
||||
MWWorld::Ptr player = mPlayer->getPlayer();
|
||||
|
||||
// removes NpcStats, ContainerStore etc
|
||||
player.getRefData().setCustomData(NULL);
|
||||
|
||||
renderPlayer();
|
||||
mRendering->resetCamera();
|
||||
|
||||
// make sure to do this so that local scripts from items that were in the players inventory are removed
|
||||
mLocalScripts.clear();
|
||||
|
||||
MWBase::Environment::get().getWindowManager()->updatePlayer();
|
||||
|
||||
ESM::Position pos;
|
||||
|
@ -290,10 +276,6 @@ namespace MWWorld
|
|||
pos.rot[2] = 0;
|
||||
mWorldScene->changeToExteriorCell(pos);
|
||||
|
||||
// enable collision
|
||||
if(!mPhysics->toggleCollisionMode())
|
||||
mPhysics->toggleCollisionMode();
|
||||
|
||||
// FIXME: should be set to 1, but the sound manager won't pause newly started sounds
|
||||
mPlayIntro = 2;
|
||||
|
||||
|
@ -314,6 +296,24 @@ namespace MWWorld
|
|||
MWBase::Environment::get().getScriptManager()->resetGlobalScripts();
|
||||
}
|
||||
|
||||
void World::clear()
|
||||
{
|
||||
mLocalScripts.clear();
|
||||
|
||||
// enable collision
|
||||
if (!mPhysics->toggleCollisionMode())
|
||||
mPhysics->toggleCollisionMode();
|
||||
|
||||
mWorldScene->changeToVoid();
|
||||
|
||||
if (mPlayer)
|
||||
mPlayer->getPlayer().getRefData() = RefData();
|
||||
|
||||
mStore.clearDynamic();
|
||||
mStore.setUp();
|
||||
|
||||
mCells.clear();
|
||||
}
|
||||
|
||||
void World::ensureNeededRecords()
|
||||
{
|
||||
|
|
|
@ -160,6 +160,8 @@ namespace MWWorld
|
|||
|
||||
virtual void startNewGame();
|
||||
|
||||
virtual void clear();
|
||||
|
||||
virtual OEngine::Render::Fader* getFader();
|
||||
///< \ŧodo remove this function. Rendering details should not be exposed.
|
||||
|
||||
|
|
Loading…
Reference in a new issue