Skip to content

Commit

Permalink
vehicle: fix sigfpe when acceleration is zero
Browse files Browse the repository at this point in the history
It fixes rare case when all engines produce zero power due to no fuel or
exhausted character and target cruise speed is set less than current.

fixes CleverRaven#45473
  • Loading branch information
CAHEK7 committed Nov 25, 2020
1 parent 26d2ef6 commit b60a833
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/vehicle_move.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ void vehicle::thrust( int thd, int z )
//so 1000 = 100% and 453 = 45.3%
int load;
// Keep exact cruise control speed
if( cruise_on ) {
if( cruise_on && accel != 0 ) {
int effective_cruise = std::min( cruise_velocity, max_vel );
if( thd > 0 ) {
vel_inc = std::min( vel_inc, effective_cruise - velocity );
Expand Down

0 comments on commit b60a833

Please sign in to comment.