1 #include "player/process-name.h"
2 #include "autopick/autopick-reader-writer.h"
3 #include "player-personality.h"
5 #include "world/world.h"
9 * @brief プレイヤーの名前をチェックして修正する
10 * Process the player name.
11 * @param player_ptr プレーヤーへの参照ポインタ
12 * @param sf セーブファイル名に合わせた修正を行うならばTRUE
15 * Extract a clean "base name".
16 * Build the savefile name if needed.
18 void process_player_name(player_type *creature_ptr, bool sf)
20 char old_player_base[32] = "";
21 if (current_world_ptr->character_generated)
22 strcpy(old_player_base, creature_ptr->base_name);
24 for (int i = 0; creature_ptr->name[i]; i++)
27 if (iskanji(creature_ptr->name[i]))
33 if (iscntrl((unsigned char)creature_ptr->name[i]))
35 if (iscntrl(creature_ptr->name[i]))
38 quit_fmt(_("'%s' という名前は不正なコントロールコードを含んでいます。", "The name '%s' contains control chars!"), creature_ptr->name);
43 for (int i = 0; creature_ptr->name[i]; i++)
46 unsigned char c = creature_ptr->name[i];
48 char c = creature_ptr->name[i];
53 if (k + 2 >= (int)sizeof(creature_ptr->base_name) || !creature_ptr->name[i + 1])
56 creature_ptr->base_name[k++] = c;
58 creature_ptr->base_name[k++] = creature_ptr->name[i];
61 else if (iskana(c)) creature_ptr->base_name[k++] = c;
65 if (!strncmp(PATH_SEP, creature_ptr->name + i, strlen(PATH_SEP)))
67 creature_ptr->base_name[k++] = '_';
68 i += strlen(PATH_SEP);
71 else if (my_strchr("\"*,/:;<>?\\|", c))
72 creature_ptr->base_name[k++] = '_';
75 creature_ptr->base_name[k++] = c;
78 creature_ptr->base_name[k] = '\0';
79 if (!creature_ptr->base_name[0])
80 strcpy(creature_ptr->base_name, "PLAYER");
82 #ifdef SAVEFILE_MUTABLE
85 if (!savefile_base[0] && savefile[0])
91 t = my_strstr(s, PATH_SEP);
97 strcpy(savefile_base, s);
100 if (!savefile_base[0] || !savefile[0])
106 strcpy(savefile_base, creature_ptr->base_name);
108 #ifdef SAVEFILE_USE_UID
109 /* Rename the savefile, using the creature_ptr->player_uid and creature_ptr->base_name */
110 (void)sprintf(temp, "%d.%s", creature_ptr->player_uid, creature_ptr->base_name);
112 /* Rename the savefile, using the creature_ptr->base_name */
113 (void)sprintf(temp, "%s", creature_ptr->base_name);
115 path_build(savefile, sizeof(savefile), ANGBAND_DIR_SAVE, temp);
118 if (current_world_ptr->character_generated && !streq(old_player_base, creature_ptr->base_name))
120 autopick_load_pref(creature_ptr, FALSE);
126 * @brief プレイヤーの名前を変更するコマンドのメインルーチン
127 * Gets a name for the character, reacting to name changes.
128 * @param creature_ptr プレーヤーへの参照ポインタ
132 * Assumes that "display_player()" has just been called
133 * Perhaps we should NOT ask for a name (at "birth()") on
134 * Unix machines? XXX XXX
135 * What a horrible name for a global function.
138 void get_name(player_type *creature_ptr)
141 strcpy(tmp, creature_ptr->name);
143 if (get_string(_("キャラクターの名前を入力して下さい: ", "Enter a name for your character: "), tmp, 15))
145 strcpy(creature_ptr->name, tmp);
148 if (strlen(creature_ptr->name) == 0)
150 strcpy(creature_ptr->name, "PLAYER");
153 strcpy(tmp, ap_ptr->title);
160 strcat(tmp, creature_ptr->name);
162 Term_erase(34, 1, 255);
163 c_put_str(TERM_L_BLUE, tmp, 1, 34);