Fix implicit floating point cast imprecision error

This commit is contained in:
Hielke Morsink 2022-04-30 00:51:52 +02:00 committed by GitHub
parent 7471cb319f
commit ad61343a83
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 1 deletions

View File

@ -364,7 +364,8 @@ static void mapgen_place_trees()
}
// Use tree:land ratio except when near an oasis
if (static_cast<float>(util_rand()) / 0xFFFFFFFF > std::max(treeToLandRatio, oasisScore))
constexpr static auto randModulo = 0xFFFF;
if (static_cast<float>(util_rand() & randModulo) / randModulo > std::max(treeToLandRatio, oasisScore))
continue;
// Use fractal noise to group tiles that are likely to spawn trees together