Skip to content

Commit

Permalink
vehicles: don't let drag stop vehicles in active cruise control
Browse files Browse the repository at this point in the history
The current vehicle model has all the drag deceleration applied
at once at the start of each turn.  Vehicles that have more drag
deceleration than speed will stop, aligning their turn direction
with their facing.

This normally works fine, but some boats and amphibious vehicles
will have enough water drag deceleration to stop them every turn,
even if they have enough acceleration to return back to their
cruise control set speed.  Under those conditions, the vehicles
will move apparently normally across water, but cannot turn.

Give vehicles that are under cruise control with a non-zero
cruise control target velocity a nominal velocity if the drag
slowdown exceeds the vehicle's current speed, which seems to
resolve the problem.
  • Loading branch information
mlangsdorf committed Jan 6, 2019
1 parent 980b56d commit 8787ab2
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/vehicle.cpp
Expand Up @@ -4245,7 +4245,11 @@ void vehicle::gain_moves()
of_turn = 1 + of_turn_carry; of_turn = 1 + of_turn_carry;
const int vslowdown = slowdown( velocity ); const int vslowdown = slowdown( velocity );
if( vslowdown > abs( velocity ) ) { if( vslowdown > abs( velocity ) ) {
stop(); if( cruise_on && cruise_velocity ) {
velocity = velocity > 0 ? 1 : -1;
} else {
stop();
}
} else if( velocity < 0 ) { } else if( velocity < 0 ) {
velocity += vslowdown; velocity += vslowdown;
} else { } else {
Expand Down

0 comments on commit 8787ab2

Please sign in to comment.