refactored cell unloading

actorid
Marc Zinnschlag 15 years ago
parent b8fee8f1ee
commit fe3b6230fc

@ -250,6 +250,29 @@ namespace MWWorld
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,
const std::string& master, bool newGame, Environment& environment)
: mSkyManager (0), mScene (renderer), mPlayerPos (0), mCurrentCell (0), mGlobalVariables (0),
@ -532,15 +555,10 @@ namespace MWWorld
if (active!=mActiveCells.end())
{
mEnvironment.mMechanicsManager->dropActors (active->first);
active->second->destroy();
mEnvironment.mSoundManager->stopSound (active->first);
delete active->second;
mActiveCells.erase (active);
unloadCell (active);
}
// register local scripts
mLocalScripts.clear(); // FIXME won't work with exteriors
insertInteriorScripts (*cell);
// adjust player
@ -585,15 +603,10 @@ namespace MWWorld
if (active!=mActiveCells.end())
{
mEnvironment.mMechanicsManager->dropActors (active->first);
active->second->destroy();
mEnvironment.mSoundManager->stopSound (active->first);
delete active->second;
mActiveCells.erase (active);
unloadCell (active);
}
// register local scripts
mLocalScripts.clear(); // FIXME won't work with exteriors
insertInteriorScripts (*cell);
// adjust player

@ -41,7 +41,7 @@ namespace MWWorld
{
public:
typedef std::vector<std::pair<std::string, Ptr> > ScriptList;
typedef std::list<std::pair<std::string, Ptr> > ScriptList;
private:
@ -77,6 +77,10 @@ namespace MWWorld
int getDaysPerMonth (int month) const;
void removeScripts (Ptr::CellStore *cell);
void unloadCell (CellRenderCollection::iterator iter);
public:
World (OEngine::Render::OgreRenderer& renderer, const boost::filesystem::path& master,

Loading…
Cancel
Save