Skip to content
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

Fix lake shore mapgen corner case #70234

Merged
merged 2 commits into from
Dec 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
136 changes: 112 additions & 24 deletions src/mapgen_functions.cpp
Original file line number Diff line number Diff line change
@@ -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 } );
}
@@ -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 } );
}
@@ -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 } );
}
@@ -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 } );
}
@@ -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 } );
}
@@ -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 } );
}
@@ -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 } );
}
@@ -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 } );
}

Unchanged files with check annotations Beta

"can spawn more reliably, or add them to the whitelist above in this function "
"(inteded for terrains that sometimes spawn, but cannot be expected to spawn "
"reliably enough for this test)" );
CHECK( num_missing == 0 );

Check failure on line 416 in tests/overmap_test.cpp

GitHub Actions / Clang 12, Ubuntu, Tiles, ASan

2 == 0
}
// The second phase of this test is to perform the tile-level mapgen once