From fd0a0f9f8b6884ae7c0ea0a68fa0d41c05c8dda2 Mon Sep 17 00:00:00 2001 From: David Brown Date: Thu, 19 Dec 2019 16:08:22 +0000 Subject: [PATCH 1/2] check autodriving before stop autodriving --- src/vehicle_move.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/vehicle_move.cpp b/src/vehicle_move.cpp index f59a8117a45a6..9920638f22f37 100644 --- a/src/vehicle_move.cpp +++ b/src/vehicle_move.cpp @@ -544,7 +544,9 @@ veh_collision vehicle::part_collision( int part, const tripoint &p, // Hit nothing or we aren't actually hitting return ret; } - stop_autodriving(); + if( is_autodriving || is_patrolling || is_following ) { + stop_autodriving(); + } // Calculate mass AFTER checking for collision // because it involves iterating over all cargo const float mass = to_kilogram( total_mass() ); From 0b303fb693aecc2102026f8c0a3e538b988a5ae3 Mon Sep 17 00:00:00 2001 From: David Brown Date: Thu, 19 Dec 2019 16:09:13 +0000 Subject: [PATCH 2/2] encapsulate in stop autodriving function --- src/vehicle.cpp | 3 +++ src/vehicle_move.cpp | 4 +--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/vehicle.cpp b/src/vehicle.cpp index 9c31a94431647..f1bd9c620a858 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -735,6 +735,9 @@ std::set vehicle::immediate_path( int rotate ) void vehicle::stop_autodriving() { + if( !is_autodriving && !is_patrolling && !is_following ){ + return; + } if( velocity > 0 ) { if( is_patrolling || is_following ) { autodrive( 0, 10 ); diff --git a/src/vehicle_move.cpp b/src/vehicle_move.cpp index 9920638f22f37..f59a8117a45a6 100644 --- a/src/vehicle_move.cpp +++ b/src/vehicle_move.cpp @@ -544,9 +544,7 @@ veh_collision vehicle::part_collision( int part, const tripoint &p, // Hit nothing or we aren't actually hitting return ret; } - if( is_autodriving || is_patrolling || is_following ) { - stop_autodriving(); - } + stop_autodriving(); // Calculate mass AFTER checking for collision // because it involves iterating over all cargo const float mass = to_kilogram( total_mass() );