From 07f401baa275a0fd554809e8a62f3c959ef01095 Mon Sep 17 00:00:00 2001 From: Matt Date: Wed, 16 Oct 2019 12:45:00 +0200 Subject: [PATCH] Use unsigned type for scenario_rand results --- src/openrct2/scenario/Scenario.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/openrct2/scenario/Scenario.cpp b/src/openrct2/scenario/Scenario.cpp index 96421f4d3e..0ed0a77aa7 100644 --- a/src/openrct2/scenario/Scenario.cpp +++ b/src/openrct2/scenario/Scenario.cpp @@ -469,12 +469,12 @@ bool scenario_create_ducks() centrePos.x += 16; centrePos.y += 16; - int32_t duckCount = (scenario_rand() & 3) + 2; - for (int32_t i = 0; i < duckCount; i++) + uint32_t duckCount = (scenario_rand() % 4) + 2; + for (uint32_t i = 0; i < duckCount; i++) { - int32_t r = scenario_rand(); - innerPos.x = (r >> 16) & (SquareRadiusSize - 1); - innerPos.y = (r & 0xFFFF) & (SquareRadiusSize - 1); + uint32_t r = scenario_rand(); + innerPos.x = (r >> 16) % SquareRadiusSize; + innerPos.y = (r & 0xFFFF) % SquareRadiusSize; CoordsXY targetPos{ centrePos.x + innerPos.x - SquareRadiusSize, centrePos.y + innerPos.y - SquareRadiusSize };