From 4e678ce6b30328ab343a91d41e59a775672ac3fa Mon Sep 17 00:00:00 2001
From: scrawl <scrawl@baseoftrash.de>
Date: Sun, 6 Dec 2015 23:32:20 +0100
Subject: [PATCH] Handle mCellId in AiEscort

---
 apps/openmw/mwmechanics/aiescort.cpp | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/apps/openmw/mwmechanics/aiescort.cpp b/apps/openmw/mwmechanics/aiescort.cpp
index f75fc22ad..484eab6fe 100644
--- a/apps/openmw/mwmechanics/aiescort.cpp
+++ b/apps/openmw/mwmechanics/aiescort.cpp
@@ -1,12 +1,14 @@
 #include "aiescort.hpp"
 
 #include <components/esm/aisequence.hpp>
+#include <components/esm/loadcell.hpp>
 
 #include "../mwbase/world.hpp"
 #include "../mwbase/environment.hpp"
 #include "../mwbase/mechanicsmanager.hpp"
 
 #include "../mwworld/class.hpp"
+#include "../mwworld/cellstore.hpp"
 
 #include "../mwmechanics/creaturestats.hpp"
 
@@ -73,6 +75,9 @@ namespace MWMechanics
                 return true;
         }
 
+        if (!mCellId.empty() && mCellId != actor.getCell()->getCell()->getCellId().mWorldspace)
+            return false; // Not in the correct cell, pause and rely on the player to go back through a teleport door
+
         actor.getClass().getCreatureStats(actor).setDrawState(DrawState_Nothing);
         actor.getClass().getCreatureStats(actor).setMovementFlag(CreatureStats::Flag_Run, false);