From b4fbaf11694aa1395f7fcebd6126090636fe5fc8 Mon Sep 17 00:00:00 2001 From: scrawl Date: Sun, 24 Aug 2014 22:51:47 +0200 Subject: [PATCH] Fix potential infinite recursion in ActionTeleport (Fixes #1840) --- apps/openmw/mwworld/actionteleport.cpp | 11 +++++++---- apps/openmw/mwworld/actionteleport.hpp | 6 +++++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/apps/openmw/mwworld/actionteleport.cpp b/apps/openmw/mwworld/actionteleport.cpp index 4378e179d..3368aa1c0 100644 --- a/apps/openmw/mwworld/actionteleport.cpp +++ b/apps/openmw/mwworld/actionteleport.cpp @@ -1,4 +1,3 @@ - #include "actionteleport.hpp" #include "../mwbase/environment.hpp" @@ -16,15 +15,19 @@ namespace MWWorld void ActionTeleport::executeImp (const Ptr& actor) { - MWBase::World* world = MWBase::Environment::get().getWorld(); - //find any NPC that is following the actor and teleport him too std::list followers = MWBase::Environment::get().getMechanicsManager()->getActorsFollowing(actor); for(std::list::iterator it = followers.begin();it != followers.end();++it) { - executeImp(*it); + teleport(*it); } + teleport(actor); + } + + void ActionTeleport::teleport(const Ptr &actor) + { + MWBase::World* world = MWBase::Environment::get().getWorld(); if(actor == world->getPlayerPtr()) { world->getPlayer().setTeleported(true); diff --git a/apps/openmw/mwworld/actionteleport.hpp b/apps/openmw/mwworld/actionteleport.hpp index a13cb61b2..9ca664de8 100644 --- a/apps/openmw/mwworld/actionteleport.hpp +++ b/apps/openmw/mwworld/actionteleport.hpp @@ -14,12 +14,16 @@ namespace MWWorld std::string mCellName; ESM::Position mPosition; + /// Teleports this actor and also teleports anyone following that actor. virtual void executeImp (const Ptr& actor); + /// Teleports only the given actor (internal use). + void teleport(const Ptr &actor); + public: ActionTeleport (const std::string& cellName, const ESM::Position& position); - ///< If cellName is empty, an exterior cell is asumed. + ///< If cellName is empty, an exterior cell is assumed. }; }