Skip to content

Commit

Permalink
Don't when forest mapgen requests groundcover from a biome with no gr…
Browse files Browse the repository at this point in the history
…oundcover.
  • Loading branch information
akrieger committed Apr 8, 2024
1 parent 8b4c779 commit 2616d77
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/mapgen_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -932,7 +932,7 @@ void mapgen_forest( mapgendata &dat )
// In order to feather (blend) this overmap tile with adjacent ones, the general composition thereof must be known.
// This can be calculated once from dat.t_nesw, and stored here:
std::array<const forest_biome *, 8> adjacent_biomes;
for( int d = 0; d < 7; d++ ) {
for( int d = 0; d <= 7; d++ ) {
auto lookup = dat.region.forest_composition.biomes.find( dat.t_nesw[d]->get_type_id() );
if( lookup != dat.region.forest_composition.biomes.end() ) {
adjacent_biomes[d] = &( lookup->second );
Expand Down Expand Up @@ -1187,7 +1187,12 @@ void mapgen_forest( mapgendata &dat )
return *dat.region.default_groundcover.pick();
default:
if( adjacent_biomes[feather_selection] != nullptr ) {
return *adjacent_biomes[feather_selection]->groundcover.pick();
auto ret = adjacent_biomes[feather_selection]->groundcover.pick();
if (ret) {
return *ret;
}
// Adjacent biome has no groundcover, use the region default.
return *dat.region.default_groundcover.pick();
} else {
return *dat.region.default_groundcover.pick();
}
Expand Down

0 comments on commit 2616d77

Please sign in to comment.