Use min/max instead of clamp for limiting tree count in RMG

Call to `clamp` may not guarantee correct result when `high` < `low`,
use calls to `max()` and `min()` explicitly instead.
This commit is contained in:
Michał Janiszewski 2018-01-05 23:22:46 +01:00 committed by Richard Jenkins
parent 0398c5d11e
commit 94946ce13b
1 changed files with 1 additions and 1 deletions

View File

@ -346,7 +346,7 @@ static void mapgen_place_trees()
// Place trees
float treeToLandRatio = (10 + (util_rand() % 30)) / 100.0f;
sint32 numTrees = Math::Clamp(4, (sint32) (availablePositions.size() * treeToLandRatio), (sint32)availablePositions.size());
sint32 numTrees = std::min(std::max(4, (sint32) (availablePositions.size() * treeToLandRatio)), (sint32)availablePositions.size());
for (sint32 i = 0; i < numTrees; i++)
{