create character name config moved to settings

This commit is contained in:
slawkens 2023-07-22 10:57:42 +02:00
parent d82e3a21e5
commit aad175548a
7 changed files with 32 additions and 20 deletions

View File

@ -48,12 +48,6 @@ $config = array(
// won't be displayed if there is only one item (rookgaard for example) // won't be displayed if there is only one item (rookgaard for example)
'character_towns' => array(1), '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 // 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) // 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 // otherwise it will try to load from your .OTBM map file

View File

@ -18,8 +18,8 @@ class CreateCharacter
*/ */
public function checkName($name, &$errors) public function checkName($name, &$errors)
{ {
$minLength = config('character_name_min_length'); $minLength = setting('core.create_character_name_min_length');
$maxLength = config('character_name_max_length'); $maxLength = setting('core.create_character_name_max_length');
if(empty($name)) { if(empty($name)) {
$errors['name'] = 'Please enter a name for your character!'; $errors['name'] = 'Please enter a name for your character!';

View File

@ -180,8 +180,8 @@ class Validator
return false; return false;
} }
$minLength = config('character_name_min_length'); $minLength = setting('core.create_character_name_min_length');
$maxLength = config('character_name_max_length'); $maxLength = setting('core.create_character_name_max_length');
// installer doesn't know config.php yet // installer doesn't know config.php yet
// that's why we need to ignore the nulls // that's why we need to ignore the nulls
@ -221,7 +221,7 @@ class Validator
return false; return false;
} }
$npcCheck = config('character_name_npc_check'); $npcCheck = setting('core.create_character_name_npc_check');
if ($npcCheck) { if ($npcCheck) {
require_once LIBS . 'npc.php'; require_once LIBS . 'npc.php';
NPCS::load(); NPCS::load();
@ -332,7 +332,7 @@ class Validator
return false; return false;
} }
$npcCheck = config('character_name_npc_check'); $npcCheck = setting('core.create_character_name_npc_check');
if ($npcCheck) { if ($npcCheck) {
require_once LIBS . 'npc.php'; require_once LIBS . 'npc.php';
NPCS::load(); NPCS::load();

View File

@ -28,8 +28,8 @@ else
if($points < $config['account_change_character_name_points']) if($points < $config['account_change_character_name_points'])
$errors[] = 'You need ' . $config['account_change_character_name_points'] . ' premium points to change name. You have <b>'.$points.'<b> premium points.'; $errors[] = 'You need ' . $config['account_change_character_name_points'] . ' premium points to change name. You have <b>'.$points.'<b> premium points.';
$minLength = config('character_name_min_length'); $minLength = setting('core.create_character_name_min_length');
$maxLength = config('character_name_max_length'); $maxLength = setting('core.create_character_name_max_length');
if(empty($errors) && empty($name)) if(empty($errors) && empty($name))
$errors[] = 'Please enter a new name for your character!'; $errors[] = 'Please enter a new name for your character!';

View File

@ -620,8 +620,26 @@ Sent by MyAAC,<br/>
'type' => 'section', 'type' => 'section',
'title' => 'Create Character', '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' => [ 'create_character_name_blocked_prefix' => [
'name' => 'Create Character Blocked Prefix', 'name' => 'Create Character Name Blocked Prefix',
'type' => 'textarea', 'type' => 'textarea',
'desc' => 'Space after is important!', 'desc' => 'Space after is important!',
'default' => 'admin ,administrator ,gm ,cm ,god ,tutor', 'default' => 'admin ,administrator ,gm ,cm ,god ,tutor',
@ -632,7 +650,7 @@ Sent by MyAAC,<br/>
], ],
], ],
'create_character_name_blocked_names' => [ 'create_character_name_blocked_names' => [
'name' => 'Create Character Blocked Names', 'name' => 'Create Character Name Blocked Names',
'type' => 'textarea', 'type' => 'textarea',
'desc' => 'Separated by comma (,)', 'desc' => 'Separated by comma (,)',
'default' => 'admin,administrator,gm,cm,god,tutor', 'default' => 'admin,administrator,gm,cm,god,tutor',
@ -643,7 +661,7 @@ Sent by MyAAC,<br/>
], ],
], ],
'create_character_name_blocked_words' => [ 'create_character_name_blocked_words' => [
'name' => 'Create Character Blocked Words', 'name' => 'Create Character Name Blocked Words',
'type' => 'textarea', 'type' => 'textarea',
'desc' => 'Separated by comma (,)', 'desc' => 'Separated by comma (,)',
'default' => "admin,administrator,gamemaster,game master,game-master,game'master,fuck,sux,suck,noob,tutor", 'default' => "admin,administrator,gamemaster,game master,game-master,game'master,fuck,sux,suck,noob,tutor",

View File

@ -140,7 +140,7 @@
<span{% if errors.name is defined %} class="red"{% endif %}>Character Name:</span> <span{% if errors.name is defined %} class="red"{% endif %}>Character Name:</span>
</td> </td>
<td> <td>
<input id="character_name" name="name" size="{{ config.character_name_max_length }}" maxlength="{{ config.character_name_max_length }}" value="{{ name }}"/> <input id="character_name" name="name" size="{{ setting('create_character_name_max_length') }}" maxlength="{{ setting('create_character_name_max_length') }}" value="{{ name }}"/>
<img id="character_indicator" src="images/global/general/{% if not save or errors.name is defined %}n{% endif %}ok.gif" style="display: none;" /> <img id="character_indicator" src="images/global/general/{% if not save or errors.name is defined %}n{% endif %}ok.gif" style="display: none;" />
<br> <br>
</td> </td>

View File

@ -45,7 +45,7 @@ In any case the name must not violate the naming conventions stated in the <a hr
</tr> </tr>
<tr class="Odd"> <tr class="Odd">
<td> <td>
<input name="name" id="character_name" value="{{ name }}" size="{{ config.character_name_max_length }}" maxlength="{{ config.character_name_max_length }}" > <input name="name" id="character_name" value="{{ name }}" size="{{ setting('create_character_name_max_length') }}" maxlength="{{ setting('create_character_name_max_length') }}" >
<img id="character_indicator" src="images/global/general/{% if not save or errors.name is defined %}n{% endif %}ok.gif" /> <img id="character_indicator" src="images/global/general/{% if not save or errors.name is defined %}n{% endif %}ok.gif" />
<br/> <br/>
<span style="font-size: 10px"> <span style="font-size: 10px">