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

Function IsValidHeightmapDimension

src/heightmap.cpp:58–63  ·  view source on GitHub ↗

* Check whether the loaded dimension of the heightmap image are considered valid enough * to attempt to load the image. In other words, the width and height are not beyond the * #MAX_HEIGHTMAP_SIDE_LENGTH_IN_PIXELS limit and the total number of pixels does not * exceed #MAX_HEIGHTMAP_SIZE_PIXELS. A width or height less than 1 are disallowed too. * @param width The width of the to be loaded hei

Source from the content-addressed store, hash-verified

56 * @return True iff the dimensions are within the limits.
57 */
58static inline bool IsValidHeightmapDimension(size_t width, size_t height)
59{
60 return (uint64_t)width * height <= MAX_HEIGHTMAP_SIZE_PIXELS &&
61 width > 0 && width <= MAX_HEIGHTMAP_SIDE_LENGTH_IN_PIXELS &&
62 height > 0 && height <= MAX_HEIGHTMAP_SIDE_LENGTH_IN_PIXELS;
63}
64
65/**
66 * Convert RGB colours to Greyscale using 29.9% Red, 58.7% Green, 11.4% Blue

Callers 2

ReadHeightmapPNGFunction · 0.85
ReadHeightmapBMPFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected