From 53549bfa2d3a87762752d29b471197866c4a35b8 Mon Sep 17 00:00:00 2001 From: toaster Date: Wed, 23 Aug 2023 17:08:06 +0100 Subject: [PATCH] M_Shuffle_UINT16: Fix to not rule out half of all possible Spray Can orders --- src/m_cond.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/m_cond.c b/src/m_cond.c index 31b852c24..9335999ff 100644 --- a/src/m_cond.c +++ b/src/m_cond.c @@ -661,9 +661,14 @@ static void M_Shuffle_UINT16(UINT16 *list, size_t len) { size_t i; UINT16 temp; - while (--len > 1) // no need to swap on == + + while (len > 1) { i = M_RandomKey(len); + + if (i == --len) + continue; + temp = list[i]; list[i] = list[len]; list[len] = temp;