mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-04 02:41:19 +00:00
Better mUse out-of-range handling
This commit is contained in:
parent
3eadb84142
commit
1497dae4fa
@ -242,14 +242,19 @@ namespace MWMechanics
|
||||
{
|
||||
std::string_view attackTypeName(AttackType attackType)
|
||||
{
|
||||
if (attackType == AttackType::Chop)
|
||||
return "chop";
|
||||
else if (attackType == AttackType::Slash)
|
||||
return "slash";
|
||||
else if (attackType == AttackType::Thrust)
|
||||
return "thrust";
|
||||
else
|
||||
return "";
|
||||
switch (attackType)
|
||||
{
|
||||
case AttackType::NoAttack:
|
||||
case AttackType::Any:
|
||||
return {};
|
||||
case AttackType::Chop:
|
||||
return "chop";
|
||||
case AttackType::Slash:
|
||||
return "slash";
|
||||
case AttackType::Thrust:
|
||||
return "thrust";
|
||||
}
|
||||
throw std::logic_error("Invalid attack type value: " + std::to_string(static_cast<int>(attackType)));
|
||||
}
|
||||
|
||||
float getTimeToDestination(const AiPackage& package, const osg::Vec3f& position, float speed, float duration,
|
||||
@ -377,10 +382,7 @@ namespace MWMechanics
|
||||
stats.setMovementFlag(MWMechanics::CreatureStats::Flag_Run, controls.mRun);
|
||||
stats.setMovementFlag(MWMechanics::CreatureStats::Flag_Sneak, controls.mSneak);
|
||||
|
||||
// Same as mUse % max AttackType int value
|
||||
AttackType attackType
|
||||
= static_cast<AttackType>(controls.mUse % (static_cast<int>(AttackType::Thrust) + 1));
|
||||
|
||||
AttackType attackType = static_cast<AttackType>(controls.mUse);
|
||||
stats.setAttackingOrSpell(attackType != AttackType::NoAttack);
|
||||
stats.setAttackType(attackTypeName(attackType));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user