Skip to content

Commit

Permalink
Fix rng going out of bounds
Browse files Browse the repository at this point in the history
  • Loading branch information
AaronVanGeffen committed May 21, 2024
1 parent e40a167 commit 6bc6322
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/openrct2-ui/windows/ProgressWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ namespace OpenRCT2::Ui::Windows
{
// Pick a random style to start off with
std::random_device r;
std::uniform_int_distribution<int> uniform_dist(0, static_cast<int8_t>(std::size(kVehicleStyles)));
auto upperBound = static_cast<int8_t>(std::size(kVehicleStyles)) - 1;
std::uniform_int_distribution<int> uniform_dist(0, upperBound);
std::default_random_engine e(r());
style = static_cast<int8_t>(uniform_dist(e));
}
Expand Down

0 comments on commit 6bc6322

Please sign in to comment.