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

Weather works with region overlay #78234

Merged
merged 2 commits into from
Nov 30, 2024
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
13 changes: 9 additions & 4 deletions src/regional_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -587,10 +587,9 @@ void load_region_settings( const JsonObject &jo )
load_building_types( "parks", new_region.city_spec.parks );
}

if( !jo.has_object( "weather" ) ) {
if( strict ) {
jo.throw_error( "\"weather\": { … } required for default" );
}
// TODO: Support overwriting only some values in non default regions
if( strict && !jo.has_object( "weather" ) ) {
jo.throw_error( "\"weather\": { … } required for default" );
} else {
JsonObject wjo = jo.get_object( "weather" );
new_region.weather = weather_generator::load( wjo );
Expand Down Expand Up @@ -747,6 +746,12 @@ void apply_region_overlay( const JsonObject &jo, regional_settings &region )
load_building_types( "shops", region.city_spec.shops );
load_building_types( "parks", region.city_spec.parks );

// TODO: Support overwriting only some values
if( jo.has_object( "weather" ) ) {
JsonObject wjo = jo.get_object( "weather" );
region.weather = weather_generator::load( wjo );
}

load_overmap_feature_flag_settings( jo, region.overmap_feature_flag, false, true );

load_overmap_forest_settings( jo, region.overmap_forest, false, true );
Expand Down
1 change: 1 addition & 0 deletions src/weather_gen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ int weather_generator::get_wind_direction( const season_type season ) const
cata_default_random_engine &wind_dir_gen = rng_get_engine();
// Assign chance to angle direction
if( season == SPRING ) {
//TODO: Unhardcode?
std::discrete_distribution<int> distribution {3, 3, 5, 8, 11, 10, 5, 2, 5, 6, 6, 5, 8, 10, 8, 6};
return distribution( wind_dir_gen );
} else if( season == SUMMER ) {
Expand Down
2 changes: 2 additions & 0 deletions src/weather_gen.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class weather_generator
double base_wind = 0;
//How much the wind peaks above average
int base_wind_distrib_peaks = 0;
// TODO: Store as arrays?
int summer_temp_manual_mod = 0;
int spring_temp_manual_mod = 0;
int autumn_temp_manual_mod = 0;
Expand All @@ -49,6 +50,7 @@ class weather_generator
//How much the wind follows seasonal variation ( lower means more change )
int base_wind_season_variation = 0;
static int current_winddir;
// TODO: Use std::vector<weather_type_id> and finalise in region settings instead?
std::vector<std::string> weather_black_list;
std::vector<std::string> weather_white_list;
/** All the current weather types based on white or black list and sorted by load order */
Expand Down
Loading