diff -r 6ed9fb9662c0 -r 966bfca56b9d src/util.c --- a/src/util.c Wed Aug 20 23:51:40 2025 +0200 +++ b/src/util.c Thu Aug 21 22:13:51 2025 +0200 @@ -28,10 +28,22 @@ #include "ascension/util.h" #include -#include -#include +#include cxmutstr asc_util_gen_name(const char *prefix) { static unsigned counter = 0; return cx_asprintf("%s_gen%u", prefix, ++counter); } + +void asc_util_seed_rand(uint64_t seed) { + SDL_srand(seed); +} + +uint32_t asc_util_rand(uint32_t n) { + if (n > INT32_MAX) { + // TODO: this probably uses quality of the generated numbers + return SDL_rand_bits() % n; + } else { + return SDL_rand((int32_t) n); + } +}