OSDN Git Service

[Refactor] #37353 object2~trap間整理。 / Refactor between object2 and trap.
authorDeskull <deskull@users.sourceforge.jp>
Mon, 24 Sep 2018 04:15:19 +0000 (13:15 +0900)
committerDeskull <deskull@users.sourceforge.jp>
Mon, 24 Sep 2018 04:15:19 +0000 (13:15 +0900)
13 files changed:
src/externs.h
src/floor-generate.c
src/grid.c
src/init1.c
src/init2.c
src/load.c
src/object2.c
src/rooms-vault.c
src/rooms.c
src/spells1.c
src/spells2.c
src/trap.c
src/trap.h

index 5bada60..e242331 100644 (file)
@@ -1010,10 +1010,6 @@ extern void place_gold(POSITION y, POSITION x);
 extern s16b drop_near(object_type *o_ptr, int chance, int y, int x);
 extern void acquirement(POSITION y1, POSITION x1, int num, bool great, bool special, bool known);
 extern void amusement(POSITION y1, POSITION x1, int num, bool known);
-extern void init_normal_traps(void);
-extern s16b choose_random_trap(void);
-extern void disclose_grid(POSITION y, POSITION x);
-extern void place_trap(POSITION y, POSITION x);
 extern void inven_item_charges(int item);
 extern void inven_item_describe(int item);
 extern void inven_item_increase(int item, int num);
index c500ac1..9992d13 100644 (file)
 #include "grid.h"
 #include "rooms.h"
 #include "streams.h"
+#include "trap.h"
 
 int dun_tun_rnd; 
 int dun_tun_chg;
index 9cd60cf..6114c46 100644 (file)
@@ -15,6 +15,7 @@
 #include "angband.h"
 #include "generate.h"
 #include "grid.h"
+#include "trap.h"
 
 
 /*!
index 2e2353e..4e70c73 100644 (file)
@@ -47,6 +47,7 @@
  */
 
 #include "angband.h"
+#include "trap.h"
 
 
 
index 0a330c5..b744d54 100644 (file)
@@ -35,6 +35,7 @@
 #include "angband.h"
 
 #include "init.h"
+#include "trap.h"
 
 #ifndef MACINTOSH
 #ifdef CHECK_MODIFICATION_TIME
index 2d2cdfe..5ae5d29 100644 (file)
@@ -42,6 +42,7 @@
 
 #include "angband.h"
 #include "generate.h"
