Skip to content

Commit

Permalink
Merge branch 'juststrummingmylute' into 'master'
Browse files Browse the repository at this point in the history
Attempt to select an AI action directly instead of waiting for the next frame

Closes #7973

See merge request OpenMW/openmw!4244
  • Loading branch information
psi29a committed Jul 9, 2024
2 parents 3e024bc + 134c099 commit ecb64ea
Showing 1 changed file with 28 additions and 18 deletions.
46 changes: 28 additions & 18 deletions apps/openmw/mwmechanics/aiwander.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -455,27 +455,37 @@ namespace MWMechanics
void AiWander::doPerFrameActionsForState(const MWWorld::Ptr& actor, float duration,
MWWorld::MovementDirectionFlags supportedMovementDirections, AiWanderStorage& storage)
{
switch (storage.mState)
// Attempt to fast forward to the next state instead of remaining in an intermediate state for a frame
for (int i = 0; i < 2; ++i)
{
case AiWanderStorage::Wander_IdleNow:
onIdleStatePerFrameActions(actor, duration, storage);
break;

case AiWanderStorage::Wander_Walking:
onWalkingStatePerFrameActions(actor, duration, supportedMovementDirections, storage);
break;

case AiWanderStorage::Wander_ChooseAction:
onChooseActionStatePerFrameActions(actor, storage);
break;
switch (storage.mState)
{
case AiWanderStorage::Wander_IdleNow:
{
onIdleStatePerFrameActions(actor, duration, storage);
if (storage.mState != AiWanderStorage::Wander_ChooseAction)
return;
continue;
}
case AiWanderStorage::Wander_Walking:
onWalkingStatePerFrameActions(actor, duration, supportedMovementDirections, storage);
return;

case AiWanderStorage::Wander_MoveNow:
break; // nothing to do
case AiWanderStorage::Wander_ChooseAction:
{
onChooseActionStatePerFrameActions(actor, storage);
if (storage.mState != AiWanderStorage::Wander_IdleNow)
return;
continue;
}
case AiWanderStorage::Wander_MoveNow:
return; // nothing to do

default:
// should never get here
assert(false);
break;
default:
// should never get here
assert(false);
return;
}
}
}

Expand Down

0 comments on commit ecb64ea

Please sign in to comment.