Permalink
Browse files

vehicles: don't let drag stop vehicles in active cruise control

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 8787ab265f3504fb9703e66c96a2cf3fb02445f4
Showing with 5 additions and 1 deletion.
  1. +5 −1 src/vehicle.cpp
@@ -4245,7 +4245,11 @@ void vehicle::gain_moves()
of_turn = 1 + of_turn_carry;
const int vslowdown = slowdown( velocity );
if( vslowdown > abs( velocity ) ) {
stop();
if( cruise_on && cruise_velocity ) {
velocity = velocity > 0 ? 1 : -1;
} else {
stop();
}
} else if( velocity < 0 ) {
velocity += vslowdown;
} else {

0 comments on commit 8787ab2

Please sign in to comment.