OSDN Git Service

[Fix] #963 Resolved the indication that unique_ptr<PlayerEnergy> should be PlayerEnergy
[hengbandforosx/hengbandosx.git] / src / player / process-name.cpp
index a2ab2b8..024f627 100644 (file)
@@ -1,8 +1,10 @@
 #include "player/process-name.h"
 #include "autopick/autopick-reader-writer.h"
 #include "core/asking-player.h"
+#include "game-option/birth-options.h"
 #include "io/files-util.h"
 #include "player/player-personality.h"
+#include "system/player-type-definition.h"
 #include "term/screen-processor.h"
 #include "term/term-color-types.h"
 #include "util/angband-files.h"
@@ -19,7 +21,7 @@
  * Extract a clean "base name".
  * Build the savefile name if needed.
  */
-void process_player_name(player_type *creature_ptr, bool sf)
+void process_player_name(player_type *creature_ptr, bool is_new_savefile)
 {
     char old_player_base[32] = "";
     if (current_world_ptr->character_generated)
@@ -80,10 +82,22 @@ void process_player_name(player_type *creature_ptr, bool sf)
     if (!creature_ptr->base_name[0])
         strcpy(creature_ptr->base_name, "PLAYER");
 
-#ifdef SAVEFILE_MUTABLE
-    sf = TRUE;
+    auto is_modified = false;
+    if (is_new_savefile && (!savefile[0] || !keep_savefile)) {
+        char temp[128];
+
+#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
-    if (!savefile_base[0] && savefile[0]) {
+        path_build(savefile, sizeof(savefile), ANGBAND_DIR_SAVE, temp);
+        is_modified = true;
+    }
+
+    if (is_modified  || !savefile_base[0]) {
         concptr s = savefile;
         while (TRUE) {
             concptr t;
@@ -93,24 +107,11 @@ void process_player_name(player_type *creature_ptr, bool sf)
             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);
+        strcpy(savefile_base, angband_strstr(s, ".") + 1);
 #else
-        /* Rename the savefile, using the creature_ptr->base_name */
-        (void)sprintf(temp, "%s", creature_ptr->base_name);
+        strcpy(savefile_base, s);
 #endif
-        path_build(savefile, sizeof(savefile), ANGBAND_DIR_SAVE, temp);
     }
 
     if (current_world_ptr->character_generated && !streq(old_player_base, creature_ptr->base_name)) {
@@ -156,4 +157,4 @@ void get_name(player_type *creature_ptr)
     term_erase(34, 1, 255);
     c_put_str(TERM_L_BLUE, tmp, 1, 34);
     clear_from(22);
-}
\ No newline at end of file
+}