M_BuildConditionSetString: Fix capitalisation rules to prevent "NO CONTEST On GREEN HILLS"

(The desired version of the string is "NO CONTEST on GREEN HILLS".)
Instead, searches for the first ':'.
- If found, goes to the first non-whitespace character afterwards and toupper's it.
- If not, goes to the first non-whitespace character at all and toupper's it.
This commit is contained in:
toaster 2023-03-16 14:05:54 +00:00
parent 412107c140
commit 7b917930d4

View file

@ -1511,13 +1511,31 @@ char *M_BuildConditionSetString(UINT8 unlockid)
}
}
// Valid sentence capitalisation handling.
{
// Finds the first : character, indicating the end of the prefix.
for (i = 0; message[i]; i++)
{
if (message[i] == toupper(message[i]))
if (message[i] != ':')
continue;
i++;
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.
// Doesn't matter if !isalpha() - toupper is a no-op.
for (; message[i]; i++)
{
if ((message[i] & 0x80) || isspace(message[i]))
continue;
message[i] = toupper(message[i]);
break;
}
}
return message;
}