mirror of
https://github.com/TES3MP/TES3MP.git
synced 2025-09-30 08:35:52 -04:00
refactored cell unloading
This commit is contained in:
parent
b8fee8f1ee
commit
fe3b6230fc
@ -250,6 +250,29 @@ namespace MWWorld
|
|||||||
throw std::runtime_error ("month out of range");
|
throw std::runtime_error ("month out of range");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void World::removeScripts (Ptr::CellStore *cell)
|
||||||
|
{
|
||||||
|
ScriptList::iterator iter = mLocalScripts.begin();
|
||||||
|
|
||||||
|
while (iter!=mLocalScripts.end())
|
||||||
|
{
|
||||||
|
if (iter->second.getCell()==cell)
|
||||||
|
mLocalScripts.erase (iter++);
|
||||||
|
else
|
||||||
|
++iter;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void World::unloadCell (CellRenderCollection::iterator iter)
|
||||||
|
{
|
||||||
|
removeScripts (iter->first);
|
||||||
|
mEnvironment.mMechanicsManager->dropActors (iter->first);
|
||||||
|
iter->second->destroy();
|
||||||
|
mEnvironment.mSoundManager->stopSound (iter->first);
|
||||||
|
delete iter->second;
|
||||||
|
mActiveCells.erase (iter);
|
||||||
|
}
|
||||||
|
|
||||||
World::World (OEngine::Render::OgreRenderer& renderer, const boost::filesystem::path& dataDir,
|
World::World (OEngine::Render::OgreRenderer& renderer, const boost::filesystem::path& dataDir,
|
||||||
const std::string& master, bool newGame, Environment& environment)
|
const std::string& master, bool newGame, Environment& environment)
|
||||||
: mSkyManager (0), mScene (renderer), mPlayerPos (0), mCurrentCell (0), mGlobalVariables (0),
|
: mSkyManager (0), mScene (renderer), mPlayerPos (0), mCurrentCell (0), mGlobalVariables (0),
|
||||||
@ -532,15 +555,10 @@ namespace MWWorld
|
|||||||
|
|
||||||
if (active!=mActiveCells.end())
|
if (active!=mActiveCells.end())
|
||||||
{
|
{
|
||||||
mEnvironment.mMechanicsManager->dropActors (active->first);
|
unloadCell (active);
|
||||||
active->second->destroy();
|
|
||||||
mEnvironment.mSoundManager->stopSound (active->first);
|
|
||||||
delete active->second;
|
|
||||||
mActiveCells.erase (active);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// register local scripts
|
// register local scripts
|
||||||
mLocalScripts.clear(); // FIXME won't work with exteriors
|
|
||||||
insertInteriorScripts (*cell);
|
insertInteriorScripts (*cell);
|
||||||
|
|
||||||
// adjust player
|
// adjust player
|
||||||
@ -585,15 +603,10 @@ namespace MWWorld
|
|||||||
|
|
||||||
if (active!=mActiveCells.end())
|
if (active!=mActiveCells.end())
|
||||||
{
|
{
|
||||||
mEnvironment.mMechanicsManager->dropActors (active->first);
|
unloadCell (active);
|
||||||
active->second->destroy();
|
|
||||||
mEnvironment.mSoundManager->stopSound (active->first);
|
|
||||||
delete active->second;
|
|
||||||
mActiveCells.erase (active);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// register local scripts
|
// register local scripts
|
||||||
mLocalScripts.clear(); // FIXME won't work with exteriors
|
|
||||||
insertInteriorScripts (*cell);
|
insertInteriorScripts (*cell);
|
||||||
|
|
||||||
// adjust player
|
// adjust player
|
||||||
|
@ -41,7 +41,7 @@ namespace MWWorld
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
typedef std::vector<std::pair<std::string, Ptr> > ScriptList;
|
typedef std::list<std::pair<std::string, Ptr> > ScriptList;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
@ -77,6 +77,10 @@ namespace MWWorld
|
|||||||
|
|
||||||
int getDaysPerMonth (int month) const;
|
int getDaysPerMonth (int month) const;
|
||||||
|
|
||||||
|
void removeScripts (Ptr::CellStore *cell);
|
||||||
|
|
||||||
|
void unloadCell (CellRenderCollection::iterator iter);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
World (OEngine::Render::OgreRenderer& renderer, const boost::filesystem::path& master,
|
World (OEngine::Render::OgreRenderer& renderer, const boost::filesystem::path& master,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user