OSDN Git Service

[Refactor] #37353 コメント整理。 / Refactor comments.
[hengband/hengband.git] / src / spells2.c
index b526bec..effed82 100644 (file)
@@ -14,6 +14,8 @@
 #include "angband.h"
 #include "grid.h"
 #include "trap.h"
+#include "monsterrace-hook.h"
+#include "melee.h"
 
 
 /*!
@@ -25,7 +27,7 @@
  */
 static bool detect_feat_flag(POSITION range, int flag, bool known)
 {
-       int x, y;
+       POSITION x, y;
        bool detect = FALSE;
        cave_type *c_ptr;
 
@@ -38,8 +40,6 @@ static bool detect_feat_flag(POSITION range, int flag, bool known)
                {
                        int dist = distance(p_ptr->y, p_ptr->x, y, x);
                        if (dist > range) continue;
-
-                       /* Access the grid */
                        c_ptr = &cave[y][x];
 
                        /* Hack -- Safe */
@@ -52,7 +52,6 @@ static bool detect_feat_flag(POSITION range, int flag, bool known)
 
                                        c_ptr->info &= ~(CAVE_UNSAFE);
 
-                                       /* Redraw */
                                        lite_spot(y, x);
                                }
                        }
@@ -66,10 +65,8 @@ static bool detect_feat_flag(POSITION range, int flag, bool known)
                                /* Hack -- Memorize */
                                c_ptr->info |= (CAVE_MARK);
 
-                               /* Redraw */
                                lite_spot(y, x);
 
-                               /* Obvious */
                                detect = TRUE;
                        }
                }
@@ -91,8 +88,6 @@ bool detect_traps(POSITION range, bool known)
        if (known) p_ptr->dtrap = TRUE;
 
        if (music_singing(MUSIC_DETECT) && SINGING_COUNT(p_ptr) > 0) detect = FALSE;
