Replace condition that may lead to UB by assert

If mPackages is empty it means package is a pointer to a deleted object
at line . We can assume it couldn't happen because execute is always called
next for this object at line 289.
pull/2856/head
elsid 5 years ago
parent b168544445
commit e3cce0949e
No known key found for this signature in database
GPG Key ID: B845CB9FEE18AB40

@ -265,16 +265,15 @@ void AiSequence::execute (const MWWorld::Ptr& actor, CharacterController& charac
}
}
if (!mPackages.empty())
{
if (nearestDist < std::numeric_limits<float>::max() && mPackages.begin() != itActualCombat)
{
// move combat package with nearest target to the front
mPackages.splice(mPackages.begin(), mPackages, itActualCombat);
}
assert(!mPackages.empty());
package = mPackages.front();
if (nearestDist < std::numeric_limits<float>::max() && mPackages.begin() != itActualCombat)
{
// move combat package with nearest target to the front
mPackages.splice(mPackages.begin(), mPackages, itActualCombat);
}
package = mPackages.front();
}
try

Loading…
Cancel
Save