From: Hourier Date: Sun, 1 Mar 2020 10:23:49 +0000 (+0900) Subject: [Refactor] #39962 Separated cmd-save.c/h from files.c X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;ds=sidebyside;h=9a19496564655831eaa43a9ced62c9e88ad20b93;p=hengband%2Fhengband.git [Refactor] #39962 Separated cmd-save.c/h from files.c --- diff --git a/Hengband_vcs2017/Hengband/Hengband.vcxproj b/Hengband_vcs2017/Hengband/Hengband.vcxproj index d4ee10435..5522eaa3f 100644 --- a/Hengband_vcs2017/Hengband/Hengband.vcxproj +++ b/Hengband_vcs2017/Hengband/Hengband.vcxproj @@ -169,6 +169,7 @@ + @@ -327,6 +328,7 @@ + diff --git a/Hengband_vcs2017/Hengband/Hengband.vcxproj.filters b/Hengband_vcs2017/Hengband/Hengband.vcxproj.filters index 9d01afe3f..e30558369 100644 --- a/Hengband_vcs2017/Hengband/Hengband.vcxproj.filters +++ b/Hengband_vcs2017/Hengband/Hengband.vcxproj.filters @@ -463,6 +463,9 @@ player + + cmd + @@ -908,6 +911,9 @@ player + + cmd + diff --git a/src/Makefile.am b/src/Makefile.am index 56354a613..95c073216 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -123,9 +123,10 @@ hengband_SOURCES = \ cmd/cmd-hissatsu.c cmd/cmd-hissatsu.h cmd/cmd-item.c cmd/cmd-item.h \ cmd/cmd-magiceat.c cmd/cmd-magiceat.h cmd/cmd-mane.c cmd/cmd-mane.h \ cmd/cmd-pet.c cmd/cmd-pet.h cmd/cmd-quaff.c cmd/cmd-quaff.h \ - cmd/cmd-read.c cmd/cmd-read.h cmd/cmd-smith.c cmd/cmd-smith.h \ - cmd/cmd-spell.c cmd/cmd-spell.h cmd/cmd-usestaff.c cmd/cmd-usestaff.h \ - cmd/cmd-zaprod.c cmd/cmd-zaprod.h cmd/cmd-zapwand.c cmd/cmd-zapwand.h \ + cmd/cmd-read.c cmd/cmd-read.h cmd/cmd-save.c cmd/cmd-save.h \ + cmd/cmd-smith.c cmd/cmd-smith.h cmd/cmd-spell.c cmd/cmd-spell.h \ + cmd/cmd-usestaff.c cmd/cmd-usestaff.h cmd/cmd-zaprod.c cmd/cmd-zaprod.h \ + cmd/cmd-zapwand.c cmd/cmd-zapwand.h \ \ combat/melee.h combat/melee1.c combat/shoot.c combat/shoot.h diff --git a/src/autopick.c b/src/autopick.c index d14ec7dad..99978d838 100644 --- a/src/autopick.c +++ b/src/autopick.c @@ -16,6 +16,7 @@ #include "term.h" #include "autopick.h" #include "core.h" +#include "cmd/cmd-save.h" #include "mind.h" diff --git a/src/cmd/cmd-activate.c b/src/cmd/cmd-activate.c index 413dfabfe..e319c5920 100644 --- a/src/cmd/cmd-activate.c +++ b/src/cmd/cmd-activate.c @@ -8,8 +8,9 @@ #include "angband.h" -#include "cmd-activate.h" -#include "cmd-basic.h" +#include "cmd/cmd-activate.h" +#include "cmd/cmd-basic.h" +#include "cmd/cmd-save.h" #include "object-hook.h" #include "sort.h" #include "artifact.h" diff --git a/src/cmd/cmd-basic.c b/src/cmd/cmd-basic.c index e30d25a02..20b4c8027 100644 --- a/src/cmd/cmd-basic.c +++ b/src/cmd/cmd-basic.c @@ -14,7 +14,8 @@ #include "core.h" #include "term.h" -#include "cmd-dump.h" +#include "cmd/cmd-dump.h" +#include "cmd/cmd-save.h" #include "chest.h" #include "trap.h" #include "dungeon.h" diff --git a/src/cmd/cmd-save.c b/src/cmd/cmd-save.c new file mode 100644 index 000000000..ac254fc02 --- /dev/null +++ b/src/cmd/cmd-save.c @@ -0,0 +1,66 @@ +#include "signal-handlers.h" +#include "cmd/cmd-save.h" +#include "cmd/cmd-dump.h" +#include "player-move.h" +#include "core.h" // 暫定。後で消す. +#include "save.h" +#include "world.h" +#include "monster-status.h" // 違和感。要調査. +#include "term.h" + +/*! + * @brief セーブするコマンドのメインルーチン + * Save the game + * @param creature_ptr プレーヤーへの参照ポインタ + * @param is_autosave オートセーブ中の処理ならばTRUE + * @return なし + * @details + */ +void do_cmd_save_game(player_type *creature_ptr, int is_autosave) +{ + if (is_autosave) + { + msg_print(_("自動セーブ中", "Autosaving the game...")); + } + else + { + disturb(creature_ptr, TRUE, TRUE); + } + + msg_print(NULL); + handle_stuff(creature_ptr); + prt(_("ゲームをセーブしています...", "Saving game..."), 0, 0); + Term_fresh(); + (void)strcpy(creature_ptr->died_from, _("(セーブ)", "(saved)")); + signals_ignore_tstp(); + if (save_player(creature_ptr)) + { + prt(_("ゲームをセーブしています... 終了", "Saving game... done."), 0, 0); + } + else + { + prt(_("ゲームをセーブしています... 失敗!", "Saving game... failed!"), 0, 0); + } + + signals_handle_tstp(); + Term_fresh(); + (void)strcpy(creature_ptr->died_from, _("(元気に生きている)", "(alive and well)")); + current_world_ptr->is_loading_now = FALSE; + update_creature(creature_ptr); + mproc_init(creature_ptr->current_floor_ptr); + current_world_ptr->is_loading_now = TRUE; +} + + +/*! + * @brief セーブ後にゲーム中断フラグを立てる/ + * Save the game and exit + * @return なし + * @details + */ +void do_cmd_save_and_exit(player_type *creature_ptr) +{ + creature_ptr->playing = FALSE; + creature_ptr->leaving = TRUE; + exe_write_diary(creature_ptr, DIARY_GAMESTART, 0, _("----ゲーム中断----", "---- Save and Exit Game ----")); +} diff --git a/src/cmd/cmd-save.h b/src/cmd/cmd-save.h new file mode 100644 index 000000000..835e696a5 --- /dev/null +++ b/src/cmd/cmd-save.h @@ -0,0 +1,6 @@ +#pragma once + +#include "angband.h" + +void do_cmd_save_game(player_type *creature_ptr, int is_autosave); +void do_cmd_save_and_exit(player_type *player_ptr); diff --git a/src/core.c b/src/core.c index dda66f506..2554fa552 100644 --- a/src/core.c +++ b/src/core.c @@ -32,6 +32,7 @@ #include "cmd/cmd-mane.h" #include "cmd/cmd-quaff.h" #include "cmd/cmd-read.h" +#include "cmd/cmd-save.h" #include "cmd/cmd-smith.h" #include "cmd/cmd-usestaff.h" #include "cmd/cmd-zaprod.h" diff --git a/src/files.c b/src/files.c index 46d06acbc..100df6b64 100644 --- a/src/files.c +++ b/src/files.c @@ -14,23 +14,14 @@ #include "angband.h" #include "term.h" -#include "signal-handlers.h" #include "uid-checker.h" #include "files.h" #include "core.h" // リファクタリングして後で消す -#include "birth.h" #include "character-dump.h" -#include "cmd-dump.h" #include "world.h" -#include "player-move.h" -#include "player-personality.h" -#include "player-effects.h" -#include "monster-status.h" #include "view-mainwindow.h" -#include "objectkind.h" #include "autopick.h" -#include "save.h" #include "io/tokenizer.h" #include "io/process-pref-file.h" // 暫定。依存性の向きがこれで良いか要確認. @@ -976,64 +967,6 @@ bool show_file(player_type *creature_ptr, bool show_version, concptr name, concp /*! - * @brief セーブするコマンドのメインルーチン - * Save the game - * @param creature_ptr プレーヤーへの参照ポインタ - * @param is_autosave オートセーブ中の処理ならばTRUE - * @return なし - * @details - */ -void do_cmd_save_game(player_type *creature_ptr, int is_autosave) -{ - if (is_autosave) - { - msg_print(_("自動セーブ中", "Autosaving the game...")); - } - else - { - disturb(creature_ptr, TRUE, TRUE); - } - - msg_print(NULL); - handle_stuff(creature_ptr); - prt(_("ゲームをセーブしています...", "Saving game..."), 0, 0); - Term_fresh(); - (void)strcpy(creature_ptr->died_from, _("(セーブ)", "(saved)")); - signals_ignore_tstp(); - if (save_player(creature_ptr)) - { - prt(_("ゲームをセーブしています... 終了", "Saving game... done."), 0, 0); - } - else - { - prt(_("ゲームをセーブしています... 失敗!", "Saving game... failed!"), 0, 0); - } - - signals_handle_tstp(); - Term_fresh(); - (void)strcpy(creature_ptr->died_from, _("(元気に生きている)", "(alive and well)")); - current_world_ptr->is_loading_now = FALSE; - update_creature(creature_ptr); - mproc_init(creature_ptr->current_floor_ptr); - current_world_ptr->is_loading_now = TRUE; -} - - -/*! - * @brief セーブ後にゲーム中断フラグを立てる/ - * Save the game and exit - * @return なし - * @details - */ -void do_cmd_save_and_exit(player_type *creature_ptr) -{ - creature_ptr->playing = FALSE; - creature_ptr->leaving = TRUE; - exe_write_diary(creature_ptr, DIARY_GAMESTART, 0, _("----ゲーム中断----", "---- Save and Exit Game ----")); -} - - -/*! * @brief ファイルからランダムに行を一つ取得する / * Get a random line from a file * @param file_name ファイル名 diff --git a/src/files.h b/src/files.h index c7672cfa0..ed2c35b75 100644 --- a/src/files.h +++ b/src/files.h @@ -26,8 +26,6 @@ extern errr process_pref_file(player_type *creature_ptr, concptr name); extern errr process_autopick_file(player_type *creature_ptr, concptr name); extern errr process_histpref_file(player_type *creature_ptr, concptr name); extern bool show_file(player_type *player_ptr, bool show_version, concptr name, concptr what, int line, BIT_FLAGS mode); -extern void do_cmd_save_game(player_type *creature_ptr, int is_autosave); -extern void do_cmd_save_and_exit(player_type *player_ptr); extern errr get_rnd_line(concptr file_name, int entry, char *output); void read_dead_file(char* buf, size_t buf_size); diff --git a/src/main-win.c b/src/main-win.c index 9e9076f26..ddbbabde9 100644 --- a/src/main-win.c +++ b/src/main-win.c @@ -99,7 +99,8 @@ #include "inet.h" #include "chuukei.h" -#include "cmd-dump.h" +#include "cmd/cmd-dump.h" +#include "cmd/cmd-save.h" #include "view-mainwindow.h" #include "floor.h" #include "floor-events.h" diff --git a/src/spells3.c b/src/spells3.c index 35992705e..5ee9916cc 100644 --- a/src/spells3.c +++ b/src/spells3.c @@ -42,8 +42,9 @@ #include "monster-process.h" #include "monster-status.h" #include "monster-spell.h" -#include "cmd-spell.h" -#include "cmd-dump.h" +#include "cmd/cmd-save.h" +#include "cmd/cmd-spell.h" +#include "cmd/cmd-dump.h" #include "snipe.h" #include "floor-save.h" #include "files.h" @@ -538,6 +539,7 @@ bool teleport_level_other(player_type *caster_ptr) /*! + * todo cmd-save.h への依存あり。コールバックで何とかしたい * @brief プレイヤー及びモンスターをレベルテレポートさせる / * Teleport the player one level up or down (random when legal) * @param creature_ptr プレーヤーへの参照ポインタ diff --git a/src/trap.c b/src/trap.c index f00fe8c06..940d19a49 100644 --- a/src/trap.c +++ b/src/trap.c @@ -1,7 +1,8 @@ #include "angband.h" #include "util.h" -#include "cmd-dump.h" +#include "cmd/cmd-dump.h" +#include "cmd/cmd-save.h" #include "trap.h" #include "player-damage.h" #include "player-move.h" @@ -327,6 +328,7 @@ static void hit_trap_pit(player_type *trapped_ptr, int trap_feat_type) take_hit(trapped_ptr, DAMAGE_NOESCAPE, dam, trap_name, -1); } + /*! * @brief ダーツ系トラップ(通常ダメージ)の判定とプレイヤーの被害処理 * @return ダーツが命中した場合TRUEを返す @@ -374,14 +376,15 @@ static void hit_trap_slow(player_type *target_ptr) } } + /*! -* @brief ダーツ系トラップ(通常ダメージ+状態異常)の判定とプレイヤーの被害処理 -* @param trap_message メッセージの補完文字列 -* @param resist 状態異常に抵抗する判定が出たならTRUE -* @param set_status 状態異常を指定する関数ポインタ -* @param turn_aux 状態異常の追加ターン量 -* @return なし -*/ + * @brief ダーツ系トラップ(通常ダメージ+状態異常)の判定とプレイヤーの被害処理 + * @param trap_message メッセージの補完文字列 + * @param resist 状態異常に抵抗する判定が出たならTRUE + * @param set_status 状態異常を指定する関数ポインタ + * @param turn_aux 状態異常の追加ターン量 + * @return なし + */ static void hit_trap_set_abnormal_status_p(player_type *trapped_ptr, concptr trap_message, bool resist, bool(*set_status)(player_type *, IDX), IDX turn_aux) { msg_print(trap_message); @@ -391,12 +394,14 @@ static void hit_trap_set_abnormal_status_p(player_type *trapped_ptr, concptr tra } } + /*! -* @brief プレイヤーへのトラップ作動処理メインルーチン / -* Handle player hitting a real trap -* @param break_trap 作動後のトラップ破壊が確定しているならばTRUE -* @return なし -*/ + * todo cmd-save.h への依存あり。コールバックで何とかしたい + * @brief プレイヤーへのトラップ作動処理メインルーチン / + * Handle player hitting a real trap + * @param break_trap 作動後のトラップ破壊が確定しているならばTRUE + * @return なし + */ void hit_trap(player_type *trapped_ptr, bool break_trap) { int i, num, dam; @@ -640,6 +645,7 @@ void hit_trap(player_type *trapped_ptr, bool break_trap) } } } + break; } diff --git a/src/wizard2.c b/src/wizard2.c index 94bbbe0d1..33d07b0ae 100644 --- a/src/wizard2.c +++ b/src/wizard2.c @@ -17,6 +17,7 @@ #include "dungeon.h" #include "cmd/cmd-dump.h" #include "cmd/cmd-help.h" +#include "cmd/cmd-save.h" #include "util.h" #include "birth.h" #include "selfinfo.h"