From aad175548a1777d41ff43e6efe7fb69bc655a179 Mon Sep 17 00:00:00 2001 From: slawkens Date: Sat, 22 Jul 2023 10:57:42 +0200 Subject: [PATCH] create character name config moved to settings --- system/config.php | 6 ----- system/libs/CreateCharacter.php | 4 ++-- system/libs/validator.php | 8 +++---- system/pages/account/change_name.php | 4 ++-- system/settings.php | 24 ++++++++++++++++--- system/templates/account.create.html.twig | 2 +- .../account.create_character.html.twig | 4 ++-- 7 files changed, 32 insertions(+), 20 deletions(-) diff --git a/system/config.php b/system/config.php index 9186dfeb..92b7c678 100644 --- a/system/config.php +++ b/system/config.php @@ -48,12 +48,6 @@ $config = array( // won't be displayed if there is only one item (rookgaard for example) 'character_towns' => array(1), - // characters length - // 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) // otherwise it will try to load from your .OTBM map file diff --git a/system/libs/CreateCharacter.php b/system/libs/CreateCharacter.php index eb3b0c11..24edfb5f 100644 --- a/system/libs/CreateCharacter.php +++ b/system/libs/CreateCharacter.php @@ -18,8 +18,8 @@ class CreateCharacter */ public function checkName($name, &$errors) { - $minLength = config('character_name_min_length'); - $maxLength = config('character_name_max_length'); + $minLength = setting('core.create_character_name_min_length'); + $maxLength = setting('core.create_character_name_max_length'); if(empty($name)) { $errors['name'] = 'Please enter a name for your character!'; diff --git a/system/libs/validator.php b/system/libs/validator.php index e90d5b71..ed416ebd 100644 --- a/system/libs/validator.php +++ b/system/libs/validator.php @@ -180,8 +180,8 @@ class Validator return false; } - $minLength = config('character_name_min_length'); - $maxLength = config('character_name_max_length'); + $minLength = setting('core.create_character_name_min_length'); + $maxLength = setting('core.create_character_name_max_length'); // installer doesn't know config.php yet // that's why we need to ignore the nulls @@ -221,7 +221,7 @@ class Validator return false; } - $npcCheck = config('character_name_npc_check'); + $npcCheck = setting('core.create_character_name_npc_check'); if ($npcCheck) { require_once LIBS . 'npc.php'; NPCS::load(); @@ -332,7 +332,7 @@ class Validator return false; } - $npcCheck = config('character_name_npc_check'); + $npcCheck = setting('core.create_character_name_npc_check'); if ($npcCheck) { require_once LIBS . 'npc.php'; NPCS::load(); diff --git a/system/pages/account/change_name.php b/system/pages/account/change_name.php index 48b6bb4d..f6053733 100644 --- a/system/pages/account/change_name.php +++ b/system/pages/account/change_name.php @@ -28,8 +28,8 @@ else if($points < $config['account_change_character_name_points']) $errors[] = 'You need ' . $config['account_change_character_name_points'] . ' premium points to change name. You have '.$points.' premium points.'; - $minLength = config('character_name_min_length'); - $maxLength = config('character_name_max_length'); + $minLength = setting('core.create_character_name_min_length'); + $maxLength = setting('core.create_character_name_max_length'); if(empty($errors) && empty($name)) $errors[] = 'Please enter a new name for your character!'; diff --git a/system/settings.php b/system/settings.php index 6208fd76..95e15003 100644 --- a/system/settings.php +++ b/system/settings.php @@ -620,8 +620,26 @@ Sent by MyAAC,
'type' => 'section', 'title' => 'Create Character', ], + 'create_character_name_npc_check' => [ + 'name' => 'Create Character Name Check NPC Names', + 'type' => 'boolean', + 'desc' => 'should country of user be automatically recognized by his IP? This makes an external API call to http://ipinfo.io', + 'default' => true, + ], + 'create_character_name_min_length' => [ + 'name' => 'Name Min Length', + 'type' => 'number', + 'desc' => '', + 'default' => 4, + ], + 'create_character_name_max_length' => [ + 'name' => 'Name Max Length', + 'type' => 'number', + 'desc' => 'It is highly recommend the maximum length to be 21', + 'default' => 21, + ], 'create_character_name_blocked_prefix' => [ - 'name' => 'Create Character Blocked Prefix', + 'name' => 'Create Character Name Blocked Prefix', 'type' => 'textarea', 'desc' => 'Space after is important!', 'default' => 'admin ,administrator ,gm ,cm ,god ,tutor', @@ -632,7 +650,7 @@ Sent by MyAAC,
], ], 'create_character_name_blocked_names' => [ - 'name' => 'Create Character Blocked Names', + 'name' => 'Create Character Name Blocked Names', 'type' => 'textarea', 'desc' => 'Separated by comma (,)', 'default' => 'admin,administrator,gm,cm,god,tutor', @@ -643,7 +661,7 @@ Sent by MyAAC,
], ], 'create_character_name_blocked_words' => [ - 'name' => 'Create Character Blocked Words', + 'name' => 'Create Character Name Blocked Words', 'type' => 'textarea', 'desc' => 'Separated by comma (,)', 'default' => "admin,administrator,gamemaster,game master,game-master,game'master,fuck,sux,suck,noob,tutor", diff --git a/system/templates/account.create.html.twig b/system/templates/account.create.html.twig index 1d46db70..3274178c 100644 --- a/system/templates/account.create.html.twig +++ b/system/templates/account.create.html.twig @@ -140,7 +140,7 @@ Character Name: - +
diff --git a/system/templates/account.create_character.html.twig b/system/templates/account.create_character.html.twig index 045c749c..afe4e9da 100644 --- a/system/templates/account.create_character.html.twig +++ b/system/templates/account.create_character.html.twig @@ -45,7 +45,7 @@ In any case the name must not violate the naming conventions stated in the - +
@@ -145,4 +145,4 @@ In any case the name must not violate the naming conventions stated in the
- \ No newline at end of file +