+#include "trap.h"
 
 
 /*
index 38228df..051e735 100644 (file)
@@ -5592,128 +5592,6 @@ void amusement(POSITION y1, POSITION x1, int num, bool known)
 }
 
 
-#define MAX_NORMAL_TRAPS 18
-
-/* See init_feat_variables() in init2.c */
-static s16b normal_traps[MAX_NORMAL_TRAPS];
-
-/*!
- * @brief タグに従って、基本トラップテーブルを初期化する / Initialize arrays for normal traps
- * @return なし
- */
-void init_normal_traps(void)
-{
-       int cur_trap = 0;
-
-       normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_TRAPDOOR");
-       normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_PIT");
-       normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_SPIKED_PIT");
-       normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_POISON_PIT");
-       normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_TY_CURSE");
-       normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_TELEPORT");
-       normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_FIRE");
-       normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_ACID");
-       normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_SLOW");
-       normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_LOSE_STR");
-       normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_LOSE_DEX");
-       normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_LOSE_CON");
-       normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_BLIND");
-       normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_CONFUSE");
-       normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_POISON");
-       normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_SLEEP");
-       normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_TRAPS");
-       normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_ALARM");
-}
-
-/*!
- * @brief 基本トラップをランダムに選択する /
- * Get random trap
- * @return 選択したトラップのID
- * @details
- * XXX XXX XXX This routine should be redone to reflect trap "level".\n
- * That is, it does not make sense to have spiked pits at 50 feet.\n
- * Actually, it is not this routine, but the "trap instantiation"\n
- * code, which should also check for "trap doors" on quest levels.\n
- */
-s16b choose_random_trap(void)
-{
-       s16b feat;
-
-       /* Pick a trap */
-       while (1)
-       {
-               /* Hack -- pick a trap */
-               feat = normal_traps[randint0(MAX_NORMAL_TRAPS)];
-
-               /* Accept non-trapdoors */
-               if (!have_flag(f_info[feat].flags, FF_MORE)) break;
-
-               /* Hack -- no trap doors on special levels */
-               if (p_ptr->inside_arena || quest_number(dun_level)) continue;
-
-               /* Hack -- no trap doors on the deepest level */
-               if (dun_level >= d_info[dungeon_type].maxdepth) continue;
-
-               break;
-       }
-
-       return feat;
-}
-
-/*!
- * @brief マスに存在するトラップを秘匿する /
- * Disclose an invisible trap
- * @param y 秘匿したいマスのY座標
- * @param x 秘匿したいマスのX座標
- * @return なし
- */
-void disclose_grid(POSITION y, POSITION x)
-{
-       cave_type *c_ptr = &cave[y][x];
-
-       if (cave_have_flag_grid(c_ptr, FF_SECRET))
-       {
-               /* No longer hidden */
-               cave_alter_feat(y, x, FF_SECRET);
-       }
-       else if (c_ptr->mimic)
-       {
-               /* No longer hidden */
-               c_ptr->mimic = 0;
-
-               /* Notice */
-               note_spot(y, x);
-
-               /* Redraw */
-               lite_spot(y, x);
-       }
-}
-
-/*!
- * @brief マスをトラップを配置する /
- * The location must be a legal, naked, floor grid.
- * @param y 配置したいマスのY座標
- * @param x 配置したいマスのX座標
- * @return
- * Note that all traps start out as "invisible" and "untyped", and then\n
- * when they are "discovered" (by detecting them or setting them off),\n
- * the trap is "instantiated" as a visible, "typed", trap.\n
- */
-void place_trap(POSITION y, POSITION x)
-{
-       cave_type *c_ptr = &cave[y][x];
-
-       /* Paranoia -- verify location */
-       if (!in_bounds(y, x)) return;
-
-       /* Require empty, clean, floor grid */
-       if (!cave_clean_bold(y, x)) return;
-
-       /* Place an invisible trap */
-       c_ptr->mimic = c_ptr->feat;
-       c_ptr->feat = choose_random_trap();
-}
-
 /*!
  * @brief 魔道具の使用回数の残量を示すメッセージを表示する /
  * Describe the charges on an item in the inventory.
index e264a2b..b8d3513 100644 (file)
@@ -2,6 +2,7 @@
 #include "grid.h"\r
 #include "rooms.h"\r
 #include "generate.h"\r
+#include "trap.h"\r
 \r
 /*\r
 * This function creates a random vault that looks like a collection of bubbles.\r
index 4a91eb7..8640ae1 100644 (file)
@@ -49,6 +49,8 @@
 #include "rooms-trap.h"
 #include "rooms-vault.h"
 
+#include "trap.h"
+
 
 /*!
  * 各部屋タイプの生成比定義
index deae243..1cd52ed 100644 (file)
@@ -13,6 +13,7 @@
 
 #include "angband.h"
 #include "cmd-pet.h"
+#include "trap.h"
 
 
 static int rakubadam_m; /*!< 振り落とされた際のダメージ量 */
index aa6b805..df0cc85 100644 (file)
@@ -13,6 +13,7 @@
 
 #include "angband.h"
 #include "grid.h"
