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 <flokuep@users.noreply.github.com>
This commit is contained in:
McSchneidarandFlorian Ostertag authored and GitHub committed 2026-10-16 06:40:24 +02:00
1 parent df412b6d33
commit 8f916aaf65
1 file changed
+2 -2
+2 -2
View File
@@ -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);
}