Skip to content

Commit

Permalink
refactor: simplify celsisus to fahrenheit calls
Browse files Browse the repository at this point in the history
  • Loading branch information
scarf005 and Coolthulhu committed Apr 17, 2023
1 parent caff8e3 commit eca33cf
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/suffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1807,7 +1807,7 @@ void Character::drench( int saturation, const body_part_set &flags, bool ignore_
}
}

void Character::apply_wetness_morale( const units::temperature &celsius_temperature )
void Character::apply_wetness_morale( const units::temperature &temperature )
{
// First, a quick check if we have any wetness to calculate morale from
// Faster than checking all worn items for friendliness
Expand All @@ -1818,11 +1818,11 @@ void Character::apply_wetness_morale( const units::temperature &celsius_temperat
return;
}

int temperature = units::celsius_to_fahrenheit( celsius_temperature.value() );
int normalized_temperature = units::to_fahrenheit( temperature );
// Normalize temperature to [-1.0,1.0]
temperature = std::clamp( temperature, 0, 100 );
normalized_temperature = std::clamp( normalized_temperature, 0, 100 );

const double global_temperature_mod = -1.0 + ( 2.0 * temperature / 100.0 );
const double global_temperature_mod = -1.0 + ( 2.0 * normalized_temperature / 100.0 );

int total_morale = 0;
const auto wet_friendliness = exclusive_flag_coverage( "WATER_FRIENDLY" );
Expand Down

0 comments on commit eca33cf

Please sign in to comment.