MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / LoadHeightmap

Function LoadHeightmap

src/heightmap.cpp:517–536  ·  view source on GitHub ↗

* Load a heightmap from file and change the map in its current dimensions * to a landscape representing the heightmap. * It converts pixels to height. The brighter, the higher. * @param dft Type of image file. * @param filename of the heightmap file to be imported */

Source from the content-addressed store, hash-verified

515 * @param filename of the heightmap file to be imported
516 */
517bool LoadHeightmap(DetailedFileType dft, std::string_view filename)
518{
519 uint x, y;
520 std::vector<uint8_t> map;
521
522 if (!ReadHeightMap(dft, filename, &x, &y, &map)) {
523 return false;
524 }
525
526 GreyscaleToMapHeights(x, y, map);
527
528 FixSlopes();
529
530 /* If all map borders are water, we will draw infinite water. */
531 _settings_game.construction.freeform_edges = !IsMapSurroundedByWater();
532
533 MarkWholeScreenDirty();
534
535 return true;
536}
537
538/**
539 * Make an empty world where all tiles are of height 'tile_height'.

Callers 1

GenerateLandscapeFunction · 0.85

Calls 5

ReadHeightMapFunction · 0.85
GreyscaleToMapHeightsFunction · 0.85
FixSlopesFunction · 0.85
IsMapSurroundedByWaterFunction · 0.85
MarkWholeScreenDirtyFunction · 0.85

Tested by

no test coverage detected