mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2026-01-30 01:48:15 +03: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:
@@ -251,8 +251,8 @@ static void generateBase36(char* string, const size_t string_size)
|
|||||||
for (i = 0; i < string_size - 1; ++i)
|
for (i = 0; i < string_size - 1; ++i)
|
||||||
{
|
{
|
||||||
/* a-z0-9 */
|
/* a-z0-9 */
|
||||||
char randchar = fRandom() * 36;
|
char randchar = fRandom() * 35;
|
||||||
if (randchar <= 26)
|
if (randchar < 26)
|
||||||
{
|
{
|
||||||
randchar += 'a';
|
randchar += 'a';
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user