Skip to content

Commit

Permalink
Fix rng going out of bounds and simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
AaronVanGeffen committed May 20, 2024
1 parent e40a167 commit 6e3d890
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/openrct2-ui/windows/ProgressWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,10 @@ namespace OpenRCT2::Ui::Windows
else
{
// 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)));
std::default_random_engine e(r());
style = static_cast<int8_t>(uniform_dist(e));
std::random_device rd;
std::mt19937 gen(rd());
std::uniform_int_distribution<int8_t> dist(0, std::size(kVehicleStyles) - 1);

Check warning on line 142 in src/openrct2-ui/windows/ProgressWindow.cpp

View workflow job for this annotation

GitHub Actions / Windows (win32)

'argument': conversion from 'size_t' to '_Ty', possible loss of data [D:\a\OpenRCT2\OpenRCT2\src\openrct2-ui\libopenrct2ui.vcxproj]

Check warning on line 142 in src/openrct2-ui/windows/ProgressWindow.cpp

View workflow job for this annotation

GitHub Actions / Windows (win32)

with [D:\a\OpenRCT2\OpenRCT2\src\openrct2-ui\libopenrct2ui.vcxproj]

Check warning on line 142 in src/openrct2-ui/windows/ProgressWindow.cpp

View workflow job for this annotation

GitHub Actions / Windows (win32)

[ [D:\a\OpenRCT2\OpenRCT2\src\openrct2-ui\libopenrct2ui.vcxproj]

Check warning on line 142 in src/openrct2-ui/windows/ProgressWindow.cpp

View workflow job for this annotation

GitHub Actions / Windows (win32)

_Ty=int8_t [D:\a\OpenRCT2\OpenRCT2\src\openrct2-ui\libopenrct2ui.vcxproj]

Check warning on line 142 in src/openrct2-ui/windows/ProgressWindow.cpp

View workflow job for this annotation

GitHub Actions / Windows (win32)

] [D:\a\OpenRCT2\OpenRCT2\src\openrct2-ui\libopenrct2ui.vcxproj]

Check warning on line 142 in src/openrct2-ui/windows/ProgressWindow.cpp

View workflow job for this annotation

GitHub Actions / Windows (win32)

with [D:\a\OpenRCT2\OpenRCT2\src\openrct2-ui\libopenrct2ui.vcxproj]

Check warning on line 142 in src/openrct2-ui/windows/ProgressWindow.cpp

View workflow job for this annotation

GitHub Actions / Windows (win32)

[ [D:\a\OpenRCT2\OpenRCT2\src\openrct2-ui\libopenrct2ui.vcxproj]

Check warning on line 142 in src/openrct2-ui/windows/ProgressWindow.cpp

View workflow job for this annotation

GitHub Actions / Windows (win32)

_Ty=int8_t [D:\a\OpenRCT2\OpenRCT2\src\openrct2-ui\libopenrct2ui.vcxproj]

Check warning on line 142 in src/openrct2-ui/windows/ProgressWindow.cpp

View workflow job for this annotation

GitHub Actions / Windows (win32)

] [D:\a\OpenRCT2\OpenRCT2\src\openrct2-ui\libopenrct2ui.vcxproj]

Check warning on line 142 in src/openrct2-ui/windows/ProgressWindow.cpp

View workflow job for this annotation

GitHub Actions / Windows (x64)

'argument': conversion from 'size_t' to '_Ty', possible loss of data [D:\a\OpenRCT2\OpenRCT2\src\openrct2-ui\libopenrct2ui.vcxproj]

Check warning on line 142 in src/openrct2-ui/windows/ProgressWindow.cpp

View workflow job for this annotation

GitHub Actions / Windows (x64)

with [D:\a\OpenRCT2\OpenRCT2\src\openrct2-ui\libopenrct2ui.vcxproj]

Check warning on line 142 in src/openrct2-ui/windows/ProgressWindow.cpp

View workflow job for this annotation

GitHub Actions / Windows (x64)

[ [D:\a\OpenRCT2\OpenRCT2\src\openrct2-ui\libopenrct2ui.vcxproj]

Check warning on line 142 in src/openrct2-ui/windows/ProgressWindow.cpp

View workflow job for this annotation

GitHub Actions / Windows (x64)

_Ty=int8_t [D:\a\OpenRCT2\OpenRCT2\src\openrct2-ui\libopenrct2ui.vcxproj]

Check warning on line 142 in src/openrct2-ui/windows/ProgressWindow.cpp

View workflow job for this annotation

GitHub Actions / Windows (x64)

] [D:\a\OpenRCT2\OpenRCT2\src\openrct2-ui\libopenrct2ui.vcxproj]

Check warning on line 142 in src/openrct2-ui/windows/ProgressWindow.cpp

View workflow job for this annotation

GitHub Actions / Windows (x64)

with [D:\a\OpenRCT2\OpenRCT2\src\openrct2-ui\libopenrct2ui.vcxproj]

Check warning on line 142 in src/openrct2-ui/windows/ProgressWindow.cpp

View workflow job for this annotation

GitHub Actions / Windows (x64)

[ [D:\a\OpenRCT2\OpenRCT2\src\openrct2-ui\libopenrct2ui.vcxproj]

Check warning on line 142 in src/openrct2-ui/windows/ProgressWindow.cpp

View workflow job for this annotation

GitHub Actions / Windows (x64)

_Ty=int8_t [D:\a\OpenRCT2\OpenRCT2\src\openrct2-ui\libopenrct2ui.vcxproj]

Check warning on line 142 in src/openrct2-ui/windows/ProgressWindow.cpp

View workflow job for this annotation

GitHub Actions / Windows (x64)

] [D:\a\OpenRCT2\OpenRCT2\src\openrct2-ui\libopenrct2ui.vcxproj]

Check warning on line 142 in src/openrct2-ui/windows/ProgressWindow.cpp

View workflow job for this annotation

GitHub Actions / Windows (arm64)

'argument': conversion from 'size_t' to '_Ty', possible loss of data [D:\a\OpenRCT2\OpenRCT2\src\openrct2-ui\libopenrct2ui.vcxproj]

Check warning on line 142 in src/openrct2-ui/windows/ProgressWindow.cpp

View workflow job for this annotation

GitHub Actions / Windows (arm64)

with [D:\a\OpenRCT2\OpenRCT2\src\openrct2-ui\libopenrct2ui.vcxproj]

Check warning on line 142 in src/openrct2-ui/windows/ProgressWindow.cpp

View workflow job for this annotation

GitHub Actions / Windows (arm64)

[ [D:\a\OpenRCT2\OpenRCT2\src\openrct2-ui\libopenrct2ui.vcxproj]

Check warning on line 142 in src/openrct2-ui/windows/ProgressWindow.cpp

View workflow job for this annotation

GitHub Actions / Windows (arm64)

_Ty=int8_t [D:\a\OpenRCT2\OpenRCT2\src\openrct2-ui\libopenrct2ui.vcxproj]

Check warning on line 142 in src/openrct2-ui/windows/ProgressWindow.cpp

View workflow job for this annotation

GitHub Actions / Windows (arm64)

] [D:\a\OpenRCT2\OpenRCT2\src\openrct2-ui\libopenrct2ui.vcxproj]

Check warning on line 142 in src/openrct2-ui/windows/ProgressWindow.cpp

View workflow job for this annotation

GitHub Actions / Windows (arm64)

with [D:\a\OpenRCT2\OpenRCT2\src\openrct2-ui\libopenrct2ui.vcxproj]

Check warning on line 142 in src/openrct2-ui/windows/ProgressWindow.cpp

View workflow job for this annotation

GitHub Actions / Windows (arm64)

[ [D:\a\OpenRCT2\OpenRCT2\src\openrct2-ui\libopenrct2ui.vcxproj]

Check warning on line 142 in src/openrct2-ui/windows/ProgressWindow.cpp

View workflow job for this annotation

GitHub Actions / Windows (arm64)

_Ty=int8_t [D:\a\OpenRCT2\OpenRCT2\src\openrct2-ui\libopenrct2ui.vcxproj]

Check warning on line 142 in src/openrct2-ui/windows/ProgressWindow.cpp

View workflow job for this annotation

GitHub Actions / Windows (arm64)

] [D:\a\OpenRCT2\OpenRCT2\src\openrct2-ui\libopenrct2ui.vcxproj]
style = dist(gen);
}
}

Expand Down

0 comments on commit 6e3d890

Please sign in to comment.