-
-       /* Describe */
        if (detect)
        {
                msg_print(_("トラップの存在を感じとった!", "You sense the presence of traps!"));
@@ -111,8 +106,6 @@ bool detect_doors(POSITION range)
        bool detect = detect_feat_flag(range, FF_DOOR, TRUE);
 
        if (music_singing(MUSIC_DETECT) && SINGING_COUNT(p_ptr) > 0) detect = FALSE;
-
-       /* Describe */
        if (detect)
        {
                msg_print(_("ドアの存在を感じとった!", "You sense the presence of doors!"));
@@ -131,8 +124,6 @@ bool detect_stairs(POSITION range)
        bool detect = detect_feat_flag(range, FF_STAIRS, TRUE);
 
        if (music_singing(MUSIC_DETECT) && SINGING_COUNT(p_ptr) > 0) detect = FALSE;
-
-       /* Describe */
        if (detect)
        {
                msg_print(_("階段の存在を感じとった!", "You sense the presence of stairs!"));
@@ -151,8 +142,6 @@ bool detect_treasure(POSITION range)
        bool detect = detect_feat_flag(range, FF_HAS_GOLD, TRUE);
 
        if (music_singing(MUSIC_DETECT) && SINGING_COUNT(p_ptr) > 6) detect = FALSE;
-
-       /* Describe */
        if (detect)
        {
                msg_print(_("埋蔵された財宝の存在を感じとった!", "You sense the presence of buried treasure!"));
@@ -168,7 +157,8 @@ bool detect_treasure(POSITION range)
  */
 bool detect_objects_gold(POSITION range)
 {
-       int i, y, x;
+       OBJECT_IDX i;
+       POSITION y, x;
        POSITION range2 = range;
 
        bool detect = FALSE;
@@ -202,8 +192,6 @@ bool detect_objects_gold(POSITION range)
        }
 
        if (music_singing(MUSIC_DETECT) && SINGING_COUNT(p_ptr) > 6) detect = FALSE;
-
-       /* Describe */
        if (detect)
        {
                msg_print(_("財宝の存在を感じとった!", "You sense the presence of treasure!"));
@@ -224,7 +212,8 @@ bool detect_objects_gold(POSITION range)
  */
 bool detect_objects_normal(POSITION range)
 {
-       int i, y, x;
+       OBJECT_IDX i;
+       POSITION y, x;
        POSITION range2 = range;
 
        bool detect = FALSE;
@@ -258,8 +247,6 @@ bool detect_objects_normal(POSITION range)
        }
 
        if (music_singing(MUSIC_DETECT) && SINGING_COUNT(p_ptr) > 6) detect = FALSE;
-
-       /* Describe */
        if (detect)
        {
                msg_print(_("アイテムの存在を感じとった!", "You sense the presence of objects!"));
@@ -288,7 +275,9 @@ bool detect_objects_normal(POSITION range)
  */
 bool detect_objects_magic(POSITION range)
 {
-       int i, y, x, tv;
+       OBJECT_TYPE_VALUE tv;
+       OBJECT_IDX i;
+       POSITION y, x;
 
        bool detect = FALSE;
 
@@ -346,8 +335,6 @@ bool detect_objects_magic(POSITION range)
                        detect = TRUE;
                }
        }
-
-       /* Describe */
        if (detect)
        {
                msg_print(_("魔法のアイテムの存在を感じとった!", "You sense the presence of magic objects!"));
@@ -367,12 +354,10 @@ bool detect_monsters_normal(POSITION range)
 {
        MONSTER_IDX i;
        POSITION y, x;
-
        bool flag = FALSE;
 
        if (d_info[dungeon_type].flags1 & DF1_DARKNESS) range /= 3;
 
-       /* Scan monsters */
        for (i = 1; i < m_max; i++)
        {
                monster_type *m_ptr = &m_list[i];
@@ -393,21 +378,15 @@ bool detect_monsters_normal(POSITION range)
                        /* Repair visibility later */
                        repair_monsters = TRUE;
 
-                       /* Hack -- Detect monster */
                        m_ptr->mflag2 |= (MFLAG2_MARK | MFLAG2_SHOW);
-
-                       /* Update the monster */
-                       update_mon(i, FALSE);
+                       update_monster(i, FALSE);
                        flag = TRUE;
                }
        }
 
        if (music_singing(MUSIC_DETECT) && SINGING_COUNT(p_ptr) > 3) flag = FALSE;
-
-       /* Describe */
        if (flag)
        {
-               /* Describe result */
                msg_print(_("モンスターの存在を感じとった!", "You sense the presence of monsters!"));
        }
        return (flag);
@@ -427,7 +406,6 @@ bool detect_monsters_invis(POSITION range)
 
        if (d_info[dungeon_type].flags1 & DF1_DARKNESS) range /= 3;
 
-       /* Scan monsters */
        for (i = 1; i < m_max; i++)
        {
                monster_type *m_ptr = &m_list[i];
@@ -454,21 +432,15 @@ bool detect_monsters_invis(POSITION range)
                        /* Repair visibility later */
                        repair_monsters = TRUE;
 
-                       /* Hack -- Detect monster */
                        m_ptr->mflag2 |= (MFLAG2_MARK | MFLAG2_SHOW);
-
-                       /* Update the monster */
-                       update_mon(i, FALSE);
+                       update_monster(i, FALSE);
                        flag = TRUE;
                }
        }
 
        if (music_singing(MUSIC_DETECT) && SINGING_COUNT(p_ptr) > 3) flag = FALSE;
-
-       /* Describe */
        if (flag)
        {
-               /* Describe result */
                msg_print(_("透明な生物の存在を感じとった!", "You sense the presence of invisible creatures!"));
        }
        return (flag);
@@ -487,7 +459,6 @@ bool detect_monsters_evil(POSITION range)
 
        if (d_info[dungeon_type].flags1 & DF1_DARKNESS) range /= 3;
 
-       /* Scan monsters */
        for (i = 1; i < m_max; i++)
        {
                monster_type *m_ptr = &m_list[i];
@@ -520,19 +491,13 @@ bool detect_monsters_evil(POSITION range)
                        /* Repair visibility later */
                        repair_monsters = TRUE;
 
-                       /* Hack -- Detect monster */
                        m_ptr->mflag2 |= (MFLAG2_MARK | MFLAG2_SHOW);
-
-                       /* Update the monster */
-                       update_mon(i, FALSE);
+                       update_monster(i, FALSE);
                        flag = TRUE;
                }
        }
-
-       /* Describe */
        if (flag)
        {
-               /* Describe result */
                msg_print(_("邪悪なる生物の存在を感じとった!", "You sense the presence of evil creatures!"));
        }
        return (flag);
@@ -551,11 +516,9 @@ bool detect_monsters_nonliving(POSITION range)
 
        if (d_info[dungeon_type].flags1 & DF1_DARKNESS) range /= 3;
 
-       /* Scan monsters */
        for (i = 1; i < m_max; i++)
        {
                monster_type *m_ptr = &m_list[i];
-               monster_race *r_ptr = &r_info[m_ptr->r_idx];
 
                /* Skip dead monsters */
                if (!m_ptr->r_idx) continue;
@@ -567,7 +530,7 @@ bool detect_monsters_nonliving(POSITION range)
                if (distance(p_ptr->y, p_ptr->x, y, x) > range) continue;
 
                /* Detect non-living monsters */
-               if (!monster_living(r_ptr))
+               if (!monster_living(m_ptr->r_idx))
                {
                        /* Update monster recall window */
                        if (p_ptr->monster_race_idx == m_ptr->r_idx)
@@ -578,19 +541,13 @@ bool detect_monsters_nonliving(POSITION range)
                        /* Repair visibility later */
                        repair_monsters = TRUE;
 
-                       /* Hack -- Detect monster */
                        m_ptr->mflag2 |= (MFLAG2_MARK | MFLAG2_SHOW);
-
-                       /* Update the monster */
-                       update_mon(i, FALSE);
+                       update_monster(i, FALSE);
                        flag = TRUE;
                }
        }
-
-       /* Describe */
        if (flag)
        {
-               /* Describe result */
                msg_print(_("自然でないモンスターの存在を感じた!", "You sense the presence of unnatural beings!"));
        }
        return (flag);
@@ -605,11 +562,10 @@ bool detect_monsters_mind(POSITION range)
 {
        MONSTER_IDX i;
        POSITION y, x;
-       bool    flag = FALSE;
+       bool flag = FALSE;
 
        if (d_info[dungeon_type].flags1 & DF1_DARKNESS) range /= 3;
 
-       /* Scan monsters */
        for (i = 1; i < m_max; i++)
        {
                monster_type *m_ptr = &m_list[i];
@@ -636,19 +592,13 @@ bool detect_monsters_mind(POSITION range)
                        /* Repair visibility later */
                        repair_monsters = TRUE;
 
-                       /* Hack -- Detect monster */
                        m_ptr->mflag2 |= (MFLAG2_MARK | MFLAG2_SHOW);
-
-                       /* Update the monster */
-                       update_mon(i, FALSE);
+                       update_monster(i, FALSE);
                        flag = TRUE;
                }
        }
-
-       /* Describe */
        if (flag)
        {
-               /* Describe result */
                msg_print(_("殺気を感じとった!", "You sense the presence of someone's mind!"));
        }
        return (flag);
@@ -669,7 +619,6 @@ bool detect_monsters_string(POSITION range, cptr Match)
 
        if (d_info[dungeon_type].flags1 & DF1_DARKNESS) range /= 3;
 
-       /* Scan monsters */
        for (i = 1; i < m_max; i++)
        {
                monster_type *m_ptr = &m_list[i];
@@ -696,21 +645,15 @@ bool detect_monsters_string(POSITION range, cptr Match)
                        /* Repair visibility later */
                        repair_monsters = TRUE;
 
-                       /* Hack -- Detect monster */
                        m_ptr->mflag2 |= (MFLAG2_MARK | MFLAG2_SHOW);
-
-                       /* Update the monster */
-                       update_mon(i, FALSE);
+                       update_monster(i, FALSE);
                        flag = TRUE;
                }
        }
 
        if (music_singing(MUSIC_DETECT) && SINGING_COUNT(p_ptr) > 3) flag = FALSE;
-
-       /* Describe */
        if (flag)
        {
-               /* Describe result */
                msg_print(_("モンスターの存在を感じとった!", "You sense the presence of monsters!"));
        }
        return (flag);
@@ -731,7 +674,6 @@ bool detect_monsters_xxx(POSITION range, u32b match_flag)
 
        if (d_info[dungeon_type].flags1 & DF1_DARKNESS) range /= 3;
 
-       /* Scan monsters */
        for (i = 1; i < m_max; i++)
        {
                monster_type *m_ptr = &m_list[i];
@@ -764,16 +706,11 @@ bool detect_monsters_xxx(POSITION range, u32b match_flag)
                        /* Repair visibility later */
                        repair_monsters = TRUE;
 
-                       /* Hack -- Detect monster */
                        m_ptr->mflag2 |= (MFLAG2_MARK | MFLAG2_SHOW);
-
-                       /* Update the monster */
-                       update_mon(i, FALSE);
+                       update_monster(i, FALSE);
                        flag = TRUE;
                }
        }
-
-       /* Describe */
        if (flag)
        {
                switch (match_flag)
@@ -786,7 +723,6 @@ bool detect_monsters_xxx(POSITION range, u32b match_flag)
                                break;
                }
 
-               /* Describe result */
                msg_format(_("%sの存在を感じとった!", "You sense the presence of %s!"), desc_monsters);
                msg_print(NULL);
        }
@@ -1007,8 +943,7 @@ void aggravate_monsters(MONSTER_IDX who)
        /* Aggravate everyone nearby */
        for (i = 1; i < m_max; i++)
        {
-               monster_type    *m_ptr = &m_list[i];
-/*             monster_race    *r_ptr = &r_info[m_ptr->r_idx]; */
+               monster_type *m_ptr = &m_list[i];
 
                /* Paranoia -- Skip dead monsters */
                if (!m_ptr->r_idx) continue;
@@ -1116,22 +1051,18 @@ bool genocide_aux(MONSTER_IDX m_idx, int power, bool player_cast, int dam_side,
 
        if (player_cast)
        {
-               /* Take damage */
                take_hit(DAMAGE_GENO, randint1(dam_side), format(_("%^sの呪文を唱えた疲労", "the strain of casting %^s"), spell_name), -1);
        }
 
        /* Visual feedback */
        move_cursor_relative(p_ptr->y, p_ptr->x);
 
-       /* Redraw */
        p_ptr->redraw |= (PR_HP);
        p_ptr->window |= (PW_PLAYER);
 
-       /* Handle */
        handle_stuff();
        Term_fresh();
 
-       /* Delay */
        Term_xtra(TERM_XTRA_DELAY, msec);
 
        return !resist;
@@ -1278,7 +1209,8 @@ bool mass_genocide_undead(int power, bool player_cast)
  */
 bool probing(void)
 {
-       int i, speed;
+       int i;
+       int speed; /* TODO */
        bool_hack cu, cv;
        bool probe = FALSE;
        char buf[256];
@@ -1362,8 +1294,9 @@ bool probing(void)
 
                        /* HACK : Add the line to message buffer */
                        message_add(buf);
+
                        p_ptr->window |= (PW_MESSAGE);
-                       window_stuff();
+                       handle_stuff();
 
                        if (m_ptr->ml) move_cursor_relative(m_ptr->fy, m_ptr->fx);
                        inkey();
@@ -1429,7 +1362,7 @@ bool destroy_area(POSITION y1, POSITION x1, POSITION r, bool in_generate)
        POSITION y, x;
        int k, t;
        cave_type *c_ptr;
-       bool      flag = FALSE;
+       bool flag = FALSE;
 
        /* Prevent destruction of quest levels and town */
        if ((p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest)) || !dun_level)
@@ -1453,8 +1386,6 @@ bool destroy_area(POSITION y1, POSITION x1, POSITION r, bool in_generate)
 
                        /* Stay in the circle of death */
                        if (k > r) continue;
-
-                       /* Access the grid */
                        c_ptr = &cave[y][x];
 
                        /* Lose room and vault */
@@ -1524,8 +1455,6 @@ bool destroy_area(POSITION y1, POSITION x1, POSITION r, bool in_generate)
                                for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
                                {
                                        object_type *o_ptr;
-
-                                       /* Acquire object */
                                        o_ptr = &o_list[this_o_idx];
 
                                        /* Acquire next object */
@@ -1629,8 +1558,6 @@ bool destroy_area(POSITION y1, POSITION x1, POSITION r, bool in_generate)
 
                                /* Stay in the circle of death */
                                if (k > r) continue;
-
-                               /* Access the grid */
                                c_ptr = &cave[y][x];
 
                                if (is_mirror_grid(c_ptr)) c_ptr->info |= CAVE_GLOW;
@@ -1675,7 +1602,6 @@ bool destroy_area(POSITION y1, POSITION x1, POSITION r, bool in_generate)
 
                p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE | PU_MONSTERS);
 
-               /* Redraw map */
                p_ptr->redraw |= (PR_MAP);
 
                p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
@@ -1763,8 +1689,6 @@ bool earthquake_aux(POSITION cy, POSITION cx, POSITION r, MONSTER_IDX m_idx)
 
                        /* Skip distant grids */
                        if (distance(cy, cx, yy, xx) > r) continue;
-
-                       /* Access the grid */
                        c_ptr = &cave[yy][xx];
 
                        /* Lose room and vault */
@@ -1878,7 +1802,6 @@ bool earthquake_aux(POSITION cy, POSITION cx, POSITION r, MONSTER_IDX m_idx)
                /* Important -- no wall on player */
                map[16+p_ptr->y-cy][16+p_ptr->x-cx] = FALSE;
 
-               /* Take some damage */
                if (damage)
                {
                        cptr killer;
@@ -1913,8 +1836,6 @@ bool earthquake_aux(POSITION cy, POSITION cx, POSITION r, MONSTER_IDX m_idx)
 
                        /* Skip unaffected grids */
                        if (!map[16+yy-cy][16+xx-cx]) continue;
-
-                       /* Access the grid */
                        c_ptr = &cave[yy][xx];
 
                        if (c_ptr->m_idx == p_ptr->riding) continue;
@@ -1949,7 +1870,6 @@ bool earthquake_aux(POSITION cy, POSITION cx, POSITION r, MONSTER_IDX m_idx)
                                                /* Look for safety */
                                                for (i = 0; i < 8; i++)
                                                {
-                                                       /* Access the grid */
                                                        y = yy + ddy_ddd[i];
                                                        x = xx + ddx_ddd[i];
 
@@ -2035,7 +1955,7 @@ bool earthquake_aux(POSITION cy, POSITION cx, POSITION r, MONSTER_IDX m_idx)
                                                m_ptr->fx = sx;
 
                                                /* Update the monster (new location) */
-                                               update_mon(m_idx, TRUE);
+                                               update_monster(m_idx, TRUE);
 
                                                /* Redraw the old grid */
                                                lite_spot(yy, xx);
@@ -2124,8 +2044,6 @@ bool earthquake_aux(POSITION cy, POSITION cx, POSITION r, MONSTER_IDX m_idx)
 
                        /* Skip distant grids */
                        if (distance(cy, cx, yy, xx) > r) continue;
-
-                       /* Access the grid */
                        c_ptr = &cave[yy][xx];
 
                        if (is_mirror_grid(c_ptr)) c_ptr->info |= CAVE_GLOW;
@@ -2159,7 +2077,6 @@ bool earthquake_aux(POSITION cy, POSITION cx, POSITION r, MONSTER_IDX m_idx)
        /* Update the health bar */
        p_ptr->redraw |= (PR_HEALTH | PR_UHEALTH);
 
-       /* Redraw map */
        p_ptr->redraw |= (PR_MAP);
 
        p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
@@ -2290,9 +2207,7 @@ static void cave_temp_room_lite(void)
                        monster_type    *m_ptr = &m_list[c_ptr->m_idx];
 
                        monster_race    *r_ptr = &r_info[m_ptr->r_idx];
-
-                       /* Update the monster */
-                       update_mon(c_ptr->m_idx, FALSE);
+                       update_monster(c_ptr->m_idx, FALSE);
 
                        /* Stupid monsters rarely wake up */
                        if (r_ptr->flags2 & (RF2_STUPID)) chance = 10;
@@ -2310,11 +2225,7 @@ static void cave_temp_room_lite(void)
                                if (m_ptr->ml)
                                {
                                        char m_name[80];
-
-                                       /* Acquire the monster name */
                                        monster_desc(m_name, m_ptr, 0);
-
-                                       /* Dump a message */
                                        msg_format(_("%^sが目を覚ました。", "%^s wakes up."), m_name);
                                }
                        }
@@ -2323,7 +2234,6 @@ static void cave_temp_room_lite(void)
                /* Note */
                note_spot(y, x);
 
-               /* Redraw */
                lite_spot(y, x);
 
                update_local_illumination(y, x);
@@ -2403,11 +2313,9 @@ static void cave_temp_room_unlite(void)
                        /* Process affected monsters */
                        if (c_ptr->m_idx)
                        {
-                               /* Update the monster */
-                               update_mon(c_ptr->m_idx, FALSE);
+                               update_monster(c_ptr->m_idx, FALSE);
                        }
 
-                       /* Redraw */
                        lite_spot(y, x);
 
                        update_local_illumination(y, x);
@@ -3394,7 +3302,6 @@ bool wall_stone(void)
 
        p_ptr->update |= (PU_FLOW);
 
-       /* Redraw map */
        p_ptr->redraw |= (PR_MAP);
 
        return dummy;
@@ -4069,9 +3976,7 @@ bool rush_attack(bool *mdeath)
 
                /* Move player before updating the monster */
                if (!player_bold(ty, tx)) teleport_player_to(ty, tx, TELEPORT_NONMAGICAL);
-
-               /* Update the monster */
-               update_mon(cave[ny][nx].m_idx, TRUE);
+               update_monster(cave[ny][nx].m_idx, TRUE);
 
                /* Found a monster */
                m_ptr = &m_list[cave[ny][nx].m_idx];
@@ -4872,7 +4777,7 @@ bool_hack life_stream(bool_hack message, bool_hack virtue)
        (void)set_cut(0);
        (void)restore_all_status();
        (void)set_shero(0, TRUE);
-       update_stuff();
+       handle_stuff();
        hp_player(5000);
 
        return TRUE;