1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-02-23 02:39:43 +00:00

Split functions to remove redundant clearPath argument

This commit is contained in:
elsid 2020-05-16 14:57:20 +02:00
parent b8513e0318
commit 131f2557b1
No known key found for this signature in database
GPG key ID: B845CB9FEE18AB40
2 changed files with 11 additions and 9 deletions

View file

@ -89,6 +89,11 @@ namespace MWMechanics
const auto maxHalfExtent = std::max(halfExtents.x(), std::max(halfExtents.y(), halfExtents.z())); const auto maxHalfExtent = std::max(halfExtents.x(), std::max(halfExtents.y(), halfExtents.z()));
return world->isAreaOccupiedByOtherActor(destination, 2 * maxHalfExtent, actor); return world->isAreaOccupiedByOtherActor(destination, 2 * maxHalfExtent, actor);
} }
void stopMovement(const MWWorld::Ptr& actor)
{
actor.getClass().getMovementSettings(actor).mPosition[1] = 0;
}
} }
AiWander::AiWander(int distance, int duration, int timeOfDay, const std::vector<unsigned char>& idle, bool repeat): AiWander::AiWander(int distance, int duration, int timeOfDay, const std::vector<unsigned char>& idle, bool repeat):
@ -206,7 +211,7 @@ namespace MWMechanics
{ {
if (storage.mState == AiWanderStorage::Wander_Walking) if (storage.mState == AiWanderStorage::Wander_Walking)
{ {
stopWalking(actor, false); stopMovement(actor);
mObstacleCheck.clear(); mObstacleCheck.clear();
storage.setState(AiWanderStorage::Wander_IdleNow); storage.setState(AiWanderStorage::Wander_IdleNow);
} }
@ -609,14 +614,11 @@ namespace MWMechanics
return TypeIdWander; return TypeIdWander;
} }
void AiWander::stopWalking(const MWWorld::Ptr& actor, bool clearPath) void AiWander::stopWalking(const MWWorld::Ptr& actor)
{ {
if (clearPath) mPathFinder.clearPath();
{ mHasDestination = false;
mPathFinder.clearPath(); stopMovement(actor);
mHasDestination = false;
}
actor.getClass().getMovementSettings(actor).mPosition[1] = 0;
} }
bool AiWander::playIdle(const MWWorld::Ptr& actor, unsigned short idleSelect) bool AiWander::playIdle(const MWWorld::Ptr& actor, unsigned short idleSelect)

View file

@ -118,7 +118,7 @@ namespace MWMechanics
private: private:
// NOTE: mDistance and mDuration must be set already // NOTE: mDistance and mDuration must be set already
void init(); void init();
void stopWalking(const MWWorld::Ptr& actor, bool clearPath = true); void stopWalking(const MWWorld::Ptr& actor);
/// Have the given actor play an idle animation /// Have the given actor play an idle animation
/// @return Success or error /// @return Success or error