diff --git a/src/activity_handlers.cpp b/src/activity_handlers.cpp index 3a4ed451a111c..c85fc8b0f45ef 100644 --- a/src/activity_handlers.cpp +++ b/src/activity_handlers.cpp @@ -1037,8 +1037,8 @@ static void butchery_drops_harvest( item *corpse_item, const mtype &mt, player & // apply skill before converting to items, but only if mass_ratio is defined roll *= roll_drops(); monster_weight_remaining -= roll; - roll = ceil( static_cast( roll ) / - to_gram( item::find_type( entry.drop )->weight ) ); + roll = std::ceil( static_cast( roll ) / + to_gram( item::find_type( entry.drop )->weight ) ); } else { monster_weight_remaining -= roll * to_gram( ( item::find_type( entry.drop ) )->weight ); } @@ -3665,7 +3665,7 @@ void activity_handlers::build_do_turn( player_activity *act, player *p ) const double current_progress = old_counter * base_total_moves / 10000000.0 + delta_progress; // Current progress as a percent of base_total_moves to 2 decimal places - pc->counter = round( current_progress / base_total_moves * 10000000.0 ); + pc->counter = std::round( current_progress / base_total_moves * 10000000.0 ); p->set_moves( 0 ); @@ -3787,7 +3787,7 @@ void activity_handlers::craft_do_turn( player_activity *act, player *p ) const double current_progress = craft->item_counter * base_total_moves / 10'000'000.0 + delta_progress; // Current progress as a percent of base_total_moves to 2 decimal places - craft->item_counter = round( current_progress / base_total_moves * 10'000'000.0 ); + craft->item_counter = std::round( current_progress / base_total_moves * 10'000'000.0 ); p->set_moves( 0 ); // This is to ensure we don't over count skill steps diff --git a/src/activity_item_handling.cpp b/src/activity_item_handling.cpp index ee0d6b66a92c1..35d95933d372e 100644 --- a/src/activity_item_handling.cpp +++ b/src/activity_item_handling.cpp @@ -1269,7 +1269,7 @@ static activity_reason_info can_do_activity_there( const activity_id &act, playe return activity_reason_info::fail( NO_ZONE ); } // if the vehicle is moving or player is controlling it. - if( abs( veh->velocity ) > 100 || veh->player_in_control( g->u ) ) { + if( std::abs( veh->velocity ) > 100 || veh->player_in_control( g->u ) ) { return activity_reason_info::fail( NO_ZONE ); } for( const npc &guy : g->all_npcs() ) { @@ -1323,8 +1323,8 @@ static activity_reason_info can_do_activity_there( const activity_id &act, playe continue; } const int max_lift = p.best_nearby_lifting_assist( src_loc ); - const int lvl = ceil( units::quantity( base.weight() ) / - TOOL_LIFT_FACTOR ); + const int lvl = std::ceil( units::quantity( base.weight() ) / + TOOL_LIFT_FACTOR ); const bool use_aid = max_lift >= lvl; const bool use_str = p.can_lift( base ); if( !( use_aid || use_str ) ) { diff --git a/src/avatar.cpp b/src/avatar.cpp index b54fc02aa93a8..d403f81730361 100644 --- a/src/avatar.cpp +++ b/src/avatar.cpp @@ -1702,9 +1702,9 @@ std::string points_left::to_string() _( "Points left: %d%c%d%c%d=%d" ), stat_points_left() >= 0 ? "light_gray" : "red", stat_points, trait_points >= 0 ? '+' : '-', - trait_points_left() >= 0 ? "light_gray" : "red", abs( trait_points ), + trait_points_left() >= 0 ? "light_gray" : "red", std::abs( trait_points ), skill_points >= 0 ? '+' : '-', - skill_points_left() >= 0 ? "light_gray" : "red", abs( skill_points ), + skill_points_left() >= 0 ? "light_gray" : "red", std::abs( skill_points ), is_valid() ? "light_gray" : "red", stat_points + trait_points + skill_points ); } else if( limit == ONE_POOL ) { return string_format( _( "Points left: %4d" ), skill_points_left() ); diff --git a/src/avatar_action.cpp b/src/avatar_action.cpp index 74c292beaa41b..d39d3ad146b19 100644 --- a/src/avatar_action.cpp +++ b/src/avatar_action.cpp @@ -335,7 +335,7 @@ bool avatar_action::move( avatar &you, map &m, int dx, int dy, int dz ) veh_closed_door = dpart >= 0 && !veh1->parts[dpart].open; } - if( veh0 != nullptr && abs( veh0->velocity ) > 100 ) { + if( veh0 != nullptr && std::abs( veh0->velocity ) > 100 ) { if( veh1 == nullptr ) { if( query_yn( _( "Dive from moving vehicle?" ) ) ) { g->moving_vehicle_dismount( dest_loc ); @@ -619,7 +619,7 @@ void avatar_action::autoattack( avatar &you, map &m ) } ); const tripoint diff = best.pos() - you.pos(); - if( abs( diff.x ) <= 1 && abs( diff.y ) <= 1 && diff.z == 0 ) { + if( std::abs( diff.x ) <= 1 && std::abs( diff.y ) <= 1 && diff.z == 0 ) { move( you, m, tripoint( diff.xy(), 0 ) ); return; } diff --git a/src/bionics.cpp b/src/bionics.cpp index 9d52031247cba..ef58a6505b2e5 100644 --- a/src/bionics.cpp +++ b/src/bionics.cpp @@ -782,7 +782,7 @@ bool Character::activate_bionic( int b, bool eff_only ) int vehwindspeed = 0; if( optional_vpart_position vp = g->m.veh_at( pos() ) ) { // vehicle velocity in mph - vehwindspeed = abs( vp->vehicle().velocity / 100 ); + vehwindspeed = std::abs( vp->vehicle().velocity / 100 ); } const oter_id &cur_om_ter = overmap_buffer.ter( global_omt_location() ); /* cache g->get_temperature( player location ) since it is used twice. No reason to recalc */ @@ -1095,7 +1095,7 @@ bool Character::burn_fuel( int b, bool start ) const optional_vpart_position vp = g->m.veh_at( pos() ); if( vp ) { // vehicle velocity in mph - vehwindspeed = abs( vp->vehicle().velocity / 100 ); + vehwindspeed = std::abs( vp->vehicle().velocity / 100 ); } const double windpower = get_local_windpower( g->weather.windspeed + vehwindspeed, overmap_buffer.ter( global_omt_location() ), pos(), g->weather.winddirection, @@ -1175,7 +1175,7 @@ void Character::passive_power_gen( int b ) const optional_vpart_position vp = g->m.veh_at( pos() ); if( vp ) { // vehicle velocity in mph - vehwindspeed = abs( vp->vehicle().velocity / 100 ); + vehwindspeed = std::abs( vp->vehicle().velocity / 100 ); } const double windpower = get_local_windpower( g->weather.windspeed + vehwindspeed, overmap_buffer.ter( global_omt_location() ), pos(), g->weather.winddirection, @@ -1553,13 +1553,14 @@ void Character::bionics_uninstall_failure( int difficulty, int success, float ad { // "success" should be passed in as a negative integer representing how far off we // were for a successful removal. We use this to determine consequences for failing. - success = abs( success ); + success = std::abs( success ); // failure level is decided by how far off the character was from a successful removal, and // this is scaled up or down by the ratio of difficulty/skill. At high skill levels (or low // difficulties), only minor consequences occur. At low skill levels, severe consequences // are more likely. - const int failure_level = static_cast( sqrt( success * 4.0 * difficulty / adjusted_skill ) ); + const int failure_level = static_cast( std::sqrt( success * 4.0 * difficulty / + adjusted_skill ) ); const int fail_type = std::min( 5, failure_level ); if( fail_type <= 0 ) { @@ -1617,13 +1618,14 @@ void Character::bionics_uninstall_failure( monster &installer, player &patient, // "success" should be passed in as a negative integer representing how far off we // were for a successful removal. We use this to determine consequences for failing. - success = abs( success ); + success = std::abs( success ); // failure level is decided by how far off the monster was from a successful removal, and // this is scaled up or down by the ratio of difficulty/skill. At high skill levels (or low // difficulties), only minor consequences occur. At low skill levels, severe consequences // are more likely. - const int failure_level = static_cast( sqrt( success * 4.0 * difficulty / adjusted_skill ) ); + const int failure_level = static_cast( std::sqrt( success * 4.0 * difficulty / + adjusted_skill ) ); const int fail_type = std::min( 5, failure_level ); bool u_see = sees( patient ); @@ -1780,7 +1782,7 @@ int bionic_manip_cos( float adjusted_skill, int bionic_difficulty ) // to reserve bionics for characters with the appropriate skill. For more difficult bionics, the // curve flattens out just above 80% chance_of_success = static_cast( ( 100 * skill_difficulty_parameter ) / - ( skill_difficulty_parameter + sqrt( 1 / skill_difficulty_parameter ) ) ); + ( skill_difficulty_parameter + std::sqrt( 1 / skill_difficulty_parameter ) ) ); return chance_of_success; } @@ -2258,13 +2260,13 @@ void Character::bionics_install_failure( const bionic_id &bid, const std::string { // "success" should be passed in as a negative integer representing how far off we // were for a successful install. We use this to determine consequences for failing. - success = abs( success ); + success = std::abs( success ); // failure level is decided by how far off the character was from a successful install, and // this is scaled up or down by the ratio of difficulty/skill. At high skill levels (or low // difficulties), only minor consequences occur. At low skill levels, severe consequences // are more likely. - int failure_level = static_cast( sqrt( success * 4.0 * difficulty / adjusted_skill ) ); + int failure_level = static_cast( std::sqrt( success * 4.0 * difficulty / adjusted_skill ) ); int fail_type = ( failure_level > 5 ? 5 : failure_level ); bool drop_cbm = false; add_msg( m_neutral, _( "The installation is a failure." ) ); diff --git a/src/calendar.cpp b/src/calendar.cpp index a4be596d497dd..0487a74ae3b5b 100644 --- a/src/calendar.cpp +++ b/src/calendar.cpp @@ -68,7 +68,7 @@ moon_phase get_moon_phase( const time_point &p ) const int num_middays = to_days( p - calendar::turn_zero + 1_days / 2 ); const time_duration nearest_midnight = num_middays * 1_days; const double phase_change = nearest_midnight / moon_phase_duration; - const int current_phase = static_cast( round( phase_change * MOON_PHASE_MAX ) ) % + const int current_phase = static_cast( std::round( phase_change * MOON_PHASE_MAX ) ) % static_cast( MOON_PHASE_MAX ); return static_cast( current_phase ); } diff --git a/src/cata_tiles.cpp b/src/cata_tiles.cpp index ca6e2cc8157e1..634fbdbcb8f67 100644 --- a/src/cata_tiles.cpp +++ b/src/cata_tiles.cpp @@ -1441,11 +1441,11 @@ void cata_tiles::get_window_tile_counts( const int width, const int height, int int &rows ) const { if( tile_iso ) { - columns = ceil( static_cast( width ) / tile_width ) * 2 + 4; - rows = ceil( static_cast( height ) / ( tile_width / 2.0 - 1 ) ) * 2 + 4; + columns = std::ceil( static_cast( width ) / tile_width ) * 2 + 4; + rows = std::ceil( static_cast( height ) / ( tile_width / 2.0 - 1 ) ) * 2 + 4; } else { - columns = ceil( static_cast( width ) / tile_width ); - rows = ceil( static_cast( height ) / tile_height ); + columns = std::ceil( static_cast( width ) / tile_width ); + rows = std::ceil( static_cast( height ) / tile_height ); } } diff --git a/src/cata_utility.cpp b/src/cata_utility.cpp index fde075f31f2ee..a7bb87fe2445b 100644 --- a/src/cata_utility.cpp +++ b/src/cata_utility.cpp @@ -126,7 +126,7 @@ bool match_include_exclude( const std::string &text, std::string filter ) double logarithmic( double t ) { - return 1 / ( 1 + exp( -t ) ); + return 1 / ( 1 + std::exp( -t ) ); } double logarithmic_range( int min, int max, int pos ) diff --git a/src/character.cpp b/src/character.cpp index 51d7ec0ae621c..cf232851bfff4 100644 --- a/src/character.cpp +++ b/src/character.cpp @@ -685,11 +685,9 @@ int Character::sight_range( int light_level ) const * log(LIGHT_AMBIENT_LOW / light_level) <= LIGHT_TRANSPARENCY_OPEN_AIR * distance * log(LIGHT_AMBIENT_LOW / light_level) * (1 / LIGHT_TRANSPARENCY_OPEN_AIR) <= distance */ - int range = static_cast( -log( get_vision_threshold( static_cast( g->m.ambient_light_at( - pos() ) ) ) / - static_cast( light_level ) ) * + int range = static_cast( -std::log( get_vision_threshold( static_cast + ( g->m.ambient_light_at( pos() ) ) ) / static_cast( light_level ) ) * ( 1.0 / LIGHT_TRANSPARENCY_OPEN_AIR ) ); - // int range = log(light_level * LIGHT_AMBIENT_LOW) / LIGHT_TRANSPARENCY_OPEN_AIR; // Clamp to [1, sight_max]. return clamp( range, 1, sight_max ); @@ -1687,7 +1685,7 @@ void Character::recalc_sight_limits() static float threshold_for_range( float range ) { constexpr float epsilon = 0.01f; - return LIGHT_AMBIENT_MINIMAL / exp( range * LIGHT_TRANSPARENCY_OPEN_AIR ) - epsilon; + return LIGHT_AMBIENT_MINIMAL / std::exp( range * LIGHT_TRANSPARENCY_OPEN_AIR ) - epsilon; } float Character::get_vision_threshold( float light_level ) const @@ -2616,8 +2614,8 @@ units::mass Character::weight_carried_with_tweaks( const item_tweaks &tweaks ) c } // Exclude wielded item if using lifting tool if( weaponweight + ret > weight_capacity() ) { - const float liftrequirement = ceil( units::to_gram( weaponweight ) / units::to_gram - ( TOOL_LIFT_FACTOR ) ); + const float liftrequirement = std::ceil( units::to_gram( weaponweight ) / + units::to_gram( TOOL_LIFT_FACTOR ) ); if( g->new_game || best_nearby_lifting_assist() < liftrequirement ) { ret += weaponweight; } @@ -4454,7 +4452,7 @@ void Character::update_health( int external_modifiers ) // For small differences, it changes 4 points per day // For large ones, up to ~40% of the difference per day int health_change = effective_healthy_mod - get_healthy() + external_modifiers; - mod_healthy( sgn( health_change ) * std::max( 1, abs( health_change ) / 10 ) ); + mod_healthy( sgn( health_change ) * std::max( 1, std::abs( health_change ) / 10 ) ); // And healthy_mod decays over time. // Slowly near 0, but it's hard to overpower it near +/-100 @@ -5133,7 +5131,7 @@ void Character::update_bodytemp() int vehwindspeed = 0; const optional_vpart_position vp = g->m.veh_at( pos() ); if( vp ) { - vehwindspeed = abs( vp->vehicle().velocity / 100 ); // vehicle velocity in mph + vehwindspeed = std::abs( vp->vehicle().velocity / 100 ); // vehicle velocity in mph } const oter_id &cur_om_ter = overmap_buffer.ter( global_omt_location() ); bool sheltered = g->is_sheltered( pos() ); @@ -5247,8 +5245,8 @@ void Character::update_bodytemp() frostbite_timer[bp] -= std::max( 5, h_radiation ); } // 111F (44C) is a temperature in which proteins break down: https://en.wikipedia.org/wiki/Burn - blister_count += h_radiation - 111 > 0 ? std::max( static_cast( sqrt( h_radiation - 111 ) ), - 0 ) : 0; + blister_count += h_radiation - 111 > 0 ? + std::max( static_cast( std::sqrt( h_radiation - 111 ) ), 0 ) : 0; const bool pyromania = has_trait( trait_PYROMANIA ); // BLISTERS : Skin gets blisters from intense heat exposure. @@ -5414,7 +5412,8 @@ void Character::update_bodytemp() rounding_error = 1; } if( temp_cur[bp] != temp_conv[bp] ) { - temp_cur[bp] = static_cast( temp_difference * exp( -0.002 ) + temp_conv[bp] + rounding_error ); + temp_cur[bp] = static_cast( temp_difference * std::exp( -0.002 ) + temp_conv[bp] + + rounding_error ); } // This statement checks if we should be wearing our bonus warmth. // If, after all the warmth calculations, we should be, then we have to recalculate the temperature. @@ -5428,7 +5427,8 @@ void Character::update_bodytemp() } if( temp_before != temp_conv[bp] ) { temp_difference = temp_before - temp_conv[bp]; - temp_cur[bp] = static_cast( temp_difference * exp( -0.002 ) + temp_conv[bp] + rounding_error ); + temp_cur[bp] = static_cast( temp_difference * std::exp( -0.002 ) + temp_conv[bp] + + rounding_error ); } } int temp_after = temp_cur[bp]; @@ -6874,7 +6874,7 @@ std::string Character::get_weight_description() const units::mass Character::bodyweight() const { - return units::from_kilogram( get_bmi() * pow( height() / 100.0f, 2 ) ); + return units::from_kilogram( get_bmi() * std::pow( height() / 100.0f, 2 ) ); } units::mass Character::bionics_weight() const @@ -6968,9 +6968,9 @@ int Character::get_bmr() const Values are for males, and average! */ const int equation_constant = 5; - return ceil( metabolic_rate_base() * activity_level * ( units::to_gram - ( bodyweight() / 100.0 ) + - ( 6.25 * height() ) - ( 5 * age() ) + equation_constant ) ); + return std::ceil( metabolic_rate_base() * activity_level * ( units::to_gram + ( bodyweight() / 100.0 ) + + ( 6.25 * height() ) - ( 5 * age() ) + equation_constant ) ); } void Character::increase_activity_level( float new_level ) @@ -8724,7 +8724,7 @@ void Character::apply_persistent_morale() } // The penalty starts at 1 at min_time and scales up to max_unhappiness at max_time. const float t = ( total_time - min_time ) / ( max_time - min_time ); - const int pen = ceil( lerp_clamped( 0, max_unhappiness, t ) ); + const int pen = std::ceil( lerp_clamped( 0, max_unhappiness, t ) ); if( pen > 0 ) { add_morale( MORALE_PERM_NOMAD, -pen, -pen, 1_minutes, 1_minutes, true ); } @@ -9287,7 +9287,7 @@ std::list Character::use_charges( const itype_id &what, int qty, qty -= std::min( qty, bio ); } - int adv = charges_of( "adv_UPS_off", static_cast( ceil( qty * 0.6 ) ) ); + int adv = charges_of( "adv_UPS_off", static_cast( std::ceil( qty * 0.6 ) ) ); if( adv > 0 ) { std::list found = use_charges( "adv_UPS_off", adv ); res.splice( res.end(), found ); @@ -9493,7 +9493,7 @@ int Character::heartrate_bpm() const //Based on get_max_healthy that already has bmi factored const int healthy = get_max_healthy(); //a bit arbitary formula that can use some love - float healthy_modifier = -0.05f * round( healthy / 20.0f ); + float healthy_modifier = -0.05f * std::round( healthy / 20.0f ); heartbeat += average_heartbeat * healthy_modifier; //Pain simply adds 2% per point after it reaches 5 (that's arbitary) const int cur_pain = get_perceived_pain(); diff --git a/src/computer_session.cpp b/src/computer_session.cpp index 842a4df75832c..a7401c0498144 100644 --- a/src/computer_session.cpp +++ b/src/computer_session.cpp @@ -649,7 +649,7 @@ void computer_session::action_amigara_log() reset_terminal(); print_line( _( "SITE %d%d%d\n" "PERTINENT FOREMAN LOGS WILL BE PREPENDED TO NOTES" ), - g->get_levx(), g->get_levy(), abs( g->get_levz() ) ); + g->get_levx(), g->get_levy(), std::abs( g->get_levz() ) ); print_text( "%s", SNIPPET.random_from_category( "amigara4" ).value_or( translation() ) ); print_gibberish_line(); print_gibberish_line(); diff --git a/src/consumption.cpp b/src/consumption.cpp index e5877948c1c0e..dfc93306432ed 100644 --- a/src/consumption.cpp +++ b/src/consumption.cpp @@ -496,7 +496,7 @@ std::pair Character::fun_for( const item &comest ) const } if( has_active_bionic( bio_taste_blocker ) && - get_power_level() > units::from_kilojoule( abs( comest.get_comestible_fun() ) ) && + get_power_level() > units::from_kilojoule( std::abs( comest.get_comestible_fun() ) ) && fun < 0 ) { fun = 0; } @@ -1033,7 +1033,7 @@ void Character::modify_stimulation( const islot_comestible &comest ) { const int current_stim = get_stim(); if( comest.stim != 0 && - ( abs( current_stim ) < ( abs( comest.stim ) * 3 ) || + ( std::abs( current_stim ) < ( std::abs( comest.stim ) * 3 ) || sgn( current_stim ) != sgn( comest.stim ) ) ) { if( comest.stim < 0 ) { set_stim( std::max( comest.stim * 3, current_stim + comest.stim ) ); diff --git a/src/craft_command.cpp b/src/craft_command.cpp index e0a2e75205b07..6d83371116554 100644 --- a/src/craft_command.cpp +++ b/src/craft_command.cpp @@ -292,7 +292,7 @@ std::vector> craft_command::check_item_components_miss for( const auto &item_sel : item_selections ) { itype_id type = item_sel.comp.type; const item_comp component = item_sel.comp; - const int count = component.count > 0 ? component.count * batch_size : abs( component.count ); + const int count = component.count > 0 ? component.count * batch_size : std::abs( component.count ); if( item::count_by_charges( type ) && count > 0 ) { switch( item_sel.use_from ) { diff --git a/src/crafting.cpp b/src/crafting.cpp index c4d64ac1d87de..f2ce6ecc286cf 100644 --- a/src/crafting.cpp +++ b/src/crafting.cpp @@ -1122,7 +1122,7 @@ void player::complete_craft( item &craft, const tripoint &loc ) const double learning_speed = std::max( get_skill_level( making.skill_used ), 1 ) * std::max( get_int(), 1 ); - const double time_to_learn = 1000 * 8 * pow( difficulty, 4 ) / learning_speed; + const double time_to_learn = 1000 * 8 * std::pow( difficulty, 4 ) / learning_speed; if( x_in_y( making.time, time_to_learn ) ) { learn_recipe( &making ); add_msg( m_good, _( "You memorized the recipe for %s!" ), @@ -1406,7 +1406,7 @@ comp_selection player::select_item_component( const std::vector 0 ) ? component.count * batch : abs( component.count ); + int count = ( component.count > 0 ) ? component.count * batch : std::abs( component.count ); if( item::count_by_charges( type ) && count > 0 ) { int map_charges = map_inv.charges_of( type, INT_MAX, filter ); @@ -1603,7 +1603,7 @@ std::list player::consume_items( map &m, const comp_selection & const tripoint &loc = origin; const bool by_charges = item::count_by_charges( selected_comp.type ) && selected_comp.count > 0; // Count given to use_amount/use_charges, changed by those functions! - int real_count = ( selected_comp.count > 0 ) ? selected_comp.count * batch : abs( + int real_count = ( selected_comp.count > 0 ) ? selected_comp.count * batch : std::abs( selected_comp.count ); // First try to get everything from the map, than (remaining amount) from player if( is.use_from & use_from_map ) { diff --git a/src/creature.cpp b/src/creature.cpp index 6c545260be01f..e7d5c499e8469 100644 --- a/src/creature.cpp +++ b/src/creature.cpp @@ -222,8 +222,8 @@ bool Creature::sees( const Creature &critter ) const ( critter.has_flag( MF_NIGHT_INVISIBILITY ) && g->m.light_at( critter.pos() ) <= LL_LOW ) || ( critter.is_underwater() && !is_underwater() && g->m.is_divable( critter.pos() ) ) || ( g->m.has_flag_ter_or_furn( TFLAG_HIDE_PLACE, critter.pos() ) && - !( abs( posx() - critter.posx() ) <= 1 && abs( posy() - critter.posy() ) <= 1 && - abs( posz() - critter.posz() ) <= 1 ) ) ) { + !( std::abs( posx() - critter.posx() ) <= 1 && std::abs( posy() - critter.posy() ) <= 1 && + std::abs( posz() - critter.posz() ) <= 1 ) ) ) { return false; } if( ch != nullptr ) { @@ -421,7 +421,7 @@ Creature *Creature::auto_find_hostile_target( int range, int &boo_hoo, int area bool maybe_boo = false; if( angle_iff ) { int tangle = coord_to_angle( pos(), m->pos() ); - int diff = abs( u_angle - tangle ); + int diff = std::abs( u_angle - tangle ); // Player is in the angle and not too far behind the target if( ( diff + iff_hangle > 360 || diff < iff_hangle ) && ( dist * 3 / 2 + 6 > pldist ) ) { diff --git a/src/dump.cpp b/src/dump.cpp index 828e125e0b031..6794fd95669ed 100644 --- a/src/dump.cpp +++ b/src/dump.cpp @@ -309,7 +309,7 @@ bool game::dump_stats( const std::string &what, dump_mode mode, std::vector r; r.push_back( obj.name() ); r.push_back( obj.location ); - r.push_back( to_string( static_cast( ceil( to_gram( item( obj.item ).weight() ) / + r.push_back( to_string( static_cast( std::ceil( to_gram( item( obj.item ).weight() ) / 1000.0 ) ) ) ); r.push_back( to_string( obj.size / units::legacy_volume_factor ) ); rows.push_back( r ); diff --git a/src/explosion.cpp b/src/explosion.cpp index ea9e2f50fb37e..ffe2af1e9263e 100644 --- a/src/explosion.cpp +++ b/src/explosion.cpp @@ -868,7 +868,8 @@ fragment_cloud shrapnel_calc( const fragment_cloud &initial, // SWAG coefficient of drag. constexpr float Cd = 0.5; fragment_cloud new_cloud; - new_cloud.velocity = initial.velocity * exp( -cloud.velocity * ( ( Cd * fragment_area * distance ) / + new_cloud.velocity = initial.velocity * std::exp( -cloud.velocity * ( ( + Cd * fragment_area * distance ) / ( 2.0 * fragment_mass ) ) ); // Two effects, the accumulated proportion of blocked fragments, // and the inverse-square dilution of fragments with distance. diff --git a/src/game.cpp b/src/game.cpp index 53001432a296a..c3bee17f5c5c2 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -5027,7 +5027,7 @@ void game::save_cyborg( item *cyborg, const tripoint &couch_pos, player &install load_npcs(); } else { - const int failure_level = static_cast( sqrt( abs( success ) * 4.0 * difficulty / + const int failure_level = static_cast( std::sqrt( std::abs( success ) * 4.0 * difficulty / adjusted_skill ) ); const int fail_type = std::min( 5, failure_level ); switch( fail_type ) { @@ -9033,7 +9033,7 @@ bool game::walk_move( const tripoint &dest_loc ) } const double base_moves = u.run_cost( mcost, diag ) * 100.0 / crit->get_speed(); const double encumb_moves = u.get_weight() / 4800.0_gram; - u.moves -= static_cast( ceil( base_moves + encumb_moves ) ); + u.moves -= static_cast( std::ceil( base_moves + encumb_moves ) ); if( u.movement_mode_is( CMM_WALK ) ) { crit->use_mech_power( -2 ); } else if( u.movement_mode_is( CMM_CROUCH ) ) { @@ -9778,7 +9778,7 @@ bool game::grabbed_furn_move( const tripoint &dp ) if( shifting_furniture ) { // We didn't move tripoint d_sum = u.grab_point + dp; - if( abs( d_sum.x ) < 2 && abs( d_sum.y ) < 2 ) { + if( std::abs( d_sum.x ) < 2 && std::abs( d_sum.y ) < 2 ) { u.grab_point = d_sum; // furniture moved relative to us } else { // we pushed furniture out of reach add_msg( _( "You let go of the %s." ), furntype.name() ); @@ -10253,7 +10253,7 @@ void game::vertical_move( int movez, bool force ) std::vector> npcs_to_bring; std::vector monsters_following; - if( !m.has_zlevels() && abs( movez ) == 1 ) { + if( !m.has_zlevels() && std::abs( movez ) == 1 ) { std::copy_if( active_npc.begin(), active_npc.end(), back_inserter( npcs_to_bring ), [this]( const shared_ptr_fast &np ) { return np->is_walking_with() && !np->is_mounted() && !np->in_sleep_state() && @@ -10261,7 +10261,7 @@ void game::vertical_move( int movez, bool force ) } ); } - if( m.has_zlevels() && abs( movez ) == 1 ) { + if( m.has_zlevels() && std::abs( movez ) == 1 ) { bool ladder = m.has_flag( "DIFFICULT_Z", u.pos() ); for( monster &critter : all_monsters() ) { if( ladder && !critter.climbs() ) { diff --git a/src/grab.cpp b/src/grab.cpp index 36002cdd425d0..0a8b784d4dbcf 100644 --- a/src/grab.cpp +++ b/src/grab.cpp @@ -55,7 +55,7 @@ bool game::grabbed_veh_move( const tripoint &dp ) if( dp == prev_grab ) { // We are pushing in the direction of vehicle dp_veh = dp; - } else if( abs( dp.x + dp_veh.x ) != 2 && abs( dp.y + dp_veh.y ) != 2 ) { + } else if( std::abs( dp.x + dp_veh.x ) != 2 && std::abs( dp.y + dp_veh.y ) != 2 ) { // Not actually moving the vehicle, don't do the checks u.grab_point = -( dp + dp_veh ); return false; diff --git a/src/handle_action.cpp b/src/handle_action.cpp index 4d7ad6620e182..03942d8007efb 100644 --- a/src/handle_action.cpp +++ b/src/handle_action.cpp @@ -604,17 +604,17 @@ static void handbrake() vehicle *const veh = &vp->vehicle(); add_msg( _( "You pull a handbrake." ) ); veh->cruise_velocity = 0; - if( veh->last_turn != 0 && rng( 15, 60 ) * 100 < abs( veh->velocity ) ) { + if( veh->last_turn != 0 && rng( 15, 60 ) * 100 < std::abs( veh->velocity ) ) { veh->skidding = true; add_msg( m_warning, _( "You lose control of %s." ), veh->name ); veh->turn( veh->last_turn > 0 ? 60 : -60 ); } else { - int braking_power = abs( veh->velocity ) / 2 + 10 * 100; - if( abs( veh->velocity ) < braking_power ) { + int braking_power = std::abs( veh->velocity ) / 2 + 10 * 100; + if( std::abs( veh->velocity ) < braking_power ) { veh->stop(); } else { int sgn = veh->velocity > 0 ? 1 : -1; - veh->velocity = sgn * ( abs( veh->velocity ) - braking_power ); + veh->velocity = sgn * ( std::abs( veh->velocity ) - braking_power ); } } g->u.moves = 0; diff --git a/src/iexamine.cpp b/src/iexamine.cpp index daecac6b5b322..c6fb508b73828 100644 --- a/src/iexamine.cpp +++ b/src/iexamine.cpp @@ -1824,7 +1824,7 @@ static bool harvest_common( player &p, const tripoint &examp, bool furn, bool ne for( const auto &entry : harvest ) { float min_num = entry.base_num.first + lev * entry.scale_num.first; float max_num = entry.base_num.second + lev * entry.scale_num.second; - int roll = std::min( entry.max, round( rng_float( min_num, max_num ) ) ); + int roll = std::min( entry.max, std::round( rng_float( min_num, max_num ) ) ); if( roll >= 1 ) { got_anything = true; for( int i = 0; i < roll; i++ ) { diff --git a/src/input.cpp b/src/input.cpp index fcac31418f167..0ac296cf9f42a 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -1023,9 +1023,9 @@ action_id input_context::display_menu( const bool permit_execute_action ) size_t legwidth = 0; string_input_popup spopup; const auto recalc_size = [&]( ui_adaptor & ui ) { - int maxwidth = max( FULL_SCREEN_WIDTH, TERMX ); + int maxwidth = std::max( FULL_SCREEN_WIDTH, TERMX ); width = min( 80, maxwidth ); - int maxheight = max( FULL_SCREEN_HEIGHT, TERMY ); + int maxheight = std::max( FULL_SCREEN_HEIGHT, TERMY ); height = min( maxheight, static_cast( hotkeys.size() ) + LEGEND_HEIGHT + BORDER_SPACE ); w_help = catacurses::newwin( height - 2, width - 2, diff --git a/src/inventory.cpp b/src/inventory.cpp index aca0b005c39b3..a7ef5d0542694 100644 --- a/src/inventory.cpp +++ b/src/inventory.cpp @@ -858,15 +858,15 @@ item *inventory::most_appropriate_painkiller( int pain ) int diff = 9999; itype_id type = elem.front().typeId(); if( type == "aspirin" ) { - diff = abs( pain - 15 ); + diff = std::abs( pain - 15 ); } else if( type == "codeine" ) { - diff = abs( pain - 30 ); + diff = std::abs( pain - 30 ); } else if( type == "oxycodone" ) { - diff = abs( pain - 60 ); + diff = std::abs( pain - 60 ); } else if( type == "heroin" ) { - diff = abs( pain - 100 ); + diff = std::abs( pain - 100 ); } else if( type == "tramadol" ) { - diff = abs( pain - 40 ) / 2; // Bonus since it's long-acting + diff = std::abs( pain - 40 ) / 2; // Bonus since it's long-acting } if( diff < difference ) { diff --git a/src/item.cpp b/src/item.cpp index 962d4c4eafaea..74331bcf67833 100644 --- a/src/item.cpp +++ b/src/item.cpp @@ -1563,7 +1563,7 @@ void item::med_info( const item *med_item, std::vector &info, const it if( parts->test( iteminfo_parts::MED_PORTIONS ) ) { info.push_back( iteminfo( "MED", _( "Portions: " ), - abs( static_cast( med_item->charges ) * batch ) ) ); + std::abs( static_cast( med_item->charges ) * batch ) ) ); } if( med_com->addict && parts->test( iteminfo_parts::DESCRIPTION_MED_ADDICTING ) ) { @@ -1620,7 +1620,7 @@ void item::food_info( const item *food_item, std::vector &info, if( parts->test( iteminfo_parts::FOOD_PORTIONS ) ) { info.push_back( iteminfo( "FOOD", _( "Portions: " ), - abs( static_cast( food_item->charges ) * batch ) ) ); + std::abs( static_cast( food_item->charges ) * batch ) ) ); } if( food_item->corpse != nullptr && parts->test( iteminfo_parts::FOOD_SMELL ) && ( debug || ( g != nullptr && ( g->u.has_trait( trait_CARNIVORE ) || @@ -2008,7 +2008,7 @@ void item::gun_info( const item *mod, std::vector &info, const iteminf return e.second.qty > 1 && !e.second.melee(); } ) ) { info.emplace_back( "GUN", _( "Recommended strength (burst): " ), "", - iteminfo::lower_is_better, ceil( mod->type->weight / 333.0_gram ) ); + iteminfo::lower_is_better, std::ceil( mod->type->weight / 333.0_gram ) ); } if( parts->test( iteminfo_parts::GUN_RELOAD_TIME ) ) { @@ -6519,7 +6519,7 @@ double item::calculate_by_enchantment( const Character &owner, double modify, modify += add_value; modify *= mult_value; if( round_value ) { - modify = round( modify ); + modify = std::round( modify ); } return modify; } @@ -6538,7 +6538,7 @@ double item::calculate_by_enchantment_wield( double modify, enchantment::mod val modify += add_value; modify *= mult_value; if( round_value ) { - modify = round( modify ); + modify = std::round( modify ); } return modify; } @@ -6852,7 +6852,7 @@ int item::gun_recoil( const player &p, bool bipod ) const handling /= 10; // algorithm is biased so heavier weapons benefit more from improved handling - handling = pow( wt, 0.8 ) * pow( handling, 1.2 ); + handling = std::pow( wt, 0.8 ) * std::pow( handling, 1.2 ); int qty = type->gun->recoil; if( ammo_data() ) { @@ -8798,7 +8798,7 @@ void item::calc_temp( const int temp, const float insulation, const time_point & if( 0.00001 * specific_energy < completely_frozen_specific_energy ) { // Was solid. new_item_temperature = ( - temperature_difference - * exp( - to_turns( time_delta ) * conductivity_term / ( mass * specific_heat_solid ) ) + * std::exp( - to_turns( time_delta ) * conductivity_term / ( mass * specific_heat_solid ) ) + env_temperature ); new_specific_energy = new_item_temperature * specific_heat_solid; if( new_item_temperature > freezing_temperature + 0.5 ) { @@ -8807,7 +8807,7 @@ void item::calc_temp( const int temp, const float insulation, const time_point & // Calculate how long the item was solid // and apply rest of the time as melting extra_time = to_turns( time_delta ) - - log( - temperature_difference / ( freezing_temperature - env_temperature ) ) + - std::log( - temperature_difference / ( freezing_temperature - env_temperature ) ) * ( mass * specific_heat_solid / conductivity_term ); new_specific_energy = completely_frozen_specific_energy + conductivity_term @@ -8825,8 +8825,8 @@ void item::calc_temp( const int temp, const float insulation, const time_point & } else if( 0.00001 * specific_energy > completely_liquid_specific_energy ) { // Was liquid. new_item_temperature = ( - temperature_difference - * exp( - to_turns( time_delta ) * conductivity_term / ( mass * - specific_heat_liquid ) ) + * std::exp( - to_turns( time_delta ) * conductivity_term / ( mass * + specific_heat_liquid ) ) + env_temperature ); new_specific_energy = ( new_item_temperature - freezing_temperature ) * specific_heat_liquid + completely_liquid_specific_energy; @@ -8836,7 +8836,7 @@ void item::calc_temp( const int temp, const float insulation, const time_point & // Calculate how long the item was liquid // and apply rest of the time as freezing extra_time = to_turns( time_delta ) - - log( - temperature_difference / ( freezing_temperature - env_temperature ) ) + - std::log( - temperature_difference / ( freezing_temperature - env_temperature ) ) * ( mass * specific_heat_liquid / conductivity_term ); new_specific_energy = completely_liquid_specific_energy + conductivity_term @@ -8864,8 +8864,8 @@ void item::calc_temp( const int temp, const float insulation, const time_point & * ( completely_liquid_specific_energy - 0.00001 * specific_energy ); new_item_temperature = ( ( freezing_temperature - env_temperature ) - * exp( - extra_time * conductivity_term / ( mass * - specific_heat_liquid ) ) + * std::exp( - extra_time * conductivity_term / ( mass * + specific_heat_liquid ) ) + env_temperature ); new_specific_energy = ( new_item_temperature - freezing_temperature ) * specific_heat_liquid + completely_liquid_specific_energy; @@ -8877,8 +8877,8 @@ void item::calc_temp( const int temp, const float insulation, const time_point & * ( completely_frozen_specific_energy - 0.00001 * specific_energy ); new_item_temperature = ( ( freezing_temperature - env_temperature ) - * exp( - extra_time * conductivity_term / ( mass * - specific_heat_solid ) ) + * std::exp( - extra_time * conductivity_term / ( mass * + specific_heat_solid ) ) + env_temperature ); new_specific_energy = new_item_temperature * specific_heat_solid; } diff --git a/src/iuse.cpp b/src/iuse.cpp index 66e9529505c5f..93840af64fc37 100644 --- a/src/iuse.cpp +++ b/src/iuse.cpp @@ -440,9 +440,9 @@ static int alcohol( player &p, const item &it, const int strength ) 36_seconds, 1_minutes, 1_minutes ) * p.str_max ); // Metabolizing the booze improves the nutritional value; // might not be healthy, and still causes Thirst problems, though - p.stomach.mod_nutr( -( abs( it.get_comestible() ? it.type->comestible->stim : 0 ) ) ); + p.stomach.mod_nutr( -( std::abs( it.get_comestible() ? it.type->comestible->stim : 0 ) ) ); // Metabolizing it cancels out the depressant - p.mod_stim( abs( it.get_comestible() ? it.get_comestible()->stim : 0 ) ); + p.mod_stim( std::abs( it.get_comestible() ? it.get_comestible()->stim : 0 ) ); } else if( p.has_trait( trait_TOLERANCE ) ) { duration -= alc_strength( strength, 9_minutes, 16_minutes, 24_minutes ); } else if( p.has_trait( trait_LIGHTWEIGHT ) ) { @@ -5707,7 +5707,7 @@ int iuse::towel_common( player *p, item *it, bool t ) } // dry off from being wet - } else if( abs( p->has_morale( MORALE_WET ) ) ) { + } else if( std::abs( p->has_morale( MORALE_WET ) ) ) { p->rem_morale( MORALE_WET ); p->body_wetness.fill( 0 ); p->add_msg_if_player( _( "You use the %s to dry off, saturating it with water!" ), @@ -9312,7 +9312,7 @@ int iuse::weather_tool( player *p, item *it, bool, const tripoint & ) if( it->typeId() == "weather_reader" ) { int vehwindspeed = 0; if( optional_vpart_position vp = g->m.veh_at( p->pos() ) ) { - vehwindspeed = abs( vp->vehicle().velocity / 100 ); // For mph + vehwindspeed = std::abs( vp->vehicle().velocity / 100 ); // For mph } const oter_id &cur_om_ter = overmap_buffer.ter( p->global_omt_location() ); /* windpower defined in internal velocity units (=.01 mph) */ diff --git a/src/iuse_actor.cpp b/src/iuse_actor.cpp index 7213cfa0f470d..0b3ebaf4be601 100644 --- a/src/iuse_actor.cpp +++ b/src/iuse_actor.cpp @@ -1446,7 +1446,7 @@ int firestarter_actor::use( player &p, item &it, bool t, const tripoint &spos ) const int moves_base = moves_cost_by_fuel( pos ); const double moves_per_turn = to_moves( 1_turns ); const int min_moves = std::min( - moves_base, sqrt( 1 + moves_base / moves_per_turn ) * moves_per_turn ); + moves_base, std::sqrt( 1 + moves_base / moves_per_turn ) * moves_per_turn ); const int moves = std::max( min_moves, moves_base * moves_modifier ) / light; if( moves > to_moves( 1_minutes ) ) { // If more than 1 minute, inform the player diff --git a/src/lightmap.cpp b/src/lightmap.cpp index 2855345fe0aad..ff0217154601f 100644 --- a/src/lightmap.cpp +++ b/src/lightmap.cpp @@ -1444,8 +1444,8 @@ void map::apply_light_arc( const tripoint &p, int angle, float luminance, int wi void map::apply_light_ray( bool lit[LIGHTMAP_CACHE_X][LIGHTMAP_CACHE_Y], const tripoint &s, const tripoint &e, float luminance ) { - int ax = abs( e.x - s.x ) * 2; - int ay = abs( e.y - s.y ) * 2; + int ax = std::abs( e.x - s.x ) * 2; + int ay = std::abs( e.y - s.y ) * 2; int dx = ( s.x < e.x ) ? 1 : -1; int dy = ( s.y < e.y ) ? 1 : -1; int x = s.x; diff --git a/src/line.cpp b/src/line.cpp index 34340a0692ba4..6bb63361684fc 100644 --- a/src/line.cpp +++ b/src/line.cpp @@ -74,9 +74,9 @@ void bresenham( const tripoint &loc1, const tripoint &loc2, int t, int t2, const int sy = ( dy == 0 ? 0 : sgn( dy ) ); const int sz = ( dz == 0 ? 0 : sgn( dz ) ); // Absolute values of slope components, x2 to avoid rounding errors. - const int ax = abs( dx ) * 2; - const int ay = abs( dy ) * 2; - const int az = abs( dz ) * 2; + const int ax = std::abs( dx ) * 2; + const int ay = std::abs( dy ) * 2; + const int az = std::abs( dz ) * 2; tripoint cur( loc1 ); @@ -550,12 +550,12 @@ std::vector squares_in_direction( const point &p1, const point &p2 ) float rl_vec2d::magnitude() const { - return sqrt( x * x + y * y ); + return std::sqrt( x * x + y * y ); } float rl_vec3d::magnitude() const { - return sqrt( x * x + y * y + z * z ); + return std::sqrt( x * x + y * y + z * z ); } rl_vec2d rl_vec2d::normalized() const @@ -619,8 +619,8 @@ bool rl_vec2d::is_null() const point rl_vec2d::as_point() const { return point( - round( x ), - round( y ) + std::round( x ), + std::round( y ) ); } @@ -632,9 +632,9 @@ bool rl_vec3d::is_null() const tripoint rl_vec3d::as_point() const { return tripoint( - round( x ), - round( y ), - round( z ) + std::round( x ), + std::round( y ), + std::round( z ) ); } diff --git a/src/line.h b/src/line.h index 43f4b1377a733..95a0ffe7a3116 100644 --- a/src/line.h +++ b/src/line.h @@ -32,7 +32,7 @@ constexpr double ARCMIN( double v ) inline double iso_tangent( double distance, double vertex ) { // we can use the cosine formula (a² = b² + c² - 2bc⋅cosθ) to calculate the tangent - return sqrt( 2 * pow( distance, 2 ) * ( 1 - cos( ARCMIN( vertex ) ) ) ); + return std::sqrt( 2 * std::pow( distance, 2 ) * ( 1 - cos( ARCMIN( vertex ) ) ) ); } //! This compile-time usable function combines the sign of each (x, y, z) component into a single integer @@ -115,9 +115,9 @@ extern bool trigdist; inline float trig_dist( const tripoint &loc1, const tripoint &loc2 ) { - return sqrt( static_cast( ( loc1.x - loc2.x ) * ( loc1.x - loc2.x ) ) + - ( ( loc1.y - loc2.y ) * ( loc1.y - loc2.y ) ) + - ( ( loc1.z - loc2.z ) * ( loc1.z - loc2.z ) ) ); + return std::sqrt( static_cast( ( loc1.x - loc2.x ) * ( loc1.x - loc2.x ) ) + + ( ( loc1.y - loc2.y ) * ( loc1.y - loc2.y ) ) + + ( ( loc1.z - loc2.z ) * ( loc1.z - loc2.z ) ) ); } inline float trig_dist( const point &loc1, const point &loc2 ) { @@ -175,7 +175,7 @@ struct FastDistanceApproximation { } inline operator int() const { if( trigdist ) { - return sqrt( value ); + return std::sqrt( value ); } return value; } diff --git a/src/magic.cpp b/src/magic.cpp index e7d91cd0d9dcf..0ae149c5ec683 100644 --- a/src/magic.cpp +++ b/src/magic.cpp @@ -504,7 +504,7 @@ std::string spell::damage_string() const if( dmg >= 0 ) { return string_format( "%d", dmg ); } else { - return string_format( "+%d", abs( dmg ) ); + return string_format( "+%d", std::abs( dmg ) ); } } } @@ -616,10 +616,10 @@ int spell::energy_cost( const player &p ) const int cost; if( type->base_energy_cost < type->final_energy_cost ) { cost = std::min( type->final_energy_cost, - static_cast( round( type->base_energy_cost + type->energy_increment * get_level() ) ) ); + static_cast( std::round( type->base_energy_cost + type->energy_increment * get_level() ) ) ); } else if( type->base_energy_cost > type->final_energy_cost ) { cost = std::max( type->final_energy_cost, - static_cast( round( type->base_energy_cost + type->energy_increment * get_level() ) ) ); + static_cast( std::round( type->base_energy_cost + type->energy_increment * get_level() ) ) ); } else { cost = type->base_energy_cost; } @@ -687,10 +687,12 @@ int spell::casting_time( const player &p ) const int casting_time = 0; if( type->base_casting_time < type->final_casting_time ) { casting_time = std::min( type->final_casting_time, - static_cast( round( type->base_casting_time + type->casting_time_increment * get_level() ) ) ); + static_cast( std::round( type->base_casting_time + type->casting_time_increment * + get_level() ) ) ); } else if( type->base_casting_time > type->final_casting_time ) { casting_time = std::max( type->final_casting_time, - static_cast( round( type->base_casting_time + type->casting_time_increment * get_level() ) ) ); + static_cast( std::round( type->base_casting_time + type->casting_time_increment * + get_level() ) ) ); } else { casting_time = type->base_casting_time; } @@ -735,7 +737,7 @@ float spell::spell_fail( const player &p ) const } else if( effective_skill < 0.0f ) { return 1.0f; } - float fail_chance = pow( ( effective_skill - 30.0f ) / 30.0f, 2 ); + float fail_chance = std::pow( ( effective_skill - 30.0f ) / 30.0f, 2 ); if( has_flag( spell_flag::SOMATIC ) && !p.has_trait_flag( "SUBTLE_SPELL" ) ) { // the first 20 points of encumbrance combined is ignored const int arms_encumb = std::max( 0, p.encumb( bp_arm_l ) + p.encumb( bp_arm_r ) - 20 ); @@ -895,7 +897,7 @@ void spell::create_field( const tripoint &at ) const void spell::make_sound( const tripoint &target ) const { if( !has_flag( spell_flag::SILENT ) ) { - int loudness = abs( damage() ) / 3; + int loudness = std::abs( damage() ) / 3; if( has_flag( spell_flag::LOUD ) ) { loudness += 1 + damage() / 3; } @@ -1009,7 +1011,7 @@ constexpr float c = -62.5; int spell::get_level() const { // you aren't at the next level unless you have the requisite xp, so floor - return std::max( static_cast( floor( log( experience + a ) / b + c ) ), 0 ); + return std::max( static_cast( std::floor( std::log( experience + a ) / b + c ) ), 0 ); } int spell::get_max_level() const @@ -1026,7 +1028,7 @@ static int exp_for_level( int level ) if( level == 0 ) { return 0; } - return ceil( exp( ( level - c ) * b ) ) - a; + return std::ceil( std::exp( ( level - c ) * b ) ) - a; } int spell::exp_to_next_level() const @@ -1042,7 +1044,7 @@ std::string spell::exp_progress() const const int denominator = next_level_xp - this_level_xp; const float progress = static_cast( xp() - this_level_xp ) / std::max( 1.0f, static_cast( denominator ) ); - return string_format( "%i%%", clamp( static_cast( round( progress * 100 ) ), 0, 99 ) ); + return string_format( "%i%%", clamp( static_cast( std::round( progress * 100 ) ), 0, 99 ) ); } float spell::exp_modifier( const player &p ) const @@ -1059,7 +1061,7 @@ int spell::casting_exp( const player &p ) const // the amount of xp you would get with no modifiers const int base_casting_xp = 75; - return round( p.adjust_for_focus( base_casting_xp * exp_modifier( p ) ) ); + return std::round( p.adjust_for_focus( base_casting_xp * exp_modifier( p ) ) ); } std::string spell::enumerate_targets() const @@ -1157,7 +1159,7 @@ void spell::cast_all_effects( Creature &source, const tripoint &target ) const { if( has_flag( spell_flag::WONDER ) ) { const auto iter = type->additional_spells.begin(); - for( int num_spells = abs( damage() ); num_spells > 0; num_spells-- ) { + for( int num_spells = std::abs( damage() ); num_spells > 0; num_spells-- ) { if( type->additional_spells.empty() ) { debugmsg( "ERROR: %s has WONDER flag but no spells to choose from!", type->id.c_str() ); return; diff --git a/src/magic_spell_effect.cpp b/src/magic_spell_effect.cpp index 87988a5aef047..9ece4403a018d 100644 --- a/src/magic_spell_effect.cpp +++ b/src/magic_spell_effect.cpp @@ -191,8 +191,8 @@ std::set spell_effect::spell_effect_cone( const spell &sp, const tripo const int range = sp.range() + 1; const int initial_angle = coord_to_angle( source, target ); std::set end_points; - for( int angle = initial_angle - floor( aoe_radius / 2.0 ); - angle <= initial_angle + ceil( aoe_radius / 2.0 ); angle++ ) { + for( int angle = initial_angle - std::floor( aoe_radius / 2.0 ); + angle <= initial_angle + std::ceil( aoe_radius / 2.0 ); angle++ ) { tripoint potential; calc_ray_end( angle, range, source, potential ); end_points.emplace( potential ); @@ -793,7 +793,7 @@ void spell_effect::spawn_summoned_monster( const spell &sp, Creature &caster, const mtype_id mon_id( sp.effect_data() ); std::set area = spell_effect_area( sp, target, spell_effect_blast, caster ); // this should never be negative, but this'll keep problems from happening - size_t num_mons = abs( sp.damage() ); + size_t num_mons = std::abs( sp.damage() ); const time_duration summon_time = sp.duration_turns(); while( num_mons > 0 && !area.empty() ) { const size_t mon_spot = rng( 0, area.size() - 1 ); diff --git a/src/map.cpp b/src/map.cpp index c68a1d3c71de2..3a41eaaffc6e7 100755 --- a/src/map.cpp +++ b/src/map.cpp @@ -449,7 +449,7 @@ vehicle *map::move_vehicle( vehicle &veh, const tripoint &dp, const tileray &fac if( dp == tripoint_zero ) { debugmsg( "Empty displacement vector" ); return &veh; - } else if( abs( dp.x ) > 1 || abs( dp.y ) > 1 || abs( dp.z ) > 1 ) { + } else if( std::abs( dp.x ) > 1 || std::abs( dp.y ) > 1 || std::abs( dp.z ) > 1 ) { debugmsg( "Invalid displacement vector: %d, %d, %d", dp.x, dp.y, dp.z ); return &veh; } @@ -777,7 +777,7 @@ float map::vehicle_vehicle_collision( vehicle &veh, vehicle &veh2, const float m1 = to_kilogram( veh.total_mass() ); // Collision is perfectly inelastic for simplicity // Assume veh2 is standing still - dmg = abs( veh.vertical_velocity / 100 ) * m1 / 10; + dmg = std::abs( veh.vertical_velocity / 100 ) * m1 / 10; veh.vertical_velocity = 0; } @@ -1728,7 +1728,8 @@ bool map::valid_move( const tripoint &from, const tripoint &to, assert( to.z > std::numeric_limits::min() ); // Note: no need to check inbounds here, because maptile_at will do that // If oob tile is supplied, the maptile_at will be an unpassable "null" tile - if( abs( from.x - to.x ) > 1 || abs( from.y - to.y ) > 1 || abs( from.z - to.z ) > 1 ) { + if( std::abs( from.x - to.x ) > 1 || std::abs( from.y - to.y ) > 1 || + std::abs( from.z - to.z ) > 1 ) { return false; } @@ -1773,7 +1774,7 @@ bool map::valid_move( const tripoint &from, const tripoint &to, if( !up_ter.has_flag( TFLAG_NO_FLOOR ) && !up_ter.has_flag( TFLAG_GOES_DOWN ) && !up_is_ledge ) { // Can't move from up to down - if( abs( from.x - to.x ) == 1 || abs( from.y - to.y ) == 1 ) { + if( std::abs( from.x - to.x ) == 1 || std::abs( from.y - to.y ) == 1 ) { // Break the move into two - vertical then horizontal tripoint midpoint( down_p.xy(), up_p.z ); return valid_move( down_p, midpoint, bash, flying ) && @@ -4628,9 +4629,9 @@ bool map::could_see_items( const tripoint &p, const tripoint &from ) const if( container ) { // can see inside of containers if adjacent or // on top of the container - return ( abs( p.x - from.x ) <= 1 && - abs( p.y - from.y ) <= 1 && - abs( p.z - from.z ) <= 1 ); + return ( std::abs( p.x - from.x ) <= 1 && + std::abs( p.y - from.y ) <= 1 && + std::abs( p.z - from.z ) <= 1 ); } return true; } @@ -6443,7 +6444,7 @@ void map::shift( const point &sp ) return; // Skip this? } - if( abs( sp.x ) > 1 || abs( sp.y ) > 1 ) { + if( std::abs( sp.x ) > 1 || std::abs( sp.y ) > 1 ) { debugmsg( "map::shift called with a shift of more than one submap" ); } diff --git a/src/map_extras.cpp b/src/map_extras.cpp index 0bd57bacf05a4..b998c958265f2 100644 --- a/src/map_extras.cpp +++ b/src/map_extras.cpp @@ -318,7 +318,7 @@ static bool mx_helicopter( map &m, const tripoint &abs_sub ) } } - } else if( one_in( 4 + ( abs( x - cx ) + ( abs( y - + } else if( one_in( 4 + ( std::abs( x - cx ) + ( std::abs( y - cy ) ) ) ) ) { // 1 in 10 chance of being wreckage anyway m.make_rubble( tripoint( x, y, abs_sub.z ), f_wreckage, true ); if( !one_in( 3 ) ) { @@ -350,8 +350,8 @@ static bool mx_helicopter( map &m, const tripoint &abs_sub ) int x_offset = veh->dir_vec().x * x_length / 2; int y_offset = veh->dir_vec().y * y_length / 2; - int x_min = abs( bbox.p1.x ) + 0; - int y_min = abs( bbox.p1.y ) + 0; + int x_min = std::abs( bbox.p1.x ) + 0; + int y_min = std::abs( bbox.p1.y ) + 0; int x_max = SEEX * 2 - bbox.p2.x - 1; int y_max = SEEY * 2 - bbox.p2.y - 1; diff --git a/src/mapgen.cpp b/src/mapgen.cpp index 8d4835fbbad92..a6c49f194376d 100644 --- a/src/mapgen.cpp +++ b/src/mapgen.cpp @@ -3872,7 +3872,7 @@ void map::draw_lab( mapgendata &dat ) for( int i = 0; i < SEEX * 2; i++ ) { for( int j = 0; j < SEEY * 2; j++ ) { // Carve out a diamond area that covers 2 spaces on each edge. - if( i + j > 10 && i + j < 36 && abs( i - j ) < 13 ) { + if( i + j > 10 && i + j < 36 && std::abs( i - j ) < 13 ) { // Doors and walls get sometimes destroyed: // 100% at the edge, usually in a central cross, occasionally elsewhere. if( ( has_flag_ter( "DOOR", point( i, j ) ) || has_flag_ter( "WALL", point( i, j ) ) ) ) { @@ -3929,7 +3929,7 @@ void map::draw_lab( mapgendata &dat ) } else if( one_in( 2 ) ) { // Create a spread of densities, from all possible lights on, to 1/3, ... // to ~1 per segment. - light_odds = pow( rng( 1, 12 ), 1.6 ); + light_odds = std::pow( rng( 1, 12 ), 1.6 ); } if( light_odds > 0 ) { for( int i = 0; i < SEEX * 2; i++ ) { @@ -4429,7 +4429,7 @@ void map::draw_lab( mapgendata &dat ) if( central_lab ) { light_odds = 1; } else if( one_in( 2 ) ) { - light_odds = pow( rng( 1, 12 ), 1.6 ); + light_odds = std::pow( rng( 1, 12 ), 1.6 ); } if( light_odds > 0 ) { for( int i = 0; i < SEEX * 2; i++ ) { @@ -4461,7 +4461,7 @@ void map::draw_temple( mapgendata &dat ) square( this, t_rock_floor, point_zero, point( EAST_EDGE, SOUTH_EDGE ) ); // We always start at the south and go north. // We use (y / 2 + z) % 4 to guarantee that rooms don't repeat. - switch( 1 + abs( abs_sub.y / 2 + dat.zlevel() + 4 ) % 4 ) { // TODO: More varieties! + switch( 1 + std::abs( abs_sub.y / 2 + dat.zlevel() + 4 ) % 4 ) { // TODO: More varieties! case 1: // Flame bursts @@ -5484,7 +5484,7 @@ void map::draw_slimepit( mapgendata &dat ) j > SEEY * 2 - dat.s_fac * SEEY || i > SEEX * 2 - dat.e_fac * SEEX ) ) { ter_set( point( i, j ), ( !one_in( 10 ) ? t_slime : t_rock_floor ) ); - } else if( rng( 0, SEEX ) > abs( i - SEEX ) && rng( 0, SEEY ) > abs( j - SEEY ) ) { + } else if( rng( 0, SEEX ) > std::abs( i - SEEX ) && rng( 0, SEEY ) > std::abs( j - SEEY ) ) { ter_set( point( i, j ), t_slime ); } else if( dat.zlevel() == 0 ) { ter_set( point( i, j ), t_dirt ); diff --git a/src/mapgen_functions.cpp b/src/mapgen_functions.cpp index 8ed01b83b6f23..e18ebfd48940d 100644 --- a/src/mapgen_functions.cpp +++ b/src/mapgen_functions.cpp @@ -2434,7 +2434,7 @@ void mapgen_ants_four_way( mapgendata &dat ) } } x += rng( -1, 1 ); - while( abs( SEEX - x ) > SEEY * 2 - j - 1 ) { + while( std::abs( SEEX - x ) > SEEY * 2 - j - 1 ) { if( x < SEEX ) { x++; } @@ -2452,7 +2452,7 @@ void mapgen_ants_four_way( mapgendata &dat ) } } y += rng( -1, 1 ); - while( abs( SEEY - y ) > SEEX * 2 - i - 1 ) { + while( std::abs( SEEY - y ) > SEEX * 2 - i - 1 ) { if( y < SEEY ) { y++; } @@ -2476,7 +2476,7 @@ void mapgen_ants_straight( mapgendata &dat ) } } x += rng( -1, 1 ); - while( abs( SEEX - x ) > SEEX * 2 - j - 1 ) { + while( std::abs( SEEX - x ) > SEEX * 2 - j - 1 ) { if( x < SEEX ) { x++; } @@ -2503,7 +2503,7 @@ void mapgen_ants_tee( mapgendata &dat ) } } x += rng( -1, 1 ); - while( abs( SEEX - x ) > SEEY * 2 - j - 1 ) { + while( std::abs( SEEX - x ) > SEEY * 2 - j - 1 ) { if( x < SEEX ) { x++; } @@ -2520,7 +2520,7 @@ void mapgen_ants_tee( mapgendata &dat ) } } y += rng( -1, 1 ); - while( abs( SEEY - y ) > SEEX * 2 - 1 - i ) { + while( std::abs( SEEY - y ) > SEEX * 2 - 1 - i ) { if( y < SEEY ) { y++; } diff --git a/src/martialarts.cpp b/src/martialarts.cpp index 3f0e0867127a1..aa7b9336c0f7e 100644 --- a/src/martialarts.cpp +++ b/src/martialarts.cpp @@ -1283,7 +1283,7 @@ std::string ma_technique::get_description() const ( 100 * ( weighting - 1 ) ) ) + "\n"; } else if( weighting < -1 ) { dump += string_format( _( "* Lower chance to activate: 1/%s" ), - abs( weighting ) ) + "\n"; + std::abs( weighting ) ) + "\n"; } if( crit_ok ) { diff --git a/src/melee.cpp b/src/melee.cpp index 8f313e9191862..f944cff5fca2e 100644 --- a/src/melee.cpp +++ b/src/melee.cpp @@ -357,7 +357,7 @@ void player::roll_all_damage( bool crit, damage_instance &di, bool average, cons static void melee_train( player &p, int lo, int hi, const item &weap ) { - p.practice( skill_melee, ceil( rng( lo, hi ) / 2.0 ), hi ); + p.practice( skill_melee, std::ceil( rng( lo, hi ) / 2.0 ), hi ); // allocate XP proportional to damage stats // Pure unarmed needs a special case because it has 0 weapon damage @@ -1149,7 +1149,7 @@ matec_id player::pick_technique( Creature &t, const item &weap, } // If we have negative weighting then roll to see if it's valid this time - if( tec.weighting < 0 && !one_in( abs( tec.weighting ) ) ) { + if( tec.weighting < 0 && !one_in( std::abs( tec.weighting ) ) ) { continue; } @@ -1401,7 +1401,7 @@ void player::perform_technique( const ma_technique &technique, Creature &t, dama g->is_dangerous_tile( prev_pos ) || // Tile contains fire, etc ( to_swimmable && to_deepwater ) || // Dive into deep water is_mounted() || - ( veh0 != nullptr && abs( veh0->velocity ) > 100 ) || // Diving from moving vehicle + ( veh0 != nullptr && std::abs( veh0->velocity ) > 100 ) || // Diving from moving vehicle ( veh0 != nullptr && veh0->player_in_control( g->u ) ) || // Player is driving has_effect( effect_amigara ); diff --git a/src/mission_companion.cpp b/src/mission_companion.cpp index c3a94dcd6ae92..ebb10982ec883 100644 --- a/src/mission_companion.cpp +++ b/src/mission_companion.cpp @@ -336,7 +336,7 @@ void talk_function::commune_refuge_caravan( mission_data &mission_key, npc &p ) } else if( calendar::turn >= elem->companion_mission_time ) { entry = entry + " " + elem->name + _( " [COMPLETE]\n" ); } else { - entry = entry + " " + elem->name + " [" + to_string( abs( to_hours + entry = entry + " " + elem->name + " [" + to_string( std::abs( to_hours ( calendar::turn - elem->companion_mission_time ) ) ) + _( " Hours]\n" ); } } diff --git a/src/monattack.cpp b/src/monattack.cpp index dc9278edd780f..df985685c0447 100644 --- a/src/monattack.cpp +++ b/src/monattack.cpp @@ -475,7 +475,7 @@ bool mattack::shriek_stun( monster *z ) int cone_angle = 20; for( const tripoint &cone : g->m.points_in_radius( z->pos(), 4 ) ) { int tile_angle = coord_to_angle( z->pos(), cone ); - int diff = abs( target_angle - tile_angle ); + int diff = std::abs( target_angle - tile_angle ); // Skip the target, because it's outside cone or it's the source if( diff + cone_angle > 360 || diff > cone_angle || cone == z->pos() ) { continue; @@ -594,7 +594,7 @@ bool mattack::acid( monster *z ) tripoint dest = hitp + tripoint( i, j, 0 ); if( g->m.passable( dest ) && g->m.clear_path( dest, hitp, 6, 1, 100 ) && - ( ( one_in( abs( j ) ) && one_in( abs( i ) ) ) || ( i == 0 && j == 0 ) ) ) { + ( ( one_in( std::abs( j ) ) && one_in( std::abs( i ) ) ) || ( i == 0 && j == 0 ) ) ) { g->m.add_field( dest, fd_acid, 2 ); } } @@ -968,7 +968,7 @@ bool mattack::resurrect( monster *z ) if( corpses.empty() ) { // No nearby corpses if( found_eligible_corpse ) { // There was a corpse, but we haven't charged enough. - if( sees_necromancer && x_in_y( 1, sqrt( lowest_raise_score / 30.0 ) ) ) { + if( sees_necromancer && x_in_y( 1, std::sqrt( lowest_raise_score / 30.0 ) ) ) { add_msg( m_info, _( "The %s gesticulates wildly." ), z->name() ); } while( z->moves >= 0 ) { @@ -5423,14 +5423,14 @@ bool mattack::kamikaze( monster *z ) } // Extra check here to avoid sqrt if not needed if( exp_actor->explosion.power > -1 ) { - int tmp = static_cast( sqrt( static_cast( exp_actor->explosion.power / 4 ) ) ); + int tmp = static_cast( std::sqrt( static_cast( exp_actor->explosion.power / 4 ) ) ); if( tmp > radius ) { radius = tmp; } } if( exp_actor->explosion.shrapnel.casing_mass > 0 ) { // Actual factor is 2 * radius, but figure most pieces of shrapnel will miss - int tmp = static_cast( sqrt( exp_actor->explosion.power ) ); + int tmp = static_cast( std::sqrt( exp_actor->explosion.power ) ); if( tmp > radius ) { radius = tmp; } @@ -5768,5 +5768,5 @@ bool mattack::dodge_check( monster *z, Creature *target ) { ///\EFFECT_DODGE increases chance of dodging, vs their melee skill float dodge = std::max( target->get_dodge() - rng( 0, z->get_hit() ), 0.0f ); - return rng( 0, 10000 ) < 10000 / ( 1 + 99 * exp( -.6 * dodge ) ); + return rng( 0, 10000 ) < 10000 / ( 1 + 99 * std::exp( -.6 * dodge ) ); } diff --git a/src/mondeath.cpp b/src/mondeath.cpp index c6de58fbcb453..5eb1568d063ef 100644 --- a/src/mondeath.cpp +++ b/src/mondeath.cpp @@ -126,7 +126,7 @@ static void scatter_chunks( const std::string &chunk_name, int chunk_amt, monste pile_size = std::max( pile_size, 1 ); // can't have more items in a pile than total items pile_size = std::min( chunk_amt, pile_size ); - distance = abs( distance ); + distance = std::abs( distance ); const item chunk( chunk_name, calendar::turn, pile_size ); for( int i = 0; i < chunk_amt; i += pile_size ) { bool drop_chunks = true; @@ -194,15 +194,15 @@ void mdeath::splatter( monster &z ) } } // 1% of the weight of the monster is the base, with overflow damage as a multiplier - int gibbed_weight = rng( 0, round( to_gram( z.get_weight() ) / 100.0 * - ( overflow_damage / max_hp + 1 ) ) ); + int gibbed_weight = rng( 0, std::round( to_gram( z.get_weight() ) / 100.0 * + ( overflow_damage / max_hp + 1 ) ) ); const int z_weight = to_gram( z.get_weight() ); // limit gibbing to 15% gibbed_weight = std::min( gibbed_weight, z_weight * 15 / 100 ); if( pulverized && gibbable ) { float overflow_ratio = overflow_damage / max_hp + 1; - int gib_distance = round( rng( 2, 4 ) ); + int gib_distance = std::round( rng( 2, 4 ) ); for( const auto &entry : *z.type->harvest ) { // only flesh and bones survive. if( entry.type == "flesh" || entry.type == "bone" ) { diff --git a/src/monmove.cpp b/src/monmove.cpp index 687613a98c385..d207326b72a2c 100644 --- a/src/monmove.cpp +++ b/src/monmove.cpp @@ -1098,7 +1098,7 @@ void monster::footsteps( const tripoint &p ) tripoint monster::scent_move() { // TODO: Remove when scentmap is 3D - if( abs( posz() - g->get_levz() ) > SCENT_MAP_Z_REACH ) { + if( std::abs( posz() - g->get_levz() ) > SCENT_MAP_Z_REACH ) { return { -1, -1, INT_MIN }; } @@ -1498,7 +1498,7 @@ bool monster::move_to( const tripoint &p, bool force, bool step_on_critter, g->m.has_flag( TFLAG_NO_FLOOR, p ) ? calc_climb_cost( pos(), destination ) : calc_movecost( pos(), destination ) ); if( cost > 0.0f ) { - moves -= static_cast( ceil( cost ) ); + moves -= static_cast( std::ceil( cost ) ); } else { return false; } @@ -1606,7 +1606,7 @@ bool monster::move_to( const tripoint &p, bool force, bool step_on_critter, if( has_flag( MF_SLUDGETRAIL ) ) { for( const tripoint &sludge_p : g->m.points_in_radius( pos(), 1 ) ) { - const int fstr = 3 - ( abs( sludge_p.x - posx() ) + abs( sludge_p.y - posy() ) ); + const int fstr = 3 - ( std::abs( sludge_p.x - posx() ) + std::abs( sludge_p.y - posy() ) ); if( fstr >= 2 ) { g->m.add_field( sludge_p, fd_sludge, fstr ); } @@ -1685,7 +1685,7 @@ bool monster::push_to( const tripoint &p, const int boost, const size_t depth ) } // Pushing forward is easier than pushing aside - const int direction_penalty = abs( dx - dir.x ) + abs( dy - dir.y ); + const int direction_penalty = std::abs( dx - dir.x ) + std::abs( dy - dir.y ); if( direction_penalty > 2 ) { continue; } diff --git a/src/monster.cpp b/src/monster.cpp index 0a8cadb2a460f..61b869e8adaef 100644 --- a/src/monster.cpp +++ b/src/monster.cpp @@ -2453,7 +2453,7 @@ void monster::process_effects() if( type->regenerates_in_dark ) { const float light = g->m.ambient_light_at( pos() ); // Magic number 10000 was chosen so that a floodlight prevents regeneration in a range of 20 tiles - if( heal( static_cast( 50.0 * exp( - light * light / 10000 ) ) > 0 && one_in( 2 ) && + if( heal( static_cast( 50.0 * std::exp( - light * light / 10000 ) ) > 0 && one_in( 2 ) && g->u.sees( *this ) ) ) { add_msg( m_warning, _( "The %s uses the darkness to regenerate." ), name() ); } diff --git a/src/morale.cpp b/src/morale.cpp index 57cefc021b0af..a7ba88cb8c563 100644 --- a/src/morale.cpp +++ b/src/morale.cpp @@ -183,8 +183,8 @@ void player_morale::morale_point::add( const int new_bonus, const int new_max_bo sqrt_of_sum_of_squares = get_net_bonus() + new_bonus; } else { // Otherwise use the sqrt of sum of squares to nerf stacking - sqrt_of_sum_of_squares = pow( get_net_bonus(), 2 ) + pow( new_bonus, 2 ); - sqrt_of_sum_of_squares = sqrt( sqrt_of_sum_of_squares ); + sqrt_of_sum_of_squares = std::pow( get_net_bonus(), 2 ) + std::pow( new_bonus, 2 ); + sqrt_of_sum_of_squares = std::sqrt( sqrt_of_sum_of_squares ); sqrt_of_sum_of_squares *= sgn( bonus ); } @@ -220,7 +220,8 @@ void player_morale::morale_point::decay( const time_duration &ticks ) int player_morale::morale_point::normalize_bonus( int bonus, int max_bonus, bool capped ) const { - return ( ( abs( bonus ) > abs( max_bonus ) && ( max_bonus != 0 || capped ) ) ? max_bonus : bonus ); + return ( ( std::abs( bonus ) > std::abs( max_bonus ) && ( max_bonus != 0 || + capped ) ) ? max_bonus : bonus ); } bool player_morale::mutation_data::get_active() const @@ -381,18 +382,18 @@ void player_morale::calculate_percentage() for( auto &m : points ) { const int bonus = m.get_net_bonus( mult ); if( bonus > 0 ) { - sum_of_positive_squares += pow( bonus, 2 ); + sum_of_positive_squares += std::pow( bonus, 2 ); } else { - sum_of_negative_squares += pow( bonus, 2 ); + sum_of_negative_squares += std::pow( bonus, 2 ); } } for( auto &m : points ) { const int bonus = m.get_net_bonus( mult ); if( bonus > 0 ) { - m.set_percent_contribution( ( pow( bonus, 2 ) / sum_of_positive_squares ) * 100 ); + m.set_percent_contribution( ( std::pow( bonus, 2 ) / sum_of_positive_squares ) * 100 ); } else { - m.set_percent_contribution( ( pow( bonus, 2 ) / sum_of_negative_squares ) * 100 ); + m.set_percent_contribution( ( std::pow( bonus, 2 ) / sum_of_negative_squares ) * 100 ); } } } @@ -404,10 +405,10 @@ int player_morale::get_total_negative_value() const for( auto &m : points ) { const int bonus = m.get_net_bonus( mult ); if( bonus < 0 ) { - sum += pow( bonus, 2 ); + sum += std::pow( bonus, 2 ); } } - return sqrt( sum ); + return std::sqrt( sum ); } int player_morale::get_total_positive_value() const @@ -417,11 +418,11 @@ int player_morale::get_total_positive_value() const for( auto &m : points ) { const int bonus = m.get_net_bonus( mult ); if( bonus > 0 ) { - sum += pow( bonus, 2 ); + sum += std::pow( bonus, 2 ); } } - return sqrt( sum ); + return std::sqrt( sum ); } int player_morale::get_level() const @@ -435,13 +436,13 @@ int player_morale::get_level() const for( auto &m : points ) { const int bonus = m.get_net_bonus( mult ); if( bonus > 0 ) { - sum_of_positive_squares += pow( bonus, 2 ); + sum_of_positive_squares += std::pow( bonus, 2 ); } else { - sum_of_negative_squares += pow( bonus, 2 ); + sum_of_negative_squares += std::pow( bonus, 2 ); } } - level = sqrt( sum_of_positive_squares ) - sqrt( sum_of_negative_squares ); + level = std::sqrt( sum_of_positive_squares ) - std::sqrt( sum_of_negative_squares ); if( took_prozac ) { level *= morale_mults::prozac; diff --git a/src/npc.cpp b/src/npc.cpp index 2f179b390deda..83bf4b24839c2 100644 --- a/src/npc.cpp +++ b/src/npc.cpp @@ -1378,9 +1378,10 @@ float npc::vehicle_danger( int radius ) const vehicle_part last_part = wrapped_veh.v->parts.back(); int size = std::max( last_part.mount.x, last_part.mount.y ); - double normal = sqrt( static_cast( ( bx - ax ) * ( bx - ax ) + ( by - ay ) * ( by - ay ) ) ); - int closest = static_cast( abs( ( posx() - ax ) * ( by - ay ) - ( posy() - ay ) * - ( bx - ax ) ) / normal ); + double normal = std::sqrt( static_cast( ( bx - ax ) * ( bx - ax ) + ( by - ay ) * + ( by - ay ) ) ); + int closest = static_cast( std::abs( ( posx() - ax ) * ( by - ay ) - ( posy() - ay ) * + ( bx - ax ) ) / normal ); if( size > closest ) { danger = i; @@ -2256,7 +2257,7 @@ int npc::print_info( const catacurses::window &w, int line, int vLines, int colu if( per <= 1 ) { visibility_cap = INT_MAX; } else { - visibility_cap = round( dist * dist / 20.0 / ( per - 1 ) ); + visibility_cap = std::round( dist * dist / 20.0 / ( per - 1 ) ); } const auto trait_str = visible_mutations( visibility_cap ); diff --git a/src/npcmove.cpp b/src/npcmove.cpp index 69f8b4fb5a390..fad7951a41fdc 100644 --- a/src/npcmove.cpp +++ b/src/npcmove.cpp @@ -1351,7 +1351,7 @@ npc_action npc::method_of_attack() return npc_reach_attack; } } else { - if( reach_range > 1 && reach_range >= round( trig_dist( pos(), tar ) ) && + if( reach_range > 1 && reach_range >= std::round( trig_dist( pos(), tar ) ) && clear_shot_reach( pos(), tar ) ) { add_msg( m_debug, "%s is trying a reach attack", disp_name() ); return npc_reach_attack; @@ -2063,7 +2063,7 @@ bool npc::wont_hit_friend( const tripoint &tar, const item &it, bool throwing ) } int ally_angle = coord_to_angle( pos(), ally.pos() ); - int angle_diff = abs( ally_angle - target_angle ); + int angle_diff = std::abs( ally_angle - target_angle ); angle_diff = std::min( 360 - angle_diff, angle_diff ); if( angle_diff < safe_angle_ally ) { // TODO: Disable NPC whining is it's other NPC who prevents aiming @@ -2308,7 +2308,7 @@ void npc::move_to( const tripoint &pt, bool no_bashing, std::set *nomo const double base_moves = run_cost( g->m.combined_movecost( pos(), p ), diag ) * 100.0 / mounted_creature->get_speed(); const double encumb_moves = get_weight() / 4800.0_gram; - moves -= static_cast( ceil( base_moves + encumb_moves ) ); + moves -= static_cast( std::ceil( base_moves + encumb_moves ) ); if( mounted_creature->has_flag( MF_RIDEABLE_MECH ) ) { mounted_creature->use_mech_power( -1 ); } @@ -2429,9 +2429,9 @@ void npc::avoid_friendly_fire() } float friend_count = ai_cache.friends.size(); - center.x = round( center.x / friend_count ); - center.y = round( center.y / friend_count ); - center.z = round( center.z / friend_count ); + center.x = std::round( center.x / friend_count ); + center.y = std::round( center.y / friend_count ); + center.z = std::round( center.z / friend_count ); std::vector candidates = closest_tripoints_first( pos(), 1 ); candidates.erase( candidates.begin() ); @@ -2494,7 +2494,7 @@ void npc::move_away_from( const tripoint &pt, bool no_bash_atk, std::set best && can_move_to( p, no_bash_atk ) ) { best_pos = p; diff --git a/src/npctalk.cpp b/src/npctalk.cpp index 4563e0fc21d99..b5e95e812c2ea 100644 --- a/src/npctalk.cpp +++ b/src/npctalk.cpp @@ -186,7 +186,7 @@ int npc_trading::cash_to_favor( const npc &, int cash ) // TODO: It should affect different NPCs to a different degree // Square root of mission value in dollars // ~31 for zed mom, 50 for horde master, ~63 for plutonium cells - double scaled_mission_val = sqrt( cash / 100.0 ); + double scaled_mission_val = std::sqrt( cash / 100.0 ); return roll_remainder( scaled_mission_val ); } diff --git a/src/output.cpp b/src/output.cpp index cad0ebffb801b..79fcd5d0dfeb9 100644 --- a/src/output.cpp +++ b/src/output.cpp @@ -1807,7 +1807,7 @@ std::pair get_light_level( const float light ) }; // Avoid magic number static const int maximum_light_level = static_cast< int >( strings.size() ) - 1; - const int light_level = clamp( static_cast< int >( ceil( light ) ), 0, maximum_light_level ); + const int light_level = clamp( static_cast< int >( std::ceil( light ) ), 0, maximum_light_level ); const size_t array_index = static_cast< size_t >( light_level ); return pair_t{ _( strings[array_index].first ), strings[array_index].second }; } diff --git a/src/overmap.cpp b/src/overmap.cpp index 797185a2baf06..2b7bbd811268a 100644 --- a/src/overmap.cpp +++ b/src/overmap.cpp @@ -2763,22 +2763,22 @@ void overmap::place_river( point pa, point pb ) } if( pb.x > x && ( rng( 0, int( OMAPX * 1.2 ) - 1 ) < pb.x - x || ( rng( 0, int( OMAPX * .2 ) - 1 ) > pb.x - x && - rng( 0, int( OMAPY * .2 ) - 1 ) > abs( pb.y - y ) ) ) ) { + rng( 0, int( OMAPY * .2 ) - 1 ) > std::abs( pb.y - y ) ) ) ) { x++; } if( pb.x < x && ( rng( 0, int( OMAPX * 1.2 ) - 1 ) < x - pb.x || ( rng( 0, int( OMAPX * .2 ) - 1 ) > x - pb.x && - rng( 0, int( OMAPY * .2 ) - 1 ) > abs( pb.y - y ) ) ) ) { + rng( 0, int( OMAPY * .2 ) - 1 ) > std::abs( pb.y - y ) ) ) ) { x--; } if( pb.y > y && ( rng( 0, int( OMAPY * 1.2 ) - 1 ) < pb.y - y || ( rng( 0, int( OMAPY * .2 ) - 1 ) > pb.y - y && - rng( 0, int( OMAPX * .2 ) - 1 ) > abs( x - pb.x ) ) ) ) { + rng( 0, int( OMAPX * .2 ) - 1 ) > std::abs( x - pb.x ) ) ) ) { y++; } if( pb.y < y && ( rng( 0, int( OMAPY * 1.2 ) - 1 ) < y - pb.y || ( rng( 0, int( OMAPY * .2 ) - 1 ) > y - pb.y && - rng( 0, int( OMAPX * .2 ) - 1 ) > abs( x - pb.x ) ) ) ) { + rng( 0, int( OMAPX * .2 ) - 1 ) > std::abs( x - pb.x ) ) ) ) { y--; } x += rng( -1, 1 ); @@ -2800,7 +2800,7 @@ void overmap::place_river( point pa, point pb ) // We don't want our riverbanks touching the edge of the map for many reasons if( inbounds( tripoint( x + j, y + i, 0 ), 1 ) || // UNLESS, of course, that's where the river is headed! - ( abs( pb.y - ( y + i ) ) < 4 && abs( pb.x - ( x + j ) ) < 4 ) ) { + ( std::abs( pb.y - ( y + i ) ) < 4 && std::abs( pb.x - ( x + j ) ) < 4 ) ) { tripoint p( x + j, y + i, 0 ); if( !inbounds( p ) ) { continue; @@ -3939,7 +3939,7 @@ void overmap::place_special( const overmap_special &special, const tripoint &p, if( !inbounds( nearby_pos ) ) { continue; } - if( one_in( 1 + abs( x ) + abs( y ) ) && elem.can_be_placed_on( ter( nearby_pos ) ) ) { + if( one_in( 1 + std::abs( x ) + std::abs( y ) ) && elem.can_be_placed_on( ter( nearby_pos ) ) ) { ter_set( nearby_pos, tid ); } } diff --git a/src/panels.cpp b/src/panels.cpp index 9f0c29b8b8ba2..ec5af2894d0a4 100644 --- a/src/panels.cpp +++ b/src/panels.cpp @@ -543,10 +543,12 @@ static std::pair temp_delta( const avatar &u ) int current_bp_extreme = 0; int conv_bp_extreme = 0; for( int i = 0; i < num_bp; i++ ) { - if( abs( u.temp_cur[i] - BODYTEMP_NORM ) > abs( u.temp_cur[current_bp_extreme] - BODYTEMP_NORM ) ) { + if( std::abs( u.temp_cur[i] - BODYTEMP_NORM ) > + std::abs( u.temp_cur[current_bp_extreme] - BODYTEMP_NORM ) ) { current_bp_extreme = i; } - if( abs( u.temp_conv[i] - BODYTEMP_NORM ) > abs( u.temp_conv[conv_bp_extreme] - BODYTEMP_NORM ) ) { + if( std::abs( u.temp_conv[i] - BODYTEMP_NORM ) > + std::abs( u.temp_conv[conv_bp_extreme] - BODYTEMP_NORM ) ) { conv_bp_extreme = i; } } @@ -846,7 +848,7 @@ static nc_color safe_color() static int get_int_digits( const int &digits ) { - int temp = abs( digits ); + int temp = std::abs( digits ); if( digits > 0 ) { return static_cast( log10( static_cast( temp ) ) ) + 1; } else if( digits < 0 ) { diff --git a/src/pathfinding.cpp b/src/pathfinding.cpp index 2857b3f6efff8..b43a763d07ef2 100644 --- a/src/pathfinding.cpp +++ b/src/pathfinding.cpp @@ -483,7 +483,7 @@ std::vector map::route( const tripoint &f, const tripoint &t, ret.push_back( cur ); // Jumps are acceptable on 1 z-level changes // This is because stairs teleport the player too - if( rl_dist( cur, par ) > 1 && abs( cur.z - par.z ) != 1 ) { + if( rl_dist( cur, par ) > 1 && std::abs( cur.z - par.z ) != 1 ) { debugmsg( "Jump in our route! %d:%d:%d->%d:%d:%d", cur.x, cur.y, cur.z, par.x, par.y, par.z ); return ret; diff --git a/src/player.cpp b/src/player.cpp index d71995589ea78..2702ac8580fa5 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -482,7 +482,7 @@ int player::kcal_speed_penalty() // TODO: get speed penalties for being too fat, too return 0; } else { - return round( multi_lerp( starv_thresholds, get_bmi() ) ); + return std::round( multi_lerp( starv_thresholds, get_bmi() ) ); } } @@ -693,7 +693,7 @@ double player::recoil_vehicle() const if( in_vehicle ) { if( const optional_vpart_position vp = g->m.veh_at( pos() ) ) { - return static_cast( abs( vp->vehicle().velocity ) ) * 3 / 100; + return static_cast( std::abs( vp->vehicle().velocity ) ) * 3 / 100; } } return 0; @@ -4073,9 +4073,9 @@ int player::book_fun_for( const item &book, const player &p ) const if( ( p.has_trait( trait_CANNIBAL ) || p.has_trait( trait_PSYCHOPATH ) || p.has_trait( trait_SAPIOVORE ) ) && book.typeId() == "cookbook_human" ) { - fun_bonus = abs( fun_bonus ); + fun_bonus = std::abs( fun_bonus ); } else if( p.has_trait( trait_SPIRITUAL ) && book.has_flag( "INSPIRATIONAL" ) ) { - fun_bonus = abs( fun_bonus * 3 ); + fun_bonus = std::abs( fun_bonus * 3 ); } if( has_trait( trait_LOVES_BOOKS ) ) { @@ -4897,8 +4897,8 @@ action_id player::get_next_auto_move_direction() // Make sure the direction is just one step and that // all diagonal moves have 0 z component - if( abs( dp.x ) > 1 || abs( dp.y ) > 1 || abs( dp.z ) > 1 || - ( abs( dp.z ) != 0 && ( abs( dp.x ) != 0 || abs( dp.y ) != 0 ) ) ) { + if( std::abs( dp.x ) > 1 || std::abs( dp.y ) > 1 || std::abs( dp.z ) > 1 || + ( std::abs( dp.z ) != 0 && ( std::abs( dp.x ) != 0 || std::abs( dp.y ) != 0 ) ) ) { // Should never happen, but check just in case return ACTION_NULL; } @@ -5245,7 +5245,7 @@ std::vector player::get_targetable_creatures( const int range ) cons } } } - bool in_range = round( rl_dist_exact( pos(), critter.pos() ) ) <= range; + bool in_range = std::round( rl_dist_exact( pos(), critter.pos() ) ) <= range; // TODO: get rid of fake npcs (pos() check) bool valid_target = this != &critter && pos() != critter.pos() && attitude_to( critter ) != Creature::Attitude::A_FRIENDLY; return valid_target && in_range && can_see; @@ -5256,7 +5256,7 @@ std::vector player::get_hostile_creatures( int range ) const { return g->get_creatures_if( [this, range]( const Creature & critter ) -> bool { // Fixes circular distance range for ranged attacks - float dist_to_creature = round( rl_dist_exact( pos(), critter.pos() ) ); + float dist_to_creature = std::round( rl_dist_exact( pos(), critter.pos() ) ); return this != &critter && pos() != critter.pos() && // TODO: get rid of fake npcs (pos() check) dist_to_creature <= range && critter.attitude_to( *this ) == A_HOSTILE && sees( critter ); diff --git a/src/player_display.cpp b/src/player_display.cpp index 08e98767c2d1f..01468dd23c569 100644 --- a/src/player_display.cpp +++ b/src/player_display.cpp @@ -1053,13 +1053,13 @@ static void draw_initial_windows( const catacurses::window &w_stats, line++; } if( you.get_thirst() > 40 ) { - pen = abs( player::thirst_speed_penalty( you.get_thirst() ) ); + pen = std::abs( player::thirst_speed_penalty( you.get_thirst() ) ); mvwprintz( w_speed, point( 1, line ), c_red, pgettext( "speed penalty", "Thirst -%2d%%" ), pen ); line++; } if( you.kcal_speed_penalty() < 0 ) { - pen = abs( you.kcal_speed_penalty() ); + pen = std::abs( you.kcal_speed_penalty() ); const std::string inanition = you.get_bmi() < character_weight_category::underweight ? _( "Starving" ) : _( "Underfed" ); //~ %s: Starving/Underfed (already left-justified), %2d: speed penalty @@ -1372,8 +1372,8 @@ void player::disp_info() nc_color col = ( speed_effect.second > 0 ? c_green : c_red ); mvwprintz( w_speed, point( 1, line ), col, "%s", speed_effect.first ); mvwprintz( w_speed, point( 21, line ), col, ( speed_effect.second > 0 ? "+" : "-" ) ); - mvwprintz( w_speed, point( abs( speed_effect.second ) >= 10 ? 22 : 23, line ), col, "%d%%", - abs( speed_effect.second ) ); + mvwprintz( w_speed, point( std::abs( speed_effect.second ) >= 10 ? 22 : 23, line ), col, "%d%%", + std::abs( speed_effect.second ) ); line++; } diff --git a/src/player_hardcoded_effects.cpp b/src/player_hardcoded_effects.cpp index 18ffabfade79e..8104d255e7310 100644 --- a/src/player_hardcoded_effects.cpp +++ b/src/player_hardcoded_effects.cpp @@ -1137,7 +1137,7 @@ void player::hardcoded_effects( effect &it ) } bool woke_up = false; - int tirednessVal = rng( 5, 200 ) + rng( 0, abs( get_fatigue() * 2 * 5 ) ); + int tirednessVal = rng( 5, 200 ) + rng( 0, std::abs( get_fatigue() * 2 * 5 ) ); if( !is_blind() && !has_effect( effect_narcosis ) ) { if( !has_trait( trait_SEESLEEP ) ) { // People who can see while sleeping are acclimated to the light. diff --git a/src/point.h b/src/point.h index f3de6f5a59c6a..85bc066416822 100644 --- a/src/point.h +++ b/src/point.h @@ -313,12 +313,12 @@ std::vector closest_points_first( const point ¢er, int min_dist, int inline point abs( const point &p ) { - return point( abs( p.x ), abs( p.y ) ); + return point( std::abs( p.x ), std::abs( p.y ) ); } inline tripoint abs( const tripoint &p ) { - return tripoint( abs( p.x ), abs( p.y ), abs( p.z ) ); + return tripoint( std::abs( p.x ), std::abs( p.y ), std::abs( p.z ) ); } static constexpr tripoint tripoint_min { INT_MIN, INT_MIN, INT_MIN }; diff --git a/src/ranged.cpp b/src/ranged.cpp index 21f2379280fe8..a3ca204437490 100644 --- a/src/ranged.cpp +++ b/src/ranged.cpp @@ -781,7 +781,7 @@ dealt_projectile_attack player::throw_item( const tripoint &target, const item & // Avoid awarding tons of xp for lucky throws against hard to hit targets const float range_factor = std::min( range, skill_lvl + 3 ); // We're aiming to get a damaging hit, not just an accurate one - reward proper weapons - const float damage_factor = 5.0f * sqrt( proj.impact.total_damage() / 5.0f ); + const float damage_factor = 5.0f * std::sqrt( proj.impact.total_damage() / 5.0f ); // This should generally have values below ~20*sqrt(skill_lvl) const float final_xp_mult = range_factor * damage_factor; @@ -1487,11 +1487,11 @@ std::vector target_handler::target_ui( player &pc, target_mode mode, // This chunk of code handles shifting the aim point around // at maximum range when using circular distance. // The range > 1 check ensures that you can always at least hit adjacent squares. - if( trigdist && range > 1 && round( trig_dist( src, dst ) ) > range ) { + if( trigdist && range > 1 && std::round( trig_dist( src, dst ) ) > range ) { bool cont = true; tripoint cp = dst; for( size_t i = 0; i < ret.size() && cont; i++ ) { - if( round( trig_dist( src, ret[i] ) ) > range ) { + if( std::round( trig_dist( src, ret[i] ) ) > range ) { ret.resize( i ); cont = false; } else { @@ -2039,11 +2039,11 @@ std::vector target_handler::target_ui( spell &casting, const bool no_f // This chunk of code handles shifting the aim point around // at maximum range when using circular distance. // The range > 1 check ensures that you can always at least hit adjacent squares. - if( trigdist && range > 1 && round( trig_dist( src, dst ) ) > range ) { + if( trigdist && range > 1 && std::round( trig_dist( src, dst ) ) > range ) { bool cont = true; tripoint cp = dst; for( size_t i = 0; i < ret.size() && cont; i++ ) { - if( round( trig_dist( src, ret[i] ) ) > range ) { + if( std::round( trig_dist( src, ret[i] ) ) > range ) { ret.resize( i ); cont = false; } else { diff --git a/src/recipe.cpp b/src/recipe.cpp index 4a7019c452a8f..c84896e8eb3e9 100644 --- a/src/recipe.cpp +++ b/src/recipe.cpp @@ -64,7 +64,7 @@ int recipe::batch_time( int batch, float multiplier, size_t assistants ) const const double scale = batch_rsize / 6.0; for( int x = 0; x < batch; x++ ) { // scaled logistic function output - const double logf = ( 2.0 / ( 1.0 + exp( -( x / scale ) ) ) ) - 1.0; + const double logf = ( 2.0 / ( 1.0 + std::exp( -( x / scale ) ) ) ) - 1.0; total_time += local_time * ( 1.0 - ( batch_rscale * logf ) ); } } diff --git a/src/relic.cpp b/src/relic.cpp index 8e18883034b2d..3d9758e0a026f 100644 --- a/src/relic.cpp +++ b/src/relic.cpp @@ -105,9 +105,9 @@ int relic::modify_value( const enchantment::mod value_type, const int value ) co multiply_modifier = std::max( multiply_modifier + 1.0, 0.0 ); int modified_value; if( multiply_modifier < 1.0 ) { - modified_value = floor( multiply_modifier * value ); + modified_value = std::floor( multiply_modifier * value ); } else { - modified_value = ceil( multiply_modifier * value ); + modified_value = std::ceil( multiply_modifier * value ); } return modified_value + add_modifier; } diff --git a/src/requirements.cpp b/src/requirements.cpp index 11f70194d288c..d3631ca257162 100644 --- a/src/requirements.cpp +++ b/src/requirements.cpp @@ -117,7 +117,7 @@ std::string tool_comp::to_string( const int batch, const int ) const count * batch ), item::nname( type ), count * batch ); } else { - return item::nname( type, abs( count ) ); + return item::nname( type, std::abs( count ) ); } } @@ -828,7 +828,7 @@ bool requirement_data::check_enough_materials( const item_comp &comp, const inve } // This item can be used for the quality requirement, same as above for specific // tools applies. - if( !crafting_inv.has_quality( qr->type, qr->level, qr->count + abs( comp.count ) ) ) { + if( !crafting_inv.has_quality( qr->type, qr->level, qr->count + std::abs( comp.count ) ) ) { comp.available = a_insufficent; } } diff --git a/src/savegame_json.cpp b/src/savegame_json.cpp index 31e895f50a615..75d0951ca7903 100644 --- a/src/savegame_json.cpp +++ b/src/savegame_json.cpp @@ -976,10 +976,10 @@ void avatar::store( JsonOut &json ) const json.member( "focus_pool", focus_pool ); // stats through kills - json.member( "str_upgrade", abs( str_upgrade ) ); - json.member( "dex_upgrade", abs( dex_upgrade ) ); - json.member( "int_upgrade", abs( int_upgrade ) ); - json.member( "per_upgrade", abs( per_upgrade ) ); + json.member( "str_upgrade", std::abs( str_upgrade ) ); + json.member( "dex_upgrade", std::abs( dex_upgrade ) ); + json.member( "int_upgrade", std::abs( int_upgrade ) ); + json.member( "per_upgrade", std::abs( per_upgrade ) ); // targeting if( activity.id() == ACT_AIM ) { diff --git a/src/scenario.cpp b/src/scenario.cpp index aa45d84d3d0e9..33a3d61dd2e59 100644 --- a/src/scenario.cpp +++ b/src/scenario.cpp @@ -110,7 +110,7 @@ const scenario *scenario::weighted_random() while( true ) { const scenario &scen = random_entry_ref( list ); - if( x_in_y( 2, abs( scen.point_cost() ) + 2 ) ) { + if( x_in_y( 2, std::abs( scen.point_cost() ) + 2 ) ) { return &scen; } // else reroll in the while loop. diff --git a/src/sdl_utils.h b/src/sdl_utils.h index 7b106c47b18c2..372088cfc35aa 100644 --- a/src/sdl_utils.h +++ b/src/sdl_utils.h @@ -139,7 +139,8 @@ inline SDL_Color color_pixel_sepia( const SDL_Color &color ) const Uint8 av = average_pixel_color( color ); const float gammav = 1.6; const float pv = av / 255.0; - const Uint8 finalv = std::min( int( round( pow( pv, gammav ) * 150 ) ), 100 ); + const Uint8 finalv = + std::min( static_cast( std::round( std::pow( pv, gammav ) * 150 ) ), 100 ); return mix_colors( sepia_dark, sepia_light, finalv ); } diff --git a/src/sdltiles.cpp b/src/sdltiles.cpp index b2b3f78d91e3f..6d4f3e64b0f9d 100644 --- a/src/sdltiles.cpp +++ b/src/sdltiles.cpp @@ -3777,8 +3777,8 @@ cata::optional input_context::get_coordinates( const catacurses::windo if( tile_iso && use_tiles ) { const float win_mid_x = win_min.x + win_size.x / 2.0f; const float win_mid_y = -win_min.y + win_size.y / 2.0f; - const int screen_col = round( ( screen_pos.x - win_mid_x ) / ( fw / 2.0 ) ); - const int screen_row = round( ( screen_pos.y - win_mid_y ) / ( fw / 4.0 ) ); + const int screen_col = std::round( ( screen_pos.x - win_mid_x ) / ( fw / 2.0 ) ); + const int screen_row = std::round( ( screen_pos.y - win_mid_y ) / ( fw / 4.0 ) ); const point selected( ( screen_col - screen_row ) / 2, ( screen_row + screen_col ) / 2 ); p = view_offset + selected; } else { diff --git a/src/sounds.cpp b/src/sounds.cpp index 8940de8fed3e4..421e797b7a6cb 100644 --- a/src/sounds.cpp +++ b/src/sounds.cpp @@ -199,7 +199,7 @@ static std::vector cluster_sounds( std::vector( 10 ) ), - static_cast( log( input_sounds.size() ) ) ); + static_cast( std::log( input_sounds.size() ) ) ); const size_t stopping_point = input_sounds.size() - num_seed_clusters; const size_t max_map_distance = rl_dist( point_zero, point( MAPSIZE_X, MAPSIZE_Y ) ); // Randomly choose cluster seeds. @@ -361,7 +361,7 @@ void sounds::process_sound_markers( player *p ) const tripoint &pos = sound_event_pair.first; const sound_event &sound = sound_event_pair.second; const int distance_to_sound = rl_dist( p->pos().xy(), pos.xy() ) + - abs( p->pos().z - pos.z ) * 10; + std::abs( p->pos().z - pos.z ) * 10; const int raw_volume = sound.volume; // The felt volume of a sound is not affected by negative multipliers, such as already diff --git a/src/stomach.cpp b/src/stomach.cpp index 5df733519afa6..884a70a767ae0 100644 --- a/src/stomach.cpp +++ b/src/stomach.cpp @@ -253,7 +253,7 @@ stomach_digest_rates stomach_contents::get_digest_rates( const needs_rates &meta rates.water = 250_ml; rates.min_kcal = roll_remainder( metabolic_rates.kcal / 24.0 * metabolic_rates.hunger ); rates.percent_kcal = 0.05f * metabolic_rates.hunger; - rates.min_vitamin = round( 100.0 / 24.0 * metabolic_rates.hunger ); + rates.min_vitamin = std::round( 100.0 / 24.0 * metabolic_rates.hunger ); rates.percent_vitamin = 0.05f * metabolic_rates.hunger; } return rates; @@ -271,7 +271,7 @@ void stomach_contents::mod_calories( int cal ) void stomach_contents::mod_nutr( int nutr ) { // nutr is legacy type code, this function simply converts old nutrition to new kcal - mod_calories( -1 * round( nutr * 2500.0f / ( 12 * 24 ) ) ); + mod_calories( -1 * std::round( nutr * 2500.0f / ( 12 * 24 ) ) ); } void stomach_contents::mod_water( units::volume h2o ) diff --git a/src/suffer.cpp b/src/suffer.cpp index 341d60d839019..c77e203cbc064 100644 --- a/src/suffer.cpp +++ b/src/suffer.cpp @@ -182,7 +182,7 @@ void Character::suffer_water_damage( const mutation_branch &mdata ) _( "'s %s is damaged by the water." ), body_part_name( bp ) ); } else if( dmg < 0 && hp_cur[bp_to_hp( bp )] != hp_max[bp_to_hp( bp )] ) { - heal( bp, abs( dmg ) ); + heal( bp, std::abs( dmg ) ); add_msg_player_or_npc( m_good, _( "Your %s is healed by the water." ), _( "'s %s is healed by the water." ), body_part_name( bp ) ); @@ -912,7 +912,7 @@ void Character::suffer_from_other_mutations() if( bp == bp_head ) { continue; } - int sores_pain = 5 + 0.4 * abs( encumb( bp ) ); + int sores_pain = 5 + 0.4 * std::abs( encumb( bp ) ); if( get_pain() < sores_pain ) { set_pain( sores_pain ); } @@ -1599,8 +1599,8 @@ void Character::mend( int rate_multiplier ) // Very hungry starts lowering the chance // square rooting the value makes the numbers drop off faster when below 1 - healing_factor *= sqrt( static_cast( get_stored_kcal() ) / static_cast - ( get_healthy_kcal() ) ); + healing_factor *= std::sqrt( static_cast( get_stored_kcal() ) / static_cast + ( get_healthy_kcal() ) ); // Similar for thirst - starts at very thirsty, drops to 0 ~halfway between two last statuses healing_factor *= 1.0f - clamp( ( get_thirst() - 80.0f ) / 300.0f, 0.0f, 1.0f ); diff --git a/src/tileray.cpp b/src/tileray.cpp index a8a2830d0c5cd..c1248bc60132a 100644 --- a/src/tileray.cpp +++ b/src/tileray.cpp @@ -189,7 +189,7 @@ void tileray::advance( int num ) if( num == 0 ) { return; } - int anum = abs( num ); + int anum = std::abs( num ); steps = anum; const bool vertical = mostly_vertical(); if( direction % 90 ) { diff --git a/src/veh_interact.cpp b/src/veh_interact.cpp index 1b7e44f9d1cae..5c6130b798f4b 100644 --- a/src/veh_interact.cpp +++ b/src/veh_interact.cpp @@ -90,7 +90,7 @@ static double jack_quality( const vehicle &veh ) { const units::quantity mass = std::min( veh.total_mass(), JACK_LIMIT ); - return ceil( mass / TOOL_LIFT_FACTOR ); + return std::ceil( mass / TOOL_LIFT_FACTOR ); } /** Can part currently be reloaded with anything? */ @@ -607,7 +607,7 @@ task_reason veh_interact::cant_do( char mode ) return UNKNOWN_TASK; } - if( abs( veh->velocity ) > 100 || g->u.controlling_vehicle ) { + if( std::abs( veh->velocity ) > 100 || g->u.controlling_vehicle ) { return MOVING_VEHICLE; } if( !valid_target ) { @@ -1375,7 +1375,7 @@ bool veh_interact::overview( std::function enabl }; headers["BATTERY"] = [epower_w]( const catacurses::window & w, int y ) { std::string batt; - if( abs( epower_w ) < 10000 ) { + if( std::abs( epower_w ) < 10000 ) { batt = string_format( _( "Batteries: %s%+4d W" ), health_color( epower_w >= 0 ), epower_w ); } else { @@ -1745,7 +1745,8 @@ bool veh_interact::can_remove_part( int idx, const player &p ) use_str = g->u.can_lift( *veh ); } else { qual = qual_LIFT; - lvl = ceil( units::quantity( base.weight() ) / TOOL_LIFT_FACTOR ); + lvl = std::ceil( units::quantity( base.weight() ) / + TOOL_LIFT_FACTOR ); str = base.lift_strength(); use_aid = max_lift >= lvl; use_str = g->u.can_lift( base ); diff --git a/src/veh_utils.cpp b/src/veh_utils.cpp index c22709d5b0a7e..0270d18e66a3f 100644 --- a/src/veh_utils.cpp +++ b/src/veh_utils.cpp @@ -52,8 +52,8 @@ int calc_xp_gain( const vpart_info &vp, const skill_id &sk, const Character &who // 5: 3 xp /h // 6: 2 xp /h // 7+: 1 xp /h - return std::ceil( static_cast( vp.install_moves ) / to_moves( 1_minutes * pow( lvl, - 2 ) ) ); + return std::ceil( static_cast( vp.install_moves ) / + to_moves( 1_minutes * std::pow( lvl, 2 ) ) ); } vehicle_part &most_repairable_part( vehicle &veh, Character &who_arg, bool only_repairable ) diff --git a/src/vehicle.cpp b/src/vehicle.cpp index f49597bee46ec..bdd6e7c2f474a 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -4210,7 +4210,7 @@ float vehicle::strain() const if( velocity < sv && velocity > -sv ) { return 0; } else { - return static_cast( abs( velocity ) - sv ) / static_cast( mv - sv ); + return static_cast( std::abs( velocity ) - sv ) / static_cast( mv - sv ); } } @@ -4679,7 +4679,7 @@ void vehicle::update_alternator_load() } alternator_load = engine_vpower - ? 1000 * ( abs( alternators_power ) + abs( extra_drag ) ) / engine_vpower + ? 1000 * ( std::abs( alternators_power ) + std::abs( extra_drag ) ) / engine_vpower : 0; } else { alternator_load = 0; @@ -4752,7 +4752,7 @@ void vehicle::power_parts() charge_battery( delta_energy_bat ); } else if( epower < 0 ) { // draw epower deficit from battery - battery_deficit = discharge_battery( abs( delta_energy_bat ) ); + battery_deficit = discharge_battery( std::abs( delta_energy_bat ) ); } if( battery_deficit != 0 ) { @@ -5304,7 +5304,7 @@ void vehicle::gain_moves() } of_turn = 1 + of_turn_carry; const int vslowdown = slowdown( velocity ); - if( vslowdown > abs( velocity ) ) { + if( vslowdown > std::abs( velocity ) ) { if( cruise_on && cruise_velocity && pl_control ) { velocity = velocity > 0 ? 1 : -1; } else { @@ -5689,8 +5689,8 @@ void vehicle::refresh_pivot() const xc_numerator, xc_denominator, yc_numerator, yc_denominator ); pivot_cache = local_center_of_mass(); } else { - pivot_cache.x = round( xc_numerator / xc_denominator ); - pivot_cache.y = round( yc_numerator / yc_denominator ); + pivot_cache.x = std::round( xc_numerator / xc_denominator ); + pivot_cache.y = std::round( yc_numerator / yc_denominator ); } } @@ -5857,8 +5857,8 @@ void vehicle::set_tow_directions() { const int length = mount_max.x - mount_min.x + 1; const point mount_of_tow = parts[get_tow_part()].mount; - const point normalized_tow_mount = point( abs( mount_of_tow.x - mount_min.x ), - abs( mount_of_tow.y - mount_min.y ) ); + const point normalized_tow_mount = point( std::abs( mount_of_tow.x - mount_min.x ), + std::abs( mount_of_tow.y - mount_min.y ) ); if( length >= 3 ) { const int trisect = length / 3; if( normalized_tow_mount.x <= trisect ) { @@ -6655,7 +6655,7 @@ void vehicle::update_time( const time_point &update_to ) continue; } - double area = pow( pt.info().size / units::legacy_volume_factor, 2 ) * M_PI; + double area = std::pow( pt.info().size / units::legacy_volume_factor, 2 ) * M_PI; int qty = roll_remainder( funnel_charges_per_turn( area, accum_weather.rain_amount ) ); int c_qty = qty + ( tank->can_reload( water_clean ) ? tank->ammo_remaining() : 0 ); int cost_to_purify = c_qty * item::find_type( "water_purifier" )->charges_to_use(); @@ -6773,12 +6773,12 @@ void vehicle::calc_mass_center( bool use_precalc ) const const float x = xf / mass_cache; const float y = yf / mass_cache; if( use_precalc ) { - mass_center_precalc.x = round( x ); - mass_center_precalc.y = round( y ); + mass_center_precalc.x = std::round( x ); + mass_center_precalc.y = std::round( y ); mass_center_precalc_dirty = false; } else { - mass_center_no_precalc.x = round( x ); - mass_center_no_precalc.y = round( y ); + mass_center_no_precalc.x = std::round( x ); + mass_center_no_precalc.y = std::round( y ); mass_center_no_precalc_dirty = false; } } diff --git a/src/vehicle_display.cpp b/src/vehicle_display.cpp index 87d03854a956a..d51da6d956642 100644 --- a/src/vehicle_display.cpp +++ b/src/vehicle_display.cpp @@ -443,11 +443,11 @@ void vehicle::print_fuel_indicator( const catacurses::window &win, const point & if( debug_mode ) { wprintz( win, tank_color, _( ", %d %s(%4.2f%%)/hour, %s until %s" ), rate, units, 100.0 * rate / cap, - to_string_clipped( 60_minutes * tank_use / abs( rate ) ), tank_goal ); + to_string_clipped( 60_minutes * tank_use / std::abs( rate ) ), tank_goal ); } else { wprintz( win, tank_color, _( ", %3.1f%% / hour, %s until %s" ), 100.0 * rate / cap, - to_string_clipped( 60_minutes * tank_use / abs( rate ) ), tank_goal ); + to_string_clipped( 60_minutes * tank_use / std::abs( rate ) ), tank_goal ); } } } diff --git a/src/vehicle_move.cpp b/src/vehicle_move.cpp index 739dbe443ad7c..100a05dae0b32 100644 --- a/src/vehicle_move.cpp +++ b/src/vehicle_move.cpp @@ -81,7 +81,7 @@ int vmiph_to_cmps( int vmiph ) int vehicle::slowdown( int at_velocity ) const { - double mps = vmiph_to_mps( abs( at_velocity ) ); + double mps = vmiph_to_mps( std::abs( at_velocity ) ); // slowdown due to air resistance is proportional to square of speed double f_total_drag = coeff_air_drag() * mps * mps; @@ -168,7 +168,7 @@ void vehicle::thrust( int thd, int z ) int max_vel = traction * max_velocity(); // Get braking power - int brk = std::max( 1000, abs( max_vel ) * 3 / 10 ); + int brk = std::max( 1000, std::abs( max_vel ) * 3 / 10 ); //pos or neg if accelerator or brake int vel_inc = ( ( thrusting ) ? accel : brk ) * thd; @@ -231,9 +231,10 @@ void vehicle::thrust( int thd, int z ) const int velocity_kt = velocity * 0.01; int value; if( velocity_kt < 70 ) { - value = 49 * pow( velocity_kt, 3 ) - 4118 * pow( velocity_kt, 2 ) - 76512 * velocity_kt + 18458000; + value = 49 * std::pow( velocity_kt, 3 ) - + 4118 * std::pow( velocity_kt, 2 ) - 76512 * velocity_kt + 18458000; } else { - value = 1864 * pow( velocity_kt, 2 ) - 272190 * velocity_kt + 19473000; + value = 1864 * std::pow( velocity_kt, 2 ) - 272190 * velocity_kt + 19473000; } value *= 0.0001; load = std::max( 200, std::min( 1000, ( ( value / 2 ) + 100 ) ) ); @@ -316,7 +317,7 @@ void vehicle::cruise_thrust( int amount ) // Integer round to lowest multiple of amount. // The result is always equal to the original or closer to zero, // even if negative - cruise_velocity = ( cruise_velocity / abs( amount ) ) * abs( amount ); + cruise_velocity = ( cruise_velocity / std::abs( amount ) ) * std::abs( amount ); } // Can't have a cruise speed faster than max speed // or reverse speed faster than max reverse speed. @@ -644,8 +645,8 @@ veh_collision vehicle::part_collision( int part, const tripoint &p, // factor = -25 if mass is much greater than mass2 // factor = +25 if mass2 is much greater than mass const float weight_factor = mass >= mass2 ? - -25 * ( log( mass ) - log( mass2 ) ) / log( mass ) : - 25 * ( log( mass2 ) - log( mass ) ) / log( mass2 ); + -25 * ( std::log( mass ) - std::log( mass2 ) ) / std::log( mass ) : + 25 * ( std::log( mass2 ) - std::log( mass ) ) / std::log( mass2 ); float k = 50 + material_factor + weight_factor; k = std::max( 10.0f, std::min( 90.0f, k ) ); @@ -838,7 +839,7 @@ veh_collision vehicle::part_collision( int part, const tripoint &p, } if( smashed && !vert_coll ) { - int turn_amount = rng( 1, 3 ) * sqrt( static_cast( part_dmg ) ); + int turn_amount = rng( 1, 3 ) * std::sqrt( static_cast( part_dmg ) ); turn_amount /= 15; if( turn_amount < 1 ) { turn_amount = 1; @@ -979,7 +980,7 @@ void vehicle::autodrive( int x, int y ) turn( turn_delta ); } if( y != 0 ) { - int thr_amount = 100 * ( abs( velocity ) < 2000 ? 4 : 5 ); + int thr_amount = 100 * ( std::abs( velocity ) < 2000 ? 4 : 5 ); if( cruise_on ) { cruise_thrust( -y * thr_amount ); } else { @@ -1136,7 +1137,7 @@ void vehicle::pldrive( const point &p, int z ) } if( p.y != 0 ) { - int thr_amount = 100 * ( abs( velocity ) < 2000 ? 4 : 5 ); + int thr_amount = 100 * ( std::abs( velocity ) < 2000 ? 4 : 5 ); if( cruise_on ) { cruise_thrust( -p.y * thr_amount ); } else { @@ -1254,7 +1255,7 @@ void vehicle::precalculate_vehicle_turning( int new_turn_dir, bool check_rail_di tripoint dp; bool is_diagonal_movement = new_turn_dir % 90 == 45; - if( abs( velocity ) >= 20 ) { + if( std::abs( velocity ) >= 20 ) { mdir.advance( velocity < 0 ? -1 : 1 ); dp.x = mdir.dx(); dp.y = mdir.dy(); @@ -1416,7 +1417,7 @@ bool vehicle::is_wheel_state_correct_to_turn_on_rails( int wheels_on_rail, int w && ( wheels_on_rail != turning_wheels_that_are_one_axis // wheels that want to turn is not on same axis || all_wheels_on_one_axis || - ( abs( rail_wheel_bounding_box.p2.x - rail_wheel_bounding_box.p1.x ) < 4 && velocity < 0 ) ); + ( std::abs( rail_wheel_bounding_box.p2.x - rail_wheel_bounding_box.p1.x ) < 4 && velocity < 0 ) ); // allow turn for vehicles with wheel distance < 4 when moving backwards } @@ -1475,7 +1476,7 @@ vehicle *vehicle::act_on_map() // Low enough for bicycles to go in reverse. // If the movement is due to a change in z-level, i.e a helicopter then the lateral movement will often be zero. - if( !should_fall && abs( velocity ) < 20 && requested_z_change == 0 ) { + if( !should_fall && std::abs( velocity ) < 20 && requested_z_change == 0 ) { stop(); of_turn -= .321f; return this; @@ -1495,7 +1496,7 @@ vehicle *vehicle::act_on_map() return this; } } - const float turn_cost = vehicles::vmiph_per_tile / std::max( 0.0001f, abs( velocity ) ); + const float turn_cost = vehicles::vmiph_per_tile / std::max( 0.0001f, std::abs( velocity ) ); // Can't afford it this turn? // Low speed shouldn't prevent vehicle from falling, though @@ -1573,7 +1574,7 @@ vehicle *vehicle::act_on_map() } tripoint dp; - if( abs( velocity ) >= 20 && !falling_only ) { + if( std::abs( velocity ) >= 20 && !falling_only ) { mdir.advance( velocity < 0 ? -1 : 1 ); dp.x = mdir.dx(); dp.y = mdir.dy(); @@ -1692,7 +1693,7 @@ float map::vehicle_wheel_traction( const vehicle &veh, int map::shake_vehicle( vehicle &veh, const int velocity_before, const int direction ) { - const int d_vel = abs( veh.velocity - velocity_before ) / 100; + const int d_vel = std::abs( veh.velocity - velocity_before ) / 100; std::vector riders = veh.get_riders(); @@ -1757,7 +1758,7 @@ int map::shake_vehicle( vehicle &veh, const int velocity_before, const int direc psg->add_msg_player_or_npc( m_warning, _( "You lose control of the %s." ), _( " loses control of the %s." ), veh.name ); - int turn_amount = rng( 1, 3 ) * sqrt( abs( veh.velocity ) ) / 30; + int turn_amount = rng( 1, 3 ) * std::sqrt( std::abs( veh.velocity ) ) / 30; if( turn_amount < 1 ) { turn_amount = 1; } diff --git a/src/vehicle_use.cpp b/src/vehicle_use.cpp index b5bcda1036725..96ba9e7591c1f 100644 --- a/src/vehicle_use.cpp +++ b/src/vehicle_use.cpp @@ -925,7 +925,7 @@ bool vehicle::start_engine( const int e ) } const double dmg = parts[engines[e]].damage_percent(); - const int engine_power = abs( part_epower_w( engines[e] ) ); + const int engine_power = std::abs( part_epower_w( engines[e] ) ); const double cold_factor = engine_cold_factor( e ); const int start_moves = engine_start_time( e ); @@ -1259,7 +1259,7 @@ void vehicle::transform_terrain() g->m.add_field( start_pos, new_field, ttd.post_field_intensity, ttd.post_field_age ); } } else { - const int speed = abs( velocity ); + const int speed = std::abs( velocity ); int v_damage = rng( 3, speed ); damage( vp.part_index(), v_damage, DT_BASH, false ); sounds::sound( start_pos, v_damage, sounds::sound_t::combat, _( "Clanggggg!" ), false, diff --git a/src/weather.cpp b/src/weather.cpp index 59b92cb5043e0..289a0fc493838 100644 --- a/src/weather.cpp +++ b/src/weather.cpp @@ -704,8 +704,8 @@ int get_local_windchill( double temperature_f, double humidity, double wind_mph // Temperature is removed at the end, because get_local_windchill is meant to calculate the difference. // Source : http://en.wikipedia.org/wiki/Wind_chill#North_American_and_United_Kingdom_wind_chill_index - windchill_f = 35.74 + 0.6215 * temperature_f - 35.75 * pow( wind_mph, - 0.16 ) + 0.4275 * temperature_f * pow( wind_mph, 0.16 ) - temperature_f; + windchill_f = 35.74 + 0.6215 * temperature_f - 35.75 * std::pow( wind_mph, + 0.16 ) + 0.4275 * temperature_f * std::pow( wind_mph, 0.16 ) - temperature_f; if( wind_mph < 3 ) { // This model fails when wind is less than 3 mph windchill_f = 0; @@ -724,7 +724,7 @@ int get_local_windchill( double temperature_f, double humidity, double wind_mph // model being designed for reasonable ambient temperature values, // rather than extremely high ones. double windchill_c = 0.33 * std::min( 150.00, humidity / 100.00 * 6.105 * - exp( 17.27 * temperature_c / ( 237.70 + temperature_c ) ) ) - 0.70 * + std::exp( 17.27 * temperature_c / ( 237.70 + temperature_c ) ) ) - 0.70 * wind_meters_per_sec - 4.00; // Convert to Fahrenheit, but omit the '+ 32' because we are only dealing with a piece of the felt air temperature equation. windchill_f = windchill_c * 9 / 5; diff --git a/src/weather_gen.cpp b/src/weather_gen.cpp index 72d8624e164e0..b68d04f856881 100644 --- a/src/weather_gen.cpp +++ b/src/weather_gen.cpp @@ -146,7 +146,7 @@ w_point weather_generator::get_weather( const tripoint &location, const time_poi 10 * ( -seasonality + 2 ); // Wind power - W = std::max( 0, static_cast( base_wind * rng( 1, 2 ) / pow( ( P + W ) / 1014.78, rng( 9, + W = std::max( 0, static_cast( base_wind * rng( 1, 2 ) / std::pow( ( P + W ) / 1014.78, rng( 9, base_wind_distrib_peaks ) ) + -cyf / base_wind_season_variation * rng( 1, 2 ) ) ); // Initial static variable diff --git a/tests/food_fun_for_test.cpp b/tests/food_fun_for_test.cpp index bfd9563947c15..cd953586a4150 100644 --- a/tests/food_fun_for_test.cpp +++ b/tests/food_fun_for_test.cpp @@ -421,7 +421,7 @@ TEST_CASE( "fun for bionic bio taste blocker", "[fun_for][food][bionic]" ) // Needs 1 kJ per negative fun unit to nullify bad taste dummy.set_power_level( 10_kJ ); REQUIRE( garlic_fun < -10 ); - REQUIRE_FALSE( dummy.get_power_level() > units::from_kilojoule( abs( garlic_fun ) ) ); + REQUIRE_FALSE( dummy.get_power_level() > units::from_kilojoule( std::abs( garlic_fun ) ) ); THEN( "the bad taste remains" ) { actual_fun = dummy.fun_for( garlic ); @@ -432,7 +432,7 @@ TEST_CASE( "fun for bionic bio taste blocker", "[fun_for][food][bionic]" ) WHEN( "it has enough power" ) { REQUIRE( garlic_fun >= -20 ); dummy.set_power_level( 20_kJ ); - REQUIRE( dummy.get_power_level() > units::from_kilojoule( abs( garlic_fun ) ) ); + REQUIRE( dummy.get_power_level() > units::from_kilojoule( std::abs( garlic_fun ) ) ); THEN( "the bad taste is nullified" ) { actual_fun = dummy.fun_for( garlic ); diff --git a/tests/iuse_test.cpp b/tests/iuse_test.cpp index b76f39ecb6cd6..b0cc1d8b57640 100644 --- a/tests/iuse_test.cpp +++ b/tests/iuse_test.cpp @@ -416,7 +416,7 @@ TEST_CASE( "towel", "[iuse][towel]" ) GIVEN( "avatar is boomered and wet" ) { dummy.add_effect( efftype_id( "boomered" ), 1_hours ); dummy.add_morale( MORALE_WET, -10, -10, 1_hours, 1_hours ); - REQUIRE( abs( dummy.has_morale( MORALE_WET ) ) ); + REQUIRE( std::abs( dummy.has_morale( MORALE_WET ) ) ); WHEN( "they use a dry towel" ) { REQUIRE_FALSE( towel.has_flag( flag_WET ) ); @@ -424,7 +424,7 @@ TEST_CASE( "towel", "[iuse][towel]" ) THEN( "it removes the boomered effect, but not the wetness" ) { CHECK_FALSE( dummy.has_effect( efftype_id( "boomered" ) ) ); - CHECK( abs( dummy.has_morale( MORALE_WET ) ) ); + CHECK( std::abs( dummy.has_morale( MORALE_WET ) ) ); AND_THEN( "the towel becomes soiled" ) { CHECK( towel.typeId() == "towel_soiled" ); diff --git a/tests/line_test.cpp b/tests/line_test.cpp index c3bb500e92bf6..a81cbc7f07d11 100644 --- a/tests/line_test.cpp +++ b/tests/line_test.cpp @@ -19,8 +19,8 @@ static std::vector canonical_line_to( std::vector ret; const int dx = x2 - x1; const int dy = y2 - y1; - const int ax = abs( dx ) << 1; - const int ay = abs( dy ) << 1; + const int ax = std::abs( dx ) << 1; + const int ay = std::abs( dy ) << 1; int sx = SGN( dx ); int sy = SGN( dy ); if( dy == 0 ) { @@ -38,10 +38,10 @@ static std::vector canonical_line_to( int xmax = ( x1 > x2 ? x1 : x2 ); int ymax = ( y1 > y2 ? y1 : y2 ); - xmin -= abs( dx ); - ymin -= abs( dy ); - xmax += abs( dx ); - ymax += abs( dy ); + xmin -= std::abs( dx ); + ymin -= std::abs( dy ); + xmax += std::abs( dx ); + ymax += std::abs( dy ); if( ax == ay ) { do { @@ -394,8 +394,8 @@ TEST_CASE( "line_to_boundaries" ) { for( int i = -60; i < 60; ++i ) { for( int j = -60; j < 60; ++j ) { - const int ax = abs( i ) * 2; - const int ay = abs( j ) * 2; + const int ax = std::abs( i ) * 2; + const int ay = std::abs( j ) * 2; const int dominant = std::max( ax, ay ); const int minor = std::min( ax, ay ); const int ideal_start_offset = minor - ( dominant / 2 ); diff --git a/tests/test_statistics.cpp b/tests/test_statistics.cpp index 81fe56e4f2e3f..19fca0e8fd0bb 100644 --- a/tests/test_statistics.cpp +++ b/tests/test_statistics.cpp @@ -11,7 +11,7 @@ BinomialMatcher::BinomialMatcher( const int num_samples, const double p, // Binomial expectation is np, variance is np(1-p). // So we want | obs - np | <= max_deviation * sqrt( np(1-p) ) expected_ = num_samples_ * p_; - margin_ = max_deviation_ * sqrt( num_samples_ * p_ * ( 1 - p_ ) ); + margin_ = max_deviation_ * std::sqrt( num_samples_ * p_ * ( 1 - p_ ) ); } bool BinomialMatcher::match( const int &obs ) const