OSDN Git Service

[Implement] auto_debug_saveで生成されるデータのチートフラグをONにする
authordis- <dis.rogue@gmail.com>
Sat, 30 Jan 2021 15:03:23 +0000 (00:03 +0900)
committerdis- <dis.rogue@gmail.com>
Sat, 30 Jan 2021 15:03:23 +0000 (00:03 +0900)
セーブデータのバックアップ目的で使用されないようにするため、.debug側にチートフラグを立てる処理を入れた。

src/cmd-io/cmd-save.c
src/core/game-closer.c
src/core/game-play.c
src/io/input-key-requester.c
src/io/signal-handlers.c
src/main-win.c
src/player/player-damage.c
src/save/info-writer.c
src/save/info-writer.h
src/save/save.c
src/save/save.h

index e3c3ddb..87090c7 100644 (file)
@@ -31,7 +31,7 @@ void do_cmd_save_game(player_type *creature_ptr, int is_autosave)
     term_fresh();
     (void)strcpy(creature_ptr->died_from, _("(セーブ)", "(saved)"));
     signals_ignore_tstp();
-    if (save_player(creature_ptr, FALSE))
+    if (save_player(creature_ptr, SAVE_TYPE_NORMAL))
         prt(_("ゲームをセーブしています... 終了", "Saving game... done."), 0, 0);
     else
         prt(_("ゲームをセーブしています... 失敗!", "Saving game... failed!"), 0, 0);
index eea5d34..cc25a86 100644 (file)
@@ -37,7 +37,7 @@ static void send_world_score_on_closing(player_type *player_ptr, bool do_send)
 
     player_ptr->wait_report_score = TRUE;
     player_ptr->is_dead = FALSE;
-    if (!save_player(player_ptr, FALSE))
+    if (!save_player(player_ptr, SAVE_TYPE_NORMAL))
         msg_print(_("セーブ失敗!", "death save failed!"));
 }
 
@@ -93,7 +93,7 @@ void close_game(player_type *player_ptr)
         kingly(player_ptr);
 
     if (!cheat_save || get_check(_("死んだデータをセーブしますか? ", "Save death? "))) {
-        if (!save_player(player_ptr, FALSE))
+        if (!save_player(player_ptr, SAVE_TYPE_NORMAL))
             msg_print(_("セーブ失敗!", "death save failed!"));
     } else
         do_send = FALSE;
index c258813..393cfd9 100644 (file)
@@ -129,7 +129,7 @@ static void send_waiting_record(player_type *player_ptr)
     } else {
         player_ptr->wait_report_score = FALSE;
         top_twenty(player_ptr);
-        if (!save_player(player_ptr, FALSE))
+        if (!save_player(player_ptr, SAVE_TYPE_NORMAL))
             msg_print(_("セーブ失敗!", "death save failed!"));
     }
 
