From 929fc68160a031e17d419af74ed6354bef895dd9 Mon Sep 17 00:00:00 2001 From: Capostrophic Date: Mon, 26 Feb 2018 23:21:51 +0300 Subject: [PATCH 1/3] Consider items with dead owner not stolen (fixes bug #4328) --- apps/openmw/mwmechanics/mechanicsmanagerimp.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp index bd5fa1b11..cd3cd1f80 100644 --- a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp +++ b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp @@ -1118,8 +1118,11 @@ namespace MWMechanics Misc::StringUtils::lowerCaseInPlace(owner.first); if (!Misc::StringUtils::ciEqual(item.getCellRef().getRefId(), MWWorld::ContainerStore::sGoldId)) - mStolenItems[Misc::StringUtils::lowerCase(item.getCellRef().getRefId())][owner] += count; - + { + const MWWorld::Ptr victimRef = MWBase::Environment::get().getWorld()->searchPtr(item.getCellRef().getOwner(), true); + if (!victimRef.getClass().getCreatureStats(victimRef).isDead()) + mStolenItems[Misc::StringUtils::lowerCase(item.getCellRef().getRefId())][owner] += count; + } if (alarm) commitCrime(ptr, victim, OT_Theft, item.getClass().getValue(item) * count); } From cc0c6ddaa6aed5c93f83597a58d12fbacba34d46 Mon Sep 17 00:00:00 2001 From: Capostrophic Date: Wed, 28 Feb 2018 14:04:56 +0300 Subject: [PATCH 2/3] Account for empty victimRef (Bug #4328) --- apps/openmw/mwmechanics/mechanicsmanagerimp.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp index cd3cd1f80..be5125a2b 100644 --- a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp +++ b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp @@ -1120,7 +1120,7 @@ namespace MWMechanics if (!Misc::StringUtils::ciEqual(item.getCellRef().getRefId(), MWWorld::ContainerStore::sGoldId)) { const MWWorld::Ptr victimRef = MWBase::Environment::get().getWorld()->searchPtr(item.getCellRef().getOwner(), true); - if (!victimRef.getClass().getCreatureStats(victimRef).isDead()) + if (victimRef.isEmpty() || !victimRef.getClass().getCreatureStats(victimRef).isDead()) mStolenItems[Misc::StringUtils::lowerCase(item.getCellRef().getRefId())][owner] += count; } if (alarm) From d371bebb333c419c0c5589bfca090410eb25a1be Mon Sep 17 00:00:00 2001 From: Capostrophic Date: Fri, 2 Mar 2018 21:10:05 +0300 Subject: [PATCH 3/3] Prevent items in a container owned by a dead actor from being counted as stolen (Bug #4328) --- apps/openmw/mwmechanics/mechanicsmanagerimp.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp index be5125a2b..225427829 100644 --- a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp +++ b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp @@ -1119,7 +1119,7 @@ namespace MWMechanics if (!Misc::StringUtils::ciEqual(item.getCellRef().getRefId(), MWWorld::ContainerStore::sGoldId)) { - const MWWorld::Ptr victimRef = MWBase::Environment::get().getWorld()->searchPtr(item.getCellRef().getOwner(), true); + const MWWorld::Ptr victimRef = MWBase::Environment::get().getWorld()->searchPtr(ownerCellRef->getOwner(), true); if (victimRef.isEmpty() || !victimRef.getClass().getCreatureStats(victimRef).isDead()) mStolenItems[Misc::StringUtils::lowerCase(item.getCellRef().getRefId())][owner] += count; }