-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix tools that use UPS conversion mods #31766
Conversation
Addec calls to units_sufficient for everything I could find in iuse and iuse_actor that could potentially use batteries.
Just a note. #29983 is made obsolete by this PR. |
src/iuse_actor.cpp
Outdated
@@ -1718,7 +1718,7 @@ ret_val<bool> 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.units_sufficient( p ) ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if ( !it.units_sufficient( p ) ) { | |
if( !it.units_sufficient( p ) ) { |
src/iuse_actor.cpp
Outdated
@@ -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.units_remaining( p ) < need_charges ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if ( need_charges && it.units_remaining( p ) < need_charges ) { | |
if( need_charges && it.units_remaining( p ) < need_charges ) { |
src/iuse.cpp
Outdated
@@ -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->units_sufficient( *p ) ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if ( !it->units_sufficient( *p ) ) { | |
if( !it->units_sufficient( *p ) ) { |
src/iuse.cpp
Outdated
@@ -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->units_sufficient( *p ) ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if ( !it->units_sufficient( *p ) ) { | |
if( !it->units_sufficient( *p ) ) { |
src/iuse.cpp
Outdated
@@ -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->units_sufficient( *p ) ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if ( !it->units_sufficient( *p ) ) { | |
if( !it->units_sufficient( *p ) ) { |
src/iuse.cpp
Outdated
@@ -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->units_sufficient( *p ) ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if ( !it->units_sufficient( *p ) ) { | |
if( !it->units_sufficient( *p ) ) { |
src/iuse.cpp
Outdated
@@ -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->units_sufficient( *p ) ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if ( !it->units_sufficient( *p ) ) { | |
if( !it->units_sufficient( *p ) ) { |
src/iuse.cpp
Outdated
@@ -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->units_sufficient( *p )) ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if ( it->typeId() != "atomic_coffeepot" && ( !it->units_sufficient( *p )) ) { | |
if( it->typeId() != "atomic_coffeepot" && ( !it->units_sufficient( *p ) ) ) { |
src/iuse.cpp
Outdated
@@ -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->units_sufficient( *p ) ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if ( !it->units_sufficient( *p ) ) { | |
if( !it->units_sufficient( *p ) ) { |
src/iuse.cpp
Outdated
@@ -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->units_sufficient( *p ) ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if ( !it->units_sufficient( *p ) ) { | |
if( !it->units_sufficient( *p ) ) { |
src/iuse.cpp
Outdated
@@ -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->units_sufficient( *p ) ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if ( !it->units_sufficient( *p ) ) { | |
if( !it->units_sufficient( *p ) ) { |
src/iuse.cpp
Outdated
@@ -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->units_sufficient( *p ) ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if ( !it->units_sufficient( *p ) ) { | |
if( !it->units_sufficient( *p ) ) { |
src/iuse.cpp
Outdated
@@ -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->units_sufficient( *p ) ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if ( !it->units_sufficient( *p ) ) { | |
if( !it->units_sufficient( *p ) ) { |
src/iuse.cpp
Outdated
@@ -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->units_sufficient( *p ) ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if ( !it->units_sufficient( *p ) ) { | |
if( !it->units_sufficient( *p ) ) { |
What about |
Co-Authored-By: ZhilkinSerg <[email protected]>
Teleporters don't use batteries, Unless the bionic one can use a UPS somehow, anyway. |
…lysm-DDA into for-real-ups-fix
Spacing issues are resolved. |
UPS soldering doesn't fix/disassemble |
Alright. Good to know. |
Summary
SUMMARY: Bugfixes "Makes UPS modified tools work as intended"
Purpose of change
Fixes #31377
Describe the solution
Replaced calls to
ammo_sufficient
andammo_remaining
withunits_sufficient
andunits_remaining
in the context of turning battery powered tools on and off. Theunits_sufficient
andunits_remaining
functions takeUSE_UPS
into account, but require a character object to be passed in. Since iuse has that anyhow, there's no harm in doing this.Describe alternatives you've considered
Add a check in
ammo_sufficient
andammo_remaining
for UPS charges, but as far as I can tell, that requires an argument of a character or player pointer, and I don't want to adjust everything in the game thta callsammo_sufficient
andammo_remaining
for a new function definition.Additional context
If I missed any tools, please let me know ASAP
Paging @esotericist
Thanks to NK4517 on Reddit (AKA @naka123 on Github) for pushing me to get this done. Their work essentially confirmed and implemented a theory I was toying with, but hadn't put into code yet. Without them, this wouldn't have happened today.