mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2026-05-05 00:12:16 +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)
|
if (len == 0 || len > MAXPLAYERNAME)
|
||||||
return false; // Empty or too long.
|
return false; // Empty or too long.
|
||||||
if (name[0] == ' ' || name[len-1] == ' ')
|
if (name[0] == ' ')
|
||||||
return false; // Starts or ends with a space.
|
return false; // Starts with a space.
|
||||||
if (isdigit(name[0]))
|
if (isdigit(name[0]))
|
||||||
return false; // Starts with a digit.
|
return false; // Starts with a digit.
|
||||||
if (name[0] == '@' || name[0] == '~')
|
if (name[0] == '@' || name[0] == '~')
|
||||||
return false; // Starts with an admin symbol.
|
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.
|
// Check if it contains a non-printing character.
|
||||||
// Note: ANSI C isprint() considers space a printing character.
|
// Note: ANSI C isprint() considers space a printing character.
|
||||||
// Also don't allow semicolons, since they are used as
|
// Also don't allow semicolons, since they are used as
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue