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: Remove some redundant steps during world generation #7880

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/genworld.cpp
Expand Up @@ -127,7 +127,9 @@ static void _GenerateWorld()
/* Make the map the height of the setting */
if (_game_mode != GM_MENU) FlatEmptyWorld(_settings_game.game_creation.se_flat_world_height);

ConvertGroundTilesIntoWaterTiles();
if (!_settings_game.construction.freeform_edges || _settings_game.game_creation.se_flat_world_height == 0) {
ConvertGroundTilesIntoWaterTiles();
}
IncreaseGeneratingWorldProgress(GWP_OBJECT);
} else {
GenerateLandscape(_gw.mode);
Expand Down
6 changes: 1 addition & 5 deletions src/heightmap.cpp
Expand Up @@ -498,9 +498,6 @@ void LoadHeightmap(DetailedFileType dft, const char *filename)

GrayscaleToMapHeights(x, y, map);
free(map);

FixSlopes();
MarkWholeScreenDirty();
}

/**
Expand All @@ -516,6 +513,5 @@ void FlatEmptyWorld(byte tile_height)
}
}

FixSlopes();
MarkWholeScreenDirty();
if (edge_distance != 0 && tile_height > 1) FixSlopes();
}
15 changes: 8 additions & 7 deletions src/landscape.cpp
Expand Up @@ -1294,8 +1294,8 @@ void GenerateLandscape(byte mode)
{
/** Number of steps of landscape generation */
enum GenLandscapeSteps {
GLS_HEIGHTMAP = 3, ///< Loading a heightmap
GLS_TERRAGENESIS = 5, ///< Terragenesis generator
GLS_HEIGHTMAP = 2, ///< Loading a heightmap
GLS_TERRAGENESIS = 4, ///< Terragenesis generator
GLS_ORIGINAL = 2, ///< Original generator
GLS_TROPIC = 12, ///< Extra steps needed for tropic landscape
GLS_OTHER = 0, ///< Extra steps for other landscapes
Expand All @@ -1305,7 +1305,6 @@ void GenerateLandscape(byte mode)
if (mode == GWM_HEIGHTMAP) {
SetGeneratingWorldProgress(GWP_LANDSCAPE, steps + GLS_HEIGHTMAP);
LoadHeightmap(_file_to_saveload.detail_ftype, _file_to_saveload.name);
IncreaseGeneratingWorldProgress(GWP_LANDSCAPE);
} else if (_settings_game.game_creation.land_generator == LG_TERRAGENESIS) {
SetGeneratingWorldProgress(GWP_LANDSCAPE, steps + GLS_TERRAGENESIS);
GenerateTerrainPerlin();
Expand Down Expand Up @@ -1364,10 +1363,12 @@ void GenerateLandscape(byte mode)
}
}

/* Do not call IncreaseGeneratingWorldProgress() before FixSlopes(),
* it allows screen redraw. Drawing of broken slopes crashes the game */
FixSlopes();
IncreaseGeneratingWorldProgress(GWP_LANDSCAPE);
if (mode == GWM_HEIGHTMAP || _settings_game.game_creation.land_generator == LG_ORIGINAL) {
/* Do not call IncreaseGeneratingWorldProgress() before FixSlopes(),
* it allows screen redraw. Drawing of broken slopes crashes the game */
FixSlopes();
IncreaseGeneratingWorldProgress(GWP_LANDSCAPE);
}
ConvertGroundTilesIntoWaterTiles();
IncreaseGeneratingWorldProgress(GWP_LANDSCAPE);

Expand Down