Self-review: Guarantee the first character of the Challenge Hint is also uppercase, thanks to a possible prefix being "The Controls Tutorial:"

This commit is contained in:
toaster 2023-10-20 15:34:44 +01:00
parent 94cfda6832
commit d1ad45236f

View file

@ -2695,12 +2695,9 @@ char *M_BuildConditionSetString(UINT16 unlockid)
break;
}
// If we didn't find a prefix, just start from the first character again.
if (!message[i])
i = 0;
// Okay, now make the first non-whitespace character after the prefix a capital.
// Okay, now make the first non-whitespace character after this a capital.
// Doesn't matter if !isalpha() - toupper is a no-op.
// (If the first loop hit the string's end, the message[i] check keeps us safe)
for (; message[i]; i++)
{
if ((message[i] & 0x80) || isspace(message[i]))
@ -2708,6 +2705,16 @@ char *M_BuildConditionSetString(UINT16 unlockid)
message[i] = toupper(message[i]);
break;
}
// Also do this for the prefix.
// This might seem redundant, but "the Controls Tutorial:" is a possible prefix!
for (i = 0; message[i]; i++)
{
if ((message[i] & 0x80) || isspace(message[i]))
continue;
message[i] = toupper(message[i]);
break;
}
}
// Finally, do a clean wordwrap!