|
|
|
@ -187,31 +187,44 @@ MWWorld::ContainerStoreIterator MWWorld::ContainerStore::add(const std::string &
|
|
|
|
|
|
|
|
|
|
MWWorld::ContainerStoreIterator MWWorld::ContainerStore::add (const Ptr& itemPtr, int count, const Ptr& actorPtr, bool setOwner)
|
|
|
|
|
{
|
|
|
|
|
MWWorld::ContainerStoreIterator it = addImp(itemPtr, count);
|
|
|
|
|
MWWorld::Ptr item = *it;
|
|
|
|
|
|
|
|
|
|
// we may have copied an item from the world, so reset a few things first
|
|
|
|
|
item.getRefData().setBaseNode(NULL);
|
|
|
|
|
item.getCellRef().mPos.rot[0] = 0;
|
|
|
|
|
item.getCellRef().mPos.rot[1] = 0;
|
|
|
|
|
item.getCellRef().mPos.rot[2] = 0;
|
|
|
|
|
item.getCellRef().mPos.pos[0] = 0;
|
|
|
|
|
item.getCellRef().mPos.pos[1] = 0;
|
|
|
|
|
item.getCellRef().mPos.pos[2] = 0;
|
|
|
|
|
|
|
|
|
|
Ptr player = MWBase::Environment::get().getWorld ()->getPlayerPtr();
|
|
|
|
|
|
|
|
|
|
MWWorld::ContainerStoreIterator it = end();
|
|
|
|
|
|
|
|
|
|
if (setOwner && actorPtr.getClass().isActor())
|
|
|
|
|
{
|
|
|
|
|
// HACK: Set owner on the original item, then reset it after we have copied it
|
|
|
|
|
// If we set the owner on the copied item, it would not stack correctly...
|
|
|
|
|
std::string oldOwner = itemPtr.getCellRef().mOwner;
|
|
|
|
|
if (actorPtr == player)
|
|
|
|
|
{
|
|
|
|
|
// No point in setting owner to the player - NPCs will not respect this anyway
|
|
|
|
|
// Additionally, setting it to "player" would make those items not stack with items that don't have an owner
|
|
|
|
|
item.getCellRef().mOwner = "";
|
|
|
|
|
itemPtr.getCellRef().mOwner = "";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
item.getCellRef().mOwner = actorPtr.getCellRef().mRefID;
|
|
|
|
|
itemPtr.getCellRef().mOwner = actorPtr.getCellRef().mRefID;
|
|
|
|
|
|
|
|
|
|
it = addImp(itemPtr, count);
|
|
|
|
|
|
|
|
|
|
itemPtr.getCellRef().mOwner = oldOwner;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
it = addImp(itemPtr, count);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// The copy of the original item we just made
|
|
|
|
|
MWWorld::Ptr item = *it;
|
|
|
|
|
|
|
|
|
|
// we may have copied an item from the world, so reset a few things first
|
|
|
|
|
item.getRefData().setBaseNode(NULL); // Especially important, otherwise scripts on the item could think that it's actually in a cell
|
|
|
|
|
item.getCellRef().mPos.rot[0] = 0;
|
|
|
|
|
item.getCellRef().mPos.rot[1] = 0;
|
|
|
|
|
item.getCellRef().mPos.rot[2] = 0;
|
|
|
|
|
item.getCellRef().mPos.pos[0] = 0;
|
|
|
|
|
item.getCellRef().mPos.pos[1] = 0;
|
|
|
|
|
item.getCellRef().mPos.pos[2] = 0;
|
|
|
|
|
|
|
|
|
|
std::string script = MWWorld::Class::get(item).getScript(item);
|
|
|
|
|
if(script != "")
|
|
|
|
|