1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-25 06:35:30 +00:00

Move some deleteObject logic from OpDelete to MWWorld::deleteObject

This commit is contained in:
Emanuel Guevel 2013-10-16 18:39:29 +02:00
parent 2786530430
commit 8ff747fbef
2 changed files with 6 additions and 16 deletions

View File

@ -512,18 +512,7 @@ namespace MWScript
runtime.pop();
if (parameter == 1)
{
if (ptr.isInCell())
MWBase::Environment::get().getWorld()->deleteObject (ptr);
else
{
MWWorld::ContainerStore* store = ptr.getContainerStore();
if (store != NULL)
store->remove(ptr, ptr.getRefData().getCount(), ptr);
else
ptr.getRefData().setCount(0);
}
}
MWBase::Environment::get().getWorld()->deleteObject(ptr);
}
};

View File

@ -837,12 +837,13 @@ namespace MWWorld
void World::deleteObject (const Ptr& ptr)
{
if (ptr.getRefData().getCount()>0)
if (ptr.getRefData().getCount() > 0)
{
ptr.getRefData().setCount (0);
ptr.getRefData().setCount(0);
if (mWorldScene->getActiveCells().find (ptr.getCell())!=mWorldScene->getActiveCells().end() &&
ptr.getRefData().isEnabled())
if (ptr.isInCell()
&& mWorldScene->getActiveCells().find(ptr.getCell()) != mWorldScene->getActiveCells().end()
&& ptr.getRefData().isEnabled())
{
mWorldScene->removeObjectFromScene (ptr);
mLocalScripts.remove (ptr);