From ecc48a46b1413573a977e6005a7feb008f5ec8f2 Mon Sep 17 00:00:00 2001
From: "Ryan C. Gordon" <[EMAIL REDACTED]>
Date: Tue, 29 Jul 2025 21:10:08 -0400
Subject: [PATCH] core: We have SDL_rand() now!
---
src/SDL_net.c | 14 +-------------
1 file changed, 1 insertion(+), 13 deletions(-)
diff --git a/src/SDL_net.c b/src/SDL_net.c
index c054858..c6cb735 100644
--- a/src/SDL_net.c
+++ b/src/SDL_net.c
@@ -121,22 +121,12 @@ static SDL_AtomicInt resolver_num_threads;
static SDL_AtomicInt resolver_num_requests;
static SDL_AtomicInt resolver_percent_loss;
-// I really want an SDL_random(). :(
-static int random_seed = 0;
-static int RandomNumber(void)
-{
- // this is POSIX.1-2001's potentially bad suggestion, but we're not exactly doing cryptography here.
- random_seed = random_seed * 1103515245 + 12345;
- return (int) ((unsigned int) (random_seed / 65536) % 32768);
-}
-
// between lo and hi (inclusive; it can return lo or hi itself, too!).
static int RandomNumberBetween(const int lo, const int hi)
{
- return (RandomNumber() % (hi + 1 - lo)) + lo;
+ return SDL_rand(((hi + 1) - lo)) + lo;
}
-
static int CloseSocketHandle(Socket handle)
{
#ifdef _WIN32
@@ -425,8 +415,6 @@ bool NET_Init(void)
}
}
- random_seed = (int) ((unsigned int) (SDL_GetPerformanceCounter() & 0xFFFFFFFF));
-
return true; // good to go.
failed: