1
0
Fork 0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-12-22 17:49:43 +01:00

Fix generateBase36 generating more than base 36

Two problems: the fRandom() range was from 0..36, but that's 37
characters, not 36. And the check to sort the lower 26 values into the
Latin alphabet used a 'lesser-than-or-equal-to 26' check, even though
that checks for the range of values of 0..26, which is 27 letters, even
though the alphabet only has 26 letters. So just drop the equals sign
from that check.
This commit is contained in:
Misa 2021-08-04 21:00:50 -07:00 committed by Ethan Lee
parent db76735c07
commit f3ca4ab2e7

View file

@ -251,8 +251,8 @@ static void generateBase36(char* string, const size_t string_size)
for (i = 0; i < string_size - 1; ++i)
{
/* a-z0-9 */
char randchar = fRandom() * 36;
if (randchar <= 26)
char randchar = fRandom() * 35;
if (randchar < 26)
{
randchar += 'a';
}