1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-02-06 18:40:23 +00:00

Fix loading 0-duration Follow and Escort packages

(Fixes #3755)
This commit is contained in:
Allofich 2017-02-18 01:38:21 +09:00
parent e0afaf3a7d
commit 3897c49e30
2 changed files with 23 additions and 21 deletions

View File

@ -45,8 +45,8 @@ namespace MWMechanics
, mCellY(std::numeric_limits<int>::max()) , mCellY(std::numeric_limits<int>::max())
{ {
// mDuration isn't saved in the save file, so just giving it "1" for now if the package has a duration. // mDuration isn't saved in the save file, so just giving it "1" for now if the package has a duration.
// The exact value of mDuration only matters for repeating packages // The exact value of mDuration only matters for repeating packages.
if (mRemainingDuration != 0) if (mRemainingDuration > 0) // Previously mRemainingDuration could be negative even when mDuration was 0. Checking for > 0 should fix old saves.
mDuration = 1; mDuration = 1;
else else
mDuration = 0; mDuration = 0;
@ -142,7 +142,8 @@ namespace MWMechanics
void AiEscort::fastForward(const MWWorld::Ptr& actor, AiState &state) void AiEscort::fastForward(const MWWorld::Ptr& actor, AiState &state)
{ {
// Update duration counter // Update duration counter if this package has a duration
if (mDuration > 0)
mRemainingDuration--; mRemainingDuration--;
} }
} }

View File

@ -52,9 +52,9 @@ AiFollow::AiFollow(const ESM::AiSequence::AiFollow *follow)
, mActorRefId(follow->mTargetId), mActorId(-1) , mActorRefId(follow->mTargetId), mActorId(-1)
, mCellId(follow->mCellId), mActive(follow->mActive), mFollowIndex(mFollowIndexCounter++) , mCellId(follow->mCellId), mActive(follow->mActive), mFollowIndex(mFollowIndexCounter++)
{ {
// mDuration isn't saved in the save file, so just giving it "1" for now if the package has a duration. // mDuration isn't saved in the save file, so just giving it "1" for now if the package had a duration.
// The exact value of mDuration only matters for repeating packages // The exact value of mDuration only matters for repeating packages.
if (mRemainingDuration != 0) if (mRemainingDuration > 0) // Previously mRemainingDuration could be negative even when mDuration was 0. Checking for > 0 should fix old saves.
mDuration = 1; mDuration = 1;
else else
mDuration = 0; mDuration = 0;
@ -107,7 +107,7 @@ bool AiFollow::execute (const MWWorld::Ptr& actor, CharacterController& characte
if (!mAlwaysFollow) //Update if you only follow for a bit if (!mAlwaysFollow) //Update if you only follow for a bit
{ {
//Check if we've run out of time //Check if we've run out of time
if (mDuration != 0) if (mDuration > 0)
{ {
mRemainingDuration -= ((duration*MWBase::Environment::get().getWorld()->getTimeScaleFactor()) / 3600); mRemainingDuration -= ((duration*MWBase::Environment::get().getWorld()->getTimeScaleFactor()) / 3600);
if (mRemainingDuration <= 0) if (mRemainingDuration <= 0)
@ -228,7 +228,8 @@ int AiFollow::getFollowIndex() const
void AiFollow::fastForward(const MWWorld::Ptr& actor, AiState &state) void AiFollow::fastForward(const MWWorld::Ptr& actor, AiState &state)
{ {
// Update duration counter // Update duration counter if this package has a duration
if (mDuration > 0)
mRemainingDuration--; mRemainingDuration--;
} }