mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-26 09:35:28 +00:00
Quick fix for Ai fast-forward crash in exteriors (Fixes #2241)
This commit is contained in:
parent
dc1c52bda7
commit
559ddbb480
@ -1653,7 +1653,10 @@ namespace MWMechanics
|
||||
{
|
||||
if (!MWBase::Environment::get().getMechanicsManager()->isAIActive())
|
||||
return;
|
||||
for (PtrActorMap::iterator it = mActors.begin(); it != mActors.end(); ++it)
|
||||
|
||||
// making a copy since fast-forward could move actor to a different cell and invalidate the mActors iterator
|
||||
PtrActorMap map = mActors;
|
||||
for (PtrActorMap::iterator it = map.begin(); it != map.end(); ++it)
|
||||
{
|
||||
MWWorld::Ptr ptr = it->first;
|
||||
if (ptr == MWBase::Environment::get().getWorld()->getPlayerPtr())
|
||||
|
@ -499,9 +499,14 @@ namespace MWMechanics
|
||||
|
||||
// convert dest to use world co-ordinates
|
||||
ESM::Pathgrid::Point dest;
|
||||
dest.mX = destNodePos[0] + currentCell->getCell()->mData.mX * ESM::Land::REAL_SIZE;
|
||||
dest.mY = destNodePos[1] + currentCell->getCell()->mData.mY * ESM::Land::REAL_SIZE;
|
||||
dest.mX = destNodePos[0];
|
||||
dest.mY = destNodePos[1];
|
||||
dest.mZ = destNodePos[2];
|
||||
if (currentCell->getCell()->isExterior())
|
||||
{
|
||||
dest.mX += currentCell->getCell()->mData.mX * ESM::Land::REAL_SIZE;
|
||||
dest.mY += currentCell->getCell()->mData.mY * ESM::Land::REAL_SIZE;
|
||||
}
|
||||
|
||||
// actor position is already in world co-ordinates
|
||||
ESM::Pathgrid::Point start;
|
||||
@ -670,6 +675,12 @@ namespace MWMechanics
|
||||
dest.mX += Ogre::Math::RangeRandom(-64, 64);
|
||||
dest.mY += Ogre::Math::RangeRandom(-64, 64);
|
||||
|
||||
if (actor.getCell()->isExterior())
|
||||
{
|
||||
dest.mX += actor.getCell()->getCell()->mData.mX * ESM::Land::REAL_SIZE;
|
||||
dest.mY += actor.getCell()->getCell()->mData.mY * ESM::Land::REAL_SIZE;
|
||||
}
|
||||
|
||||
MWBase::Environment::get().getWorld()->moveObject(actor, dest.mX, dest.mY, dest.mZ);
|
||||
actor.getClass().adjustPosition(actor, false);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user