Skip to content

Commit

Permalink
refactor: average_annual_termperature to units::temperature
Browse files Browse the repository at this point in the history
  • Loading branch information
scarf005 committed Apr 5, 2023
1 parent 9ccbe63 commit 9845588
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
13 changes: 5 additions & 8 deletions src/game_constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ static constexpr int VEHICLE_HANDLING_PENALTY = 80;
static constexpr int PLUTONIUM_CHARGES = 500;

// Temperature constants.

/// Average annual temperature used for climate, weather and temperature calculation.
constexpr units::temperature average_annual_termperature = 6_c;

namespace temperatures
{
// temperature at which something starts is considered HOT.
Expand All @@ -97,8 +101,7 @@ constexpr units::temperature freezer = -5_c;
constexpr units::temperature freezing = 0_c;

// Arbitrary constant for root cellar temperature
// Should be equal to AVERAGE_ANNUAL_TEMPERATURE, but is declared before it...
constexpr units::temperature root_cellar = 6_c;
constexpr units::temperature root_cellar = average_annual_termperature;
} // namespace temperatures

// Weight per level of LIFT/JACK tool quality.
Expand Down Expand Up @@ -139,12 +142,6 @@ static constexpr int BIO_CQB_LEVEL = 5;
// Minimum size of a horde to show up on the minimap.
static constexpr int HORDE_VISIBILITY_SIZE = 3;

/**
* Average annual temperature in F used for climate, weather and temperature calculation.
* Average New England temperature = 43F/6C rounded to int.
*/
static constexpr int AVERAGE_ANNUAL_TEMPERATURE = 43;

/**
* Base starting spring temperature in F used for climate, weather and temperature calculation.
* New England base spring temperature = 65F/18C rounded to int.
Expand Down
2 changes: 1 addition & 1 deletion src/item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9018,7 +9018,7 @@ bool item::process_rot( const bool seals, const tripoint &pos,
calendar::config, seed );
env_temperature_raw = weather_temperature + local_mod;
} else {
env_temperature_raw = units::from_fahrenheit( AVERAGE_ANNUAL_TEMPERATURE ) + local_mod;
env_temperature_raw = average_annual_termperature + local_mod;
}

units::temperature env_temperature_clipped = clip_by_temperature_flag( env_temperature_raw, flag );
Expand Down
5 changes: 3 additions & 2 deletions src/weather.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1119,7 +1119,8 @@ int weather_manager::get_temperature( const tripoint &location ) const
temp_mod += get_convection_temperature( location );
}
//underground temperature = average New England temperature = 43F/6C rounded to int
const int temp = ( location.z < 0 ? AVERAGE_ANNUAL_TEMPERATURE : temperature ) +
const int temp = ( location.z < 0 ? units::to_fahrenheit( average_annual_termperature ) :
temperature ) +
( g->new_game ? 0 : g->m.get_temperature( location ) + temp_mod );

temperature_cache.emplace( std::make_pair( location, temp ) );
Expand All @@ -1129,7 +1130,7 @@ int weather_manager::get_temperature( const tripoint &location ) const
int weather_manager::get_temperature( const tripoint_abs_omt &location )
{
if( location.z() < 0 ) {
return AVERAGE_ANNUAL_TEMPERATURE;
return units::to_fahrenheit( average_annual_termperature );
}

tripoint abs_ms = project_to<coords::ms>( location ).raw();
Expand Down

0 comments on commit 9845588

Please sign in to comment.