From f5af09aed94402dde25f9c8fc4b63ebde886ad52 Mon Sep 17 00:00:00 2001 From: Alexei Dobrohotov Date: Tue, 22 Dec 2020 05:56:59 +0300 Subject: [PATCH] Fix AI sequence looping code (bug #5706) --- CHANGELOG.md | 1 + apps/openmw/mwmechanics/aisequence.cpp | 13 ++++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d896ca55c..fc6eb2d28 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -72,6 +72,7 @@ Bug #5688: Water shader broken indoors with enable indoor shadows = false Bug #5695: ExplodeSpell for actors doesn't target the ground Bug #5703: OpenMW-CS menu system crashing on XFCE + Bug #5706: AI sequences stop looping after the saved game is reloaded Bug #5731: Editor: skirts are invisible on characters Feature #390: 3rd person look "over the shoulder" Feature #1536: Show more information about level on menu diff --git a/apps/openmw/mwmechanics/aisequence.cpp b/apps/openmw/mwmechanics/aisequence.cpp index 57d32898c..575a03434 100644 --- a/apps/openmw/mwmechanics/aisequence.cpp +++ b/apps/openmw/mwmechanics/aisequence.cpp @@ -403,7 +403,7 @@ const AiPackage& MWMechanics::AiSequence::getActivePackage() void AiSequence::fill(const ESM::AIPackageList &list) { // If there is more than one package in the list, enable repeating - if (!list.mList.empty() && list.mList.begin() != (list.mList.end()-1)) + if (list.mList.size() >= 2) mRepeat = true; for (const auto& esmPackage : list.mList) @@ -459,8 +459,15 @@ void AiSequence::readState(const ESM::AiSequence::AiSequence &sequence) int count = 0; for (auto& container : sequence.mPackages) { - if (isActualAiPackage(static_cast(container.mType))) - count++; + switch (container.mType) + { + case ESM::AiSequence::Ai_Wander: + case ESM::AiSequence::Ai_Travel: + case ESM::AiSequence::Ai_Escort: + case ESM::AiSequence::Ai_Follow: + case ESM::AiSequence::Ai_Activate: + ++count; + } } if (count > 1)