+#include "trap.h"
 
 
 /*!
index a8c13b4..dadaac1 100644 (file)
@@ -1,4 +1,126 @@
 #include "angband.h"\r
+#include "trap.h"\r
+\r
+static s16b normal_traps[MAX_NORMAL_TRAPS];\r
+\r
+\r
+/*!\r
+* @brief \83^\83O\82É\8f]\82Á\82Ä\81A\8aî\96{\83g\83\89\83b\83v\83e\81[\83u\83\8b\82ð\8f\89\8aú\89»\82·\82é / Initialize arrays for normal traps\r
+* @return \82È\82µ\r
+*/\r
+void init_normal_traps(void)\r
+{\r
+       int cur_trap = 0;\r
+\r
+       normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_TRAPDOOR");\r
+       normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_PIT");\r
+       normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_SPIKED_PIT");\r
+       normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_POISON_PIT");\r
+       normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_TY_CURSE");\r
+       normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_TELEPORT");\r
+       normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_FIRE");\r
+       normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_ACID");\r
+       normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_SLOW");\r
+       normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_LOSE_STR");\r
+       normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_LOSE_DEX");\r
+       normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_LOSE_CON");\r
+       normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_BLIND");\r
+       normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_CONFUSE");\r
+       normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_POISON");\r
+       normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_SLEEP");\r
+       normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_TRAPS");\r
+       normal_traps[cur_trap++] = f_tag_to_index_in_init("TRAP_ALARM");\r
+}\r
+\r
+/*!\r
+* @brief \8aî\96{\83g\83\89\83b\83v\82ð\83\89\83\93\83_\83\80\82É\91I\91ð\82·\82é /\r
+* Get random trap\r
+* @return \91I\91ð\82µ\82½\83g\83\89\83b\83v\82ÌID\r
+* @details\r
+* XXX XXX XXX This routine should be redone to reflect trap "level".\n\r
+* That is, it does not make sense to have spiked pits at 50 feet.\n\r
+* Actually, it is not this routine, but the "trap instantiation"\n\r
+* code, which should also check for "trap doors" on quest levels.\n\r
+*/\r
+s16b choose_random_trap(void)\r
+{\r
+       s16b feat;\r
+\r
+       /* Pick a trap */\r
+       while (1)\r
+       {\r
+               /* Hack -- pick a trap */\r
+               feat = normal_traps[randint0(MAX_NORMAL_TRAPS)];\r
+\r
+               /* Accept non-trapdoors */\r
+               if (!have_flag(f_info[feat].flags, FF_MORE)) break;\r
+\r
+               /* Hack -- no trap doors on special levels */\r
+               if (p_ptr->inside_arena || quest_number(dun_level)) continue;\r
+\r
+               /* Hack -- no trap doors on the deepest level */\r
+               if (dun_level >= d_info[dungeon_type].maxdepth) continue;\r
+\r
+               break;\r
+       }\r
+\r
+       return feat;\r
+}\r
+\r
+/*!\r
+* @brief \83}\83X\82É\91\8dÝ\82·\82é\83g\83\89\83b\83v\82ð\94é\93½\82·\82é /\r
+* Disclose an invisible trap\r
+* @param y \94é\93½\82µ\82½\82¢\83}\83X\82ÌY\8dÀ\95W\r
+* @param x \94é\93½\82µ\82½\82¢\83}\83X\82ÌX\8dÀ\95W\r
+* @return \82È\82µ\r
+*/\r
+void disclose_grid(POSITION y, POSITION x)\r
+{\r
+       cave_type *c_ptr = &cave[y][x];\r
+\r
+       if (cave_have_flag_grid(c_ptr, FF_SECRET))\r
+       {\r
+               /* No longer hidden */\r
+               cave_alter_feat(y, x, FF_SECRET);\r
+       }\r
+       else if (c_ptr->mimic)\r
+       {\r
+               /* No longer hidden */\r
+               c_ptr->mimic = 0;\r
+\r
+               /* Notice */\r
+               note_spot(y, x);\r
+\r
+               /* Redraw */\r
+               lite_spot(y, x);\r
+       }\r
+}\r
+\r
+/*!\r
+* @brief \83}\83X\82ð\83g\83\89\83b\83v\82ð\94z\92u\82·\82é /\r
+* The location must be a legal, naked, floor grid.\r
+* @param y \94z\92u\82µ\82½\82¢\83}\83X\82ÌY\8dÀ\95W\r
+* @param x \94z\92u\82µ\82½\82¢\83}\83X\82ÌX\8dÀ\95W\r
+* @return\r
+* Note that all traps start out as "invisible" and "untyped", and then\n\r
+* when they are "discovered" (by detecting them or setting them off),\n\r
+* the trap is "instantiated" as a visible, "typed", trap.\n\r
+*/\r
+void place_trap(POSITION y, POSITION x)\r
+{\r
+       cave_type *c_ptr = &cave[y][x];\r
+\r
+       /* Paranoia -- verify location */\r
+       if (!in_bounds(y, x)) return;\r
+\r
+       /* Require empty, clean, floor grid */\r
+       if (!cave_clean_bold(y, x)) return;\r
+\r
+       /* Place an invisible trap */\r
+       c_ptr->mimic = c_ptr->feat;\r
+       c_ptr->feat = choose_random_trap();\r
+}\r
+\r
 \r
 \r
 /*!\r
index 1ac7b53..7ccdf0d 100644 (file)
@@ -1,2 +1,10 @@
-void hit_trap(bool break_trap);\r
 \r
+extern void init_normal_traps(void);\r
+extern s16b choose_random_trap(void);\r
+extern void disclose_grid(POSITION y, POSITION x);\r
+extern void place_trap(POSITION y, POSITION x);\r
+extern void hit_trap(bool break_trap);\r
+\r
+#define MAX_NORMAL_TRAPS 18\r
+\r
+/* See init_feat_variables() in init2.c */\r