mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-26 18:35:20 +00:00
Do not use fallthrough in switches
This commit is contained in:
parent
040d2675c6
commit
d0643d266a
@ -1773,23 +1773,25 @@ bool CharacterController::updateWeaponState(CharacterState& idle)
|
||||
0, mAttackType+" min attack", mAttackType+" max attack", 0.999f, 0);
|
||||
break;
|
||||
case UpperCharState_StartToMinAttack:
|
||||
{
|
||||
// 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.
|
||||
// Note: if the "min attack"->"max attack" is a stub, "play" it anyway. Attack strength will be random.
|
||||
float minAttackTime = mAnimation->getTextKeyTime(mCurrentWeapon+": "+mAttackType+" "+"min attack");
|
||||
float maxAttackTime = mAnimation->getTextKeyTime(mCurrentWeapon+": "+mAttackType+" "+"max attack");
|
||||
if (mAttackingOrSpell || minAttackTime == maxAttackTime)
|
||||
{
|
||||
start = mAttackType+" min attack";
|
||||
stop = mAttackType+" max attack";
|
||||
mUpperBodyState = UpperCharState_MinAttackToMaxAttack;
|
||||
break;
|
||||
}
|
||||
playSwishSound(0.0f);
|
||||
}
|
||||
// Fall-through
|
||||
case UpperCharState_MaxAttackToMinHit:
|
||||
{
|
||||
if (mUpperBodyState == UpperCharState_StartToMinAttack)
|
||||
{
|
||||
// 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.
|
||||
// Note: if the "min attack"->"max attack" is a stub, "play" it anyway. Attack strength will be random.
|
||||
float minAttackTime = mAnimation->getTextKeyTime(mCurrentWeapon+": "+mAttackType+" "+"min attack");
|
||||
float maxAttackTime = mAnimation->getTextKeyTime(mCurrentWeapon+": "+mAttackType+" "+"max attack");
|
||||
if (mAttackingOrSpell || minAttackTime == maxAttackTime)
|
||||
{
|
||||
start = mAttackType+" min attack";
|
||||
stop = mAttackType+" max attack";
|
||||
mUpperBodyState = UpperCharState_MinAttackToMaxAttack;
|
||||
break;
|
||||
}
|
||||
playSwishSound(0.0f);
|
||||
}
|
||||
|
||||
if(mAttackType == "shoot")
|
||||
{
|
||||
start = mAttackType+" min hit";
|
||||
@ -1802,6 +1804,7 @@ bool CharacterController::updateWeaponState(CharacterState& idle)
|
||||
}
|
||||
mUpperBodyState = UpperCharState_MinHitToHit;
|
||||
break;
|
||||
}
|
||||
case UpperCharState_MinHitToHit:
|
||||
if(mAttackType == "shoot")
|
||||
{
|
||||
|
@ -127,54 +127,39 @@ namespace MWMechanics
|
||||
mDistSameSpot = DIST_SAME_SPOT * actor.getClass().getSpeed(actor);
|
||||
|
||||
const float distSameSpot = mDistSameSpot * duration;
|
||||
const bool samePosition = (pos - mPrev).length2() < distSameSpot * distSameSpot;
|
||||
const bool samePosition = (pos - mPrev).length2() < distSameSpot * distSameSpot;
|
||||
|
||||
mPrev = pos;
|
||||
|
||||
switch(mWalkState)
|
||||
if (mWalkState != State_Evade)
|
||||
{
|
||||
case State_Norm:
|
||||
if(!samePosition)
|
||||
{
|
||||
if(!samePosition)
|
||||
break;
|
||||
else
|
||||
mWalkState = State_CheckStuck;
|
||||
mWalkState = State_Norm;
|
||||
mStuckDuration = 0;
|
||||
mEvadeDuration = 0;
|
||||
return;
|
||||
}
|
||||
/* FALL THROUGH */
|
||||
case State_CheckStuck:
|
||||
|
||||
mWalkState = State_CheckStuck;
|
||||
mStuckDuration += duration;
|
||||
// consider stuck only if position unchanges for a period
|
||||
if(mStuckDuration < DURATION_SAME_SPOT)
|
||||
return; // still checking, note duration added to timer
|
||||
else
|
||||
{
|
||||
if(!samePosition)
|
||||
{
|
||||
mWalkState = State_Norm;
|
||||
mStuckDuration = 0;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
mStuckDuration += duration;
|
||||
// consider stuck only if position unchanges for a period
|
||||
if(mStuckDuration < DURATION_SAME_SPOT)
|
||||
break; // still checking, note duration added to timer
|
||||
else
|
||||
{
|
||||
mStuckDuration = 0;
|
||||
mWalkState = State_Evade;
|
||||
chooseEvasionDirection();
|
||||
}
|
||||
}
|
||||
mStuckDuration = 0;
|
||||
mWalkState = State_Evade;
|
||||
chooseEvasionDirection();
|
||||
}
|
||||
/* FALL THROUGH */
|
||||
case State_Evade:
|
||||
{
|
||||
mEvadeDuration += duration;
|
||||
if(mEvadeDuration >= DURATION_TO_EVADE)
|
||||
{
|
||||
// tried to evade, assume all is ok and start again
|
||||
mWalkState = State_Norm;
|
||||
mEvadeDuration = 0;
|
||||
}
|
||||
}
|
||||
/* NO DEFAULT CASE */
|
||||
}
|
||||
|
||||
mEvadeDuration += duration;
|
||||
if(mEvadeDuration >= DURATION_TO_EVADE)
|
||||
{
|
||||
// tried to evade, assume all is ok and start again
|
||||
mWalkState = State_Norm;
|
||||
mEvadeDuration = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user