diff --git a/Quake/common.c b/Quake/common.c index 47435600..3abbef0c 100644 --- a/Quake/common.c +++ b/Quake/common.c @@ -3196,7 +3196,8 @@ static inline uint32_t rotl (const uint32_t x, int k) { return (x << k) | (x >> (32 - k)); } -uint32_t COM_Rand () + +int32_t COM_Rand () { // Xorshiro64** const uint32_t s0 = xorshiro_state[0]; @@ -3205,5 +3206,6 @@ uint32_t COM_Rand () s1 ^= s0; xorshiro_state[0] = rotl (s0, 26) ^ s1 ^ (s1 << 9); xorshiro_state[1] = rotl (s1, 13); - return result & COM_RAND_MAX; + + return (int)(result & COM_RAND_MAX); } diff --git a/Quake/common.h b/Quake/common.h index d64e28d7..e911363f 100644 --- a/Quake/common.h +++ b/Quake/common.h @@ -313,8 +313,8 @@ const char *LOC_GetString (const char *key); qboolean LOC_HasPlaceholders (const char *str); size_t LOC_Format (const char *format, const char *(*getarg_fn) (int idx, void *userdata), void *userdata, char *out, size_t len); -void COM_SeedRand (uint64_t seed); -uint32_t COM_Rand (void); +void COM_SeedRand (uint64_t seed); +int32_t COM_Rand (void); // Limit to 24 bits so values fit in float mantissa & don't get negative when casting to ints #define COM_RAND_MAX 0xFFFFFF