Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate c-style math functions to C++ cmath counterparts #58766

Merged
merged 2 commits into from
Jun 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/construction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1442,16 +1442,16 @@ void construct::done_wiring( const tripoint &p, Character &/*who*/ )

bounding_box vehicle_box = veh->get_bounding_box( false );
point size;
size.x = abs( ( vehicle_box.p2 - vehicle_box.p1 ).x ) + 1;
size.y = abs( ( vehicle_box.p2 - vehicle_box.p1 ).y ) + 1;
size.x = std::abs( ( vehicle_box.p2 - vehicle_box.p1 ).x ) + 1;
size.y = std::abs( ( vehicle_box.p2 - vehicle_box.p1 ).y ) + 1;

vehicle &veh_target = vp->vehicle();
if( &veh_target != veh && veh_target.has_tag( flag_WIRING ) ) {
bounding_box target_vehicle_box = veh_target.get_bounding_box( false );

point target_size;
target_size.x = abs( ( target_vehicle_box.p2 - target_vehicle_box.p1 ).x ) + 1;
target_size.y = abs( ( target_vehicle_box.p2 - target_vehicle_box.p1 ).y ) + 1;
target_size.x = std::abs( ( target_vehicle_box.p2 - target_vehicle_box.p1 ).x ) + 1;
target_size.y = std::abs( ( target_vehicle_box.p2 - target_vehicle_box.p1 ).y ) + 1;

if( size.x + target_size.x <= MAX_WIRE_VEHICLE_SIZE &&
size.y + target_size.y <= MAX_WIRE_VEHICLE_SIZE ) {
Expand Down
2 changes: 1 addition & 1 deletion src/faction_camp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2525,7 +2525,7 @@ static const int max_salt_water_pipe_length =
// Hard coded strings used to construct expansion "provides" needed by recipes to coordinate salt water pipe construction
static const std::string salt_water_pipe_string_base = "salt_water_pipe_";
static const std::string salt_water_pipe_string_suffix = "_scheduled";
static const double diagonal_salt_pipe_cost = sqrt( 2.0 );
static const double diagonal_salt_pipe_cost = std::sqrt( 2.0 );
static const double salt_pipe_legal = 0.0;
static const double salt_pipe_illegal = -0.1;
static const double salt_pipe_swamp = -0.2;
Expand Down
2 changes: 1 addition & 1 deletion src/item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4968,7 +4968,7 @@ void item::melee_combat_info( std::vector<iteminfo> &info, const iteminfo_query

if( base_stamina || base_dpstam ) {
stam = player_character.get_total_melee_stamina_cost( this ) * -1;
stam_pct = truncf( stam * 1000.0 / player_character.get_stamina_max() ) / 10;
stam_pct = std::truncf( stam * 1000.0 / player_character.get_stamina_max() ) / 10;
}

if( base_dps || base_dpstam ) {
Expand Down
2 changes: 1 addition & 1 deletion src/material.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ bool material_type::is_valid_thickness( float thickness ) const
}

// float calcs so rounding need to be mindful of
return fmodf( thickness, _sheet_thickness ) < .01;
return std::fmod( thickness, _sheet_thickness ) < .01f;
}

float material_type::thickness_multiple() const
Expand Down