From 0a5e99b5285265a8e95bcd77048bf3608373a11c Mon Sep 17 00:00:00 2001 From: Fris0uman Date: Thu, 31 Oct 2019 18:57:43 +0100 Subject: [PATCH 01/11] bionic_tags --- src/bionics.cpp | 37 ++++++++++++++++++++++++++++++ src/bionics.h | 60 +++++++++++++++++++++++++++---------------------- 2 files changed, 70 insertions(+), 27 deletions(-) diff --git a/src/bionics.cpp b/src/bionics.cpp index 215c89a2a83f1..be6c01a39d2c9 100644 --- a/src/bionics.cpp +++ b/src/bionics.cpp @@ -2264,6 +2264,25 @@ void finalize_bionics() } } +void bionic::set_flag( const std::string flag ) +{ + if( !has_flag( flag ) ) { + bionic_tags.insert( flag ); + } +} + +void bionic::remove_flag( const std::string flag ) +{ + if( has_flag( flag ) ) { + bionic_tags.erase( flag ); + } +} + +bool bionic::has_flag( const std::string flag ) const +{ + return bionic_tags.find( flag ) != bionic_tags.end(); +} + int bionic::get_quality( const quality_id &quality ) const { const auto &i = info(); @@ -2280,6 +2299,15 @@ bool bionic::is_this_fuel_powered( const itype_id this_fuel ) const return std::find( fuel_op.begin(), fuel_op.end(), this_fuel ) != fuel_op.end(); } +void bionic::toggle_safe_fuel_mod() +{ + if( !has_flag( "SAFE_FUEL_ON" ) ) { + set_flag( "SAFE_FUEL_ON" ); + } else { + remove_flag( "SAFE_FUEL_ON" ); + } +} + void bionic::serialize( JsonOut &json ) const { json.start_object(); @@ -2289,6 +2317,7 @@ void bionic::serialize( JsonOut &json ) const json.member( "charge", charge_timer ); json.member( "ammo_loaded", ammo_loaded ); json.member( "ammo_count", ammo_count ); + json.member( "bionic_tags", bionic_tags ); if( incapacitated_time > 0_turns ) { json.member( "incapacitated_time", incapacitated_time ); } @@ -2311,6 +2340,14 @@ void bionic::deserialize( JsonIn &jsin ) if( jo.has_int( "incapacitated_time" ) ) { incapacitated_time = 1_turns * jo.get_int( "incapacitated_time" ); } + if( jo.has_array( "bionic_tags" ) ) { + JsonArray jsar = jo.get_array( "bionic_tags" ); + while( jsar.has_more() ) { + JsonArray ja = jsar.next_array(); + bionic_tags.insert( ja.get_string( 0 ) ); + } + } + } void player::introduce_into_anesthesia( const time_duration &duration, player &installer, diff --git a/src/bionics.h b/src/bionics.h index 8e29f5ced5110..eca87b41c7943 100644 --- a/src/bionics.h +++ b/src/bionics.h @@ -136,33 +136,39 @@ struct bionic_data { }; struct bionic { - bionic_id id; - int charge_timer = 0; - char invlet = 'a'; - bool powered = false; - /* Ammunition actually loaded in this bionic gun in deactivated state */ - itype_id ammo_loaded = "null"; - /* Ammount of ammo actually held inside by this bionic gun in deactivated state */ - unsigned int ammo_count = 0; - /* An amount of time during which this bionic has been rendered inoperative. */ - time_duration incapacitated_time; - - bionic() - : id( "bio_batteries" ), incapacitated_time( 0_turns ) { - } - bionic( bionic_id pid, char pinvlet ) - : id( std::move( pid ) ), invlet( pinvlet ), incapacitated_time( 0_turns ) { } - - const bionic_data &info() const { - return *id; - } - - int get_quality( const quality_id &quality ) const; - - bool is_this_fuel_powered( const itype_id this_fuel ) const; - - void serialize( JsonOut &json ) const; - void deserialize( JsonIn &jsin ); + bionic_id id; + int charge_timer = 0; + char invlet = 'a'; + bool powered = false; + /* Ammunition actually loaded in this bionic gun in deactivated state */ + itype_id ammo_loaded = "null"; + /* Ammount of ammo actually held inside by this bionic gun in deactivated state */ + unsigned int ammo_count = 0; + /* An amount of time during which this bionic has been rendered inoperative. */ + time_duration incapacitated_time; + bionic() + : id( "bio_batteries" ), incapacitated_time( 0_turns ) { + } + bionic( bionic_id pid, char pinvlet ) + : id( std::move( pid ) ), invlet( pinvlet ), incapacitated_time( 0_turns ) { } + + const bionic_data &info() const { + return *id; + } + + void set_flag( const std::string flag ); + void remove_flag( const std::string flag ); + bool has_flag( const std::string flag ) const ; + + int get_quality( const quality_id &quality ) const; + + bool is_this_fuel_powered( const itype_id this_fuel ) const; + void toggle_safe_fuel_mod(); + + void serialize( JsonOut &json ) const; + void deserialize( JsonIn &jsin ); + private: + cata::flat_set bionic_tags; // generic bionic specific flags }; // A simpler wrapper to allow forward declarations of it. std::vector can not From e0b16572a27a5e911167596e79fdf630149764c8 Mon Sep 17 00:00:00 2001 From: Fris0uman Date: Thu, 31 Oct 2019 20:35:03 +0100 Subject: [PATCH 02/11] safe fuel mod --- data/raw/keybindings.json | 7 +++++++ src/bionics.cpp | 9 ++++++--- src/bionics_ui.cpp | 30 +++++++++++++++++++++++++++--- 3 files changed, 40 insertions(+), 6 deletions(-) diff --git a/data/raw/keybindings.json b/data/raw/keybindings.json index ae5082e0a6984..44df0239da8d4 100644 --- a/data/raw/keybindings.json +++ b/data/raw/keybindings.json @@ -1410,6 +1410,13 @@ "name": "Toggle activate/examine", "bindings": [ { "input_method": "keyboard", "key": "!" } ] }, + { + "type": "keybinding", + "id": "TOGGLE_SAFE_FUEL", + "category": "BIONICS", + "name": "Toggle safe fuel mod", + "bindings": [ { "input_method": "keyboard", "key": "s" } ] + }, { "type": "keybinding", "id": "TOGGLE_EXAMINE", diff --git a/src/bionics.cpp b/src/bionics.cpp index be6c01a39d2c9..864bed8a380c3 100644 --- a/src/bionics.cpp +++ b/src/bionics.cpp @@ -854,7 +854,8 @@ bool player::burn_fuel( int b, bool start ) current_fuel_stock = std::stoi( get_value( fuel ) ); } - if( get_power_level() + units::from_kilojoule( fuel_energy ) * fuel_efficiency + if( bio.has_flag( "SAFE_FUEL_ON" ) && + get_power_level() + units::from_kilojoule( fuel_energy ) * fuel_efficiency > get_max_power_level() ) { add_msg_player_or_npc( m_info, _( "Your %s turns off to not waste fuel." ), _( "'s %s turns off to not waste fuel." ), bio.info().name ); @@ -2301,6 +2302,9 @@ bool bionic::is_this_fuel_powered( const itype_id this_fuel ) const void bionic::toggle_safe_fuel_mod() { + if( !info().power_source ) { + return; + } if( !has_flag( "SAFE_FUEL_ON" ) ) { set_flag( "SAFE_FUEL_ON" ); } else { @@ -2343,8 +2347,7 @@ void bionic::deserialize( JsonIn &jsin ) if( jo.has_array( "bionic_tags" ) ) { JsonArray jsar = jo.get_array( "bionic_tags" ); while( jsar.has_more() ) { - JsonArray ja = jsar.next_array(); - bionic_tags.insert( ja.get_string( 0 ) ); + bionic_tags.insert( jsar.next_string() ); } } diff --git a/src/bionics_ui.cpp b/src/bionics_ui.cpp index f41d7e49576d7..65606af4822b7 100644 --- a/src/bionics_ui.cpp +++ b/src/bionics_ui.cpp @@ -71,6 +71,7 @@ static void draw_bionics_titlebar( const catacurses::window &window, player *p, fuel ) << "" << "/" << p->get_total_fuel_capacity( fuel ) << " "; } } + std::string fuel_string = fuel_stream.str(); std::string power_string; const int curr_power = units::to_millijoule( p->get_power_level() ); const int kilo = curr_power / units::to_millijoule( 1_kJ ); @@ -98,14 +99,15 @@ static void draw_bionics_titlebar( const catacurses::window &window, player *p, std::string desc; if( mode == REASSIGNING ) { desc = _( "Reassigning.\nSelect a bionic to reassign or press SPACE to cancel." ); + fuel_string.clear(); } else if( mode == ACTIVATING ) { - desc = _( "Activating ! to examine, = to reassign, TAB to switch tabs." ); + desc = _( "Activating ! to examine, = to reassign, TAB to switch tabs, s to toggle safe fuel mod." ); } else if( mode == EXAMINING ) { - desc = _( "Examining ! to activate, = to reassign, TAB to switch tabs." ); + desc = _( "Examining ! to activate, = to reassign, TAB to switch tabs, s to toggle safe fuel mod." ); } int n_pt_y = 0; fold_and_print( window, point( 1, n_pt_y++ ), pwr_str_pos, c_white, desc ); - fold_and_print( window, point( 1, n_pt_y++ ), pwr_str_pos, c_white, fuel_stream.str() ); + fold_and_print( window, point( 1, n_pt_y++ ), pwr_str_pos, c_white, fuel_string ); wrefresh( window ); } @@ -135,6 +137,9 @@ static std::string build_bionic_poweronly_string( const bionic &bio ) if( bio.incapacitated_time > 0_turns ) { properties.push_back( _( "(incapacitated)" ) ); } + if( bio.has_flag( "SAFE_FUEL_ON" ) ) { + properties.push_back( _( "(safe fuel mod ON)" ) ); + } return enumerate_as_string( properties, enumeration_conjunction::none ); } @@ -405,6 +410,7 @@ void player::power_bionics() ctxt.register_action( "PREV_TAB" ); ctxt.register_action( "CONFIRM" ); ctxt.register_action( "HELP_KEYBINDINGS" ); + ctxt.register_action( "TOGGLE_SAFE_FUEL" ); bool recalc = false; bool redraw = true; @@ -520,6 +526,7 @@ void player::power_bionics() const int ch = ctxt.get_raw_input().get_first_input(); bionic *tmp = nullptr; bool confirmCheck = false; + bool toggle_safe_fuel = false; if( action == "DOWN" ) { redraw = true; @@ -611,6 +618,8 @@ void player::power_bionics() } else if( action == "TOGGLE_EXAMINE" ) { // switches between activation and examination menu_mode = menu_mode == ACTIVATING ? EXAMINING : ACTIVATING; redraw = true; + } else if( action == "TOGGLE_SAFE_FUEL" ) { + toggle_safe_fuel = true; } else if( action == "HELP_KEYBINDINGS" ) { redraw = true; } else if( action == "CONFIRM" ) { @@ -618,6 +627,21 @@ void player::power_bionics() } else { confirmCheck = true; } + + if( toggle_safe_fuel ) { + auto &bio_list = tab_mode == TAB_ACTIVE ? active : passive; + if( action == "TOGGLE_SAFE_FUEL" && !current_bionic_list->empty() ) { + tmp = bio_list[cursor]; + if( tmp->info().power_source ) { + tmp->toggle_safe_fuel_mod(); + g->refresh_all(); + redraw = true; + } else { + popup( _( "You can't toggle safe fuel mod on a non fueled CBM" ) ); + } + + } + } //confirmation either occurred by pressing enter where the bionic cursor is, or the hotkey was selected if( confirmCheck ) { auto &bio_list = tab_mode == TAB_ACTIVE ? active : passive; From b1f60570cc587e1e64af05dddc63df986487c437 Mon Sep 17 00:00:00 2001 From: Fris0uman Date: Thu, 31 Oct 2019 20:58:59 +0100 Subject: [PATCH 03/11] small menu fix --- src/bionics_ui.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/bionics_ui.cpp b/src/bionics_ui.cpp index 65606af4822b7..b62812c22afb6 100644 --- a/src/bionics_ui.cpp +++ b/src/bionics_ui.cpp @@ -60,11 +60,14 @@ static void draw_bionics_titlebar( const catacurses::window &window, player *p, { werase( window ); std::ostringstream fuel_stream; + bool fuel_available = false; fuel_stream << _( "Available Fuel: " ); for( const bionic &bio : *p->my_bionics ) { for( const itype_id fuel : p->get_fuel_available( bio.id ) ) { - const item temp_fuel( fuel ) ; + fuel_available = true; + const item temp_fuel( fuel ); if( temp_fuel.has_flag( "PERPETUAL" ) ) { + fuel_stream << "" << temp_fuel.tname() << ""; continue; } fuel_stream << temp_fuel.tname() << ": " << "" << p->get_value( @@ -72,6 +75,9 @@ static void draw_bionics_titlebar( const catacurses::window &window, player *p, } } std::string fuel_string = fuel_stream.str(); + if( !fuel_available ) { + fuel_string.clear(); + } std::string power_string; const int curr_power = units::to_millijoule( p->get_power_level() ); const int kilo = curr_power / units::to_millijoule( 1_kJ ); From 66b6e4484ac54e25637df06efc2d2ef9f0392a08 Mon Sep 17 00:00:00 2001 From: Fris0uman Date: Fri, 1 Nov 2019 10:55:23 +0100 Subject: [PATCH 04/11] fuel saving mod is ON by defautl --- src/bionics.cpp | 8 ++++---- src/bionics.h | 2 +- src/bionics_ui.cpp | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/bionics.cpp b/src/bionics.cpp index 5e7bafe6fa46f..ef9239f2bea1d 100644 --- a/src/bionics.cpp +++ b/src/bionics.cpp @@ -854,7 +854,7 @@ bool player::burn_fuel( int b, bool start ) current_fuel_stock = std::stoi( get_value( fuel ) ); } - if( bio.has_flag( "SAFE_FUEL_ON" ) && + if( !bio.has_flag( "SAFE_FUEL_OFF" ) && get_power_level() + units::from_kilojoule( fuel_energy ) * fuel_efficiency > get_max_power_level() ) { add_msg_player_or_npc( m_info, _( "Your %s turns off to not waste fuel." ), @@ -2305,10 +2305,10 @@ void bionic::toggle_safe_fuel_mod() if( !info().power_source ) { return; } - if( !has_flag( "SAFE_FUEL_ON" ) ) { - set_flag( "SAFE_FUEL_ON" ); + if( !has_flag( "SAFE_FUEL_OFF" ) ) { + set_flag( "SAFE_FUEL_OFF" ); } else { - remove_flag( "SAFE_FUEL_ON" ); + remove_flag( "SAFE_FUEL_OFF" ); } } diff --git a/src/bionics.h b/src/bionics.h index eca87b41c7943..59c4c8bb7563a 100644 --- a/src/bionics.h +++ b/src/bionics.h @@ -162,7 +162,7 @@ struct bionic { int get_quality( const quality_id &quality ) const; - bool is_this_fuel_powered( const itype_id this_fuel ) const; + bool is_this_fuel_powered( const itype_id &this_fuel ) const; void toggle_safe_fuel_mod(); void serialize( JsonOut &json ) const; diff --git a/src/bionics_ui.cpp b/src/bionics_ui.cpp index b62812c22afb6..dbb55af0626e5 100644 --- a/src/bionics_ui.cpp +++ b/src/bionics_ui.cpp @@ -107,9 +107,9 @@ static void draw_bionics_titlebar( const catacurses::window &window, player *p, desc = _( "Reassigning.\nSelect a bionic to reassign or press SPACE to cancel." ); fuel_string.clear(); } else if( mode == ACTIVATING ) { - desc = _( "Activating ! to examine, = to reassign, TAB to switch tabs, s to toggle safe fuel mod." ); + desc = _( "Activating ! to examine, = to reassign, TAB to switch tabs, s to toggle fuel saving mod." ); } else if( mode == EXAMINING ) { - desc = _( "Examining ! to activate, = to reassign, TAB to switch tabs, s to toggle safe fuel mod." ); + desc = _( "Examining ! to activate, = to reassign, TAB to switch tabs, s to toggle fuel saving mod." ); } int n_pt_y = 0; fold_and_print( window, point( 1, n_pt_y++ ), pwr_str_pos, c_white, desc ); @@ -143,8 +143,8 @@ static std::string build_bionic_poweronly_string( const bionic &bio ) if( bio.incapacitated_time > 0_turns ) { properties.push_back( _( "(incapacitated)" ) ); } - if( bio.has_flag( "SAFE_FUEL_ON" ) ) { - properties.push_back( _( "(safe fuel mod ON)" ) ); + if( !bio.has_flag( "SAFE_FUEL_OFF" ) && bio.info().power_source ) { + properties.push_back( _( "(fuel saving mod ON)" ) ); } return enumerate_as_string( properties, enumeration_conjunction::none ); From 0587ed17af1ad395f05e4b24d4e6bee829b3f3a6 Mon Sep 17 00:00:00 2001 From: Fris0uman Date: Fri, 1 Nov 2019 11:03:19 +0100 Subject: [PATCH 05/11] revert menu tweak to move them to their own PR --- src/bionics_ui.cpp | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/bionics_ui.cpp b/src/bionics_ui.cpp index dbb55af0626e5..b96538b6538a4 100644 --- a/src/bionics_ui.cpp +++ b/src/bionics_ui.cpp @@ -60,24 +60,17 @@ static void draw_bionics_titlebar( const catacurses::window &window, player *p, { werase( window ); std::ostringstream fuel_stream; - bool fuel_available = false; fuel_stream << _( "Available Fuel: " ); for( const bionic &bio : *p->my_bionics ) { for( const itype_id fuel : p->get_fuel_available( bio.id ) ) { - fuel_available = true; const item temp_fuel( fuel ); if( temp_fuel.has_flag( "PERPETUAL" ) ) { - fuel_stream << "" << temp_fuel.tname() << ""; continue; } fuel_stream << temp_fuel.tname() << ": " << "" << p->get_value( fuel ) << "" << "/" << p->get_total_fuel_capacity( fuel ) << " "; } } - std::string fuel_string = fuel_stream.str(); - if( !fuel_available ) { - fuel_string.clear(); - } std::string power_string; const int curr_power = units::to_millijoule( p->get_power_level() ); const int kilo = curr_power / units::to_millijoule( 1_kJ ); @@ -105,7 +98,6 @@ static void draw_bionics_titlebar( const catacurses::window &window, player *p, std::string desc; if( mode == REASSIGNING ) { desc = _( "Reassigning.\nSelect a bionic to reassign or press SPACE to cancel." ); - fuel_string.clear(); } else if( mode == ACTIVATING ) { desc = _( "Activating ! to examine, = to reassign, TAB to switch tabs, s to toggle fuel saving mod." ); } else if( mode == EXAMINING ) { @@ -113,7 +105,7 @@ static void draw_bionics_titlebar( const catacurses::window &window, player *p, } int n_pt_y = 0; fold_and_print( window, point( 1, n_pt_y++ ), pwr_str_pos, c_white, desc ); - fold_and_print( window, point( 1, n_pt_y++ ), pwr_str_pos, c_white, fuel_string ); + fold_and_print( window, point( 1, n_pt_y++ ), pwr_str_pos, c_white, fuel_stream.str() ); wrefresh( window ); } From a67940e2a632da16b5cc9856119c4eb3d216ac5f Mon Sep 17 00:00:00 2001 From: Fris0uman Date: Fri, 1 Nov 2019 11:04:52 +0100 Subject: [PATCH 06/11] fuel saving mod --- src/bionics_ui.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bionics_ui.cpp b/src/bionics_ui.cpp index b96538b6538a4..520933eaaf725 100644 --- a/src/bionics_ui.cpp +++ b/src/bionics_ui.cpp @@ -635,7 +635,7 @@ void player::power_bionics() g->refresh_all(); redraw = true; } else { - popup( _( "You can't toggle safe fuel mod on a non fueled CBM" ) ); + popup( _( "You can't toggle fuel saving mod on a non fueled CBM" ) ); } } From 444d9a2a613a361661c073c3fd80cf0e8162c901 Mon Sep 17 00:00:00 2001 From: Fris0uman Date: Fri, 1 Nov 2019 11:11:27 +0100 Subject: [PATCH 07/11] typo --- src/bionics_ui.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/bionics_ui.cpp b/src/bionics_ui.cpp index 520933eaaf725..95e0579cb78d2 100644 --- a/src/bionics_ui.cpp +++ b/src/bionics_ui.cpp @@ -99,9 +99,9 @@ static void draw_bionics_titlebar( const catacurses::window &window, player *p, if( mode == REASSIGNING ) { desc = _( "Reassigning.\nSelect a bionic to reassign or press SPACE to cancel." ); } else if( mode == ACTIVATING ) { - desc = _( "Activating ! to examine, = to reassign, TAB to switch tabs, s to toggle fuel saving mod." ); + desc = _( "Activating ! to examine, = to reassign, TAB to switch tabs, s to toggle fuel saving mode." ); } else if( mode == EXAMINING ) { - desc = _( "Examining ! to activate, = to reassign, TAB to switch tabs, s to toggle fuel saving mod." ); + desc = _( "Examining ! to activate, = to reassign, TAB to switch tabs, s to toggle fuel saving mode." ); } int n_pt_y = 0; fold_and_print( window, point( 1, n_pt_y++ ), pwr_str_pos, c_white, desc ); @@ -136,7 +136,7 @@ static std::string build_bionic_poweronly_string( const bionic &bio ) properties.push_back( _( "(incapacitated)" ) ); } if( !bio.has_flag( "SAFE_FUEL_OFF" ) && bio.info().power_source ) { - properties.push_back( _( "(fuel saving mod ON)" ) ); + properties.push_back( _( "(fuel saving mode ON)" ) ); } return enumerate_as_string( properties, enumeration_conjunction::none ); @@ -635,7 +635,7 @@ void player::power_bionics() g->refresh_all(); redraw = true; } else { - popup( _( "You can't toggle fuel saving mod on a non fueled CBM" ) ); + popup( _( "You can't toggle fuel saving mode on a non fueled CBM" ) ); } } From 3cdf431dd1ca1cc21d4f1cfddd38c60d517b7f1d Mon Sep 17 00:00:00 2001 From: Fris0uman Date: Fri, 1 Nov 2019 12:09:14 +0100 Subject: [PATCH 08/11] check for fuel_opts.empty() instead of power_source --- src/bionics.cpp | 2 +- src/bionics_ui.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/bionics.cpp b/src/bionics.cpp index ef9239f2bea1d..7d1b7cd6f3015 100644 --- a/src/bionics.cpp +++ b/src/bionics.cpp @@ -2302,7 +2302,7 @@ bool bionic::is_this_fuel_powered( const itype_id &this_fuel ) const void bionic::toggle_safe_fuel_mod() { - if( !info().power_source ) { + if( info().fuel_opts.empty() ) { return; } if( !has_flag( "SAFE_FUEL_OFF" ) ) { diff --git a/src/bionics_ui.cpp b/src/bionics_ui.cpp index 95e0579cb78d2..985520b3aeb74 100644 --- a/src/bionics_ui.cpp +++ b/src/bionics_ui.cpp @@ -135,7 +135,7 @@ static std::string build_bionic_poweronly_string( const bionic &bio ) if( bio.incapacitated_time > 0_turns ) { properties.push_back( _( "(incapacitated)" ) ); } - if( !bio.has_flag( "SAFE_FUEL_OFF" ) && bio.info().power_source ) { + if( !bio.has_flag( "SAFE_FUEL_OFF" ) && !bio.info().fuel_opts.empty() ) { properties.push_back( _( "(fuel saving mode ON)" ) ); } @@ -630,7 +630,7 @@ void player::power_bionics() auto &bio_list = tab_mode == TAB_ACTIVE ? active : passive; if( action == "TOGGLE_SAFE_FUEL" && !current_bionic_list->empty() ) { tmp = bio_list[cursor]; - if( tmp->info().power_source ) { + if( !tmp->info().fuel_opts.empty() ) { tmp->toggle_safe_fuel_mod(); g->refresh_all(); redraw = true; From 242a30ab4d05f0852ae69118d3a094f93b9944f8 Mon Sep 17 00:00:00 2001 From: Fris0uman Date: Fri, 1 Nov 2019 15:43:37 +0100 Subject: [PATCH 09/11] no const in declaration --- src/bionics.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/bionics.h b/src/bionics.h index 59c4c8bb7563a..0a7b8297f06f0 100644 --- a/src/bionics.h +++ b/src/bionics.h @@ -156,9 +156,9 @@ struct bionic { return *id; } - void set_flag( const std::string flag ); - void remove_flag( const std::string flag ); - bool has_flag( const std::string flag ) const ; + void set_flag( std::string flag ); + void remove_flag( std::string flag ); + bool has_flag( std::string flag ) const ; int get_quality( const quality_id &quality ) const; From 240eb55710d689ad0bb070745d9cd9981c3c5f4d Mon Sep 17 00:00:00 2001 From: Fris0uman Date: Sun, 10 Nov 2019 18:24:11 +0100 Subject: [PATCH 10/11] no check --- src/bionics.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/bionics.cpp b/src/bionics.cpp index 7d1b7cd6f3015..9ffb367cf95e5 100644 --- a/src/bionics.cpp +++ b/src/bionics.cpp @@ -2267,16 +2267,12 @@ void finalize_bionics() void bionic::set_flag( const std::string flag ) { - if( !has_flag( flag ) ) { - bionic_tags.insert( flag ); - } + bionic_tags.insert( flag ); } void bionic::remove_flag( const std::string flag ) { - if( has_flag( flag ) ) { - bionic_tags.erase( flag ); - } + bionic_tags.erase( flag ); } bool bionic::has_flag( const std::string flag ) const From a79e80bf8e197a74ec03a5dc8974d21cd0f460ea Mon Sep 17 00:00:00 2001 From: Fris0uman Date: Sun, 10 Nov 2019 18:25:45 +0100 Subject: [PATCH 11/11] fix --- src/bionics_ui.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bionics_ui.cpp b/src/bionics_ui.cpp index 985520b3aeb74..204120267b5df 100644 --- a/src/bionics_ui.cpp +++ b/src/bionics_ui.cpp @@ -628,14 +628,14 @@ void player::power_bionics() if( toggle_safe_fuel ) { auto &bio_list = tab_mode == TAB_ACTIVE ? active : passive; - if( action == "TOGGLE_SAFE_FUEL" && !current_bionic_list->empty() ) { + if( !current_bionic_list->empty() ) { tmp = bio_list[cursor]; if( !tmp->info().fuel_opts.empty() ) { tmp->toggle_safe_fuel_mod(); g->refresh_all(); redraw = true; } else { - popup( _( "You can't toggle fuel saving mode on a non fueled CBM" ) ); + popup( _( "You can't toggle fuel saving mode on a non fueled CBM." ) ); } }