Skip to content

Commit

Permalink
Jsonized new district fields
Browse files Browse the repository at this point in the history
  • Loading branch information
NotFuji committed Jan 6, 2019
1 parent f2ffa7f commit 1895701
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
6 changes: 4 additions & 2 deletions data/json/regional_map_settings.json
Expand Up @@ -521,8 +521,10 @@
"swamp_spread_chance": 8500,
"city": {
"type": "town",
"shop_radius": 80,
"park_radius": 90,
"shop_radius": 30,
"shop_sigma": 20,
"park_radius": 30,
"park_sigma": 70,
"house_basement_chance": 5,
"houses": {
"house_two_story_basement": 1,
Expand Down
2 changes: 1 addition & 1 deletion src/overmap.cpp
Expand Up @@ -2361,7 +2361,7 @@ void overmap::place_building( const tripoint &p, om_direction::type dir, const c
const om_direction::type building_dir = om_direction::opposite( dir );

const int town_dist = ( trig_dist( building_pos.x, building_pos.y, town.pos.x,
town.pos.y ) * 100 ) / std::max( town.size / 2, 1 );
town.pos.y ) * 100 ) / std::max( town.size, 1 );

for( size_t retries = 10; retries > 0; --retries ) {
const overmap_special_id building_tid = pick_random_building_to_place( town_dist );
Expand Down
8 changes: 8 additions & 0 deletions src/regional_settings.cpp
Expand Up @@ -387,9 +387,15 @@ void load_region_settings( JsonObject &jo )
if( ! cjo.read( "shop_radius", new_region.city_spec.shop_radius ) && strict ) {
jo.throw_error( "city: shop_radius required for default" );
}
if( !cjo.read( "shop_sigma", new_region.city_spec.shop_sigma ) && strict ) {
jo.throw_error( "city: shop_sigma required for default" );
}
if( ! cjo.read( "park_radius", new_region.city_spec.park_radius ) && strict ) {
jo.throw_error( "city: park_radius required for default" );
}
if( !cjo.read( "park_sigma", new_region.city_spec.park_sigma ) && strict ) {
jo.throw_error( "city: park_sigma required for default" );
}
if( ! cjo.read( "house_basement_chance", new_region.city_spec.house_basement_chance ) && strict ) {
jo.throw_error( "city: house_basement_chance required for default" );
}
Expand Down Expand Up @@ -573,7 +579,9 @@ void apply_region_overlay( JsonObject &jo, regional_settings &region )
JsonObject cityjo = jo.get_object( "city" );

cityjo.read( "shop_radius", region.city_spec.shop_radius );
cityjo.read( "shop_sigma", region.city_spec.shop_sigma );
cityjo.read( "park_radius", region.city_spec.park_radius );
cityjo.read( "park_sigma", region.city_spec.park_sigma );
cityjo.read( "house_basement_chance", region.city_spec.house_basement_chance );

const auto load_building_types = [&cityjo]( const std::string & type, building_bin & dest ) {
Expand Down

0 comments on commit 1895701

Please sign in to comment.