diff --git a/src/activity_handlers.cpp b/src/activity_handlers.cpp index 1e2187422f6fb..b59638a94a981 100644 --- a/src/activity_handlers.cpp +++ b/src/activity_handlers.cpp @@ -3101,7 +3101,7 @@ void activity_handlers::operation_do_turn( player_activity *act, player *p ) if( p->has_bionic( bid ) ) { p->perform_uninstall( bid, act->values[0], act->values[1], - act->values[2], act->values[3] ); + units::from_millijoule( act->values[2] ), act->values[3] ); } else { debugmsg( _( "Tried to uninstall %s, but you don't have this bionic installed." ), act->str_values[cbm_id] ); diff --git a/src/bionics.cpp b/src/bionics.cpp index 5f07dcc1ff24f..6c6bc4aa722a8 100644 --- a/src/bionics.cpp +++ b/src/bionics.cpp @@ -900,10 +900,11 @@ bool player::burn_fuel( int b, bool start ) * @param rate divides the number of turns we may charge (rate of 2 discharges in half the time). * @return indicates whether we successfully charged the bionic. */ -static bool attempt_recharge( player &p, bionic &bio, int &amount, int factor = 1, int rate = 1 ) +static bool attempt_recharge( player &p, bionic &bio, units::energy &amount, int factor = 1, + int rate = 1 ) { const bionic_data &info = bio.info(); - const int armor_power_cost = 1; + const units::energy armor_power_cost = 1_kJ; units::energy power_cost = info.power_over_time * factor; bool recharged = false; @@ -915,12 +916,12 @@ static bool attempt_recharge( player &p, bionic &bio, int &amount, int factor = return w.active && w.is_power_armor(); } ); if( !powered_armor ) { - power_cost -= units::from_kilojoule( armor_power_cost ) * factor; + power_cost -= armor_power_cost * factor; } } if( p.get_power_level() >= power_cost ) { // Set the recharging cost and charge the bionic. - amount = units::to_kilojoule( power_cost ); + amount = power_cost; // This is our first turn of charging, so subtract a turn from the recharge delay. bio.charge_timer = info.charge_time - rate; recharged = true; @@ -953,7 +954,7 @@ void player::process_bionic( int b ) bio.charge_timer = bio.info().charge_time; } else { // Try to recharge our bionic if it is made for it - int cost = 0; + units::energy cost = 0_mJ; bool recharged = attempt_recharge( *this, bio, cost, discharge_factor, discharge_rate ); if( !recharged ) { // No power to recharge, so deactivate @@ -963,8 +964,8 @@ void player::process_bionic( int b ) deactivate_bionic( b, true ); return; } - if( cost ) { - mod_power_level( units::from_kilojoule( -cost ) ); + if( cost > 0_mJ ) { + mod_power_level( -cost ); } } } @@ -1461,7 +1462,7 @@ bool player::uninstall_bionic( const bionic_id &b_id, player &installer, bool au return true; } -void player::perform_uninstall( bionic_id bid, int difficulty, int success, int power_lvl, +void player::perform_uninstall( bionic_id bid, int difficulty, int success, units::energy power_lvl, int pl_skill ) { if( success > 0 ) { @@ -1474,7 +1475,7 @@ void player::perform_uninstall( bionic_id bid, int difficulty, int success, int remove_bionic( bid ); // remove power bank provided by bionic - mod_max_power_level( -units::from_kilojoule( power_lvl ) ); + mod_max_power_level( -power_lvl ); item cbm( "burnt_out_bionic" ); if( item::type_is_defined( bid.c_str() ) ) { @@ -1686,7 +1687,7 @@ bool player::install_bionics( const itype &type, player &installer, bool autodoc activity.values.push_back( difficulty ); activity.values.push_back( success ); - activity.values.push_back( units::to_kilojoule( bionics[bioid].capacity ) ); + activity.values.push_back( units::to_millijoule( bionics[bioid].capacity ) ); activity.values.push_back( pl_skill ); activity.str_values.push_back( "install" ); activity.str_values.push_back( "" ); diff --git a/src/player.h b/src/player.h index 7a9d1d4fb7e2f..213915fd420ee 100644 --- a/src/player.h +++ b/src/player.h @@ -324,7 +324,8 @@ class player : public Character bool uninstall_bionic( const bionic_id &b_id, player &installer, bool autodoc = false, int skill_level = -1 ); /**Succes or failure of removal happens here*/ - void perform_uninstall( bionic_id bid, int difficulty, int success, int power_lvl, int pl_skill ); + void perform_uninstall( bionic_id bid, int difficulty, int success, units::energy power_lvl, + int pl_skill ); /**Used by monster to perform surgery*/ bool uninstall_bionic( const bionic &target_cbm, monster &installer, player &patient, float adjusted_skill, bool autodoc = false );