update validator name check

-added character_name_npc_check to config.php
-added npc name check to validator
This commit is contained in:
Lee 2021-03-09 23:42:21 +00:00
parent 31f0050f4e
commit 9d8f398d9f
2 changed files with 21 additions and 0 deletions

View File

@ -171,6 +171,7 @@ $config = array(
// This is the minimum and the maximum length that a player can create a character. It is highly recommend the maximum length to be 21.
'character_name_min_length' => 4,
'character_name_max_length' => 21,
'character_name_npc_check' => true,
// list of towns
// if you use TFS 1.3 with support for 'towns' table in database, then you can ignore this - it will be configured automatically (from MySQL database - Table - towns)

View File

@ -221,6 +221,16 @@ class Validator
return false;
}
$npcCheck = config('character_name_npc_check');
if ($npcCheck) {
require LIBS . 'npc.php';
NPCS::load();
if(NPCS::$npcs && in_array(strtolower($name), NPCS::$npcs)) {
self::$lastError = "Invalid name format. Do not use NPC Names";
return false;
}
}
return true;
}
@ -334,6 +344,16 @@ class Validator
}
}
$npcCheck = config('character_name_npc_check');
if ($npcCheck) {
require LIBS . 'npc.php';
NPCS::load();
if(NPCS::$npcs && in_array($name_lower, NPCS::$npcs)) {
self::$lastError = "Invalid name format. Do not use NPC Names";
return false;
}
}
if(strspn($name, "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM- '") != $name_length) {
self::$lastError = 'This name contains invalid letters, words or format. Please use only a-Z, - , \' and space.';
return false;