OSDN Git Service

[Refactor] #37353 stair_creation() を spells-floor.c/h に移動。
authordeskull <deskull@users.sourceforge.jp>
Wed, 17 Apr 2019 13:41:42 +0000 (22:41 +0900)
committerdeskull <deskull@users.sourceforge.jp>
Wed, 17 Apr 2019 13:41:42 +0000 (22:41 +0900)
src/externs.h
src/floor-save.c
src/grid.h
src/spells-floor.c
src/spells-floor.h

index cf310d6..aeec91f 100644 (file)
@@ -597,7 +597,6 @@ extern saved_floor_type *get_sf_ptr(FLOOR_IDX floor_id);
 extern FLOOR_IDX get_new_floor_id(void);
 extern void prepare_change_floor_mode(BIT_FLAGS mode);
 extern void precalc_cur_num_of_pet(void);
-extern void stair_creation(void);
 
 /* init1.c */
 extern TERM_COLOR color_char_to_attr(SYMBOL_CODE c);
index ddb64a5..6d521b9 100644 (file)
@@ -734,12 +734,6 @@ static void get_out_monster(void)
 }
 
 /*!
- * マス構造体のspecial要素を利用する地形かどうかを判定するマクロ / Is this feature has special meaning (except floor_id) with g_ptr->special?
- */
-#define feat_uses_special(F) (have_flag(f_info[(F)].flags, FF_SPECIAL))
-
-
-/*!
  * @brief 新フロアに移動元フロアに繋がる階段を配置する / Virtually teleport onto the stairs that is connecting between two floors.
  * @param sf_ptr 移動元の保存フロア構造体参照ポインタ
  * @return なし
@@ -1392,128 +1386,3 @@ void change_floor(void)
 
        select_floor_music();
 }
-
-/*!
- * @brief プレイヤーの手による能動的な階段生成処理 /
- * Create stairs at or move previously created stairs into the player location.
- * @return なし
- */
-void stair_creation(void)
-{
-       saved_floor_type *sf_ptr;
-       saved_floor_type *dest_sf_ptr;
-
-       bool up = TRUE;
-       bool down = TRUE;
-       FLOOR_IDX dest_floor_id = 0;
-
-
-       /* Forbid up staircases on Ironman mode */
-       if (ironman_downward) up = FALSE;
-
-       /* Forbid down staircases on quest level */
-       if (quest_number(current_floor_ptr->dun_level) || (current_floor_ptr->dun_level >= d_info[p_ptr->dungeon_idx].maxdepth)) down = FALSE;
-
-       /* No effect out of standard dungeon floor */
-       if (!current_floor_ptr->dun_level || (!up && !down) ||
-           (p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) ||
-           p_ptr->inside_arena || p_ptr->inside_battle)
-       {
-               /* arena or quest */
-               msg_print(_("効果がありません!", "There is no effect!"));
-               return;
-       }
-
-       /* Artifacts resists */
-       if (!cave_valid_bold(p_ptr->y, p_ptr->x))
-       {
-               msg_print(_("床上のアイテムが呪文を跳ね返した。", "The object resists the spell."));
-               return;
-       }
-
-       /* Destroy all objects in the grid */
-       delete_object(p_ptr->y, p_ptr->x);
-
-       /* Extract current floor data */
-       sf_ptr = get_sf_ptr(p_ptr->floor_id);
-       if (!sf_ptr)
-       {
-               /* No floor id? -- Create now! */
-               p_ptr->floor_id = get_new_floor_id();
-               sf_ptr = get_sf_ptr(p_ptr->floor_id);
-       } 
-
-       /* Choose randomly */
-       if (up && down)
-       {
-               if (randint0(100) < 50) up = FALSE;
-               else down = FALSE;
-       }
-
-       /* Destination is already fixed */
-       if (up)
-       {
-               if (sf_ptr->upper_floor_id) dest_floor_id = sf_ptr->upper_floor_id;
-       }
-       else
-       {
-               if (sf_ptr->lower_floor_id) dest_floor_id = sf_ptr->lower_floor_id;
-       }
-
-
-       /* Search old stairs leading to the destination */
-       if (dest_floor_id)
-       {
-               POSITION x, y;
-
-               for (y = 0; y < current_floor_ptr->height; y++)
-               {
-                       for (x = 0; x < current_floor_ptr->width; x++)
-                       {
-                               grid_type *g_ptr = &current_floor_ptr->grid_array[y][x];
-
-                               if (!g_ptr->special) continue;
-                               if (feat_uses_special(g_ptr->feat)) continue;
-                               if (g_ptr->special != dest_floor_id) continue;
-
-                               /* Remove old stairs */
-                               g_ptr->special = 0;
-                               cave_set_feat(y, x, feat_ground_type[randint0(100)]);
-                       }
-               }
-       }
-
-       /* No old destination -- Get new one now */
-       else
-       {
-               dest_floor_id = get_new_floor_id();
-
-               /* Fix it */
-               if (up)
-                       sf_ptr->upper_floor_id = dest_floor_id;
-               else
-                       sf_ptr->lower_floor_id = dest_floor_id;
-       }
-
-       /* Extract destination floor data */
-       dest_sf_ptr = get_sf_ptr(dest_floor_id);
-
-
-       /* Create a staircase */
-       if (up)
-       {
-               cave_set_feat(p_ptr->y, p_ptr->x,
-                       (dest_sf_ptr->last_visit && (dest_sf_ptr->dun_level <= current_floor_ptr->dun_level - 2)) ?
-                       feat_state(feat_up_stair, FF_SHAFT) : feat_up_stair);
-       }
-       else
-       {
-               cave_set_feat(p_ptr->y, p_ptr->x,
-                       (dest_sf_ptr->last_visit && (dest_sf_ptr->dun_level >= current_floor_ptr->dun_level + 2)) ?
-                       feat_state(feat_down_stair, FF_SHAFT) : feat_down_stair);
-       }
-
-
-       /* Connect this stairs to the destination */
-       current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].special = dest_floor_id;
-}
index 91989df..647f30a 100644 (file)
@@ -318,4 +318,10 @@ extern bool is_known_trap(grid_type *g_ptr);
 extern bool is_hidden_door(grid_type *g_ptr);
 extern bool is_mirror_grid(grid_type *g_ptr);
 extern bool is_glyph_grid(grid_type *g_ptr);