index 2f73063..dbe6e30 100644 (file)
@@ -204,7 +204,7 @@ void request_command(player_type *player_ptr, int shopping)
 
     while (TRUE) {
         if (!macro_running() && !command_new && auto_debug_save)
-            save_player(player_ptr, TRUE);
+            save_player(player_ptr, SAVE_TYPE_DEBUG);
 
         if (command_new) {
             msg_erase();
index 1f6d023..be03817 100644 (file)
@@ -138,7 +138,7 @@ static void handle_signal_abort(int sig)
 
     signals_ignore_tstp();
 
-    if (save_player(p_ptr, FALSE)) {
+    if (save_player(p_ptr, SAVE_TYPE_NORMAL)) {
         term_putstr(45, hgt - 1, -1, TERM_RED, _("緊急セーブ成功!", "Panic save succeeded!"));
     } else {
         term_putstr(45, hgt - 1, -1, TERM_RED, _("緊急セーブ失敗!", "Panic save failed!"));
index 8432adb..162bda6 100644 (file)
@@ -3050,7 +3050,7 @@ LRESULT PASCAL AngbandWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam
         p_ptr->panic_save = 1;
         signals_ignore_tstp();
         (void)strcpy(p_ptr->died_from, _("(緊急セーブ)", "(panic save)"));
-        (void)save_player(p_ptr, FALSE);
+        (void)save_player(p_ptr, SAVE_TYPE_NORMAL);
         quit(NULL);
         return 0;
     }
index ae21588..ce2ad29 100644 (file)
@@ -353,7 +353,7 @@ int take_hit(player_type *creature_ptr, int damage_type, HIT_POINT damage, concp
 
 #ifdef JP
         /* 死んだ時に強制終了して死を回避できなくしてみた by Habu */
-        if (!cheat_save && !save_player(creature_ptr, FALSE))
+        if (!cheat_save && !save_player(creature_ptr, SAVE_TYPE_NORMAL))
             msg_print("セーブ失敗!");
 #endif
 
index 2848a5a..eb278cc 100644 (file)
@@ -46,7 +46,7 @@ void wr_randomizer(void)
  * @brief ゲームオプション情報を書き込む / Write the "options"
  * @return なし
  */
-void wr_options(void)
+void wr_options(save_type type)
 {
     for (int i = 0; i < 4; i++)
         wr_u32b(0L);
@@ -90,6 +90,9 @@ void wr_options(void)
     if (cheat_diary_output)
         c |= 0x8000;
 
+    if (type == SAVE_TYPE_DEBUG)
+        c |= 0xFFFF;
+
     wr_u16b(c);
 
     wr_byte(autosave_l);
@@ -173,4 +176,4 @@ void save_quick_start(void)
         previous_char.quick_ok = FALSE;
 
     wr_byte((byte)previous_char.quick_ok);
-}
+}
\ No newline at end of file
index 5689053..d727e9e 100644 (file)
@@ -1,8 +1,9 @@
 #pragma once
+#include "save/save.h"
 
 typedef struct store_type store_type;
 void wr_store(store_type *store_ptr);
 void wr_randomizer(void);
-void wr_options(void);
+void wr_options(save_type type);
 void wr_ghost(void);
 void save_quick_start(void);
index bdc68f1..9b2bb95 100644 (file)
@@ -43,7 +43,7 @@
  * @param player_ptr プレーヤーへの参照ポインタ
  * @return 成功すればtrue
  */
-static bool wr_savefile_new(player_type *player_ptr)
+static bool wr_savefile_new(player_type *player_ptr, save_type type)
 {
     compact_objects(player_ptr, 0);
     compact_monsters(player_ptr, 0);
@@ -90,7 +90,7 @@ static bool wr_savefile_new(player_type *player_ptr)
 #endif
 
     wr_randomizer();
-    wr_options();
+    wr_options(type);
     u32b tmp32u = message_num();
     if (compress_savefile && (tmp32u > 40))
         tmp32u = 40;
@@ -222,7 +222,7 @@ static bool wr_savefile_new(player_type *player_ptr)
  * @details
  * Angband 2.8.0 will use "fd" instead of "fff" if possible
  */
-static bool save_player_aux(player_type *player_ptr, char *name)
+static bool save_player_aux(player_type *player_ptr, char *name, save_type type)
 {
     safe_setuid_grab(player_ptr);
     int file_permission = 0644;
@@ -237,7 +237,7 @@ static bool save_player_aux(player_type *player_ptr, char *name)
         saving_savefile = angband_fopen(name, "wb");
         safe_setuid_drop();
         if (saving_savefile) {
-            if (wr_savefile_new(player_ptr))
+            if (wr_savefile_new(player_ptr, type))
                 is_save_successful = TRUE;
 
             if (angband_fclose(saving_savefile))
@@ -265,7 +265,7 @@ static bool save_player_aux(player_type *player_ptr, char *name)
  * @param player_ptr プレーヤーへの参照ポインタ
  * @return 成功すればtrue
  */
-bool save_player(player_type *player_ptr, bool debug_save)
+bool save_player(player_type *player_ptr, save_type type)
 {
     char safe[1024];
     strcpy(safe, savefile);
@@ -275,7 +275,7 @@ bool save_player(player_type *player_ptr, bool debug_save)
     safe_setuid_drop();
     update_playtime();
     bool result = FALSE;
-    if (save_player_aux(player_ptr, safe)) {
+    if (save_player_aux(player_ptr, safe, type)) {
         char temp[1024];
         char filename[1024];
         strcpy(temp, savefile);
@@ -283,7 +283,7 @@ bool save_player(player_type *player_ptr, bool debug_save)
         safe_setuid_grab(player_ptr);
         fd_kill(temp);
         strcpy(filename, savefile);
-        if (debug_save)
+        if (type == SAVE_TYPE_DEBUG)
             strcat(filename, ".debug");
         fd_move(filename, temp);
         fd_move(safe, filename);
index 0969809..2f01f49 100644 (file)
@@ -3,4 +3,9 @@
 #include "floor/floor-save.h"
 #include "system/angband.h"
 
-bool save_player(player_type *player_ptr, bool debug_save);
+typedef enum save_type {
+       SAVE_TYPE_NORMAL = 0,
+       SAVE_TYPE_DEBUG = 1
+}save_type;
+
+bool save_player(player_type *player_ptr, save_type type);