mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-21 13:23:53 +00:00
fix crash on disappeared target
This commit is contained in:
parent
e1249f6a31
commit
fa14df62b7
1 changed files with 22 additions and 6 deletions
|
@ -141,7 +141,16 @@ void AiSequence::execute (const MWWorld::Ptr& actor,float duration)
|
||||||
{
|
{
|
||||||
if ((*it)->getTypeId() != AiPackage::TypeIdCombat) break;
|
if ((*it)->getTypeId() != AiPackage::TypeIdCombat) break;
|
||||||
|
|
||||||
ESM::Position &targetPos = static_cast<const AiCombat *>(*it)->getTarget().getRefData().getPosition();
|
MWWorld::Ptr target = static_cast<const AiCombat *>(*it)->getTarget();
|
||||||
|
|
||||||
|
// target disappeared (e.g. summoned creatures)
|
||||||
|
if (target.isEmpty())
|
||||||
|
{
|
||||||
|
mPackages.erase(it++);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ESM::Position &targetPos = target.getRefData().getPosition();
|
||||||
|
|
||||||
float distTo = (Ogre::Vector3(targetPos.pos) - vActorPos).length();
|
float distTo = (Ogre::Vector3(targetPos.pos) - vActorPos).length();
|
||||||
if (distTo < nearestDist)
|
if (distTo < nearestDist)
|
||||||
|
@ -150,8 +159,15 @@ void AiSequence::execute (const MWWorld::Ptr& actor,float duration)
|
||||||
itActualCombat = it;
|
itActualCombat = it;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (mPackages.begin() != itActualCombat)
|
// all targets disappeared
|
||||||
|
if (nearestDist == std::numeric_limits<float>::max())
|
||||||
|
{
|
||||||
|
mDone = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (mPackages.begin() != itActualCombat)
|
||||||
{
|
{
|
||||||
// move combat package with nearest target to the front
|
// move combat package with nearest target to the front
|
||||||
mPackages.splice(mPackages.begin(), mPackages, itActualCombat);
|
mPackages.splice(mPackages.begin(), mPackages, itActualCombat);
|
||||||
|
|
Loading…
Reference in a new issue