mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-21 09:53:52 +00:00
objects scripts are now stopped when they are removed from a container
This commit is contained in:
parent
d4ca954d47
commit
c138e00aa2
6 changed files with 35 additions and 0 deletions
|
@ -45,6 +45,7 @@ namespace MWWorld
|
|||
class Ptr;
|
||||
class TimeStamp;
|
||||
class ESMStore;
|
||||
class RefData;
|
||||
}
|
||||
|
||||
namespace MWBase
|
||||
|
@ -138,6 +139,9 @@ namespace MWBase
|
|||
|
||||
virtual std::string getCurrentCellName() const = 0;
|
||||
|
||||
virtual void removeRefScript (MWWorld::RefData *ref) = 0;
|
||||
//< Remove the script attached to ref from mLocalScripts
|
||||
|
||||
virtual MWWorld::Ptr getPtr (const std::string& name, bool activeOnly) = 0;
|
||||
///< Return a pointer to a liveCellRef with the given name.
|
||||
/// \param activeOnly do non search inactive cells.
|
||||
|
|
|
@ -146,6 +146,20 @@ void MWWorld::LocalScripts::clearCell (Ptr::CellStore *cell)
|
|||
}
|
||||
}
|
||||
|
||||
void MWWorld::LocalScripts::remove (RefData *ref)
|
||||
{
|
||||
for (std::list<std::pair<std::string, Ptr> >::iterator iter = mScripts.begin();
|
||||
iter!=mScripts.end(); ++iter)
|
||||
if (&(iter->second.getRefData()) == ref)
|
||||
{
|
||||
if (iter==mIter)
|
||||
++mIter;
|
||||
|
||||
mScripts.erase (iter);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void MWWorld::LocalScripts::remove (const Ptr& ptr)
|
||||
{
|
||||
for (std::list<std::pair<std::string, Ptr> >::iterator iter = mScripts.begin();
|
||||
|
|
|
@ -10,6 +10,7 @@ namespace MWWorld
|
|||
{
|
||||
struct ESMStore;
|
||||
class CellStore;
|
||||
class RefData;
|
||||
|
||||
/// \brief List of active local scripts
|
||||
class LocalScripts
|
||||
|
@ -47,6 +48,8 @@ namespace MWWorld
|
|||
|
||||
void clearCell (CellStore *cell);
|
||||
///< Remove all scripts belonging to \a cell.
|
||||
|
||||
void remove (RefData *ref);
|
||||
|
||||
void remove (const Ptr& ptr);
|
||||
///< Remove script for given reference (ignored if reference does not have a scirpt listed).
|
||||
|
|
|
@ -6,6 +6,9 @@
|
|||
#include "customdata.hpp"
|
||||
#include "cellstore.hpp"
|
||||
|
||||
#include "../mwbase/environment.hpp"
|
||||
#include "../mwbase/world.hpp"
|
||||
|
||||
namespace MWWorld
|
||||
{
|
||||
void RefData::copy (const RefData& refData)
|
||||
|
@ -107,6 +110,9 @@ namespace MWWorld
|
|||
|
||||
void RefData::setCount (int count)
|
||||
{
|
||||
if(count == 0)
|
||||
MWBase::Environment::get().getWorld()->removeRefScript(this);
|
||||
|
||||
mCount = count;
|
||||
}
|
||||
|
||||
|
|
|
@ -341,6 +341,11 @@ namespace MWWorld
|
|||
return name;
|
||||
}
|
||||
|
||||
void World::removeRefScript (MWWorld::RefData *ref)
|
||||
{
|
||||
mLocalScripts.remove (ref);
|
||||
}
|
||||
|
||||
Ptr World::getPtr (const std::string& name, bool activeOnly)
|
||||
{
|
||||
// the player is always in an active cell.
|
||||
|
|
|
@ -172,6 +172,9 @@ namespace MWWorld
|
|||
virtual std::vector<std::string> getGlobals () const;
|
||||
|
||||
virtual std::string getCurrentCellName () const;
|
||||
|
||||
virtual void removeRefScript (MWWorld::RefData *ref);
|
||||
//< Remove the script attached to ref from mLocalScripts
|
||||
|
||||
virtual Ptr getPtr (const std::string& name, bool activeOnly);
|
||||
///< Return a pointer to a liveCellRef with the given name.
|
||||
|
|
Loading…
Reference in a new issue