• R/O
  • HTTP
  • SSH
  • HTTPS

hengband: Commit

変愚蛮怒のメインリポジトリです


Commit MetaInfo

Revisioned5a7935a0af11126f74ce954069745d0a77333d (tree)
Time2019-06-14 01:10:18
Authordeskull <deskull@user...>
Commiterdeskull

Log Message

[Refactor] #37353 ダンジョンに関する処理を dungeon.c へ移動.

Change Summary

Incremental Difference

--- a/src/dungeon.c
+++ b/src/dungeon.c
@@ -13,3 +13,86 @@ char *d_text;
1313 */
1414 DUNGEON_IDX max_d_idx;
1515 DEPTH *max_dlv;
16+
17+
18+/*!
19+ * @brief これまでに入ったダンジョンの一覧を表示し、選択させる。
20+ * @param note ダンジョンに施す処理記述
21+ * @param y コンソールY座標
22+ * @param x コンソールX座標
23+ * @return 選択されたダンジョンID
24+ */
25+DUNGEON_IDX choose_dungeon(concptr note, POSITION y, POSITION x)
26+{
27+ DUNGEON_IDX select_dungeon;
28+ DUNGEON_IDX i;
29+ int num = 0;
30+ DUNGEON_IDX *dun;
31+
32+ /* Hack -- No need to choose dungeon in some case */
33+ if (lite_town || vanilla_town || ironman_downward)
34+ {
35+ if (max_dlv[DUNGEON_ANGBAND]) return DUNGEON_ANGBAND;
36+ else
37+ {
38+ msg_format(_("まだ%sに入ったことはない。", "You haven't entered %s yet."), d_name + d_info[DUNGEON_ANGBAND].name);
39+ msg_print(NULL);
40+ return 0;
41+ }
42+ }
43+
44+ /* Allocate the "dun" array */
45+ C_MAKE(dun, max_d_idx, DUNGEON_IDX);
46+
47+ screen_save();
48+ for (i = 1; i < max_d_idx; i++)
49+ {
50+ char buf[80];
51+ bool seiha = FALSE;
52+
53+ if (!d_info[i].maxdepth) continue;
54+ if (!max_dlv[i]) continue;
55+ if (d_info[i].final_guardian)
56+ {
57+ if (!r_info[d_info[i].final_guardian].max_num) seiha = TRUE;
58+ }
59+ else if (max_dlv[i] == d_info[i].maxdepth) seiha = TRUE;
60+
61+ sprintf(buf, _(" %c) %c%-12s : 最大 %d 階", " %c) %c%-16s : Max level %d"),
62+ 'a' + num, seiha ? '!' : ' ', d_name + d_info[i].name, (int)max_dlv[i]);
63+ prt(buf, y + num, x);
64+ dun[num++] = i;
65+ }
66+
67+ if (!num)
68+ {
69+ prt(_(" 選べるダンジョンがない。", " No dungeon is available."), y, x);
70+ }
71+
72+ prt(format(_("どのダンジョン%sしますか:", "Which dungeon do you %s?: "), note), 0, 0);
73+ while (1)
74+ {
75+ i = inkey();
76+ if ((i == ESCAPE) || !num)
77+ {
78+ /* Free the "dun" array */
79+ C_KILL(dun, max_d_idx, DUNGEON_IDX);
80+
81+ screen_load();
82+ return 0;
83+ }
84+ if (i >= 'a' && i < ('a' + num))
85+ {
86+ select_dungeon = dun[i - 'a'];
87+ break;
88+ }
89+ else bell();
90+ }
91+ screen_load();
92+
93+ /* Free the "dun" array */
94+ C_KILL(dun, max_d_idx, DUNGEON_IDX);
95+
96+ return select_dungeon;
97+}
98+
--- a/src/dungeon.h
+++ b/src/dungeon.h
@@ -3,6 +3,26 @@
33
44 #define DUNGEON_FEAT_PROB_NUM 3
55
6+#define DUNGEON_ANGBAND 1
7+#define DUNGEON_GALGALS 2
8+#define DUNGEON_ORC 3
9+#define DUNGEON_MAZE 4
10+#define DUNGEON_DRAGON 5
11+#define DUNGEON_GRAVE 6
12+#define DUNGEON_WOOD 7
13+#define DUNGEON_VOLCANO 8
14+#define DUNGEON_HELL 9
15+#define DUNGEON_HEAVEN 10
16+#define DUNGEON_OCEAN 11
17+#define DUNGEON_CASTLE 12
18+#define DUNGEON_CTH 13
19+#define DUNGEON_MOUNTAIN 14
20+#define DUNGEON_GOLD 15
21+#define DUNGEON_NO_MAGIC 16
22+#define DUNGEON_NO_MELEE 17
23+#define DUNGEON_CHAMELEON 18
24+#define DUNGEON_DARKNESS 19
25+
626 /* A structure for the != dungeon types */
727 typedef struct dungeon_type dungeon_type;
828 struct dungeon_type {
@@ -61,4 +81,6 @@ extern DEPTH *max_dlv;
6181 extern DUNGEON_IDX max_d_idx;
6282 extern dungeon_type *d_info;
6383 extern char *d_name;
64-extern char *d_text;
\ No newline at end of file
84+extern char *d_text;
85+
86+extern DUNGEON_IDX choose_dungeon(concptr note, POSITION y, POSITION x);
--- a/src/floor.h
+++ b/src/floor.h
@@ -167,26 +167,6 @@ typedef struct {
167167
168168 #define DF1_LAKE_MASK (DF1_LAKE_WATER | DF1_LAKE_LAVA | DF1_LAKE_RUBBLE | DF1_LAKE_TREE | DF1_LAKE_POISONOUS | DF1_LAKE_ACID)
169169
170-#define DUNGEON_ANGBAND 1
171-#define DUNGEON_GALGALS 2
172-#define DUNGEON_ORC 3
173-#define DUNGEON_MAZE 4
174-#define DUNGEON_DRAGON 5
175-#define DUNGEON_GRAVE 6
176-#define DUNGEON_WOOD 7
177-#define DUNGEON_VOLCANO 8
178-#define DUNGEON_HELL 9
179-#define DUNGEON_HEAVEN 10
180-#define DUNGEON_OCEAN 11
181-#define DUNGEON_CASTLE 12
182-#define DUNGEON_CTH 13
183-#define DUNGEON_MOUNTAIN 14
184-#define DUNGEON_GOLD 15
185-#define DUNGEON_NO_MAGIC 16
186-#define DUNGEON_NO_MELEE 17
187-#define DUNGEON_CHAMELEON 18
188-#define DUNGEON_DARKNESS 19
189-
190170 /*
191171 * Determines if a map location is fully inside the outer walls
192172 */
--- a/src/quest.c
+++ b/src/quest.c
@@ -2,6 +2,7 @@
22 #include "util.h"
33
44 #include "core.h"
5+#include "dungeon.h"
56 #include "floor.h"
67 #include "floor-save.h"
78 #include "floor-events.h"
--- a/src/spells.h
+++ b/src/spells.h
@@ -293,7 +293,6 @@ extern void teleport_player_to(POSITION ny, POSITION nx, BIT_FLAGS mode);
293293 extern void teleport_away_followable(MONSTER_IDX m_idx);
294294 extern bool teleport_level_other(player_type *creature_ptr);
295295 extern void teleport_level(MONSTER_IDX m_idx);
296-extern DUNGEON_IDX choose_dungeon(concptr note, POSITION y, POSITION x);
297296 extern bool recall_player(player_type *creature_ptr, TIME_EFFECT turns);
298297 extern bool free_level_recall(player_type *creature_ptr);
299298 extern bool reset_recall(void);
--- a/src/spells3.c
+++ b/src/spells3.c
@@ -776,89 +776,6 @@ void teleport_level(MONSTER_IDX m_idx)
776776 sound(SOUND_TPLEVEL);
777777 }
778778
779-
780-/*!
781- * @brief これまでに入ったダンジョンの一覧を表示し、選択させる。
782- * @param note ダンジョンに施す処理記述
783- * @param y コンソールY座標
784- * @param x コンソールX座標
785- * @return 選択されたダンジョンID
786- */
787-DUNGEON_IDX choose_dungeon(concptr note, POSITION y, POSITION x)
788-{
789- DUNGEON_IDX select_dungeon;
790- DUNGEON_IDX i;
791- int num = 0;
792- DUNGEON_IDX *dun;
793-
794- /* Hack -- No need to choose dungeon in some case */
795- if (lite_town || vanilla_town || ironman_downward)
796- {
797- if (max_dlv[DUNGEON_ANGBAND]) return DUNGEON_ANGBAND;
798- else
799- {
800- msg_format(_("まだ%sに入ったことはない。", "You haven't entered %s yet."), d_name + d_info[DUNGEON_ANGBAND].name);
801- msg_print(NULL);
802- return 0;
803- }
804- }
805-
806- /* Allocate the "dun" array */
807- C_MAKE(dun, max_d_idx, DUNGEON_IDX);
808-
809- screen_save();
810- for(i = 1; i < max_d_idx; i++)
811- {
812- char buf[80];
813- bool seiha = FALSE;
814-
815- if (!d_info[i].maxdepth) continue;
816- if (!max_dlv[i]) continue;
817- if (d_info[i].final_guardian)
818- {
819- if (!r_info[d_info[i].final_guardian].max_num) seiha = TRUE;
820- }
821- else if (max_dlv[i] == d_info[i].maxdepth) seiha = TRUE;
822-
823- sprintf(buf,_(" %c) %c%-12s : 最大 %d 階", " %c) %c%-16s : Max level %d"),
824- 'a'+num, seiha ? '!' : ' ', d_name + d_info[i].name, (int)max_dlv[i]);
825- prt(buf, y + num, x);
826- dun[num++] = i;
827- }
828-
829- if (!num)
830- {
831- prt(_(" 選べるダンジョンがない。", " No dungeon is available."), y, x);
832- }
833-
834- prt(format(_("どのダンジョン%sしますか:", "Which dungeon do you %s?: "), note), 0, 0);
835- while(1)
836- {
837- i = inkey();
838- if ((i == ESCAPE) || !num)
839- {
840- /* Free the "dun" array */
841- C_KILL(dun, max_d_idx, DUNGEON_IDX);
842-
843- screen_load();
844- return 0;
845- }
846- if (i >= 'a' && i <('a'+num))
847- {
848- select_dungeon = dun[i-'a'];
849- break;
850- }
851- else bell();
852- }
853- screen_load();
854-
855- /* Free the "dun" array */
856- C_KILL(dun, max_d_idx, DUNGEON_IDX);
857-
858- return select_dungeon;
859-}
860-
861-
862779 /*!
863780 * @brief プレイヤーの帰還発動及び中止処理 /
864781 * Recall the player to town or dungeon
Show on old repository browser