1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-02-04 12:15:32 +00:00

Do not use fallthrough in switches

This commit is contained in:
Andrei Kortunov 2019-11-19 15:34:21 +04:00
parent 040d2675c6
commit d0643d266a
2 changed files with 44 additions and 56 deletions

View file

@ -1773,6 +1773,9 @@ bool CharacterController::updateWeaponState(CharacterState& idle)
0, mAttackType+" min attack", mAttackType+" max attack", 0.999f, 0); 0, mAttackType+" min attack", mAttackType+" max attack", 0.999f, 0);
break; break;
case UpperCharState_StartToMinAttack: case UpperCharState_StartToMinAttack:
case UpperCharState_MaxAttackToMinHit:
{
if (mUpperBodyState == UpperCharState_StartToMinAttack)
{ {
// If actor is already stopped preparing attack, do not play the "min attack -> max attack" part. // If actor is already stopped preparing attack, do not play the "min attack -> max attack" part.
// Happens if the player did not hold the attack button. // Happens if the player did not hold the attack button.
@ -1788,8 +1791,7 @@ bool CharacterController::updateWeaponState(CharacterState& idle)
} }
playSwishSound(0.0f); playSwishSound(0.0f);
} }
// Fall-through
case UpperCharState_MaxAttackToMinHit:
if(mAttackType == "shoot") if(mAttackType == "shoot")
{ {
start = mAttackType+" min hit"; start = mAttackType+" min hit";
@ -1802,6 +1804,7 @@ bool CharacterController::updateWeaponState(CharacterState& idle)
} }
mUpperBodyState = UpperCharState_MinHitToHit; mUpperBodyState = UpperCharState_MinHitToHit;
break; break;
}
case UpperCharState_MinHitToHit: case UpperCharState_MinHitToHit:
if(mAttackType == "shoot") if(mAttackType == "shoot")
{ {

View file

@ -131,30 +131,21 @@ namespace MWMechanics
mPrev = pos; mPrev = pos;
switch(mWalkState) if (mWalkState != State_Evade)
{
case State_Norm:
{
if(!samePosition)
break;
else
mWalkState = State_CheckStuck;
}
/* FALL THROUGH */
case State_CheckStuck:
{ {
if(!samePosition) if(!samePosition)
{ {
mWalkState = State_Norm; mWalkState = State_Norm;
mStuckDuration = 0; mStuckDuration = 0;
break; mEvadeDuration = 0;
return;
} }
else
{ mWalkState = State_CheckStuck;
mStuckDuration += duration; mStuckDuration += duration;
// consider stuck only if position unchanges for a period // consider stuck only if position unchanges for a period
if(mStuckDuration < DURATION_SAME_SPOT) if(mStuckDuration < DURATION_SAME_SPOT)
break; // still checking, note duration added to timer return; // still checking, note duration added to timer
else else
{ {
mStuckDuration = 0; mStuckDuration = 0;
@ -162,10 +153,7 @@ namespace MWMechanics
chooseEvasionDirection(); chooseEvasionDirection();
} }
} }
}
/* FALL THROUGH */
case State_Evade:
{
mEvadeDuration += duration; mEvadeDuration += duration;
if(mEvadeDuration >= DURATION_TO_EVADE) if(mEvadeDuration >= DURATION_TO_EVADE)
{ {
@ -174,9 +162,6 @@ namespace MWMechanics
mEvadeDuration = 0; mEvadeDuration = 0;
} }
} }
/* NO DEFAULT CASE */
}
}
void ObstacleCheck::takeEvasiveAction(MWMechanics::Movement& actorMovement) const void ObstacleCheck::takeEvasiveAction(MWMechanics::Movement& actorMovement) const
{ {