1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-02-21 09:09:43 +00:00

Make sure PathFinder::getClosestPoint is not called with failing precondition

Pathgrid should be not nullptr and points should be not empty.
This commit is contained in:
elsid 2021-09-23 01:47:19 +02:00
parent 14516b9fd6
commit d36595e09e
No known key found for this signature in database
GPG key ID: B845CB9FEE18AB40
2 changed files with 4 additions and 1 deletions

View file

@ -348,7 +348,7 @@ namespace MWMechanics
bool runFallback = true;
if (pathgrid && !actor.getClass().isPureWaterCreature(actor))
if (pathgrid != nullptr && !pathgrid->mPoints.empty() && !actor.getClass().isPureWaterCreature(actor))
{
ESM::Pathgrid::PointList points;
Misc::CoordinateConverter coords(storage.mCell->getCell());

View file

@ -758,6 +758,9 @@ namespace MWMechanics
const ESM::Pathgrid *pathgrid =
MWBase::Environment::get().getWorld()->getStore().get<ESM::Pathgrid>().search(*currentCell->getCell());
if (pathgrid == nullptr || pathgrid->mPoints.empty())
return;
int index = PathFinder::getClosestPoint(pathgrid, PathFinder::makeOsgVec3(dest));
getPathGridGraph(currentCell).getNeighbouringPoints(index, points);