From a89488a3e28f0e43521dfba5a530dbbfbc6af931 Mon Sep 17 00:00:00 2001 From: Inglonias <2125926+Inglonias@users.noreply.github.com> Date: Sun, 23 Jun 2019 09:45:39 -0400 Subject: [PATCH 1/5] Fixed tools for use with UPS Addec calls to units_sufficient for everything I could find in iuse and iuse_actor that could potentially use batteries. --- src/iuse.cpp | 28 ++++++++++++++-------------- src/iuse_actor.cpp | 6 +++--- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/iuse.cpp b/src/iuse.cpp index 3ab5df19175ef..695eea18c40cf 100644 --- a/src/iuse.cpp +++ b/src/iuse.cpp @@ -2198,7 +2198,7 @@ int iuse::water_purifier( player *p, item *it, bool, const tripoint & ) int iuse::radio_off( player *p, item *it, bool, const tripoint & ) { - if( !it->ammo_sufficient() ) { + if( !it->ammo_sufficient() && !it->units_sufficient( *p ) ) { p->add_msg_if_player( _( "It's dead." ) ); } else { p->add_msg_if_player( _( "You turn the radio on." ) ); @@ -2321,7 +2321,7 @@ int iuse::radio_on( player *p, item *it, bool t, const tripoint &pos ) int iuse::noise_emitter_off( player *p, item *it, bool, const tripoint & ) { - if( !it->ammo_sufficient() ) { + if( !it->ammo_sufficient() && !it->units_sufficient( *p ) ) { p->add_msg_if_player( _( "It's dead." ) ); } else { p->add_msg_if_player( _( "You turn the noise emitter on." ) ); @@ -3895,7 +3895,7 @@ int iuse::portal( player *p, item *it, bool, const tripoint & ) int iuse::tazer( player *p, item *it, bool, const tripoint &pos ) { - if( !it->ammo_sufficient() ) { + if( !it->ammo_sufficient() && !it->units_sufficient( *p ) ) { return 0; } @@ -3988,7 +3988,7 @@ int iuse::shocktonfa_off( player *p, item *it, bool t, const tripoint &pos ) return iuse::tazer2( p, it, t, pos ); } case 1: { - if( !it->ammo_sufficient() ) { + if( !it->ammo_sufficient() && !it->units_sufficient( *p ) ) { p->add_msg_if_player( m_info, _( "The batteries are dead." ) ); return 0; } else { @@ -4006,7 +4006,7 @@ int iuse::shocktonfa_on( player *p, item *it, bool t, const tripoint &pos ) if( t ) { // Effects while simply on } else { - if( !it->ammo_sufficient() ) { + if( !it->ammo_sufficient() && !it->units_sufficient( *p ) ) { p->add_msg_if_player( m_info, _( "Your tactical tonfa is out of power." ) ); it->convert( "shocktonfa_off" ).active = false; } else { @@ -4030,7 +4030,7 @@ int iuse::shocktonfa_on( player *p, item *it, bool t, const tripoint &pos ) int iuse::mp3( player *p, item *it, bool, const tripoint & ) { - if( !it->ammo_sufficient() ) { + if( !it->ammo_sufficient() && !it->units_sufficient( *p ) ) { p->add_msg_if_player( m_info, _( "The device's batteries are dead." ) ); } else if( p->has_active_item( "mp3_on" ) || p->has_active_item( "smartphone_music" ) ) { p->add_msg_if_player( m_info, _( "You are already listening to music!" ) ); @@ -4425,7 +4425,7 @@ int iuse::vibe( player *p, item *it, bool, const tripoint & ) p->add_msg_if_player( m_info, _( "It's waterproof, but oxygen maybe?" ) ); return 0; } - if( !it->ammo_sufficient() ) { + if( !it->ammo_sufficient() && !it->units_sufficient( *p ) ) { p->add_msg_if_player( m_info, _( "The %s's batteries are dead." ), it->tname() ); return 0; } @@ -5356,7 +5356,7 @@ int iuse::heat_food( player *p, item *it, bool, const tripoint & ) int iuse::hotplate( player *p, item *it, bool, const tripoint & ) { - if( it->typeId() != "atomic_coffeepot" && ( !it->ammo_sufficient() ) ) { + if( it->typeId() != "atomic_coffeepot" && ( !it->ammo_sufficient() && !it->units_sufficient( *p )) ) { p->add_msg_if_player( m_info, _( "The %s's batteries are dead." ), it->tname() ); return 0; } @@ -5566,7 +5566,7 @@ int iuse::radglove( player *p, item *it, bool, const tripoint & ) p->add_msg_if_player( m_info, _( "You must wear the radiation biomonitor before you can activate it." ) ); return 0; - } else if( !it->ammo_sufficient() ) { + } else if( !it->ammo_sufficient() && !it->units_sufficient( *p ) ) { p->add_msg_if_player( m_info, _( "The radiation biomonitor needs batteries to function." ) ); return 0; } else { @@ -5620,7 +5620,7 @@ int iuse::contacts( player *p, item *it, bool, const tripoint & ) int iuse::talking_doll( player *p, item *it, bool, const tripoint & ) { - if( !it->ammo_sufficient() ) { + if( !it->ammo_sufficient() && !it->units_sufficient( *p ) ) { p->add_msg_if_player( m_info, _( "The %s's batteries are dead." ), it->tname() ); return 0; } @@ -5887,7 +5887,7 @@ bool iuse::robotcontrol_can_target( player *p, const monster &m ) int iuse::robotcontrol( player *p, item *it, bool, const tripoint & ) { - if( !it->ammo_sufficient() ) { + if( !it->ammo_sufficient() && !it->units_sufficient( *p ) ) { p->add_msg_if_player( _( "The %s's batteries are dead." ), it->tname() ); return 0; @@ -7864,7 +7864,7 @@ static void sendRadioSignal( player &p, const std::string &signal ) int iuse::radiocontrol( player *p, item *it, bool t, const tripoint & ) { if( t ) { - if( !it->ammo_sufficient() ) { + if( !it->ammo_sufficient() && !it->units_sufficient( *p ) ) { it->active = false; p->remove_value( "remote_controlling" ); } else if( p->get_value( "remote_controlling" ).empty() ) { @@ -8043,7 +8043,7 @@ int iuse::remoteveh( player *p, item *it, bool t, const tripoint &pos ) vehicle *remote = g->remoteveh(); if( t ) { bool stop = false; - if( !it->ammo_sufficient() ) { + if( !it->ammo_sufficient() && !it->units_sufficient( *p ) ) { p->add_msg_if_player( m_bad, _( "The remote control's battery goes dead." ) ); stop = true; } else if( remote == nullptr ) { @@ -8178,7 +8178,7 @@ int iuse::multicooker( player *p, item *it, bool t, const tripoint &pos ) static const int charges_to_start = 50; if( t ) { - if( !it->ammo_sufficient() ) { + if( !it->ammo_sufficient() && !it->units_sufficient( *p ) ) { it->active = false; return 0; } diff --git a/src/iuse_actor.cpp b/src/iuse_actor.cpp index c0919a9e87e41..a1ec50130169f 100644 --- a/src/iuse_actor.cpp +++ b/src/iuse_actor.cpp @@ -191,7 +191,7 @@ int iuse_transform::use( player &p, item &it, bool t, const tripoint &pos ) cons p.add_msg_if_player( m_info, _( "You need to wear the %1$s before activating it." ), it.tname() ); return 0; } - if( need_charges && it.ammo_remaining() < need_charges ) { + if( need_charges && it.ammo_remaining() < need_charges && it.units_remaining( p ) < need_charges ) { if( possess ) { p.add_msg_if_player( m_info, need_charges_msg, it.tname() ); } @@ -1718,7 +1718,7 @@ ret_val cauterize_actor::can_use( const player &p, const item &it, bool, _( "You need a source of flame (4 charges worth) before you can cauterize yourself." ) ); } } else { - if( !it.ammo_sufficient() ) { + if( !it.ammo_sufficient() && !it.units_sufficient( p ) ) { return ret_val::make_failure( _( "You need at least %d charges to cauterize wounds." ), it.ammo_required() ); } @@ -2740,7 +2740,7 @@ bool repair_item_actor::can_use_tool( const player &p, const item &tool, bool pr } return false; } - if( !tool.ammo_sufficient() ) { + if( !tool.ammo_sufficient() && !tool.units_sufficient( p ) ) { if( print_msg ) { p.add_msg_if_player( m_info, _( "Your tool does not have enough charges to do that." ) ); } From 182e35441b1fb9d7c1971e0c9db60d5ad0a38ef9 Mon Sep 17 00:00:00 2001 From: Inglonias <2125926+Inglonias@users.noreply.github.com> Date: Sun, 23 Jun 2019 09:56:16 -0400 Subject: [PATCH 2/5] Astyled --- src/iuse.cpp | 24 ++++++++++++------------ src/iuse_actor.cpp | 6 +++--- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/iuse.cpp b/src/iuse.cpp index 695eea18c40cf..262a7d5edcf30 100644 --- a/src/iuse.cpp +++ b/src/iuse.cpp @@ -2198,7 +2198,7 @@ int iuse::water_purifier( player *p, item *it, bool, const tripoint & ) int iuse::radio_off( player *p, item *it, bool, const tripoint & ) { - if( !it->ammo_sufficient() && !it->units_sufficient( *p ) ) { + if ( !it->ammo_sufficient() && !it->units_sufficient( *p ) ) { p->add_msg_if_player( _( "It's dead." ) ); } else { p->add_msg_if_player( _( "You turn the radio on." ) ); @@ -2321,7 +2321,7 @@ int iuse::radio_on( player *p, item *it, bool t, const tripoint &pos ) int iuse::noise_emitter_off( player *p, item *it, bool, const tripoint & ) { - if( !it->ammo_sufficient() && !it->units_sufficient( *p ) ) { + if ( !it->ammo_sufficient() && !it->units_sufficient( *p ) ) { p->add_msg_if_player( _( "It's dead." ) ); } else { p->add_msg_if_player( _( "You turn the noise emitter on." ) ); @@ -3895,7 +3895,7 @@ int iuse::portal( player *p, item *it, bool, const tripoint & ) int iuse::tazer( player *p, item *it, bool, const tripoint &pos ) { - if( !it->ammo_sufficient() && !it->units_sufficient( *p ) ) { + if ( !it->ammo_sufficient() && !it->units_sufficient( *p ) ) { return 0; } @@ -4006,7 +4006,7 @@ int iuse::shocktonfa_on( player *p, item *it, bool t, const tripoint &pos ) if( t ) { // Effects while simply on } else { - if( !it->ammo_sufficient() && !it->units_sufficient( *p ) ) { + if ( !it->ammo_sufficient() && !it->units_sufficient( *p ) ) { p->add_msg_if_player( m_info, _( "Your tactical tonfa is out of power." ) ); it->convert( "shocktonfa_off" ).active = false; } else { @@ -4030,7 +4030,7 @@ int iuse::shocktonfa_on( player *p, item *it, bool t, const tripoint &pos ) int iuse::mp3( player *p, item *it, bool, const tripoint & ) { - if( !it->ammo_sufficient() && !it->units_sufficient( *p ) ) { + if ( !it->ammo_sufficient() && !it->units_sufficient( *p ) ) { p->add_msg_if_player( m_info, _( "The device's batteries are dead." ) ); } else if( p->has_active_item( "mp3_on" ) || p->has_active_item( "smartphone_music" ) ) { p->add_msg_if_player( m_info, _( "You are already listening to music!" ) ); @@ -4425,7 +4425,7 @@ int iuse::vibe( player *p, item *it, bool, const tripoint & ) p->add_msg_if_player( m_info, _( "It's waterproof, but oxygen maybe?" ) ); return 0; } - if( !it->ammo_sufficient() && !it->units_sufficient( *p ) ) { + if ( !it->ammo_sufficient() && !it->units_sufficient( *p ) ) { p->add_msg_if_player( m_info, _( "The %s's batteries are dead." ), it->tname() ); return 0; } @@ -5356,7 +5356,7 @@ int iuse::heat_food( player *p, item *it, bool, const tripoint & ) int iuse::hotplate( player *p, item *it, bool, const tripoint & ) { - if( it->typeId() != "atomic_coffeepot" && ( !it->ammo_sufficient() && !it->units_sufficient( *p )) ) { + if ( it->typeId() != "atomic_coffeepot" && (!it->ammo_sufficient() && !it->units_sufficient( *p )) ) { p->add_msg_if_player( m_info, _( "The %s's batteries are dead." ), it->tname() ); return 0; } @@ -5620,7 +5620,7 @@ int iuse::contacts( player *p, item *it, bool, const tripoint & ) int iuse::talking_doll( player *p, item *it, bool, const tripoint & ) { - if( !it->ammo_sufficient() && !it->units_sufficient( *p ) ) { + if ( !it->ammo_sufficient() && !it->units_sufficient( *p ) ) { p->add_msg_if_player( m_info, _( "The %s's batteries are dead." ), it->tname() ); return 0; } @@ -5887,7 +5887,7 @@ bool iuse::robotcontrol_can_target( player *p, const monster &m ) int iuse::robotcontrol( player *p, item *it, bool, const tripoint & ) { - if( !it->ammo_sufficient() && !it->units_sufficient( *p ) ) { + if ( !it->ammo_sufficient() && !it->units_sufficient( *p ) ) { p->add_msg_if_player( _( "The %s's batteries are dead." ), it->tname() ); return 0; @@ -7864,7 +7864,7 @@ static void sendRadioSignal( player &p, const std::string &signal ) int iuse::radiocontrol( player *p, item *it, bool t, const tripoint & ) { if( t ) { - if( !it->ammo_sufficient() && !it->units_sufficient( *p ) ) { + if ( !it->ammo_sufficient() && !it->units_sufficient( *p ) ) { it->active = false; p->remove_value( "remote_controlling" ); } else if( p->get_value( "remote_controlling" ).empty() ) { @@ -8043,7 +8043,7 @@ int iuse::remoteveh( player *p, item *it, bool t, const tripoint &pos ) vehicle *remote = g->remoteveh(); if( t ) { bool stop = false; - if( !it->ammo_sufficient() && !it->units_sufficient( *p ) ) { + if ( !it->ammo_sufficient() && !it->units_sufficient( *p ) ) { p->add_msg_if_player( m_bad, _( "The remote control's battery goes dead." ) ); stop = true; } else if( remote == nullptr ) { @@ -8178,7 +8178,7 @@ int iuse::multicooker( player *p, item *it, bool t, const tripoint &pos ) static const int charges_to_start = 50; if( t ) { - if( !it->ammo_sufficient() && !it->units_sufficient( *p ) ) { + if ( !it->ammo_sufficient() && !it->units_sufficient( *p ) ) { it->active = false; return 0; } diff --git a/src/iuse_actor.cpp b/src/iuse_actor.cpp index a1ec50130169f..ad90e498e5eac 100644 --- a/src/iuse_actor.cpp +++ b/src/iuse_actor.cpp @@ -191,7 +191,7 @@ int iuse_transform::use( player &p, item &it, bool t, const tripoint &pos ) cons p.add_msg_if_player( m_info, _( "You need to wear the %1$s before activating it." ), it.tname() ); return 0; } - if( need_charges && it.ammo_remaining() < need_charges && it.units_remaining( p ) < need_charges ) { + if ( need_charges && it.ammo_remaining() < need_charges && it.units_remaining( p ) < need_charges ) { if( possess ) { p.add_msg_if_player( m_info, need_charges_msg, it.tname() ); } @@ -1718,7 +1718,7 @@ ret_val cauterize_actor::can_use( const player &p, const item &it, bool, _( "You need a source of flame (4 charges worth) before you can cauterize yourself." ) ); } } else { - if( !it.ammo_sufficient() && !it.units_sufficient( p ) ) { + if ( !it.ammo_sufficient() && !it.units_sufficient( p ) ) { return ret_val::make_failure( _( "You need at least %d charges to cauterize wounds." ), it.ammo_required() ); } @@ -2740,7 +2740,7 @@ bool repair_item_actor::can_use_tool( const player &p, const item &tool, bool pr } return false; } - if( !tool.ammo_sufficient() && !tool.units_sufficient( p ) ) { + if ( !tool.ammo_sufficient() && !tool.units_sufficient( p ) ) { if( print_msg ) { p.add_msg_if_player( m_info, _( "Your tool does not have enough charges to do that." ) ); } From f47347b7410f5540ca8897964b264000905cc0cb Mon Sep 17 00:00:00 2001 From: Inglonias <2125926+Inglonias@users.noreply.github.com> Date: Sun, 23 Jun 2019 12:12:53 -0400 Subject: [PATCH 3/5] Removed unnecessary ammo_sufficient calls --- src/iuse.cpp | 28 ++++++++++++++-------------- src/iuse_actor.cpp | 6 +++--- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/iuse.cpp b/src/iuse.cpp index 262a7d5edcf30..8301752dc4b81 100644 --- a/src/iuse.cpp +++ b/src/iuse.cpp @@ -2198,7 +2198,7 @@ int iuse::water_purifier( player *p, item *it, bool, const tripoint & ) int iuse::radio_off( player *p, item *it, bool, const tripoint & ) { - if ( !it->ammo_sufficient() && !it->units_sufficient( *p ) ) { + if ( !it->units_sufficient( *p ) ) { p->add_msg_if_player( _( "It's dead." ) ); } else { p->add_msg_if_player( _( "You turn the radio on." ) ); @@ -2321,7 +2321,7 @@ int iuse::radio_on( player *p, item *it, bool t, const tripoint &pos ) int iuse::noise_emitter_off( player *p, item *it, bool, const tripoint & ) { - if ( !it->ammo_sufficient() && !it->units_sufficient( *p ) ) { + if ( !it->units_sufficient( *p ) ) { p->add_msg_if_player( _( "It's dead." ) ); } else { p->add_msg_if_player( _( "You turn the noise emitter on." ) ); @@ -3895,7 +3895,7 @@ int iuse::portal( player *p, item *it, bool, const tripoint & ) int iuse::tazer( player *p, item *it, bool, const tripoint &pos ) { - if ( !it->ammo_sufficient() && !it->units_sufficient( *p ) ) { + if ( !it->units_sufficient( *p ) ) { return 0; } @@ -3988,7 +3988,7 @@ int iuse::shocktonfa_off( player *p, item *it, bool t, const tripoint &pos ) return iuse::tazer2( p, it, t, pos ); } case 1: { - if( !it->ammo_sufficient() && !it->units_sufficient( *p ) ) { + if( !it->units_sufficient( *p ) ) { p->add_msg_if_player( m_info, _( "The batteries are dead." ) ); return 0; } else { @@ -4006,7 +4006,7 @@ int iuse::shocktonfa_on( player *p, item *it, bool t, const tripoint &pos ) if( t ) { // Effects while simply on } else { - if ( !it->ammo_sufficient() && !it->units_sufficient( *p ) ) { + if ( !it->units_sufficient( *p ) ) { p->add_msg_if_player( m_info, _( "Your tactical tonfa is out of power." ) ); it->convert( "shocktonfa_off" ).active = false; } else { @@ -4030,7 +4030,7 @@ int iuse::shocktonfa_on( player *p, item *it, bool t, const tripoint &pos ) int iuse::mp3( player *p, item *it, bool, const tripoint & ) { - if ( !it->ammo_sufficient() && !it->units_sufficient( *p ) ) { + if ( !it->units_sufficient( *p ) ) { p->add_msg_if_player( m_info, _( "The device's batteries are dead." ) ); } else if( p->has_active_item( "mp3_on" ) || p->has_active_item( "smartphone_music" ) ) { p->add_msg_if_player( m_info, _( "You are already listening to music!" ) ); @@ -4425,7 +4425,7 @@ int iuse::vibe( player *p, item *it, bool, const tripoint & ) p->add_msg_if_player( m_info, _( "It's waterproof, but oxygen maybe?" ) ); return 0; } - if ( !it->ammo_sufficient() && !it->units_sufficient( *p ) ) { + if ( !it->units_sufficient( *p ) ) { p->add_msg_if_player( m_info, _( "The %s's batteries are dead." ), it->tname() ); return 0; } @@ -5356,7 +5356,7 @@ int iuse::heat_food( player *p, item *it, bool, const tripoint & ) int iuse::hotplate( player *p, item *it, bool, const tripoint & ) { - if ( it->typeId() != "atomic_coffeepot" && (!it->ammo_sufficient() && !it->units_sufficient( *p )) ) { + if ( it->typeId() != "atomic_coffeepot" && ( !it->units_sufficient( *p )) ) { p->add_msg_if_player( m_info, _( "The %s's batteries are dead." ), it->tname() ); return 0; } @@ -5566,7 +5566,7 @@ int iuse::radglove( player *p, item *it, bool, const tripoint & ) p->add_msg_if_player( m_info, _( "You must wear the radiation biomonitor before you can activate it." ) ); return 0; - } else if( !it->ammo_sufficient() && !it->units_sufficient( *p ) ) { + } else if( !it->units_sufficient( *p ) ) { p->add_msg_if_player( m_info, _( "The radiation biomonitor needs batteries to function." ) ); return 0; } else { @@ -5620,7 +5620,7 @@ int iuse::contacts( player *p, item *it, bool, const tripoint & ) int iuse::talking_doll( player *p, item *it, bool, const tripoint & ) { - if ( !it->ammo_sufficient() && !it->units_sufficient( *p ) ) { + if ( !it->units_sufficient( *p ) ) { p->add_msg_if_player( m_info, _( "The %s's batteries are dead." ), it->tname() ); return 0; } @@ -5887,7 +5887,7 @@ bool iuse::robotcontrol_can_target( player *p, const monster &m ) int iuse::robotcontrol( player *p, item *it, bool, const tripoint & ) { - if ( !it->ammo_sufficient() && !it->units_sufficient( *p ) ) { + if ( !it->units_sufficient( *p ) ) { p->add_msg_if_player( _( "The %s's batteries are dead." ), it->tname() ); return 0; @@ -7864,7 +7864,7 @@ static void sendRadioSignal( player &p, const std::string &signal ) int iuse::radiocontrol( player *p, item *it, bool t, const tripoint & ) { if( t ) { - if ( !it->ammo_sufficient() && !it->units_sufficient( *p ) ) { + if ( !it->units_sufficient( *p ) ) { it->active = false; p->remove_value( "remote_controlling" ); } else if( p->get_value( "remote_controlling" ).empty() ) { @@ -8043,7 +8043,7 @@ int iuse::remoteveh( player *p, item *it, bool t, const tripoint &pos ) vehicle *remote = g->remoteveh(); if( t ) { bool stop = false; - if ( !it->ammo_sufficient() && !it->units_sufficient( *p ) ) { + if ( !it->units_sufficient( *p ) ) { p->add_msg_if_player( m_bad, _( "The remote control's battery goes dead." ) ); stop = true; } else if( remote == nullptr ) { @@ -8178,7 +8178,7 @@ int iuse::multicooker( player *p, item *it, bool t, const tripoint &pos ) static const int charges_to_start = 50; if( t ) { - if ( !it->ammo_sufficient() && !it->units_sufficient( *p ) ) { + if ( !it->units_sufficient( *p ) ) { it->active = false; return 0; } diff --git a/src/iuse_actor.cpp b/src/iuse_actor.cpp index ad90e498e5eac..59a19e6cf51c7 100644 --- a/src/iuse_actor.cpp +++ b/src/iuse_actor.cpp @@ -191,7 +191,7 @@ int iuse_transform::use( player &p, item &it, bool t, const tripoint &pos ) cons p.add_msg_if_player( m_info, _( "You need to wear the %1$s before activating it." ), it.tname() ); return 0; } - if ( need_charges && it.ammo_remaining() < need_charges && it.units_remaining( p ) < need_charges ) { + if ( need_charges && it.units_remaining( p ) < need_charges ) { if( possess ) { p.add_msg_if_player( m_info, need_charges_msg, it.tname() ); } @@ -1718,7 +1718,7 @@ ret_val cauterize_actor::can_use( const player &p, const item &it, bool, _( "You need a source of flame (4 charges worth) before you can cauterize yourself." ) ); } } else { - if ( !it.ammo_sufficient() && !it.units_sufficient( p ) ) { + if ( !it.units_sufficient( p ) ) { return ret_val::make_failure( _( "You need at least %d charges to cauterize wounds." ), it.ammo_required() ); } @@ -2740,7 +2740,7 @@ bool repair_item_actor::can_use_tool( const player &p, const item &tool, bool pr } return false; } - if ( !tool.ammo_sufficient() && !tool.units_sufficient( p ) ) { + if ( !tool.units_sufficient( p ) ) { if( print_msg ) { p.add_msg_if_player( m_info, _( "Your tool does not have enough charges to do that." ) ); } From bbee2cb017bf2f96637b0411cb7e1a109254b63c Mon Sep 17 00:00:00 2001 From: Inglonias <2125926+Inglonias@users.noreply.github.com> Date: Sun, 23 Jun 2019 13:33:16 -0400 Subject: [PATCH 4/5] Update src/iuse_actor.cpp Co-Authored-By: ZhilkinSerg --- src/iuse_actor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/iuse_actor.cpp b/src/iuse_actor.cpp index 59a19e6cf51c7..1bd0216a1167f 100644 --- a/src/iuse_actor.cpp +++ b/src/iuse_actor.cpp @@ -2740,7 +2740,7 @@ bool repair_item_actor::can_use_tool( const player &p, const item &tool, bool pr } return false; } - if ( !tool.units_sufficient( p ) ) { + if( !tool.units_sufficient( p ) ) { if( print_msg ) { p.add_msg_if_player( m_info, _( "Your tool does not have enough charges to do that." ) ); } From eca5691aba20cd136141a39ed4ce828326701206 Mon Sep 17 00:00:00 2001 From: Inglonias <2125926+Inglonias@users.noreply.github.com> Date: Sun, 23 Jun 2019 13:35:41 -0400 Subject: [PATCH 5/5] Committed suggested changes. --- src/iuse.cpp | 24 ++++++++++++------------ src/iuse_actor.cpp | 6 +++--- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/iuse.cpp b/src/iuse.cpp index 8301752dc4b81..58d3ac077c9c4 100644 --- a/src/iuse.cpp +++ b/src/iuse.cpp @@ -2198,7 +2198,7 @@ int iuse::water_purifier( player *p, item *it, bool, const tripoint & ) int iuse::radio_off( player *p, item *it, bool, const tripoint & ) { - if ( !it->units_sufficient( *p ) ) { + if( !it->units_sufficient( *p ) ) { p->add_msg_if_player( _( "It's dead." ) ); } else { p->add_msg_if_player( _( "You turn the radio on." ) ); @@ -2321,7 +2321,7 @@ int iuse::radio_on( player *p, item *it, bool t, const tripoint &pos ) int iuse::noise_emitter_off( player *p, item *it, bool, const tripoint & ) { - if ( !it->units_sufficient( *p ) ) { + if( !it->units_sufficient( *p ) ) { p->add_msg_if_player( _( "It's dead." ) ); } else { p->add_msg_if_player( _( "You turn the noise emitter on." ) ); @@ -3895,7 +3895,7 @@ int iuse::portal( player *p, item *it, bool, const tripoint & ) int iuse::tazer( player *p, item *it, bool, const tripoint &pos ) { - if ( !it->units_sufficient( *p ) ) { + if( !it->units_sufficient( *p ) ) { return 0; } @@ -4006,7 +4006,7 @@ int iuse::shocktonfa_on( player *p, item *it, bool t, const tripoint &pos ) if( t ) { // Effects while simply on } else { - if ( !it->units_sufficient( *p ) ) { + if( !it->units_sufficient( *p ) ) { p->add_msg_if_player( m_info, _( "Your tactical tonfa is out of power." ) ); it->convert( "shocktonfa_off" ).active = false; } else { @@ -4030,7 +4030,7 @@ int iuse::shocktonfa_on( player *p, item *it, bool t, const tripoint &pos ) int iuse::mp3( player *p, item *it, bool, const tripoint & ) { - if ( !it->units_sufficient( *p ) ) { + if( !it->units_sufficient( *p ) ) { p->add_msg_if_player( m_info, _( "The device's batteries are dead." ) ); } else if( p->has_active_item( "mp3_on" ) || p->has_active_item( "smartphone_music" ) ) { p->add_msg_if_player( m_info, _( "You are already listening to music!" ) ); @@ -4425,7 +4425,7 @@ int iuse::vibe( player *p, item *it, bool, const tripoint & ) p->add_msg_if_player( m_info, _( "It's waterproof, but oxygen maybe?" ) ); return 0; } - if ( !it->units_sufficient( *p ) ) { + if( !it->units_sufficient( *p ) ) { p->add_msg_if_player( m_info, _( "The %s's batteries are dead." ), it->tname() ); return 0; } @@ -5356,7 +5356,7 @@ int iuse::heat_food( player *p, item *it, bool, const tripoint & ) int iuse::hotplate( player *p, item *it, bool, const tripoint & ) { - if ( it->typeId() != "atomic_coffeepot" && ( !it->units_sufficient( *p )) ) { + if( it->typeId() != "atomic_coffeepot" && ( !it->units_sufficient( *p )) ) { p->add_msg_if_player( m_info, _( "The %s's batteries are dead." ), it->tname() ); return 0; } @@ -5620,7 +5620,7 @@ int iuse::contacts( player *p, item *it, bool, const tripoint & ) int iuse::talking_doll( player *p, item *it, bool, const tripoint & ) { - if ( !it->units_sufficient( *p ) ) { + if( !it->units_sufficient( *p ) ) { p->add_msg_if_player( m_info, _( "The %s's batteries are dead." ), it->tname() ); return 0; } @@ -5887,7 +5887,7 @@ bool iuse::robotcontrol_can_target( player *p, const monster &m ) int iuse::robotcontrol( player *p, item *it, bool, const tripoint & ) { - if ( !it->units_sufficient( *p ) ) { + if( !it->units_sufficient( *p ) ) { p->add_msg_if_player( _( "The %s's batteries are dead." ), it->tname() ); return 0; @@ -7864,7 +7864,7 @@ static void sendRadioSignal( player &p, const std::string &signal ) int iuse::radiocontrol( player *p, item *it, bool t, const tripoint & ) { if( t ) { - if ( !it->units_sufficient( *p ) ) { + if( !it->units_sufficient( *p ) ) { it->active = false; p->remove_value( "remote_controlling" ); } else if( p->get_value( "remote_controlling" ).empty() ) { @@ -8043,7 +8043,7 @@ int iuse::remoteveh( player *p, item *it, bool t, const tripoint &pos ) vehicle *remote = g->remoteveh(); if( t ) { bool stop = false; - if ( !it->units_sufficient( *p ) ) { + if( !it->units_sufficient( *p ) ) { p->add_msg_if_player( m_bad, _( "The remote control's battery goes dead." ) ); stop = true; } else if( remote == nullptr ) { @@ -8178,7 +8178,7 @@ int iuse::multicooker( player *p, item *it, bool t, const tripoint &pos ) static const int charges_to_start = 50; if( t ) { - if ( !it->units_sufficient( *p ) ) { + if( !it->units_sufficient( *p ) ) { it->active = false; return 0; } diff --git a/src/iuse_actor.cpp b/src/iuse_actor.cpp index 59a19e6cf51c7..e5a6706c50437 100644 --- a/src/iuse_actor.cpp +++ b/src/iuse_actor.cpp @@ -191,7 +191,7 @@ int iuse_transform::use( player &p, item &it, bool t, const tripoint &pos ) cons p.add_msg_if_player( m_info, _( "You need to wear the %1$s before activating it." ), it.tname() ); return 0; } - if ( need_charges && it.units_remaining( p ) < need_charges ) { + if( need_charges && it.units_remaining( p ) < need_charges ) { if( possess ) { p.add_msg_if_player( m_info, need_charges_msg, it.tname() ); } @@ -1718,7 +1718,7 @@ ret_val cauterize_actor::can_use( const player &p, const item &it, bool, _( "You need a source of flame (4 charges worth) before you can cauterize yourself." ) ); } } else { - if ( !it.units_sufficient( p ) ) { + if( !it.units_sufficient( p ) ) { return ret_val::make_failure( _( "You need at least %d charges to cauterize wounds." ), it.ammo_required() ); } @@ -2740,7 +2740,7 @@ bool repair_item_actor::can_use_tool( const player &p, const item &tool, bool pr } return false; } - if ( !tool.units_sufficient( p ) ) { + if( !tool.units_sufficient( p ) ) { if( print_msg ) { p.add_msg_if_player( m_info, _( "Your tool does not have enough charges to do that." ) ); }