objects with scripts attached, that are inside containers will behave correctly when the container is moved

This commit is contained in:
Tom Mason 2013-01-20 17:01:30 +00:00
parent 23dada0ee4
commit 31c71c029d

View file

@ -685,6 +685,7 @@ namespace MWWorld
{ {
mWorldScene->removeObjectFromScene (ptr); mWorldScene->removeObjectFromScene (ptr);
mLocalScripts.remove (ptr); mLocalScripts.remove (ptr);
removeContainerScripts (ptr);
} }
} }
} }
@ -698,6 +699,8 @@ namespace MWWorld
CellStore *currCell = ptr.getCell(); CellStore *currCell = ptr.getCell();
bool isPlayer = ptr == mPlayer->getPlayer(); bool isPlayer = ptr == mPlayer->getPlayer();
bool haveToMove = mWorldScene->isCellActive(*currCell) || isPlayer; bool haveToMove = mWorldScene->isCellActive(*currCell) || isPlayer;
removeContainerScripts(ptr);
if (*currCell != newCell) if (*currCell != newCell)
{ {
@ -725,6 +728,8 @@ namespace MWWorld
MWWorld::Ptr copy = MWWorld::Ptr copy =
MWWorld::Class::get(ptr).copyToCell(ptr, newCell); MWWorld::Class::get(ptr).copyToCell(ptr, newCell);
addContainerScripts(copy, &newCell);
mRendering->moveObjectToCell(copy, vec, currCell); mRendering->moveObjectToCell(copy, vec, currCell);
if (MWWorld::Class::get(ptr).isActor()) if (MWWorld::Class::get(ptr).isActor())
@ -1333,6 +1338,7 @@ namespace MWWorld
if (!script.empty()) { if (!script.empty()) {
mLocalScripts.add(script, dropped); mLocalScripts.add(script, dropped);
} }
addContainerScripts(dropped, &cell);
} }
} }