forked from mirror/openmw-tes3mp
Consider faction ownerships in item stolen checks (fixes #4293)
This commit is contained in:
parent
cfdf99f601
commit
191cc76378
5 changed files with 11 additions and 8 deletions
|
@ -239,7 +239,7 @@ namespace MWBase
|
|||
virtual std::vector<std::pair<std::string, int> > getStolenItemOwners(const std::string& itemid) = 0;
|
||||
|
||||
/// Has the player stolen this item from the given owner?
|
||||
virtual bool isItemStolenFrom(const std::string& itemid, const std::string& ownerid) = 0;
|
||||
virtual bool isItemStolenFrom(const std::string& itemid, const MWWorld::Ptr& ptr) = 0;
|
||||
|
||||
virtual bool isBoundItem(const MWWorld::Ptr& item) = 0;
|
||||
virtual bool isAllowedToUse (const MWWorld::Ptr& ptr, const MWWorld::Ptr& target, MWWorld::Ptr& victim) = 0;
|
||||
|
|
|
@ -339,8 +339,7 @@ namespace MWGui
|
|||
for (int i=0; i<2; ++i)
|
||||
{
|
||||
MWWorld::Ptr item = (i == 0) ? mEnchanting.getOldItem() : mEnchanting.getGem();
|
||||
if (MWBase::Environment::get().getMechanicsManager()->isItemStolenFrom(item.getCellRef().getRefId(),
|
||||
mPtr.getCellRef().getRefId()))
|
||||
if (MWBase::Environment::get().getMechanicsManager()->isItemStolenFrom(item.getCellRef().getRefId(), mPtr))
|
||||
{
|
||||
std::string msg = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("sNotifyMessage49")->getString();
|
||||
if (msg.find("%s") != std::string::npos)
|
||||
|
|
|
@ -311,8 +311,7 @@ namespace MWGui
|
|||
// check if the player is attempting to sell back an item stolen from this actor
|
||||
for (std::vector<ItemStack>::iterator it = merchantBought.begin(); it != merchantBought.end(); ++it)
|
||||
{
|
||||
if (MWBase::Environment::get().getMechanicsManager()->isItemStolenFrom(it->mBase.getCellRef().getRefId(),
|
||||
mPtr.getCellRef().getRefId()))
|
||||
if (MWBase::Environment::get().getMechanicsManager()->isItemStolenFrom(it->mBase.getCellRef().getRefId(), mPtr))
|
||||
{
|
||||
std::string msg = gmst.find("sNotifyMessage49")->getString();
|
||||
if (msg.find("%s") != std::string::npos)
|
||||
|
|
|
@ -992,14 +992,19 @@ namespace MWMechanics
|
|||
}
|
||||
}
|
||||
|
||||
bool MechanicsManager::isItemStolenFrom(const std::string &itemid, const std::string &ownerid)
|
||||
bool MechanicsManager::isItemStolenFrom(const std::string &itemid, const MWWorld::Ptr& ptr)
|
||||
{
|
||||
StolenItemsMap::const_iterator it = mStolenItems.find(Misc::StringUtils::lowerCase(itemid));
|
||||
if (it == mStolenItems.end())
|
||||
return false;
|
||||
|
||||
const OwnerMap& owners = it->second;
|
||||
const std::string ownerid = ptr.getCellRef().getRefId();
|
||||
const std::string factionid = ptr.getClass().getPrimaryFaction(ptr);
|
||||
OwnerMap::const_iterator ownerFound = owners.find(std::make_pair(Misc::StringUtils::lowerCase(ownerid), false));
|
||||
return ownerFound != owners.end();
|
||||
OwnerMap::const_iterator factionOwnerFound = owners.find(std::make_pair(Misc::StringUtils::lowerCase(factionid), true));
|
||||
|
||||
return ownerFound != owners.end() || factionOwnerFound != owners.end();
|
||||
}
|
||||
|
||||
void MechanicsManager::confiscateStolenItemToOwner(const MWWorld::Ptr &player, const MWWorld::Ptr &item, const MWWorld::Ptr& victim, int count)
|
||||
|
|
|
@ -205,7 +205,7 @@ namespace MWMechanics
|
|||
virtual std::vector<std::pair<std::string, int> > getStolenItemOwners(const std::string& itemid);
|
||||
|
||||
/// Has the player stolen this item from the given owner?
|
||||
virtual bool isItemStolenFrom(const std::string& itemid, const std::string& ownerid);
|
||||
virtual bool isItemStolenFrom(const std::string& itemid, const MWWorld::Ptr& ptr);
|
||||
|
||||
virtual bool isBoundItem(const MWWorld::Ptr& item);
|
||||
|
||||
|
|
Loading…
Reference in a new issue