Fixes to character name validation

Admin should be able to create any name
Also fixes to config.character_name_min_length being ignored
This commit is contained in:
slawkens
2021-01-20 18:02:07 +01:00
parent 8b41e144f8
commit 81b293a5a6
4 changed files with 32 additions and 14 deletions

View File

@@ -180,14 +180,17 @@ class Validator
return false;
}
$minLength = config('character_name_min_length');
$maxLength = config('character_name_max_length');
$length = strlen($name);
if($length < 3)
if($length < $minLength)
{
self::$lastError = 'Character name is too short. Min. length <b>3</b> characters.';
return false;
}
if($length > 25)
if($length > $maxLength)
{
self::$lastError = 'Character name is too long. Max. length <b>25</b> characters.';
return false;
@@ -201,7 +204,7 @@ class Validator
if(preg_match('/ {2,}/', $name))
{
self::$lastError = 'Invalid character name format. Use only A-Z and numbers 0-9 and no double spaces.';
self::$lastError = 'Invalid character name format. Use only A-Z and no double spaces.';
return false;
}
@@ -289,13 +292,6 @@ class Validator
}
}
$player = new OTS_Player();
$player->find($name);
if($player->isLoaded()) {
self::$lastError = 'Character with this name already exist.';
return false;
}
//check if was namelocked previously
if($db->hasTable('player_namelocks') && $db->hasColumn('player_namelocks', 'name')) {
$namelock = $db->query('SELECT `player_id` FROM `player_namelocks` WHERE `name` = ' . $db->quote($name));