From ad61343a8313ee7a35c2dd3770b33fb56a267b3f Mon Sep 17 00:00:00 2001 From: Hielke Morsink Date: Sat, 30 Apr 2022 00:51:52 +0200 Subject: [PATCH] Fix implicit floating point cast imprecision error --- src/openrct2/world/MapGen.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/openrct2/world/MapGen.cpp b/src/openrct2/world/MapGen.cpp index 3edae0d550..3640534ce8 100644 --- a/src/openrct2/world/MapGen.cpp +++ b/src/openrct2/world/MapGen.cpp @@ -364,7 +364,8 @@ static void mapgen_place_trees() } // Use tree:land ratio except when near an oasis - if (static_cast(util_rand()) / 0xFFFFFFFF > std::max(treeToLandRatio, oasisScore)) + constexpr static auto randModulo = 0xFFFF; + if (static_cast(util_rand() & randModulo) / randModulo > std::max(treeToLandRatio, oasisScore)) continue; // Use fractal noise to group tiles that are likely to spawn trees together