OSDN Git Service

Merge branch 'develop' into macos-develop
[hengbandforosx/hengbandosx.git] / src / cmd-io / cmd-save.cpp
1 #include "cmd-io/cmd-save.h"
2 #include "cmd-io/cmd-dump.h"
3 #include "core/disturbance.h"
4 #include "core/stuff-handler.h"
5 #include "io/signal-handlers.h"
6 #include "io/write-diary.h"
7 #include "monster/monster-status.h" // 違和感。要調査.
8 #include "save/save.h"
9 #include "system/player-type-definition.h"
10 #include "term/screen-processor.h"
11 #include "view/display-messages.h"
12 #include "world/world.h"
13
14 /*!
15  * @brief セーブするコマンドのメインルーチン
16  * Save the game
17  * @param player_ptr プレイヤーへの参照ポインタ
18  * @param is_autosave オートセーブ中の処理ならばTRUE
19  * @details
20  */
21 void do_cmd_save_game(PlayerType *player_ptr, int is_autosave)
22 {
23     if (is_autosave) {
24         msg_print(_("自動セーブ中", "Autosaving the game..."));
25     } else {
26         disturb(player_ptr, true, true);
27     }
28
29     msg_print(nullptr);
30     handle_stuff(player_ptr);
31     prt(_("ゲームをセーブしています...", "Saving game..."), 0, 0);
32     term_fresh();
33     player_ptr->died_from = _("(セーブ)", "(saved)");
34     signals_ignore_tstp();
35     if (save_player(player_ptr, SaveType::CONTINUE_GAME)) {
36         prt(_("ゲームをセーブしています... 終了", "Saving game... done."), 0, 0);
37     } else {
38         prt(_("ゲームをセーブしています... 失敗!", "Saving game... failed!"), 0, 0);
39     }
40
41     signals_handle_tstp();
42     term_fresh();
43     player_ptr->died_from = _("(元気に生きている)", "(alive and well)");
44 }
45
46 /*!
47  * @brief セーブ後にゲーム中断フラグを立てる/
48  * Save the game and exit
49  * @details
50  */
51 void do_cmd_save_and_exit(PlayerType *player_ptr)
52 {
53     player_ptr->playing = false;
54     player_ptr->leaving = true;
55     exe_write_diary(player_ptr, DiaryKind::GAMESTART, 0, _("----ゲーム中断----", "--- Saved and Exited Game ---"));
56 }