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

deque
scrawl 11 years ago
parent 5f5c0c5bff
commit f935cfc6c9

@ -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();

@ -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?
*/

Loading…
Cancel
Save