summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatric Stout <truebrain@openttd.org>2021-03-25 23:51:37 +0100
committerPatric Stout <github@truebrain.nl>2021-03-26 12:22:32 +0100
commitd0ed656fd117d69410fa4691f80f8ceeb3d90496 (patch)
treef07e1a133274eb65e579601ae0e504e3c4d7cc55
parent13a52644381b5b4f2f7122d81fee9fb95cc5337a (diff)
downloadopenttd-d0ed656fd117d69410fa4691f80f8ceeb3d90496.tar.xz
Change: scale heightmaps we export to highest peak and inform the user of this value
Before this commit, it scaled to map-height-limit. Recently this could also be set to "auto", meaning players don't really know or care about this value. This also means that if a player exported a heightmap and wanted to import it again, looking like the exact same map, he did not know what value for "highest peak" to use.
-rw-r--r--src/lang/english.txt1
-rw-r--r--src/screenshot.cpp20
2 files changed, 18 insertions, 3 deletions
diff --git a/src/lang/english.txt b/src/lang/english.txt
index 2554a5a17..9f43788e5 100644
--- a/src/lang/english.txt
+++ b/src/lang/english.txt
@@ -4358,6 +4358,7 @@ STR_WARNING_FALLBACK_SOUNDSET :{WHITE}Only a f
STR_WARNING_SCREENSHOT_SIZE_CAPTION :{WHITE}Huge screenshot
STR_WARNING_SCREENSHOT_SIZE_MESSAGE :{YELLOW}The screenshot will have a resolution of {COMMA} x {COMMA} pixels. Taking the screenshot may take a while. Do you want to continue?
+STR_MESSAGE_HEIGHTMAP_SUCCESSFULLY :{WHITE}Heightmap successfully saved as '{RAW_STRING}'. Highest peak is {NUM}
STR_MESSAGE_SCREENSHOT_SUCCESSFULLY :{WHITE}Screenshot successfully saved as '{RAW_STRING}'
STR_ERROR_SCREENSHOT_FAILED :{WHITE}Screenshot failed!
diff --git a/src/screenshot.cpp b/src/screenshot.cpp
index 12047f4ad..06fae707a 100644
--- a/src/screenshot.cpp
+++ b/src/screenshot.cpp
@@ -39,6 +39,7 @@ uint _num_screenshot_formats; ///< Number of available screenshot format
uint _cur_screenshot_format; ///< Index of the currently selected screenshot format in #_screenshot_formats.
static char _screenshot_name[128]; ///< Filename of the screenshot file.
char _full_screenshot_name[MAX_PATH]; ///< Pathname of the screenshot file.
+uint _heightmap_highest_peak; ///< When saving a heightmap, this contains the highest peak on the map.
/**
* Callback function signature for generating lines of pixel data to be written to the screenshot file.
@@ -820,7 +821,7 @@ static void HeightmapCallback(void *userdata, void *buffer, uint y, uint pitch,
while (n > 0) {
TileIndex ti = TileXY(MapMaxX(), y);
for (uint x = MapMaxX(); true; x--) {
- *buf = 256 * TileHeight(ti) / (1 + _settings_game.construction.map_height_limit);
+ *buf = 256 * TileHeight(ti) / (1 + _heightmap_highest_peak);
buf++;
if (x == 0) break;
ti = TILE_ADDXY(ti, -1, 0);
@@ -843,6 +844,13 @@ bool MakeHeightmapScreenshot(const char *filename)
palette[i].g = i;
palette[i].b = i;
}
+
+ _heightmap_highest_peak = 0;
+ for (TileIndex tile = 0; tile < MapSize(); tile++) {
+ uint h = TileHeight(tile);
+ _heightmap_highest_peak = std::max(h, _heightmap_highest_peak);
+ }
+
const ScreenshotFormat *sf = _screenshot_formats + _cur_screenshot_format;
return sf->proc(filename, HeightmapCallback, nullptr, MapSizeX(), MapSizeY(), 8, palette);
}
@@ -946,8 +954,14 @@ bool MakeScreenshot(ScreenshotType t, const char *name, uint32 width, uint32 hei
}
if (ret) {
- SetDParamStr(0, _screenshot_name);
- ShowErrorMessage(STR_MESSAGE_SCREENSHOT_SUCCESSFULLY, INVALID_STRING_ID, WL_WARNING);
+ if (t == SC_HEIGHTMAP) {
+ SetDParamStr(0, _screenshot_name);
+ SetDParam(1, _heightmap_highest_peak);
+ ShowErrorMessage(STR_MESSAGE_HEIGHTMAP_SUCCESSFULLY, INVALID_STRING_ID, WL_CRITICAL);
+ } else {
+ SetDParamStr(0, _screenshot_name);
+ ShowErrorMessage(STR_MESSAGE_SCREENSHOT_SUCCESSFULLY, INVALID_STRING_ID, WL_WARNING);
+ }
} else {
ShowErrorMessage(STR_ERROR_SCREENSHOT_FAILED, INVALID_STRING_ID, WL_ERROR);
}