Fix AIWander crash

This commit is contained in:
scrawl 2013-11-25 15:38:18 +01:00
parent 9f5ff033d7
commit eba068149d

View file

@ -144,11 +144,11 @@ namespace MWMechanics
mCurrentNode = mAllowedNodes[index]; mCurrentNode = mAllowedNodes[index];
mAllowedNodes.erase(mAllowedNodes.begin() + index); mAllowedNodes.erase(mAllowedNodes.begin() + index);
} }
}
}
if(mAllowedNodes.empty()) if(mAllowedNodes.empty())
mDistance = 0; mDistance = 0;
}
}
// Don't try to move if you are in a new cell (ie: positioncell command called) but still play idles. // Don't try to move if you are in a new cell (ie: positioncell command called) but still play idles.
if(mDistance && (mCellX != actor.getCell()->mCell->mData.mX || mCellY != actor.getCell()->mCell->mData.mY)) if(mDistance && (mCellX != actor.getCell()->mCell->mData.mX || mCellY != actor.getCell()->mCell->mData.mY))
@ -200,6 +200,7 @@ namespace MWMechanics
{ {
if(!mPathFinder.isPathConstructed()) if(!mPathFinder.isPathConstructed())
{ {
assert(mAllowedNodes.size());
unsigned int randNode = (int)(rand() / ((double)RAND_MAX + 1) * mAllowedNodes.size()); unsigned int randNode = (int)(rand() / ((double)RAND_MAX + 1) * mAllowedNodes.size());
Ogre::Vector3 destNodePos(mAllowedNodes[randNode].mX, mAllowedNodes[randNode].mY, mAllowedNodes[randNode].mZ); Ogre::Vector3 destNodePos(mAllowedNodes[randNode].mX, mAllowedNodes[randNode].mY, mAllowedNodes[randNode].mZ);