Code: Select all
function bool AdjustPlayerName(string CurrentName, out string NewName) {
/*******************************************************************************
Returns all "bad" characters in *CurrentName* replaced with "_" in *NewName*.
If at least one bad character was found, TRUE is returned.
*******************************************************************************/
local int i, CharCode;
logger(LOG_Debug, "AdjustPlayerName", "CurrentName='" $ CurrentName $ "', Len(CurrentName)=" $ len(CurrentName));
NewName = "";
for (i = 0; i < len(CurrentName); i++)
{
CharCode = asc(mid(CurrentName, i, 1));
logger(LOG_Debug, "AdjustPlayerName", mid(CurrentName, i, 1) $ "=" $ CharCode);
if (class'SharedCode'.static.CharIsWhite(CharCode) || CharCode > 255)
NewName = NewName $ "_";
else
NewName = NewName $ Chr(CharCode);
}
if (CurrentName == NewName)
{
logger(LOG_All, "AdjustPlayerName", "'" $ CurrentName $ "' has no bad chars, keeping this name");
return false;
}
else
{
logger(LOG_Debug, "AdjustPlayerName", "changed" @ CurrentName @ "to '" $ NewName $ "'");
return true;
}
}
static function bool CharIsWhite
Code: Select all
static function bool CharIsWhite(int charcode) {
/******************************************************************************
Returns TRUE if the char with *charcode* is a white char (= no ink is used if
printed).
******************************************************************************/
switch (charcode) {
case 9: // tab
return true;
case 10: // LF
return true;
case 11: // vTab
return true;
case 12: // FF
return true;
case 13: // CR
return true;
case 32: // Space
return true;
case 0xAD: // soft hyphen
return true;
}
if (charcode <= 255)
return false;
// what about unicode?
return false;
}
The log file wrote:Level server received: JOIN
Join request: MH-GreatescapeV0?Name=??Class=BotPack.TFemale1?Team=255?skin=FCommandoSkins_Negaverse_Titus.ttus?Face=FCommandoSkins_Negaverse_Titus.titus?Voice=BotPack.VoiceFemaleTwo?Override
Team 255
Login: ?
2023-06-16 01:18:19 MH-GreatescapeV0.MonsterHuntSB0.AdjustPlayerName LOG_Debug: CurrentName='?', Len(CurrentName)=1
2023-06-16 01:18:19 MH-GreatescapeV0.MonsterHuntSB0.AdjustPlayerName LOG_Debug: ?=144