Repair save games affected by bug #3080 (Fixes #3160)

move
scrawl 9 years ago
parent be6ea3d607
commit 48ac0bef3e

@ -351,60 +351,64 @@ void AiSequence::readState(const ESM::AiSequence::AiSequence &sequence)
for (std::vector<ESM::AiSequence::AiPackageContainer>::const_iterator it = sequence.mPackages.begin(); for (std::vector<ESM::AiSequence::AiPackageContainer>::const_iterator it = sequence.mPackages.begin();
it != sequence.mPackages.end(); ++it) it != sequence.mPackages.end(); ++it)
{ {
MWMechanics::AiPackage* package = NULL;
switch (it->mType) switch (it->mType)
{ {
case ESM::AiSequence::Ai_Wander: case ESM::AiSequence::Ai_Wander:
{ {
MWMechanics::AiWander* wander = new AiWander( package = new AiWander(static_cast<ESM::AiSequence::AiWander*>(it->mPackage));
static_cast<ESM::AiSequence::AiWander*>(it->mPackage));
mPackages.push_back(wander);
break; break;
} }
case ESM::AiSequence::Ai_Travel: case ESM::AiSequence::Ai_Travel:
{ {
MWMechanics::AiTravel* travel = new AiTravel( package = new AiTravel(static_cast<ESM::AiSequence::AiTravel*>(it->mPackage));
static_cast<ESM::AiSequence::AiTravel*>(it->mPackage));
mPackages.push_back(travel);
break; break;
} }
case ESM::AiSequence::Ai_Escort: case ESM::AiSequence::Ai_Escort:
{ {
MWMechanics::AiEscort* escort = new AiEscort( package = new AiEscort(static_cast<ESM::AiSequence::AiEscort*>(it->mPackage));
static_cast<ESM::AiSequence::AiEscort*>(it->mPackage));
mPackages.push_back(escort);
break; break;
} }
case ESM::AiSequence::Ai_Follow: case ESM::AiSequence::Ai_Follow:
{ {
MWMechanics::AiFollow* follow = new AiFollow( package = new AiFollow(static_cast<ESM::AiSequence::AiFollow*>(it->mPackage));
static_cast<ESM::AiSequence::AiFollow*>(it->mPackage));
mPackages.push_back(follow);
break; break;
} }
case ESM::AiSequence::Ai_Activate: case ESM::AiSequence::Ai_Activate:
{ {
MWMechanics::AiActivate* activate = new AiActivate( package = new AiActivate(static_cast<ESM::AiSequence::AiActivate*>(it->mPackage));
static_cast<ESM::AiSequence::AiActivate*>(it->mPackage));
mPackages.push_back(activate);
break; break;
} }
case ESM::AiSequence::Ai_Combat: case ESM::AiSequence::Ai_Combat:
{ {
MWMechanics::AiCombat* combat = new AiCombat( package = new AiCombat(static_cast<ESM::AiSequence::AiCombat*>(it->mPackage));
static_cast<ESM::AiSequence::AiCombat*>(it->mPackage));
mPackages.push_back(combat);
break; break;
} }
case ESM::AiSequence::Ai_Pursue: case ESM::AiSequence::Ai_Pursue:
{ {
MWMechanics::AiPursue* pursue = new AiPursue( package = new AiPursue(static_cast<ESM::AiSequence::AiPursue*>(it->mPackage));
static_cast<ESM::AiSequence::AiPursue*>(it->mPackage));
mPackages.push_back(pursue);
break; break;
} }
default: default:
break; break;
} }
if (!package)
continue;
// remove previous packages if required
if (package->shouldCancelPreviousAi())
{
for(std::list<AiPackage *>::iterator it = mPackages.begin(); it != mPackages.end();)
{
if((*it)->canCancel())
it = mPackages.erase(it);
else
++it;
}
}
mPackages.push_back(package);
} }
} }

Loading…
Cancel
Save