Skip to content

Commit

Permalink
Merge pull request CleverRaven#78234 from Procyonae/WeatherWorksWithO…
Browse files Browse the repository at this point in the history
…verlay

Weather works with region overlay
  • Loading branch information
Maleclypse authored Nov 30, 2024
2 parents 447eda8 + b1913fb commit 3b34699
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
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

0 comments on commit 3b34699

Please sign in to comment.