Change stolen items handling to match MW (Fixes #1443, Fixes #2290)

celladd
scrawl 10 years ago
parent 2bf1dd8f46
commit aa6ebcd75c

@ -129,7 +129,9 @@ namespace MWBase
/// @return false if the attack was considered a "friendly hit" and forgiven /// @return false if the attack was considered a "friendly hit" and forgiven
virtual bool actorAttacked (const MWWorld::Ptr& victim, const MWWorld::Ptr& attacker) = 0; virtual bool actorAttacked (const MWWorld::Ptr& victim, const MWWorld::Ptr& attacker) = 0;
/// Utility to check if taking this item is illegal and calling commitCrime if so /// Utility to check if taking this item is illegal and calling commitCrime if so
virtual void itemTaken (const MWWorld::Ptr& ptr, const MWWorld::Ptr& item, int count) = 0; /// @param container The container the item is in; may be empty for an item in the world
virtual void itemTaken (const MWWorld::Ptr& ptr, const MWWorld::Ptr& item, const MWWorld::Ptr& container,
int count) = 0;
/// Utility to check if opening (i.e. unlocking) this object is illegal and calling commitCrime if so /// Utility to check if opening (i.e. unlocking) this object is illegal and calling commitCrime if so
virtual void objectOpened (const MWWorld::Ptr& ptr, const MWWorld::Ptr& item) = 0; virtual void objectOpened (const MWWorld::Ptr& ptr, const MWWorld::Ptr& item) = 0;
/// Attempt sleeping in a bed. If this is illegal, call commitCrime. /// Attempt sleeping in a bed. If this is illegal, call commitCrime.

@ -285,7 +285,7 @@ namespace MWGui
if (mPtr.getClass().isActor() && mPtr.getClass().getCreatureStats(mPtr).isDead()) if (mPtr.getClass().isActor() && mPtr.getClass().getCreatureStats(mPtr).isDead())
return true; return true;
else else
MWBase::Environment::get().getMechanicsManager()->itemTaken(player, item.mBase, count); MWBase::Environment::get().getMechanicsManager()->itemTaken(player, item.mBase, mPtr, count);
} }
return true; return true;
} }

@ -624,7 +624,7 @@ namespace MWGui
throw std::runtime_error("Added item not found"); throw std::runtime_error("Added item not found");
mDragAndDrop->startDrag(i, mSortModel, mTradeModel, mItemView, count); mDragAndDrop->startDrag(i, mSortModel, mTradeModel, mItemView, count);
MWBase::Environment::get().getMechanicsManager()->itemTaken(player, newObject, count); MWBase::Environment::get().getMechanicsManager()->itemTaken(player, newObject, MWWorld::Ptr(), count);
if (MWBase::Environment::get().getWindowManager()->getSpellWindow()) if (MWBase::Environment::get().getWindowManager()->getSpellWindow())
MWBase::Environment::get().getWindowManager()->getSpellWindow()->updateSpells(); MWBase::Environment::get().getWindowManager()->getSpellWindow()->updateSpells();

@ -936,11 +936,29 @@ namespace MWMechanics
commitCrime(ptr, victim, OT_Trespassing); commitCrime(ptr, victim, OT_Trespassing);
} }
void MechanicsManager::itemTaken(const MWWorld::Ptr &ptr, const MWWorld::Ptr &item, int count) void MechanicsManager::itemTaken(const MWWorld::Ptr &ptr, const MWWorld::Ptr &item, const MWWorld::Ptr& container,
int count)
{ {
MWWorld::Ptr victim; MWWorld::Ptr victim;
if (isAllowedToUse(ptr, item, victim))
return; if (!container.isEmpty())
{
// Inherit the owner of the container
if (isAllowedToUse(ptr, container, victim))
return;
}
else
{
if (isAllowedToUse(ptr, item, victim))
return;
if (!item.getCellRef().hasContentFile())
{
// this is a manually placed item, which means it was already stolen
return;
}
}
commitCrime(ptr, victim, OT_Theft, item.getClass().getValue(item) * count); commitCrime(ptr, victim, OT_Theft, item.getClass().getValue(item) * count);
} }

@ -121,7 +121,9 @@ namespace MWMechanics
/// @return false if the attack was considered a "friendly hit" and forgiven /// @return false if the attack was considered a "friendly hit" and forgiven
virtual bool actorAttacked (const MWWorld::Ptr& victim, const MWWorld::Ptr& attacker); virtual bool actorAttacked (const MWWorld::Ptr& victim, const MWWorld::Ptr& attacker);
/// Utility to check if taking this item is illegal and calling commitCrime if so /// Utility to check if taking this item is illegal and calling commitCrime if so
virtual void itemTaken (const MWWorld::Ptr& ptr, const MWWorld::Ptr& item, int count); /// @param container The container the item is in; may be empty for an item in the world
virtual void itemTaken (const MWWorld::Ptr& ptr, const MWWorld::Ptr& item, const MWWorld::Ptr& container,
int count);
/// Utility to check if opening (i.e. unlocking) this object is illegal and calling commitCrime if so /// Utility to check if opening (i.e. unlocking) this object is illegal and calling commitCrime if so
virtual void objectOpened (const MWWorld::Ptr& ptr, const MWWorld::Ptr& item); virtual void objectOpened (const MWWorld::Ptr& ptr, const MWWorld::Ptr& item);
/// Attempt sleeping in a bed. If this is illegal, call commitCrime. /// Attempt sleeping in a bed. If this is illegal, call commitCrime.

@ -16,7 +16,7 @@ namespace MWWorld
void ActionTake::executeImp (const Ptr& actor) void ActionTake::executeImp (const Ptr& actor)
{ {
MWBase::Environment::get().getMechanicsManager()->itemTaken( MWBase::Environment::get().getMechanicsManager()->itemTaken(
actor, getTarget(), getTarget().getRefData().getCount()); actor, getTarget(), MWWorld::Ptr(), getTarget().getRefData().getCount());
actor.getClass().getContainerStore (actor).add (getTarget(), getTarget().getRefData().getCount(), actor); actor.getClass().getContainerStore (actor).add (getTarget(), getTarget().getRefData().getCount(), actor);
MWBase::Environment::get().getWorld()->deleteObject (getTarget()); MWBase::Environment::get().getWorld()->deleteObject (getTarget());
} }

Loading…
Cancel
Save