From 914cbd07570b81f902b157c15d788a894738305f Mon Sep 17 00:00:00 2001 From: ZhilkinSerg Date: Thu, 11 Jul 2019 11:35:13 +0300 Subject: [PATCH 01/11] Fixed invalid field identifiers --- src/map_field.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/map_field.cpp b/src/map_field.cpp index de973c76b42e7..c453e64ae3919 100644 --- a/src/map_field.cpp +++ b/src/map_field.cpp @@ -1016,8 +1016,8 @@ bool map::process_fields_in_submap( submap *const current_submap, } if( curtype == fd_cold_air1 || curtype == fd_cold_air2 || curtype == fd_cold_air3 || curtype == fd_cold_air4 || - curtype == fd_hot_air1 || curtype == fd_hot_air3 || - curtype == fd_hot_air3 || curtype == fd_cold_air3 ) { + curtype == fd_hot_air1 || curtype == fd_hot_air2 || + curtype == fd_hot_air3 || curtype == fd_hot_air4 ) { // No transparency cache wrecking here! spread_gas( cur, p, 100, 100_minutes, sblk ); } From 070be217f46c9fca7db5be0f7d333f560f234557 Mon Sep 17 00:00:00 2001 From: ZhilkinSerg Date: Thu, 11 Jul 2019 11:45:19 +0300 Subject: [PATCH 02/11] Used constant reference --- src/overmap_ui.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/overmap_ui.cpp b/src/overmap_ui.cpp index 8701facd1fba3..a3a381b20a228 100644 --- a/src/overmap_ui.cpp +++ b/src/overmap_ui.cpp @@ -476,7 +476,7 @@ void draw( const catacurses::window &w, const catacurses::window &wbar, const tr std::array, cache_size> cache {{}}; size_t cache_next = 0; - const auto set_color_and_symbol = [&]( const oter_id & cur_ter, const tripoint omp, + const auto set_color_and_symbol = [&]( const oter_id & cur_ter, const tripoint & omp, std::string & ter_sym, nc_color & ter_color ) { // First see if we have the oter_t cached oter_t const *info = nullptr; From 5e7fc2c32f2bf9c9690cd71f4c3e1ecbca835989 Mon Sep 17 00:00:00 2001 From: ZhilkinSerg Date: Thu, 11 Jul 2019 11:50:10 +0300 Subject: [PATCH 03/11] Used references to avoid using expressions repeatedly --- src/wish.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/wish.cpp b/src/wish.cpp index 81c9bf8e28ceb..241642ab624fa 100644 --- a/src/wish.cpp +++ b/src/wish.cpp @@ -263,15 +263,16 @@ void debug_menu::wishmutate( player *p ) uistate.wishmutate_selected = wmenu.selected; if( rc != 0 ) { for( size_t i = 0; i < cb.vTraits.size(); i++ ) { - wmenu.entries[ i ].extratxt.txt.clear(); + uilist_entry &entry = wmenu.entries[ i ]; + entry.extratxt.txt.clear(); if( p->has_trait( cb.vTraits[ i ] ) ) { - wmenu.entries[ i ].text_color = c_green; + entry.text_color = c_green; cb.pTraits[ cb.vTraits[ i ] ] = true; if( p->has_base_trait( cb.vTraits[ i ] ) ) { - wmenu.entries[ i ].extratxt.txt = "T"; + entry.extratxt.txt = "T"; } } else { - wmenu.entries[ i ].text_color = wmenu.text_color; + entry.text_color = wmenu.text_color; cb.pTraits[ cb.vTraits[ i ] ] = false; } } @@ -508,9 +509,10 @@ void debug_menu::wishitem( player *p, int x, int y, int z ) item ity( opts[i], 0 ); wmenu.addentry( i, true, 0, string_format( _( "%.*s" ), wmenu.pad_right - 5, ity.tname( 1, false ) ) ); - wmenu.entries[i].extratxt.txt = ity.symbol(); - wmenu.entries[i].extratxt.color = ity.color(); - wmenu.entries[i].extratxt.left = 1; + mvwzstr &entry_extra_text = wmenu.entries[i].extratxt; + entry_extra_text.txt = ity.symbol(); + entry_extra_text.color = ity.color(); + entry_extra_text.left = 1; } do { From 72da62c907baf7191b3b1eed794fe59706eff17c Mon Sep 17 00:00:00 2001 From: ZhilkinSerg Date: Thu, 11 Jul 2019 11:52:17 +0300 Subject: [PATCH 04/11] Used clear function instead of assignment to empty string --- src/activity_item_handling.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/activity_item_handling.cpp b/src/activity_item_handling.cpp index b6547537aad1a..eb8f27bd3b90e 100644 --- a/src/activity_item_handling.cpp +++ b/src/activity_item_handling.cpp @@ -1163,7 +1163,7 @@ void activity_on_turn_blueprint_move( player_activity &, player &p ) // If we got here without restarting the activity, it means we're done. if( p.is_npc() ) { npc *guy = dynamic_cast( &p ); - guy->current_activity = ""; + guy->current_activity.clear(); guy->revert_after_activity(); } } From c654e97696ee067950b443e9f5c3af31bc5bd5cd Mon Sep 17 00:00:00 2001 From: ZhilkinSerg Date: Thu, 11 Jul 2019 11:57:40 +0300 Subject: [PATCH 05/11] Declare variables in lower level scopes --- src/activity_handlers.cpp | 2 +- src/map_extras.cpp | 12 ++++++------ src/map_field.cpp | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/activity_handlers.cpp b/src/activity_handlers.cpp index 6f8501c5a5aa2..2df5b5756764e 100644 --- a/src/activity_handlers.cpp +++ b/src/activity_handlers.cpp @@ -2668,7 +2668,6 @@ void activity_handlers::drive_do_turn( player_activity *act, player *p ) void activity_handlers::travel_do_turn( player_activity *act, player *p ) { - const activity_id act_travel = activity_id( "ACT_TRAVELLING" ); if( !p->omt_path.empty() ) { p->omt_path.pop_back(); if( p->omt_path.empty() ) { @@ -2691,6 +2690,7 @@ void activity_handlers::travel_do_turn( player_activity *act, player *p ) const auto route_to = g->m.route( p->pos(), centre_sub, p->get_pathfinding_settings(), p->get_path_avoid() ); if( !route_to.empty() ) { + const activity_id act_travel = activity_id( "ACT_TRAVELLING" ); p->set_destination( route_to, player_activity( act_travel ) ); } else { p->add_msg_if_player( _( "You cannot reach that destination" ) ); diff --git a/src/map_extras.cpp b/src/map_extras.cpp index 0a01afe44a442..83bfe2e4e9099 100644 --- a/src/map_extras.cpp +++ b/src/map_extras.cpp @@ -2317,8 +2317,8 @@ static void mx_casings( map &m, const tripoint &abs_sub ) //Spawn blood and bloody rag and sometimes trail of blood if( one_in( 2 ) ) { m.add_field( location, fd_blood, rng( 1, 3 ) ); - const tripoint bloody_rag_loc = random_entry( m.points_in_radius( location, 3 ) ); if( one_in( 2 ) ) { + const tripoint bloody_rag_loc = random_entry( m.points_in_radius( location, 3 ) ); m.spawn_item( bloody_rag_loc, "rag_bloody" ); } if( one_in( 2 ) ) { @@ -2347,11 +2347,11 @@ static void mx_casings( map &m, const tripoint &abs_sub ) m.spawn_items( trash_loc, trash ); } //Spawn blood and bloody rag in random place - const tripoint random_place = random_entry( m.points_in_radius( location, rng( 1, 10 ) ) ); if( one_in( 2 ) ) { + const tripoint random_place = random_entry( m.points_in_radius( location, rng( 1, 10 ) ) ); m.add_field( random_place, fd_blood, rng( 1, 3 ) ); - const tripoint bloody_rag_loc = random_entry( m.points_in_radius( random_place, 3 ) ); if( one_in( 2 ) ) { + const tripoint bloody_rag_loc = random_entry( m.points_in_radius( random_place, 3 ) ); m.spawn_item( bloody_rag_loc, "rag_bloody" ); } } @@ -2380,8 +2380,8 @@ static void mx_casings( map &m, const tripoint &abs_sub ) //Spawn blood and bloody rag at the destination if( one_in( 2 ) ) { m.add_field( from, fd_blood, rng( 1, 3 ) ); - const tripoint bloody_rag_loc = random_entry( m.points_in_radius( to, 3 ) ); if( one_in( 2 ) ) { + const tripoint bloody_rag_loc = random_entry( m.points_in_radius( to, 3 ) ); m.spawn_item( bloody_rag_loc, "rag_bloody" ); } } @@ -2413,8 +2413,8 @@ static void mx_casings( map &m, const tripoint &abs_sub ) //Spawn blood and bloody rag at the first location, sometimes trail of blood if( one_in( 2 ) ) { m.add_field( first_loc, fd_blood, rng( 1, 3 ) ); - const tripoint bloody_rag_loc = random_entry( m.points_in_radius( first_loc, 3 ) ); if( one_in( 2 ) ) { + const tripoint bloody_rag_loc = random_entry( m.points_in_radius( first_loc, 3 ) ); m.spawn_item( bloody_rag_loc, "rag_bloody" ); } if( one_in( 2 ) ) { @@ -2425,8 +2425,8 @@ static void mx_casings( map &m, const tripoint &abs_sub ) //Spawn blood and bloody rag at the second location, sometimes trail of blood if( one_in( 2 ) ) { m.add_field( second_loc, fd_blood, rng( 1, 3 ) ); - const tripoint bloody_rag_loc = random_entry( m.points_in_radius( second_loc, 3 ) ); if( one_in( 2 ) ) { + const tripoint bloody_rag_loc = random_entry( m.points_in_radius( second_loc, 3 ) ); m.spawn_item( bloody_rag_loc, "rag_bloody" ); } if( one_in( 2 ) ) { diff --git a/src/map_field.cpp b/src/map_field.cpp index c453e64ae3919..12e5b46889d32 100644 --- a/src/map_field.cpp +++ b/src/map_field.cpp @@ -249,9 +249,9 @@ void map::spread_gas( field_entry &cur, const tripoint &p, int percent_spread, } const int current_intensity = cur.get_field_intensity(); - const time_duration current_age = cur.get_field_age(); // Dissipate faster outdoors. if( is_outside( p ) ) { + const time_duration current_age = cur.get_field_age(); cur.set_field_age( current_age + outdoor_age_speedup ); } From cf229fdd0a413818e12b65f85637fa6f56de7803 Mon Sep 17 00:00:00 2001 From: ZhilkinSerg Date: Thu, 11 Jul 2019 12:28:00 +0300 Subject: [PATCH 06/11] Do not use C-style casts --- src/action.cpp | 4 ++-- src/armor_layers.cpp | 2 +- src/artifact.cpp | 28 ++++++++++++++-------------- src/calendar.cpp | 2 +- src/computer.cpp | 5 +++-- src/debug_menu.cpp | 2 +- src/defense.cpp | 28 ++++++++++++++-------------- src/item.cpp | 4 ++-- src/iuse_actor.cpp | 8 ++++---- src/main_menu.cpp | 6 +++--- src/map_extras.cpp | 2 +- src/mapgen.cpp | 12 ++++++------ src/mission.cpp | 2 +- src/npc.cpp | 13 +++++++------ src/npcmove.cpp | 4 ++-- src/npctalk_funcs.cpp | 8 ++++---- src/savegame_json.cpp | 12 ++++++------ src/start_location.cpp | 2 +- 18 files changed, 73 insertions(+), 71 deletions(-) diff --git a/src/action.cpp b/src/action.cpp index a08b6e563069a..c3e842c911e35 100644 --- a/src/action.cpp +++ b/src/action.cpp @@ -458,8 +458,8 @@ action_id look_up_action( const std::string &ident ) } // ^^ Temporarily for the interface with the input manager! for( int i = 0; i < NUM_ACTIONS; i++ ) { - if( action_ident( action_id( i ) ) == ident ) { - return action_id( i ); + if( action_ident( static_cast( i ) ) == ident ) { + return static_cast( i ); } } return ACTION_NULL; diff --git a/src/armor_layers.cpp b/src/armor_layers.cpp index 86e740fa7ad5e..66569201873ac 100644 --- a/src/armor_layers.cpp +++ b/src/armor_layers.cpp @@ -123,7 +123,7 @@ std::string body_part_names( const std::vector &parts ) names.reserve( parts.size() ); for( size_t i = 0; i < parts.size(); ++i ) { const body_part part = parts[i]; - if( i + 1 < parts.size() && parts[i + 1] == body_part( bp_aiOther[part] ) ) { + if( i + 1 < parts.size() && parts[i + 1] == static_cast( bp_aiOther[part] ) ) { // Can combine two body parts (e.g. arms) names.push_back( body_part_name_accusative( part, 2 ) ); ++i; diff --git a/src/artifact.cpp b/src/artifact.cpp index cb9b222541949..dc2f8bb4a1fa1 100644 --- a/src/artifact.cpp +++ b/src/artifact.cpp @@ -782,14 +782,14 @@ std::string new_artifact() def.tool->def_charges = def.tool->max_charges; // If we have charges, pick a recharge mechanism if( def.tool->max_charges > 0 ) { - def.artifact->charge_type = art_charge( rng( ARTC_NULL + 1, NUM_ARTCS - 1 ) ); + def.artifact->charge_type = static_cast( rng( ARTC_NULL + 1, NUM_ARTCS - 1 ) ); } if( one_in( 8 ) && num_bad + num_good >= 4 ) { def.artifact->charge_type = ARTC_NULL; // 1 in 8 chance that it can't recharge! } // Maybe pick an extra recharge requirement if( one_in( std::max( 1, 6 - num_good ) ) && def.artifact->charge_type != ARTC_NULL ) { - def.artifact->charge_req = art_charge_req( rng( ACR_NULL + 1, NUM_ACRS - 1 ) ); + def.artifact->charge_req = static_cast( rng( ACR_NULL + 1, NUM_ACRS - 1 ) ); } // Assign dream data (stored individually so they can be overridden in json) def.artifact->dream_msg_unmet = artifact_dream_data[static_cast @@ -923,8 +923,8 @@ std::string new_natural_artifact( artifact_natural_property prop ) const artifact_shape_datum &shape_data = random_entry_ref( artifact_shape_data ); // Pick a property const artifact_natural_property property = ( prop > ARTPROP_NULL ? prop : - artifact_natural_property( rng( ARTPROP_NULL + 1, - ARTPROP_MAX - 1 ) ) ); + static_cast( rng( ARTPROP_NULL + 1, + ARTPROP_MAX - 1 ) ) ); const artifact_property_datum &property_data = artifact_property_data[property]; def.sym = ":"; @@ -968,25 +968,25 @@ std::string new_natural_artifact( artifact_natural_property prop ) if( good_passive ) { aep_good = random_entry_ref( property_data.passive_good ); if( aep_good == AEP_NULL || one_in( 4 ) ) { - aep_good = art_effect_passive( rng( AEP_NULL + 1, AEP_SPLIT - 1 ) ); + aep_good = static_cast( rng( AEP_NULL + 1, AEP_SPLIT - 1 ) ); } } if( bad_passive ) { aep_bad = random_entry_ref( property_data.passive_bad ); if( aep_bad == AEP_NULL || one_in( 4 ) ) { - aep_bad = art_effect_passive( rng( AEP_SPLIT + 1, NUM_AEAS - 1 ) ); + aep_bad = static_cast( rng( AEP_SPLIT + 1, NUM_AEAS - 1 ) ); } } if( good_active ) { aea_good = random_entry_ref( property_data.active_good ); if( aea_good == AEA_NULL || one_in( 4 ) ) { - aea_good = art_effect_active( rng( AEA_NULL + 1, AEA_SPLIT - 1 ) ); + aea_good = static_cast( rng( AEA_NULL + 1, AEA_SPLIT - 1 ) ); } } if( bad_active ) { aea_bad = random_entry_ref( property_data.active_bad ); if( aea_bad == AEA_NULL || one_in( 4 ) ) { - aea_bad = art_effect_active( rng( AEA_SPLIT + 1, NUM_AEAS - 1 ) ); + aea_bad = static_cast( rng( AEA_SPLIT + 1, NUM_AEAS - 1 ) ); } } @@ -1012,10 +1012,10 @@ std::string new_natural_artifact( artifact_natural_property prop ) // (When "implanting" them in a mundane item, this ability may be lost if( !def.artifact->effects_activated.empty() ) { def.tool->def_charges = def.tool->max_charges = rng( 1, 4 ); - def.artifact->charge_type = art_charge( rng( ARTC_NULL + 1, NUM_ARTCS - 1 ) ); + def.artifact->charge_type = static_cast( rng( ARTC_NULL + 1, NUM_ARTCS - 1 ) ); //Maybe pick an extra recharge requirement if( one_in( 6 ) ) { - def.artifact->charge_req = art_charge_req( rng( ACR_NULL + 1, NUM_ACRS - 1 ) ); + def.artifact->charge_req = static_cast( rng( ACR_NULL + 1, NUM_ACRS - 1 ) ); } } // Assign dream data (stored individually so they can be overridden in json) @@ -1062,7 +1062,7 @@ std::vector fill_good_passive() { std::vector ret; for( int i = AEP_NULL + 1; i < AEP_SPLIT; i++ ) { - ret.push_back( art_effect_passive( i ) ); + ret.push_back( static_cast( i ) ); } return ret; } @@ -1071,7 +1071,7 @@ std::vector fill_bad_passive() { std::vector ret; for( int i = AEP_SPLIT + 1; i < NUM_AEPS; i++ ) { - ret.push_back( art_effect_passive( i ) ); + ret.push_back( static_cast( i ) ); } return ret; } @@ -1080,7 +1080,7 @@ std::vector fill_good_active() { std::vector ret; for( int i = AEA_NULL + 1; i < AEA_SPLIT; i++ ) { - ret.push_back( art_effect_active( i ) ); + ret.push_back( static_cast( i ) ); } return ret; } @@ -1089,7 +1089,7 @@ std::vector fill_bad_active() { std::vector ret; for( int i = AEA_SPLIT + 1; i < NUM_AEAS; i++ ) { - ret.push_back( art_effect_active( i ) ); + ret.push_back( static_cast( i ) ); } return ret; } diff --git a/src/calendar.cpp b/src/calendar.cpp index 1b5afe99e3e1e..afb20ce9598c3 100644 --- a/src/calendar.cpp +++ b/src/calendar.cpp @@ -581,7 +581,7 @@ void calendar::sync() // mid-game, the result could be the wrong season! season = initial_season; } else { - season = season_type( turn_number / DAYS( sl ) % 4 ); + season = static_cast( turn_number / DAYS( sl ) % 4 ); } day = turn_number / DAYS( 1 ) % sl; diff --git a/src/computer.cpp b/src/computer.cpp index d234a47ea3ea2..4a69fedc84e31 100644 --- a/src/computer.cpp +++ b/src/computer.cpp @@ -332,7 +332,8 @@ void computer::load_data( const std::string &data ) dump >> tmpname >> tmpaction >> tmpsec; - add_option( string_replace( tmpname, "_", " " ), computer_action( tmpaction ), tmpsec ); + add_option( string_replace( tmpname, "_", " " ), static_cast( tmpaction ), + tmpsec ); } // Pull in failures @@ -341,7 +342,7 @@ void computer::load_data( const std::string &data ) for( int n = 0; n < failsize; n++ ) { int tmpfail; dump >> tmpfail; - add_failure( computer_failure_type( tmpfail ) ); + add_failure( static_cast( tmpfail ) ); } } diff --git a/src/debug_menu.cpp b/src/debug_menu.cpp index 069e714bc94f1..9578925a772c1 100644 --- a/src/debug_menu.cpp +++ b/src/debug_menu.cpp @@ -1182,7 +1182,7 @@ void debug() case DEBUG_SPAWN_ARTIFACT: if( const cata::optional center = g->look_around() ) { - artifact_natural_property prop = artifact_natural_property( rng( ARTPROP_NULL + 1, + artifact_natural_property prop = static_cast( rng( ARTPROP_NULL + 1, ARTPROP_MAX - 1 ) ); m.create_anomaly( *center, prop ); m.spawn_natural_artifact( *center, prop ); diff --git a/src/defense.cpp b/src/defense.cpp index 21b52b56ca199..5576e53409ffe 100644 --- a/src/defense.cpp +++ b/src/defense.cpp @@ -538,17 +538,17 @@ void defense_game::setup() switch( selection ) { case 1: // Scenario selection if( action == "RIGHT" ) { - if( style == defense_style( NUM_DEFENSE_STYLES - 1 ) ) { - style = defense_style( 1 ); + if( style == static_cast( NUM_DEFENSE_STYLES - 1 ) ) { + style = static_cast( 1 ); } else { - style = defense_style( style + 1 ); + style = static_cast( style + 1 ); } } if( action == "LEFT" ) { - if( style == defense_style( 1 ) ) { - style = defense_style( NUM_DEFENSE_STYLES - 1 ); + if( style == static_cast( 1 ) ) { + style = static_cast( NUM_DEFENSE_STYLES - 1 ); } else { - style = defense_style( style - 1 ); + style = static_cast( style - 1 ); } } init_to_style( style ); @@ -556,17 +556,17 @@ void defense_game::setup() case 2: // Location selection if( action == "RIGHT" ) { - if( location == defense_location( NUM_DEFENSE_LOCATIONS - 1 ) ) { - location = defense_location( 1 ); + if( location == static_cast( NUM_DEFENSE_LOCATIONS - 1 ) ) { + location = static_cast( 1 ); } else { - location = defense_location( location + 1 ); + location = static_cast( location + 1 ); } } if( action == "LEFT" ) { - if( location == defense_location( 1 ) ) { - location = defense_location( NUM_DEFENSE_LOCATIONS - 1 ); + if( location == static_cast( 1 ) ) { + location = static_cast( NUM_DEFENSE_LOCATIONS - 1 ); } else { - location = defense_location( location - 1 ); + location = static_cast( location - 1 ); } } mvwprintz( w, 5, 2, c_black, "\ @@ -900,7 +900,7 @@ void defense_game::caravan() // Init the items for each category for( int i = 0; i < NUM_CARAVAN_CATEGORIES; i++ ) { - items[i] = caravan_items( caravan_category( i ) ); + items[i] = caravan_items( static_cast( i ) ); for( std::vector::iterator it = items[i].begin(); it != items[i].end(); ) { if( current_wave == 0 || !one_in( 4 ) ) { @@ -1286,7 +1286,7 @@ void draw_caravan_categories( const catacurses::window &w, int category_selected for( int i = 0; i < NUM_CARAVAN_CATEGORIES; i++ ) { mvwprintz( w, i + 3, 1, ( i == category_selected ? h_white : c_white ), - caravan_category_name( caravan_category( i ) ) ); + caravan_category_name( static_cast( i ) ) ); } wrefresh( w ); } diff --git a/src/item.cpp b/src/item.cpp index ecda7ad82688d..663acf2e0e8a5 100644 --- a/src/item.cpp +++ b/src/item.cpp @@ -1263,7 +1263,7 @@ std::string item::info( std::vector &info, const iteminfo_query *parts return ( g->u.vitamin_rate( v.first ) > 0_turns && v.second != 0 ) // only display vitamins that we actually require ? string_format( "%s (%i%%)", v.first.obj().name(), - int( v.second * g->u.vitamin_rate( v.first ) / 1_days * 100 ) ) + static_cast( v.second * g->u.vitamin_rate( v.first ) / 1_days * 100 ) ) : std::string(); } ); if( !required_vits.empty() && parts->test( iteminfo_parts::FOOD_VITAMINS ) ) { @@ -4446,7 +4446,7 @@ bool item::ready_to_revive( const tripoint &pos ) const return false; } int age_in_hours = to_hours( age() ); - age_in_hours -= int( static_cast( burnt ) / ( volume() / 250_ml ) ); + age_in_hours -= static_cast( static_cast( burnt ) / ( volume() / 250_ml ) ); if( damage_level( 4 ) > 0 ) { age_in_hours /= ( damage_level( 4 ) + 1 ); } diff --git a/src/iuse_actor.cpp b/src/iuse_actor.cpp index 585b1517ce046..a537857a3ce14 100644 --- a/src/iuse_actor.cpp +++ b/src/iuse_actor.cpp @@ -635,8 +635,8 @@ void consume_drug_iuse::info( const item &, std::vector &dump ) const if( rate <= 0_turns ) { return std::string(); } - const int lo = int( v.second.first * rate / 1_days * 100 ); - const int hi = int( v.second.second * rate / 1_days * 100 ); + const int lo = static_cast( v.second.first * rate / 1_days * 100 ); + const int hi = static_cast( v.second.second * rate / 1_days * 100 ); return string_format( lo == hi ? "%s (%i%%)" : "%s (%i-%i%%)", v.first.obj().name(), lo, hi ); @@ -3561,7 +3561,7 @@ hp_part heal_actor::use_healing_item( player &healer, player &patient, item &it, int highest_damage = 0; for( int i = 0; i < num_hp_parts; i++ ) { int damage = 0; - const body_part i_bp = player::hp_to_bp( hp_part( i ) ); + const body_part i_bp = player::hp_to_bp( static_cast( i ) ); if( !patient.has_effect( effect_bandaged, i_bp ) ) { damage += patient.hp_max[i] - patient.hp_cur[i]; } @@ -3570,7 +3570,7 @@ hp_part heal_actor::use_healing_item( player &healer, player &patient, item &it, damage += infect * patient.get_effect_dur( effect_infected, i_bp ) / 10_minutes; if( damage > highest_damage ) { highest_damage = damage; - healed = hp_part( i ); + healed = static_cast( i ); } } } else if( patient.is_player() ) { diff --git a/src/main_menu.cpp b/src/main_menu.cpp index 299c713222782..f85834f4b688c 100644 --- a/src/main_menu.cpp +++ b/src/main_menu.cpp @@ -509,7 +509,7 @@ bool main_menu::opening_screen() int yoffset = iMenuOffsetY - 2; int xlen = 0; for( int i = 1; i < NUM_SPECIAL_GAMES; i++ ) { - std::string spec_name = special_game_name( special_game_id( i ) ); + std::string spec_name = special_game_name( static_cast( i ) ); special_names.push_back( spec_name ); xlen += spec_name.size() + 2; } @@ -538,9 +538,9 @@ bool main_menu::opening_screen() } if( action == "UP" || action == "CONFIRM" ) { if( sel2 >= 0 && sel2 < NUM_SPECIAL_GAMES - 1 ) { - g->gamemode = get_special_game( special_game_id( sel2 + 1 ) ); + g->gamemode = get_special_game( static_cast( sel2 + 1 ) ); // check world - WORLDPTR world = world_generator->make_new_world( special_game_id( sel2 + 1 ) ); + WORLDPTR world = world_generator->make_new_world( static_cast( sel2 + 1 ) ); if( world == nullptr ) { continue; } diff --git a/src/map_extras.cpp b/src/map_extras.cpp index 83bfe2e4e9099..dc89df498000a 100644 --- a/src/map_extras.cpp +++ b/src/map_extras.cpp @@ -1431,7 +1431,7 @@ static void mx_anomaly( map &m, const tripoint &abs_sub ) { tripoint center( rng( 6, SEEX * 2 - 7 ), rng( 6, SEEY * 2 - 7 ), abs_sub.z ); artifact_natural_property prop = - artifact_natural_property( rng( ARTPROP_NULL + 1, ARTPROP_MAX - 1 ) ); + static_cast( rng( ARTPROP_NULL + 1, ARTPROP_MAX - 1 ) ); m.create_anomaly( center, prop ); m.spawn_natural_artifact( center, prop ); } diff --git a/src/mapgen.cpp b/src/mapgen.cpp index 2e2941473d43c..6c64ee072de39 100644 --- a/src/mapgen.cpp +++ b/src/mapgen.cpp @@ -688,7 +688,7 @@ void mapgen_function_json_base::setup_setmap( JsonArray &parray ) pjo.read( "fuel", tmp_fuel ); pjo.read( "status", tmp_status ); jmapgen_setmap tmp( tmp_x, tmp_y, tmp_x2, tmp_y2, - jmapgen_setmap_op( tmpop + setmap_optype ), tmp_i, + static_cast( tmpop + setmap_optype ), tmp_i, tmp_chance, tmp_repeat, tmp_rotation, tmp_fuel, tmp_status ); setmap_points.push_back( tmp ); @@ -4963,7 +4963,7 @@ void map::draw_mine( const oter_id &terrain_type, mapgendata &dat, const time_po } } if( okay ) { - room_type type = room_type( rng( room_mine_office, room_mine_housing ) ); + room_type type = static_cast( rng( room_mine_office, room_mine_housing ) ); build_mine_room( this, type, x1, y1, x2, y2, dat ); tries = 0; } else { @@ -8256,13 +8256,13 @@ void map::create_anomaly( const tripoint &cp, artifact_natural_property prop, bo case ARTPROP_FRACTAL: create_anomaly( cx - 4, cy - 4, - artifact_natural_property( rng( ARTPROP_NULL + 1, ARTPROP_MAX - 1 ) ) ); + static_cast( rng( ARTPROP_NULL + 1, ARTPROP_MAX - 1 ) ) ); create_anomaly( cx + 4, cy - 4, - artifact_natural_property( rng( ARTPROP_NULL + 1, ARTPROP_MAX - 1 ) ) ); + static_cast( rng( ARTPROP_NULL + 1, ARTPROP_MAX - 1 ) ) ); create_anomaly( cx - 4, cy + 4, - artifact_natural_property( rng( ARTPROP_NULL + 1, ARTPROP_MAX - 1 ) ) ); + static_cast( rng( ARTPROP_NULL + 1, ARTPROP_MAX - 1 ) ) ); create_anomaly( cx + 4, cy - 4, - artifact_natural_property( rng( ARTPROP_NULL + 1, ARTPROP_MAX - 1 ) ) ); + static_cast( rng( ARTPROP_NULL + 1, ARTPROP_MAX - 1 ) ) ); break; default: break; diff --git a/src/mission.cpp b/src/mission.cpp index c51f611d6a3b3..e0173e3bc846b 100644 --- a/src/mission.cpp +++ b/src/mission.cpp @@ -621,7 +621,7 @@ void mission::load_info( std::istream &data ) deadline = time_point::from_turn( deadline_ ); target.z = 0; follow_up = mission_type::from_legacy( tmpfollow ); - reward.type = npc_favor_type( reward_id ); + reward.type = static_cast( reward_id ); reward.item_id = itype_id( rew_item ); reward.skill = Skill::from_legacy_int( rew_skill ); item_id = itype_id( itemid ); diff --git a/src/npc.cpp b/src/npc.cpp index 4c77f7938557c..424cdef817eb0 100644 --- a/src/npc.cpp +++ b/src/npc.cpp @@ -213,8 +213,8 @@ void npc_template::load( JsonObject &jsobj ) guy.myclass = npc_class_id( jsobj.get_string( "class" ) ); } - guy.set_attitude( npc_attitude( jsobj.get_int( "attitude" ) ) ); - guy.mission = npc_mission( jsobj.get_int( "mission" ) ); + guy.set_attitude( static_cast( jsobj.get_int( "attitude" ) ) ); + guy.mission = static_cast( jsobj.get_int( "mission" ) ); guy.chatbin.first_topic = jsobj.get_string( "chat" ); if( jsobj.has_string( "mission_offered" ) ) { guy.miss_ids.emplace_back( mission_type_id( jsobj.get_string( "mission_offered" ) ) ); @@ -827,7 +827,7 @@ bool npc::wear_if_wanted( const item &it ) if( splint ) { splint = false; for( int i = 0; i < num_hp_parts; i++ ) { - hp_part hpp = hp_part( i ); + hp_part hpp = static_cast( i ); body_part bp = player::hp_to_bp( hpp ); if( hp_cur[i] <= 0 && it.covers( bp ) ) { splint = true; @@ -1101,7 +1101,8 @@ float npc::vehicle_danger( int radius ) const int size = std::max( last_part.mount.x, last_part.mount.y ); double normal = sqrt( static_cast( ( bx - ax ) * ( bx - ax ) + ( by - ay ) * ( by - ay ) ) ); - int closest = int( abs( ( posx() - ax ) * ( by - ay ) - ( posy() - ay ) * ( bx - ax ) ) / normal ); + int closest = static_cast( abs( ( posx() - ax ) * ( by - ay ) - ( posy() - ay ) * + ( bx - ax ) ) / normal ); if( size > closest ) { danger = i; @@ -1222,12 +1223,12 @@ void npc::decide_needs() if( needrank[i] < 20 ) { for( j = 0; j < needs.size(); j++ ) { if( needrank[i] < needrank[needs[j]] ) { - needs.insert( needs.begin() + j, npc_need( i ) ); + needs.insert( needs.begin() + j, static_cast( i ) ); j = needs.size() + 1; } } if( j == needs.size() ) { - needs.push_back( npc_need( i ) ); + needs.push_back( static_cast( i ) ); } } } diff --git a/src/npcmove.cpp b/src/npcmove.cpp index 53b59f12fedfc..8659a8d4f709d 100644 --- a/src/npcmove.cpp +++ b/src/npcmove.cpp @@ -1363,7 +1363,7 @@ bool npc::need_heal( const player &n ) } for( int i = 0; i < num_hp_parts; i++ ) { - const hp_part part = hp_part( i ); + const hp_part part = static_cast( i ); const body_part bp_wounded = hp_to_bp( part ); if( ai_cache.can_heal.bleed && n.has_effect( effect_bleed, bp_wounded ) ) { @@ -4131,7 +4131,7 @@ bool npc::adjust_worn() const auto covers_broken = [this]( const item & it, side s ) { const auto covered = it.get_covered_body_parts( s ); for( size_t i = 0; i < num_hp_parts; i++ ) { - if( hp_cur[ i ] <= 0 && covered.test( hp_to_bp( hp_part( i ) ) ) ) { + if( hp_cur[ i ] <= 0 && covered.test( hp_to_bp( static_cast( i ) ) ) ) { return true; } } diff --git a/src/npctalk_funcs.cpp b/src/npctalk_funcs.cpp index 2f44032527be8..3bd6d45595848 100644 --- a/src/npctalk_funcs.cpp +++ b/src/npctalk_funcs.cpp @@ -489,8 +489,8 @@ void talk_function::give_aid( npc &p ) { p.add_effect( effect_currently_busy, 30_minutes ); for( int i = 0; i < num_hp_parts; i++ ) { - const body_part bp_healed = player::hp_to_bp( hp_part( i ) ); - g->u.heal( hp_part( i ), 5 * rng( 2, 5 ) ); + const body_part bp_healed = player::hp_to_bp( static_cast( i ) ); + g->u.heal( static_cast( i ), 5 * rng( 2, 5 ) ); if( g->u.has_effect( effect_bite, bp_healed ) ) { g->u.remove_effect( effect_bite, bp_healed ); } @@ -512,8 +512,8 @@ void talk_function::give_all_aid( npc &p ) for( npc &guy : g->all_npcs() ) { if( guy.is_walking_with() && rl_dist( guy.pos(), g->u.pos() ) < PICKUP_RANGE ) { for( int i = 0; i < num_hp_parts; i++ ) { - const body_part bp_healed = player::hp_to_bp( hp_part( i ) ); - guy.heal( hp_part( i ), 5 * rng( 2, 5 ) ); + const body_part bp_healed = player::hp_to_bp( static_cast( i ) ); + guy.heal( static_cast( i ), 5 * rng( 2, 5 ) ); if( guy.has_effect( effect_bite, bp_healed ) ) { guy.remove_effect( effect_bite, bp_healed ); } diff --git a/src/savegame_json.cpp b/src/savegame_json.cpp index 708e04af03ff0..350e798ac33a1 100644 --- a/src/savegame_json.cpp +++ b/src/savegame_json.cpp @@ -1227,7 +1227,7 @@ void npc_chatbin::deserialize( JsonIn &jsin ) if( data.has_int( "first_topic" ) ) { int tmptopic = 0; data.read( "first_topic", tmptopic ); - first_topic = convert_talk_topic( talk_topic_enum( tmptopic ) ); + first_topic = convert_talk_topic( static_cast( tmptopic ) ); } else { data.read( "first_topic", first_topic ); } @@ -1311,7 +1311,7 @@ void npc_opinion::serialize( JsonOut &json ) const void npc_favor::deserialize( JsonIn &jsin ) { JsonObject jo = jsin.get_object(); - type = npc_favor_type( jo.get_int( "type" ) ); + type = static_cast( jo.get_int( "type" ) ); jo.read( "value", value ); jo.read( "itype_id", item_id ); if( jo.has_int( "skill_id" ) ) { @@ -1427,7 +1427,7 @@ void npc::load( JsonObject &data ) } if( data.read( "mission", misstmp ) ) { - mission = npc_mission( misstmp ); + mission = static_cast( misstmp ); static const std::set legacy_missions = {{ NPC_MISSION_LEGACY_1, NPC_MISSION_LEGACY_2, NPC_MISSION_LEGACY_3 @@ -1438,7 +1438,7 @@ void npc::load( JsonObject &data ) } } if( data.read( "previous_mission", misstmp ) ) { - previous_mission = npc_mission( misstmp ); + previous_mission = static_cast( misstmp ); static const std::set legacy_missions = {{ NPC_MISSION_LEGACY_1, NPC_MISSION_LEGACY_2, NPC_MISSION_LEGACY_3 @@ -1460,7 +1460,7 @@ void npc::load( JsonObject &data ) } if( data.read( "attitude", atttmp ) ) { - attitude = npc_attitude( atttmp ); + attitude = static_cast( atttmp ); static const std::set legacy_attitudes = {{ NPCATT_LEGACY_1, NPCATT_LEGACY_2, NPCATT_LEGACY_3, NPCATT_LEGACY_4, NPCATT_LEGACY_5, NPCATT_LEGACY_6 @@ -1471,7 +1471,7 @@ void npc::load( JsonObject &data ) } } if( data.read( "previous_attitude", atttmp ) ) { - previous_attitude = npc_attitude( atttmp ); + previous_attitude = static_cast( atttmp ); static const std::set legacy_attitudes = {{ NPCATT_LEGACY_1, NPCATT_LEGACY_2, NPCATT_LEGACY_3, NPCATT_LEGACY_4, NPCATT_LEGACY_5, NPCATT_LEGACY_6 diff --git a/src/start_location.cpp b/src/start_location.cpp index 87a63fbf1f87d..ac68885bf648f 100644 --- a/src/start_location.cpp +++ b/src/start_location.cpp @@ -409,7 +409,7 @@ void start_location::add_map_extra( const tripoint &omtstart, void start_location::handle_heli_crash( player &u ) const { for( int i = 2; i < num_hp_parts; i++ ) { // Skip head + torso for balance reasons. - const auto part = hp_part( i ); + const auto part = static_cast( i ); const auto bp_part = u.hp_to_bp( part ); const int roll = static_cast( rng( 1, 8 ) ); switch( roll ) { From a10c1b7fc35a671aff179643ac8cb0212b57bfda Mon Sep 17 00:00:00 2001 From: ZhilkinSerg Date: Thu, 11 Jul 2019 12:33:16 +0300 Subject: [PATCH 07/11] Remove unused declarators --- src/handle_action.cpp | 1 - src/player.cpp | 11 ----------- 2 files changed, 12 deletions(-) diff --git a/src/handle_action.cpp b/src/handle_action.cpp index 0559a2c94423e..6c7a80eb2cc8e 100644 --- a/src/handle_action.cpp +++ b/src/handle_action.cpp @@ -75,7 +75,6 @@ static const bionic_id bio_remote( "bio_remote" ); static const trait_id trait_HIBERNATE( "HIBERNATE" ); static const trait_id trait_SHELL2( "SHELL2" ); -static const trait_id trait_DEBUG_HS( "DEBUG_HS" ); const skill_id skill_driving( "driving" ); const skill_id skill_melee( "melee" ); diff --git a/src/player.cpp b/src/player.cpp index 292a98cd2ccf3..e5779cee5bc93 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -257,8 +257,6 @@ static const trait_id trait_ALBINO( "ALBINO" ); static const trait_id trait_AMPHIBIAN( "AMPHIBIAN" ); static const trait_id trait_ANTENNAE( "ANTENNAE" ); static const trait_id trait_ANTLERS( "ANTLERS" ); -static const trait_id trait_ARACHNID_ARMS( "ARACHNID_ARMS" ); -static const trait_id trait_ARACHNID_ARMS_OK( "ARACHNID_ARMS_OK" ); static const trait_id trait_ASTHMA( "ASTHMA" ); static const trait_id trait_BADBACK( "BADBACK" ); static const trait_id trait_BARK( "BARK" ); @@ -269,15 +267,12 @@ static const trait_id trait_CF_HAIR( "CF_HAIR" ); static const trait_id trait_CHAOTIC( "CHAOTIC" ); static const trait_id trait_CHAOTIC_BAD( "CHAOTIC_BAD" ); static const trait_id trait_CHEMIMBALANCE( "CHEMIMBALANCE" ); -static const trait_id trait_CHITIN2( "CHITIN2" ); -static const trait_id trait_CHITIN3( "CHITIN3" ); static const trait_id trait_CHITIN_FUR( "CHITIN_FUR" ); static const trait_id trait_CHITIN_FUR2( "CHITIN_FUR2" ); static const trait_id trait_CHITIN_FUR3( "CHITIN_FUR3" ); static const trait_id trait_CHLOROMORPH( "CHLOROMORPH" ); static const trait_id trait_CLUMSY( "CLUMSY" ); static const trait_id trait_COLDBLOOD4( "COLDBLOOD4" ); -static const trait_id trait_COMPOUND_EYES( "COMPOUND_EYES" ); static const trait_id trait_DEAF( "DEAF" ); static const trait_id trait_DEFT( "DEFT" ); static const trait_id trait_DEBUG_BIONIC_POWER( "DEBUG_BIONIC_POWER" ); @@ -316,8 +311,6 @@ static const trait_id trait_HORNS_POINTED( "HORNS_POINTED" ); static const trait_id trait_HUGE( "HUGE" ); static const trait_id trait_HUGE_OK( "HUGE_OK" ); static const trait_id trait_INFIMMUNE( "INFIMMUNE" ); -static const trait_id trait_INSECT_ARMS( "INSECT_ARMS" ); -static const trait_id trait_INSECT_ARMS_OK( "INSECT_ARMS_OK" ); static const trait_id trait_INSOMNIA( "INSOMNIA" ); static const trait_id trait_INT_SLIME( "INT_SLIME" ); static const trait_id trait_JITTERY( "JITTERY" ); @@ -406,12 +399,10 @@ static const trait_id trait_SORES( "SORES" ); static const trait_id trait_SPINES( "SPINES" ); static const trait_id trait_SPIRITUAL( "SPIRITUAL" ); static const trait_id trait_SQUEAMISH( "SQUEAMISH" ); -static const trait_id trait_STIMBOOST( "STIMBOOST" ); static const trait_id trait_STRONGSTOMACH( "STRONGSTOMACH" ); static const trait_id trait_SUNBURN( "SUNBURN" ); static const trait_id trait_SUNLIGHT_DEPENDENT( "SUNLIGHT_DEPENDENT" ); static const trait_id trait_TAIL_FIN( "TAIL_FIN" ); -static const trait_id trait_THICK_SCALES( "THICK_SCALES" ); static const trait_id trait_THORNS( "THORNS" ); static const trait_id trait_THRESH_SPIDER( "THRESH_SPIDER" ); static const trait_id trait_TOUGH_FEET( "TOUGH_FEET" ); @@ -431,8 +422,6 @@ static const trait_id trait_WEBBED( "WEBBED" ); static const trait_id trait_WEB_SPINNER( "WEB_SPINNER" ); static const trait_id trait_WEB_WALKER( "WEB_WALKER" ); static const trait_id trait_WEB_WEAVER( "WEB_WEAVER" ); -static const trait_id trait_WHISKERS( "WHISKERS" ); -static const trait_id trait_WHISKERS_RAT( "WHISKERS_RAT" ); static const trait_id trait_WOOLALLERGY( "WOOLALLERGY" ); stat_mod player::get_pain_penalty() const From 45709bc85ea6a46b17afedb70aa484dc16dfcc92 Mon Sep 17 00:00:00 2001 From: ZhilkinSerg Date: Thu, 11 Jul 2019 12:34:26 +0300 Subject: [PATCH 08/11] Removed unimplemented functions --- src/veh_interact.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/veh_interact.h b/src/veh_interact.h index c55f0f1a04847..c272c7a1f54eb 100644 --- a/src/veh_interact.h +++ b/src/veh_interact.h @@ -149,7 +149,6 @@ class veh_interact void display_veh(); void display_stats() const; void display_name(); - void display_owner(); void display_mode(); void display_list( size_t pos, const std::vector &list, const int header = 0 ); void display_details( const vpart_info *part ); From e38bca4efe1a93dd10e6946bed3f609d91bd7c5d Mon Sep 17 00:00:00 2001 From: ZhilkinSerg Date: Thu, 11 Jul 2019 12:38:58 +0300 Subject: [PATCH 09/11] Combined declaration and assignment --- src/map_field.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/map_field.cpp b/src/map_field.cpp index 12e5b46889d32..66d4e4d5a3ab6 100644 --- a/src/map_field.cpp +++ b/src/map_field.cpp @@ -1373,9 +1373,6 @@ void map::player_in_field( player &u ) // A copy of the current field for reference. Do not add fields to it, use map::add_field field &curfield = get_field( u.pos() ); bool inside = false; // Are we inside? - //to modify power of a field based on... whatever is relevant for the effect. - int adjusted_intensity; - //If we are in a vehicle figure out if we are inside (reduces effects usually) // and what part of the vehicle we need to deal with. if( u.in_vehicle ) { @@ -1482,8 +1479,9 @@ void map::player_in_field( player &u ) //heatsink or suit prevents ALL fire damage. break; } + //to modify power of a field based on... whatever is relevant for the effect. + int adjusted_intensity = cur.get_field_intensity(); //Burn the player. Less so if you are in a car or ON a car. - adjusted_intensity = cur.get_field_intensity(); if( u.in_vehicle ) { if( inside ) { adjusted_intensity -= 2; From de8ff0215f6fc30ab90ac914a2eef4f9780b883e Mon Sep 17 00:00:00 2001 From: ZhilkinSerg Date: Thu, 11 Jul 2019 12:40:37 +0300 Subject: [PATCH 10/11] Removed redundant empty declarations and statements --- src/iuse.cpp | 2 +- src/list.h | 4 ++-- src/magic.h | 2 +- src/requirements.h | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/iuse.cpp b/src/iuse.cpp index 7d947a84c9771..41d9d0fc31de8 100644 --- a/src/iuse.cpp +++ b/src/iuse.cpp @@ -6567,7 +6567,7 @@ static std::string colorized_trap_name_at( const tripoint &point ) std::string name; if( !trap.is_null() && trap.get_visibility() <= 1 ) { name = colorize( trap.name(), trap.color ) + _( " on " ); - }; + } return name; } diff --git a/src/list.h b/src/list.h index 2f9ca8a068282..3672bd1ce5010 100644 --- a/src/list.h +++ b/src/list.h @@ -208,12 +208,12 @@ template &max_level = cata::nullopt ) : id( sp_id ), - max_level( max_level ), self( hit_self ) {}; + max_level( max_level ), self( hit_self ) {} }; class spell_type diff --git a/src/requirements.h b/src/requirements.h index 85449672161d2..b4862855b59b0 100644 --- a/src/requirements.h +++ b/src/requirements.h @@ -173,7 +173,7 @@ struct requirement_data { requirement_data() = default; requirement_data( const alter_tool_comp_vector &tools, const alter_quali_req_vector &qualities, const alter_item_comp_vector &components ) : tools( tools ), qualities( qualities ), - components( components ) {}; + components( components ) {} const requirement_id &id() const { return id_; From 9f1ad48bcc09ecf0a81a2c46bf4a1e36a57c78a6 Mon Sep 17 00:00:00 2001 From: ZhilkinSerg Date: Thu, 11 Jul 2019 12:52:29 +0300 Subject: [PATCH 11/11] Removed redundant parentheses --- src/event.cpp | 4 ++-- src/grab.cpp | 4 ++-- src/help.cpp | 2 +- src/iuse_software_snake.cpp | 4 ++-- src/mutation_data.cpp | 2 +- src/mutation_ui.cpp | 8 +++---- src/vehicle_display.cpp | 8 +++---- src/vehicle_part.cpp | 6 ++--- src/weather.cpp | 44 ++++++++++++++++++------------------- 9 files changed, 41 insertions(+), 41 deletions(-) diff --git a/src/event.cpp b/src/event.cpp index c459f57c4873d..87dd8e175e934 100644 --- a/src/event.cpp +++ b/src/event.cpp @@ -53,8 +53,8 @@ void event::actualize() g->u.add_memorial_log( pgettext( "memorial_male", "Became wanted by the police!" ), pgettext( "memorial_female", "Became wanted by the police!" ) ); - int robx = ( u_pos.x > map_point.x ? 0 - SEEX * 2 : SEEX * 4 ); - int roby = ( u_pos.y > map_point.y ? 0 - SEEY * 2 : SEEY * 4 ); + int robx = u_pos.x > map_point.x ? 0 - SEEX * 2 : SEEX * 4; + int roby = u_pos.y > map_point.y ? 0 - SEEY * 2 : SEEY * 4; g->summon_mon( robot_type, tripoint( robx, roby, g->u.posz() ) ); } } diff --git a/src/grab.cpp b/src/grab.cpp index 3fb1c046b1042..00ab4a19149ae 100644 --- a/src/grab.cpp +++ b/src/grab.cpp @@ -62,8 +62,8 @@ bool game::grabbed_veh_move( const tripoint &dp ) next_grab.x != 0 && next_grab.y != 0 ) { // Zig-zag (or semi-zig-zag) pull: player is diagonal to vehicle // and moves away from it, but not directly away - dp_veh.x = ( dp.x == -dp_veh.x ) ? 0 : dp_veh.x; - dp_veh.y = ( dp.y == -dp_veh.y ) ? 0 : dp_veh.y; + dp_veh.x = dp.x == -dp_veh.x ? 0 : dp_veh.x; + dp_veh.y = dp.y == -dp_veh.y ? 0 : dp_veh.y; next_grab = -dp_veh; zigzag = true; diff --git a/src/help.cpp b/src/help.cpp index bfb6c69239c7f..c9b9cbc6688b0 100644 --- a/src/help.cpp +++ b/src/help.cpp @@ -107,7 +107,7 @@ Press ESC to return to the game." ) ) + 1; second_column = std::max( second_column, utf8_width( cat_name ) + 4 ); } - shortcut_print( win, y + i % half_size, ( i < half_size ? 1 : second_column ), + shortcut_print( win, y + i % half_size, i < half_size ? 1 : second_column, c_white, c_light_blue, cat_name ); } diff --git a/src/iuse_software_snake.cpp b/src/iuse_software_snake.cpp index 02b478d8ab3ce..bb74998b71a5d 100644 --- a/src/iuse_software_snake.cpp +++ b/src/iuse_software_snake.cpp @@ -86,8 +86,8 @@ int snake_game::start_game() std::vector > vSnakeBody; std::map > mSnakeBody; - int iOffsetX = ( TERMX > FULL_SCREEN_WIDTH ) ? ( TERMX - FULL_SCREEN_WIDTH ) / 2 : 0; - int iOffsetY = ( TERMY > FULL_SCREEN_HEIGHT ) ? ( TERMY - FULL_SCREEN_HEIGHT ) / 2 : 0; + int iOffsetX = TERMX > FULL_SCREEN_WIDTH ? ( TERMX - FULL_SCREEN_WIDTH ) / 2 : 0; + int iOffsetY = TERMY > FULL_SCREEN_HEIGHT ? ( TERMY - FULL_SCREEN_HEIGHT ) / 2 : 0; catacurses::window w_snake = catacurses::newwin( FULL_SCREEN_HEIGHT, FULL_SCREEN_WIDTH, iOffsetY, iOffsetX ); diff --git a/src/mutation_data.cpp b/src/mutation_data.cpp index 864afad68474f..6f9c98b64db39 100644 --- a/src/mutation_data.cpp +++ b/src/mutation_data.cpp @@ -748,7 +748,7 @@ void mutation_branch::add_entry( Trait_group &tg, JsonObject &obj ) std::shared_ptr mutation_branch::get_group( const trait_group::Trait_group_tag &gid ) { auto found = trait_groups.find( gid ); - return ( found != trait_groups.end() ) ? found->second : nullptr; + return found != trait_groups.end() ? found->second : nullptr; } std::vector mutation_branch::get_all_group_names() diff --git a/src/mutation_ui.cpp b/src/mutation_ui.cpp index f56ea5e7cc556..61deee6f1f59a 100644 --- a/src/mutation_ui.cpp +++ b/src/mutation_ui.cpp @@ -145,7 +145,7 @@ void player::power_mutations() // drawing the mutation starts with mutation[scroll_position] const int list_start_y = HEADER_LINE_Y + 2 - scroll_position; int max_scroll_position = HEADER_LINE_Y + 2 + mutations_count - - ( ( menu_mode == "examining" ) ? DESCRIPTION_LINE_Y : ( HEIGHT - 1 ) ); + ( menu_mode == "examining" ? DESCRIPTION_LINE_Y : HEIGHT - 1 ); if( redraw ) { redraw = false; @@ -175,7 +175,7 @@ void player::power_mutations() ( menu_mode == "examining" ? DESCRIPTION_LINE_Y : HEIGHT - 1 ) ) { break; } - type = ( has_base_trait( passive[i] ) ? c_cyan : c_light_cyan ); + type = has_base_trait( passive[i] ) ? c_cyan : c_light_cyan; mvwprintz( wBio, list_start_y + i, 2, type, "%c %s", td.key, md.name() ); } } @@ -191,9 +191,9 @@ void player::power_mutations() break; } if( td.powered ) { - type = ( has_base_trait( active[i] ) ? c_green : c_light_green ); + type = has_base_trait( active[i] ) ? c_green : c_light_green; } else { - type = ( has_base_trait( active[i] ) ? c_red : c_light_red ); + type = has_base_trait( active[i] ) ? c_red : c_light_red; } // TODO: track resource(s) used and specify mvwputch( wBio, list_start_y + i, second_column, type, td.key ); diff --git a/src/vehicle_display.cpp b/src/vehicle_display.cpp index 71e89b47d56c2..f135e2151267d 100644 --- a/src/vehicle_display.cpp +++ b/src/vehicle_display.cpp @@ -303,7 +303,7 @@ std::vector vehicle::get_printable_fuel_types() const { std::set opts; for( const auto &pt : parts ) { - if( ( pt.is_fuel_store() ) && pt.ammo_current() != "null" ) { + if( pt.is_fuel_store() && pt.ammo_current() != "null" ) { opts.emplace( pt.ammo_current() ); } } @@ -351,7 +351,7 @@ void vehicle::print_fuel_indicators( const catacurses::window &win, int y, int x } int yofs = 0; - int max_gauge = ( ( isHorizontal ) ? 12 : 5 ) + start_index; + int max_gauge = ( isHorizontal ? 12 : 5 ) + start_index; int max_size = std::min( static_cast( fuels.size() ), max_gauge ); std::map fuel_usages = fuel_usage(); @@ -362,7 +362,7 @@ void vehicle::print_fuel_indicators( const catacurses::window &win, int y, int x } // check if the current index is less than the max size minus 12 or 5, to indicate that there's more - if( ( start_index < static_cast( fuels.size() ) - ( ( isHorizontal ) ? 12 : 5 ) ) ) { + if( start_index < static_cast( fuels.size() ) - ( isHorizontal ? 12 : 5 ) ) { mvwprintz( win, y + yofs, x, c_light_green, ">" ); wprintz( win, c_light_gray, " for more" ); } @@ -403,7 +403,7 @@ void vehicle::print_fuel_indicator( const catacurses::window &win, int y, int x, if( debug_mode ) { mvwprintz( win, y, x + 6, f_color, "%d/%d", f_left, cap ); } else { - mvwprintz( win, y, x + 6, f_color, "%d", ( f_left * 100 ) / cap ); + mvwprintz( win, y, x + 6, f_color, "%d", f_left * 100 / cap ); wprintz( win, c_light_gray, "%c", 045 ); } } diff --git a/src/vehicle_part.cpp b/src/vehicle_part.cpp index fb84ec8470c7c..88ac5d6930ea8 100644 --- a/src/vehicle_part.cpp +++ b/src/vehicle_part.cpp @@ -95,7 +95,7 @@ std::string vehicle_part::name( bool with_prefix ) const } if( base.is_faulty() ) { - res += ( _( " (faulty)" ) ); + res += _( " (faulty)" ); } if( base.has_var( "contained_name" ) ) { @@ -113,7 +113,7 @@ int vehicle_part::hp() const { const int dur = info().durability; if( base.max_damage() > 0 ) { - return dur - ( dur * base.damage() / base.max_damage() ); + return dur - dur * base.damage() / base.max_damage(); } else { return dur; } @@ -131,7 +131,7 @@ int vehicle_part::damage_level( int max ) const double vehicle_part::health_percent() const { - return ( 1.0 - static_cast( base.damage() ) / base.max_damage() ); + return 1.0 - static_cast( base.damage() ) / base.max_damage(); } double vehicle_part::damage_percent() const diff --git a/src/weather.cpp b/src/weather.cpp index 49c2ad4fbd72b..dcc05e67ccbe7 100644 --- a/src/weather.cpp +++ b/src/weather.cpp @@ -240,7 +240,7 @@ void item::add_rain_to_container( bool acid, int charges ) // The container has water, and the acid rain didn't turn it // into weak acid. Poison the water instead, assuming 1 // charge of acid would act like a charge of water with poison 5. - int total_poison = liq.poison * ( orig ) + ( 5 * added ); + int total_poison = liq.poison * orig + 5 * added; liq.poison = total_poison / liq.charges; int leftover_poison = total_poison - liq.poison * liq.charges; if( leftover_poison > rng( 0, liq.charges ) ) { @@ -711,8 +711,8 @@ int get_local_windchill( double temperature, double humidity, double windpower ) // Temperature is removed at the end, because get_local_windchill is meant to calculate the difference. // Source : http://en.wikipedia.org/wiki/Wind_chill#North_American_and_United_Kingdom_wind_chill_index - windchill = 35.74 + 0.6215 * tmptemp - 35.75 * ( pow( tmpwind, - 0.16 ) ) + 0.4275 * tmptemp * ( pow( tmpwind, 0.16 ) ) - tmptemp; + windchill = 35.74 + 0.6215 * tmptemp - 35.75 * pow( tmpwind, + 0.16 ) + 0.4275 * tmptemp * pow( tmpwind, 0.16 ) - tmptemp; if( tmpwind < 4 ) { windchill = 0; // This model fails when there is 0 wind. } @@ -723,8 +723,8 @@ int get_local_windchill( double temperature, double humidity, double windpower ) tmpwind = tmpwind * 0.44704; // Convert to meters per second. tmptemp = temp_to_celsius( tmptemp ); - windchill = ( 0.33 * ( ( humidity / 100.00 ) * 6.105 * exp( ( 17.27 * tmptemp ) / - ( 237.70 + tmptemp ) ) ) - 0.70 * tmpwind - 4.00 ); + windchill = 0.33 * ( humidity / 100.00 * 6.105 * exp( 17.27 * tmptemp / + ( 237.70 + tmptemp ) ) ) - 0.70 * tmpwind - 4.00; // Convert to Fahrenheit, but omit the '+ 32' because we are only dealing with a piece of the felt air temperature equation. windchill = windchill * 9 / 5; } @@ -770,21 +770,21 @@ std::string get_shortdirstring( int angle ) std::string dirstring; int dirangle = angle; if( dirangle <= 23 || dirangle > 338 ) { - dirstring = ( "N" ); + dirstring = "N"; } else if( dirangle <= 68 && dirangle > 23 ) { - dirstring = ( "NE" ); + dirstring = "NE"; } else if( dirangle <= 113 && dirangle > 68 ) { - dirstring = ( "E" ); + dirstring = "E"; } else if( dirangle <= 158 && dirangle > 113 ) { - dirstring = ( "SE" ); + dirstring = "SE"; } else if( dirangle <= 203 && dirangle > 158 ) { - dirstring = ( "S" ); + dirstring = "S"; } else if( dirangle <= 248 && dirangle > 203 ) { - dirstring = ( "SW" ); + dirstring = "SW"; } else if( dirangle <= 293 && dirangle > 248 ) { - dirstring = ( "W" ); + dirstring = "W"; } else if( dirangle <= 338 && dirangle > 293 ) { - dirstring = ( "NW" ); + dirstring = "NW"; } return dirstring; } @@ -795,21 +795,21 @@ std::string get_dirstring( int angle ) std::string dirstring; int dirangle = angle; if( dirangle <= 23 || dirangle > 338 ) { - dirstring = ( "North" ); + dirstring = "North"; } else if( dirangle <= 68 && dirangle > 23 ) { - dirstring = ( "North-East" ); + dirstring = "North-East"; } else if( dirangle <= 113 && dirangle > 68 ) { - dirstring = ( "East" ); + dirstring = "East"; } else if( dirangle <= 158 && dirangle > 113 ) { - dirstring = ( "South-East" ); + dirstring = "South-East"; } else if( dirangle <= 203 && dirangle > 158 ) { - dirstring = ( "South" ); + dirstring = "South"; } else if( dirangle <= 248 && dirangle > 203 ) { - dirstring = ( "South-West" ); + dirstring = "South-West"; } else if( dirangle <= 293 && dirangle > 248 ) { - dirstring = ( "West" ); + dirstring = "West"; } else if( dirangle <= 338 && dirangle > 293 ) { - dirstring = ( "North-West" ); + dirstring = "North-West"; } return dirstring; } @@ -1028,7 +1028,7 @@ int weather_manager::get_temperature( const tripoint &location ) } //underground temperature = average New England temperature = 43F/6C rounded to int const int temp = ( location.z < 0 ? AVERAGE_ANNUAL_TEMPERATURE : temperature ) + - ( g->new_game ? 0 : ( g->m.get_temperature( location ) + temp_mod ) ); + ( g->new_game ? 0 : g->m.get_temperature( location ) + temp_mod ); temperature_cache.emplace( std::make_pair( location, temp ) ); return temp;