OSDN Git Service

[Feature] キャラメイク時にキャラ名を変えてもロードしたセーブファイルのままスタートするオプション #126
authoriks <iks3@users.noreply.github.com>
Thu, 1 Apr 2021 11:34:56 +0000 (20:34 +0900)
committeriks <iks3@users.noreply.github.com>
Thu, 1 Apr 2021 11:34:56 +0000 (20:34 +0900)
src/game-option/birth-options.cpp
src/game-option/birth-options.h
src/game-option/option-types-table.cpp
src/game-option/option-types-table.h
src/player/process-name.cpp

index de0f0ca..6726f30 100644 (file)
@@ -21,3 +21,4 @@ bool show_ammo_detail; /* Show Description of ammo damage */
 bool show_ammo_no_crit; /* Show No-crit damage of ammo */
 bool show_ammo_crit_ratio; /* Show critical ratio of ammo */
 bool show_actual_value; /* Show actual value of skill */
+bool keep_savefile; //!< 同一のセーブファイルでゲームを開始する / Start game with same savefile thet is loaded
index a551ac4..78d5e73 100644 (file)
@@ -19,3 +19,4 @@ extern bool preserve_mode; /* Preserve artifacts (*) */
 extern bool autoroller; /* Allow use of autoroller for stats (*) */
 extern bool autochara; /* Autoroll for weight, height and social status */
 extern bool powerup_home; /* Increase capacity of your home (*) */
+extern bool keep_savefile; //!< 同一のセーブファイルでゲームを開始する / Start game with same savefile thet is loaded
index 6a3d765..94e01d4 100644 (file)
@@ -15,7 +15,8 @@
  * @brief オプションテーブル /
  * Available Options
  */
-const std::array<option_type, MAX_OPTION_INFO> option_info = {{ /*** Input Options ***/
+const std::array<const option_type, MAX_OPTION_INFO> option_info = {{
+    /*** Input Options ***/
     { &rogue_like_commands, FALSE, OPT_PAGE_INPUT, 0, 0, "rogue_like_commands", _("ローグ風キー配置を使用する", "Rogue-like commands") },
 
     { &always_pickup, FALSE, OPT_PAGE_INPUT, 0, 5, "always_pickup", _("常にアイテムを拾う", "Pick things up by default") },
@@ -240,6 +241,8 @@ const std::array<option_type, MAX_OPTION_INFO> option_info = {{ /*** Input Optio
 
     { &powerup_home, TRUE, OPT_PAGE_BIRTH, 4, 3, "powerup_home", _("我が家を拡張する(*)", "Increase capacity of your home (*)") },
 
+    { &keep_savefile, TRUE, OPT_PAGE_BIRTH, 4, 4, "keep_savefile", _("同一のセーブファイルでゲームを開始する(*)", "Start game with same savefile thet is loaded (*)") },
+
     /*** Easy Object Auto-Destroyer ***/
     { &destroy_items, FALSE, OPT_PAGE_AUTODESTROY, 7, 0, "destroy_items", _("アイテムの簡易自動破壊を使用する", "Use easy auto-destroyer") },
 
index e9b709a..3518237 100644 (file)
@@ -1,7 +1,6 @@
 #pragma once
 
 #include "system/angband.h"
-
 #include <array>
 
 /*
@@ -24,10 +23,10 @@ struct option_type {
     concptr o_desc{};
 };
 
-#define MAX_OPTION_INFO 124
+#define MAX_OPTION_INFO 125
 #define MAX_CHEAT_OPTIONS 10
 #define MAX_AUTOSAVE_INFO 2
 
-extern const std::array<option_type, MAX_OPTION_INFO> option_info;
+extern const std::array<const option_type, MAX_OPTION_INFO> option_info;
 extern const option_type cheat_info[MAX_CHEAT_OPTIONS];
 extern const option_type autosave_info[MAX_AUTOSAVE_INFO];
index a2ab2b8..76a16fa 100644 (file)
@@ -1,6 +1,7 @@
 #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 "term/screen-processor.h"
@@ -80,37 +81,39 @@ 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;
+        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;
+        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);
         }
 
-        strcpy(savefile_base, s);
-    }
+        if (!savefile_base[0] || !savefile[0])
+            sf = TRUE;
 
-    if (!savefile_base[0] || !savefile[0])
-        sf = TRUE;
-
-    if (sf) {
-        char temp[128];
-        strcpy(savefile_base, creature_ptr->base_name);
+        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);
+            /* 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);
+            /* 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);
+            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 +159,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
+}