From 8f916aaf653b2b4ed9062fd3f5b6ccfb8792ccad Mon Sep 17 00:00:00 2001 From: McSchneidar <262792195+McSchneidar@users.noreply.github.com> Date: Fri, 16 Oct 2026 06:40:24 +0200 Subject: [PATCH] Allow the last entry to be picked in random song/category selection (#903) Random.Next(min, max) excludes max, so Next(0, Count - 1) never returned the last index. The last song or category in the list was only picked once it was the only one left, so it always came last. Use Next(0, Count) instead. Co-authored-by: Florian Ostertag --- Vocaluxe/Base/CSongs.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Vocaluxe/Base/CSongs.cs b/Vocaluxe/Base/CSongs.cs index 42f0b4c0..dbf91b2a 100644 --- a/Vocaluxe/Base/CSongs.cs +++ b/Vocaluxe/Base/CSongs.cs @@ -247,7 +247,7 @@ namespace Vocaluxe.Base return -1; } - var song = _SongsForRandom[CGame.Rand.Next(0, _SongsForRandom.Count - 1)]; + var song = _SongsForRandom[CGame.Rand.Next(0, _SongsForRandom.Count)]; _SongsForRandom.Remove(song); return GetVisibleSongNumber(song.Id); } @@ -291,7 +291,7 @@ namespace Vocaluxe.Base return -1; } - var category = _CategoriesForRandom[CGame.Rand.Next(0, _CategoriesForRandom.Count - 1)]; + var category = _CategoriesForRandom[CGame.Rand.Next(0, _CategoriesForRandom.Count)]; _CategoriesForRandom.Remove(category); return _GetCategoryNumber(category); }