From a94341fccca1b8b1df56ca1e5be54e06f69bffde Mon Sep 17 00:00:00 2001 From: Brambor Date: Mon, 10 Jun 2024 23:14:23 +0200 Subject: [PATCH] fix typo & refactor --- src/handle_action.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/handle_action.cpp b/src/handle_action.cpp index 627b9a27b524c..471b9b87e9a9a 100644 --- a/src/handle_action.cpp +++ b/src/handle_action.cpp @@ -182,6 +182,8 @@ extern bool add_best_key_for_action_to_quick_shortcuts( action_id action, extern bool add_key_to_quick_shortcuts( int key, const std::string &category, bool back ); #endif +static bool has_vehicle_control( avatar &player_character ); + class user_turn { @@ -1245,6 +1247,10 @@ static void wait() static void sleep() { avatar &player_character = get_avatar(); + if( has_vehicle_control( player_character ) ) { + add_msg( m_info, _( "You can't sleep while controlling a vehicle." ) ); + return; + } if( player_character.is_mounted() ) { add_msg( m_info, _( "You cannot sleep while mounted." ) ); return; @@ -2624,11 +2630,7 @@ bool game::do_regular_action( action_id &act, avatar &player_character, break; case ACTION_SLEEP: - if( has_vehicle_control( player_character ) ) { - add_msg( m_info, _( "You can't sleep while controlling a vehicle" ) ); - } else { - sleep(); - } + sleep(); break; case ACTION_CONTROL_VEHICLE: