From: dis- Date: Sun, 31 Jan 2021 15:12:38 +0000 (+0900) Subject: [Implement] 自動デバッグセーブの保存先をlib/save/log/に変更 X-Git-Tag: vmacos3.0.0-alpha52~433^2~1 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=437f9c66110c6175e5a6309c60914f6767936b18;p=hengbandforosx%2Fhengbandosx.git [Implement] 自動デバッグセーブの保存先をlib/save/log/に変更 自動デバッグセーブをlib/save/log以下に保存するよう変更した。 また、ファイルネームをyyyy-mm-dd-hh-mm-ssにして履歴を残すようにした。 --- diff --git a/src/io/files-util.c b/src/io/files-util.c index d400d2831..c09656f1d 100644 --- a/src/io/files-util.c +++ b/src/io/files-util.c @@ -33,6 +33,7 @@ concptr ANGBAND_DIR_HELP; //!< Help files (normal) for the online help (ascii) T concptr ANGBAND_DIR_INFO; //!< Help files (spoilers) for the online help (ascii) These files are portable between platforms concptr ANGBAND_DIR_PREF; //!< Default user "preference" files (ascii) These files are rarely portable between platforms concptr ANGBAND_DIR_SAVE; //!< Savefiles for current characters (binary) +concptr ANGBAND_DIR_DEBUG_SAVE; //*< Savefiles for debug data concptr ANGBAND_DIR_USER; //!< User "preference" files (ascii) These files are rarely portable between platforms concptr ANGBAND_DIR_XTRA; //!< Various extra files (binary) These files are rarely portable between platforms @@ -42,6 +43,7 @@ concptr ANGBAND_DIR_XTRA; //!< Various extra files (binary) These files are rare */ char savefile[1024]; char savefile_base[40]; +char debug_savefile[1024]; /*! * @brief プレイヤーステータスをファイルダンプ出力する diff --git a/src/io/files-util.h b/src/io/files-util.h index 6060aba7e..7b4b9eef4 100644 --- a/src/io/files-util.h +++ b/src/io/files-util.h @@ -4,6 +4,7 @@ extern char savefile[1024]; extern char savefile_base[40]; +extern char debug_savefile[1024]; extern concptr ANGBAND_DIR; extern concptr ANGBAND_DIR_APEX; @@ -16,6 +17,7 @@ extern concptr ANGBAND_DIR_HELP; extern concptr ANGBAND_DIR_INFO; extern concptr ANGBAND_DIR_PREF; extern concptr ANGBAND_DIR_SAVE; +extern concptr ANGBAND_DIR_DEBUG_SAVE; extern concptr ANGBAND_DIR_USER; extern concptr ANGBAND_DIR_XTRA; diff --git a/src/main-win.c b/src/main-win.c index 162bda609..c2cc572d6 100644 --- a/src/main-win.c +++ b/src/main-win.c @@ -3459,6 +3459,7 @@ static void init_stuff(void) validate_dir(ANGBAND_DIR_INFO, FALSE); validate_dir(ANGBAND_DIR_PREF, TRUE); validate_dir(ANGBAND_DIR_SAVE, FALSE); + validate_dir(ANGBAND_DIR_DEBUG_SAVE, FALSE); validate_dir(ANGBAND_DIR_USER, TRUE); validate_dir(ANGBAND_DIR_XTRA, TRUE); path_build(path, sizeof(path), ANGBAND_DIR_FILE, _("news_j.txt", "news.txt")); diff --git a/src/main/angband-initializer.c b/src/main/angband-initializer.c index 0d5b23072..e7ec060d0 100644 --- a/src/main/angband-initializer.c +++ b/src/main/angband-initializer.c @@ -27,6 +27,7 @@ #include "system/system-variables.h" #include "term/screen-processor.h" #include "term/term-color-types.h" +#include "time.h" #include "util/angband-files.h" #include "world/world.h" @@ -57,6 +58,7 @@ void init_file_paths(char *libpath, char *varpath) string_free(ANGBAND_DIR_HELP); string_free(ANGBAND_DIR_INFO); string_free(ANGBAND_DIR_SAVE); + string_free(ANGBAND_DIR_DEBUG_SAVE); string_free(ANGBAND_DIR_USER); string_free(ANGBAND_DIR_XTRA); @@ -83,6 +85,8 @@ void init_file_paths(char *libpath, char *varpath) ANGBAND_DIR_PREF = string_make(libpath); strcpy(vartail, "save"); ANGBAND_DIR_SAVE = string_make(varpath); + strcpy(vartail, "save\\log"); + ANGBAND_DIR_DEBUG_SAVE = string_make(varpath); #ifdef PRIVATE_USER_PATH path_build(buf, sizeof(buf), PRIVATE_USER_PATH, VERSION_NAME); ANGBAND_DIR_USER = string_make(buf); @@ -92,6 +96,12 @@ void init_file_paths(char *libpath, char *varpath) #endif strcpy(libtail, "xtra"); ANGBAND_DIR_XTRA = string_make(libpath); + + time_t now = time(NULL); + struct tm *t = localtime(&now); + char tmp[128]; + strftime(tmp, sizeof(tmp), "%Y-%m-%d-%H-%M-%S", t); + path_build(debug_savefile, sizeof(debug_savefile), ANGBAND_DIR_DEBUG_SAVE, tmp); } /*! diff --git a/src/player/process-name.c b/src/player/process-name.c index 1928dc3f4..a2ab2b825 100644 --- a/src/player/process-name.c +++ b/src/player/process-name.c @@ -21,111 +21,103 @@ */ 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); + 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++) - { + for (int i = 0; creature_ptr->name[i]; i++) { #ifdef JP - if (iskanji(creature_ptr->name[i])) - { - i++; - continue; - } + if (iskanji(creature_ptr->name[i])) { + i++; + continue; + } - if (iscntrl((unsigned char)creature_ptr->name[i])) + if (iscntrl((unsigned char)creature_ptr->name[i])) #else - if (iscntrl(creature_ptr->name[i])) + 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++) - { + { + 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]; + unsigned char c = creature_ptr->name[i]; #else - char c = creature_ptr->name[i]; + char c = creature_ptr->name[i]; #endif #ifdef JP - if (iskanji(c)) { - if (k + 2 >= (int)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]; - } + if (iskanji(c)) { + if (k + 2 >= (int)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; + else if (iskana(c)) + creature_ptr->base_name[k++] = c; #endif - else + else #endif - if (!strncmp(PATH_SEP, creature_ptr->name + i, strlen(PATH_SEP))) - { - creature_ptr->base_name[k++] = '_'; - i += strlen(PATH_SEP); - } + 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 (angband_strchr("\"*,/:;<>?\\|", c)) - creature_ptr->base_name[k++] = '_'; + else if (angband_strchr("\"*,/:;<>?\\|", c)) + creature_ptr->base_name[k++] = '_'; #endif - else if (isprint(c)) - creature_ptr->base_name[k++] = c; - } + 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"); + creature_ptr->base_name[k] = '\0'; + if (!creature_ptr->base_name[0]) + strcpy(creature_ptr->base_name, "PLAYER"); #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; - } - - strcpy(savefile_base, s); - } - - if (!savefile_base[0] || !savefile[0]) - sf = TRUE; - - if (sf) - { - char temp[128]; - strcpy(savefile_base, creature_ptr->base_name); + 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); + } + + 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); + /* 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)) - { - autopick_load_pref(creature_ptr, FALSE); - } + 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. @@ -141,29 +133,27 @@ void process_player_name(player_type *creature_ptr, bool sf) */ void get_name(player_type *creature_ptr) { - char tmp[64]; - strcpy(tmp, creature_ptr->name); + 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 (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"); - } + if (strlen(creature_ptr->name) == 0) { + strcpy(creature_ptr->name, "PLAYER"); + } - strcpy(tmp, ap_ptr->title); + strcpy(tmp, ap_ptr->title); #ifdef JP - if (ap_ptr->no == 1) - strcat(tmp, "の"); + if (ap_ptr->no == 1) + strcat(tmp, "の"); #else - strcat(tmp, " "); + strcat(tmp, " "); #endif - strcat(tmp, creature_ptr->name); + strcat(tmp, creature_ptr->name); - term_erase(34, 1, 255); - c_put_str(TERM_L_BLUE, tmp, 1, 34); - clear_from(22); -} + term_erase(34, 1, 255); + c_put_str(TERM_L_BLUE, tmp, 1, 34); + clear_from(22); +} \ No newline at end of file diff --git a/src/save/save.c b/src/save/save.c index 9b2bb95d7..617c0b743 100644 --- a/src/save/save.c +++ b/src/save/save.c @@ -282,9 +282,12 @@ bool save_player(player_type *player_ptr, save_type type) strcat(temp, ".old"); safe_setuid_grab(player_ptr); fd_kill(temp); - strcpy(filename, savefile); + if (type == SAVE_TYPE_DEBUG) - strcat(filename, ".debug"); + strcpy(filename, debug_savefile); + if (type == SAVE_TYPE_NORMAL) + strcpy(filename, savefile); + fd_move(filename, temp); fd_move(safe, filename); fd_kill(temp);