mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-02-04 09:45:33 +00:00
Do not use fallthrough in switches
This commit is contained in:
parent
040d2675c6
commit
d0643d266a
2 changed files with 44 additions and 56 deletions
|
@ -1773,23 +1773,25 @@ 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:
|
||||||
{
|
|
||||||
// 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:
|
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")
|
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")
|
||||||
{
|
{
|
||||||
|
|
|
@ -127,54 +127,39 @@ namespace MWMechanics
|
||||||
mDistSameSpot = DIST_SAME_SPOT * actor.getClass().getSpeed(actor);
|
mDistSameSpot = DIST_SAME_SPOT * actor.getClass().getSpeed(actor);
|
||||||
|
|
||||||
const float distSameSpot = mDistSameSpot * duration;
|
const float distSameSpot = mDistSameSpot * duration;
|
||||||
const bool samePosition = (pos - mPrev).length2() < distSameSpot * distSameSpot;
|
const bool samePosition = (pos - mPrev).length2() < distSameSpot * distSameSpot;
|
||||||
|
|
||||||
mPrev = pos;
|
mPrev = pos;
|
||||||
|
|
||||||
switch(mWalkState)
|
if (mWalkState != State_Evade)
|
||||||
{
|
{
|
||||||
case State_Norm:
|
if(!samePosition)
|
||||||
{
|
{
|
||||||
if(!samePosition)
|
mWalkState = State_Norm;
|
||||||
break;
|
mStuckDuration = 0;
|
||||||
else
|
mEvadeDuration = 0;
|
||||||
mWalkState = State_CheckStuck;
|
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)
|
mStuckDuration = 0;
|
||||||
{
|
mWalkState = State_Evade;
|
||||||
mWalkState = State_Norm;
|
chooseEvasionDirection();
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/* FALL THROUGH */
|
}
|
||||||
case State_Evade:
|
|
||||||
{
|
mEvadeDuration += duration;
|
||||||
mEvadeDuration += duration;
|
if(mEvadeDuration >= DURATION_TO_EVADE)
|
||||||
if(mEvadeDuration >= DURATION_TO_EVADE)
|
{
|
||||||
{
|
// tried to evade, assume all is ok and start again
|
||||||
// tried to evade, assume all is ok and start again
|
mWalkState = State_Norm;
|
||||||
mWalkState = State_Norm;
|
mEvadeDuration = 0;
|
||||||
mEvadeDuration = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/* NO DEFAULT CASE */
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue