OSDN Git Service

[Refactor] #39962 Separated process-name.c/h from files.c
authorHourier <hourier@users.sourceforge.jp>
Sun, 1 Mar 2020 09:54:26 +0000 (18:54 +0900)
committerHourier <hourier@users.sourceforge.jp>
Sun, 1 Mar 2020 09:54:26 +0000 (18:54 +0900)
Hengband_vcs2017/Hengband/Hengband.vcxproj
Hengband_vcs2017/Hengband/Hengband.vcxproj.filters
src/Makefile.am
src/birth.c
src/cmd/cmd-dump.c
src/core.c
src/files.c
src/files.h
src/player/process-name.c [new file with mode: 0644]
src/player/process-name.h [new file with mode: 0644]

index 9308efe..d4ee104 100644 (file)
     <ClCompile Include="..\..\src\player-skill.c" />\r
     <ClCompile Include="..\..\src\player-status.c" />\r
     <ClCompile Include="..\..\src\player\permanent-resistances.c" />\r
+    <ClCompile Include="..\..\src\player\process-name.c" />\r
     <ClCompile Include="..\..\src\player\race-resistances.c" />\r
     <ClCompile Include="..\..\src\player\temporary-resistances.c" />\r
     <ClCompile Include="..\..\src\quest.c" />\r
     <ClInclude Include="..\..\src\object-flavor.h" />\r
     <ClInclude Include="..\..\src\player-inventory.h" />\r
     <ClInclude Include="..\..\src\player\permanent-resistances.h" />\r
+    <ClInclude Include="..\..\src\player\process-name.h" />\r
     <ClInclude Include="..\..\src\player\race-resistances.h" />\r
     <ClInclude Include="..\..\src\player\temporary-resistances.h" />\r
     <ClInclude Include="..\..\src\signal-handlers.h" />\r
index 588607b..9d01afe 100644 (file)
     <ClCompile Include="..\..\src\cmd\cmd-help.c">
       <Filter>cmd</Filter>
     </ClCompile>
+    <ClCompile Include="..\..\src\player\process-name.c">
+      <Filter>player</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\src\gamevalue.h" />
     <ClInclude Include="..\..\src\cmd\cmd-help.h">
       <Filter>cmd</Filter>
     </ClInclude>
+    <ClInclude Include="..\..\src\player\process-name.h">
+      <Filter>player</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <None Include="..\..\src\wall.bmp" />
index cababb5..d7e228d 100644 (file)
@@ -25,6 +25,7 @@ hengband_SOURCES = \
        player/race-resistances.c player/race-resistances.h \
        player/permanent-resistances.c player/permanent-resistances.h \
        player/temporary-resistances.c player/temporary-resistances.h \
+       player/process-name.c player/process-name.h \
        \
        io/gf-descriptions.c io/gf-descriptions.h \
        io/tokenizer.c io/tokenizer.h \
index 8d6ca1e..748237f 100644 (file)
@@ -28,7 +28,8 @@
 #include "store.h"
 #include "patron.h"
 #include "quest.h"
-#include "view/display-player.h"
+#include "player/process-name.h"
+#include "view/display-player.h" // 暫定。後で消す.
 #include "player-class.h"
 #include "player-status.h"
 #include "player-personality.h"
index aa91920..74d6cfe 100644 (file)
@@ -52,6 +52,7 @@
 #include "dungeon.h"
 #include "world.h"
 #include "view/display-player.h"
+#include "player/process-name.h"
 #include "player-effects.h"
 #include "player-status.h"
 #include "player-skill.h"
index 793dfcb..dda66f5 100644 (file)
@@ -63,6 +63,7 @@
 #include "artifact.h"
 #include "avatar.h"
 #include "view/display-player.h"
+#include "player/process-name.h"
 #include "player-move.h"
 #include "player-status.h"
 #include "player-class.h"
