forked from mirror/openmw-tes3mp
Correction to teleportation changes.
OMW Bug #2400 Related to OMW Bug #1533 Don't crash when finding the closest marker to an exterior position.
This commit is contained in:
parent
da9bd09a8c
commit
691ebd2372
2 changed files with 29 additions and 19 deletions
|
@ -2832,6 +2832,10 @@ namespace MWWorld
|
|||
|
||||
MWWorld::Ptr World::getClosestMarker( const MWWorld::Ptr &ptr, const std::string &id )
|
||||
{
|
||||
if ( ptr.getCell()->isExterior() ) {
|
||||
return getClosestMarkerFromExteriorPosition(mPlayer->getLastKnownExteriorPosition(), id);
|
||||
}
|
||||
|
||||
// Search for a 'nearest' marker, counting each cell between the starting
|
||||
// cell and the exterior as a distance of 1. If an exterior is found, jump
|
||||
// to the nearest exterior marker, without further interior searching.
|
||||
|
@ -2868,9 +2872,25 @@ namespace MWWorld
|
|||
if (ref.mRef.getDestCell().empty())
|
||||
{
|
||||
Ogre::Vector3 worldPos = Ogre::Vector3(ref.mRef.getDoorDest().pos);
|
||||
return getClosestMarkerFromExteriorPosition(worldPos, id);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string dest = ref.mRef.getDestCell();
|
||||
if ( !checkedCells.count(dest) && !currentCells.count(dest) )
|
||||
nextCells.insert(dest);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return MWWorld::Ptr();
|
||||
}
|
||||
|
||||
MWWorld::Ptr World::getClosestMarkerFromExteriorPosition( const Ogre::Vector3 worldPos, const std::string &id ) {
|
||||
MWWorld::Ptr closestMarker;
|
||||
float closestDistance = FLT_MAX;
|
||||
|
||||
MWWorld::Ptr closestMarker;
|
||||
std::vector<MWWorld::Ptr> markers;
|
||||
mCells.getExteriorPtrs(id, markers);
|
||||
for (std::vector<MWWorld::Ptr>::iterator it2 = markers.begin(); it2 != markers.end(); ++it2)
|
||||
|
@ -2888,18 +2908,7 @@ namespace MWWorld
|
|||
|
||||
return closestMarker;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string dest = ref.mRef.getDestCell();
|
||||
if ( !checkedCells.count(dest) && !currentCells.count(dest) )
|
||||
nextCells.insert(dest);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return MWWorld::Ptr();
|
||||
}
|
||||
|
||||
void World::teleportToClosestMarker (const MWWorld::Ptr& ptr,
|
||||
const std::string& id)
|
||||
|
|
|
@ -151,6 +151,7 @@ namespace MWWorld
|
|||
float feetToGameUnits(float feet);
|
||||
|
||||
MWWorld::Ptr getClosestMarker( const MWWorld::Ptr &ptr, const std::string &id );
|
||||
MWWorld::Ptr getClosestMarkerFromExteriorPosition( const Ogre::Vector3 worldPos, const std::string &id );
|
||||
|
||||
public:
|
||||
|
||||
|
|
Loading…
Reference in a new issue