From 0c64d5c2f1be8ae9d10e9645027890e5abb1ecd3 Mon Sep 17 00:00:00 2001 From: Pupsi Mupsi <44737997+Pupsi-Mupsi@users.noreply.github.com> Date: Thu, 12 Mar 2020 15:08:50 +0100 Subject: [PATCH 01/10] colorize ask for deactivation --- src/handle_action.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/handle_action.cpp b/src/handle_action.cpp index 71eb8af87dc6a..ac821b561bd34 100644 --- a/src/handle_action.cpp +++ b/src/handle_action.cpp @@ -962,7 +962,7 @@ static void sleep() data << _( "You may want to deactivate these before you sleep." ) << std::endl; data << " " << std::endl; for( auto &a : active ) { - data << a << std::endl; + data << "" << a << "" << std::endl; } as_m.text = data.str(); } From f1eb7a0ccfc527afdc88196c74a4d75663c32dc5 Mon Sep 17 00:00:00 2001 From: Pupsi Mupsi <44737997+Pupsi-Mupsi@users.noreply.github.com> Date: Thu, 12 Mar 2020 20:32:29 +0100 Subject: [PATCH 02/10] change default selection sleep menu to NO --- src/handle_action.cpp | 2670 ++++++++++++++++++++++++----------------- 1 file changed, 1576 insertions(+), 1094 deletions(-) diff --git a/src/handle_action.cpp b/src/handle_action.cpp index ac821b561bd34..4fe0a928bc0d4 100644 --- a/src/handle_action.cpp +++ b/src/handle_action.cpp @@ -80,39 +80,44 @@ extern bool add_key_to_quick_shortcuts( int key, const std::string &category, bo class user_turn { - private: - std::chrono::time_point user_turn_start; - public: - user_turn() { - user_turn_start = std::chrono::steady_clock::now(); - } - - bool has_timeout_elapsed() { - return moves_elapsed() > 100; - } - - int moves_elapsed() { - const float turn_duration = get_option( "TURN_DURATION" ); - // Magic number 0.005 chosen due to option menu's 2 digit precision and - // the option menu UI rounding <= 0.005 down to "0.00" in the display. - // This conditional will catch values (e.g. 0.003) that the options menu - // would round down to "0.00" in the options menu display. This prevents - // the user from being surprised by floating point rounding near zero. - if( turn_duration <= 0.005 ) { - return 0; - } - auto now = std::chrono::steady_clock::now(); - std::chrono::milliseconds elapsed_ms = - std::chrono::duration_cast( now - user_turn_start ); - return elapsed_ms.count() / ( 10.0 * turn_duration ); +private: + std::chrono::time_point user_turn_start; +public: + user_turn() + { + user_turn_start = std::chrono::steady_clock::now(); + } + + bool has_timeout_elapsed() + { + return moves_elapsed() > 100; + } + + int moves_elapsed() + { + const float turn_duration = get_option( "TURN_DURATION" ); + // Magic number 0.005 chosen due to option menu's 2 digit precision and + // the option menu UI rounding <= 0.005 down to "0.00" in the display. + // This conditional will catch values (e.g. 0.003) that the options menu + // would round down to "0.00" in the options menu display. This prevents + // the user from being surprised by floating point rounding near zero. + if( turn_duration <= 0.005 ) + { + return 0; } + auto now = std::chrono::steady_clock::now(); + std::chrono::milliseconds elapsed_ms = + std::chrono::duration_cast( now - user_turn_start ); + return elapsed_ms.count() / ( 10.0 * turn_duration ); + } }; input_context game::get_player_input( std::string &action ) { input_context ctxt; - if( uquit == QUIT_WATCH ) { + if( uquit == QUIT_WATCH ) + { ctxt = input_context( "DEFAULTMODE" ); ctxt.set_iso( true ); // The list of allowed actions in death-cam mode in game::handle_action @@ -135,7 +140,9 @@ input_context game::get_player_input( std::string &action ) } // *INDENT-ON* ctxt.register_action( "QUIT", to_translation( "Accept your fate" ) ); - } else { + } + else + { ctxt = get_default_mode_input_context(); } @@ -146,7 +153,8 @@ input_context game::get_player_input( std::string &action ) user_turn current_turn; - if( get_option( "ANIMATIONS" ) ) { + if( get_option( "ANIMATIONS" ) ) + { const int TOTAL_VIEW = MAX_VIEW_DISTANCE * 2 + 1; int iStartX = ( TERRAIN_WINDOW_WIDTH > TOTAL_VIEW ) ? ( TERRAIN_WINDOW_WIDTH - TOTAL_VIEW ) / 2 : 0; int iStartY = ( TERRAIN_WINDOW_HEIGHT > TOTAL_VIEW ) ? ( TERRAIN_WINDOW_HEIGHT - TOTAL_VIEW ) / 2 : @@ -159,7 +167,8 @@ input_context game::get_player_input( std::string &action ) ( TERRAIN_WINDOW_HEIGHT - TOTAL_VIEW ) / 2 : TERRAIN_WINDOW_HEIGHT; - if( fullscreen ) { + if( fullscreen ) + { iStartX = 0; iStartY = 0; iEndX = TERMX; @@ -172,7 +181,8 @@ input_context game::get_player_input( std::string &action ) int offset_y = u.posy() + u.view_offset.y - getmaxy( w_terrain ) / 2; #if defined(TILES) - if( tile_iso && use_tiles ) { + if( tile_iso && use_tiles ) + { iStartX = 0; iStartY = 0; iEndX = MAPSIZE_X; @@ -194,8 +204,10 @@ input_context game::get_player_input( std::string &action ) ctxt.set_timeout( 125 ); bool initial_draw = true; - do { - if( bWeatherEffect && get_option( "ANIMATION_RAIN" ) ) { + do + { + if( bWeatherEffect && get_option( "ANIMATION_RAIN" ) ) + { /* Location to add rain drop animation bits! Since it refreshes w_terrain it can be added to the animation section easily Get tile information from above's weather information: @@ -205,14 +217,17 @@ input_context game::get_player_input( std::string &action ) */ #if defined(TILES) - if( !use_tiles ) { + if( !use_tiles ) + { #endif //TILES //If not using tiles, erase previous drops from w_terrain - for( auto &elem : wPrint.vdrops ) { + for( auto &elem : wPrint.vdrops ) + { const tripoint location( elem.first + offset_x, elem.second + offset_y, get_levz() ); const lit_level lighting = visibility_cache[location.x][location.y]; wmove( w_terrain, location.xy() + point( -offset_x, -offset_y ) ); - if( !m.apply_vision_effects( w_terrain, m.get_visibility( lighting, cache ) ) ) { + if( !m.apply_vision_effects( w_terrain, m.get_visibility( lighting, cache ) ) ) + { m.drawsq( w_terrain, u, location, false, true, u.pos() + u.view_offset, lighting == LL_LOW, lighting == LL_BRIGHT ); @@ -223,7 +238,8 @@ input_context game::get_player_input( std::string &action ) #endif //TILES wPrint.vdrops.clear(); - for( int i = 0; i < dropCount; i++ ) { + for( int i = 0; i < dropCount; i++ ) + { const int iRandX = rng( iStartX, iEndX - 1 ); const int iRandY = rng( iStartY, iEndY - 1 ); const int mapx = iRandX + offset_x; @@ -234,26 +250,33 @@ input_context game::get_player_input( std::string &action ) const lit_level lighting = visibility_cache[mapp.x][mapp.y]; if( m.is_outside( mapp ) && m.get_visibility( lighting, cache ) == VIS_CLEAR && - !critter_at( mapp, true ) ) { + !critter_at( mapp, true ) ) + { // Suppress if a critter is there wPrint.vdrops.emplace_back( std::make_pair( iRandX, iRandY ) ); } } } // don't bother calculating SCT if we won't show it - if( uquit != QUIT_WATCH && get_option( "ANIMATION_SCT" ) ) { + if( uquit != QUIT_WATCH && get_option( "ANIMATION_SCT" ) ) + { #if defined(TILES) - if( !use_tiles ) { + if( !use_tiles ) + { #endif - for( auto &elem : SCT.vSCT ) { + for( auto &elem : SCT.vSCT ) + { //Erase previous text from w_terrain - if( elem.getStep() > 0 ) { + if( elem.getStep() > 0 ) + { const int width = utf8_width( elem.getText() ); - for( int i = 0; i < width; ++i ) { + for( int i = 0; i < width; ++i ) + { const tripoint location( elem.getPosX() + i, elem.getPosY(), get_levz() ); const lit_level lighting = visibility_cache[location.x][location.y]; wmove( w_terrain, location.xy() + point( -offset_x, -offset_y ) ); - if( !m.apply_vision_effects( w_terrain, m.get_visibility( lighting, cache ) ) ) { + if( !m.apply_vision_effects( w_terrain, m.get_visibility( lighting, cache ) ) ) + { m.drawsq( w_terrain, u, location, false, true, u.pos() + u.view_offset, lighting == LL_LOW, lighting == LL_BRIGHT ); @@ -268,20 +291,26 @@ input_context game::get_player_input( std::string &action ) SCT.advanceAllSteps(); //Check for creatures on all drawing positions and offset if necessary - for( auto iter = SCT.vSCT.rbegin(); iter != SCT.vSCT.rend(); ++iter ) { + for( auto iter = SCT.vSCT.rbegin(); iter != SCT.vSCT.rend(); ++iter ) + { const direction oCurDir = iter->getDirecton(); const int width = utf8_width( iter->getText() ); - for( int i = 0; i < width; ++i ) { + for( int i = 0; i < width; ++i ) + { tripoint tmp( iter->getPosX() + i, iter->getPosY(), get_levz() ); const Creature *critter = critter_at( tmp, true ); - if( critter != nullptr && u.sees( *critter ) ) { + if( critter != nullptr && u.sees( *critter ) ) + { i = -1; int iPos = iter->getStep() + iter->getStepOffset(); - for( auto iter2 = iter; iter2 != SCT.vSCT.rend(); ++iter2 ) { + for( auto iter2 = iter; iter2 != SCT.vSCT.rend(); ++iter2 ) + { if( iter2->getDirecton() == oCurDir && - iter2->getStep() + iter2->getStepOffset() <= iPos ) { - if( iter2->getType() == "hp" ) { + iter2->getStep() + iter2->getStepOffset() <= iPos ) + { + if( iter2->getType() == "hp" ) + { iter2->advanceStepOffset(); } @@ -294,7 +323,8 @@ input_context game::get_player_input( std::string &action ) } } - if( initial_draw ) { + if( initial_draw ) + { werase( w_terrain ); draw_ter(); @@ -302,26 +332,33 @@ input_context game::get_player_input( std::string &action ) } draw_weather( wPrint ); - if( uquit != QUIT_WATCH ) { + if( uquit != QUIT_WATCH ) + { draw_sct(); } wrefresh( w_terrain ); g->draw_panels(); - if( uquit == QUIT_WATCH ) { + if( uquit == QUIT_WATCH ) + { query_popup() .wait_message( c_red, _( "Press %s to accept your fate…" ), ctxt.get_desc( "QUIT" ) ) .on_top( true ) .show(); } - } while( handle_mouseview( ctxt, action ) && uquit != QUIT_WATCH - && ( action != "TIMEOUT" || !current_turn.has_timeout_elapsed() ) ); + } + while( handle_mouseview( ctxt, action ) && uquit != QUIT_WATCH + && ( action != "TIMEOUT" || !current_turn.has_timeout_elapsed() ) ); ctxt.reset_timeout(); - } else { + } + else + { ctxt.set_timeout( 125 ); - while( handle_mouseview( ctxt, action ) ) { - if( action == "TIMEOUT" && current_turn.has_timeout_elapsed() ) { + while( handle_mouseview( ctxt, action ) ) + { + if( action == "TIMEOUT" && current_turn.has_timeout_elapsed() ) + { break; } } @@ -337,7 +374,8 @@ static void rcdrive( int dx, int dy ) map &m = g->m; std::stringstream car_location_string( u.get_value( "remote_controlling" ) ); - if( car_location_string.str().empty() ) { + if( car_location_string.str().empty() ) + { //no turned radio car found u.add_msg_if_player( m_warning, _( "No radio car connected." ) ); return; @@ -349,12 +387,15 @@ static void rcdrive( int dx, int dy ) auto rc_pairs = m.get_rc_items( tripoint( cx, cy, cz ) ); auto rc_pair = rc_pairs.begin(); - for( ; rc_pair != rc_pairs.end(); ++rc_pair ) { - if( rc_pair->second->typeId() == "radio_car_on" && rc_pair->second->active ) { + for( ; rc_pair != rc_pairs.end(); ++rc_pair ) + { + if( rc_pair->second->typeId() == "radio_car_on" && rc_pair->second->active ) + { break; } } - if( rc_pair == rc_pairs.end() ) { + if( rc_pair == rc_pairs.end() ) + { u.add_msg_if_player( m_warning, _( "No radio car connected." ) ); u.remove_value( "remote_controlling" ); return; @@ -363,11 +404,14 @@ static void rcdrive( int dx, int dy ) tripoint dest( cx + dx, cy + dy, cz ); if( m.impassable( dest ) || !m.can_put_items_ter_furn( dest ) || - m.has_furn( dest ) ) { + m.has_furn( dest ) ) + { sounds::sound( dest, 7, sounds::sound_t::combat, _( "sound of a collision with an obstacle." ), true, "misc", "rc_car_hits_obstacle" ); return; - } else if( !m.add_item_or_charges( dest, *rc_car ).is_null() ) { + } + else if( !m.add_item_or_charges( dest, *rc_car ).is_null() ) + { tripoint src( cx, cy, cz ); //~ Sound of moving a remote controlled car sounds::sound( src, 6, sounds::sound_t::movement, _( "zzz…" ), true, "misc", "rc_car_drives" ); @@ -387,43 +431,54 @@ inline static void rcdrive( point d ) static void pldrive( int x, int y ) { - if( !g->check_safe_mode_allowed() ) { + if( !g->check_safe_mode_allowed() ) + { return; } player &u = g->u; vehicle *veh = g->remoteveh(); bool remote = true; int part = -1; - if( !veh ) { - if( const optional_vpart_position vp = g->m.veh_at( u.pos() ) ) { + if( !veh ) + { + if( const optional_vpart_position vp = g->m.veh_at( u.pos() ) ) + { veh = &vp->vehicle(); part = vp->part_index(); } remote = false; } - if( !veh ) { + if( !veh ) + { dbg( D_ERROR ) << "game::pldrive: can't find vehicle! Drive mode is now off."; debugmsg( "game::pldrive error: can't find vehicle! Drive mode is now off." ); u.in_vehicle = false; return; } - if( !remote ) { + if( !remote ) + { static const itype_id fuel_type_animal( "animal" ); const bool has_animal_controls = veh->part_with_feature( part, "CONTROL_ANIMAL", true ) >= 0; const bool has_controls = veh->part_with_feature( part, "CONTROLS", true ) >= 0; const bool has_animal = veh->has_engine_type( fuel_type_animal, false ) && veh->has_harnessed_animal(); - if( !has_controls && !has_animal_controls ) { + if( !has_controls && !has_animal_controls ) + { add_msg( m_info, _( "You can't drive the vehicle from here. You need controls!" ) ); u.controlling_vehicle = false; return; - } else if( !has_controls && has_animal_controls && !has_animal ) { + } + else if( !has_controls && has_animal_controls && !has_animal ) + { add_msg( m_info, _( "You can't drive this vehicle without an animal to pull it." ) ); u.controlling_vehicle = false; return; } - } else { - if( empty( veh->get_avail_parts( "REMOTE_CONTROLS" ) ) ) { + } + else + { + if( empty( veh->get_avail_parts( "REMOTE_CONTROLS" ) ) ) + { add_msg( m_info, _( "Can't drive this vehicle remotely. It has no working controls." ) ); return; } @@ -446,49 +501,67 @@ static void open() pgettext( "no door, gate, curtain, etc.", "There is nothing that can be opened nearby." ), ACTION_OPEN, false ); - if( !openp_ ) { + if( !openp_ ) + { return; } const tripoint openp = *openp_; u.moves -= 100; - if( const optional_vpart_position vp = m.veh_at( openp ) ) { + if( const optional_vpart_position vp = m.veh_at( openp ) ) + { vehicle *const veh = &vp->vehicle(); int openable = veh->next_part_to_open( vp->part_index() ); - if( openable >= 0 ) { + if( openable >= 0 ) + { const vehicle *player_veh = veh_pointer_or_null( m.veh_at( u.pos() ) ); bool outside = !player_veh || player_veh != veh; - if( !outside ) { - if( !veh->handle_potential_theft( dynamic_cast( g->u ) ) ) { + if( !outside ) + { + if( !veh->handle_potential_theft( dynamic_cast( g->u ) ) ) + { u.moves += 100; return; - } else { + } + else + { veh->open( openable ); } - } else { + } + else + { // Outside means we check if there's anything in that tile outside-openable. // If there is, we open everything on tile. This means opening a closed, // curtained door from outside is possible, but it will magically open the // curtains as well. int outside_openable = veh->next_part_to_open( vp->part_index(), true ); - if( outside_openable == -1 ) { + if( outside_openable == -1 ) + { const std::string name = veh->part_info( openable ).name(); add_msg( m_info, _( "That %s can only opened from the inside." ), name ); u.moves += 100; - } else { - if( !veh->handle_potential_theft( dynamic_cast( g->u ) ) ) { + } + else + { + if( !veh->handle_potential_theft( dynamic_cast( g->u ) ) ) + { u.moves += 100; return; - } else { + } + else + { veh->open_all_at( openable ); } } } - } else { + } + else + { // If there are any OPENABLE parts here, they must be already open if( const cata::optional already_open = vp.part_with_feature( "OPENABLE", - true ) ) { + true ) ) + { const std::string name = already_open->info().name(); add_msg( m_info, _( "That %s is already open." ), name ); } @@ -499,13 +572,17 @@ static void open() bool didit = m.open_door( openp, !m.is_outside( u.pos() ) ); - if( !didit ) { + if( !didit ) + { const ter_str_id tid = m.ter( openp ).id(); - if( m.has_flag( flag_LOCKED, openp ) ) { + if( m.has_flag( flag_LOCKED, openp ) ) + { add_msg( m_info, _( "The door is locked!" ) ); return; - } else if( tid.obj().close ) { + } + else if( tid.obj().close ) + { // if the following message appears unexpectedly, the prior check was for t_door_o add_msg( m_info, _( "That door is already open." ) ); u.moves += 100; @@ -520,7 +597,8 @@ static void close() { if( const cata::optional pnt = choose_adjacent_highlight( _( "Close where?" ), pgettext( "no door, gate, etc.", "There is nothing that can be closed nearby." ), - ACTION_CLOSE, false ) ) { + ACTION_CLOSE, false ) ) + { doors::close_door( g->m, g->u, *pnt ); } } @@ -528,21 +606,28 @@ static void close() static void handbrake() { const optional_vpart_position vp = g->m.veh_at( g->u.pos() ); - if( !vp ) { + if( !vp ) + { return; } vehicle *const veh = &vp->vehicle(); add_msg( _( "You pull a handbrake." ) ); veh->cruise_velocity = 0; - if( veh->last_turn != 0 && rng( 15, 60 ) * 100 < abs( veh->velocity ) ) { + if( veh->last_turn != 0 && rng( 15, 60 ) * 100 < abs( veh->velocity ) ) + { veh->skidding = true; add_msg( m_warning, _( "You lose control of %s." ), veh->name ); veh->turn( veh->last_turn > 0 ? 60 : -60 ); - } else { + } + else + { int braking_power = abs( veh->velocity ) / 2 + 10 * 100; - if( abs( veh->velocity ) < braking_power ) { + if( abs( veh->velocity ) < braking_power ) + { veh->stop(); - } else { + } + else + { int sgn = veh->velocity > 0 ? 1 : -1; veh->velocity = sgn * ( abs( veh->velocity ) - braking_power ); } @@ -556,10 +641,14 @@ static void grab() avatar &you = g->u; map &m = g->m; - if( you.get_grab_type() != OBJECT_NONE ) { - if( const optional_vpart_position vp = m.veh_at( you.pos() + you.grab_point ) ) { + if( you.get_grab_type() != OBJECT_NONE ) + { + if( const optional_vpart_position vp = m.veh_at( you.pos() + you.grab_point ) ) + { add_msg( _( "You release the %s." ), vp->vehicle().name ); - } else if( m.has_furn( you.pos() + you.grab_point ) ) { + } + else if( m.has_furn( you.pos() + you.grab_point ) ) + { add_msg( _( "You release the %s." ), m.furnname( you.pos() + you.grab_point ) ); } @@ -568,35 +657,47 @@ static void grab() } const cata::optional grabp_ = choose_adjacent( _( "Grab where?" ) ); - if( !grabp_ ) { + if( !grabp_ ) + { add_msg( _( "Never mind." ) ); return; } const tripoint grabp = *grabp_; - if( grabp == you.pos() ) { + if( grabp == you.pos() ) + { add_msg( _( "You get a hold of yourself." ) ); you.grab( OBJECT_NONE ); return; } - if( const optional_vpart_position vp = m.veh_at( grabp ) ) { - if( !vp->vehicle().handle_potential_theft( dynamic_cast( g->u ) ) ) { + if( const optional_vpart_position vp = m.veh_at( grabp ) ) + { + if( !vp->vehicle().handle_potential_theft( dynamic_cast( g->u ) ) ) + { return; } you.grab( OBJECT_VEHICLE, grabp - you.pos() ); add_msg( _( "You grab the %s." ), vp->vehicle().name ); - } else if( m.has_furn( grabp ) ) { // If not, grab furniture if present - if( !m.furn( grabp ).obj().is_movable() ) { + } + else if( m.has_furn( grabp ) ) // If not, grab furniture if present + { + if( !m.furn( grabp ).obj().is_movable() ) + { add_msg( _( "You can not grab the %s" ), m.furnname( grabp ) ); return; } you.grab( OBJECT_FURNITURE, grabp - you.pos() ); - if( !m.can_move_furniture( grabp, &you ) ) { + if( !m.can_move_furniture( grabp, &you ) ) + { add_msg( _( "You grab the %s. It feels really heavy." ), m.furnname( grabp ) ); - } else { + } + else + { add_msg( _( "You grab the %s." ), m.furnname( grabp ) ); } - } else { // TODO: grab mob? Captured squirrel = pet (or meat that stays fresh longer). + } + else // TODO: grab mob? Captured squirrel = pet (or meat that stays fresh longer). + { add_msg( m_info, _( "There's nothing to grab there!" ) ); } } @@ -606,18 +707,30 @@ static void haul() player &u = g->u; map &m = g->m; - if( u.is_hauling() ) { + if( u.is_hauling() ) + { u.stop_hauling(); - } else { - if( m.veh_at( u.pos() ) ) { + } + else + { + if( m.veh_at( u.pos() ) ) + { add_msg( m_info, _( "You cannot haul inside vehicles." ) ); - } else if( m.has_flag( TFLAG_DEEP_WATER, u.pos() ) ) { + } + else if( m.has_flag( TFLAG_DEEP_WATER, u.pos() ) ) + { add_msg( m_info, _( "You cannot haul while in deep water." ) ); - } else if( !m.can_put_items( u.pos() ) ) { + } + else if( !m.can_put_items( u.pos() ) ) + { add_msg( m_info, _( "You cannot haul items here." ) ); - } else if( !m.has_items( u.pos() ) ) { + } + else if( !m.has_items( u.pos() ) ) + { add_msg( m_info, _( "There are no items to haul here." ) ); - } else { + } + else + { u.start_hauling(); } } @@ -627,10 +740,13 @@ static void smash() { player &u = g->u; map &m = g->m; - if( u.is_mounted() ) { + if( u.is_mounted() ) + { auto mons = u.mounted_creature.get(); - if( mons->has_flag( MF_RIDEABLE_MECH ) ) { - if( !mons->check_mech_powered() ) { + if( mons->has_flag( MF_RIDEABLE_MECH ) ) + { + if( !mons->check_mech_powered() ) + { add_msg( m_bad, _( "Your %s refuses to move as its batteries have been drained." ), mons->get_name() ); return; @@ -642,25 +758,31 @@ static void smash() bool mech_smash = false; int smashskill; ///\EFFECT_STR increases smashing capability - if( u.is_mounted() ) { + if( u.is_mounted() ) + { auto mon = u.mounted_creature.get(); smashskill = u.str_cur + mon->mech_str_addition() + mon->type->melee_dice * mon->type->melee_sides; mech_smash = true; - } else { + } + else + { smashskill = u.str_cur + u.weapon.damage_melee( DT_BASH ); } const bool allow_floor_bash = debug_mode; // Should later become "true" const cata::optional smashp_ = choose_adjacent( _( "Smash where?" ), allow_floor_bash ); - if( !smashp_ ) { + if( !smashp_ ) + { return; } tripoint smashp = *smashp_; bool smash_floor = false; - if( smashp.z != u.posz() ) { - if( smashp.z > u.posz() ) { + if( smashp.z != u.posz() ) + { + if( smashp.z > u.posz() ) + { // TODO: Knock on the ceiling return; } @@ -668,13 +790,16 @@ static void smash() smashp.z = u.posz(); smash_floor = true; } - if( u.is_mounted() ) { + if( u.is_mounted() ) + { monster *crit = u.mounted_creature.get(); - if( crit->has_flag( MF_RIDEABLE_MECH ) ) { + if( crit->has_flag( MF_RIDEABLE_MECH ) ) + { crit->use_mech_power( -3 ); } } - if( m.get_field( smashp, fd_web ) != nullptr ) { + if( m.get_field( smashp, fd_web ) != nullptr ) + { m.remove_field( smashp, fd_web ); sounds::sound( smashp, 2, sounds::sound_t::combat, _( "hsh!" ), true, "smash", "web" ); add_msg( m_info, _( "You brush aside some webs." ) ); @@ -682,9 +807,11 @@ static void smash() return; } - for( const auto &maybe_corpse : m.i_at( smashp ) ) { + for( const auto &maybe_corpse : m.i_at( smashp ) ) + { if( maybe_corpse.is_corpse() && maybe_corpse.damage() < maybe_corpse.max_damage() && - maybe_corpse.get_mtype()->has_flag( MF_REVIVES ) ) { + maybe_corpse.get_mtype()->has_flag( MF_REVIVES ) ) + { // do activity forever. ACT_PULP stops itself u.assign_activity( ACT_PULP, calendar::INDEFINITELY_LONG, 0 ); u.activity.placement = g->m.getabs( smashp ); @@ -692,32 +819,40 @@ static void smash() } } vehicle *veh = veh_pointer_or_null( g->m.veh_at( smashp ) ); - if( veh != nullptr ) { - if( !veh->handle_potential_theft( dynamic_cast( g->u ) ) ) { + if( veh != nullptr ) + { + if( !veh->handle_potential_theft( dynamic_cast( g->u ) ) ) + { return; } } didit = m.bash( smashp, smashskill, false, false, smash_floor ).did_bash; - if( didit ) { - if( !mech_smash ) { + if( didit ) + { + if( !mech_smash ) + { u.increase_activity_level( MODERATE_EXERCISE ); u.handle_melee_wear( u.weapon ); const int mod_sta = ( ( u.weapon.weight() / 10_gram ) + 200 + static_cast ( get_option( "PLAYER_BASE_STAMINA_REGEN_RATE" ) ) ) * -1; u.mod_stamina( mod_sta ); - if( u.get_skill_level( skill_melee ) == 0 ) { + if( u.get_skill_level( skill_melee ) == 0 ) + { u.practice( skill_melee, rng( 0, 1 ) * rng( 0, 1 ) ); } const int vol = u.weapon.volume() / units::legacy_volume_factor; if( u.weapon.made_of( material_id( "glass" ) ) && - rng( 0, vol + 3 ) < vol ) { + rng( 0, vol + 3 ) < vol ) + { add_msg( m_bad, _( "Your %s shatters!" ), u.weapon.tname() ); - for( auto &elem : u.weapon.contents ) { + for( auto &elem : u.weapon.contents ) + { m.add_item_or_charges( u.pos(), elem ); } sounds::sound( u.pos(), 24, sounds::sound_t::combat, "CRACK!", true, "smash", "glass" ); u.deal_damage( nullptr, bp_hand_r, damage_instance( DT_CUT, rng( 0, vol ) ) ); - if( vol > 20 ) { + if( vol > 20 ) + { // Hurt left arm too, if it was big u.deal_damage( nullptr, bp_hand_l, damage_instance( DT_CUT, rng( 0, static_cast( vol * .5 ) ) ) ); @@ -728,16 +863,22 @@ static void smash() } u.moves -= move_cost; - if( smashskill < m.bash_resistance( smashp ) && one_in( 10 ) ) { - if( m.has_furn( smashp ) && m.furn( smashp ).obj().bash.str_min != -1 ) { + if( smashskill < m.bash_resistance( smashp ) && one_in( 10 ) ) + { + if( m.has_furn( smashp ) && m.furn( smashp ).obj().bash.str_min != -1 ) + { // %s is the smashed furniture add_msg( m_neutral, _( "You don't seem to be damaging the %s." ), m.furnname( smashp ) ); - } else { + } + else + { // %s is the smashed terrain add_msg( m_neutral, _( "You don't seem to be damaging the %s." ), m.tername( smashp ) ); } } - } else { + } + else + { add_msg( _( "There's nothing there to smash!" ) ); } } @@ -770,14 +911,17 @@ static void wait() bool setting_alarm = false; if( u.controlling_vehicle && ( g->m.veh_at( u.pos() )->vehicle().velocity || - g->m.veh_at( u.pos() )->vehicle().cruise_velocity ) ) { + g->m.veh_at( u.pos() )->vehicle().cruise_velocity ) ) + { popup( _( "You can't pass time while controlling a moving vehicle." ) ); return; } - if( u.has_alarm_clock() ) { + if( u.has_alarm_clock() ) + { int alarm_query = try_set_alarm(); - if( alarm_query == UILIST_CANCEL ) { + if( alarm_query == UILIST_CANCEL ) + { return; } setting_alarm = alarm_query == 1; @@ -787,11 +931,13 @@ static void wait() const auto add_menu_item = [ &as_m, &durations, has_watch ] ( int retval, int hotkey, const std::string &caption = "", - const time_duration &duration = time_duration::from_turns( calendar::INDEFINITELY_LONG ) ) { + const time_duration &duration = time_duration::from_turns( calendar::INDEFINITELY_LONG ) ) + { std::string text( caption ); - if( has_watch && duration != time_duration::from_turns( calendar::INDEFINITELY_LONG ) ) { + if( has_watch && duration != time_duration::from_turns( calendar::INDEFINITELY_LONG ) ) + { const std::string dur_str( to_string( duration ) ); text += ( text.empty() ? dur_str : string_format( " (%s)", dur_str ) ); } @@ -799,23 +945,29 @@ static void wait() durations.emplace( retval, duration ); }; - if( setting_alarm ) { + if( setting_alarm ) + { add_menu_item( 0, '0', "", 30_minutes ); - for( int i = 1; i <= 9; ++i ) { + for( int i = 1; i <= 9; ++i ) + { add_menu_item( i, '0' + i, "", i * 1_hours ); } - } else { - if( g->u.get_stamina() < g->u.get_stamina_max() ) { + } + else + { + if( g->u.get_stamina() < g->u.get_stamina_max() ) + { as_m.addentry( 12, true, 'w', _( "Wait until you catch your breath" ) ); durations.emplace( 12, 15_minutes ); // to hide it from showing } add_menu_item( 1, '1', !has_watch ? _( "Wait 300 heartbeats" ) : "", 5_minutes ); add_menu_item( 2, '2', !has_watch ? _( "Wait 1800 heartbeats" ) : "", 30_minutes ); - if( has_watch ) { + if( has_watch ) + { add_menu_item( 3, '3', "", 1_hours ); add_menu_item( 4, '4', "", 2_hours ); add_menu_item( 5, '5', "", 3_hours ); @@ -823,9 +975,11 @@ static void wait() } } - if( g->get_levz() >= 0 || has_watch ) { + if( g->get_levz() >= 0 || has_watch ) + { const time_point last_midnight = calendar::turn - time_past_midnight( calendar::turn ); - const auto diurnal_time_before = []( const time_point & p ) { + const auto diurnal_time_before = []( const time_point & p ) + { // Either the given time is in the future (e.g. waiting for sunset while it's early morning), // than use it directly. Otherwise (in the past), add a single day to get the same time tomorrow // (e.g. waiting for sunrise while it's noon). @@ -845,12 +999,16 @@ static void wait() add_menu_item( 10, 'm', setting_alarm ? _( "Set alarm for midnight" ) : _( "Wait till midnight" ), diurnal_time_before( last_midnight + 0_hours ) ); - if( setting_alarm ) { - if( u.has_effect( effect_alarm_clock ) ) { + if( setting_alarm ) + { + if( u.has_effect( effect_alarm_clock ) ) + { add_menu_item( 11, 'x', _( "Cancel the currently set alarm." ), 0_turns ); } - } else { + } + else + { add_menu_item( 11, 'W', _( "Wait till weather changes" ) ); } } @@ -861,29 +1019,41 @@ static void wait() as_m.query(); /* calculate key and window variables, generate window, and loop until we get a valid answer */ const auto dur_iter = durations.find( as_m.ret ); - if( dur_iter == durations.end() ) { + if( dur_iter == durations.end() ) + { return; } const time_duration time_to_wait = dur_iter->second; - if( setting_alarm ) { + if( setting_alarm ) + { // Setting alarm u.remove_effect( effect_alarm_clock ); - if( as_m.ret == 11 ) { + if( as_m.ret == 11 ) + { add_msg( _( "You cancel your alarm." ) ); - } else { + } + else + { u.add_effect( effect_alarm_clock, time_to_wait ); add_msg( _( "You set your alarm." ) ); } - } else { + } + else + { // Waiting activity_id actType; - if( as_m.ret == 11 ) { + if( as_m.ret == 11 ) + { actType = ACT_WAIT_WEATHER; - } else if( as_m.ret == 12 ) { + } + else if( as_m.ret == 12 ) + { actType = ACT_WAIT_STAMINA; - } else { + } + else + { actType = ACT_WAIT; } @@ -896,59 +1066,71 @@ static void wait() static void sleep() { player &u = g->u; - if( u.is_mounted() ) { + if( u.is_mounted() ) + { u.add_msg_if_player( m_info, _( "You cannot sleep while mounted." ) ); return; } uilist as_m; as_m.text = _( "Are you sure you want to sleep?" ); // (Y)es/(S)ave before sleeping/(N)o - as_m.entries.emplace_back( 0, true, - get_option( "FORCE_CAPITAL_YN" ) ? 'Y' : 'y', - _( "Yes." ) ); - as_m.entries.emplace_back( 1, g->get_moves_since_last_save(), - get_option( "FORCE_CAPITAL_YN" ) ? 'S' : 's', - _( "Yes, and save game before sleeping." ) ); as_m.entries.emplace_back( 2, true, get_option( "FORCE_CAPITAL_YN" ) ? 'N' : 'n', _( "No." ) ); + as_m.entries.emplace_back( 1, g->get_moves_since_last_save(), + get_option( "FORCE_CAPITAL_YN" ) ? 'S' : 's', + _( "Yes, and save game before sleeping." ) ); + as_m.entries.emplace_back( 0, true, + get_option( "FORCE_CAPITAL_YN" ) ? 'Y' : 'y', + _( "Yes." ) ); + // List all active items, bionics or mutations so player can deactivate them std::vector active; - for( auto &it : u.inv_dump() ) { + for( auto &it : u.inv_dump() ) + { if( it->active && ( it->charges > 0 || it->units_remaining( u ) > 0 ) && - it->is_transformable() ) { + it->is_transformable() ) + { active.push_back( it->tname() ); } } - for( int i = 0; i < g->u.num_bionics(); i++ ) { + for( int i = 0; i < g->u.num_bionics(); i++ ) + { const bionic &bio = u.bionic_at_index( i ); - if( !bio.powered ) { + if( !bio.powered ) + { continue; } // some bionics // bio_alarm is useful for waking up during sleeping // turning off bio_leukocyte has 'unpleasant side effects' - if( bio.info().sleep_friendly ) { + if( bio.info().sleep_friendly ) + { continue; } const auto &info = bio.info(); - if( info.power_over_time > 0_kJ ) { + if( info.power_over_time > 0_kJ ) + { active.push_back( info.name.translated() ); } } - for( auto &mut : u.get_mutations() ) { + for( auto &mut : u.get_mutations() ) + { const auto &mdata = mut.obj(); - if( mdata.cost > 0 && u.has_active_mutation( mut ) ) { + if( mdata.cost > 0 && u.has_active_mutation( mut ) ) + { active.push_back( mdata.name() ); } } // check for deactivating any currently played music instrument. - for( auto &item : u.inv_dump() ) { - if( item->active && item->get_use( "musical_instrument" ) != nullptr ) { + for( auto &item : u.inv_dump() ) + { + if( item->active && item->get_use( "musical_instrument" ) != nullptr ) + { u.add_msg_if_player( _( "You stop playing your %s before trying to sleep." ), item->tname() ); // deactivate instrument item->active = false; @@ -957,11 +1139,13 @@ static void sleep() // ask for deactivation std::stringstream data; - if( !active.empty() ) { + if( !active.empty() ) + { data << as_m.text << std::endl; data << _( "You may want to deactivate these before you sleep." ) << std::endl; data << " " << std::endl; - for( auto &a : active ) { + for( auto &a : active ) + { data << "" << a << "" << std::endl; } as_m.text = data.str(); @@ -971,18 +1155,23 @@ static void sleep() and loop until we get a valid answer. */ as_m.query(); - if( as_m.ret == 1 ) { + if( as_m.ret == 1 ) + { g->quicksave(); - } else if( as_m.ret == 2 || as_m.ret < 0 ) { + } + else if( as_m.ret == 2 || as_m.ret < 0 ) + { return; } time_duration try_sleep_dur = 24_hours; std::string deaf_text; - if( g->u.is_deaf() ) { + if( g->u.is_deaf() ) + { deaf_text = _( " (DEAF!)" ); } - if( u.has_alarm_clock() ) { + if( u.has_alarm_clock() ) + { /* Reuse menu to ask player whether they want to set an alarm. */ bool can_hibernate = u.get_hunger() < -60 && u.has_active_mutation( trait_HIBERNATE ); @@ -997,16 +1186,20 @@ static void sleep() get_option( "FORCE_CAPITAL_YN" ) ? 'N' : 'n', _( "No, don't set an alarm." ) ); - for( int i = 3; i <= 9; ++i ) { + for( int i = 3; i <= 9; ++i ) + { as_m.entries.emplace_back( i, true, '0' + i, string_format( _( "Set alarm to wake up in %i hours." ), i ) + deaf_text ); } as_m.query(); - if( as_m.ret >= 3 && as_m.ret <= 9 ) { + if( as_m.ret >= 3 && as_m.ret <= 9 ) + { u.add_effect( effect_alarm_clock, 1_hours * as_m.ret ); try_sleep_dur = 1_hours * as_m.ret + 1_turns; - } else if( as_m.ret < 0 ) { + } + else if( as_m.ret < 0 ) + { return; } } @@ -1017,7 +1210,8 @@ static void sleep() static void loot() { - enum ZoneFlags { + enum ZoneFlags + { None = 1, SortLoot = 2, FertilizePlots = 16, @@ -1041,7 +1235,8 @@ static void loot() mgr.cache_vzones(); flags |= g->check_near_zone( zone_type_id( "LOOT_UNSORTED" ), u.pos() ) ? SortLoot : 0; - if( g->check_near_zone( zone_type_id( "FARM_PLOT" ), u.pos() ) ) { + if( g->check_near_zone( zone_type_id( "FARM_PLOT" ), u.pos() ) ) + { flags |= FertilizePlots; flags |= MultiFarmPlots; } @@ -1054,7 +1249,8 @@ static void loot() u.pos() ) ? Multideconvehicle : 0; flags |= g->check_near_zone( zone_type_id( "VEHICLE_REPAIR" ), u.pos() ) ? Multirepairvehicle : 0; flags |= g->check_near_zone( zone_type_id( "LOOT_CORPSE" ), u.pos() ) ? MultiButchery : 0; - if( flags == 0 ) { + if( flags == 0 ) + { add_msg( m_info, _( "There is no compatible zone nearby." ) ); add_msg( m_info, _( "Compatible zones are %s and %s" ), mgr.get_name_from_type( zone_type_id( "LOOT_UNSORTED" ) ), @@ -1066,42 +1262,51 @@ static void loot() menu.text = _( "Pick action:" ); menu.desc_enabled = true; - if( flags & SortLoot ) { + if( flags & SortLoot ) + { menu.addentry_desc( SortLoot, true, 'o', _( "Sort out my loot" ), _( "Sorts out the loot from Loot: Unsorted zone to nearby appropriate Loot zones. Uses empty space in your inventory or utilizes a cart, if you are holding one." ) ); } - if( flags & FertilizePlots ) { + if( flags & FertilizePlots ) + { menu.addentry_desc( FertilizePlots, has_fertilizer, 'f', !has_fertilizer ? _( "Fertilize plots… you don't have any fertilizer" ) : _( "Fertilize plots" ), _( "Fertilize any nearby Farm: Plot zones." ) ); } - if( flags & ConstructPlots ) { + if( flags & ConstructPlots ) + { menu.addentry_desc( ConstructPlots, true, 'c', _( "Construct plots" ), _( "Work on any nearby Blueprint: construction zones." ) ); } - if( flags & MultiFarmPlots ) { + if( flags & MultiFarmPlots ) + { menu.addentry_desc( MultiFarmPlots, true, 'm', _( "Farm plots" ), _( "Till and plant on any nearby farm plots - auto-fetch seeds and tools." ) ); } - if( flags & Multichoptrees ) { + if( flags & Multichoptrees ) + { menu.addentry_desc( Multichoptrees, true, 'C', _( "Chop trees" ), _( "Chop down any trees in the designated zone - auto-fetch tools." ) ); } - if( flags & Multichopplanks ) { + if( flags & Multichopplanks ) + { menu.addentry_desc( Multichopplanks, true, 'P', _( "Chop planks" ), _( "Auto-chop logs in wood loot zones into planks - auto-fetch tools." ) ); } - if( flags & Multideconvehicle ) { + if( flags & Multideconvehicle ) + { menu.addentry_desc( Multideconvehicle, true, 'v', _( "Deconstruct vehicle" ), _( "Auto-deconstruct vehicle in designated zone - auto-fetch tools." ) ); } - if( flags & Multirepairvehicle ) { + if( flags & Multirepairvehicle ) + { menu.addentry_desc( Multirepairvehicle, true, 'V', _( "Repair vehicle" ), _( "Auto-repair vehicle in designated zone - auto-fetch tools." ) ); } - if( flags & MultiButchery ) { + if( flags & MultiButchery ) + { menu.addentry_desc( MultiButchery, true, 'B', _( "Butcher corpses" ), _( "Auto-butcher anything in corpse loot zones - auto-fetch tools." ) ); } @@ -1109,40 +1314,41 @@ static void loot() menu.query(); flags = ( menu.ret >= 0 ) ? menu.ret : None; - switch( flags ) { - case None: - add_msg( _( "Never mind." ) ); - break; - case SortLoot: - u.assign_activity( ACT_MOVE_LOOT ); - break; - case FertilizePlots: - u.assign_activity( ACT_FERTILIZE_PLOT ); - break; - case ConstructPlots: - u.assign_activity( ACT_MULTIPLE_CONSTRUCTION ); - break; - case MultiFarmPlots: - u.assign_activity( ACT_MULTIPLE_FARM ); - break; - case Multichoptrees: - u.assign_activity( ACT_MULTIPLE_CHOP_TREES ); - break; - case Multichopplanks: - u.assign_activity( ACT_MULTIPLE_CHOP_PLANKS ); - break; - case Multideconvehicle: - u.assign_activity( ACT_VEHICLE_DECONSTRUCTION ); - break; - case Multirepairvehicle: - u.assign_activity( ACT_VEHICLE_REPAIR ); - break; - case MultiButchery: - u.assign_activity( ACT_MULTIPLE_BUTCHER ); - break; - default: - debugmsg( "Unsupported flag" ); - break; + switch( flags ) + { + case None: + add_msg( _( "Never mind." ) ); + break; + case SortLoot: + u.assign_activity( ACT_MOVE_LOOT ); + break; + case FertilizePlots: + u.assign_activity( ACT_FERTILIZE_PLOT ); + break; + case ConstructPlots: + u.assign_activity( ACT_MULTIPLE_CONSTRUCTION ); + break; + case MultiFarmPlots: + u.assign_activity( ACT_MULTIPLE_FARM ); + break; + case Multichoptrees: + u.assign_activity( ACT_MULTIPLE_CHOP_TREES ); + break; + case Multichopplanks: + u.assign_activity( ACT_MULTIPLE_CHOP_PLANKS ); + break; + case Multideconvehicle: + u.assign_activity( ACT_VEHICLE_DECONSTRUCTION ); + break; + case Multirepairvehicle: + u.assign_activity( ACT_VEHICLE_REPAIR ); + break; + case MultiButchery: + u.assign_activity( ACT_MULTIPLE_BUTCHER ); + break; + default: + debugmsg( "Unsupported flag" ); + break; } } @@ -1151,9 +1357,12 @@ static void wear() avatar &u = g->u; item_location loc = game_menus::inv::wear( u ); - if( loc ) { + if( loc ) + { u.wear( u.i_at( loc.obtain( u ) ) ); - } else { + } + else + { add_msg( _( "Never mind." ) ); } } @@ -1163,9 +1372,12 @@ static void takeoff() avatar &u = g->u; item_location loc = game_menus::inv::take_off( u ); - if( loc ) { + if( loc ) + { u.takeoff( u.i_at( loc.obtain( u ) ) ); - } else { + } + else + { add_msg( _( "Never mind." ) ); } } @@ -1176,16 +1388,22 @@ static void read() // Can read items from inventory or within one tile (including in vehicles) item_location loc = game_menus::inv::read( u ); - if( loc ) { - if( loc->type->can_use( "learn_spell" ) ) { + if( loc ) + { + if( loc->type->can_use( "learn_spell" ) ) + { item spell_book = *loc.get_item(); spell_book.get_use( "learn_spell" )->call( u, spell_book, spell_book.active, u.pos() ); - } else { + } + else + { // calling obtain() invalidates the item pointer // TODO: find a way to do this without an int index u.read( u.i_at( loc.obtain( u ) ) ); } - } else { + } + else + { add_msg( _( "Never mind." ) ); } } @@ -1199,7 +1417,8 @@ static void reach_attack( int range, player &u ) g->m.draw( g->w_terrain, u.pos() ); std::vector trajectory = target_handler().target_ui( u, TARGET_MODE_REACH, &u.weapon, range ); - if( !trajectory.empty() ) { + if( !trajectory.empty() ) + { u.reach_attack( trajectory.back() ); } g->draw_ter(); @@ -1213,73 +1432,86 @@ static void fire() player &u = g->u; // Use vehicle turret or draw a pistol from a holster if unarmed - if( !u.is_armed() ) { + if( !u.is_armed() ) + { const optional_vpart_position vp = g->m.veh_at( u.pos() ); turret_data turret; // TODO: move direct turret firing from ACTION_FIRE to separate function. - if( vp && ( turret = vp->vehicle().turret_query( u.pos() ) ) ) { - switch( turret.query() ) { - case turret_data::status::no_ammo: - add_msg( m_bad, _( "The %s is out of ammo." ), turret.name() ); - break; - - case turret_data::status::no_power: - add_msg( m_bad, _( "The %s is not powered." ), turret.name() ); - break; - - case turret_data::status::ready: { - // if more than one firing mode provide callback to cycle through them - target_callback switch_mode; - if( turret.base()->gun_all_modes().size() > 1 ) { - switch_mode = [&turret]( item * obj ) { - obj->gun_cycle_mode(); - // currently gun modes do not change ammo but they may in the future - return turret.ammo_current() == "null" ? nullptr : - item::find_type( turret.ammo_current() ); - }; - } - - // if multiple ammo types available provide callback to cycle alternatives - target_callback switch_ammo; - if( turret.ammo_options().size() > 1 ) { - switch_ammo = [&turret]( item * ) { - const auto opts = turret.ammo_options(); - auto iter = opts.find( turret.ammo_current() ); - turret.ammo_select( ++iter != opts.end() ? *iter : *opts.begin() ); - return item::find_type( turret.ammo_current() ); - }; - } - - // callbacks for handling setup and cleanup of turret firing - firing_callback prepare_fire = [&u, &turret]( const int ) { - turret.prepare_fire( u ); - }; - firing_callback post_fire = [&u, &turret]( const int shots ) { - turret.post_fire( u, shots ); + if( vp && ( turret = vp->vehicle().turret_query( u.pos() ) ) ) + { + switch( turret.query() ) + { + case turret_data::status::no_ammo: + add_msg( m_bad, _( "The %s is out of ammo." ), turret.name() ); + break; + + case turret_data::status::no_power: + add_msg( m_bad, _( "The %s is not powered." ), turret.name() ); + break; + + case turret_data::status::ready: + { + // if more than one firing mode provide callback to cycle through them + target_callback switch_mode; + if( turret.base()->gun_all_modes().size() > 1 ) + { + switch_mode = [&turret]( item * obj ) + { + obj->gun_cycle_mode(); + // currently gun modes do not change ammo but they may in the future + return turret.ammo_current() == "null" ? nullptr : + item::find_type( turret.ammo_current() ); }; + } - targeting_data args = { - TARGET_MODE_TURRET_MANUAL, & *turret.base(), - turret.range(), 0, false, turret.ammo_data(), - switch_mode, switch_ammo, prepare_fire, post_fire + // if multiple ammo types available provide callback to cycle alternatives + target_callback switch_ammo; + if( turret.ammo_options().size() > 1 ) + { + switch_ammo = [&turret]( item * ) + { + const auto opts = turret.ammo_options(); + auto iter = opts.find( turret.ammo_current() ); + turret.ammo_select( ++iter != opts.end() ? *iter : *opts.begin() ); + return item::find_type( turret.ammo_current() ); }; - u.set_targeting_data( args ); - avatar_action::fire( g->u, g->m ); - - break; } - default: - debugmsg( "unknown turret status" ); - break; + // callbacks for handling setup and cleanup of turret firing + firing_callback prepare_fire = [&u, &turret]( const int ) + { + turret.prepare_fire( u ); + }; + firing_callback post_fire = [&u, &turret]( const int shots ) + { + turret.post_fire( u, shots ); + }; + + targeting_data args = + { + TARGET_MODE_TURRET_MANUAL, & *turret.base(), + turret.range(), 0, false, turret.ammo_data(), + switch_mode, switch_ammo, prepare_fire, post_fire + }; + u.set_targeting_data( args ); + avatar_action::fire( g->u, g->m ); + + break; + } + + default: + debugmsg( "unknown turret status" ); + break; } return; } - if( vp.part_with_feature( "CONTROLS", true ) ) { - if( vp->vehicle().turrets_aim_and_fire() ) { + if( vp.part_with_feature( "CONTROLS", true ) ) + { + if( vp->vehicle().turrets_aim_and_fire() ) + { return; } } @@ -1287,9 +1519,11 @@ static void fire() std::vector options; std::vector> actions; - for( auto &w : u.worn ) { + for( auto &w : u.worn ) + { if( w.type->can_use( "holster" ) && !w.has_flag( flag_NO_QUICKDRAW ) && - !w.contents.empty() && w.contents.front().is_gun() ) { + !w.contents.empty() && w.contents.front().is_gun() ) + { //~ draw (first) gun contained in holster //~ %1$s: weapon name, %2$s: container name, %3$d: remaining ammo count options.push_back( string_format( pgettext( "holster", "%1$s from %2$s (%3$d)" ), @@ -1299,46 +1533,67 @@ static void fire() actions.emplace_back( [&] { u.invoke_item( &w, "holster" ); } ); - } else if( w.is_gun() && w.gunmod_find( "shoulder_strap" ) ) { + } + else if( w.is_gun() && w.gunmod_find( "shoulder_strap" ) ) + { // wield item currently worn using shoulder strap options.push_back( w.display_name() ); actions.emplace_back( [&] { u.wield( w ); } ); } } - if( !options.empty() ) { + if( !options.empty() ) + { int sel = uilist( _( "Draw what?" ), options ); - if( sel >= 0 ) { + if( sel >= 0 ) + { actions[sel](); } } } - if( u.weapon.is_gun() && !u.weapon.gun_current_mode().melee() ) { + if( u.weapon.is_gun() && !u.weapon.gun_current_mode().melee() ) + { avatar_action::fire( g->u, g->m, u.weapon ); - } else if( u.weapon.has_flag( flag_REACH_ATTACK ) ) { + } + else if( u.weapon.has_flag( flag_REACH_ATTACK ) ) + { int range = u.weapon.has_flag( flag_REACH3 ) ? 3 : 2; - if( u.has_effect( effect_relax_gas ) ) { - if( one_in( 8 ) ) { + if( u.has_effect( effect_relax_gas ) ) + { + if( one_in( 8 ) ) + { add_msg( m_good, _( "Your willpower asserts itself, and so do you!" ) ); reach_attack( range, u ); - } else { + } + else + { u.moves -= rng( 2, 8 ) * 10; add_msg( m_bad, _( "You're too pacified to strike anything…" ) ); } - } else { + } + else + { reach_attack( range, u ); } - } else if( u.weapon.is_gun() && u.weapon.gun_current_mode().flags.count( flag_REACH_ATTACK ) ) { + } + else if( u.weapon.is_gun() && u.weapon.gun_current_mode().flags.count( flag_REACH_ATTACK ) ) + { int range = u.weapon.gun_current_mode().qty; - if( u.has_effect( effect_relax_gas ) ) { - if( one_in( 8 ) ) { + if( u.has_effect( effect_relax_gas ) ) + { + if( one_in( 8 ) ) + { add_msg( m_good, _( "Your willpower asserts itself, and so do you!" ) ); reach_attack( range, u ); - } else { + } + else + { u.moves -= rng( 2, 8 ) * 10; add_msg( m_bad, _( "You're too pacified to strike anything…" ) ); } - } else { + } + else + { reach_attack( range, u ); } } @@ -1356,18 +1611,19 @@ static void open_movement_mode_menu() as_m.entries.emplace_back( 2, true, 'c', _( "Crouch" ) ); as_m.query(); - switch( as_m.ret ) { - case 0: - u.set_movement_mode( CMM_WALK ); - break; - case 1: - u.set_movement_mode( CMM_RUN ); - break; - case 2: - u.set_movement_mode( CMM_CROUCH ); - break; - default: - break; + switch( as_m.ret ) + { + case 0: + u.set_movement_mode( CMM_WALK ); + break; + case 1: + u.set_movement_mode( CMM_RUN ); + break; + case 2: + u.set_movement_mode( CMM_CROUCH ); + break; + default: + break; } } @@ -1377,42 +1633,50 @@ static void cast_spell() std::vector spells = u.magic.spells(); - if( spells.empty() ) { + if( spells.empty() ) + { add_msg( m_bad, _( "You don't know any spells to cast." ) ); return; } bool can_cast_spells = false; - for( spell_id sp : spells ) { + for( spell_id sp : spells ) + { spell temp_spell = u.magic.get_spell( sp ); - if( temp_spell.can_cast( u ) ) { + if( temp_spell.can_cast( u ) ) + { can_cast_spells = true; } } - if( !can_cast_spells ) { + if( !can_cast_spells ) + { add_msg( m_bad, _( "You can't cast any of the spells you know!" ) ); } const int spell_index = u.magic.select_spell( u ); - if( spell_index < 0 ) { + if( spell_index < 0 ) + { return; } spell &sp = *u.magic.get_spells()[spell_index]; if( u.is_armed() && !sp.has_flag( spell_flag::NO_HANDS ) && - !u.weapon.has_flag( flag_MAGIC_FOCUS ) ) { + !u.weapon.has_flag( flag_MAGIC_FOCUS ) ) + { add_msg( m_bad, _( "You need your hands free to cast this spell!" ) ); return; } - if( !u.magic.has_enough_energy( u, sp ) ) { + if( !u.magic.has_enough_energy( u, sp ) ) + { add_msg( m_bad, _( "You don't have enough %s to cast the spell." ), sp.energy_string() ); return; } - if( sp.energy_source() == hp_energy && !u.has_quality( qual_CUT ) ) { + if( sp.energy_source() == hp_energy && !u.has_quality( qual_CUT ) ) + { add_msg( m_bad, _( "You cannot cast Blood Magic without a cutting implement." ) ); return; } @@ -1425,8 +1689,10 @@ static void cast_spell() // [2] this value overrides the mana cost if set to 0 cast_spell.values.emplace_back( 1 ); cast_spell.name = sp.id().c_str(); - if( u.magic.casting_ignore ) { - const std::vector ignored_distractions = { + if( u.magic.casting_ignore ) + { + const std::vector ignored_distractions = + { distraction_type::noise, distraction_type::pain, distraction_type::attacked, @@ -1436,7 +1702,8 @@ static void cast_spell() distraction_type::motion_alarm, distraction_type::weather_change }; - for( const distraction_type ignored : ignored_distractions ) { + for( const distraction_type ignored : ignored_distractions ) + { cast_spell.ignore_distraction( ignored ); } } @@ -1454,18 +1721,19 @@ void game::open_consume_item_menu() as_m.entries.emplace_back( 2, true, 'm', _( "Medication" ) ); as_m.query(); - switch( as_m.ret ) { - case 0: - avatar_action::eat( u, game_menus::inv::consume_food( u ) ); - break; - case 1: - avatar_action::eat( u, game_menus::inv::consume_drink( u ) ); - break; - case 2: - avatar_action::eat( u, game_menus::inv::consume_meds( u ) ); - break; - default: - break; + switch( as_m.ret ) + { + case 0: + avatar_action::eat( u, game_menus::inv::consume_food( u ) ); + break; + case 1: + avatar_action::eat( u, game_menus::inv::consume_drink( u ) ); + break; + case 2: + avatar_action::eat( u, game_menus::inv::consume_meds( u ) ); + break; + default: + break; } } @@ -1476,18 +1744,24 @@ bool game::handle_action() action_id act = ACTION_NULL; user_turn current_turn; // Check if we have an auto-move destination - if( u.has_destination() ) { + if( u.has_destination() ) + { act = u.get_next_auto_move_direction(); - if( act == ACTION_NULL ) { + if( act == ACTION_NULL ) + { add_msg( m_info, _( "Auto-move canceled" ) ); u.clear_destination(); return false; } - } else if( u.has_destination_activity() ) { + } + else if( u.has_destination_activity() ) + { // starts destination activity after the player successfully reached his destination u.start_destination_activity(); return false; - } else { + } + else + { // No auto-move, ask player for input ctxt = get_player_input( action ); } @@ -1500,98 +1774,124 @@ bool game::handle_action() // of location clicked. cata::optional mouse_target; - if( uquit == QUIT_WATCH && action == "QUIT" ) { + if( uquit == QUIT_WATCH && action == "QUIT" ) + { uquit = QUIT_DIED; return false; } - if( act == ACTION_NULL ) { + if( act == ACTION_NULL ) + { act = look_up_action( action ); - if( act == ACTION_KEYBINDINGS ) { + if( act == ACTION_KEYBINDINGS ) + { // already handled by input context refresh_all(); return false; } - if( act == ACTION_MAIN_MENU ) { - if( uquit == QUIT_WATCH ) { + if( act == ACTION_MAIN_MENU ) + { + if( uquit == QUIT_WATCH ) + { return false; } // No auto-move actions have or can be set at this point. u.clear_destination(); destination_preview.clear(); act = handle_main_menu(); - if( act == ACTION_NULL ) { + if( act == ACTION_NULL ) + { return false; } } - if( act == ACTION_ACTIONMENU ) { - if( uquit == QUIT_WATCH ) { + if( act == ACTION_ACTIONMENU ) + { + if( uquit == QUIT_WATCH ) + { return false; } // No auto-move actions have or can be set at this point. u.clear_destination(); destination_preview.clear(); act = handle_action_menu(); - if( act == ACTION_NULL ) { + if( act == ACTION_NULL ) + { return false; } #if defined(__ANDROID__) - if( get_option( "ANDROID_ACTIONMENU_AUTOADD" ) && ctxt.get_category() == "DEFAULTMODE" ) { + if( get_option( "ANDROID_ACTIONMENU_AUTOADD" ) && ctxt.get_category() == "DEFAULTMODE" ) + { add_best_key_for_action_to_quick_shortcuts( act, ctxt.get_category(), false ); } #endif } - if( act == ACTION_KEYBINDINGS ) { + if( act == ACTION_KEYBINDINGS ) + { u.clear_destination(); destination_preview.clear(); act = ctxt.display_menu( true ); - if( act == ACTION_NULL ) { + if( act == ACTION_NULL ) + { return false; } } - if( can_action_change_worldstate( act ) ) { + if( can_action_change_worldstate( act ) ) + { user_action_counter += 1; } - if( act == ACTION_SELECT || act == ACTION_SEC_SELECT ) { + if( act == ACTION_SELECT || act == ACTION_SEC_SELECT ) + { // Mouse button click - if( veh_ctrl ) { + if( veh_ctrl ) + { // No mouse use in vehicle return false; } - if( u.is_dead_state() ) { + if( u.is_dead_state() ) + { // do not allow mouse actions while dead return false; } const cata::optional mouse_pos = ctxt.get_coordinates( w_terrain ); - if( !mouse_pos ) { + if( !mouse_pos ) + { return false; - } else if( !u.sees( *mouse_pos ) ) { + } + else if( !u.sees( *mouse_pos ) ) + { // Not clicked in visible terrain return false; } mouse_target = mouse_pos; - if( act == ACTION_SELECT ) { + if( act == ACTION_SELECT ) + { // Note: The following has the potential side effect of // setting auto-move destination state in addition to setting // act. - if( !try_get_left_click_action( act, *mouse_target ) ) { + if( !try_get_left_click_action( act, *mouse_target ) ) + { return false; } - } else if( act == ACTION_SEC_SELECT ) { - if( !try_get_right_click_action( act, *mouse_target ) ) { + } + else if( act == ACTION_SEC_SELECT ) + { + if( !try_get_right_click_action( act, *mouse_target ) ) + { return false; } } - } else if( act != ACTION_TIMEOUT ) { + } + else if( act != ACTION_TIMEOUT ) + { // act has not been set for an auto-move, so clearing possible // auto-move destinations. Since initializing an auto-move with // the mouse may span across multiple actions, we do not clear the @@ -1603,15 +1903,19 @@ bool game::handle_action() } } - if( act == ACTION_NULL ) { + if( act == ACTION_NULL ) + { const input_event &&evt = ctxt.get_raw_input(); - if( !evt.sequence.empty() ) { + if( !evt.sequence.empty() ) + { const int ch = evt.get_first_input(); const std::string &&name = inp_mngr.get_keyname( ch, evt.type, true ); - if( !get_option( "NO_UNKNOWN_COMMAND_MSG" ) ) { + if( !get_option( "NO_UNKNOWN_COMMAND_MSG" ) ) + { add_msg( m_info, _( "Unknown command: \"%s\" (%ld)" ), name, ch ); if( const cata::optional hint = - press_x_if_bound( ACTION_KEYBINDINGS ) ) { + press_x_if_bound( ACTION_KEYBINDINGS ) ) + { add_msg( m_info, _( "%s at any time to see and edit keybindings relevant to " "the current context." ), *hint ); @@ -1629,852 +1933,1030 @@ bool game::handle_action() int before_action_moves = u.moves; // These actions are allowed while deathcam is active. Registered in game::get_player_input - if( uquit == QUIT_WATCH || !u.is_dead_state() ) { - switch( act ) { - case ACTION_TOGGLE_MAP_MEMORY: - u.toggle_map_memory(); - break; - - case ACTION_CENTER: - u.view_offset.x = driving_view_offset.x; - u.view_offset.y = driving_view_offset.y; - break; + if( uquit == QUIT_WATCH || !u.is_dead_state() ) + { + switch( act ) + { + case ACTION_TOGGLE_MAP_MEMORY: + u.toggle_map_memory(); + break; - case ACTION_SHIFT_N: - case ACTION_SHIFT_NE: - case ACTION_SHIFT_E: - case ACTION_SHIFT_SE: - case ACTION_SHIFT_S: - case ACTION_SHIFT_SW: - case ACTION_SHIFT_W: - case ACTION_SHIFT_NW: { - static const std::map> shift_delta = { - { ACTION_SHIFT_N, { point_north, point_north_east } }, - { ACTION_SHIFT_NE, { point_north_east, point_east } }, - { ACTION_SHIFT_E, { point_east, point_south_east } }, - { ACTION_SHIFT_SE, { point_south_east, point_south } }, - { ACTION_SHIFT_S, { point_south, point_south_west } }, - { ACTION_SHIFT_SW, { point_south_west, point_west } }, - { ACTION_SHIFT_W, { point_west, point_north_west } }, - { ACTION_SHIFT_NW, { point_north_west, point_north } }, - }; - u.view_offset += use_tiles && tile_iso ? - shift_delta.at( act ).second * soffset : shift_delta.at( act ).first * soffset; - } + case ACTION_CENTER: + u.view_offset.x = driving_view_offset.x; + u.view_offset.y = driving_view_offset.y; break; - case ACTION_LOOK: - look_around(); - break; + case ACTION_SHIFT_N: + case ACTION_SHIFT_NE: + case ACTION_SHIFT_E: + case ACTION_SHIFT_SE: + case ACTION_SHIFT_S: + case ACTION_SHIFT_SW: + case ACTION_SHIFT_W: + case ACTION_SHIFT_NW: + { + static const std::map> shift_delta = + { + { ACTION_SHIFT_N, { point_north, point_north_east } }, + { ACTION_SHIFT_NE, { point_north_east, point_east } }, + { ACTION_SHIFT_E, { point_east, point_south_east } }, + { ACTION_SHIFT_SE, { point_south_east, point_south } }, + { ACTION_SHIFT_S, { point_south, point_south_west } }, + { ACTION_SHIFT_SW, { point_south_west, point_west } }, + { ACTION_SHIFT_W, { point_west, point_north_west } }, + { ACTION_SHIFT_NW, { point_north_west, point_north } }, + }; + u.view_offset += use_tiles && tile_iso ? + shift_delta.at( act ).second * soffset : shift_delta.at( act ).first * soffset; + } + break; - case ACTION_KEYBINDINGS: - // already handled by input context - break; + case ACTION_LOOK: + look_around(); + break; - default: - break; + case ACTION_KEYBINDINGS: + // already handled by input context + break; + + default: + break; } } // actions allowed only while alive - if( !u.is_dead_state() ) { - switch( act ) { - case ACTION_NULL: - case NUM_ACTIONS: - break; // dummy entries - case ACTION_ACTIONMENU: - case ACTION_MAIN_MENU: - case ACTION_KEYBINDINGS: - break; // handled above - - case ACTION_TIMEOUT: - if( check_safe_mode_allowed( false ) ) { - u.pause(); - } - break; + if( !u.is_dead_state() ) + { + switch( act ) + { + case ACTION_NULL: + case NUM_ACTIONS: + break; // dummy entries + case ACTION_ACTIONMENU: + case ACTION_MAIN_MENU: + case ACTION_KEYBINDINGS: + break; // handled above + + case ACTION_TIMEOUT: + if( check_safe_mode_allowed( false ) ) + { + u.pause(); + } + break; - case ACTION_PAUSE: - if( check_safe_mode_allowed() ) { - u.pause(); - } - break; + case ACTION_PAUSE: + if( check_safe_mode_allowed() ) + { + u.pause(); + } + break; - case ACTION_CYCLE_MOVE: - u.cycle_move_mode(); - break; + case ACTION_CYCLE_MOVE: + u.cycle_move_mode(); + break; - case ACTION_RESET_MOVE: - u.reset_move_mode(); - break; + case ACTION_RESET_MOVE: + u.reset_move_mode(); + break; - case ACTION_TOGGLE_RUN: - u.toggle_run_mode(); - break; + case ACTION_TOGGLE_RUN: + u.toggle_run_mode(); + break; - case ACTION_TOGGLE_CROUCH: - u.toggle_crouch_mode(); - break; + case ACTION_TOGGLE_CROUCH: + u.toggle_crouch_mode(); + break; - case ACTION_OPEN_MOVEMENT: - open_movement_mode_menu(); - break; + case ACTION_OPEN_MOVEMENT: + open_movement_mode_menu(); + break; - case ACTION_MOVE_FORTH: - case ACTION_MOVE_FORTH_RIGHT: - case ACTION_MOVE_RIGHT: - case ACTION_MOVE_BACK_RIGHT: - case ACTION_MOVE_BACK: - case ACTION_MOVE_BACK_LEFT: - case ACTION_MOVE_LEFT: - case ACTION_MOVE_FORTH_LEFT: - if( !u.get_value( "remote_controlling" ).empty() && - ( u.has_active_item( "radiocontrol" ) || u.has_active_bionic( bio_remote ) ) ) { - rcdrive( get_delta_from_movement_action( act, iso_rotate::yes ) ); - } else if( veh_ctrl ) { - // vehicle control uses x for steering and y for ac/deceleration, - // so no rotation needed - pldrive( get_delta_from_movement_action( act, iso_rotate::no ) ); - } else { - point dest_delta = get_delta_from_movement_action( act, iso_rotate::yes ); - if( auto_travel_mode && !u.is_auto_moving() ) { - for( int i = 0; i < SEEX; i++ ) { - tripoint auto_travel_destination( u.posx() + dest_delta.x * ( SEEX - i ), - u.posy() + dest_delta.y * ( SEEX - i ), - u.posz() ); - destination_preview = m.route( u.pos(), - auto_travel_destination, - u.get_pathfinding_settings(), - u.get_path_avoid() ); - if( !destination_preview.empty() ) { - destination_preview.erase( destination_preview.begin() + 1, destination_preview.end() ); - u.set_destination( destination_preview ); - break; - } - } - act = u.get_next_auto_move_direction(); - const point dest_next = get_delta_from_movement_action( act, iso_rotate::yes ); - if( dest_next == point_zero ) { - u.clear_destination(); + case ACTION_MOVE_FORTH: + case ACTION_MOVE_FORTH_RIGHT: + case ACTION_MOVE_RIGHT: + case ACTION_MOVE_BACK_RIGHT: + case ACTION_MOVE_BACK: + case ACTION_MOVE_BACK_LEFT: + case ACTION_MOVE_LEFT: + case ACTION_MOVE_FORTH_LEFT: + if( !u.get_value( "remote_controlling" ).empty() && + ( u.has_active_item( "radiocontrol" ) || u.has_active_bionic( bio_remote ) ) ) + { + rcdrive( get_delta_from_movement_action( act, iso_rotate::yes ) ); + } + else if( veh_ctrl ) + { + // vehicle control uses x for steering and y for ac/deceleration, + // so no rotation needed + pldrive( get_delta_from_movement_action( act, iso_rotate::no ) ); + } + else + { + point dest_delta = get_delta_from_movement_action( act, iso_rotate::yes ); + if( auto_travel_mode && !u.is_auto_moving() ) + { + for( int i = 0; i < SEEX; i++ ) + { + tripoint auto_travel_destination( u.posx() + dest_delta.x * ( SEEX - i ), + u.posy() + dest_delta.y * ( SEEX - i ), + u.posz() ); + destination_preview = m.route( u.pos(), + auto_travel_destination, + u.get_pathfinding_settings(), + u.get_path_avoid() ); + if( !destination_preview.empty() ) + { + destination_preview.erase( destination_preview.begin() + 1, destination_preview.end() ); + u.set_destination( destination_preview ); + break; } - dest_delta = dest_next; } - if( !avatar_action::move( u, m, dest_delta ) ) { - // auto-move should be canceled due to a failed move or obstacle + act = u.get_next_auto_move_direction(); + const point dest_next = get_delta_from_movement_action( act, iso_rotate::yes ); + if( dest_next == point_zero ) + { u.clear_destination(); } + dest_delta = dest_next; } - break; - case ACTION_MOVE_DOWN: - if( u.is_mounted() ) { - auto mon = u.mounted_creature.get(); - if( !mon->has_flag( MF_RIDEABLE_MECH ) ) { - add_msg( m_info, _( "You can't go down stairs while you're riding." ) ); - break; - } + if( !avatar_action::move( u, m, dest_delta ) ) + { + // auto-move should be canceled due to a failed move or obstacle + u.clear_destination(); } - if( !u.in_vehicle ) { - vertical_move( -1, false ); + } + break; + case ACTION_MOVE_DOWN: + if( u.is_mounted() ) + { + auto mon = u.mounted_creature.get(); + if( !mon->has_flag( MF_RIDEABLE_MECH ) ) + { + add_msg( m_info, _( "You can't go down stairs while you're riding." ) ); + break; } - break; + } + if( !u.in_vehicle ) + { + vertical_move( -1, false ); + } + break; - case ACTION_MOVE_UP: - if( u.is_mounted() ) { - auto mon = u.mounted_creature.get(); - if( !mon->has_flag( MF_RIDEABLE_MECH ) ) { - add_msg( m_info, _( "You can't go down stairs while you're riding." ) ); - break; - } - } - if( !u.in_vehicle ) { - vertical_move( 1, false ); + case ACTION_MOVE_UP: + if( u.is_mounted() ) + { + auto mon = u.mounted_creature.get(); + if( !mon->has_flag( MF_RIDEABLE_MECH ) ) + { + add_msg( m_info, _( "You can't go down stairs while you're riding." ) ); + break; } - break; + } + if( !u.in_vehicle ) + { + vertical_move( 1, false ); + } + break; - case ACTION_OPEN: - if( u.has_active_mutation( trait_SHELL2 ) ) { - add_msg( m_info, _( "You can't open things while you're in your shell." ) ); - } else if( u.is_mounted() ) { - add_msg( m_info, _( "You can't open things while you're riding." ) ); - } else { - open(); - } - break; + case ACTION_OPEN: + if( u.has_active_mutation( trait_SHELL2 ) ) + { + add_msg( m_info, _( "You can't open things while you're in your shell." ) ); + } + else if( u.is_mounted() ) + { + add_msg( m_info, _( "You can't open things while you're riding." ) ); + } + else + { + open(); + } + break; - case ACTION_CLOSE: - if( u.has_active_mutation( trait_SHELL2 ) ) { - add_msg( m_info, _( "You can't close things while you're in your shell." ) ); - } else if( u.is_mounted() ) { - auto mon = u.mounted_creature.get(); - if( !mon->has_flag( MF_RIDEABLE_MECH ) ) { - add_msg( m_info, _( "You can't close things while you're riding." ) ); - } - } else if( mouse_target ) { - doors::close_door( m, u, *mouse_target ); - } else { - close(); + case ACTION_CLOSE: + if( u.has_active_mutation( trait_SHELL2 ) ) + { + add_msg( m_info, _( "You can't close things while you're in your shell." ) ); + } + else if( u.is_mounted() ) + { + auto mon = u.mounted_creature.get(); + if( !mon->has_flag( MF_RIDEABLE_MECH ) ) + { + add_msg( m_info, _( "You can't close things while you're riding." ) ); } - break; + } + else if( mouse_target ) + { + doors::close_door( m, u, *mouse_target ); + } + else + { + close(); + } + break; - case ACTION_SMASH: - if( veh_ctrl ) { - handbrake(); - } else if( u.has_active_mutation( trait_SHELL2 ) ) { - add_msg( m_info, _( "You can't smash things while you're in your shell." ) ); - } else { - smash(); - } - break; + case ACTION_SMASH: + if( veh_ctrl ) + { + handbrake(); + } + else if( u.has_active_mutation( trait_SHELL2 ) ) + { + add_msg( m_info, _( "You can't smash things while you're in your shell." ) ); + } + else + { + smash(); + } + break; - case ACTION_EXAMINE: - if( u.has_active_mutation( trait_SHELL2 ) ) { - add_msg( m_info, _( "You can't examine your surroundings while you're in your shell." ) ); - } else if( mouse_target ) { - examine( *mouse_target ); - } else { - examine(); - } - break; + case ACTION_EXAMINE: + if( u.has_active_mutation( trait_SHELL2 ) ) + { + add_msg( m_info, _( "You can't examine your surroundings while you're in your shell." ) ); + } + else if( mouse_target ) + { + examine( *mouse_target ); + } + else + { + examine(); + } + break; - case ACTION_ADVANCEDINV: - if( u.has_active_mutation( trait_SHELL2 ) ) { - add_msg( m_info, _( "You can't move mass quantities while you're in your shell." ) ); - } else if( u.is_mounted() ) { - add_msg( m_info, _( "You can't move mass quantities while you're riding." ) ); - } else { - create_advanced_inv(); - } - break; + case ACTION_ADVANCEDINV: + if( u.has_active_mutation( trait_SHELL2 ) ) + { + add_msg( m_info, _( "You can't move mass quantities while you're in your shell." ) ); + } + else if( u.is_mounted() ) + { + add_msg( m_info, _( "You can't move mass quantities while you're riding." ) ); + } + else + { + create_advanced_inv(); + } + break; - case ACTION_PICKUP: - if( u.has_active_mutation( trait_SHELL2 ) ) { - add_msg( m_info, _( "You can't pick anything up while you're in your shell." ) ); - } else if( u.is_mounted() ) { - add_msg( m_info, _( "You can't pick anything up while you're riding." ) ); - } else if( mouse_target ) { - pickup( *mouse_target ); - } else { - pickup(); - } - break; + case ACTION_PICKUP: + if( u.has_active_mutation( trait_SHELL2 ) ) + { + add_msg( m_info, _( "You can't pick anything up while you're in your shell." ) ); + } + else if( u.is_mounted() ) + { + add_msg( m_info, _( "You can't pick anything up while you're riding." ) ); + } + else if( mouse_target ) + { + pickup( *mouse_target ); + } + else + { + pickup(); + } + break; - case ACTION_PICKUP_FEET: - if( u.has_active_mutation( trait_SHELL2 ) ) { - add_msg( m_info, _( "You can't pick anything up while you're in your shell." ) ); - } else { - pickup_feet(); - } - break; + case ACTION_PICKUP_FEET: + if( u.has_active_mutation( trait_SHELL2 ) ) + { + add_msg( m_info, _( "You can't pick anything up while you're in your shell." ) ); + } + else + { + pickup_feet(); + } + break; - case ACTION_GRAB: - if( u.has_active_mutation( trait_SHELL2 ) ) { - add_msg( m_info, _( "You can't grab things while you're in your shell." ) ); - } else if( u.is_mounted() ) { - add_msg( m_info, _( "You can't grab things while you're riding." ) ); - } else { - grab(); - } - break; + case ACTION_GRAB: + if( u.has_active_mutation( trait_SHELL2 ) ) + { + add_msg( m_info, _( "You can't grab things while you're in your shell." ) ); + } + else if( u.is_mounted() ) + { + add_msg( m_info, _( "You can't grab things while you're riding." ) ); + } + else + { + grab(); + } + break; - case ACTION_HAUL: - if( u.has_active_mutation( trait_SHELL2 ) ) { - add_msg( m_info, _( "You can't haul things while you're in your shell." ) ); - } else if( u.is_mounted() ) { - add_msg( m_info, _( "You can't haul things while you're riding." ) ); - } else { - haul(); - } - break; + case ACTION_HAUL: + if( u.has_active_mutation( trait_SHELL2 ) ) + { + add_msg( m_info, _( "You can't haul things while you're in your shell." ) ); + } + else if( u.is_mounted() ) + { + add_msg( m_info, _( "You can't haul things while you're riding." ) ); + } + else + { + haul(); + } + break; - case ACTION_BUTCHER: - if( u.has_active_mutation( trait_SHELL2 ) ) { - add_msg( m_info, _( "You can't butcher while you're in your shell." ) ); - } else if( u.is_mounted() ) { - add_msg( m_info, _( "You can't butcher while you're riding." ) ); - } else { - butcher(); - } - break; + case ACTION_BUTCHER: + if( u.has_active_mutation( trait_SHELL2 ) ) + { + add_msg( m_info, _( "You can't butcher while you're in your shell." ) ); + } + else if( u.is_mounted() ) + { + add_msg( m_info, _( "You can't butcher while you're riding." ) ); + } + else + { + butcher(); + } + break; - case ACTION_CHAT: - chat(); - break; + case ACTION_CHAT: + chat(); + break; - case ACTION_PEEK: - if( u.has_active_mutation( trait_SHELL2 ) ) { - add_msg( m_info, _( "You can't peek around corners while you're in your shell." ) ); - } else if( u.is_mounted() ) { - add_msg( m_info, _( "You can't peek around corners while you're riding." ) ); - } else { - peek(); - } - break; + case ACTION_PEEK: + if( u.has_active_mutation( trait_SHELL2 ) ) + { + add_msg( m_info, _( "You can't peek around corners while you're in your shell." ) ); + } + else if( u.is_mounted() ) + { + add_msg( m_info, _( "You can't peek around corners while you're riding." ) ); + } + else + { + peek(); + } + break; - case ACTION_LIST_ITEMS: - list_items_monsters(); - break; + case ACTION_LIST_ITEMS: + list_items_monsters(); + break; - case ACTION_ZONES: - zones_manager(); - break; + case ACTION_ZONES: + zones_manager(); + break; - case ACTION_LOOT: - loot(); - break; + case ACTION_LOOT: + loot(); + break; - case ACTION_INVENTORY: - game_menus::inv::common( u ); - break; + case ACTION_INVENTORY: + game_menus::inv::common( u ); + break; - case ACTION_COMPARE: - game_menus::inv::compare( u, cata::nullopt ); - break; + case ACTION_COMPARE: + game_menus::inv::compare( u, cata::nullopt ); + break; - case ACTION_ORGANIZE: - game_menus::inv::swap_letters( u ); - break; + case ACTION_ORGANIZE: + game_menus::inv::swap_letters( u ); + break; - case ACTION_USE: - // Shell-users are presumed to be able to mess with their inventories, etc - // while in the shell. Eating, gear-changing, and item use are OK. - avatar_action::use_item( u ); - break; + case ACTION_USE: + // Shell-users are presumed to be able to mess with their inventories, etc + // while in the shell. Eating, gear-changing, and item use are OK. + avatar_action::use_item( u ); + break; - case ACTION_USE_WIELDED: - u.use_wielded(); - break; + case ACTION_USE_WIELDED: + u.use_wielded(); + break; - case ACTION_WEAR: - wear(); - break; + case ACTION_WEAR: + wear(); + break; - case ACTION_TAKE_OFF: - takeoff(); - break; + case ACTION_TAKE_OFF: + takeoff(); + break; - case ACTION_EAT: - if( !avatar_action::eat_here( u ) ) { - avatar_action::eat( u ); - } - break; + case ACTION_EAT: + if( !avatar_action::eat_here( u ) ) + { + avatar_action::eat( u ); + } + break; - case ACTION_OPEN_CONSUME: - if( !avatar_action::eat_here( u ) ) { - open_consume_item_menu(); - } - break; + case ACTION_OPEN_CONSUME: + if( !avatar_action::eat_here( u ) ) + { + open_consume_item_menu(); + } + break; - case ACTION_READ: - // Shell-users are presumed to have the book just at an opening and read it that way - read(); - break; + case ACTION_READ: + // Shell-users are presumed to have the book just at an opening and read it that way + read(); + break; - case ACTION_WIELD: - wield(); - break; + case ACTION_WIELD: + wield(); + break; - case ACTION_PICK_STYLE: - u.martial_arts_data.pick_style( u ); - break; + case ACTION_PICK_STYLE: + u.martial_arts_data.pick_style( u ); + break; - case ACTION_RELOAD_ITEM: - reload_item(); - break; + case ACTION_RELOAD_ITEM: + reload_item(); + break; - case ACTION_RELOAD_WEAPON: - reload_weapon(); - break; + case ACTION_RELOAD_WEAPON: + reload_weapon(); + break; - case ACTION_RELOAD_WIELDED: - reload_wielded(); - break; + case ACTION_RELOAD_WIELDED: + reload_wielded(); + break; - case ACTION_UNLOAD: - avatar_action::unload( u ); - break; + case ACTION_UNLOAD: + avatar_action::unload( u ); + break; - case ACTION_MEND: - avatar_action::mend( g->u, item_location() ); - break; + case ACTION_MEND: + avatar_action::mend( g->u, item_location() ); + break; - case ACTION_THROW: { - item_location loc; - avatar_action::plthrow( g->u, loc ); - break; - } + case ACTION_THROW: + { + item_location loc; + avatar_action::plthrow( g->u, loc ); + break; + } - case ACTION_FIRE: - fire(); - break; + case ACTION_FIRE: + fire(); + break; - case ACTION_CAST_SPELL: - cast_spell(); - break; + case ACTION_CAST_SPELL: + cast_spell(); + break; - case ACTION_FIRE_BURST: { - gun_mode_id original_mode = u.weapon.gun_get_mode_id(); - if( u.weapon.gun_set_mode( gun_mode_id( "AUTO" ) ) ) { - avatar_action::fire( u, m, u.weapon ); - u.weapon.gun_set_mode( original_mode ); - } - break; + case ACTION_FIRE_BURST: + { + gun_mode_id original_mode = u.weapon.gun_get_mode_id(); + if( u.weapon.gun_set_mode( gun_mode_id( "AUTO" ) ) ) + { + avatar_action::fire( u, m, u.weapon ); + u.weapon.gun_set_mode( original_mode ); } + break; + } - case ACTION_SELECT_FIRE_MODE: - if( u.is_armed() ) { - if( u.weapon.is_gun() && !u.weapon.is_gunmod() && u.weapon.gun_all_modes().size() > 1 ) { - u.weapon.gun_cycle_mode(); - } else if( u.weapon.has_flag( flag_RELOAD_ONE ) || u.weapon.has_flag( flag_RELOAD_AND_SHOOT ) ) { - item::reload_option opt = u.select_ammo( u.weapon, false ); - if( !opt ) { - break; - } else if( u.ammo_location && opt.ammo == u.ammo_location ) { - u.ammo_location = item_location(); - } else { - u.ammo_location = opt.ammo; - } + case ACTION_SELECT_FIRE_MODE: + if( u.is_armed() ) + { + if( u.weapon.is_gun() && !u.weapon.is_gunmod() && u.weapon.gun_all_modes().size() > 1 ) + { + u.weapon.gun_cycle_mode(); + } + else if( u.weapon.has_flag( flag_RELOAD_ONE ) || u.weapon.has_flag( flag_RELOAD_AND_SHOOT ) ) + { + item::reload_option opt = u.select_ammo( u.weapon, false ); + if( !opt ) + { + break; + } + else if( u.ammo_location && opt.ammo == u.ammo_location ) + { + u.ammo_location = item_location(); + } + else + { + u.ammo_location = opt.ammo; } } - break; + } + break; - case ACTION_DROP: - // You CAN drop things to your own tile while in the shell. - drop(); - break; + case ACTION_DROP: + // You CAN drop things to your own tile while in the shell. + drop(); + break; - case ACTION_DIR_DROP: - if( u.has_active_mutation( trait_SHELL2 ) ) { - add_msg( m_info, _( "You can't drop things to another tile while you're in your shell." ) ); - } else { - drop_in_direction(); - } - break; - case ACTION_BIONICS: - u.power_bionics(); - refresh_all(); - break; - case ACTION_MUTATIONS: - u.power_mutations(); - refresh_all(); - break; + case ACTION_DIR_DROP: + if( u.has_active_mutation( trait_SHELL2 ) ) + { + add_msg( m_info, _( "You can't drop things to another tile while you're in your shell." ) ); + } + else + { + drop_in_direction(); + } + break; + case ACTION_BIONICS: + u.power_bionics(); + refresh_all(); + break; + case ACTION_MUTATIONS: + u.power_mutations(); + refresh_all(); + break; - case ACTION_SORT_ARMOR: - u.sort_armor(); - refresh_all(); - break; + case ACTION_SORT_ARMOR: + u.sort_armor(); + refresh_all(); + break; - case ACTION_WAIT: - wait(); - break; + case ACTION_WAIT: + wait(); + break; - case ACTION_CRAFT: - if( u.has_active_mutation( trait_SHELL2 ) ) { - add_msg( m_info, _( "You can't craft while you're in your shell." ) ); - } else if( u.is_mounted() ) { - add_msg( m_info, _( "You can't craft while you're riding." ) ); - } else { - u.craft(); - } - break; + case ACTION_CRAFT: + if( u.has_active_mutation( trait_SHELL2 ) ) + { + add_msg( m_info, _( "You can't craft while you're in your shell." ) ); + } + else if( u.is_mounted() ) + { + add_msg( m_info, _( "You can't craft while you're riding." ) ); + } + else + { + u.craft(); + } + break; - case ACTION_RECRAFT: - if( u.has_active_mutation( trait_SHELL2 ) ) { - add_msg( m_info, _( "You can't craft while you're in your shell." ) ); - } else if( u.is_mounted() ) { - add_msg( m_info, _( "You can't craft while you're riding." ) ); - } else { - u.recraft(); - } - break; + case ACTION_RECRAFT: + if( u.has_active_mutation( trait_SHELL2 ) ) + { + add_msg( m_info, _( "You can't craft while you're in your shell." ) ); + } + else if( u.is_mounted() ) + { + add_msg( m_info, _( "You can't craft while you're riding." ) ); + } + else + { + u.recraft(); + } + break; - case ACTION_LONGCRAFT: - if( u.has_active_mutation( trait_SHELL2 ) ) { - add_msg( m_info, _( "You can't craft while you're in your shell." ) ); - } else if( u.is_mounted() ) { - add_msg( m_info, _( "You can't craft while you're riding." ) ); - } else { - u.long_craft(); - } - break; + case ACTION_LONGCRAFT: + if( u.has_active_mutation( trait_SHELL2 ) ) + { + add_msg( m_info, _( "You can't craft while you're in your shell." ) ); + } + else if( u.is_mounted() ) + { + add_msg( m_info, _( "You can't craft while you're riding." ) ); + } + else + { + u.long_craft(); + } + break; - case ACTION_DISASSEMBLE: - if( u.controlling_vehicle ) { - add_msg( m_info, _( "You can't disassemble items while driving." ) ); - } else if( u.is_mounted() ) { - add_msg( m_info, _( "You can't disassemble items while you're riding." ) ); - } else { - u.disassemble(); - refresh_all(); - } - break; + case ACTION_DISASSEMBLE: + if( u.controlling_vehicle ) + { + add_msg( m_info, _( "You can't disassemble items while driving." ) ); + } + else if( u.is_mounted() ) + { + add_msg( m_info, _( "You can't disassemble items while you're riding." ) ); + } + else + { + u.disassemble(); + refresh_all(); + } + break; - case ACTION_CONSTRUCT: - if( u.in_vehicle ) { - add_msg( m_info, _( "You can't construct while in a vehicle." ) ); - } else if( u.has_active_mutation( trait_SHELL2 ) ) { - add_msg( m_info, _( "You can't construct while you're in your shell." ) ); - } else if( u.is_mounted() ) { - add_msg( m_info, _( "You can't construct while you're riding." ) ); - } else { - construction_menu( false ); - } - break; + case ACTION_CONSTRUCT: + if( u.in_vehicle ) + { + add_msg( m_info, _( "You can't construct while in a vehicle." ) ); + } + else if( u.has_active_mutation( trait_SHELL2 ) ) + { + add_msg( m_info, _( "You can't construct while you're in your shell." ) ); + } + else if( u.is_mounted() ) + { + add_msg( m_info, _( "You can't construct while you're riding." ) ); + } + else + { + construction_menu( false ); + } + break; - case ACTION_SLEEP: - if( veh_ctrl ) { - add_msg( m_info, _( "Vehicle control has moved, %s" ), - press_x( ACTION_CONTROL_VEHICLE, _( "new binding is " ), - _( "new default binding is '^'." ) ) ); - } else { - sleep(); - } - break; + case ACTION_SLEEP: + if( veh_ctrl ) + { + add_msg( m_info, _( "Vehicle control has moved, %s" ), + press_x( ACTION_CONTROL_VEHICLE, _( "new binding is " ), + _( "new default binding is '^'." ) ) ); + } + else + { + sleep(); + } + break; - case ACTION_CONTROL_VEHICLE: - if( u.has_active_mutation( trait_SHELL2 ) ) { - add_msg( m_info, _( "You can't operate a vehicle while you're in your shell." ) ); - } else if( u.is_mounted() ) { - u.dismount(); - } else if( u.has_trait( trait_WAYFARER ) ) { - add_msg( m_info, _( "You refuse to take control of this vehicle." ) ); - } else { - control_vehicle(); - } - break; + case ACTION_CONTROL_VEHICLE: + if( u.has_active_mutation( trait_SHELL2 ) ) + { + add_msg( m_info, _( "You can't operate a vehicle while you're in your shell." ) ); + } + else if( u.is_mounted() ) + { + u.dismount(); + } + else if( u.has_trait( trait_WAYFARER ) ) + { + add_msg( m_info, _( "You refuse to take control of this vehicle." ) ); + } + else + { + control_vehicle(); + } + break; - case ACTION_TOGGLE_AUTO_TRAVEL_MODE: - auto_travel_mode = !auto_travel_mode; - add_msg( m_info, auto_travel_mode ? _( "Auto travel mode ON!" ) : _( "Auto travel mode OFF!" ) ); - break; + case ACTION_TOGGLE_AUTO_TRAVEL_MODE: + auto_travel_mode = !auto_travel_mode; + add_msg( m_info, auto_travel_mode ? _( "Auto travel mode ON!" ) : _( "Auto travel mode OFF!" ) ); + break; + + case ACTION_TOGGLE_SAFEMODE: + if( safe_mode == SAFE_MODE_OFF ) + { + set_safe_mode( SAFE_MODE_ON ); + mostseen = 0; + add_msg( m_info, _( "Safe mode ON!" ) ); + } + else + { + turnssincelastmon = 0; + set_safe_mode( SAFE_MODE_OFF ); + add_msg( m_info, get_option( "AUTOSAFEMODE" ) + ? _( "Safe mode OFF! (Auto safe mode still enabled!)" ) : _( "Safe mode OFF!" ) ); + } + if( u.has_effect( effect_laserlocked ) ) + { + u.remove_effect( effect_laserlocked ); + safe_mode_warning_logged = false; + } + break; + + case ACTION_TOGGLE_AUTOSAFE: + { + auto &autosafemode_option = get_options().get_option( "AUTOSAFEMODE" ); + add_msg( m_info, autosafemode_option.value_as() + ? _( "Auto safe mode OFF!" ) : _( "Auto safe mode ON!" ) ); + autosafemode_option.setNext(); + break; + } - case ACTION_TOGGLE_SAFEMODE: - if( safe_mode == SAFE_MODE_OFF ) { - set_safe_mode( SAFE_MODE_ON ); - mostseen = 0; - add_msg( m_info, _( "Safe mode ON!" ) ); - } else { - turnssincelastmon = 0; - set_safe_mode( SAFE_MODE_OFF ); - add_msg( m_info, get_option( "AUTOSAFEMODE" ) - ? _( "Safe mode OFF! (Auto safe mode still enabled!)" ) : _( "Safe mode OFF!" ) ); + case ACTION_IGNORE_ENEMY: + if( safe_mode == SAFE_MODE_STOP ) + { + add_msg( m_info, _( "Ignoring enemy!" ) ); + for( auto &elem : u.get_mon_visible().new_seen_mon ) + { + monster &critter = *elem; + critter.ignoring = rl_dist( u.pos(), critter.pos() ); } - if( u.has_effect( effect_laserlocked ) ) { - u.remove_effect( effect_laserlocked ); - safe_mode_warning_logged = false; + set_safe_mode( SAFE_MODE_ON ); + } + else if( u.has_effect( effect_laserlocked ) ) + { + if( u.has_trait( trait_PROF_CHURL ) ) + { + add_msg( m_warning, _( "You make the sign of the cross." ) ); } - break; - - case ACTION_TOGGLE_AUTOSAFE: { - auto &autosafemode_option = get_options().get_option( "AUTOSAFEMODE" ); - add_msg( m_info, autosafemode_option.value_as() - ? _( "Auto safe mode OFF!" ) : _( "Auto safe mode ON!" ) ); - autosafemode_option.setNext(); - break; + else + { + add_msg( m_info, _( "Ignoring laser targeting!" ) ); + } + u.remove_effect( effect_laserlocked ); + safe_mode_warning_logged = false; } + break; - case ACTION_IGNORE_ENEMY: - if( safe_mode == SAFE_MODE_STOP ) { - add_msg( m_info, _( "Ignoring enemy!" ) ); - for( auto &elem : u.get_mon_visible().new_seen_mon ) { - monster &critter = *elem; - critter.ignoring = rl_dist( u.pos(), critter.pos() ); - } - set_safe_mode( SAFE_MODE_ON ); - } else if( u.has_effect( effect_laserlocked ) ) { - if( u.has_trait( trait_PROF_CHURL ) ) { - add_msg( m_warning, _( "You make the sign of the cross." ) ); - } else { - add_msg( m_info, _( "Ignoring laser targeting!" ) ); - } - u.remove_effect( effect_laserlocked ); - safe_mode_warning_logged = false; - } - break; + case ACTION_WHITELIST_ENEMY: + if( safe_mode == SAFE_MODE_STOP && !get_safemode().empty() ) + { + get_safemode().add_rule( get_safemode().lastmon_whitelist, Creature::A_ANY, 0, RULE_WHITELISTED ); + add_msg( m_info, _( "Creature whitelisted: %s" ), get_safemode().lastmon_whitelist ); + set_safe_mode( SAFE_MODE_ON ); + mostseen = 0; + } + else + { + get_safemode().show(); + } + break; - case ACTION_WHITELIST_ENEMY: - if( safe_mode == SAFE_MODE_STOP && !get_safemode().empty() ) { - get_safemode().add_rule( get_safemode().lastmon_whitelist, Creature::A_ANY, 0, RULE_WHITELISTED ); - add_msg( m_info, _( "Creature whitelisted: %s" ), get_safemode().lastmon_whitelist ); - set_safe_mode( SAFE_MODE_ON ); - mostseen = 0; - } else { - get_safemode().show(); + case ACTION_SUICIDE: + if( query_yn( _( "Commit suicide?" ) ) ) + { + if( query_yn( _( "REALLY commit suicide?" ) ) ) + { + u.moves = 0; + u.place_corpse(); + uquit = QUIT_SUICIDE; } - break; + } + refresh_all(); + break; - case ACTION_SUICIDE: - if( query_yn( _( "Commit suicide?" ) ) ) { - if( query_yn( _( "REALLY commit suicide?" ) ) ) { - u.moves = 0; - u.place_corpse(); - uquit = QUIT_SUICIDE; - } + case ACTION_SAVE: + if( query_yn( _( "Save and quit?" ) ) ) + { + if( save() ) + { + u.moves = 0; + uquit = QUIT_SAVED; } - refresh_all(); - break; + } + refresh_all(); + break; - case ACTION_SAVE: - if( query_yn( _( "Save and quit?" ) ) ) { - if( save() ) { - u.moves = 0; - uquit = QUIT_SAVED; - } - } - refresh_all(); - break; + case ACTION_QUICKSAVE: + quicksave(); + return false; - case ACTION_QUICKSAVE: - quicksave(); - return false; + case ACTION_QUICKLOAD: + quickload(); + return false; - case ACTION_QUICKLOAD: - quickload(); - return false; + case ACTION_PL_INFO: + u.disp_info(); + break; - case ACTION_PL_INFO: - u.disp_info(); - break; + case ACTION_MAP: + werase( w_terrain ); + ui::omap::display(); + break; - case ACTION_MAP: + case ACTION_SKY: + if( m.is_outside( u.pos() ) ) + { werase( w_terrain ); - ui::omap::display(); - break; - - case ACTION_SKY: - if( m.is_outside( u.pos() ) ) { - werase( w_terrain ); - ui::omap::display_visible_weather(); - } else { - add_msg( m_info, _( "You can't see the sky from here." ) ); - } - break; + ui::omap::display_visible_weather(); + } + else + { + add_msg( m_info, _( "You can't see the sky from here." ) ); + } + break; - case ACTION_MISSIONS: - list_missions(); - break; + case ACTION_MISSIONS: + list_missions(); + break; - case ACTION_SCORES: - show_scores_ui( stats(), get_kill_tracker() ); - break; + case ACTION_SCORES: + show_scores_ui( stats(), get_kill_tracker() ); + break; - case ACTION_FACTIONS: - faction_manager_ptr->display(); - break; + case ACTION_FACTIONS: + faction_manager_ptr->display(); + break; - case ACTION_MORALE: - u.disp_morale(); - refresh_all(); - break; + case ACTION_MORALE: + u.disp_morale(); + refresh_all(); + break; - case ACTION_MESSAGES: - Messages::display_messages(); - refresh_all(); - break; + case ACTION_MESSAGES: + Messages::display_messages(); + refresh_all(); + break; - case ACTION_HELP: - get_help().display_help(); - refresh_all(); - break; + case ACTION_HELP: + get_help().display_help(); + refresh_all(); + break; - case ACTION_OPTIONS: - get_options().show( true ); - g->init_ui( true ); - break; + case ACTION_OPTIONS: + get_options().show( true ); + g->init_ui( true ); + break; - case ACTION_AUTOPICKUP: - get_auto_pickup().show(); - refresh_all(); - break; + case ACTION_AUTOPICKUP: + get_auto_pickup().show(); + refresh_all(); + break; - case ACTION_AUTONOTES: - get_auto_notes_settings().show_gui(); - refresh_all(); - break; + case ACTION_AUTONOTES: + get_auto_notes_settings().show_gui(); + refresh_all(); + break; - case ACTION_SAFEMODE: - get_safemode().show(); - refresh_all(); - break; + case ACTION_SAFEMODE: + get_safemode().show(); + refresh_all(); + break; - case ACTION_COLOR: - all_colors.show_gui(); - refresh_all(); - break; + case ACTION_COLOR: + all_colors.show_gui(); + refresh_all(); + break; - case ACTION_WORLD_MODS: - world_generator->show_active_world_mods( world_generator->active_world->active_mod_order ); - refresh_all(); - break; + case ACTION_WORLD_MODS: + world_generator->show_active_world_mods( world_generator->active_world->active_mod_order ); + refresh_all(); + break; - case ACTION_DEBUG: - if( MAP_SHARING::isCompetitive() && !MAP_SHARING::isDebugger() ) { - break; //don't do anything when sharing and not debugger - } - debug_menu::debug(); - break; + case ACTION_DEBUG: + if( MAP_SHARING::isCompetitive() && !MAP_SHARING::isDebugger() ) + { + break; //don't do anything when sharing and not debugger + } + debug_menu::debug(); + break; - case ACTION_TOGGLE_FULLSCREEN: - toggle_fullscreen(); - break; + case ACTION_TOGGLE_FULLSCREEN: + toggle_fullscreen(); + break; - case ACTION_TOGGLE_PIXEL_MINIMAP: - toggle_pixel_minimap(); - break; + case ACTION_TOGGLE_PIXEL_MINIMAP: + toggle_pixel_minimap(); + break; - case ACTION_TOGGLE_PANEL_ADM: - toggle_panel_adm(); - break; + case ACTION_TOGGLE_PANEL_ADM: + toggle_panel_adm(); + break; - case ACTION_RELOAD_TILESET: - reload_tileset(); - break; + case ACTION_RELOAD_TILESET: + reload_tileset(); + break; - case ACTION_TOGGLE_AUTO_FEATURES: - get_options().get_option( "AUTO_FEATURES" ).setNext(); - get_options().save(); - //~ Auto Features are now ON/OFF - add_msg( _( "%s are now %s." ), - get_options().get_option( "AUTO_FEATURES" ).getMenuText(), - get_option( "AUTO_FEATURES" ) ? _( "ON" ) : _( "OFF" ) ); - break; + case ACTION_TOGGLE_AUTO_FEATURES: + get_options().get_option( "AUTO_FEATURES" ).setNext(); + get_options().save(); + //~ Auto Features are now ON/OFF + add_msg( _( "%s are now %s." ), + get_options().get_option( "AUTO_FEATURES" ).getMenuText(), + get_option( "AUTO_FEATURES" ) ? _( "ON" ) : _( "OFF" ) ); + break; - case ACTION_TOGGLE_AUTO_PULP_BUTCHER: - get_options().get_option( "AUTO_PULP_BUTCHER" ).setNext(); - get_options().save(); - //~ Auto Pulp/Pulp Adjacent/Butcher is now set to x - add_msg( _( "%s is now set to %s." ), - get_options().get_option( "AUTO_PULP_BUTCHER" ).getMenuText(), - get_options().get_option( "AUTO_PULP_BUTCHER" ).getValueName() ); - break; + case ACTION_TOGGLE_AUTO_PULP_BUTCHER: + get_options().get_option( "AUTO_PULP_BUTCHER" ).setNext(); + get_options().save(); + //~ Auto Pulp/Pulp Adjacent/Butcher is now set to x + add_msg( _( "%s is now set to %s." ), + get_options().get_option( "AUTO_PULP_BUTCHER" ).getMenuText(), + get_options().get_option( "AUTO_PULP_BUTCHER" ).getValueName() ); + break; - case ACTION_TOGGLE_AUTO_MINING: - get_options().get_option( "AUTO_MINING" ).setNext(); - get_options().save(); - //~ Auto Mining is now ON/OFF - add_msg( _( "%s is now %s." ), - get_options().get_option( "AUTO_MINING" ).getMenuText(), - get_option( "AUTO_MINING" ) ? _( "ON" ) : _( "OFF" ) ); - break; + case ACTION_TOGGLE_AUTO_MINING: + get_options().get_option( "AUTO_MINING" ).setNext(); + get_options().save(); + //~ Auto Mining is now ON/OFF + add_msg( _( "%s is now %s." ), + get_options().get_option( "AUTO_MINING" ).getMenuText(), + get_option( "AUTO_MINING" ) ? _( "ON" ) : _( "OFF" ) ); + break; - case ACTION_TOGGLE_THIEF_MODE: - if( g->u.get_value( "THIEF_MODE" ) == "THIEF_ASK" ) { - u.set_value( "THIEF_MODE", "THIEF_HONEST" ); - u.set_value( "THIEF_MODE_KEEP", "YES" ); - //~ Thief mode cycled between THIEF_ASK/THIEF_HONEST/THIEF_STEAL - add_msg( _( "You will not pick up other peoples belongings." ) ); - } else if( g->u.get_value( "THIEF_MODE" ) == "THIEF_HONEST" ) { - u.set_value( "THIEF_MODE", "THIEF_STEAL" ); - u.set_value( "THIEF_MODE_KEEP", "YES" ); - //~ Thief mode cycled between THIEF_ASK/THIEF_HONEST/THIEF_STEAL - add_msg( _( "You will pick up also those things that belong to others!" ) ); - } else if( g->u.get_value( "THIEF_MODE" ) == "THIEF_STEAL" ) { - u.set_value( "THIEF_MODE", "THIEF_ASK" ); - u.set_value( "THIEF_MODE_KEEP", "NO" ); - //~ Thief mode cycled between THIEF_ASK/THIEF_HONEST/THIEF_STEAL - add_msg( _( "You will be reminded not to steal." ) ); - } else { - // ERROR - add_msg( _( "THIEF_MODE CONTAINED BAD VALUE [ %s ]!" ), g->u.get_value( "THIEF_MODE" ) ); - } - break; + case ACTION_TOGGLE_THIEF_MODE: + if( g->u.get_value( "THIEF_MODE" ) == "THIEF_ASK" ) + { + u.set_value( "THIEF_MODE", "THIEF_HONEST" ); + u.set_value( "THIEF_MODE_KEEP", "YES" ); + //~ Thief mode cycled between THIEF_ASK/THIEF_HONEST/THIEF_STEAL + add_msg( _( "You will not pick up other peoples belongings." ) ); + } + else if( g->u.get_value( "THIEF_MODE" ) == "THIEF_HONEST" ) + { + u.set_value( "THIEF_MODE", "THIEF_STEAL" ); + u.set_value( "THIEF_MODE_KEEP", "YES" ); + //~ Thief mode cycled between THIEF_ASK/THIEF_HONEST/THIEF_STEAL + add_msg( _( "You will pick up also those things that belong to others!" ) ); + } + else if( g->u.get_value( "THIEF_MODE" ) == "THIEF_STEAL" ) + { + u.set_value( "THIEF_MODE", "THIEF_ASK" ); + u.set_value( "THIEF_MODE_KEEP", "NO" ); + //~ Thief mode cycled between THIEF_ASK/THIEF_HONEST/THIEF_STEAL + add_msg( _( "You will be reminded not to steal." ) ); + } + else + { + // ERROR + add_msg( _( "THIEF_MODE CONTAINED BAD VALUE [ %s ]!" ), g->u.get_value( "THIEF_MODE" ) ); + } + break; - case ACTION_TOGGLE_AUTO_FORAGING: - get_options().get_option( "AUTO_FORAGING" ).setNext(); - get_options().save(); - //~ Auto Foraging is now set to x - add_msg( _( "%s is now set to %s." ), - get_options().get_option( "AUTO_FORAGING" ).getMenuText(), - get_options().get_option( "AUTO_FORAGING" ).getValueName() ); - break; + case ACTION_TOGGLE_AUTO_FORAGING: + get_options().get_option( "AUTO_FORAGING" ).setNext(); + get_options().save(); + //~ Auto Foraging is now set to x + add_msg( _( "%s is now set to %s." ), + get_options().get_option( "AUTO_FORAGING" ).getMenuText(), + get_options().get_option( "AUTO_FORAGING" ).getValueName() ); + break; - case ACTION_TOGGLE_AUTO_PICKUP: - get_options().get_option( "AUTO_PICKUP" ).setNext(); - get_options().save(); - //~ Auto pickup is now set to x - add_msg( _( "%s is now set to %s." ), - get_options().get_option( "AUTO_PICKUP" ).getMenuText(), - get_options().get_option( "AUTO_PICKUP" ).getValueName() ); - break; + case ACTION_TOGGLE_AUTO_PICKUP: + get_options().get_option( "AUTO_PICKUP" ).setNext(); + get_options().save(); + //~ Auto pickup is now set to x + add_msg( _( "%s is now set to %s." ), + get_options().get_option( "AUTO_PICKUP" ).getMenuText(), + get_options().get_option( "AUTO_PICKUP" ).getValueName() ); + break; - case ACTION_DISPLAY_SCENT: - if( MAP_SHARING::isCompetitive() && !MAP_SHARING::isDebugger() ) { - break; //don't do anything when sharing and not debugger - } - display_scent(); - break; + case ACTION_DISPLAY_SCENT: + if( MAP_SHARING::isCompetitive() && !MAP_SHARING::isDebugger() ) + { + break; //don't do anything when sharing and not debugger + } + display_scent(); + break; - case ACTION_DISPLAY_SCENT_TYPE: - if( MAP_SHARING::isCompetitive() && !MAP_SHARING::isDebugger() ) { - break; //don't do anything when sharing and not debugger - } - display_scent(); - break; + case ACTION_DISPLAY_SCENT_TYPE: + if( MAP_SHARING::isCompetitive() && !MAP_SHARING::isDebugger() ) + { + break; //don't do anything when sharing and not debugger + } + display_scent(); + break; - case ACTION_DISPLAY_TEMPERATURE: - if( MAP_SHARING::isCompetitive() && !MAP_SHARING::isDebugger() ) { - break; //don't do anything when sharing and not debugger - } - display_temperature(); - break; - case ACTION_DISPLAY_VEHICLE_AI: - if( MAP_SHARING::isCompetitive() && !MAP_SHARING::isDebugger() ) { - break; //don't do anything when sharing and not debugger - } - display_vehicle_ai(); - break; - case ACTION_DISPLAY_VISIBILITY: - if( MAP_SHARING::isCompetitive() && !MAP_SHARING::isDebugger() ) { - break; //don't do anything when sharing and not debugger - } - display_visibility(); - break; + case ACTION_DISPLAY_TEMPERATURE: + if( MAP_SHARING::isCompetitive() && !MAP_SHARING::isDebugger() ) + { + break; //don't do anything when sharing and not debugger + } + display_temperature(); + break; + case ACTION_DISPLAY_VEHICLE_AI: + if( MAP_SHARING::isCompetitive() && !MAP_SHARING::isDebugger() ) + { + break; //don't do anything when sharing and not debugger + } + display_vehicle_ai(); + break; + case ACTION_DISPLAY_VISIBILITY: + if( MAP_SHARING::isCompetitive() && !MAP_SHARING::isDebugger() ) + { + break; //don't do anything when sharing and not debugger + } + display_visibility(); + break; - case ACTION_DISPLAY_LIGHTING: - if( MAP_SHARING::isCompetitive() && !MAP_SHARING::isDebugger() ) { - break; //don't do anything when sharing and not debugger - } - display_lighting(); - break; + case ACTION_DISPLAY_LIGHTING: + if( MAP_SHARING::isCompetitive() && !MAP_SHARING::isDebugger() ) + { + break; //don't do anything when sharing and not debugger + } + display_lighting(); + break; - case ACTION_DISPLAY_RADIATION: - if( MAP_SHARING::isCompetitive() && !MAP_SHARING::isDebugger() ) { - break; //don't do anything when sharing and not debugger - } - display_radiation(); - break; + case ACTION_DISPLAY_RADIATION: + if( MAP_SHARING::isCompetitive() && !MAP_SHARING::isDebugger() ) + { + break; //don't do anything when sharing and not debugger + } + display_radiation(); + break; - case ACTION_TOGGLE_DEBUG_MODE: - if( MAP_SHARING::isCompetitive() && !MAP_SHARING::isDebugger() ) { - break; //don't do anything when sharing and not debugger - } - debug_mode = !debug_mode; - if( debug_mode ) { - add_msg( m_info, _( "Debug mode ON!" ) ); - } else { - add_msg( m_info, _( "Debug mode OFF!" ) ); - } - break; + case ACTION_TOGGLE_DEBUG_MODE: + if( MAP_SHARING::isCompetitive() && !MAP_SHARING::isDebugger() ) + { + break; //don't do anything when sharing and not debugger + } + debug_mode = !debug_mode; + if( debug_mode ) + { + add_msg( m_info, _( "Debug mode ON!" ) ); + } + else + { + add_msg( m_info, _( "Debug mode OFF!" ) ); + } + break; - case ACTION_ZOOM_IN: - zoom_in(); - break; + case ACTION_ZOOM_IN: + zoom_in(); + break; - case ACTION_ZOOM_OUT: - zoom_out(); - break; + case ACTION_ZOOM_OUT: + zoom_out(); + break; - case ACTION_ITEMACTION: - item_action_menu(); - break; + case ACTION_ITEMACTION: + item_action_menu(); + break; - case ACTION_AUTOATTACK: - avatar_action::autoattack( u, m ); - break; + case ACTION_AUTOATTACK: + avatar_action::autoattack( u, m ); + break; - default: - break; + default: + break; } } - if( act != ACTION_TIMEOUT ) { + if( act != ACTION_TIMEOUT ) + { u.mod_moves( -current_turn.moves_elapsed() ); } gamemode->post_action( act ); From c4ed4c057330e0f7f46ac588d9c03514226f295f Mon Sep 17 00:00:00 2001 From: Pupsi Mupsi <44737997+Pupsi-Mupsi@users.noreply.github.com> Date: Thu, 12 Mar 2020 20:37:15 +0100 Subject: [PATCH 03/10] undo astyle --- src/handle_action.cpp | 2658 +++++++++++++++++------------------------ 1 file changed, 1088 insertions(+), 1570 deletions(-) diff --git a/src/handle_action.cpp b/src/handle_action.cpp index 4fe0a928bc0d4..e9c072d26d8d6 100644 --- a/src/handle_action.cpp +++ b/src/handle_action.cpp @@ -80,44 +80,39 @@ extern bool add_key_to_quick_shortcuts( int key, const std::string &category, bo class user_turn { -private: - std::chrono::time_point user_turn_start; -public: - user_turn() - { - user_turn_start = std::chrono::steady_clock::now(); - } - - bool has_timeout_elapsed() - { - return moves_elapsed() > 100; - } - - int moves_elapsed() - { - const float turn_duration = get_option( "TURN_DURATION" ); - // Magic number 0.005 chosen due to option menu's 2 digit precision and - // the option menu UI rounding <= 0.005 down to "0.00" in the display. - // This conditional will catch values (e.g. 0.003) that the options menu - // would round down to "0.00" in the options menu display. This prevents - // the user from being surprised by floating point rounding near zero. - if( turn_duration <= 0.005 ) - { - return 0; + private: + std::chrono::time_point user_turn_start; + public: + user_turn() { + user_turn_start = std::chrono::steady_clock::now(); + } + + bool has_timeout_elapsed() { + return moves_elapsed() > 100; + } + + int moves_elapsed() { + const float turn_duration = get_option( "TURN_DURATION" ); + // Magic number 0.005 chosen due to option menu's 2 digit precision and + // the option menu UI rounding <= 0.005 down to "0.00" in the display. + // This conditional will catch values (e.g. 0.003) that the options menu + // would round down to "0.00" in the options menu display. This prevents + // the user from being surprised by floating point rounding near zero. + if( turn_duration <= 0.005 ) { + return 0; + } + auto now = std::chrono::steady_clock::now(); + std::chrono::milliseconds elapsed_ms = + std::chrono::duration_cast( now - user_turn_start ); + return elapsed_ms.count() / ( 10.0 * turn_duration ); } - auto now = std::chrono::steady_clock::now(); - std::chrono::milliseconds elapsed_ms = - std::chrono::duration_cast( now - user_turn_start ); - return elapsed_ms.count() / ( 10.0 * turn_duration ); - } }; input_context game::get_player_input( std::string &action ) { input_context ctxt; - if( uquit == QUIT_WATCH ) - { + if( uquit == QUIT_WATCH ) { ctxt = input_context( "DEFAULTMODE" ); ctxt.set_iso( true ); // The list of allowed actions in death-cam mode in game::handle_action @@ -140,9 +135,7 @@ input_context game::get_player_input( std::string &action ) } // *INDENT-ON* ctxt.register_action( "QUIT", to_translation( "Accept your fate" ) ); - } - else - { + } else { ctxt = get_default_mode_input_context(); } @@ -153,8 +146,7 @@ input_context game::get_player_input( std::string &action ) user_turn current_turn; - if( get_option( "ANIMATIONS" ) ) - { + if( get_option( "ANIMATIONS" ) ) { const int TOTAL_VIEW = MAX_VIEW_DISTANCE * 2 + 1; int iStartX = ( TERRAIN_WINDOW_WIDTH > TOTAL_VIEW ) ? ( TERRAIN_WINDOW_WIDTH - TOTAL_VIEW ) / 2 : 0; int iStartY = ( TERRAIN_WINDOW_HEIGHT > TOTAL_VIEW ) ? ( TERRAIN_WINDOW_HEIGHT - TOTAL_VIEW ) / 2 : @@ -167,8 +159,7 @@ input_context game::get_player_input( std::string &action ) ( TERRAIN_WINDOW_HEIGHT - TOTAL_VIEW ) / 2 : TERRAIN_WINDOW_HEIGHT; - if( fullscreen ) - { + if( fullscreen ) { iStartX = 0; iStartY = 0; iEndX = TERMX; @@ -181,8 +172,7 @@ input_context game::get_player_input( std::string &action ) int offset_y = u.posy() + u.view_offset.y - getmaxy( w_terrain ) / 2; #if defined(TILES) - if( tile_iso && use_tiles ) - { + if( tile_iso && use_tiles ) { iStartX = 0; iStartY = 0; iEndX = MAPSIZE_X; @@ -204,10 +194,8 @@ input_context game::get_player_input( std::string &action ) ctxt.set_timeout( 125 ); bool initial_draw = true; - do - { - if( bWeatherEffect && get_option( "ANIMATION_RAIN" ) ) - { + do { + if( bWeatherEffect && get_option( "ANIMATION_RAIN" ) ) { /* Location to add rain drop animation bits! Since it refreshes w_terrain it can be added to the animation section easily Get tile information from above's weather information: @@ -217,17 +205,14 @@ input_context game::get_player_input( std::string &action ) */ #if defined(TILES) - if( !use_tiles ) - { + if( !use_tiles ) { #endif //TILES //If not using tiles, erase previous drops from w_terrain - for( auto &elem : wPrint.vdrops ) - { + for( auto &elem : wPrint.vdrops ) { const tripoint location( elem.first + offset_x, elem.second + offset_y, get_levz() ); const lit_level lighting = visibility_cache[location.x][location.y]; wmove( w_terrain, location.xy() + point( -offset_x, -offset_y ) ); - if( !m.apply_vision_effects( w_terrain, m.get_visibility( lighting, cache ) ) ) - { + if( !m.apply_vision_effects( w_terrain, m.get_visibility( lighting, cache ) ) ) { m.drawsq( w_terrain, u, location, false, true, u.pos() + u.view_offset, lighting == LL_LOW, lighting == LL_BRIGHT ); @@ -238,8 +223,7 @@ input_context game::get_player_input( std::string &action ) #endif //TILES wPrint.vdrops.clear(); - for( int i = 0; i < dropCount; i++ ) - { + for( int i = 0; i < dropCount; i++ ) { const int iRandX = rng( iStartX, iEndX - 1 ); const int iRandY = rng( iStartY, iEndY - 1 ); const int mapx = iRandX + offset_x; @@ -250,33 +234,26 @@ input_context game::get_player_input( std::string &action ) const lit_level lighting = visibility_cache[mapp.x][mapp.y]; if( m.is_outside( mapp ) && m.get_visibility( lighting, cache ) == VIS_CLEAR && - !critter_at( mapp, true ) ) - { + !critter_at( mapp, true ) ) { // Suppress if a critter is there wPrint.vdrops.emplace_back( std::make_pair( iRandX, iRandY ) ); } } } // don't bother calculating SCT if we won't show it - if( uquit != QUIT_WATCH && get_option( "ANIMATION_SCT" ) ) - { + if( uquit != QUIT_WATCH && get_option( "ANIMATION_SCT" ) ) { #if defined(TILES) - if( !use_tiles ) - { + if( !use_tiles ) { #endif - for( auto &elem : SCT.vSCT ) - { + for( auto &elem : SCT.vSCT ) { //Erase previous text from w_terrain - if( elem.getStep() > 0 ) - { + if( elem.getStep() > 0 ) { const int width = utf8_width( elem.getText() ); - for( int i = 0; i < width; ++i ) - { + for( int i = 0; i < width; ++i ) { const tripoint location( elem.getPosX() + i, elem.getPosY(), get_levz() ); const lit_level lighting = visibility_cache[location.x][location.y]; wmove( w_terrain, location.xy() + point( -offset_x, -offset_y ) ); - if( !m.apply_vision_effects( w_terrain, m.get_visibility( lighting, cache ) ) ) - { + if( !m.apply_vision_effects( w_terrain, m.get_visibility( lighting, cache ) ) ) { m.drawsq( w_terrain, u, location, false, true, u.pos() + u.view_offset, lighting == LL_LOW, lighting == LL_BRIGHT ); @@ -291,26 +268,20 @@ input_context game::get_player_input( std::string &action ) SCT.advanceAllSteps(); //Check for creatures on all drawing positions and offset if necessary - for( auto iter = SCT.vSCT.rbegin(); iter != SCT.vSCT.rend(); ++iter ) - { + for( auto iter = SCT.vSCT.rbegin(); iter != SCT.vSCT.rend(); ++iter ) { const direction oCurDir = iter->getDirecton(); const int width = utf8_width( iter->getText() ); - for( int i = 0; i < width; ++i ) - { + for( int i = 0; i < width; ++i ) { tripoint tmp( iter->getPosX() + i, iter->getPosY(), get_levz() ); const Creature *critter = critter_at( tmp, true ); - if( critter != nullptr && u.sees( *critter ) ) - { + if( critter != nullptr && u.sees( *critter ) ) { i = -1; int iPos = iter->getStep() + iter->getStepOffset(); - for( auto iter2 = iter; iter2 != SCT.vSCT.rend(); ++iter2 ) - { + for( auto iter2 = iter; iter2 != SCT.vSCT.rend(); ++iter2 ) { if( iter2->getDirecton() == oCurDir && - iter2->getStep() + iter2->getStepOffset() <= iPos ) - { - if( iter2->getType() == "hp" ) - { + iter2->getStep() + iter2->getStepOffset() <= iPos ) { + if( iter2->getType() == "hp" ) { iter2->advanceStepOffset(); } @@ -323,8 +294,7 @@ input_context game::get_player_input( std::string &action ) } } - if( initial_draw ) - { + if( initial_draw ) { werase( w_terrain ); draw_ter(); @@ -332,33 +302,26 @@ input_context game::get_player_input( std::string &action ) } draw_weather( wPrint ); - if( uquit != QUIT_WATCH ) - { + if( uquit != QUIT_WATCH ) { draw_sct(); } wrefresh( w_terrain ); g->draw_panels(); - if( uquit == QUIT_WATCH ) - { + if( uquit == QUIT_WATCH ) { query_popup() .wait_message( c_red, _( "Press %s to accept your fate…" ), ctxt.get_desc( "QUIT" ) ) .on_top( true ) .show(); } - } - while( handle_mouseview( ctxt, action ) && uquit != QUIT_WATCH - && ( action != "TIMEOUT" || !current_turn.has_timeout_elapsed() ) ); + } while( handle_mouseview( ctxt, action ) && uquit != QUIT_WATCH + && ( action != "TIMEOUT" || !current_turn.has_timeout_elapsed() ) ); ctxt.reset_timeout(); - } - else - { + } else { ctxt.set_timeout( 125 ); - while( handle_mouseview( ctxt, action ) ) - { - if( action == "TIMEOUT" && current_turn.has_timeout_elapsed() ) - { + while( handle_mouseview( ctxt, action ) ) { + if( action == "TIMEOUT" && current_turn.has_timeout_elapsed() ) { break; } } @@ -374,8 +337,7 @@ static void rcdrive( int dx, int dy ) map &m = g->m; std::stringstream car_location_string( u.get_value( "remote_controlling" ) ); - if( car_location_string.str().empty() ) - { + if( car_location_string.str().empty() ) { //no turned radio car found u.add_msg_if_player( m_warning, _( "No radio car connected." ) ); return; @@ -387,15 +349,12 @@ static void rcdrive( int dx, int dy ) auto rc_pairs = m.get_rc_items( tripoint( cx, cy, cz ) ); auto rc_pair = rc_pairs.begin(); - for( ; rc_pair != rc_pairs.end(); ++rc_pair ) - { - if( rc_pair->second->typeId() == "radio_car_on" && rc_pair->second->active ) - { + for( ; rc_pair != rc_pairs.end(); ++rc_pair ) { + if( rc_pair->second->typeId() == "radio_car_on" && rc_pair->second->active ) { break; } } - if( rc_pair == rc_pairs.end() ) - { + if( rc_pair == rc_pairs.end() ) { u.add_msg_if_player( m_warning, _( "No radio car connected." ) ); u.remove_value( "remote_controlling" ); return; @@ -404,14 +363,11 @@ static void rcdrive( int dx, int dy ) tripoint dest( cx + dx, cy + dy, cz ); if( m.impassable( dest ) || !m.can_put_items_ter_furn( dest ) || - m.has_furn( dest ) ) - { + m.has_furn( dest ) ) { sounds::sound( dest, 7, sounds::sound_t::combat, _( "sound of a collision with an obstacle." ), true, "misc", "rc_car_hits_obstacle" ); return; - } - else if( !m.add_item_or_charges( dest, *rc_car ).is_null() ) - { + } else if( !m.add_item_or_charges( dest, *rc_car ).is_null() ) { tripoint src( cx, cy, cz ); //~ Sound of moving a remote controlled car sounds::sound( src, 6, sounds::sound_t::movement, _( "zzz…" ), true, "misc", "rc_car_drives" ); @@ -431,54 +387,43 @@ inline static void rcdrive( point d ) static void pldrive( int x, int y ) { - if( !g->check_safe_mode_allowed() ) - { + if( !g->check_safe_mode_allowed() ) { return; } player &u = g->u; vehicle *veh = g->remoteveh(); bool remote = true; int part = -1; - if( !veh ) - { - if( const optional_vpart_position vp = g->m.veh_at( u.pos() ) ) - { + if( !veh ) { + if( const optional_vpart_position vp = g->m.veh_at( u.pos() ) ) { veh = &vp->vehicle(); part = vp->part_index(); } remote = false; } - if( !veh ) - { + if( !veh ) { dbg( D_ERROR ) << "game::pldrive: can't find vehicle! Drive mode is now off."; debugmsg( "game::pldrive error: can't find vehicle! Drive mode is now off." ); u.in_vehicle = false; return; } - if( !remote ) - { + if( !remote ) { static const itype_id fuel_type_animal( "animal" ); const bool has_animal_controls = veh->part_with_feature( part, "CONTROL_ANIMAL", true ) >= 0; const bool has_controls = veh->part_with_feature( part, "CONTROLS", true ) >= 0; const bool has_animal = veh->has_engine_type( fuel_type_animal, false ) && veh->has_harnessed_animal(); - if( !has_controls && !has_animal_controls ) - { + if( !has_controls && !has_animal_controls ) { add_msg( m_info, _( "You can't drive the vehicle from here. You need controls!" ) ); u.controlling_vehicle = false; return; - } - else if( !has_controls && has_animal_controls && !has_animal ) - { + } else if( !has_controls && has_animal_controls && !has_animal ) { add_msg( m_info, _( "You can't drive this vehicle without an animal to pull it." ) ); u.controlling_vehicle = false; return; } - } - else - { - if( empty( veh->get_avail_parts( "REMOTE_CONTROLS" ) ) ) - { + } else { + if( empty( veh->get_avail_parts( "REMOTE_CONTROLS" ) ) ) { add_msg( m_info, _( "Can't drive this vehicle remotely. It has no working controls." ) ); return; } @@ -501,67 +446,49 @@ static void open() pgettext( "no door, gate, curtain, etc.", "There is nothing that can be opened nearby." ), ACTION_OPEN, false ); - if( !openp_ ) - { + if( !openp_ ) { return; } const tripoint openp = *openp_; u.moves -= 100; - if( const optional_vpart_position vp = m.veh_at( openp ) ) - { + if( const optional_vpart_position vp = m.veh_at( openp ) ) { vehicle *const veh = &vp->vehicle(); int openable = veh->next_part_to_open( vp->part_index() ); - if( openable >= 0 ) - { + if( openable >= 0 ) { const vehicle *player_veh = veh_pointer_or_null( m.veh_at( u.pos() ) ); bool outside = !player_veh || player_veh != veh; - if( !outside ) - { - if( !veh->handle_potential_theft( dynamic_cast( g->u ) ) ) - { + if( !outside ) { + if( !veh->handle_potential_theft( dynamic_cast( g->u ) ) ) { u.moves += 100; return; - } - else - { + } else { veh->open( openable ); } - } - else - { + } else { // Outside means we check if there's anything in that tile outside-openable. // If there is, we open everything on tile. This means opening a closed, // curtained door from outside is possible, but it will magically open the // curtains as well. int outside_openable = veh->next_part_to_open( vp->part_index(), true ); - if( outside_openable == -1 ) - { + if( outside_openable == -1 ) { const std::string name = veh->part_info( openable ).name(); add_msg( m_info, _( "That %s can only opened from the inside." ), name ); u.moves += 100; - } - else - { - if( !veh->handle_potential_theft( dynamic_cast( g->u ) ) ) - { + } else { + if( !veh->handle_potential_theft( dynamic_cast( g->u ) ) ) { u.moves += 100; return; - } - else - { + } else { veh->open_all_at( openable ); } } } - } - else - { + } else { // If there are any OPENABLE parts here, they must be already open if( const cata::optional already_open = vp.part_with_feature( "OPENABLE", - true ) ) - { + true ) ) { const std::string name = already_open->info().name(); add_msg( m_info, _( "That %s is already open." ), name ); } @@ -572,17 +499,13 @@ static void open() bool didit = m.open_door( openp, !m.is_outside( u.pos() ) ); - if( !didit ) - { + if( !didit ) { const ter_str_id tid = m.ter( openp ).id(); - if( m.has_flag( flag_LOCKED, openp ) ) - { + if( m.has_flag( flag_LOCKED, openp ) ) { add_msg( m_info, _( "The door is locked!" ) ); return; - } - else if( tid.obj().close ) - { + } else if( tid.obj().close ) { // if the following message appears unexpectedly, the prior check was for t_door_o add_msg( m_info, _( "That door is already open." ) ); u.moves += 100; @@ -597,8 +520,7 @@ static void close() { if( const cata::optional pnt = choose_adjacent_highlight( _( "Close where?" ), pgettext( "no door, gate, etc.", "There is nothing that can be closed nearby." ), - ACTION_CLOSE, false ) ) - { + ACTION_CLOSE, false ) ) { doors::close_door( g->m, g->u, *pnt ); } } @@ -606,28 +528,21 @@ static void close() static void handbrake() { const optional_vpart_position vp = g->m.veh_at( g->u.pos() ); - if( !vp ) - { + if( !vp ) { return; } vehicle *const veh = &vp->vehicle(); add_msg( _( "You pull a handbrake." ) ); veh->cruise_velocity = 0; - if( veh->last_turn != 0 && rng( 15, 60 ) * 100 < abs( veh->velocity ) ) - { + if( veh->last_turn != 0 && rng( 15, 60 ) * 100 < abs( veh->velocity ) ) { veh->skidding = true; add_msg( m_warning, _( "You lose control of %s." ), veh->name ); veh->turn( veh->last_turn > 0 ? 60 : -60 ); - } - else - { + } else { int braking_power = abs( veh->velocity ) / 2 + 10 * 100; - if( abs( veh->velocity ) < braking_power ) - { + if( abs( veh->velocity ) < braking_power ) { veh->stop(); - } - else - { + } else { int sgn = veh->velocity > 0 ? 1 : -1; veh->velocity = sgn * ( abs( veh->velocity ) - braking_power ); } @@ -641,14 +556,10 @@ static void grab() avatar &you = g->u; map &m = g->m; - if( you.get_grab_type() != OBJECT_NONE ) - { - if( const optional_vpart_position vp = m.veh_at( you.pos() + you.grab_point ) ) - { + if( you.get_grab_type() != OBJECT_NONE ) { + if( const optional_vpart_position vp = m.veh_at( you.pos() + you.grab_point ) ) { add_msg( _( "You release the %s." ), vp->vehicle().name ); - } - else if( m.has_furn( you.pos() + you.grab_point ) ) - { + } else if( m.has_furn( you.pos() + you.grab_point ) ) { add_msg( _( "You release the %s." ), m.furnname( you.pos() + you.grab_point ) ); } @@ -657,47 +568,35 @@ static void grab() } const cata::optional grabp_ = choose_adjacent( _( "Grab where?" ) ); - if( !grabp_ ) - { + if( !grabp_ ) { add_msg( _( "Never mind." ) ); return; } const tripoint grabp = *grabp_; - if( grabp == you.pos() ) - { + if( grabp == you.pos() ) { add_msg( _( "You get a hold of yourself." ) ); you.grab( OBJECT_NONE ); return; } - if( const optional_vpart_position vp = m.veh_at( grabp ) ) - { - if( !vp->vehicle().handle_potential_theft( dynamic_cast( g->u ) ) ) - { + if( const optional_vpart_position vp = m.veh_at( grabp ) ) { + if( !vp->vehicle().handle_potential_theft( dynamic_cast( g->u ) ) ) { return; } you.grab( OBJECT_VEHICLE, grabp - you.pos() ); add_msg( _( "You grab the %s." ), vp->vehicle().name ); - } - else if( m.has_furn( grabp ) ) // If not, grab furniture if present - { - if( !m.furn( grabp ).obj().is_movable() ) - { + } else if( m.has_furn( grabp ) ) { // If not, grab furniture if present + if( !m.furn( grabp ).obj().is_movable() ) { add_msg( _( "You can not grab the %s" ), m.furnname( grabp ) ); return; } you.grab( OBJECT_FURNITURE, grabp - you.pos() ); - if( !m.can_move_furniture( grabp, &you ) ) - { + if( !m.can_move_furniture( grabp, &you ) ) { add_msg( _( "You grab the %s. It feels really heavy." ), m.furnname( grabp ) ); - } - else - { + } else { add_msg( _( "You grab the %s." ), m.furnname( grabp ) ); } - } - else // TODO: grab mob? Captured squirrel = pet (or meat that stays fresh longer). - { + } else { // TODO: grab mob? Captured squirrel = pet (or meat that stays fresh longer). add_msg( m_info, _( "There's nothing to grab there!" ) ); } } @@ -707,30 +606,18 @@ static void haul() player &u = g->u; map &m = g->m; - if( u.is_hauling() ) - { + if( u.is_hauling() ) { u.stop_hauling(); - } - else - { - if( m.veh_at( u.pos() ) ) - { + } else { + if( m.veh_at( u.pos() ) ) { add_msg( m_info, _( "You cannot haul inside vehicles." ) ); - } - else if( m.has_flag( TFLAG_DEEP_WATER, u.pos() ) ) - { + } else if( m.has_flag( TFLAG_DEEP_WATER, u.pos() ) ) { add_msg( m_info, _( "You cannot haul while in deep water." ) ); - } - else if( !m.can_put_items( u.pos() ) ) - { + } else if( !m.can_put_items( u.pos() ) ) { add_msg( m_info, _( "You cannot haul items here." ) ); - } - else if( !m.has_items( u.pos() ) ) - { + } else if( !m.has_items( u.pos() ) ) { add_msg( m_info, _( "There are no items to haul here." ) ); - } - else - { + } else { u.start_hauling(); } } @@ -740,13 +627,10 @@ static void smash() { player &u = g->u; map &m = g->m; - if( u.is_mounted() ) - { + if( u.is_mounted() ) { auto mons = u.mounted_creature.get(); - if( mons->has_flag( MF_RIDEABLE_MECH ) ) - { - if( !mons->check_mech_powered() ) - { + if( mons->has_flag( MF_RIDEABLE_MECH ) ) { + if( !mons->check_mech_powered() ) { add_msg( m_bad, _( "Your %s refuses to move as its batteries have been drained." ), mons->get_name() ); return; @@ -758,31 +642,25 @@ static void smash() bool mech_smash = false; int smashskill; ///\EFFECT_STR increases smashing capability - if( u.is_mounted() ) - { + if( u.is_mounted() ) { auto mon = u.mounted_creature.get(); smashskill = u.str_cur + mon->mech_str_addition() + mon->type->melee_dice * mon->type->melee_sides; mech_smash = true; - } - else - { + } else { smashskill = u.str_cur + u.weapon.damage_melee( DT_BASH ); } const bool allow_floor_bash = debug_mode; // Should later become "true" const cata::optional smashp_ = choose_adjacent( _( "Smash where?" ), allow_floor_bash ); - if( !smashp_ ) - { + if( !smashp_ ) { return; } tripoint smashp = *smashp_; bool smash_floor = false; - if( smashp.z != u.posz() ) - { - if( smashp.z > u.posz() ) - { + if( smashp.z != u.posz() ) { + if( smashp.z > u.posz() ) { // TODO: Knock on the ceiling return; } @@ -790,16 +668,13 @@ static void smash() smashp.z = u.posz(); smash_floor = true; } - if( u.is_mounted() ) - { + if( u.is_mounted() ) { monster *crit = u.mounted_creature.get(); - if( crit->has_flag( MF_RIDEABLE_MECH ) ) - { + if( crit->has_flag( MF_RIDEABLE_MECH ) ) { crit->use_mech_power( -3 ); } } - if( m.get_field( smashp, fd_web ) != nullptr ) - { + if( m.get_field( smashp, fd_web ) != nullptr ) { m.remove_field( smashp, fd_web ); sounds::sound( smashp, 2, sounds::sound_t::combat, _( "hsh!" ), true, "smash", "web" ); add_msg( m_info, _( "You brush aside some webs." ) ); @@ -807,11 +682,9 @@ static void smash() return; } - for( const auto &maybe_corpse : m.i_at( smashp ) ) - { + for( const auto &maybe_corpse : m.i_at( smashp ) ) { if( maybe_corpse.is_corpse() && maybe_corpse.damage() < maybe_corpse.max_damage() && - maybe_corpse.get_mtype()->has_flag( MF_REVIVES ) ) - { + maybe_corpse.get_mtype()->has_flag( MF_REVIVES ) ) { // do activity forever. ACT_PULP stops itself u.assign_activity( ACT_PULP, calendar::INDEFINITELY_LONG, 0 ); u.activity.placement = g->m.getabs( smashp ); @@ -819,40 +692,32 @@ static void smash() } } vehicle *veh = veh_pointer_or_null( g->m.veh_at( smashp ) ); - if( veh != nullptr ) - { - if( !veh->handle_potential_theft( dynamic_cast( g->u ) ) ) - { + if( veh != nullptr ) { + if( !veh->handle_potential_theft( dynamic_cast( g->u ) ) ) { return; } } didit = m.bash( smashp, smashskill, false, false, smash_floor ).did_bash; - if( didit ) - { - if( !mech_smash ) - { + if( didit ) { + if( !mech_smash ) { u.increase_activity_level( MODERATE_EXERCISE ); u.handle_melee_wear( u.weapon ); const int mod_sta = ( ( u.weapon.weight() / 10_gram ) + 200 + static_cast ( get_option( "PLAYER_BASE_STAMINA_REGEN_RATE" ) ) ) * -1; u.mod_stamina( mod_sta ); - if( u.get_skill_level( skill_melee ) == 0 ) - { + if( u.get_skill_level( skill_melee ) == 0 ) { u.practice( skill_melee, rng( 0, 1 ) * rng( 0, 1 ) ); } const int vol = u.weapon.volume() / units::legacy_volume_factor; if( u.weapon.made_of( material_id( "glass" ) ) && - rng( 0, vol + 3 ) < vol ) - { + rng( 0, vol + 3 ) < vol ) { add_msg( m_bad, _( "Your %s shatters!" ), u.weapon.tname() ); - for( auto &elem : u.weapon.contents ) - { + for( auto &elem : u.weapon.contents ) { m.add_item_or_charges( u.pos(), elem ); } sounds::sound( u.pos(), 24, sounds::sound_t::combat, "CRACK!", true, "smash", "glass" ); u.deal_damage( nullptr, bp_hand_r, damage_instance( DT_CUT, rng( 0, vol ) ) ); - if( vol > 20 ) - { + if( vol > 20 ) { // Hurt left arm too, if it was big u.deal_damage( nullptr, bp_hand_l, damage_instance( DT_CUT, rng( 0, static_cast( vol * .5 ) ) ) ); @@ -863,22 +728,16 @@ static void smash() } u.moves -= move_cost; - if( smashskill < m.bash_resistance( smashp ) && one_in( 10 ) ) - { - if( m.has_furn( smashp ) && m.furn( smashp ).obj().bash.str_min != -1 ) - { + if( smashskill < m.bash_resistance( smashp ) && one_in( 10 ) ) { + if( m.has_furn( smashp ) && m.furn( smashp ).obj().bash.str_min != -1 ) { // %s is the smashed furniture add_msg( m_neutral, _( "You don't seem to be damaging the %s." ), m.furnname( smashp ) ); - } - else - { + } else { // %s is the smashed terrain add_msg( m_neutral, _( "You don't seem to be damaging the %s." ), m.tername( smashp ) ); } } - } - else - { + } else { add_msg( _( "There's nothing there to smash!" ) ); } } @@ -911,17 +770,14 @@ static void wait() bool setting_alarm = false; if( u.controlling_vehicle && ( g->m.veh_at( u.pos() )->vehicle().velocity || - g->m.veh_at( u.pos() )->vehicle().cruise_velocity ) ) - { + g->m.veh_at( u.pos() )->vehicle().cruise_velocity ) ) { popup( _( "You can't pass time while controlling a moving vehicle." ) ); return; } - if( u.has_alarm_clock() ) - { + if( u.has_alarm_clock() ) { int alarm_query = try_set_alarm(); - if( alarm_query == UILIST_CANCEL ) - { + if( alarm_query == UILIST_CANCEL ) { return; } setting_alarm = alarm_query == 1; @@ -931,13 +787,11 @@ static void wait() const auto add_menu_item = [ &as_m, &durations, has_watch ] ( int retval, int hotkey, const std::string &caption = "", - const time_duration &duration = time_duration::from_turns( calendar::INDEFINITELY_LONG ) ) - { + const time_duration &duration = time_duration::from_turns( calendar::INDEFINITELY_LONG ) ) { std::string text( caption ); - if( has_watch && duration != time_duration::from_turns( calendar::INDEFINITELY_LONG ) ) - { + if( has_watch && duration != time_duration::from_turns( calendar::INDEFINITELY_LONG ) ) { const std::string dur_str( to_string( duration ) ); text += ( text.empty() ? dur_str : string_format( " (%s)", dur_str ) ); } @@ -945,29 +799,23 @@ static void wait() durations.emplace( retval, duration ); }; - if( setting_alarm ) - { + if( setting_alarm ) { add_menu_item( 0, '0', "", 30_minutes ); - for( int i = 1; i <= 9; ++i ) - { + for( int i = 1; i <= 9; ++i ) { add_menu_item( i, '0' + i, "", i * 1_hours ); } - } - else - { - if( g->u.get_stamina() < g->u.get_stamina_max() ) - { + } else { + if( g->u.get_stamina() < g->u.get_stamina_max() ) { as_m.addentry( 12, true, 'w', _( "Wait until you catch your breath" ) ); durations.emplace( 12, 15_minutes ); // to hide it from showing } add_menu_item( 1, '1', !has_watch ? _( "Wait 300 heartbeats" ) : "", 5_minutes ); add_menu_item( 2, '2', !has_watch ? _( "Wait 1800 heartbeats" ) : "", 30_minutes ); - if( has_watch ) - { + if( has_watch ) { add_menu_item( 3, '3', "", 1_hours ); add_menu_item( 4, '4', "", 2_hours ); add_menu_item( 5, '5', "", 3_hours ); @@ -975,11 +823,9 @@ static void wait() } } - if( g->get_levz() >= 0 || has_watch ) - { + if( g->get_levz() >= 0 || has_watch ) { const time_point last_midnight = calendar::turn - time_past_midnight( calendar::turn ); - const auto diurnal_time_before = []( const time_point & p ) - { + const auto diurnal_time_before = []( const time_point & p ) { // Either the given time is in the future (e.g. waiting for sunset while it's early morning), // than use it directly. Otherwise (in the past), add a single day to get the same time tomorrow // (e.g. waiting for sunrise while it's noon). @@ -999,16 +845,12 @@ static void wait() add_menu_item( 10, 'm', setting_alarm ? _( "Set alarm for midnight" ) : _( "Wait till midnight" ), diurnal_time_before( last_midnight + 0_hours ) ); - if( setting_alarm ) - { - if( u.has_effect( effect_alarm_clock ) ) - { + if( setting_alarm ) { + if( u.has_effect( effect_alarm_clock ) ) { add_menu_item( 11, 'x', _( "Cancel the currently set alarm." ), 0_turns ); } - } - else - { + } else { add_menu_item( 11, 'W', _( "Wait till weather changes" ) ); } } @@ -1019,41 +861,29 @@ static void wait() as_m.query(); /* calculate key and window variables, generate window, and loop until we get a valid answer */ const auto dur_iter = durations.find( as_m.ret ); - if( dur_iter == durations.end() ) - { + if( dur_iter == durations.end() ) { return; } const time_duration time_to_wait = dur_iter->second; - if( setting_alarm ) - { + if( setting_alarm ) { // Setting alarm u.remove_effect( effect_alarm_clock ); - if( as_m.ret == 11 ) - { + if( as_m.ret == 11 ) { add_msg( _( "You cancel your alarm." ) ); - } - else - { + } else { u.add_effect( effect_alarm_clock, time_to_wait ); add_msg( _( "You set your alarm." ) ); } - } - else - { + } else { // Waiting activity_id actType; - if( as_m.ret == 11 ) - { + if( as_m.ret == 11 ) { actType = ACT_WAIT_WEATHER; - } - else if( as_m.ret == 12 ) - { + } else if( as_m.ret == 12 ) { actType = ACT_WAIT_STAMINA; - } - else - { + } else { actType = ACT_WAIT; } @@ -1066,8 +896,7 @@ static void wait() static void sleep() { player &u = g->u; - if( u.is_mounted() ) - { + if( u.is_mounted() ) { u.add_msg_if_player( m_info, _( "You cannot sleep while mounted." ) ); return; } @@ -1084,53 +913,42 @@ static void sleep() get_option( "FORCE_CAPITAL_YN" ) ? 'Y' : 'y', _( "Yes." ) ); - // List all active items, bionics or mutations so player can deactivate them std::vector active; - for( auto &it : u.inv_dump() ) - { + for( auto &it : u.inv_dump() ) { if( it->active && ( it->charges > 0 || it->units_remaining( u ) > 0 ) && - it->is_transformable() ) - { + it->is_transformable() ) { active.push_back( it->tname() ); } } - for( int i = 0; i < g->u.num_bionics(); i++ ) - { + for( int i = 0; i < g->u.num_bionics(); i++ ) { const bionic &bio = u.bionic_at_index( i ); - if( !bio.powered ) - { + if( !bio.powered ) { continue; } // some bionics // bio_alarm is useful for waking up during sleeping // turning off bio_leukocyte has 'unpleasant side effects' - if( bio.info().sleep_friendly ) - { + if( bio.info().sleep_friendly ) { continue; } const auto &info = bio.info(); - if( info.power_over_time > 0_kJ ) - { + if( info.power_over_time > 0_kJ ) { active.push_back( info.name.translated() ); } } - for( auto &mut : u.get_mutations() ) - { + for( auto &mut : u.get_mutations() ) { const auto &mdata = mut.obj(); - if( mdata.cost > 0 && u.has_active_mutation( mut ) ) - { + if( mdata.cost > 0 && u.has_active_mutation( mut ) ) { active.push_back( mdata.name() ); } } // check for deactivating any currently played music instrument. - for( auto &item : u.inv_dump() ) - { - if( item->active && item->get_use( "musical_instrument" ) != nullptr ) - { + for( auto &item : u.inv_dump() ) { + if( item->active && item->get_use( "musical_instrument" ) != nullptr ) { u.add_msg_if_player( _( "You stop playing your %s before trying to sleep." ), item->tname() ); // deactivate instrument item->active = false; @@ -1139,13 +957,11 @@ static void sleep() // ask for deactivation std::stringstream data; - if( !active.empty() ) - { + if( !active.empty() ) { data << as_m.text << std::endl; data << _( "You may want to deactivate these before you sleep." ) << std::endl; data << " " << std::endl; - for( auto &a : active ) - { + for( auto &a : active ) { data << "" << a << "" << std::endl; } as_m.text = data.str(); @@ -1155,23 +971,18 @@ static void sleep() and loop until we get a valid answer. */ as_m.query(); - if( as_m.ret == 1 ) - { + if( as_m.ret == 1 ) { g->quicksave(); - } - else if( as_m.ret == 2 || as_m.ret < 0 ) - { + } else if( as_m.ret == 2 || as_m.ret < 0 ) { return; } time_duration try_sleep_dur = 24_hours; std::string deaf_text; - if( g->u.is_deaf() ) - { + if( g->u.is_deaf() ) { deaf_text = _( " (DEAF!)" ); } - if( u.has_alarm_clock() ) - { + if( u.has_alarm_clock() ) { /* Reuse menu to ask player whether they want to set an alarm. */ bool can_hibernate = u.get_hunger() < -60 && u.has_active_mutation( trait_HIBERNATE ); @@ -1186,20 +997,16 @@ static void sleep() get_option( "FORCE_CAPITAL_YN" ) ? 'N' : 'n', _( "No, don't set an alarm." ) ); - for( int i = 3; i <= 9; ++i ) - { + for( int i = 3; i <= 9; ++i ) { as_m.entries.emplace_back( i, true, '0' + i, string_format( _( "Set alarm to wake up in %i hours." ), i ) + deaf_text ); } as_m.query(); - if( as_m.ret >= 3 && as_m.ret <= 9 ) - { + if( as_m.ret >= 3 && as_m.ret <= 9 ) { u.add_effect( effect_alarm_clock, 1_hours * as_m.ret ); try_sleep_dur = 1_hours * as_m.ret + 1_turns; - } - else if( as_m.ret < 0 ) - { + } else if( as_m.ret < 0 ) { return; } } @@ -1210,8 +1017,7 @@ static void sleep() static void loot() { - enum ZoneFlags - { + enum ZoneFlags { None = 1, SortLoot = 2, FertilizePlots = 16, @@ -1235,8 +1041,7 @@ static void loot() mgr.cache_vzones(); flags |= g->check_near_zone( zone_type_id( "LOOT_UNSORTED" ), u.pos() ) ? SortLoot : 0; - if( g->check_near_zone( zone_type_id( "FARM_PLOT" ), u.pos() ) ) - { + if( g->check_near_zone( zone_type_id( "FARM_PLOT" ), u.pos() ) ) { flags |= FertilizePlots; flags |= MultiFarmPlots; } @@ -1249,8 +1054,7 @@ static void loot() u.pos() ) ? Multideconvehicle : 0; flags |= g->check_near_zone( zone_type_id( "VEHICLE_REPAIR" ), u.pos() ) ? Multirepairvehicle : 0; flags |= g->check_near_zone( zone_type_id( "LOOT_CORPSE" ), u.pos() ) ? MultiButchery : 0; - if( flags == 0 ) - { + if( flags == 0 ) { add_msg( m_info, _( "There is no compatible zone nearby." ) ); add_msg( m_info, _( "Compatible zones are %s and %s" ), mgr.get_name_from_type( zone_type_id( "LOOT_UNSORTED" ) ), @@ -1262,51 +1066,42 @@ static void loot() menu.text = _( "Pick action:" ); menu.desc_enabled = true; - if( flags & SortLoot ) - { + if( flags & SortLoot ) { menu.addentry_desc( SortLoot, true, 'o', _( "Sort out my loot" ), _( "Sorts out the loot from Loot: Unsorted zone to nearby appropriate Loot zones. Uses empty space in your inventory or utilizes a cart, if you are holding one." ) ); } - if( flags & FertilizePlots ) - { + if( flags & FertilizePlots ) { menu.addentry_desc( FertilizePlots, has_fertilizer, 'f', !has_fertilizer ? _( "Fertilize plots… you don't have any fertilizer" ) : _( "Fertilize plots" ), _( "Fertilize any nearby Farm: Plot zones." ) ); } - if( flags & ConstructPlots ) - { + if( flags & ConstructPlots ) { menu.addentry_desc( ConstructPlots, true, 'c', _( "Construct plots" ), _( "Work on any nearby Blueprint: construction zones." ) ); } - if( flags & MultiFarmPlots ) - { + if( flags & MultiFarmPlots ) { menu.addentry_desc( MultiFarmPlots, true, 'm', _( "Farm plots" ), _( "Till and plant on any nearby farm plots - auto-fetch seeds and tools." ) ); } - if( flags & Multichoptrees ) - { + if( flags & Multichoptrees ) { menu.addentry_desc( Multichoptrees, true, 'C', _( "Chop trees" ), _( "Chop down any trees in the designated zone - auto-fetch tools." ) ); } - if( flags & Multichopplanks ) - { + if( flags & Multichopplanks ) { menu.addentry_desc( Multichopplanks, true, 'P', _( "Chop planks" ), _( "Auto-chop logs in wood loot zones into planks - auto-fetch tools." ) ); } - if( flags & Multideconvehicle ) - { + if( flags & Multideconvehicle ) { menu.addentry_desc( Multideconvehicle, true, 'v', _( "Deconstruct vehicle" ), _( "Auto-deconstruct vehicle in designated zone - auto-fetch tools." ) ); } - if( flags & Multirepairvehicle ) - { + if( flags & Multirepairvehicle ) { menu.addentry_desc( Multirepairvehicle, true, 'V', _( "Repair vehicle" ), _( "Auto-repair vehicle in designated zone - auto-fetch tools." ) ); } - if( flags & MultiButchery ) - { + if( flags & MultiButchery ) { menu.addentry_desc( MultiButchery, true, 'B', _( "Butcher corpses" ), _( "Auto-butcher anything in corpse loot zones - auto-fetch tools." ) ); } @@ -1314,41 +1109,40 @@ static void loot() menu.query(); flags = ( menu.ret >= 0 ) ? menu.ret : None; - switch( flags ) - { - case None: - add_msg( _( "Never mind." ) ); - break; - case SortLoot: - u.assign_activity( ACT_MOVE_LOOT ); - break; - case FertilizePlots: - u.assign_activity( ACT_FERTILIZE_PLOT ); - break; - case ConstructPlots: - u.assign_activity( ACT_MULTIPLE_CONSTRUCTION ); - break; - case MultiFarmPlots: - u.assign_activity( ACT_MULTIPLE_FARM ); - break; - case Multichoptrees: - u.assign_activity( ACT_MULTIPLE_CHOP_TREES ); - break; - case Multichopplanks: - u.assign_activity( ACT_MULTIPLE_CHOP_PLANKS ); - break; - case Multideconvehicle: - u.assign_activity( ACT_VEHICLE_DECONSTRUCTION ); - break; - case Multirepairvehicle: - u.assign_activity( ACT_VEHICLE_REPAIR ); - break; - case MultiButchery: - u.assign_activity( ACT_MULTIPLE_BUTCHER ); - break; - default: - debugmsg( "Unsupported flag" ); - break; + switch( flags ) { + case None: + add_msg( _( "Never mind." ) ); + break; + case SortLoot: + u.assign_activity( ACT_MOVE_LOOT ); + break; + case FertilizePlots: + u.assign_activity( ACT_FERTILIZE_PLOT ); + break; + case ConstructPlots: + u.assign_activity( ACT_MULTIPLE_CONSTRUCTION ); + break; + case MultiFarmPlots: + u.assign_activity( ACT_MULTIPLE_FARM ); + break; + case Multichoptrees: + u.assign_activity( ACT_MULTIPLE_CHOP_TREES ); + break; + case Multichopplanks: + u.assign_activity( ACT_MULTIPLE_CHOP_PLANKS ); + break; + case Multideconvehicle: + u.assign_activity( ACT_VEHICLE_DECONSTRUCTION ); + break; + case Multirepairvehicle: + u.assign_activity( ACT_VEHICLE_REPAIR ); + break; + case MultiButchery: + u.assign_activity( ACT_MULTIPLE_BUTCHER ); + break; + default: + debugmsg( "Unsupported flag" ); + break; } } @@ -1357,12 +1151,9 @@ static void wear() avatar &u = g->u; item_location loc = game_menus::inv::wear( u ); - if( loc ) - { + if( loc ) { u.wear( u.i_at( loc.obtain( u ) ) ); - } - else - { + } else { add_msg( _( "Never mind." ) ); } } @@ -1372,12 +1163,9 @@ static void takeoff() avatar &u = g->u; item_location loc = game_menus::inv::take_off( u ); - if( loc ) - { + if( loc ) { u.takeoff( u.i_at( loc.obtain( u ) ) ); - } - else - { + } else { add_msg( _( "Never mind." ) ); } } @@ -1388,22 +1176,16 @@ static void read() // Can read items from inventory or within one tile (including in vehicles) item_location loc = game_menus::inv::read( u ); - if( loc ) - { - if( loc->type->can_use( "learn_spell" ) ) - { + if( loc ) { + if( loc->type->can_use( "learn_spell" ) ) { item spell_book = *loc.get_item(); spell_book.get_use( "learn_spell" )->call( u, spell_book, spell_book.active, u.pos() ); - } - else - { + } else { // calling obtain() invalidates the item pointer // TODO: find a way to do this without an int index u.read( u.i_at( loc.obtain( u ) ) ); } - } - else - { + } else { add_msg( _( "Never mind." ) ); } } @@ -1417,8 +1199,7 @@ static void reach_attack( int range, player &u ) g->m.draw( g->w_terrain, u.pos() ); std::vector trajectory = target_handler().target_ui( u, TARGET_MODE_REACH, &u.weapon, range ); - if( !trajectory.empty() ) - { + if( !trajectory.empty() ) { u.reach_attack( trajectory.back() ); } g->draw_ter(); @@ -1432,86 +1213,73 @@ static void fire() player &u = g->u; // Use vehicle turret or draw a pistol from a holster if unarmed - if( !u.is_armed() ) - { + if( !u.is_armed() ) { const optional_vpart_position vp = g->m.veh_at( u.pos() ); turret_data turret; // TODO: move direct turret firing from ACTION_FIRE to separate function. - if( vp && ( turret = vp->vehicle().turret_query( u.pos() ) ) ) - { - switch( turret.query() ) - { - case turret_data::status::no_ammo: - add_msg( m_bad, _( "The %s is out of ammo." ), turret.name() ); - break; - - case turret_data::status::no_power: - add_msg( m_bad, _( "The %s is not powered." ), turret.name() ); - break; - - case turret_data::status::ready: - { - // if more than one firing mode provide callback to cycle through them - target_callback switch_mode; - if( turret.base()->gun_all_modes().size() > 1 ) - { - switch_mode = [&turret]( item * obj ) - { - obj->gun_cycle_mode(); - // currently gun modes do not change ammo but they may in the future - return turret.ammo_current() == "null" ? nullptr : - item::find_type( turret.ammo_current() ); - }; - } + if( vp && ( turret = vp->vehicle().turret_query( u.pos() ) ) ) { + switch( turret.query() ) { + case turret_data::status::no_ammo: + add_msg( m_bad, _( "The %s is out of ammo." ), turret.name() ); + break; - // if multiple ammo types available provide callback to cycle alternatives - target_callback switch_ammo; - if( turret.ammo_options().size() > 1 ) - { - switch_ammo = [&turret]( item * ) - { - const auto opts = turret.ammo_options(); - auto iter = opts.find( turret.ammo_current() ); - turret.ammo_select( ++iter != opts.end() ? *iter : *opts.begin() ); - return item::find_type( turret.ammo_current() ); - }; - } + case turret_data::status::no_power: + add_msg( m_bad, _( "The %s is not powered." ), turret.name() ); + break; - // callbacks for handling setup and cleanup of turret firing - firing_callback prepare_fire = [&u, &turret]( const int ) - { - turret.prepare_fire( u ); - }; - firing_callback post_fire = [&u, &turret]( const int shots ) - { - turret.post_fire( u, shots ); - }; + case turret_data::status::ready: { + // if more than one firing mode provide callback to cycle through them + target_callback switch_mode; + if( turret.base()->gun_all_modes().size() > 1 ) { + switch_mode = [&turret]( item * obj ) { + obj->gun_cycle_mode(); + // currently gun modes do not change ammo but they may in the future + return turret.ammo_current() == "null" ? nullptr : + item::find_type( turret.ammo_current() ); + }; + } - targeting_data args = - { - TARGET_MODE_TURRET_MANUAL, & *turret.base(), - turret.range(), 0, false, turret.ammo_data(), - switch_mode, switch_ammo, prepare_fire, post_fire - }; - u.set_targeting_data( args ); - avatar_action::fire( g->u, g->m ); + // if multiple ammo types available provide callback to cycle alternatives + target_callback switch_ammo; + if( turret.ammo_options().size() > 1 ) { + switch_ammo = [&turret]( item * ) { + const auto opts = turret.ammo_options(); + auto iter = opts.find( turret.ammo_current() ); + turret.ammo_select( ++iter != opts.end() ? *iter : *opts.begin() ); + return item::find_type( turret.ammo_current() ); + }; + } - break; - } + // callbacks for handling setup and cleanup of turret firing + firing_callback prepare_fire = [&u, &turret]( const int ) { + turret.prepare_fire( u ); + }; + firing_callback post_fire = [&u, &turret]( const int shots ) { + turret.post_fire( u, shots ); + }; - default: - debugmsg( "unknown turret status" ); - break; + targeting_data args = { + TARGET_MODE_TURRET_MANUAL, & *turret.base(), + turret.range(), 0, false, turret.ammo_data(), + switch_mode, switch_ammo, prepare_fire, post_fire + }; + u.set_targeting_data( args ); + avatar_action::fire( g->u, g->m ); + + break; + } + + default: + debugmsg( "unknown turret status" ); + break; } return; } - if( vp.part_with_feature( "CONTROLS", true ) ) - { - if( vp->vehicle().turrets_aim_and_fire() ) - { + if( vp.part_with_feature( "CONTROLS", true ) ) { + if( vp->vehicle().turrets_aim_and_fire() ) { return; } } @@ -1519,11 +1287,9 @@ static void fire() std::vector options; std::vector> actions; - for( auto &w : u.worn ) - { + for( auto &w : u.worn ) { if( w.type->can_use( "holster" ) && !w.has_flag( flag_NO_QUICKDRAW ) && - !w.contents.empty() && w.contents.front().is_gun() ) - { + !w.contents.empty() && w.contents.front().is_gun() ) { //~ draw (first) gun contained in holster //~ %1$s: weapon name, %2$s: container name, %3$d: remaining ammo count options.push_back( string_format( pgettext( "holster", "%1$s from %2$s (%3$d)" ), @@ -1533,67 +1299,46 @@ static void fire() actions.emplace_back( [&] { u.invoke_item( &w, "holster" ); } ); - } - else if( w.is_gun() && w.gunmod_find( "shoulder_strap" ) ) - { + } else if( w.is_gun() && w.gunmod_find( "shoulder_strap" ) ) { // wield item currently worn using shoulder strap options.push_back( w.display_name() ); actions.emplace_back( [&] { u.wield( w ); } ); } } - if( !options.empty() ) - { + if( !options.empty() ) { int sel = uilist( _( "Draw what?" ), options ); - if( sel >= 0 ) - { + if( sel >= 0 ) { actions[sel](); } } } - if( u.weapon.is_gun() && !u.weapon.gun_current_mode().melee() ) - { + if( u.weapon.is_gun() && !u.weapon.gun_current_mode().melee() ) { avatar_action::fire( g->u, g->m, u.weapon ); - } - else if( u.weapon.has_flag( flag_REACH_ATTACK ) ) - { + } else if( u.weapon.has_flag( flag_REACH_ATTACK ) ) { int range = u.weapon.has_flag( flag_REACH3 ) ? 3 : 2; - if( u.has_effect( effect_relax_gas ) ) - { - if( one_in( 8 ) ) - { + if( u.has_effect( effect_relax_gas ) ) { + if( one_in( 8 ) ) { add_msg( m_good, _( "Your willpower asserts itself, and so do you!" ) ); reach_attack( range, u ); - } - else - { + } else { u.moves -= rng( 2, 8 ) * 10; add_msg( m_bad, _( "You're too pacified to strike anything…" ) ); } - } - else - { + } else { reach_attack( range, u ); } - } - else if( u.weapon.is_gun() && u.weapon.gun_current_mode().flags.count( flag_REACH_ATTACK ) ) - { + } else if( u.weapon.is_gun() && u.weapon.gun_current_mode().flags.count( flag_REACH_ATTACK ) ) { int range = u.weapon.gun_current_mode().qty; - if( u.has_effect( effect_relax_gas ) ) - { - if( one_in( 8 ) ) - { + if( u.has_effect( effect_relax_gas ) ) { + if( one_in( 8 ) ) { add_msg( m_good, _( "Your willpower asserts itself, and so do you!" ) ); reach_attack( range, u ); - } - else - { + } else { u.moves -= rng( 2, 8 ) * 10; add_msg( m_bad, _( "You're too pacified to strike anything…" ) ); } - } - else - { + } else { reach_attack( range, u ); } } @@ -1611,19 +1356,18 @@ static void open_movement_mode_menu() as_m.entries.emplace_back( 2, true, 'c', _( "Crouch" ) ); as_m.query(); - switch( as_m.ret ) - { - case 0: - u.set_movement_mode( CMM_WALK ); - break; - case 1: - u.set_movement_mode( CMM_RUN ); - break; - case 2: - u.set_movement_mode( CMM_CROUCH ); - break; - default: - break; + switch( as_m.ret ) { + case 0: + u.set_movement_mode( CMM_WALK ); + break; + case 1: + u.set_movement_mode( CMM_RUN ); + break; + case 2: + u.set_movement_mode( CMM_CROUCH ); + break; + default: + break; } } @@ -1633,50 +1377,42 @@ static void cast_spell() std::vector spells = u.magic.spells(); - if( spells.empty() ) - { + if( spells.empty() ) { add_msg( m_bad, _( "You don't know any spells to cast." ) ); return; } bool can_cast_spells = false; - for( spell_id sp : spells ) - { + for( spell_id sp : spells ) { spell temp_spell = u.magic.get_spell( sp ); - if( temp_spell.can_cast( u ) ) - { + if( temp_spell.can_cast( u ) ) { can_cast_spells = true; } } - if( !can_cast_spells ) - { + if( !can_cast_spells ) { add_msg( m_bad, _( "You can't cast any of the spells you know!" ) ); } const int spell_index = u.magic.select_spell( u ); - if( spell_index < 0 ) - { + if( spell_index < 0 ) { return; } spell &sp = *u.magic.get_spells()[spell_index]; if( u.is_armed() && !sp.has_flag( spell_flag::NO_HANDS ) && - !u.weapon.has_flag( flag_MAGIC_FOCUS ) ) - { + !u.weapon.has_flag( flag_MAGIC_FOCUS ) ) { add_msg( m_bad, _( "You need your hands free to cast this spell!" ) ); return; } - if( !u.magic.has_enough_energy( u, sp ) ) - { + if( !u.magic.has_enough_energy( u, sp ) ) { add_msg( m_bad, _( "You don't have enough %s to cast the spell." ), sp.energy_string() ); return; } - if( sp.energy_source() == hp_energy && !u.has_quality( qual_CUT ) ) - { + if( sp.energy_source() == hp_energy && !u.has_quality( qual_CUT ) ) { add_msg( m_bad, _( "You cannot cast Blood Magic without a cutting implement." ) ); return; } @@ -1689,10 +1425,8 @@ static void cast_spell() // [2] this value overrides the mana cost if set to 0 cast_spell.values.emplace_back( 1 ); cast_spell.name = sp.id().c_str(); - if( u.magic.casting_ignore ) - { - const std::vector ignored_distractions = - { + if( u.magic.casting_ignore ) { + const std::vector ignored_distractions = { distraction_type::noise, distraction_type::pain, distraction_type::attacked, @@ -1702,8 +1436,7 @@ static void cast_spell() distraction_type::motion_alarm, distraction_type::weather_change }; - for( const distraction_type ignored : ignored_distractions ) - { + for( const distraction_type ignored : ignored_distractions ) { cast_spell.ignore_distraction( ignored ); } } @@ -1721,19 +1454,18 @@ void game::open_consume_item_menu() as_m.entries.emplace_back( 2, true, 'm', _( "Medication" ) ); as_m.query(); - switch( as_m.ret ) - { - case 0: - avatar_action::eat( u, game_menus::inv::consume_food( u ) ); - break; - case 1: - avatar_action::eat( u, game_menus::inv::consume_drink( u ) ); - break; - case 2: - avatar_action::eat( u, game_menus::inv::consume_meds( u ) ); - break; - default: - break; + switch( as_m.ret ) { + case 0: + avatar_action::eat( u, game_menus::inv::consume_food( u ) ); + break; + case 1: + avatar_action::eat( u, game_menus::inv::consume_drink( u ) ); + break; + case 2: + avatar_action::eat( u, game_menus::inv::consume_meds( u ) ); + break; + default: + break; } } @@ -1744,24 +1476,18 @@ bool game::handle_action() action_id act = ACTION_NULL; user_turn current_turn; // Check if we have an auto-move destination - if( u.has_destination() ) - { + if( u.has_destination() ) { act = u.get_next_auto_move_direction(); - if( act == ACTION_NULL ) - { + if( act == ACTION_NULL ) { add_msg( m_info, _( "Auto-move canceled" ) ); u.clear_destination(); return false; } - } - else if( u.has_destination_activity() ) - { + } else if( u.has_destination_activity() ) { // starts destination activity after the player successfully reached his destination u.start_destination_activity(); return false; - } - else - { + } else { // No auto-move, ask player for input ctxt = get_player_input( action ); } @@ -1774,124 +1500,98 @@ bool game::handle_action() // of location clicked. cata::optional mouse_target; - if( uquit == QUIT_WATCH && action == "QUIT" ) - { + if( uquit == QUIT_WATCH && action == "QUIT" ) { uquit = QUIT_DIED; return false; } - if( act == ACTION_NULL ) - { + if( act == ACTION_NULL ) { act = look_up_action( action ); - if( act == ACTION_KEYBINDINGS ) - { + if( act == ACTION_KEYBINDINGS ) { // already handled by input context refresh_all(); return false; } - if( act == ACTION_MAIN_MENU ) - { - if( uquit == QUIT_WATCH ) - { + if( act == ACTION_MAIN_MENU ) { + if( uquit == QUIT_WATCH ) { return false; } // No auto-move actions have or can be set at this point. u.clear_destination(); destination_preview.clear(); act = handle_main_menu(); - if( act == ACTION_NULL ) - { + if( act == ACTION_NULL ) { return false; } } - if( act == ACTION_ACTIONMENU ) - { - if( uquit == QUIT_WATCH ) - { + if( act == ACTION_ACTIONMENU ) { + if( uquit == QUIT_WATCH ) { return false; } // No auto-move actions have or can be set at this point. u.clear_destination(); destination_preview.clear(); act = handle_action_menu(); - if( act == ACTION_NULL ) - { + if( act == ACTION_NULL ) { return false; } #if defined(__ANDROID__) - if( get_option( "ANDROID_ACTIONMENU_AUTOADD" ) && ctxt.get_category() == "DEFAULTMODE" ) - { + if( get_option( "ANDROID_ACTIONMENU_AUTOADD" ) && ctxt.get_category() == "DEFAULTMODE" ) { add_best_key_for_action_to_quick_shortcuts( act, ctxt.get_category(), false ); } #endif } - if( act == ACTION_KEYBINDINGS ) - { + if( act == ACTION_KEYBINDINGS ) { u.clear_destination(); destination_preview.clear(); act = ctxt.display_menu( true ); - if( act == ACTION_NULL ) - { + if( act == ACTION_NULL ) { return false; } } - if( can_action_change_worldstate( act ) ) - { + if( can_action_change_worldstate( act ) ) { user_action_counter += 1; } - if( act == ACTION_SELECT || act == ACTION_SEC_SELECT ) - { + if( act == ACTION_SELECT || act == ACTION_SEC_SELECT ) { // Mouse button click - if( veh_ctrl ) - { + if( veh_ctrl ) { // No mouse use in vehicle return false; } - if( u.is_dead_state() ) - { + if( u.is_dead_state() ) { // do not allow mouse actions while dead return false; } const cata::optional mouse_pos = ctxt.get_coordinates( w_terrain ); - if( !mouse_pos ) - { + if( !mouse_pos ) { return false; - } - else if( !u.sees( *mouse_pos ) ) - { + } else if( !u.sees( *mouse_pos ) ) { // Not clicked in visible terrain return false; } mouse_target = mouse_pos; - if( act == ACTION_SELECT ) - { + if( act == ACTION_SELECT ) { // Note: The following has the potential side effect of // setting auto-move destination state in addition to setting // act. - if( !try_get_left_click_action( act, *mouse_target ) ) - { + if( !try_get_left_click_action( act, *mouse_target ) ) { return false; } - } - else if( act == ACTION_SEC_SELECT ) - { - if( !try_get_right_click_action( act, *mouse_target ) ) - { + } else if( act == ACTION_SEC_SELECT ) { + if( !try_get_right_click_action( act, *mouse_target ) ) { return false; } } - } - else if( act != ACTION_TIMEOUT ) - { + } else if( act != ACTION_TIMEOUT ) { // act has not been set for an auto-move, so clearing possible // auto-move destinations. Since initializing an auto-move with // the mouse may span across multiple actions, we do not clear the @@ -1903,19 +1603,15 @@ bool game::handle_action() } } - if( act == ACTION_NULL ) - { + if( act == ACTION_NULL ) { const input_event &&evt = ctxt.get_raw_input(); - if( !evt.sequence.empty() ) - { + if( !evt.sequence.empty() ) { const int ch = evt.get_first_input(); const std::string &&name = inp_mngr.get_keyname( ch, evt.type, true ); - if( !get_option( "NO_UNKNOWN_COMMAND_MSG" ) ) - { + if( !get_option( "NO_UNKNOWN_COMMAND_MSG" ) ) { add_msg( m_info, _( "Unknown command: \"%s\" (%ld)" ), name, ch ); if( const cata::optional hint = - press_x_if_bound( ACTION_KEYBINDINGS ) ) - { + press_x_if_bound( ACTION_KEYBINDINGS ) ) { add_msg( m_info, _( "%s at any time to see and edit keybindings relevant to " "the current context." ), *hint ); @@ -1933,1030 +1629,852 @@ bool game::handle_action() int before_action_moves = u.moves; // These actions are allowed while deathcam is active. Registered in game::get_player_input - if( uquit == QUIT_WATCH || !u.is_dead_state() ) - { - switch( act ) - { - case ACTION_TOGGLE_MAP_MEMORY: - u.toggle_map_memory(); - break; - - case ACTION_CENTER: - u.view_offset.x = driving_view_offset.x; - u.view_offset.y = driving_view_offset.y; - break; + if( uquit == QUIT_WATCH || !u.is_dead_state() ) { + switch( act ) { + case ACTION_TOGGLE_MAP_MEMORY: + u.toggle_map_memory(); + break; - case ACTION_SHIFT_N: - case ACTION_SHIFT_NE: - case ACTION_SHIFT_E: - case ACTION_SHIFT_SE: - case ACTION_SHIFT_S: - case ACTION_SHIFT_SW: - case ACTION_SHIFT_W: - case ACTION_SHIFT_NW: - { - static const std::map> shift_delta = - { - { ACTION_SHIFT_N, { point_north, point_north_east } }, - { ACTION_SHIFT_NE, { point_north_east, point_east } }, - { ACTION_SHIFT_E, { point_east, point_south_east } }, - { ACTION_SHIFT_SE, { point_south_east, point_south } }, - { ACTION_SHIFT_S, { point_south, point_south_west } }, - { ACTION_SHIFT_SW, { point_south_west, point_west } }, - { ACTION_SHIFT_W, { point_west, point_north_west } }, - { ACTION_SHIFT_NW, { point_north_west, point_north } }, - }; - u.view_offset += use_tiles && tile_iso ? - shift_delta.at( act ).second * soffset : shift_delta.at( act ).first * soffset; - } - break; + case ACTION_CENTER: + u.view_offset.x = driving_view_offset.x; + u.view_offset.y = driving_view_offset.y; + break; - case ACTION_LOOK: - look_around(); + case ACTION_SHIFT_N: + case ACTION_SHIFT_NE: + case ACTION_SHIFT_E: + case ACTION_SHIFT_SE: + case ACTION_SHIFT_S: + case ACTION_SHIFT_SW: + case ACTION_SHIFT_W: + case ACTION_SHIFT_NW: { + static const std::map> shift_delta = { + { ACTION_SHIFT_N, { point_north, point_north_east } }, + { ACTION_SHIFT_NE, { point_north_east, point_east } }, + { ACTION_SHIFT_E, { point_east, point_south_east } }, + { ACTION_SHIFT_SE, { point_south_east, point_south } }, + { ACTION_SHIFT_S, { point_south, point_south_west } }, + { ACTION_SHIFT_SW, { point_south_west, point_west } }, + { ACTION_SHIFT_W, { point_west, point_north_west } }, + { ACTION_SHIFT_NW, { point_north_west, point_north } }, + }; + u.view_offset += use_tiles && tile_iso ? + shift_delta.at( act ).second * soffset : shift_delta.at( act ).first * soffset; + } break; - case ACTION_KEYBINDINGS: - // already handled by input context - break; + case ACTION_LOOK: + look_around(); + break; - default: - break; + case ACTION_KEYBINDINGS: + // already handled by input context + break; + + default: + break; } } // actions allowed only while alive - if( !u.is_dead_state() ) - { - switch( act ) - { - case ACTION_NULL: - case NUM_ACTIONS: - break; // dummy entries - case ACTION_ACTIONMENU: - case ACTION_MAIN_MENU: - case ACTION_KEYBINDINGS: - break; // handled above - - case ACTION_TIMEOUT: - if( check_safe_mode_allowed( false ) ) - { - u.pause(); - } - break; + if( !u.is_dead_state() ) { + switch( act ) { + case ACTION_NULL: + case NUM_ACTIONS: + break; // dummy entries + case ACTION_ACTIONMENU: + case ACTION_MAIN_MENU: + case ACTION_KEYBINDINGS: + break; // handled above + + case ACTION_TIMEOUT: + if( check_safe_mode_allowed( false ) ) { + u.pause(); + } + break; - case ACTION_PAUSE: - if( check_safe_mode_allowed() ) - { - u.pause(); - } - break; + case ACTION_PAUSE: + if( check_safe_mode_allowed() ) { + u.pause(); + } + break; - case ACTION_CYCLE_MOVE: - u.cycle_move_mode(); - break; + case ACTION_CYCLE_MOVE: + u.cycle_move_mode(); + break; - case ACTION_RESET_MOVE: - u.reset_move_mode(); - break; + case ACTION_RESET_MOVE: + u.reset_move_mode(); + break; - case ACTION_TOGGLE_RUN: - u.toggle_run_mode(); - break; + case ACTION_TOGGLE_RUN: + u.toggle_run_mode(); + break; - case ACTION_TOGGLE_CROUCH: - u.toggle_crouch_mode(); - break; + case ACTION_TOGGLE_CROUCH: + u.toggle_crouch_mode(); + break; - case ACTION_OPEN_MOVEMENT: - open_movement_mode_menu(); - break; + case ACTION_OPEN_MOVEMENT: + open_movement_mode_menu(); + break; - case ACTION_MOVE_FORTH: - case ACTION_MOVE_FORTH_RIGHT: - case ACTION_MOVE_RIGHT: - case ACTION_MOVE_BACK_RIGHT: - case ACTION_MOVE_BACK: - case ACTION_MOVE_BACK_LEFT: - case ACTION_MOVE_LEFT: - case ACTION_MOVE_FORTH_LEFT: - if( !u.get_value( "remote_controlling" ).empty() && - ( u.has_active_item( "radiocontrol" ) || u.has_active_bionic( bio_remote ) ) ) - { - rcdrive( get_delta_from_movement_action( act, iso_rotate::yes ) ); - } - else if( veh_ctrl ) - { - // vehicle control uses x for steering and y for ac/deceleration, - // so no rotation needed - pldrive( get_delta_from_movement_action( act, iso_rotate::no ) ); - } - else - { - point dest_delta = get_delta_from_movement_action( act, iso_rotate::yes ); - if( auto_travel_mode && !u.is_auto_moving() ) - { - for( int i = 0; i < SEEX; i++ ) - { - tripoint auto_travel_destination( u.posx() + dest_delta.x * ( SEEX - i ), - u.posy() + dest_delta.y * ( SEEX - i ), - u.posz() ); - destination_preview = m.route( u.pos(), - auto_travel_destination, - u.get_pathfinding_settings(), - u.get_path_avoid() ); - if( !destination_preview.empty() ) - { - destination_preview.erase( destination_preview.begin() + 1, destination_preview.end() ); - u.set_destination( destination_preview ); - break; + case ACTION_MOVE_FORTH: + case ACTION_MOVE_FORTH_RIGHT: + case ACTION_MOVE_RIGHT: + case ACTION_MOVE_BACK_RIGHT: + case ACTION_MOVE_BACK: + case ACTION_MOVE_BACK_LEFT: + case ACTION_MOVE_LEFT: + case ACTION_MOVE_FORTH_LEFT: + if( !u.get_value( "remote_controlling" ).empty() && + ( u.has_active_item( "radiocontrol" ) || u.has_active_bionic( bio_remote ) ) ) { + rcdrive( get_delta_from_movement_action( act, iso_rotate::yes ) ); + } else if( veh_ctrl ) { + // vehicle control uses x for steering and y for ac/deceleration, + // so no rotation needed + pldrive( get_delta_from_movement_action( act, iso_rotate::no ) ); + } else { + point dest_delta = get_delta_from_movement_action( act, iso_rotate::yes ); + if( auto_travel_mode && !u.is_auto_moving() ) { + for( int i = 0; i < SEEX; i++ ) { + tripoint auto_travel_destination( u.posx() + dest_delta.x * ( SEEX - i ), + u.posy() + dest_delta.y * ( SEEX - i ), + u.posz() ); + destination_preview = m.route( u.pos(), + auto_travel_destination, + u.get_pathfinding_settings(), + u.get_path_avoid() ); + if( !destination_preview.empty() ) { + destination_preview.erase( destination_preview.begin() + 1, destination_preview.end() ); + u.set_destination( destination_preview ); + break; + } } + act = u.get_next_auto_move_direction(); + const point dest_next = get_delta_from_movement_action( act, iso_rotate::yes ); + if( dest_next == point_zero ) { + u.clear_destination(); + } + dest_delta = dest_next; } - act = u.get_next_auto_move_direction(); - const point dest_next = get_delta_from_movement_action( act, iso_rotate::yes ); - if( dest_next == point_zero ) - { + if( !avatar_action::move( u, m, dest_delta ) ) { + // auto-move should be canceled due to a failed move or obstacle u.clear_destination(); } - dest_delta = dest_next; } - if( !avatar_action::move( u, m, dest_delta ) ) - { - // auto-move should be canceled due to a failed move or obstacle - u.clear_destination(); + break; + case ACTION_MOVE_DOWN: + if( u.is_mounted() ) { + auto mon = u.mounted_creature.get(); + if( !mon->has_flag( MF_RIDEABLE_MECH ) ) { + add_msg( m_info, _( "You can't go down stairs while you're riding." ) ); + break; + } } - } - break; - case ACTION_MOVE_DOWN: - if( u.is_mounted() ) - { - auto mon = u.mounted_creature.get(); - if( !mon->has_flag( MF_RIDEABLE_MECH ) ) - { - add_msg( m_info, _( "You can't go down stairs while you're riding." ) ); - break; + if( !u.in_vehicle ) { + vertical_move( -1, false ); } - } - if( !u.in_vehicle ) - { - vertical_move( -1, false ); - } - break; + break; - case ACTION_MOVE_UP: - if( u.is_mounted() ) - { - auto mon = u.mounted_creature.get(); - if( !mon->has_flag( MF_RIDEABLE_MECH ) ) - { - add_msg( m_info, _( "You can't go down stairs while you're riding." ) ); - break; + case ACTION_MOVE_UP: + if( u.is_mounted() ) { + auto mon = u.mounted_creature.get(); + if( !mon->has_flag( MF_RIDEABLE_MECH ) ) { + add_msg( m_info, _( "You can't go down stairs while you're riding." ) ); + break; + } } - } - if( !u.in_vehicle ) - { - vertical_move( 1, false ); - } - break; + if( !u.in_vehicle ) { + vertical_move( 1, false ); + } + break; - case ACTION_OPEN: - if( u.has_active_mutation( trait_SHELL2 ) ) - { - add_msg( m_info, _( "You can't open things while you're in your shell." ) ); - } - else if( u.is_mounted() ) - { - add_msg( m_info, _( "You can't open things while you're riding." ) ); - } - else - { - open(); - } - break; + case ACTION_OPEN: + if( u.has_active_mutation( trait_SHELL2 ) ) { + add_msg( m_info, _( "You can't open things while you're in your shell." ) ); + } else if( u.is_mounted() ) { + add_msg( m_info, _( "You can't open things while you're riding." ) ); + } else { + open(); + } + break; - case ACTION_CLOSE: - if( u.has_active_mutation( trait_SHELL2 ) ) - { - add_msg( m_info, _( "You can't close things while you're in your shell." ) ); - } - else if( u.is_mounted() ) - { - auto mon = u.mounted_creature.get(); - if( !mon->has_flag( MF_RIDEABLE_MECH ) ) - { - add_msg( m_info, _( "You can't close things while you're riding." ) ); + case ACTION_CLOSE: + if( u.has_active_mutation( trait_SHELL2 ) ) { + add_msg( m_info, _( "You can't close things while you're in your shell." ) ); + } else if( u.is_mounted() ) { + auto mon = u.mounted_creature.get(); + if( !mon->has_flag( MF_RIDEABLE_MECH ) ) { + add_msg( m_info, _( "You can't close things while you're riding." ) ); + } + } else if( mouse_target ) { + doors::close_door( m, u, *mouse_target ); + } else { + close(); } - } - else if( mouse_target ) - { - doors::close_door( m, u, *mouse_target ); - } - else - { - close(); - } - break; + break; - case ACTION_SMASH: - if( veh_ctrl ) - { - handbrake(); - } - else if( u.has_active_mutation( trait_SHELL2 ) ) - { - add_msg( m_info, _( "You can't smash things while you're in your shell." ) ); - } - else - { - smash(); - } - break; + case ACTION_SMASH: + if( veh_ctrl ) { + handbrake(); + } else if( u.has_active_mutation( trait_SHELL2 ) ) { + add_msg( m_info, _( "You can't smash things while you're in your shell." ) ); + } else { + smash(); + } + break; - case ACTION_EXAMINE: - if( u.has_active_mutation( trait_SHELL2 ) ) - { - add_msg( m_info, _( "You can't examine your surroundings while you're in your shell." ) ); - } - else if( mouse_target ) - { - examine( *mouse_target ); - } - else - { - examine(); - } - break; + case ACTION_EXAMINE: + if( u.has_active_mutation( trait_SHELL2 ) ) { + add_msg( m_info, _( "You can't examine your surroundings while you're in your shell." ) ); + } else if( mouse_target ) { + examine( *mouse_target ); + } else { + examine(); + } + break; - case ACTION_ADVANCEDINV: - if( u.has_active_mutation( trait_SHELL2 ) ) - { - add_msg( m_info, _( "You can't move mass quantities while you're in your shell." ) ); - } - else if( u.is_mounted() ) - { - add_msg( m_info, _( "You can't move mass quantities while you're riding." ) ); - } - else - { - create_advanced_inv(); - } - break; + case ACTION_ADVANCEDINV: + if( u.has_active_mutation( trait_SHELL2 ) ) { + add_msg( m_info, _( "You can't move mass quantities while you're in your shell." ) ); + } else if( u.is_mounted() ) { + add_msg( m_info, _( "You can't move mass quantities while you're riding." ) ); + } else { + create_advanced_inv(); + } + break; - case ACTION_PICKUP: - if( u.has_active_mutation( trait_SHELL2 ) ) - { - add_msg( m_info, _( "You can't pick anything up while you're in your shell." ) ); - } - else if( u.is_mounted() ) - { - add_msg( m_info, _( "You can't pick anything up while you're riding." ) ); - } - else if( mouse_target ) - { - pickup( *mouse_target ); - } - else - { - pickup(); - } - break; + case ACTION_PICKUP: + if( u.has_active_mutation( trait_SHELL2 ) ) { + add_msg( m_info, _( "You can't pick anything up while you're in your shell." ) ); + } else if( u.is_mounted() ) { + add_msg( m_info, _( "You can't pick anything up while you're riding." ) ); + } else if( mouse_target ) { + pickup( *mouse_target ); + } else { + pickup(); + } + break; - case ACTION_PICKUP_FEET: - if( u.has_active_mutation( trait_SHELL2 ) ) - { - add_msg( m_info, _( "You can't pick anything up while you're in your shell." ) ); - } - else - { - pickup_feet(); - } - break; + case ACTION_PICKUP_FEET: + if( u.has_active_mutation( trait_SHELL2 ) ) { + add_msg( m_info, _( "You can't pick anything up while you're in your shell." ) ); + } else { + pickup_feet(); + } + break; - case ACTION_GRAB: - if( u.has_active_mutation( trait_SHELL2 ) ) - { - add_msg( m_info, _( "You can't grab things while you're in your shell." ) ); - } - else if( u.is_mounted() ) - { - add_msg( m_info, _( "You can't grab things while you're riding." ) ); - } - else - { - grab(); - } - break; + case ACTION_GRAB: + if( u.has_active_mutation( trait_SHELL2 ) ) { + add_msg( m_info, _( "You can't grab things while you're in your shell." ) ); + } else if( u.is_mounted() ) { + add_msg( m_info, _( "You can't grab things while you're riding." ) ); + } else { + grab(); + } + break; - case ACTION_HAUL: - if( u.has_active_mutation( trait_SHELL2 ) ) - { - add_msg( m_info, _( "You can't haul things while you're in your shell." ) ); - } - else if( u.is_mounted() ) - { - add_msg( m_info, _( "You can't haul things while you're riding." ) ); - } - else - { - haul(); - } - break; + case ACTION_HAUL: + if( u.has_active_mutation( trait_SHELL2 ) ) { + add_msg( m_info, _( "You can't haul things while you're in your shell." ) ); + } else if( u.is_mounted() ) { + add_msg( m_info, _( "You can't haul things while you're riding." ) ); + } else { + haul(); + } + break; - case ACTION_BUTCHER: - if( u.has_active_mutation( trait_SHELL2 ) ) - { - add_msg( m_info, _( "You can't butcher while you're in your shell." ) ); - } - else if( u.is_mounted() ) - { - add_msg( m_info, _( "You can't butcher while you're riding." ) ); - } - else - { - butcher(); - } - break; + case ACTION_BUTCHER: + if( u.has_active_mutation( trait_SHELL2 ) ) { + add_msg( m_info, _( "You can't butcher while you're in your shell." ) ); + } else if( u.is_mounted() ) { + add_msg( m_info, _( "You can't butcher while you're riding." ) ); + } else { + butcher(); + } + break; - case ACTION_CHAT: - chat(); - break; + case ACTION_CHAT: + chat(); + break; - case ACTION_PEEK: - if( u.has_active_mutation( trait_SHELL2 ) ) - { - add_msg( m_info, _( "You can't peek around corners while you're in your shell." ) ); - } - else if( u.is_mounted() ) - { - add_msg( m_info, _( "You can't peek around corners while you're riding." ) ); - } - else - { - peek(); - } - break; + case ACTION_PEEK: + if( u.has_active_mutation( trait_SHELL2 ) ) { + add_msg( m_info, _( "You can't peek around corners while you're in your shell." ) ); + } else if( u.is_mounted() ) { + add_msg( m_info, _( "You can't peek around corners while you're riding." ) ); + } else { + peek(); + } + break; - case ACTION_LIST_ITEMS: - list_items_monsters(); - break; + case ACTION_LIST_ITEMS: + list_items_monsters(); + break; - case ACTION_ZONES: - zones_manager(); - break; + case ACTION_ZONES: + zones_manager(); + break; - case ACTION_LOOT: - loot(); - break; + case ACTION_LOOT: + loot(); + break; - case ACTION_INVENTORY: - game_menus::inv::common( u ); - break; + case ACTION_INVENTORY: + game_menus::inv::common( u ); + break; - case ACTION_COMPARE: - game_menus::inv::compare( u, cata::nullopt ); - break; + case ACTION_COMPARE: + game_menus::inv::compare( u, cata::nullopt ); + break; - case ACTION_ORGANIZE: - game_menus::inv::swap_letters( u ); - break; + case ACTION_ORGANIZE: + game_menus::inv::swap_letters( u ); + break; - case ACTION_USE: - // Shell-users are presumed to be able to mess with their inventories, etc - // while in the shell. Eating, gear-changing, and item use are OK. - avatar_action::use_item( u ); - break; + case ACTION_USE: + // Shell-users are presumed to be able to mess with their inventories, etc + // while in the shell. Eating, gear-changing, and item use are OK. + avatar_action::use_item( u ); + break; - case ACTION_USE_WIELDED: - u.use_wielded(); - break; + case ACTION_USE_WIELDED: + u.use_wielded(); + break; - case ACTION_WEAR: - wear(); - break; + case ACTION_WEAR: + wear(); + break; - case ACTION_TAKE_OFF: - takeoff(); - break; + case ACTION_TAKE_OFF: + takeoff(); + break; - case ACTION_EAT: - if( !avatar_action::eat_here( u ) ) - { - avatar_action::eat( u ); - } - break; + case ACTION_EAT: + if( !avatar_action::eat_here( u ) ) { + avatar_action::eat( u ); + } + break; - case ACTION_OPEN_CONSUME: - if( !avatar_action::eat_here( u ) ) - { - open_consume_item_menu(); - } - break; + case ACTION_OPEN_CONSUME: + if( !avatar_action::eat_here( u ) ) { + open_consume_item_menu(); + } + break; - case ACTION_READ: - // Shell-users are presumed to have the book just at an opening and read it that way - read(); - break; + case ACTION_READ: + // Shell-users are presumed to have the book just at an opening and read it that way + read(); + break; - case ACTION_WIELD: - wield(); - break; + case ACTION_WIELD: + wield(); + break; - case ACTION_PICK_STYLE: - u.martial_arts_data.pick_style( u ); - break; + case ACTION_PICK_STYLE: + u.martial_arts_data.pick_style( u ); + break; - case ACTION_RELOAD_ITEM: - reload_item(); - break; + case ACTION_RELOAD_ITEM: + reload_item(); + break; - case ACTION_RELOAD_WEAPON: - reload_weapon(); - break; + case ACTION_RELOAD_WEAPON: + reload_weapon(); + break; - case ACTION_RELOAD_WIELDED: - reload_wielded(); - break; + case ACTION_RELOAD_WIELDED: + reload_wielded(); + break; - case ACTION_UNLOAD: - avatar_action::unload( u ); - break; + case ACTION_UNLOAD: + avatar_action::unload( u ); + break; - case ACTION_MEND: - avatar_action::mend( g->u, item_location() ); - break; + case ACTION_MEND: + avatar_action::mend( g->u, item_location() ); + break; - case ACTION_THROW: - { - item_location loc; - avatar_action::plthrow( g->u, loc ); - break; - } + case ACTION_THROW: { + item_location loc; + avatar_action::plthrow( g->u, loc ); + break; + } - case ACTION_FIRE: - fire(); - break; + case ACTION_FIRE: + fire(); + break; - case ACTION_CAST_SPELL: - cast_spell(); - break; + case ACTION_CAST_SPELL: + cast_spell(); + break; - case ACTION_FIRE_BURST: - { - gun_mode_id original_mode = u.weapon.gun_get_mode_id(); - if( u.weapon.gun_set_mode( gun_mode_id( "AUTO" ) ) ) - { - avatar_action::fire( u, m, u.weapon ); - u.weapon.gun_set_mode( original_mode ); + case ACTION_FIRE_BURST: { + gun_mode_id original_mode = u.weapon.gun_get_mode_id(); + if( u.weapon.gun_set_mode( gun_mode_id( "AUTO" ) ) ) { + avatar_action::fire( u, m, u.weapon ); + u.weapon.gun_set_mode( original_mode ); + } + break; } - break; - } - case ACTION_SELECT_FIRE_MODE: - if( u.is_armed() ) - { - if( u.weapon.is_gun() && !u.weapon.is_gunmod() && u.weapon.gun_all_modes().size() > 1 ) - { - u.weapon.gun_cycle_mode(); - } - else if( u.weapon.has_flag( flag_RELOAD_ONE ) || u.weapon.has_flag( flag_RELOAD_AND_SHOOT ) ) - { - item::reload_option opt = u.select_ammo( u.weapon, false ); - if( !opt ) - { - break; - } - else if( u.ammo_location && opt.ammo == u.ammo_location ) - { - u.ammo_location = item_location(); - } - else - { - u.ammo_location = opt.ammo; + case ACTION_SELECT_FIRE_MODE: + if( u.is_armed() ) { + if( u.weapon.is_gun() && !u.weapon.is_gunmod() && u.weapon.gun_all_modes().size() > 1 ) { + u.weapon.gun_cycle_mode(); + } else if( u.weapon.has_flag( flag_RELOAD_ONE ) || u.weapon.has_flag( flag_RELOAD_AND_SHOOT ) ) { + item::reload_option opt = u.select_ammo( u.weapon, false ); + if( !opt ) { + break; + } else if( u.ammo_location && opt.ammo == u.ammo_location ) { + u.ammo_location = item_location(); + } else { + u.ammo_location = opt.ammo; + } } } - } - break; - - case ACTION_DROP: - // You CAN drop things to your own tile while in the shell. - drop(); - break; - - case ACTION_DIR_DROP: - if( u.has_active_mutation( trait_SHELL2 ) ) - { - add_msg( m_info, _( "You can't drop things to another tile while you're in your shell." ) ); - } - else - { - drop_in_direction(); - } - break; - case ACTION_BIONICS: - u.power_bionics(); - refresh_all(); - break; - case ACTION_MUTATIONS: - u.power_mutations(); - refresh_all(); - break; + break; - case ACTION_SORT_ARMOR: - u.sort_armor(); - refresh_all(); - break; + case ACTION_DROP: + // You CAN drop things to your own tile while in the shell. + drop(); + break; - case ACTION_WAIT: - wait(); - break; + case ACTION_DIR_DROP: + if( u.has_active_mutation( trait_SHELL2 ) ) { + add_msg( m_info, _( "You can't drop things to another tile while you're in your shell." ) ); + } else { + drop_in_direction(); + } + break; + case ACTION_BIONICS: + u.power_bionics(); + refresh_all(); + break; + case ACTION_MUTATIONS: + u.power_mutations(); + refresh_all(); + break; - case ACTION_CRAFT: - if( u.has_active_mutation( trait_SHELL2 ) ) - { - add_msg( m_info, _( "You can't craft while you're in your shell." ) ); - } - else if( u.is_mounted() ) - { - add_msg( m_info, _( "You can't craft while you're riding." ) ); - } - else - { - u.craft(); - } - break; + case ACTION_SORT_ARMOR: + u.sort_armor(); + refresh_all(); + break; - case ACTION_RECRAFT: - if( u.has_active_mutation( trait_SHELL2 ) ) - { - add_msg( m_info, _( "You can't craft while you're in your shell." ) ); - } - else if( u.is_mounted() ) - { - add_msg( m_info, _( "You can't craft while you're riding." ) ); - } - else - { - u.recraft(); - } - break; + case ACTION_WAIT: + wait(); + break; - case ACTION_LONGCRAFT: - if( u.has_active_mutation( trait_SHELL2 ) ) - { - add_msg( m_info, _( "You can't craft while you're in your shell." ) ); - } - else if( u.is_mounted() ) - { - add_msg( m_info, _( "You can't craft while you're riding." ) ); - } - else - { - u.long_craft(); - } - break; + case ACTION_CRAFT: + if( u.has_active_mutation( trait_SHELL2 ) ) { + add_msg( m_info, _( "You can't craft while you're in your shell." ) ); + } else if( u.is_mounted() ) { + add_msg( m_info, _( "You can't craft while you're riding." ) ); + } else { + u.craft(); + } + break; - case ACTION_DISASSEMBLE: - if( u.controlling_vehicle ) - { - add_msg( m_info, _( "You can't disassemble items while driving." ) ); - } - else if( u.is_mounted() ) - { - add_msg( m_info, _( "You can't disassemble items while you're riding." ) ); - } - else - { - u.disassemble(); - refresh_all(); - } - break; + case ACTION_RECRAFT: + if( u.has_active_mutation( trait_SHELL2 ) ) { + add_msg( m_info, _( "You can't craft while you're in your shell." ) ); + } else if( u.is_mounted() ) { + add_msg( m_info, _( "You can't craft while you're riding." ) ); + } else { + u.recraft(); + } + break; - case ACTION_CONSTRUCT: - if( u.in_vehicle ) - { - add_msg( m_info, _( "You can't construct while in a vehicle." ) ); - } - else if( u.has_active_mutation( trait_SHELL2 ) ) - { - add_msg( m_info, _( "You can't construct while you're in your shell." ) ); - } - else if( u.is_mounted() ) - { - add_msg( m_info, _( "You can't construct while you're riding." ) ); - } - else - { - construction_menu( false ); - } - break; + case ACTION_LONGCRAFT: + if( u.has_active_mutation( trait_SHELL2 ) ) { + add_msg( m_info, _( "You can't craft while you're in your shell." ) ); + } else if( u.is_mounted() ) { + add_msg( m_info, _( "You can't craft while you're riding." ) ); + } else { + u.long_craft(); + } + break; - case ACTION_SLEEP: - if( veh_ctrl ) - { - add_msg( m_info, _( "Vehicle control has moved, %s" ), - press_x( ACTION_CONTROL_VEHICLE, _( "new binding is " ), - _( "new default binding is '^'." ) ) ); - } - else - { - sleep(); - } - break; + case ACTION_DISASSEMBLE: + if( u.controlling_vehicle ) { + add_msg( m_info, _( "You can't disassemble items while driving." ) ); + } else if( u.is_mounted() ) { + add_msg( m_info, _( "You can't disassemble items while you're riding." ) ); + } else { + u.disassemble(); + refresh_all(); + } + break; - case ACTION_CONTROL_VEHICLE: - if( u.has_active_mutation( trait_SHELL2 ) ) - { - add_msg( m_info, _( "You can't operate a vehicle while you're in your shell." ) ); - } - else if( u.is_mounted() ) - { - u.dismount(); - } - else if( u.has_trait( trait_WAYFARER ) ) - { - add_msg( m_info, _( "You refuse to take control of this vehicle." ) ); - } - else - { - control_vehicle(); - } - break; + case ACTION_CONSTRUCT: + if( u.in_vehicle ) { + add_msg( m_info, _( "You can't construct while in a vehicle." ) ); + } else if( u.has_active_mutation( trait_SHELL2 ) ) { + add_msg( m_info, _( "You can't construct while you're in your shell." ) ); + } else if( u.is_mounted() ) { + add_msg( m_info, _( "You can't construct while you're riding." ) ); + } else { + construction_menu( false ); + } + break; - case ACTION_TOGGLE_AUTO_TRAVEL_MODE: - auto_travel_mode = !auto_travel_mode; - add_msg( m_info, auto_travel_mode ? _( "Auto travel mode ON!" ) : _( "Auto travel mode OFF!" ) ); - break; + case ACTION_SLEEP: + if( veh_ctrl ) { + add_msg( m_info, _( "Vehicle control has moved, %s" ), + press_x( ACTION_CONTROL_VEHICLE, _( "new binding is " ), + _( "new default binding is '^'." ) ) ); + } else { + sleep(); + } + break; - case ACTION_TOGGLE_SAFEMODE: - if( safe_mode == SAFE_MODE_OFF ) - { - set_safe_mode( SAFE_MODE_ON ); - mostseen = 0; - add_msg( m_info, _( "Safe mode ON!" ) ); - } - else - { - turnssincelastmon = 0; - set_safe_mode( SAFE_MODE_OFF ); - add_msg( m_info, get_option( "AUTOSAFEMODE" ) - ? _( "Safe mode OFF! (Auto safe mode still enabled!)" ) : _( "Safe mode OFF!" ) ); - } - if( u.has_effect( effect_laserlocked ) ) - { - u.remove_effect( effect_laserlocked ); - safe_mode_warning_logged = false; - } - break; + case ACTION_CONTROL_VEHICLE: + if( u.has_active_mutation( trait_SHELL2 ) ) { + add_msg( m_info, _( "You can't operate a vehicle while you're in your shell." ) ); + } else if( u.is_mounted() ) { + u.dismount(); + } else if( u.has_trait( trait_WAYFARER ) ) { + add_msg( m_info, _( "You refuse to take control of this vehicle." ) ); + } else { + control_vehicle(); + } + break; - case ACTION_TOGGLE_AUTOSAFE: - { - auto &autosafemode_option = get_options().get_option( "AUTOSAFEMODE" ); - add_msg( m_info, autosafemode_option.value_as() - ? _( "Auto safe mode OFF!" ) : _( "Auto safe mode ON!" ) ); - autosafemode_option.setNext(); - break; - } + case ACTION_TOGGLE_AUTO_TRAVEL_MODE: + auto_travel_mode = !auto_travel_mode; + add_msg( m_info, auto_travel_mode ? _( "Auto travel mode ON!" ) : _( "Auto travel mode OFF!" ) ); + break; - case ACTION_IGNORE_ENEMY: - if( safe_mode == SAFE_MODE_STOP ) - { - add_msg( m_info, _( "Ignoring enemy!" ) ); - for( auto &elem : u.get_mon_visible().new_seen_mon ) - { - monster &critter = *elem; - critter.ignoring = rl_dist( u.pos(), critter.pos() ); - } - set_safe_mode( SAFE_MODE_ON ); - } - else if( u.has_effect( effect_laserlocked ) ) - { - if( u.has_trait( trait_PROF_CHURL ) ) - { - add_msg( m_warning, _( "You make the sign of the cross." ) ); + case ACTION_TOGGLE_SAFEMODE: + if( safe_mode == SAFE_MODE_OFF ) { + set_safe_mode( SAFE_MODE_ON ); + mostseen = 0; + add_msg( m_info, _( "Safe mode ON!" ) ); + } else { + turnssincelastmon = 0; + set_safe_mode( SAFE_MODE_OFF ); + add_msg( m_info, get_option( "AUTOSAFEMODE" ) + ? _( "Safe mode OFF! (Auto safe mode still enabled!)" ) : _( "Safe mode OFF!" ) ); } - else - { - add_msg( m_info, _( "Ignoring laser targeting!" ) ); + if( u.has_effect( effect_laserlocked ) ) { + u.remove_effect( effect_laserlocked ); + safe_mode_warning_logged = false; } - u.remove_effect( effect_laserlocked ); - safe_mode_warning_logged = false; - } - break; + break; - case ACTION_WHITELIST_ENEMY: - if( safe_mode == SAFE_MODE_STOP && !get_safemode().empty() ) - { - get_safemode().add_rule( get_safemode().lastmon_whitelist, Creature::A_ANY, 0, RULE_WHITELISTED ); - add_msg( m_info, _( "Creature whitelisted: %s" ), get_safemode().lastmon_whitelist ); - set_safe_mode( SAFE_MODE_ON ); - mostseen = 0; - } - else - { - get_safemode().show(); + case ACTION_TOGGLE_AUTOSAFE: { + auto &autosafemode_option = get_options().get_option( "AUTOSAFEMODE" ); + add_msg( m_info, autosafemode_option.value_as() + ? _( "Auto safe mode OFF!" ) : _( "Auto safe mode ON!" ) ); + autosafemode_option.setNext(); + break; } - break; - case ACTION_SUICIDE: - if( query_yn( _( "Commit suicide?" ) ) ) - { - if( query_yn( _( "REALLY commit suicide?" ) ) ) - { - u.moves = 0; - u.place_corpse(); - uquit = QUIT_SUICIDE; + case ACTION_IGNORE_ENEMY: + if( safe_mode == SAFE_MODE_STOP ) { + add_msg( m_info, _( "Ignoring enemy!" ) ); + for( auto &elem : u.get_mon_visible().new_seen_mon ) { + monster &critter = *elem; + critter.ignoring = rl_dist( u.pos(), critter.pos() ); + } + set_safe_mode( SAFE_MODE_ON ); + } else if( u.has_effect( effect_laserlocked ) ) { + if( u.has_trait( trait_PROF_CHURL ) ) { + add_msg( m_warning, _( "You make the sign of the cross." ) ); + } else { + add_msg( m_info, _( "Ignoring laser targeting!" ) ); + } + u.remove_effect( effect_laserlocked ); + safe_mode_warning_logged = false; } - } - refresh_all(); - break; + break; - case ACTION_SAVE: - if( query_yn( _( "Save and quit?" ) ) ) - { - if( save() ) - { - u.moves = 0; - uquit = QUIT_SAVED; + case ACTION_WHITELIST_ENEMY: + if( safe_mode == SAFE_MODE_STOP && !get_safemode().empty() ) { + get_safemode().add_rule( get_safemode().lastmon_whitelist, Creature::A_ANY, 0, RULE_WHITELISTED ); + add_msg( m_info, _( "Creature whitelisted: %s" ), get_safemode().lastmon_whitelist ); + set_safe_mode( SAFE_MODE_ON ); + mostseen = 0; + } else { + get_safemode().show(); } - } - refresh_all(); - break; + break; - case ACTION_QUICKSAVE: - quicksave(); - return false; + case ACTION_SUICIDE: + if( query_yn( _( "Commit suicide?" ) ) ) { + if( query_yn( _( "REALLY commit suicide?" ) ) ) { + u.moves = 0; + u.place_corpse(); + uquit = QUIT_SUICIDE; + } + } + refresh_all(); + break; - case ACTION_QUICKLOAD: - quickload(); - return false; + case ACTION_SAVE: + if( query_yn( _( "Save and quit?" ) ) ) { + if( save() ) { + u.moves = 0; + uquit = QUIT_SAVED; + } + } + refresh_all(); + break; - case ACTION_PL_INFO: - u.disp_info(); - break; + case ACTION_QUICKSAVE: + quicksave(); + return false; - case ACTION_MAP: - werase( w_terrain ); - ui::omap::display(); - break; + case ACTION_QUICKLOAD: + quickload(); + return false; + + case ACTION_PL_INFO: + u.disp_info(); + break; - case ACTION_SKY: - if( m.is_outside( u.pos() ) ) - { + case ACTION_MAP: werase( w_terrain ); - ui::omap::display_visible_weather(); - } - else - { - add_msg( m_info, _( "You can't see the sky from here." ) ); - } - break; + ui::omap::display(); + break; - case ACTION_MISSIONS: - list_missions(); - break; + case ACTION_SKY: + if( m.is_outside( u.pos() ) ) { + werase( w_terrain ); + ui::omap::display_visible_weather(); + } else { + add_msg( m_info, _( "You can't see the sky from here." ) ); + } + break; - case ACTION_SCORES: - show_scores_ui( stats(), get_kill_tracker() ); - break; + case ACTION_MISSIONS: + list_missions(); + break; - case ACTION_FACTIONS: - faction_manager_ptr->display(); - break; + case ACTION_SCORES: + show_scores_ui( stats(), get_kill_tracker() ); + break; - case ACTION_MORALE: - u.disp_morale(); - refresh_all(); - break; + case ACTION_FACTIONS: + faction_manager_ptr->display(); + break; - case ACTION_MESSAGES: - Messages::display_messages(); - refresh_all(); - break; + case ACTION_MORALE: + u.disp_morale(); + refresh_all(); + break; - case ACTION_HELP: - get_help().display_help(); - refresh_all(); - break; + case ACTION_MESSAGES: + Messages::display_messages(); + refresh_all(); + break; - case ACTION_OPTIONS: - get_options().show( true ); - g->init_ui( true ); - break; + case ACTION_HELP: + get_help().display_help(); + refresh_all(); + break; - case ACTION_AUTOPICKUP: - get_auto_pickup().show(); - refresh_all(); - break; + case ACTION_OPTIONS: + get_options().show( true ); + g->init_ui( true ); + break; - case ACTION_AUTONOTES: - get_auto_notes_settings().show_gui(); - refresh_all(); - break; + case ACTION_AUTOPICKUP: + get_auto_pickup().show(); + refresh_all(); + break; - case ACTION_SAFEMODE: - get_safemode().show(); - refresh_all(); - break; + case ACTION_AUTONOTES: + get_auto_notes_settings().show_gui(); + refresh_all(); + break; - case ACTION_COLOR: - all_colors.show_gui(); - refresh_all(); - break; + case ACTION_SAFEMODE: + get_safemode().show(); + refresh_all(); + break; - case ACTION_WORLD_MODS: - world_generator->show_active_world_mods( world_generator->active_world->active_mod_order ); - refresh_all(); - break; + case ACTION_COLOR: + all_colors.show_gui(); + refresh_all(); + break; - case ACTION_DEBUG: - if( MAP_SHARING::isCompetitive() && !MAP_SHARING::isDebugger() ) - { - break; //don't do anything when sharing and not debugger - } - debug_menu::debug(); - break; + case ACTION_WORLD_MODS: + world_generator->show_active_world_mods( world_generator->active_world->active_mod_order ); + refresh_all(); + break; - case ACTION_TOGGLE_FULLSCREEN: - toggle_fullscreen(); - break; + case ACTION_DEBUG: + if( MAP_SHARING::isCompetitive() && !MAP_SHARING::isDebugger() ) { + break; //don't do anything when sharing and not debugger + } + debug_menu::debug(); + break; - case ACTION_TOGGLE_PIXEL_MINIMAP: - toggle_pixel_minimap(); - break; + case ACTION_TOGGLE_FULLSCREEN: + toggle_fullscreen(); + break; - case ACTION_TOGGLE_PANEL_ADM: - toggle_panel_adm(); - break; + case ACTION_TOGGLE_PIXEL_MINIMAP: + toggle_pixel_minimap(); + break; - case ACTION_RELOAD_TILESET: - reload_tileset(); - break; + case ACTION_TOGGLE_PANEL_ADM: + toggle_panel_adm(); + break; - case ACTION_TOGGLE_AUTO_FEATURES: - get_options().get_option( "AUTO_FEATURES" ).setNext(); - get_options().save(); - //~ Auto Features are now ON/OFF - add_msg( _( "%s are now %s." ), - get_options().get_option( "AUTO_FEATURES" ).getMenuText(), - get_option( "AUTO_FEATURES" ) ? _( "ON" ) : _( "OFF" ) ); - break; + case ACTION_RELOAD_TILESET: + reload_tileset(); + break; - case ACTION_TOGGLE_AUTO_PULP_BUTCHER: - get_options().get_option( "AUTO_PULP_BUTCHER" ).setNext(); - get_options().save(); - //~ Auto Pulp/Pulp Adjacent/Butcher is now set to x - add_msg( _( "%s is now set to %s." ), - get_options().get_option( "AUTO_PULP_BUTCHER" ).getMenuText(), - get_options().get_option( "AUTO_PULP_BUTCHER" ).getValueName() ); - break; + case ACTION_TOGGLE_AUTO_FEATURES: + get_options().get_option( "AUTO_FEATURES" ).setNext(); + get_options().save(); + //~ Auto Features are now ON/OFF + add_msg( _( "%s are now %s." ), + get_options().get_option( "AUTO_FEATURES" ).getMenuText(), + get_option( "AUTO_FEATURES" ) ? _( "ON" ) : _( "OFF" ) ); + break; - case ACTION_TOGGLE_AUTO_MINING: - get_options().get_option( "AUTO_MINING" ).setNext(); - get_options().save(); - //~ Auto Mining is now ON/OFF - add_msg( _( "%s is now %s." ), - get_options().get_option( "AUTO_MINING" ).getMenuText(), - get_option( "AUTO_MINING" ) ? _( "ON" ) : _( "OFF" ) ); - break; + case ACTION_TOGGLE_AUTO_PULP_BUTCHER: + get_options().get_option( "AUTO_PULP_BUTCHER" ).setNext(); + get_options().save(); + //~ Auto Pulp/Pulp Adjacent/Butcher is now set to x + add_msg( _( "%s is now set to %s." ), + get_options().get_option( "AUTO_PULP_BUTCHER" ).getMenuText(), + get_options().get_option( "AUTO_PULP_BUTCHER" ).getValueName() ); + break; - case ACTION_TOGGLE_THIEF_MODE: - if( g->u.get_value( "THIEF_MODE" ) == "THIEF_ASK" ) - { - u.set_value( "THIEF_MODE", "THIEF_HONEST" ); - u.set_value( "THIEF_MODE_KEEP", "YES" ); - //~ Thief mode cycled between THIEF_ASK/THIEF_HONEST/THIEF_STEAL - add_msg( _( "You will not pick up other peoples belongings." ) ); - } - else if( g->u.get_value( "THIEF_MODE" ) == "THIEF_HONEST" ) - { - u.set_value( "THIEF_MODE", "THIEF_STEAL" ); - u.set_value( "THIEF_MODE_KEEP", "YES" ); - //~ Thief mode cycled between THIEF_ASK/THIEF_HONEST/THIEF_STEAL - add_msg( _( "You will pick up also those things that belong to others!" ) ); - } - else if( g->u.get_value( "THIEF_MODE" ) == "THIEF_STEAL" ) - { - u.set_value( "THIEF_MODE", "THIEF_ASK" ); - u.set_value( "THIEF_MODE_KEEP", "NO" ); - //~ Thief mode cycled between THIEF_ASK/THIEF_HONEST/THIEF_STEAL - add_msg( _( "You will be reminded not to steal." ) ); - } - else - { - // ERROR - add_msg( _( "THIEF_MODE CONTAINED BAD VALUE [ %s ]!" ), g->u.get_value( "THIEF_MODE" ) ); - } - break; + case ACTION_TOGGLE_AUTO_MINING: + get_options().get_option( "AUTO_MINING" ).setNext(); + get_options().save(); + //~ Auto Mining is now ON/OFF + add_msg( _( "%s is now %s." ), + get_options().get_option( "AUTO_MINING" ).getMenuText(), + get_option( "AUTO_MINING" ) ? _( "ON" ) : _( "OFF" ) ); + break; - case ACTION_TOGGLE_AUTO_FORAGING: - get_options().get_option( "AUTO_FORAGING" ).setNext(); - get_options().save(); - //~ Auto Foraging is now set to x - add_msg( _( "%s is now set to %s." ), - get_options().get_option( "AUTO_FORAGING" ).getMenuText(), - get_options().get_option( "AUTO_FORAGING" ).getValueName() ); - break; + case ACTION_TOGGLE_THIEF_MODE: + if( g->u.get_value( "THIEF_MODE" ) == "THIEF_ASK" ) { + u.set_value( "THIEF_MODE", "THIEF_HONEST" ); + u.set_value( "THIEF_MODE_KEEP", "YES" ); + //~ Thief mode cycled between THIEF_ASK/THIEF_HONEST/THIEF_STEAL + add_msg( _( "You will not pick up other peoples belongings." ) ); + } else if( g->u.get_value( "THIEF_MODE" ) == "THIEF_HONEST" ) { + u.set_value( "THIEF_MODE", "THIEF_STEAL" ); + u.set_value( "THIEF_MODE_KEEP", "YES" ); + //~ Thief mode cycled between THIEF_ASK/THIEF_HONEST/THIEF_STEAL + add_msg( _( "You will pick up also those things that belong to others!" ) ); + } else if( g->u.get_value( "THIEF_MODE" ) == "THIEF_STEAL" ) { + u.set_value( "THIEF_MODE", "THIEF_ASK" ); + u.set_value( "THIEF_MODE_KEEP", "NO" ); + //~ Thief mode cycled between THIEF_ASK/THIEF_HONEST/THIEF_STEAL + add_msg( _( "You will be reminded not to steal." ) ); + } else { + // ERROR + add_msg( _( "THIEF_MODE CONTAINED BAD VALUE [ %s ]!" ), g->u.get_value( "THIEF_MODE" ) ); + } + break; - case ACTION_TOGGLE_AUTO_PICKUP: - get_options().get_option( "AUTO_PICKUP" ).setNext(); - get_options().save(); - //~ Auto pickup is now set to x - add_msg( _( "%s is now set to %s." ), - get_options().get_option( "AUTO_PICKUP" ).getMenuText(), - get_options().get_option( "AUTO_PICKUP" ).getValueName() ); - break; + case ACTION_TOGGLE_AUTO_FORAGING: + get_options().get_option( "AUTO_FORAGING" ).setNext(); + get_options().save(); + //~ Auto Foraging is now set to x + add_msg( _( "%s is now set to %s." ), + get_options().get_option( "AUTO_FORAGING" ).getMenuText(), + get_options().get_option( "AUTO_FORAGING" ).getValueName() ); + break; - case ACTION_DISPLAY_SCENT: - if( MAP_SHARING::isCompetitive() && !MAP_SHARING::isDebugger() ) - { - break; //don't do anything when sharing and not debugger - } - display_scent(); - break; + case ACTION_TOGGLE_AUTO_PICKUP: + get_options().get_option( "AUTO_PICKUP" ).setNext(); + get_options().save(); + //~ Auto pickup is now set to x + add_msg( _( "%s is now set to %s." ), + get_options().get_option( "AUTO_PICKUP" ).getMenuText(), + get_options().get_option( "AUTO_PICKUP" ).getValueName() ); + break; - case ACTION_DISPLAY_SCENT_TYPE: - if( MAP_SHARING::isCompetitive() && !MAP_SHARING::isDebugger() ) - { - break; //don't do anything when sharing and not debugger - } - display_scent(); - break; + case ACTION_DISPLAY_SCENT: + if( MAP_SHARING::isCompetitive() && !MAP_SHARING::isDebugger() ) { + break; //don't do anything when sharing and not debugger + } + display_scent(); + break; - case ACTION_DISPLAY_TEMPERATURE: - if( MAP_SHARING::isCompetitive() && !MAP_SHARING::isDebugger() ) - { - break; //don't do anything when sharing and not debugger - } - display_temperature(); - break; - case ACTION_DISPLAY_VEHICLE_AI: - if( MAP_SHARING::isCompetitive() && !MAP_SHARING::isDebugger() ) - { - break; //don't do anything when sharing and not debugger - } - display_vehicle_ai(); - break; - case ACTION_DISPLAY_VISIBILITY: - if( MAP_SHARING::isCompetitive() && !MAP_SHARING::isDebugger() ) - { - break; //don't do anything when sharing and not debugger - } - display_visibility(); - break; + case ACTION_DISPLAY_SCENT_TYPE: + if( MAP_SHARING::isCompetitive() && !MAP_SHARING::isDebugger() ) { + break; //don't do anything when sharing and not debugger + } + display_scent(); + break; - case ACTION_DISPLAY_LIGHTING: - if( MAP_SHARING::isCompetitive() && !MAP_SHARING::isDebugger() ) - { - break; //don't do anything when sharing and not debugger - } - display_lighting(); - break; + case ACTION_DISPLAY_TEMPERATURE: + if( MAP_SHARING::isCompetitive() && !MAP_SHARING::isDebugger() ) { + break; //don't do anything when sharing and not debugger + } + display_temperature(); + break; + case ACTION_DISPLAY_VEHICLE_AI: + if( MAP_SHARING::isCompetitive() && !MAP_SHARING::isDebugger() ) { + break; //don't do anything when sharing and not debugger + } + display_vehicle_ai(); + break; + case ACTION_DISPLAY_VISIBILITY: + if( MAP_SHARING::isCompetitive() && !MAP_SHARING::isDebugger() ) { + break; //don't do anything when sharing and not debugger + } + display_visibility(); + break; - case ACTION_DISPLAY_RADIATION: - if( MAP_SHARING::isCompetitive() && !MAP_SHARING::isDebugger() ) - { - break; //don't do anything when sharing and not debugger - } - display_radiation(); - break; + case ACTION_DISPLAY_LIGHTING: + if( MAP_SHARING::isCompetitive() && !MAP_SHARING::isDebugger() ) { + break; //don't do anything when sharing and not debugger + } + display_lighting(); + break; - case ACTION_TOGGLE_DEBUG_MODE: - if( MAP_SHARING::isCompetitive() && !MAP_SHARING::isDebugger() ) - { - break; //don't do anything when sharing and not debugger - } - debug_mode = !debug_mode; - if( debug_mode ) - { - add_msg( m_info, _( "Debug mode ON!" ) ); - } - else - { - add_msg( m_info, _( "Debug mode OFF!" ) ); - } - break; + case ACTION_DISPLAY_RADIATION: + if( MAP_SHARING::isCompetitive() && !MAP_SHARING::isDebugger() ) { + break; //don't do anything when sharing and not debugger + } + display_radiation(); + break; - case ACTION_ZOOM_IN: - zoom_in(); - break; + case ACTION_TOGGLE_DEBUG_MODE: + if( MAP_SHARING::isCompetitive() && !MAP_SHARING::isDebugger() ) { + break; //don't do anything when sharing and not debugger + } + debug_mode = !debug_mode; + if( debug_mode ) { + add_msg( m_info, _( "Debug mode ON!" ) ); + } else { + add_msg( m_info, _( "Debug mode OFF!" ) ); + } + break; - case ACTION_ZOOM_OUT: - zoom_out(); - break; + case ACTION_ZOOM_IN: + zoom_in(); + break; - case ACTION_ITEMACTION: - item_action_menu(); - break; + case ACTION_ZOOM_OUT: + zoom_out(); + break; - case ACTION_AUTOATTACK: - avatar_action::autoattack( u, m ); - break; + case ACTION_ITEMACTION: + item_action_menu(); + break; - default: - break; + case ACTION_AUTOATTACK: + avatar_action::autoattack( u, m ); + break; + + default: + break; } } - if( act != ACTION_TIMEOUT ) - { + if( act != ACTION_TIMEOUT ) { u.mod_moves( -current_turn.moves_elapsed() ); } gamemode->post_action( act ); From bc7ca240039d4a261df6bee8bd8a1a13d85f661f Mon Sep 17 00:00:00 2001 From: Pupsi Mupsi <44737997+Pupsi-Mupsi@users.noreply.github.com> Date: Fri, 13 Mar 2020 10:49:35 +0100 Subject: [PATCH 04/10] show player all active inv-ob that use up charges --- src/handle_action.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/handle_action.cpp b/src/handle_action.cpp index e9c072d26d8d6..687d12ff04306 100644 --- a/src/handle_action.cpp +++ b/src/handle_action.cpp @@ -917,7 +917,7 @@ static void sleep() std::vector active; for( auto &it : u.inv_dump() ) { if( it->active && ( it->charges > 0 || it->units_remaining( u ) > 0 ) && - it->is_transformable() ) { + it->is_tool() ) { active.push_back( it->tname() ); } } From 8a0987594ee04a4b5ec6a0610320c1ae143ba8b3 Mon Sep 17 00:00:00 2001 From: Pupsi Mupsi <44737997+Pupsi-Mupsi@users.noreply.github.com> Date: Fri, 13 Mar 2020 11:07:48 +0100 Subject: [PATCH 05/10] color and text --- src/handle_action.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/handle_action.cpp b/src/handle_action.cpp index 687d12ff04306..5fcb2b7cac834 100644 --- a/src/handle_action.cpp +++ b/src/handle_action.cpp @@ -901,7 +901,7 @@ static void sleep() return; } uilist as_m; - as_m.text = _( "Are you sure you want to sleep?" ); + as_m.text = _( "Are you sure you want to sleep?" ); // (Y)es/(S)ave before sleeping/(N)o as_m.entries.emplace_back( 2, true, get_option( "FORCE_CAPITAL_YN" ) ? 'N' : 'n', @@ -959,7 +959,7 @@ static void sleep() std::stringstream data; if( !active.empty() ) { data << as_m.text << std::endl; - data << _( "You may want to deactivate these before you sleep." ) << std::endl; + data << _( "You may want to turn off:" ) << std::endl; data << " " << std::endl; for( auto &a : active ) { data << "" << a << "" << std::endl; From 87db42b75d19ae9ffde8b1402e194762b1de3985 Mon Sep 17 00:00:00 2001 From: Pupsi Mupsi <44737997+Pupsi-Mupsi@users.noreply.github.com> Date: Fri, 13 Mar 2020 20:23:20 +0100 Subject: [PATCH 06/10] Add test to check for lit items (cigar ...) --- src/handle_action.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/handle_action.cpp b/src/handle_action.cpp index 5fcb2b7cac834..c9432dfc02415 100644 --- a/src/handle_action.cpp +++ b/src/handle_action.cpp @@ -916,8 +916,8 @@ static void sleep() // List all active items, bionics or mutations so player can deactivate them std::vector active; for( auto &it : u.inv_dump() ) { - if( it->active && ( it->charges > 0 || it->units_remaining( u ) > 0 ) && - it->is_tool() ) { + if( it->has_flag( flag_LITCIG ) || + it->active && ( it->charges > 0 || it->units_remaining( u ) > 0 ) && it->is_tool() ) { active.push_back( it->tname() ); } } From 2f0472425f69aaa8858aa19badf5d528cb1addcf Mon Sep 17 00:00:00 2001 From: Pupsi Mupsi <44737997+Pupsi-Mupsi@users.noreply.github.com> Date: Fri, 13 Mar 2020 20:44:44 +0100 Subject: [PATCH 07/10] Add missing parentheses --- src/handle_action.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/handle_action.cpp b/src/handle_action.cpp index c9432dfc02415..cf1f294a18c78 100644 --- a/src/handle_action.cpp +++ b/src/handle_action.cpp @@ -917,7 +917,7 @@ static void sleep() std::vector active; for( auto &it : u.inv_dump() ) { if( it->has_flag( flag_LITCIG ) || - it->active && ( it->charges > 0 || it->units_remaining( u ) > 0 ) && it->is_tool() ) { + it->active && ( it->charges > 0 || it->units_remaining( u ) > 0 ) && ( it->is_tool() ) ) { active.push_back( it->tname() ); } } From ef8ca080ebc4cf04fddbf2b98cd87fcd948786bc Mon Sep 17 00:00:00 2001 From: Pupsi Mupsi <44737997+Pupsi-Mupsi@users.noreply.github.com> Date: Fri, 13 Mar 2020 21:03:56 +0100 Subject: [PATCH 08/10] typo --- src/handle_action.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/handle_action.cpp b/src/handle_action.cpp index cf1f294a18c78..daa52293fcad6 100644 --- a/src/handle_action.cpp +++ b/src/handle_action.cpp @@ -917,7 +917,7 @@ static void sleep() std::vector active; for( auto &it : u.inv_dump() ) { if( it->has_flag( flag_LITCIG ) || - it->active && ( it->charges > 0 || it->units_remaining( u ) > 0 ) && ( it->is_tool() ) ) { + it->active && ( it->charges > 0 || it->units_remaining( u ) > 0 && it->is_tool() ) ) { active.push_back( it->tname() ); } } From 8c86ce2f3878e2fce513073299dfe6feb00abc44 Mon Sep 17 00:00:00 2001 From: Kevin Granade Date: Sat, 14 Mar 2020 06:52:42 +0000 Subject: [PATCH 09/10] Update src/handle_action.cpp --- src/handle_action.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/handle_action.cpp b/src/handle_action.cpp index daa52293fcad6..e346e5e15bea7 100644 --- a/src/handle_action.cpp +++ b/src/handle_action.cpp @@ -917,7 +917,7 @@ static void sleep() std::vector active; for( auto &it : u.inv_dump() ) { if( it->has_flag( flag_LITCIG ) || - it->active && ( it->charges > 0 || it->units_remaining( u ) > 0 && it->is_tool() ) ) { + ( it->active && ( it->charges > 0 || it->units_remaining( u ) > 0 && it->is_tool() ) ) ) { active.push_back( it->tname() ); } } From 1339576659300451e8ea917a8350b3eff0ac7cc8 Mon Sep 17 00:00:00 2001 From: Kevin Granade Date: Sat, 14 Mar 2020 07:05:39 +0000 Subject: [PATCH 10/10] Update src/handle_action.cpp --- src/handle_action.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/handle_action.cpp b/src/handle_action.cpp index e346e5e15bea7..a1fbc0b10145d 100644 --- a/src/handle_action.cpp +++ b/src/handle_action.cpp @@ -917,7 +917,7 @@ static void sleep() std::vector active; for( auto &it : u.inv_dump() ) { if( it->has_flag( flag_LITCIG ) || - ( it->active && ( it->charges > 0 || it->units_remaining( u ) > 0 && it->is_tool() ) ) ) { + ( it->active && ( it->charges > 0 || it->units_remaining( u ) > 0 ) && it->is_tool() ) ) { active.push_back( it->tname() ); } }