index bfc5d31..77f4d96 100644 (file)
@@ -976,166 +976,6 @@ bool show_file(player_type *creature_ptr, bool show_version, concptr name, concp
 
 
 /*!
- * @brief プレイヤーの名前をチェックして修正する
- * Process the player name.
- * @param player_ptr プレーヤーへの参照ポインタ
- * @param sf セーブファイル名に合わせた修正を行うならばTRUE
- * @return なし
- * @details
- * Extract a clean "base name".
- * Build the savefile name if needed.
- */
-void process_player_name(player_type *creature_ptr, bool sf)
-{
-       char old_player_base[32] = "";
-       if (current_world_ptr->character_generated)
-               strcpy(old_player_base, creature_ptr->base_name);
-
-       for (int i = 0; creature_ptr->name[i]; i++)
-       {
-#ifdef JP
-               if (iskanji(creature_ptr->name[i]))
-               {
-                       i++;
-                       continue;
-               }
-
-               if (iscntrl((unsigned char)creature_ptr->name[i]))
-#else
-               if (iscntrl(creature_ptr->name[i]))
-#endif
-               {
-                       quit_fmt(_("'%s' という名前は不正なコントロールコードを含んでいます。", "The name '%s' contains control chars!"), creature_ptr->name);
-               }
-       }
-
-       int k = 0;
-       for (int i = 0; creature_ptr->name[i]; i++)
-       {
-#ifdef JP
-               unsigned char c = creature_ptr->name[i];
-#else
-               char c = creature_ptr->name[i];
-#endif
-
-#ifdef JP
-               if (iskanji(c)) {
-                       if (k + 2 >= sizeof(creature_ptr->base_name) || !creature_ptr->name[i + 1])
-                               break;
-
-                       creature_ptr->base_name[k++] = c;
-                       i++;
-                       creature_ptr->base_name[k++] = creature_ptr->name[i];
-               }
-#ifdef SJIS
-               else if (iskana(c)) creature_ptr->base_name[k++] = c;
-#endif
-               else
-#endif
-                       if (!strncmp(PATH_SEP, creature_ptr->name + i, strlen(PATH_SEP)))
-                       {
-                               creature_ptr->base_name[k++] = '_';
-                               i += strlen(PATH_SEP);
-                       }
-#if defined(WINDOWS)
-                       else if (my_strchr("\"*,/:;<>?\\|", c))
-                               creature_ptr->base_name[k++] = '_';
-#endif
-                       else if (isprint(c))
-                               creature_ptr->base_name[k++] = c;
-       }
-
-       creature_ptr->base_name[k] = '\0';
-       if (!creature_ptr->base_name[0])
-               strcpy(creature_ptr->base_name, "PLAYER");
-
-#ifdef SAVEFILE_MUTABLE
-       sf = TRUE;
-#endif
-       if (!savefile_base[0] && savefile[0])
-       {
-               concptr s = savefile;
-               while (TRUE)
-               {
-                       concptr t;
-                       t = my_strstr(s, PATH_SEP);
-                       if (!t)
-                               break;
-                       s = t + 1;
-               }
-
-               strcpy(savefile_base, s);
-       }
-
-       if (!savefile_base[0] || !savefile[0])
-               sf = TRUE;
-
-       if (sf)
-       {
-               char temp[128];
-               strcpy(savefile_base, creature_ptr->base_name);
-
-#ifdef SAVEFILE_USE_UID
-               /* Rename the savefile, using the creature_ptr->player_uid and creature_ptr->base_name */
-               (void)sprintf(temp, "%d.%s", creature_ptr->player_uid, creature_ptr->base_name);
-#else
-               /* Rename the savefile, using the creature_ptr->base_name */
-               (void)sprintf(temp, "%s", creature_ptr->base_name);
-#endif
-               path_build(savefile, sizeof(savefile), ANGBAND_DIR_SAVE, temp);
-       }
-
-       if (current_world_ptr->character_generated && !streq(old_player_base, creature_ptr->base_name))
-       {
-               autopick_load_pref(creature_ptr, FALSE);
-       }
-}
-
-
-/*!
- * @brief プレイヤーの名前を変更するコマンドのメインルーチン
- * Gets a name for the character, reacting to name changes.
- * @param creature_ptr プレーヤーへの参照ポインタ
- * @return なし
- * @details
- * <pre>
- * Assumes that "display_player()" has just been called
- * Perhaps we should NOT ask for a name (at "birth()") on
- * Unix machines?  XXX XXX
- * What a horrible name for a global function.
- * </pre>
- */
-void get_name(player_type *creature_ptr)
-{
-       char tmp[64];
-       strcpy(tmp, creature_ptr->name);
-
-       if (get_string(_("キャラクターの名前を入力して下さい: ", "Enter a name for your character: "), tmp, 15))
-       {
-               strcpy(creature_ptr->name, tmp);
-       }
-
-       if (strlen(creature_ptr->name) == 0)
-       {
-               strcpy(creature_ptr->name, "PLAYER");
-       }
-
-       strcpy(tmp, ap_ptr->title);
-#ifdef JP
-       if (ap_ptr->no == 1)
-               strcat(tmp, "の");
-#else
-       strcat(tmp, " ");
-#endif
-       strcat(tmp, creature_ptr->name);
-
-       Term_erase(34, 1, 255);
-       c_put_str(TERM_L_BLUE, tmp, 1, 34);
-       clear_from(22);
-}
-
-
-/*!
  * @brief セーブするコマンドのメインルーチン
  * Save the game
  * @param creature_ptr プレーヤーへの参照ポインタ
index ee34710..21d5641 100644 (file)
@@ -26,8 +26,6 @@ extern errr process_pref_file(player_type *creature_ptr, concptr name);
 extern errr process_autopick_file(player_type *creature_ptr, concptr name);
 extern errr process_histpref_file(player_type *creature_ptr, concptr name);
 extern bool show_file(player_type *player_ptr, bool show_version, concptr name, concptr what, int line, BIT_FLAGS mode);
-extern void process_player_name(player_type *creature_ptr, bool sf);
-extern void get_name(player_type *creature_ptr);
 extern void do_cmd_save_game(player_type *creature_ptr, int is_autosave);
 extern void do_cmd_save_and_exit(player_type *player_ptr);
 extern void exit_game_panic(player_type *creature_ptr);
diff --git a/src/player/process-name.c b/src/player/process-name.c
new file mode 100644 (file)
index 0000000..db30ed7
--- /dev/null
@@ -0,0 +1,165 @@
+#include "player/process-name.h"
+#include "autopick.h"
+#include "player-personality.h"
+#include "files.h"
+#include "world.h"
+#include "term.h"
+
+/*!
+ * @brief プレイヤーの名前をチェックして修正する
+ * Process the player name.
+ * @param player_ptr プレーヤーへの参照ポインタ
+ * @param sf セーブファイル名に合わせた修正を行うならばTRUE
+ * @return なし
+ * @details
+ * Extract a clean "base name".
+ * Build the savefile name if needed.
+ */
+void process_player_name(player_type *creature_ptr, bool sf)
+{
+       char old_player_base[32] = "";
+       if (current_world_ptr->character_generated)
+               strcpy(old_player_base, creature_ptr->base_name);
+
+       for (int i = 0; creature_ptr->name[i]; i++)
+       {
+#ifdef JP
+               if (iskanji(creature_ptr->name[i]))
+               {
+                       i++;
+                       continue;
+               }
+
+               if (iscntrl((unsigned char)creature_ptr->name[i]))
+#else
+               if (iscntrl(creature_ptr->name[i]))
+#endif
+               {
+                       quit_fmt(_("'%s' という名前は不正なコントロールコードを含んでいます。", "The name '%s' contains control chars!"), creature_ptr->name);
+               }
+       }
+
+       int k = 0;
+       for (int i = 0; creature_ptr->name[i]; i++)
+       {
+#ifdef JP
+               unsigned char c = creature_ptr->name[i];
+#else
+               char c = creature_ptr->name[i];
+#endif
+
+#ifdef JP
+               if (iskanji(c)) {
+                       if (k + 2 >= sizeof(creature_ptr->base_name) || !creature_ptr->name[i + 1])
+                               break;
+
+                       creature_ptr->base_name[k++] = c;
+                       i++;
+                       creature_ptr->base_name[k++] = creature_ptr->name[i];
+               }
+#ifdef SJIS
+               else if (iskana(c)) creature_ptr->base_name[k++] = c;
+#endif
+               else
+#endif
+                       if (!strncmp(PATH_SEP, creature_ptr->name + i, strlen(PATH_SEP)))
+                       {
+                               creature_ptr->base_name[k++] = '_';
+                               i += strlen(PATH_SEP);
+                       }
+#if defined(WINDOWS)
+                       else if (my_strchr("\"*,/:;<>?\\|", c))
+                               creature_ptr->base_name[k++] = '_';
+#endif
+                       else if (isprint(c))
+                               creature_ptr->base_name[k++] = c;
+       }
+
+       creature_ptr->base_name[k] = '\0';
+       if (!creature_ptr->base_name[0])
+               strcpy(creature_ptr->base_name, "PLAYER");
+
+#ifdef SAVEFILE_MUTABLE
+       sf = TRUE;
+#endif
+       if (!savefile_base[0] && savefile[0])
+       {
+               concptr s = savefile;
+               while (TRUE)
+               {
+                       concptr t;
+                       t = my_strstr(s, PATH_SEP);
+                       if (!t)
+                               break;
+                       s = t + 1;
+               }
+
+               strcpy(savefile_base, s);
+       }
+
+       if (!savefile_base[0] || !savefile[0])
+               sf = TRUE;
+
+       if (sf)
+       {
+               char temp[128];
+               strcpy(savefile_base, creature_ptr->base_name);
+
+#ifdef SAVEFILE_USE_UID
+               /* Rename the savefile, using the creature_ptr->player_uid and creature_ptr->base_name */
+               (void)sprintf(temp, "%d.%s", creature_ptr->player_uid, creature_ptr->base_name);
+#else
+               /* Rename the savefile, using the creature_ptr->base_name */
+               (void)sprintf(temp, "%s", creature_ptr->base_name);
+#endif
+               path_build(savefile, sizeof(savefile), ANGBAND_DIR_SAVE, temp);
+       }
+
+       if (current_world_ptr->character_generated && !streq(old_player_base, creature_ptr->base_name))
+       {
+               autopick_load_pref(creature_ptr, FALSE);
+       }
+}
+
+
+/*!
+ * @brief プレイヤーの名前を変更するコマンドのメインルーチン
+ * Gets a name for the character, reacting to name changes.
+ * @param creature_ptr プレーヤーへの参照ポインタ
+ * @return なし
+ * @details
+ * <pre>
+ * Assumes that "display_player()" has just been called
+ * Perhaps we should NOT ask for a name (at "birth()") on
+ * Unix machines?  XXX XXX
+ * What a horrible name for a global function.
+ * </pre>
+ */
+void get_name(player_type *creature_ptr)
+{
+       char tmp[64];
+       strcpy(tmp, creature_ptr->name);
+
+       if (get_string(_("キャラクターの名前を入力して下さい: ", "Enter a name for your character: "), tmp, 15))
+       {
+               strcpy(creature_ptr->name, tmp);
+       }
+
+       if (strlen(creature_ptr->name) == 0)
+       {
+               strcpy(creature_ptr->name, "PLAYER");
+       }
+
+       strcpy(tmp, ap_ptr->title);
+#ifdef JP
+       if (ap_ptr->no == 1)
+               strcat(tmp, "の");
+#else
+       strcat(tmp, " ");
+#endif
+       strcat(tmp, creature_ptr->name);
+
+       Term_erase(34, 1, 255);
+       c_put_str(TERM_L_BLUE, tmp, 1, 34);
+       clear_from(22);
+}
diff --git a/src/player/process-name.h b/src/player/process-name.h
new file mode 100644 (file)
index 0000000..d37d7d3
--- /dev/null
@@ -0,0 +1,6 @@
+#pragma once
+
+#include "angband.h"
+
+void process_player_name(player_type *creature_ptr, bool sf);
+void get_name(player_type *creature_ptr);