Skip to content

Commit

Permalink
Merge pull request #58766 from BrettDong/cmath
Browse files Browse the repository at this point in the history
Migrate c-style math functions to C++ cmath counterparts
  • Loading branch information
ZhilkinSerg authored Jun 27, 2022
2 parents 31319f8 + 6cc660f commit b1d5318
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
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

0 comments on commit b1d5318

Please sign in to comment.