mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-12-22 16:02:29 +00:00
EnsurePlayerNameIsGood: Remove trailing whitespace, instead of just failing on it
Interesting error with its recursive duplication resolving exposed by the previous commit!
This commit is contained in:
parent
a4cec98c26
commit
a161df579f
1 changed files with 11 additions and 2 deletions
|
|
@ -606,13 +606,22 @@ boolean EnsurePlayerNameIsGood(char *name, INT32 playernum)
|
|||
|
||||
if (len == 0 || len > MAXPLAYERNAME)
|
||||
return false; // Empty or too long.
|
||||
if (name[0] == ' ' || name[len-1] == ' ')
|
||||
return false; // Starts or ends with a space.
|
||||
if (name[0] == ' ')
|
||||
return false; // Starts with a space.
|
||||
if (isdigit(name[0]))
|
||||
return false; // Starts with a digit.
|
||||
if (name[0] == '@' || name[0] == '~')
|
||||
return false; // Starts with an admin symbol.
|
||||
|
||||
// Clean up trailing whitespace.
|
||||
while (len && name[len-1] == ' ')
|
||||
{
|
||||
name[len-1] = '\0';
|
||||
len--;
|
||||
}
|
||||
if (len == 0)
|
||||
return false;
|
||||
|
||||
// Check if it contains a non-printing character.
|
||||
// Note: ANSI C isprint() considers space a printing character.
|
||||
// Also don't allow semicolons, since they are used as
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue