mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-03-29 22:06:45 +00:00
Fix potential infinite recursion in ActionTeleport (Fixes #1840)
This commit is contained in:
parent
854491ac15
commit
b4fbaf1169
2 changed files with 12 additions and 5 deletions
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
#include "actionteleport.hpp"
|
#include "actionteleport.hpp"
|
||||||
|
|
||||||
#include "../mwbase/environment.hpp"
|
#include "../mwbase/environment.hpp"
|
||||||
|
@ -16,15 +15,19 @@ namespace MWWorld
|
||||||
|
|
||||||
void ActionTeleport::executeImp (const Ptr& actor)
|
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
|
//find any NPC that is following the actor and teleport him too
|
||||||
std::list<MWWorld::Ptr> followers = MWBase::Environment::get().getMechanicsManager()->getActorsFollowing(actor);
|
std::list<MWWorld::Ptr> followers = MWBase::Environment::get().getMechanicsManager()->getActorsFollowing(actor);
|
||||||
for(std::list<MWWorld::Ptr>::iterator it = followers.begin();it != followers.end();++it)
|
for(std::list<MWWorld::Ptr>::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())
|
if(actor == world->getPlayerPtr())
|
||||||
{
|
{
|
||||||
world->getPlayer().setTeleported(true);
|
world->getPlayer().setTeleported(true);
|
||||||
|
|
|
@ -14,12 +14,16 @@ namespace MWWorld
|
||||||
std::string mCellName;
|
std::string mCellName;
|
||||||
ESM::Position mPosition;
|
ESM::Position mPosition;
|
||||||
|
|
||||||
|
/// Teleports this actor and also teleports anyone following that actor.
|
||||||
virtual void executeImp (const Ptr& actor);
|
virtual void executeImp (const Ptr& actor);
|
||||||
|
|
||||||
|
/// Teleports only the given actor (internal use).
|
||||||
|
void teleport(const Ptr &actor);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
ActionTeleport (const std::string& cellName, const ESM::Position& position);
|
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.
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue