Confiscate stolen goods: Support Mournhold prisons.

OMW Bug #1533
This commit is contained in:
Jordan Ayers 2015-02-14 16:09:17 -06:00
parent 5ef78903dc
commit 6d1aec6970

View file

@ -3071,28 +3071,29 @@ namespace MWWorld
void World::confiscateStolenItems(const Ptr &ptr) void World::confiscateStolenItems(const Ptr &ptr)
{ {
Ogre::Vector3 playerPos; MWWorld::Ptr prisonMarker = getClosestMarker( ptr, "prisonmarker" );
if (!findInteriorPositionInWorldSpace(ptr.getCell(), playerPos)) std::string prisonName = prisonMarker.mRef->mRef.getDestCell();
playerPos = mPlayer->getLastKnownExteriorPosition(); if ( prisonName.empty() )
{
std::cerr << "Failed to confiscate items: prison marker not linked to prison interior" << std::endl;
return;
}
MWWorld::CellStore *prison = getInterior( prisonName );
if ( !prison )
{
std::cerr << "Failed to confiscate items: failed to load cell " << prisonName << std::endl;
return;
}
MWWorld::Ptr closestChest; MWWorld::Ptr closestChest;
float closestDistance = FLT_MAX;
//Find closest stolen_goods chest MWWorld::CellRefList<ESM::Container>& containers = prison->get<ESM::Container>();
std::vector<MWWorld::Ptr> chests; CellRefList<ESM::Container>::List& refList = containers.mList;
mCells.getInteriorPtrs("stolen_goods", chests); for (CellRefList<ESM::Container>::List::iterator it = refList.begin(); it != refList.end(); ++it)
Ogre::Vector3 chestPos;
for (std::vector<MWWorld::Ptr>::iterator it = chests.begin(); it != chests.end(); ++it)
{ {
if (!findInteriorPositionInWorldSpace(it->getCell(), chestPos)) MWWorld::LiveCellRef<ESM::Container>& ref = *it;
continue; if ( ref.mRef.getRefId() == "stolen_goods" ) {
closestChest = MWWorld::Ptr( &ref, prison );
float distance = playerPos.squaredDistance(chestPos);
if (distance < closestDistance)
{
closestDistance = distance;
closestChest = *it;
} }
} }