1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-19 22:23:51 +00:00

Fix crash when stealing items with the owner not around (Fixes #1512)

This commit is contained in:
scrawl 2014-06-16 04:03:53 +02:00
parent 5f5c0c5bff
commit f935cfc6c9
2 changed files with 4 additions and 1 deletions

View file

@ -827,6 +827,8 @@ namespace MWMechanics
// NOTE: int arg can be from itemTaken() so DON'T modify it, since it is
// passed to reportCrime later on in this function.
// NOTE: victim may be empty
// Only player can commit crime
if (player.getRefData().getHandle() != "player")
return false;
@ -860,7 +862,7 @@ namespace MWMechanics
mActors.getObjectsInRange(from, radius, neighbors);
// victim should be considered even beyond alarm radius
if (from.squaredDistance(Ogre::Vector3(victim.getRefData().getPosition().pos)) > radius*radius)
if (!victim.isEmpty() && from.squaredDistance(Ogre::Vector3(victim.getRefData().getPosition().pos)) > radius*radius)
neighbors.push_back(victim);
int id = MWBase::Environment::get().getWorld()->getPlayer().getNewCrimeId();

View file

@ -111,6 +111,7 @@ namespace MWMechanics
/**
* @brief Commit a crime. If any actors witness the crime and report it,
* reportCrime will be called automatically.
* @note victim may be empty
* @param arg Depends on \a type, e.g. for Theft, the value of the item that was stolen.
* @return was the crime reported?
*/