mirror of
https://github.com/OpenMW/openmw.git
synced 2025-03-26 22:40:25 +00:00
Fix container scripts not getting removed properly on cell change
Broken by f99eda1a54
This commit is contained in:
parent
56ff399f30
commit
42ea43c3d1
1 changed files with 16 additions and 12 deletions
|
@ -229,23 +229,27 @@ MWWorld::ContainerStoreIterator MWWorld::ContainerStore::add (const Ptr& itemPtr
|
||||||
std::string script = item.getClass().getScript(item);
|
std::string script = item.getClass().getScript(item);
|
||||||
if(script != "")
|
if(script != "")
|
||||||
{
|
{
|
||||||
CellStore *cell;
|
if (actorPtr == player)
|
||||||
|
{
|
||||||
|
// Items in player's inventory have cell set to 0, so their scripts will never be removed
|
||||||
|
item.mCell = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Set mCell to the cell of the container/actor, so that the scripts are removed properly when
|
||||||
|
// the cell of the container/actor goes inactive
|
||||||
|
item.mCell = actorPtr.getCell();
|
||||||
|
}
|
||||||
|
|
||||||
|
item.mContainerStore = 0;
|
||||||
|
|
||||||
MWBase::Environment::get().getWorld()->getLocalScripts().add(script, item);
|
MWBase::Environment::get().getWorld()->getLocalScripts().add(script, item);
|
||||||
|
|
||||||
if(&(player.getClass().getContainerStore (player)) == this)
|
|
||||||
{
|
|
||||||
cell = 0; // Items in player's inventory have cell set to 0, so their scripts will never be removed
|
|
||||||
|
|
||||||
// Set OnPCAdd special variable, if it is declared
|
// Set OnPCAdd special variable, if it is declared
|
||||||
|
// Make sure to do this *after* we have added the script to LocalScripts
|
||||||
|
if (actorPtr == player)
|
||||||
item.getRefData().getLocals().setVarByInt(script, "onpcadd", 1);
|
item.getRefData().getLocals().setVarByInt(script, "onpcadd", 1);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
cell = player.getCell();
|
|
||||||
|
|
||||||
item.mCell = cell;
|
|
||||||
item.mContainerStore = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return it;
|
return it;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue