Skip to content
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

Merged
merged 6 commits into from
Jun 23, 2019

Conversation

Inglonias
Copy link
Contributor

@Inglonias Inglonias commented Jun 23, 2019

Summary

SUMMARY: Bugfixes "Makes UPS modified tools work as intended"

Purpose of change

Fixes #31377

Describe the solution

Replaced calls to ammo_sufficient and ammo_remaining with units_sufficient and units_remaining in the context of turning battery powered tools on and off. The units_sufficient and units_remaining functions take USE_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 and ammo_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 calls ammo_sufficient and ammo_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.

Addec calls to units_sufficient for everything I could find in iuse and iuse_actor that could potentially use batteries.
@Inglonias
Copy link
Contributor Author

Just a note. #29983 is made obsolete by this PR.

@ZhilkinSerg ZhilkinSerg added <Bugfix> This is a fix for a bug (or closes open issue) [C++] Changes (can be) made in C++. Previously named `Code` Items: Battery / UPS Electric power management labels Jun 23, 2019
src/iuse_actor.cpp Outdated Show resolved Hide resolved
@@ -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 ) ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if ( !it.units_sufficient( p ) ) {
if( !it.units_sufficient( p ) ) {

@@ -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 ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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 ) ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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 ) ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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 ) ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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 ) ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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 ) ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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 )) ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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 ) ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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 ) ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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 ) ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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 ) ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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 ) ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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 ) ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if ( !it->units_sufficient( *p ) ) {
if( !it->units_sufficient( *p ) ) {

@ZhilkinSerg
Copy link
Contributor

What about iuse::teleport?

@Inglonias
Copy link
Contributor Author

Inglonias commented Jun 23, 2019

What about iuse::teleport?

Teleporters don't use batteries, Unless the bionic one can use a UPS somehow, anyway.

@Inglonias
Copy link
Contributor Author

Spacing issues are resolved.

@ZhilkinSerg ZhilkinSerg merged commit c2b6a99 into CleverRaven:master Jun 23, 2019
@akerigan
Copy link

akerigan commented Jun 24, 2019

If I missed any tools, please let me know ASAP

UPS soldering doesn't fix/disassemble

@Inglonias
Copy link
Contributor Author

Alright. Good to know.

@Inglonias Inglonias deleted the for-real-ups-fix branch September 23, 2020 18:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
<Bugfix> This is a fix for a bug (or closes open issue) [C++] Changes (can be) made in C++. Previously named `Code` Items: Battery / UPS Electric power management
Projects
None yet
Development

Successfully merging this pull request may close these issues.

UPS-modded lights do not work
3 participants