変愚蛮怒のメインリポジトリです
修訂 | 52643e62c770df70ce16c0c2af9e5c5511aa55c4 (tree) |
---|---|
時間 | 2020-03-08 17:59:00 |
作者 | Hourier <hourier@user...> |
Commiter | Hourier |
[Refactor] #40236 Separated write_floor() from exe_write_diary()
@@ -22,15 +22,15 @@ bool write_level; | ||
22 | 22 | * @param disable_diary 日記への追加を無効化する場合TRUE |
23 | 23 | * @return ファイルがあったらTRUE、なかったらFALSE |
24 | 24 | */ |
25 | -static bool open_diary_file(FILE *fff, bool *disable_diary) | |
25 | +static bool open_diary_file(FILE **fff, bool *disable_diary) | |
26 | 26 | { |
27 | 27 | GAME_TEXT file_name[MAX_NLEN]; |
28 | 28 | sprintf(file_name, _("playrecord-%s.txt", "playrec-%s.txt"), savefile_base); |
29 | 29 | char buf[1024]; |
30 | 30 | path_build(buf, sizeof(buf), ANGBAND_DIR_USER, file_name); |
31 | 31 | FILE_TYPE(FILE_TYPE_TEXT); |
32 | - fff = my_fopen(buf, "a"); | |
33 | - if (fff) return TRUE; | |
32 | + *fff = my_fopen(buf, "a"); | |
33 | + if (*fff) return TRUE; | |
34 | 34 | |
35 | 35 | msg_format(_("%s を開くことができませんでした。プレイ記録を一時停止します。", "Failed to open %s. Play-Record is disabled temporarily."), buf); |
36 | 36 | msg_format(NULL); |
@@ -40,6 +40,38 @@ static bool open_diary_file(FILE *fff, bool *disable_diary) | ||
40 | 40 | |
41 | 41 | |
42 | 42 | /*! |
43 | + * @brief フロア情報を日記に追加する | |
44 | + * @param creature_ptr プレーヤーへの参照ポインタ | |
45 | + * @return クエストID | |
46 | + */ | |
47 | +static QUEST_IDX write_floor(player_type *creature_ptr, concptr *note_level) | |
48 | +{ | |
49 | + floor_type *floor_ptr = creature_ptr->current_floor_ptr; | |
50 | + QUEST_IDX q_idx = quest_number(creature_ptr, floor_ptr->dun_level); | |
51 | + if (!write_level) return q_idx; | |
52 | + | |
53 | + if (floor_ptr->inside_arena) | |
54 | + *note_level = _("アリーナ:", "Arane:"); | |
55 | + else if (!floor_ptr->dun_level) | |
56 | + *note_level = _("地上:", "Surface:"); | |
57 | + else if (q_idx && (is_fixed_quest_idx(q_idx) && !((q_idx == QUEST_OBERON) || (q_idx == QUEST_SERPENT)))) | |
58 | + *note_level = _("クエスト:", "Quest:"); | |
59 | + else | |
60 | + { | |
61 | + char note_level_buf[40]; | |
62 | +#ifdef JP | |
63 | + sprintf(note_level_buf, "%d階(%s):", (int)floor_ptr->dun_level, d_name + d_info[creature_ptr->dungeon_idx].name); | |
64 | +#else | |
65 | + sprintf(note_level_buf, "%s L%d:", d_name + d_info[creature_ptr->dungeon_idx].name, (int)floor_ptr->dun_level); | |
66 | +#endif | |
67 | + *note_level = note_level_buf; | |
68 | + } | |
69 | + | |
70 | + return q_idx; | |
71 | +} | |
72 | + | |
73 | + | |
74 | +/*! | |
43 | 75 | * @brief ペットに関する日記を追加する |
44 | 76 | * @param fff 日記ファイル |
45 | 77 | * @param num 日記へ追加する内容番号 |
@@ -133,30 +165,10 @@ errr exe_write_diary(player_type *creature_ptr, int type, int num, concptr note) | ||
133 | 165 | } |
134 | 166 | |
135 | 167 | FILE *fff = NULL; |
136 | - if (!open_diary_file(fff, &disable_diary)) return -1; | |
168 | + if (!open_diary_file(&fff, &disable_diary)) return -1; | |
137 | 169 | |
138 | - QUEST_IDX q_idx = quest_number(creature_ptr, creature_ptr->current_floor_ptr->dun_level); | |
139 | 170 | concptr note_level = ""; |
140 | - if (write_level) | |
141 | - { | |
142 | - if (creature_ptr->current_floor_ptr->inside_arena) | |
143 | - note_level = _("アリーナ:", "Arane:"); | |
144 | - else if (!creature_ptr->current_floor_ptr->dun_level) | |
145 | - note_level = _("地上:", "Surface:"); | |
146 | - else if (q_idx && (is_fixed_quest_idx(q_idx) | |
147 | - && !((q_idx == QUEST_OBERON) || (q_idx == QUEST_SERPENT)))) | |
148 | - note_level = _("クエスト:", "Quest:"); | |
149 | - else | |
150 | - { | |
151 | - char note_level_buf[40]; | |
152 | -#ifdef JP | |
153 | - sprintf(note_level_buf, "%d階(%s):", (int)creature_ptr->current_floor_ptr->dun_level, d_name + d_info[creature_ptr->dungeon_idx].name); | |
154 | -#else | |
155 | - sprintf(note_level_buf, "%s L%d:", d_name + d_info[creature_ptr->dungeon_idx].name, (int)creature_ptr->current_floor_ptr->dun_level); | |
156 | -#endif | |
157 | - note_level = note_level_buf; | |
158 | - } | |
159 | - } | |
171 | + QUEST_IDX q_idx = write_floor(creature_ptr, ¬e_level); | |
160 | 172 | |
161 | 173 | bool do_level = TRUE; |
162 | 174 | switch (type) |