OSDN Git Service

[Fix] savefile_baseが更新されず、一時ファイルとplayrecord.txtのファイル名がおかしい #738
authoriks <iks3@users.noreply.github.com>
Thu, 8 Apr 2021 12:19:03 +0000 (21:19 +0900)
committeriks <iks3@users.noreply.github.com>
Thu, 8 Apr 2021 14:01:01 +0000 (23:01 +0900)
#676のエンバグ

src/birth/quick-start.cpp
src/cmd-visual/cmd-draw.cpp
src/core/game-play.cpp
src/player/process-name.cpp
src/player/process-name.h

index acb3db2..97cb490 100644 (file)
@@ -62,7 +62,7 @@ bool ask_quick_start(player_type *creature_ptr)
     update_creature(creature_ptr);
     creature_ptr->chp = creature_ptr->mhp;
     creature_ptr->csp = creature_ptr->msp;
-    process_player_name(creature_ptr, FALSE);
+    process_player_name(creature_ptr);
     return TRUE;
 }
 /*!
index 5cbf1b1..65eb79f 100644 (file)
@@ -96,7 +96,7 @@ void do_cmd_player_status(player_type *creature_ptr)
                if (c == 'c')
                {
                        get_name(creature_ptr);
-                       process_player_name(creature_ptr, FALSE);
+                       process_player_name(creature_ptr);
                }
                else if (c == 'f')
                {
index ac5e8c0..0774f37 100644 (file)
@@ -150,7 +150,7 @@ static void init_random_seed(player_type *player_ptr, bool new_game)
         init_saved_floors(player_ptr, TRUE);
 
     if (!new_game)
-        process_player_name(player_ptr, FALSE);
+        process_player_name(player_ptr);
 
     if (init_random_seed)
         Rand_state_init();
index 76a16fa..6399326 100644 (file)
@@ -20,7 +20,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)
@@ -81,39 +81,36 @@ void process_player_name(player_type *creature_ptr, bool sf)
     if (!creature_ptr->base_name[0])
         strcpy(creature_ptr->base_name, "PLAYER");
 
-    if (!keep_savefile || !savefile[0]) {
-#ifdef SAVEFILE_MUTABLE
-        sf = TRUE;
-#endif
-        if (!savefile_base[0] && savefile[0]) {
-            concptr s = savefile;
-            while (TRUE) {
-                concptr t;
-                t = angband_strstr(s, PATH_SEP);
-                if (!t)
-                    break;
-                s = t + 1;
-            }
-
-            strcpy(savefile_base, s);
-        }
+    auto is_modified = false;
+    if (is_new_savefile && (!savefile[0] || !keep_savefile)) {
+        char temp[128];
 
-        if (!savefile_base[0] || !savefile[0])
-            sf = TRUE;
+#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);
+        is_modified = true;
+    }
 
-        if (sf) {
-            char temp[128];
-            strcpy(savefile_base, creature_ptr->base_name);
+    if (is_modified  || !savefile_base[0]) {
+        concptr s = savefile;
+        while (TRUE) {
+            concptr t;
+            t = angband_strstr(s, PATH_SEP);
+            if (!t)
+                break;
+            s = t + 1;
+        }
 
 #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)) {
index 6e5d4bc..1f6fb66 100644 (file)
@@ -1,6 +1,6 @@
-#pragma once
+#pragma once
 
 #include "system/angband.h"
 
-void process_player_name(player_type *creature_ptr, bool sf);
+void process_player_name(player_type *creature_ptr, bool is_new_savefile = false);
 void get_name(player_type *creature_ptr);