Skip to content

Commit

Permalink
Please name your variables uniquely
Browse files Browse the repository at this point in the history
  • Loading branch information
RenechCDDA committed Mar 9, 2024
1 parent aaea62b commit 9ada61b
Showing 1 changed file with 23 additions and 17 deletions.
40 changes: 23 additions & 17 deletions src/iuse_actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,8 @@ std::optional<int> iuse_transform::use( Character *p, item &it, const tripoint &
p->add_msg_if_player( m_neutral, msg_transform, it.tname() );
}

p->moves -= moves;
// Uses the moves specified by iuse_actor's definition
p->mod_moves( -moves );

if( need_fire && p->has_trait( trait_PYROMANIA ) ) {
if( one_in( 2 ) ) {
Expand Down Expand Up @@ -818,7 +819,8 @@ std::optional<int> consume_drug_iuse::use( Character *p, item &it, const tripoin
p->i_add_or_drop( used_up );
}

p->moves -= moves;
// Uses the moves specified by iuse_actor's definition
p->mod_moves( -moves );
return 1;
}

Expand Down Expand Up @@ -904,7 +906,8 @@ std::optional<int> place_monster_iuse::use( Character *p, item &it, const tripoi
return std::nullopt;
}
}
p->moves -= moves;
// Uses the moves specified by iuse_actor's definition
p->mod_moves( -moves );

newmon.ammo = newmon.type->starting_ammo;
if( !newmon.has_flag( mon_flag_INTERIOR_AMMO ) ) {
Expand Down Expand Up @@ -1103,7 +1106,8 @@ static ret_val<tripoint> check_deploy_square( Character *p, item &it, const trip
here.mop_spills( tripoint_bub_ms( pnt ) );
p->add_msg_if_player( m_info, _( "You mopped up the spill with a nearby mop when deploying a %s." ),
it.tname() );
p->moves -= 15;
// Note this used to be 15 moves... please mop responsibly, not at the speed of light
p->mod_moves( -to_moves<int>( 15_seconds ) );
} else {
return ret_val<tripoint>::make_failure( pos,
_( "You need a mop to clean up liquids before deploying the %s." ), it.tname() );
Expand Down Expand Up @@ -1728,7 +1732,7 @@ void salvage_actor::cut_up( Character &p, item_location &cut ) const
int amount = salvaged_mat.second;
if( amount > 0 ) {
// Time based on number of components.
p.moves -= moves_per_part;
p.mod_moves( -moves_per_part );
if( result.count_by_charges() ) {
result.charges = amount;
amount = 1;
Expand Down Expand Up @@ -1925,7 +1929,8 @@ std::optional<int> fireweapon_off_actor::use( Character *p, item &it,
return std::nullopt;
}

p->moves -= moves;
// Uses the moves specified by iuse_actor's definition
p->mod_moves( -moves );
if( rng( 0, 10 ) - it.damage_level() > success_chance && !p->is_underwater() ) {
if( noise > 0 ) {
sounds::sound( p->pos(), noise, sounds::sound_t::combat, success_message );
Expand Down Expand Up @@ -2021,7 +2026,8 @@ std::unique_ptr<iuse_actor> manualnoise_actor::clone() const

std::optional<int> manualnoise_actor::use( Character *p, item &, const tripoint & ) const
{
p->moves -= moves;
// Uses the moves specified by iuse_actor's definition
p->mod_moves( -moves );
if( noise > 0 ) {
sounds::sound( p->pos(), noise, sounds::sound_t::activity,
noise_message.empty() ? _( "Hsss" ) : noise_message.translated(), true, noise_id, noise_variant );
Expand Down Expand Up @@ -4708,7 +4714,7 @@ std::optional<int> link_up_actor::use( Character *p, item &it, const tripoint &p

it.update_link_traits();
it.process( here, p, p->pos() );
p->moves -= move_cost;
p->mod_moves( -move_cost );
return 0;

} else if( choice == 21 ) {
Expand Down Expand Up @@ -4744,7 +4750,7 @@ std::optional<int> link_up_actor::use( Character *p, item &it, const tripoint &p
loc->set_var( "cable", "plugged_in" );
it.update_link_traits();
it.process( here, p, p->pos() );
p->moves -= move_cost;
p->mod_moves( -move_cost );
return 0;

} else if( choice == 22 ) {
Expand Down Expand Up @@ -4780,7 +4786,7 @@ std::optional<int> link_up_actor::use( Character *p, item &it, const tripoint &p
loc->set_var( "cable", "plugged_in" );
it.update_link_traits();
it.process( here, p, p->pos() );
p->moves -= move_cost;
p->mod_moves( -move_cost );
return 0;
}
return std::nullopt;
Expand Down Expand Up @@ -4849,7 +4855,7 @@ std::optional<int> link_up_actor::link_to_veh_app( Character *p, item &it,
}

it.process( here, p, p->pos() );
p->moves -= move_cost;
p->mod_moves( -move_cost );
return 0;

} else {
Expand All @@ -4869,7 +4875,7 @@ std::optional<int> link_up_actor::link_to_veh_app( Character *p, item &it,
// Remove linked_flag from attached parts - the just-added cable vehicle parts do the same thing.
it.reset_link( true, p );
}
p->moves -= move_cost;
p->mod_moves( -move_cost );
return 1; // Let the cable be destroyed.
}
}
Expand Down Expand Up @@ -4918,7 +4924,7 @@ std::optional<int> link_up_actor::link_tow_cable( Character *p, item &it,
sel_vp->vehicle().name );

it.process( here, p, p->pos() );
p->moves -= move_cost;
p->mod_moves( -move_cost );
return 0;

} else {
Expand All @@ -4933,7 +4939,7 @@ std::optional<int> link_up_actor::link_tow_cable( Character *p, item &it,
p->add_msg_if_player( m_good, result.str() );
}

p->moves -= move_cost;
p->mod_moves( -move_cost );
return 1; // Let the cable be destroyed.
}
}
Expand Down Expand Up @@ -5040,7 +5046,7 @@ std::optional<int> link_up_actor::link_extend_cable( Character *p, item &it,
extension.remove_item();
p->invalidate_inventory_validity_cache();
p->drop_invalid_inventory();
p->moves -= move_cost;
p->mod_moves( -move_cost );
return 0;
}

Expand Down Expand Up @@ -5087,7 +5093,7 @@ std::optional<int> link_up_actor::remove_extensions( Character *p, item &it ) co
}

p->i_add_or_drop( cable_main_copy );
p->moves -= move_cost;
p->mod_moves( -move_cost );
return 0;
}

Expand Down Expand Up @@ -5400,7 +5406,7 @@ std::optional<int> sew_advanced_actor::use( Character *p, item &it, const tripoi

std::vector<item_comp> comps;
comps.emplace_back( repair_item, items_needed );
p->moves -= to_moves<int>( 30_seconds * p->fine_detail_vision_mod() );
p->mod_moves( -to_moves<int>( 30_seconds * p->fine_detail_vision_mod() ) );
p->practice( used_skill, items_needed * 3 + 3 );
/** @EFFECT_TAILOR randomly improves clothing modification efforts */
int rn = dice( 3, 2 + round( p->get_skill_level( used_skill ) ) ); // Skill
Expand Down

0 comments on commit 9ada61b

Please sign in to comment.