We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d56ca5d commit 04d0950Copy full SHA for 04d0950
Source/engine/random.cpp
@@ -1,5 +1,7 @@
1
#include "engine/random.hpp"
2
3
+#include <limits>
4
+
5
#include "utils/stdcompat/abs.hpp"
6
7
namespace devilution {
@@ -29,7 +31,9 @@ uint32_t GetLCGEngineState()
29
31
30
32
int32_t GetRndSeed()
33
{
- return abs(static_cast<int32_t>(sglGameSeed));
34
+ const int32_t seed = static_cast<int32_t>(sglGameSeed);
35
+ // since abs(INT_MIN) is undefined behavior, handle this value specially
36
+ return seed == std::numeric_limits<int32_t>::min() ? std::numeric_limits<int32_t>::min() : abs(seed);
37
}
38
39
int32_t AdvanceRndSeed()
0 commit comments