Skip to content

Commit bbc02d4

Browse files
authored
Clamp boost, strafe to valid ranges (#2865)
1 parent d8b2ac6 commit bbc02d4

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

src/systems/maneuvering.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ void ManeuveringSystem::update(float delta)
3838
if (combat.boost.active > combat.boost.request)
3939
combat.boost.active = combat.boost.request;
4040
}
41+
// Clamp boost to 0-1.
42+
combat.boost.active = std::clamp(combat.boost.active, 0.0f, 1.0f);
43+
4144
if (combat.strafe.active > combat.strafe.request)
4245
{
4346
combat.strafe.active -= delta;
@@ -50,9 +53,11 @@ void ManeuveringSystem::update(float delta)
5053
if (combat.strafe.active > combat.strafe.request)
5154
combat.strafe.active = combat.strafe.request;
5255
}
56+
// Clamp strafe to -1 to 1.
57+
combat.strafe.active = std::clamp(combat.strafe.active, -1.0f, 1.0f);
5358

5459
// If the ship is making a combat maneuver ...
55-
if (combat.boost.active != 0.0f || combat.strafe.active != 0.0f)
60+
if (combat.boost.active > 0.0f || combat.strafe.active != 0.0f)
5661
{
5762
// ... consume its combat maneuver boost.
5863
combat.charge -= fabs(combat.boost.active) * delta / combat.boost.max_time;

0 commit comments

Comments
 (0)