From 2eaceb71bab24c55fa171b97f678887ee2c50919 Mon Sep 17 00:00:00 2001 From: scrawl Date: Wed, 17 Sep 2014 12:39:10 +0200 Subject: [PATCH] Reject AiTravel destinations further than 7168 units away, as in vanilla MW (Fixes #1911) --- apps/openmw/mwmechanics/aitravel.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/apps/openmw/mwmechanics/aitravel.cpp b/apps/openmw/mwmechanics/aitravel.cpp index 3fd4704d9..7278e74f2 100644 --- a/apps/openmw/mwmechanics/aitravel.cpp +++ b/apps/openmw/mwmechanics/aitravel.cpp @@ -1,5 +1,7 @@ #include "aitravel.hpp" +#include + #include #include "../mwbase/world.hpp" @@ -70,6 +72,12 @@ namespace MWMechanics } } + // Maximum travel distance for vanilla compatibility. + // Was likely meant to prevent NPCs walking into non-loaded exterior cells, but for some reason is used in interior cells as well. + // We can make this configurable at some point, but the default *must* be the below value. Anything else will break shoddily-written content (*cough* MW *cough*) in bizarre ways. + if (Ogre::Vector3(mX, mY, mZ).squaredDistance(Ogre::Vector3(pos.pos)) > 7168*7168) + return false; + bool cellChange = cell->mData.mX != mCellX || cell->mData.mY != mCellY; if(!mPathFinder.isPathConstructed() || cellChange) {