-extern bool is_explosive_rune_grid(grid_type *g_ptr);
\ No newline at end of file
+extern bool is_explosive_rune_grid(grid_type *g_ptr);
+
+/*!
+ * マス構造体のspecial要素を利用する地形かどうかを判定するマクロ / Is this feature has special meaning (except floor_id) with g_ptr->special?
+ */
+#define feat_uses_special(F) (have_flag(f_info[(F)].flags, FF_SPECIAL))
+
index 64adc4b..558e309 100644 (file)
@@ -2,6 +2,7 @@
 #include "floor.h"
 #include "spells-floor.h"
 #include "grid.h"
+#include "quest.h"
 
 /*
  * Light up the dungeon using "clairvoyance"
@@ -241,3 +242,128 @@ bool place_mirror(void)
 
        return TRUE;
 }
+
+/*!
+ * @brief プレイヤーの手による能動的な階段生成処理 /
+ * Create stairs at or move previously created stairs into the player location.
+ * @return なし
+ */
+void stair_creation(void)
+{
+       saved_floor_type *sf_ptr;
+       saved_floor_type *dest_sf_ptr;
+
+       bool up = TRUE;
+       bool down = TRUE;
+       FLOOR_IDX dest_floor_id = 0;
+
+
+       /* Forbid up staircases on Ironman mode */
+       if (ironman_downward) up = FALSE;
+
+       /* Forbid down staircases on quest level */
+       if (quest_number(current_floor_ptr->dun_level) || (current_floor_ptr->dun_level >= d_info[p_ptr->dungeon_idx].maxdepth)) down = FALSE;
+
+       /* No effect out of standard dungeon floor */
+       if (!current_floor_ptr->dun_level || (!up && !down) ||
+               (p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) ||
+               p_ptr->inside_arena || p_ptr->inside_battle)
+       {
+               /* arena or quest */
+               msg_print(_("効果がありません!", "There is no effect!"));
+               return;
+       }
+
+       /* Artifacts resists */
+       if (!cave_valid_bold(p_ptr->y, p_ptr->x))
+       {
+               msg_print(_("床上のアイテムが呪文を跳ね返した。", "The object resists the spell."));
+               return;
+       }
+
+       /* Destroy all objects in the grid */
+       delete_object(p_ptr->y, p_ptr->x);
+
+       /* Extract current floor data */
+       sf_ptr = get_sf_ptr(p_ptr->floor_id);
+       if (!sf_ptr)
+       {
+               /* No floor id? -- Create now! */
+               p_ptr->floor_id = get_new_floor_id();
+               sf_ptr = get_sf_ptr(p_ptr->floor_id);
+       }
+
+       /* Choose randomly */
+       if (up && down)
+       {
+               if (randint0(100) < 50) up = FALSE;
+               else down = FALSE;
+       }
+
+       /* Destination is already fixed */
+       if (up)
+       {
+               if (sf_ptr->upper_floor_id) dest_floor_id = sf_ptr->upper_floor_id;
+       }
+       else
+       {
+               if (sf_ptr->lower_floor_id) dest_floor_id = sf_ptr->lower_floor_id;
+       }
+
+
+       /* Search old stairs leading to the destination */
+       if (dest_floor_id)
+       {
+               POSITION x, y;
+
+               for (y = 0; y < current_floor_ptr->height; y++)
+               {
+                       for (x = 0; x < current_floor_ptr->width; x++)
+                       {
+                               grid_type *g_ptr = &current_floor_ptr->grid_array[y][x];
+
+                               if (!g_ptr->special) continue;
+                               if (feat_uses_special(g_ptr->feat)) continue;
+                               if (g_ptr->special != dest_floor_id) continue;
+
+                               /* Remove old stairs */
+                               g_ptr->special = 0;
+                               cave_set_feat(y, x, feat_ground_type[randint0(100)]);
+                       }
+               }
+       }
+
+       /* No old destination -- Get new one now */
+       else
+       {
+               dest_floor_id = get_new_floor_id();
+
+               /* Fix it */
+               if (up)
+                       sf_ptr->upper_floor_id = dest_floor_id;
+               else
+                       sf_ptr->lower_floor_id = dest_floor_id;
+       }
+
+       /* Extract destination floor data */
+       dest_sf_ptr = get_sf_ptr(dest_floor_id);
+
+
+       /* Create a staircase */
+       if (up)
+       {
+               cave_set_feat(p_ptr->y, p_ptr->x,
+                       (dest_sf_ptr->last_visit && (dest_sf_ptr->dun_level <= current_floor_ptr->dun_level - 2)) ?
+                       feat_state(feat_up_stair, FF_SHAFT) : feat_up_stair);
+       }
+       else
+       {
+               cave_set_feat(p_ptr->y, p_ptr->x,
+                       (dest_sf_ptr->last_visit && (dest_sf_ptr->dun_level >= current_floor_ptr->dun_level + 2)) ?
+                       feat_state(feat_down_stair, FF_SHAFT) : feat_down_stair);
+       }
+
+
+       /* Connect this stairs to the destination */
+       current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].special = dest_floor_id;
+}
index 4f468dc..93b4441 100644 (file)
@@ -5,3 +5,4 @@ extern void wiz_dark(void);
 extern bool warding_glyph(void);
 extern bool explosive_rune(void);
 extern bool place_mirror(void);
+extern void stair_creation(void);