-
Notifications
You must be signed in to change notification settings - Fork 278
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
Smoother rivers connections on overmaps edges #3178
Merged
Merged
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1649,7 +1649,7 @@ void overmap::generate( const overmap *north, const overmap *east, | |
place_specials( enabled_specials ); | ||
place_forest_trailheads(); | ||
|
||
polish_river(); | ||
polish_river( north, east, south, west ); | ||
|
||
// TODO: there is no reason we can't generate the sublevels in one pass | ||
// for that matter there is no reason we can't as we add the entrance ways either | ||
|
@@ -3972,15 +3972,6 @@ void overmap::connect_closest_points( const std::vector<point_om_omt> &points, i | |
} | ||
} | ||
|
||
void overmap::polish_river() | ||
{ | ||
for( int x = 0; x < OMAPX; x++ ) { | ||
for( int y = 0; y < OMAPY; y++ ) { | ||
good_river( { x, y, 0 } ); | ||
} | ||
} | ||
} | ||
|
||
// Changes neighboring empty rock to partial rock | ||
void overmap::chip_rock( const tripoint_om_omt &p ) | ||
{ | ||
|
@@ -4020,95 +4011,117 @@ bool overmap::check_overmap_special_type( const overmap_special_id &id, | |
return found_id->second == id; | ||
} | ||
|
||
void overmap::good_river( const tripoint_om_omt &p ) | ||
void overmap::polish_river( const overmap *north, const overmap *east, const overmap *south, | ||
const overmap *west ) | ||
{ | ||
if( !is_ot_match( "river", ter( p ), ot_match_type::prefix ) ) { | ||
return; | ||
} | ||
if( ( p.x() == 0 ) || ( p.x() == OMAPX - 1 ) ) { | ||
if( !is_river_or_lake( ter( p + point_north ) ) ) { | ||
ter_set( p, oter_id( "river_north" ) ); | ||
} else if( !is_river_or_lake( ter( p + point_south ) ) ) { | ||
ter_set( p, oter_id( "river_south" ) ); | ||
} else { | ||
ter_set( p, oter_id( "river_center" ) ); | ||
} | ||
return; | ||
} | ||
if( ( p.y() == 0 ) || ( p.y() == OMAPY - 1 ) ) { | ||
if( !is_river_or_lake( ter( p + point_west ) ) ) { | ||
ter_set( p, oter_id( "river_west" ) ); | ||
} else if( !is_river_or_lake( ter( p + point_east ) ) ) { | ||
ter_set( p, oter_id( "river_east" ) ); | ||
} else { | ||
ter_set( p, oter_id( "river_center" ) ); | ||
} | ||
return; | ||
} | ||
if( is_river_or_lake( ter( p + point_west ) ) ) { | ||
if( is_river_or_lake( ter( p + point_north ) ) ) { | ||
if( is_river_or_lake( ter( p + point_south ) ) ) { | ||
if( is_river_or_lake( ter( p + point_east ) ) ) { | ||
// River on N, S, E, W; | ||
// but we might need to take a "bite" out of the corner | ||
if( !is_river_or_lake( ter( p + point_north_west ) ) ) { | ||
ter_set( p, oter_id( "river_c_not_nw" ) ); | ||
} else if( !is_river_or_lake( ter( p + point_north_east ) ) ) { | ||
ter_set( p, oter_id( "river_c_not_ne" ) ); | ||
} else if( !is_river_or_lake( ter( p + point_south_west ) ) ) { | ||
ter_set( p, oter_id( "river_c_not_sw" ) ); | ||
} else if( !is_river_or_lake( ter( p + point_south_east ) ) ) { | ||
ter_set( p, oter_id( "river_c_not_se" ) ); | ||
for( int x = 0; x < OMAPX; x++ ) { | ||
for( int y = 0; y < OMAPY; y++ ) { | ||
const tripoint_om_omt p = { x, y, 0 }; | ||
|
||
if( !is_ot_match( "river", ter( p ), ot_match_type::prefix ) ) { | ||
continue; | ||
} | ||
|
||
// For ungenerated overmaps we're assuming that terra incognita is covered by water, and leaving polishing to its mapgen | ||
bool water_north = y != 0 ? is_river_or_lake( ter( { x, y - 1, 0} ) ) : | ||
north != nullptr ? is_river_or_lake( north->ter( { x, OMAPY - 1, 0 } ) ) : true; | ||
bool water_west = x != 0 ? is_river_or_lake( ter( { x - 1, y, 0} ) ) : | ||
west != nullptr ? is_river_or_lake( west->ter( { OMAPX - 1, y, 0 } ) ) : true; | ||
bool water_south = y != OMAPY - 1 ? is_river_or_lake( ter( { x, y + 1, 0} ) ) : | ||
south != nullptr ? is_river_or_lake( south->ter( { x, 0, 0 } ) ) : true; | ||
bool water_east = x != OMAPX - 1 ? is_river_or_lake( ter( { x + 1, y, 0} ) ) : | ||
east != nullptr ? is_river_or_lake( east->ter( { 0, y, 0 } ) ) : true; | ||
|
||
if( water_west ) { | ||
if( water_north ) { | ||
if( water_south ) { | ||
if( water_east ) { | ||
// River on N, S, E, W; | ||
// but we might need to take a "bite" out of the corner | ||
if( ( x > 0 && y > 0 && | ||
!is_river_or_lake( ter( { x - 1, y - 1, 0} ) ) ) || | ||
( x > 0 && y == 0 && north != nullptr && | ||
!is_river_or_lake( north->ter( { x - 1, OMAPY - 1, 0} ) ) ) || | ||
( x == 0 && y > 0 && west != nullptr && | ||
!is_river_or_lake( west->ter( { OMAPX - 1, y - 1, 0} ) ) ) | ||
) { | ||
Comment on lines
+4041
to
+4047
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there an easy way to extract these checks into some function, or closure, that would take |
||
ter_set( p, oter_id( "river_c_not_nw" ) ); | ||
} else if( ( x < OMAPX - 1 && y > 0 && | ||
!is_river_or_lake( ter( { x + 1, y - 1, 0} ) ) ) || | ||
( x < OMAPX - 1 && y == 0 && north != nullptr && | ||
!is_river_or_lake( north->ter( { x + 1, OMAPY - 1, 0 } ) ) ) || | ||
( x == OMAPX - 1 && y > 0 && east != nullptr && | ||
!is_river_or_lake( east->ter( { 0, y - 1, 0 } ) ) ) | ||
) { | ||
ter_set( p, oter_id( "river_c_not_ne" ) ); | ||
} else if( ( x > 0 && y < OMAPY - 1 && | ||
!is_river_or_lake( ter( { x - 1, y + 1, 0} ) ) ) || | ||
( x > 0 && y == OMAPY - 1 && south != nullptr && | ||
!is_river_or_lake( south->ter( { x - 1, 0, 0} ) ) ) || | ||
( x == 0 && y < OMAPY - 1 && west != nullptr && | ||
!is_river_or_lake( west->ter( { OMAPX - 1, y + 1, 0} ) ) ) | ||
) { | ||
ter_set( p, oter_id( "river_c_not_sw" ) ); | ||
} else if( ( x < OMAPX - 1 && y < OMAPY - 1 && | ||
!is_river_or_lake( ter( { x + 1, y + 1, 0} ) ) ) || | ||
( x < OMAPX - 1 && y == OMAPY - 1 && south != nullptr && | ||
!is_river_or_lake( south->ter( { x + 1, 0, 0 } ) ) ) || | ||
( x == OMAPX - 1 && y < OMAPY - 1 && east != nullptr && | ||
!is_river_or_lake( east->ter( { 0, y + 1, 0 } ) ) ) | ||
) { | ||
ter_set( p, oter_id( "river_c_not_se" ) ); | ||
} else { | ||
ter_set( p, oter_id( "river_center" ) ); | ||
} | ||
} else { | ||
ter_set( p, oter_id( "river_east" ) ); | ||
} | ||
} else { | ||
ter_set( p, oter_id( "river_center" ) ); | ||
if( water_east ) { | ||
ter_set( p, oter_id( "river_south" ) ); | ||
} else { | ||
ter_set( p, oter_id( "river_se" ) ); | ||
} | ||
} | ||
} else { | ||
ter_set( p, oter_id( "river_east" ) ); | ||
if( water_south ) { | ||
if( water_east ) { | ||
ter_set( p, oter_id( "river_north" ) ); | ||
} else { | ||
ter_set( p, oter_id( "river_ne" ) ); | ||
} | ||
} else { | ||
if( water_east ) { // Means it's swampy | ||
ter_set( p, oter_id( "forest_water" ) ); | ||
} | ||
} | ||
} | ||
} else { | ||
if( is_river_or_lake( ter( p + point_east ) ) ) { | ||
ter_set( p, oter_id( "river_south" ) ); | ||
} else { | ||
ter_set( p, oter_id( "river_se" ) ); | ||
} | ||
} | ||
} else { | ||
if( is_river_or_lake( ter( p + point_south ) ) ) { | ||
if( is_river_or_lake( ter( p + point_east ) ) ) { | ||
ter_set( p, oter_id( "river_north" ) ); | ||
if( water_north ) { | ||
if( water_south ) { | ||
if( water_east ) { | ||
ter_set( p, oter_id( "river_west" ) ); | ||
} else { // Should never happen | ||
ter_set( p, oter_id( "forest_water" ) ); | ||
} | ||
} else { | ||
if( water_east ) { | ||
ter_set( p, oter_id( "river_sw" ) ); | ||
} else { // Should never happen | ||
ter_set( p, oter_id( "forest_water" ) ); | ||
} | ||
} | ||
} else { | ||
ter_set( p, oter_id( "river_ne" ) ); | ||
} | ||
} else { | ||
if( is_river_or_lake( ter( p + point_east ) ) ) { // Means it's swampy | ||
ter_set( p, oter_id( "forest_water" ) ); | ||
} | ||
} | ||
} | ||
} else { | ||
if( is_river_or_lake( ter( p + point_north ) ) ) { | ||
if( is_river_or_lake( ter( p + point_south ) ) ) { | ||
if( is_river_or_lake( ter( p + point_east ) ) ) { | ||
ter_set( p, oter_id( "river_west" ) ); | ||
} else { // Should never happen | ||
ter_set( p, oter_id( "forest_water" ) ); | ||
} | ||
} else { | ||
if( is_river_or_lake( ter( p + point_east ) ) ) { | ||
ter_set( p, oter_id( "river_sw" ) ); | ||
} else { // Should never happen | ||
ter_set( p, oter_id( "forest_water" ) ); | ||
} | ||
} | ||
} else { | ||
if( is_river_or_lake( ter( p + point_south ) ) ) { | ||
if( is_river_or_lake( ter( p + point_east ) ) ) { | ||
ter_set( p, oter_id( "river_nw" ) ); | ||
} else { // Should never happen | ||
ter_set( p, oter_id( "forest_water" ) ); | ||
if( water_south ) { | ||
if( water_east ) { | ||
ter_set( p, oter_id( "river_nw" ) ); | ||
} else { // Should never happen | ||
ter_set( p, oter_id( "forest_water" ) ); | ||
} | ||
} else { // Should never happen | ||
ter_set( p, oter_id( "forest_water" ) ); | ||
} | ||
} | ||
} else { // Should never happen | ||
ter_set( p, oter_id( "forest_water" ) ); | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything from this line and to the end of the loop should really be extracted into a separate function.
good_river
was a terrible name, but something likepolish_river_tile(x,y,north,south,east,west)
simply begs to exist here.Usually the less nested
if
s andfor
s there are in a function, the more readable it is.