From 0abf01dd9b9c55fa72a5674ddaf43fccc056ae32 Mon Sep 17 00:00:00 2001 From: John Bytheway Date: Mon, 27 Apr 2020 16:41:36 -0400 Subject: [PATCH] Convert get_blended_feature helper to use point --- src/mapgen_functions.cpp | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/mapgen_functions.cpp b/src/mapgen_functions.cpp index c35b2a144e897..5d94ca4d103ef 100644 --- a/src/mapgen_functions.cpp +++ b/src/mapgen_functions.cpp @@ -2579,7 +2579,7 @@ void mapgen_forest( mapgendata &dat ) static constexpr int margin_y = SEEY * 2 / 3; const auto get_blended_feature = [&no_ter_furn, &max_factor, &factor, - &get_feature_for_neighbor, &dat]( int x, int y ) { + &get_feature_for_neighbor, &dat]( const point & p ) { // Pick one random feature from each biome according to the biome defs and save it into a lookup. // We'll blend these features together below based on the current and adjacent terrains. std::map biome_features; @@ -2612,25 +2612,25 @@ void mapgen_forest( mapgendata &dat ) // --------------- // SOUTH (SEEX * 2, SEEY * 2) - const int west_weight = std::max( margin_x - x, 0 ); - const int east_weight = std::max( x - ( SEEX * 2 - margin_x ) + 1, 0 ); - const int north_weight = std::max( margin_y - y, 0 ); - const int south_weight = std::max( y - ( SEEY * 2 - margin_y ) + 1, 0 ); + const int west_weight = std::max( margin_x - p.x, 0 ); + const int east_weight = std::max( p.x - ( SEEX * 2 - margin_x ) + 1, 0 ); + const int north_weight = std::max( margin_y - p.y, 0 ); + const int south_weight = std::max( p.y - ( SEEY * 2 - margin_y ) + 1, 0 ); // We'll build a weighted list of features to pull from at the end. weighted_int_list feature_pool; // W sections - if( x < margin_x ) { + if( p.x < margin_x ) { // NW corner - blend N, W, and self - if( y < margin_y ) { + if( p.y < margin_y ) { feature_pool.add( no_ter_furn, 3 * max_factor - ( dat.n_fac + dat.w_fac + factor * 2 ) ); feature_pool.add( self_feature, 1 ); feature_pool.add( west_feature, west_weight ); feature_pool.add( north_feature, north_weight ); } // SW corner - blend S, W, and self - else if( y > SEEY * 2 - margin_y ) { + else if( p.y > SEEY * 2 - margin_y ) { feature_pool.add( no_ter_furn, 3 * max_factor - ( dat.s_fac + dat.w_fac + factor * 2 ) ); feature_pool.add( self_feature, factor ); feature_pool.add( west_feature, west_weight ); @@ -2644,16 +2644,16 @@ void mapgen_forest( mapgendata &dat ) } } // E sections - else if( x > SEEX * 2 - margin_x ) { + else if( p.x > SEEX * 2 - margin_x ) { // NE corner - blend N, E, and self - if( y < margin_y ) { + if( p.y < margin_y ) { feature_pool.add( no_ter_furn, 3 * max_factor - ( dat.n_fac + dat.e_fac + factor * 2 ) ); feature_pool.add( self_feature, factor ); feature_pool.add( east_feature, east_weight ); feature_pool.add( north_feature, north_weight ); } // SE corner - blend S, E, and self - else if( y > SEEY * 2 - margin_y ) { + else if( p.y > SEEY * 2 - margin_y ) { feature_pool.add( no_ter_furn, 3 * max_factor - ( dat.s_fac + dat.e_fac + factor * 2 ) ); feature_pool.add( self_feature, factor ); feature_pool.add( east_feature, east_weight ); @@ -2669,13 +2669,13 @@ void mapgen_forest( mapgendata &dat ) // Central sections else { // N edge - blend N and self - if( y < margin_y ) { + if( p.y < margin_y ) { feature_pool.add( no_ter_furn, 2 * max_factor - ( dat.n_fac + factor * 2 ) ); feature_pool.add( self_feature, factor ); feature_pool.add( north_feature, north_weight ); } // S edge - blend S, and self - else if( y > SEEY * 2 - margin_y ) { + else if( p.y > SEEY * 2 - margin_y ) { feature_pool.add( no_ter_furn, 2 * max_factor - ( dat.s_fac + factor * 2 ) ); feature_pool.add( self_feature, factor ); feature_pool.add( south_feature, south_weight ); @@ -2743,7 +2743,7 @@ void mapgen_forest( mapgendata &dat ) // terrain dependent furniture. for( int x = 0; x < SEEX * 2; x++ ) { for( int y = 0; y < SEEY * 2; y++ ) { - const ter_furn_id feature = get_blended_feature( x, y ); + const ter_furn_id feature = get_blended_feature( point( x, y ) ); ter_or_furn_set( m, x, y, feature ); set_terrain_dependent_furniture( feature.ter, x, y ); }