Skip to content

Commit

Permalink
Merge pull request #70234 from ralreegorganon/minor-lake-issues
Browse files Browse the repository at this point in the history
Fix lake shore mapgen corner case
  • Loading branch information
Maleclypse authored Dec 16, 2023
2 parents 067f6ad + 7d9c490 commit e93b4ac
Showing 1 changed file with 112 additions and 24 deletions.
136 changes: 112 additions & 24 deletions src/mapgen_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1605,12 +1605,23 @@ void mapgen_lake_shore( mapgendata &dat )
if( n_lake && w_lake ) {
nw.x += sector_length / 2;
nw.y += sector_length / 2;
} else if( n_shore && w_shore ) {
} else if( ( n_shore || n_river_bank ) && ( w_shore || w_river_bank ) ) {
point n = nw_corner;
point w = nw_corner;

n.x += sector_length;
w.y += sector_length;
n.x += sector_length * ( n_river_bank ? 2 : 1 );
w.y += sector_length * ( w_river_bank ? 2 : 1 );

n.y += n_river_bank ? sector_length / 2 : 0;
w.x += w_river_bank ? sector_length / 2 : 0;

if( w_river_bank ) {
line_segments.push_back( { sw, w } );
}

if( n_river_bank ) {
line_segments.push_back( { n, ne } );
}

line_segments.push_back( { n, w } );
}
Expand All @@ -1620,12 +1631,23 @@ void mapgen_lake_shore( mapgendata &dat )
if( n_lake && e_lake ) {
ne.x -= sector_length / 2;
ne.y += sector_length / 2;
} else if( n_shore && e_shore ) {
} else if( ( n_shore || n_river_bank ) && ( e_shore || e_river_bank ) ) {
point n = ne_corner;
point e = ne_corner;

n.x -= sector_length;
e.y += sector_length;
n.x -= sector_length * ( n_river_bank ? 2 : 1 );
e.y += sector_length * ( e_river_bank ? 2 : 1 );

n.y += n_river_bank ? sector_length / 2 : 0;
e.x -= e_river_bank ? sector_length / 2 : 0;

if( e_river_bank ) {
line_segments.push_back( { se, e } );
}

if( n_river_bank ) {
line_segments.push_back( { n, nw } );
}

line_segments.push_back( { n, e } );
}
Expand All @@ -1635,12 +1657,23 @@ void mapgen_lake_shore( mapgendata &dat )
if( s_lake && w_lake ) {
sw.x += sector_length / 2;
sw.y -= sector_length / 2;
} else if( s_shore && w_shore ) {
} else if( ( s_shore || s_river_bank ) && ( w_shore || w_river_bank ) ) {
point s = sw_corner;
point w = sw_corner;

s.x += sector_length;
w.y -= sector_length;
s.x += sector_length * ( s_river_bank ? 2 : 1 );
w.y -= sector_length * ( w_river_bank ? 2 : 1 );

s.y -= s_river_bank ? sector_length / 2 : 0;
w.x += w_river_bank ? sector_length / 2 : 0;

if( w_river_bank ) {
line_segments.push_back( { nw, w } );
}

if( s_river_bank ) {
line_segments.push_back( { s, se } );
}

line_segments.push_back( { s, w } );
}
Expand All @@ -1650,12 +1683,23 @@ void mapgen_lake_shore( mapgendata &dat )
if( s_lake && e_lake ) {
se.x -= sector_length / 2;
se.y -= sector_length / 2;
} else if( s_shore && e_shore ) {
} else if( ( s_shore || s_river_bank ) && ( e_shore || e_river_bank ) ) {
point s = se_corner;
point e = se_corner;

s.x -= sector_length;
e.y -= sector_length;
s.x -= sector_length * ( s_river_bank ? 2 : 1 );
e.y -= sector_length * ( e_river_bank ? 2 : 1 );

s.y -= s_river_bank ? sector_length / 2 : 0;
e.x -= e_river_bank ? sector_length / 2 : 0;

if( e_river_bank ) {
line_segments.push_back( { ne, e } );
}

if( s_river_bank ) {
line_segments.push_back( { s, sw } );
}

line_segments.push_back( { s, e } );
}
Expand Down Expand Up @@ -1956,12 +2000,23 @@ void mapgen_ocean_shore( mapgendata &dat )
if( n_ocean && w_ocean ) {
nw.x += sector_length / 2;
nw.y += sector_length / 2;
} else if( n_shore && w_shore ) {
} else if( ( n_shore || n_river_bank ) && ( w_shore || w_river_bank ) ) {
point n = nw_corner;
point w = nw_corner;

n.x += sector_length;
w.y += sector_length;
n.x += sector_length * ( n_river_bank ? 2 : 1 );
w.y += sector_length * ( w_river_bank ? 2 : 1 );

n.y += n_river_bank ? sector_length / 2 : 0;
w.x += w_river_bank ? sector_length / 2 : 0;

if( w_river_bank ) {
line_segments.push_back( { sw, w } );
}

if( n_river_bank ) {
line_segments.push_back( { n, ne } );
}

line_segments.push_back( { n, w } );
}
Expand All @@ -1971,12 +2026,23 @@ void mapgen_ocean_shore( mapgendata &dat )
if( n_ocean && e_ocean ) {
ne.x -= sector_length / 2;
ne.y += sector_length / 2;
} else if( n_shore && e_shore ) {
} else if( ( n_shore || n_river_bank ) && ( e_shore || e_river_bank ) ) {
point n = ne_corner;
point e = ne_corner;

n.x -= sector_length;
e.y += sector_length;
n.x -= sector_length * ( n_river_bank ? 2 : 1 );
e.y += sector_length * ( e_river_bank ? 2 : 1 );

n.y += n_river_bank ? sector_length / 2 : 0;
e.x -= e_river_bank ? sector_length / 2 : 0;

if( e_river_bank ) {
line_segments.push_back( { se, e } );
}

if( n_river_bank ) {
line_segments.push_back( { n, nw } );
}

line_segments.push_back( { n, e } );
}
Expand All @@ -1986,12 +2052,23 @@ void mapgen_ocean_shore( mapgendata &dat )
if( s_ocean && w_ocean ) {
sw.x += sector_length / 2;
sw.y -= sector_length / 2;
} else if( s_shore && w_shore ) {
} else if( ( s_shore || s_river_bank ) && ( w_shore || w_river_bank ) ) {
point s = sw_corner;
point w = sw_corner;

s.x += sector_length;
w.y -= sector_length;
s.x += sector_length * ( s_river_bank ? 2 : 1 );
w.y -= sector_length * ( w_river_bank ? 2 : 1 );

s.y -= s_river_bank ? sector_length / 2 : 0;
w.x += w_river_bank ? sector_length / 2 : 0;

if( w_river_bank ) {
line_segments.push_back( { nw, w } );
}

if( s_river_bank ) {
line_segments.push_back( { s, se } );
}

line_segments.push_back( { s, w } );
}
Expand All @@ -2001,12 +2078,23 @@ void mapgen_ocean_shore( mapgendata &dat )
if( s_ocean && e_ocean ) {
se.x -= sector_length / 2;
se.y -= sector_length / 2;
} else if( s_shore && e_shore ) {
} else if( ( s_shore || s_river_bank ) && ( e_shore || e_river_bank ) ) {
point s = se_corner;
point e = se_corner;

s.x -= sector_length;
e.y -= sector_length;
s.x -= sector_length * ( s_river_bank ? 2 : 1 );
e.y -= sector_length * ( e_river_bank ? 2 : 1 );

s.y -= s_river_bank ? sector_length / 2 : 0;
e.x -= e_river_bank ? sector_length / 2 : 0;

if( e_river_bank ) {
line_segments.push_back( { ne, e } );
}

if( s_river_bank ) {
line_segments.push_back( { s, sw } );
}

line_segments.push_back( { s, e } );
}
Expand Down

0 comments on commit e93b4ac

Please sign in to comment.