Fixed issue which may occur if there's no evidence chest nearby

actorid
Thomas 11 years ago
parent f6deca7c80
commit ee581f593b

@ -2695,6 +2695,7 @@ namespace MWWorld
MWWorld::Ptr closestChest; MWWorld::Ptr closestChest;
float closestDistance = FLT_MAX; float closestDistance = FLT_MAX;
//Find closest stolen_goods chest
std::vector<MWWorld::Ptr> chests; std::vector<MWWorld::Ptr> chests;
mCells.getInteriorPtrs("stolen_goods", chests); mCells.getInteriorPtrs("stolen_goods", chests);
@ -2712,20 +2713,20 @@ namespace MWWorld
} }
} }
if (!closestChest.isEmpty()) if (!closestChest.isEmpty()) //Found a close chest
{ {
ContainerStore& store = ptr.getClass().getContainerStore(ptr); ContainerStore& store = ptr.getClass().getContainerStore(ptr);
for (ContainerStoreIterator it = store.begin(); it != store.end(); ++it) for (ContainerStoreIterator it = store.begin(); it != store.end(); ++it) //Move all stolen stuff into chest
{ {
if (!it->getCellRef().mOwner.empty() && it->getCellRef().mOwner != "player") if (!it->getCellRef().mOwner.empty() && it->getCellRef().mOwner != "player") //Not owned by no one/player?
{ {
closestChest.getClass().getContainerStore(closestChest).add(*it, it->getRefData().getCount(), closestChest); closestChest.getClass().getContainerStore(closestChest).add(*it, it->getRefData().getCount(), closestChest);
store.remove(*it, it->getRefData().getCount(), ptr); store.remove(*it, it->getRefData().getCount(), ptr);
} }
} }
}
closestChest.getCellRef().mLockLevel = abs(closestChest.getCellRef().mLockLevel); closestChest.getCellRef().mLockLevel = abs(closestChest.getCellRef().mLockLevel);
} }
}
void World::goToJail() void World::goToJail()
{ {

Loading…
Cancel
Save