OSDN Git Service

[Refactor] #37353 コメント整理。 update_mon()をupdate_monster()に改名。 / Refactor comments and...
[hengband/hengband.git] / src / monster-process.c
index f303d6e..55eff62 100644 (file)
@@ -215,7 +215,7 @@ void mon_take_hit_mon(MONSTER_IDX m_idx, HIT_POINT dam, bool *fear, cptr note, I
        /* Wake it up */
        (void)set_monster_csleep(m_idx, 0);
 
-       if (p_ptr->riding && (m_idx == p_ptr->riding)) disturb(1, 1);
+       if (p_ptr->riding && (m_idx == p_ptr->riding)) disturb(TRUE, TRUE);
 
        if (MON_INVULNER(m_ptr) && randint0(PENETRATE_INVULNERABILITY))
        {
@@ -298,7 +298,7 @@ void mon_take_hit_mon(MONSTER_IDX m_idx, HIT_POINT dam, bool *fear, cptr note, I
                        /* Generate treasure */
                        monster_death(m_idx, FALSE);
 
-                       /* Delete the monster */
+
                        delete_monster_idx(m_idx);
 
                        /* Not afraid */
@@ -338,7 +338,7 @@ void mon_take_hit_mon(MONSTER_IDX m_idx, HIT_POINT dam, bool *fear, cptr note, I
                        /* Hack -- note fear */
                        (*fear) = TRUE;
 
-                       /* XXX XXX XXX Hack -- Add some timed fear */
+                       /* Hack -- Add some timed fear */
                        (void)set_monster_monfear(m_idx, (randint1(10) +
                                (((dam >= m_ptr->hp) && (percentage > 7)) ?
                                20 : ((11 - percentage) * 5))));
@@ -707,7 +707,7 @@ static bool get_fear_moves_aux(MONSTER_IDX m_idx, POSITION *yp, POSITION *xp)
        /* Check nearby grids, diagonals first */
        for (i = 7; i >= 0; i--)
        {
-               int dis, s;
+               POSITION dis, s;
 
                /* Get the location */
                y = fy + ddy_ddd[i];
@@ -764,53 +764,30 @@ static bool get_fear_moves_aux(MONSTER_IDX m_idx, POSITION *yp, POSITION *xp)
  * It is probably better to replace these arrays with code to compute
  * the relevant arrays, even if the storage is pre-allocated in hard
  * coded sizes.  At the very least, code should be included which is
- * able to generate and dump these arrays (ala "los()").  XXX XXX XXX
+ * able to generate and dump these arrays (ala "los()").  
  *
- * Also, the storage needs could be halved by using bytes.  XXX XXX XXX
+ * Also, the storage needs could be halved by using bytes.  
  *
  * These arrays could be combined into two big arrays, using sub-arrays
  * to hold the offsets and lengths of each portion of the sub-arrays, and
- * this could perhaps also be used somehow in the "look" code.  XXX XXX XXX
+ * this could perhaps also be used somehow in the "look" code.  
  */
 
 
-static sint d_off_y_0[] =
-{ 0 };
-
-static sint d_off_x_0[] =
-{ 0 };
-
-
-static sint d_off_y_1[] =
-{ -1, -1, -1, 0, 0, 1, 1, 1, 0 };
-
-static sint d_off_x_1[] =
-{ -1, 0, 1, -1, 1, -1, 0, 1, 0 };
-
-
-static sint d_off_y_2[] =
-{ -1, -1, -2, -2, -2, 0, 0, 1, 1, 2, 2, 2, 0 };
+static sint d_off_y_0[] = { 0 };
+static sint d_off_x_0[] = { 0 };
 
-static sint d_off_x_2[] =
-{ -2, 2, -1, 0, 1, -2, 2, -2, 2, -1, 0, 1, 0 };
+static sint d_off_y_1[] = { -1, -1, -1, 0, 0, 1, 1, 1, 0 };
+static sint d_off_x_1[] = { -1, 0, 1, -1, 1, -1, 0, 1, 0 };
 
+static sint d_off_y_2[] = { -1, -1, -2, -2, -2, 0, 0, 1, 1, 2, 2, 2, 0 };
+static sint d_off_x_2[] = { -2, 2, -1, 0, 1, -2, 2, -2, 2, -1, 0, 1, 0 };
 
-static sint d_off_y_3[] =
-{ -1, -1, -2, -2, -3, -3, -3, 0, 0, 1, 1, 2, 2,
-  3, 3, 3, 0 };
+static sint d_off_y_3[] = { -1, -1, -2, -2, -3, -3, -3, 0, 0, 1, 1, 2, 2, 3, 3, 3, 0 };
+static sint d_off_x_3[] = { -3, 3, -2, 2, -1, 0, 1, -3, 3, -3, 3, -2, 2, -1, 0, 1, 0 };
 
-static sint d_off_x_3[] =
-{ -3, 3, -2, 2, -1, 0, 1, -3, 3, -3, 3, -2, 2,
-  -1, 0, 1, 0 };
-
-
-static sint d_off_y_4[] =
-{ -1, -1, -2, -2, -3, -3, -3, -3, -4, -4, -4, 0,
-  0, 1, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 0 };
-
-static sint d_off_x_4[] =
-{ -4, 4, -3, 3, -2, -3, 2, 3, -1, 0, 1, -4, 4,
-  -4, 4, -3, 3, -2, -3, 2, 3, -1, 0, 1, 0 };
+static sint d_off_y_4[] = { -1, -1, -2, -2, -3, -3, -3, -3, -4, -4, -4, 0, 0, 1, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 0 };
+static sint d_off_x_4[] = { -4, 4, -3, 3, -2, -3, 2, 3, -1, 0, 1, -4, 4, -4, 4, -3, 3, -2, -3, 2, 3, -1, 0, 1, 0 };
 
 
 static sint d_off_y_5[] =
@@ -1181,7 +1158,6 @@ static bool get_moves(MONSTER_IDX m_idx, int *mm)
                        y = m_ptr->fy - y2;
                        x = m_ptr->fx - x2;
 
-                       /* Done */
                        done = TRUE;
                }
        }
@@ -1441,7 +1417,7 @@ static int check_hit2(int power, DEPTH level, ARMOUR_CLASS ac, int stun)
  * @param t_idx 目標側モンスターの参照ID
  * @return 実際に打撃処理が行われた場合TRUEを返す
  */
-static bool monst_attack_monst(MONSTER_IDX m_idx, IDX t_idx)
+static bool monst_attack_monst(MONSTER_IDX m_idx, MONSTER_IDX t_idx)
 {
        monster_type    *m_ptr = &m_list[m_idx];
        monster_type    *t_ptr = &m_list[t_idx];
@@ -1497,7 +1473,7 @@ static bool monst_attack_monst(MONSTER_IDX m_idx, IDX t_idx)
                mon_fight = TRUE;
        }
 
-       if (p_ptr->riding && (m_idx == p_ptr->riding)) disturb(1, 1);
+       if (p_ptr->riding && (m_idx == p_ptr->riding)) disturb(TRUE, TRUE);
 
        /* Scan through all four blows */
        for (ap_cnt = 0; ap_cnt < 4; ap_cnt++)
@@ -1651,7 +1627,7 @@ static bool monst_attack_monst(MONSTER_IDX m_idx, IDX t_idx)
 
                        case RBM_EXPLODE:
                                {
-                                       if (see_either) disturb(1, 1);
+                                       if (see_either) disturb(TRUE, TRUE);
                                        act = _("爆発した。", "explodes.");
                                        explode = TRUE;
                                        touched = FALSE;
@@ -1715,7 +1691,6 @@ static bool monst_attack_monst(MONSTER_IDX m_idx, IDX t_idx)
                                }
                        }
 
-                       /* Message */
                        if (act && see_either)
                        {
 #ifdef JP
@@ -1993,9 +1968,8 @@ static bool monst_attack_monst(MONSTER_IDX m_idx, IDX t_idx)
                                        /* Visible monsters */
                                        if (see_m)
                                        {
-                                               /* Message */
 #ifdef JP
-                                               msg_format("%sは%^sの攻撃をかわした。", t_name,m_name);
+                                               msg_format("%sは%^sの攻撃をかわした。", t_name, m_name);
 #else
                                                msg_format("%^s misses %s.", m_name, t_name);
 #endif
@@ -2094,7 +2068,7 @@ static bool check_hp_for_feat_destruction(feature_type *f_ptr, monster_type *m_p
  * fixate on opening a door even if they cannot open it.  Actually,\n
  * the same thing happens to normal monsters when they hit a door\n
  *\n
- * XXX XXX XXX In addition, monsters which *cannot* open or bash\n
+ * In addition, monsters which *cannot* open or bash\n
  * down a door will still stand there trying to open it...\n
  *\n
  * XXX Technically, need to check for monster in the way\n
@@ -2193,7 +2167,7 @@ void process_monster(MONSTER_IDX m_idx)
                        do_cmd_write_nikki(NIKKI_NAMED_PET, RECORD_NAMED_PET_LOSE_PARENT, m_name);
                }
 
-               /* Delete the monster */
+
                delete_monster_idx(m_idx);
 
                return;
@@ -2220,14 +2194,13 @@ void process_monster(MONSTER_IDX m_idx)
                                /* Acquire the monster name */
                                monster_desc(m_name, m_ptr, 0);
 
-                               /* Oops */
                                msg_format(_("%sは消え去った!", "%^s disappears!"), m_name);
                        }
 
                        /* Generate treasure, etc */
                        monster_death(m_idx, FALSE);
 
-                       /* Delete the monster */
+
                        delete_monster_idx(m_idx);
 
                        if (sad)
@@ -2258,7 +2231,7 @@ void process_monster(MONSTER_IDX m_idx)
                                msg_format(_("%sは傷の痛さの余りあなたの束縛から逃れようとしている。",
                                                         "%^s seems to be in so much pain, and trying to escape from your restriction."), m_name);
                                riding_pinch++;
-                               disturb(1, 1);
+                               disturb(TRUE, TRUE);
                        }
                        else
                        {
@@ -2607,7 +2580,7 @@ void process_monster(MONSTER_IDX m_idx)
                        if (avoid || lonely || distant)
                        {
                                /* Remember the leash length */
-                               int dis = p_ptr->pet_follow_distance;
+                               POSITION dis = p_ptr->pet_follow_distance;
 
                                /* Hack -- adjust follow distance temporarily */
                                if (p_ptr->pet_follow_distance > PET_SEEK_DIST)
@@ -2742,14 +2715,13 @@ void process_monster(MONSTER_IDX m_idx)
                                        /* Do not bash the door */
                                        may_bash = FALSE;
 
-                                       /* Take a turn */
                                        do_turn = TRUE;
                                }
 
                                /* Locked doors (not jammed) */
                                else
                                {
-                                       /* Try to unlock it XXX XXX XXX */
+                                       /* Try to unlock it */
                                        if (randint0(m_ptr->hp / 10) > f_ptr->power)
                                        {
                                                /* Unlock the door */
@@ -2758,7 +2730,6 @@ void process_monster(MONSTER_IDX m_idx)
                                                /* Do not bash the door */
                                                may_bash = FALSE;
 
-                                               /* Take a turn */
                                                do_turn = TRUE;
                                        }
                                }
@@ -2768,17 +2739,16 @@ void process_monster(MONSTER_IDX m_idx)
                        if (may_bash && (r_ptr->flags2 & RF2_BASH_DOOR) && have_flag(f_ptr->flags, FF_BASH) &&
                                (!is_pet(m_ptr) || (p_ptr->pet_extra_flags & PF_OPEN_DOORS)))
                        {
-                               /* Attempt to Bash XXX XXX XXX */
+                               /* Attempt to Bash */
                                if (check_hp_for_feat_destruction(f_ptr, m_ptr) && (randint0(m_ptr->hp / 10) > f_ptr->power))
                                {
-                                       /* Message */
                                        if (have_flag(f_ptr->flags, FF_GLASS))
                                                msg_print(_("ガラスが砕ける音がした!", "You hear a glass was crashed!"));
                                        else
                                                msg_print(_("ドアを叩き開ける音がした!", "You hear a door burst open!"));
 
                                        /* Disturb (sometimes) */
-                                       if (disturb_minor) disturb(0, 0);
+                                       if (disturb_minor) disturb(FALSE, FALSE);
 
                                        /* The door was bashed open */
                                        did_bash_door = TRUE;
@@ -2848,7 +2818,6 @@ void process_monster(MONSTER_IDX m_idx)
                                /* Allow movement */
                                do_move = TRUE;
 
-                               /* Notice */
                                note_spot(ny, nx);
                        }
                }
@@ -2990,7 +2959,7 @@ void process_monster(MONSTER_IDX m_idx)
                                /* Wake up the moved monster */
                                (void)set_monster_csleep(c_ptr->m_idx, 0);
 
-                               /* XXX XXX XXX Message */
+                               /* Message */
                        }
                }
 
@@ -3026,7 +2995,6 @@ void process_monster(MONSTER_IDX m_idx)
                        /* Note changes to viewable region */
                        do_view = TRUE;
 
-                       /* Take a turn */
                        do_turn = TRUE;
                }
 
@@ -3064,7 +3032,6 @@ void process_monster(MONSTER_IDX m_idx)
                /* Creature has been allowed move */
                if (do_move)
                {
-                       /* Take a turn */
                        do_turn = TRUE;
 
                        if (have_flag(f_ptr->flags, FF_TREE))
@@ -3088,7 +3055,7 @@ void process_monster(MONSTER_IDX m_idx)
                                        y_ptr->fx = ox;
 
                                        /* Update the old monster */
-                                       update_mon(c_ptr->m_idx, TRUE);
+                                       update_monster(c_ptr->m_idx, TRUE);
                                }
 
                                /* Hack -- Update the new location */
@@ -3097,9 +3064,7 @@ void process_monster(MONSTER_IDX m_idx)
                                /* Move the monster */
                                m_ptr->fy = ny;
                                m_ptr->fx = nx;
-
-                               /* Update the monster */
-                               update_mon(m_idx, TRUE);
+                               update_monster(m_idx, TRUE);
 
                                /* Redraw the old grid */
                                lite_spot(oy, ox);
@@ -3121,22 +3086,21 @@ void process_monster(MONSTER_IDX m_idx)
                             (disturb_near && (m_ptr->mflag & MFLAG_VIEW) && projectable(p_ptr->y, p_ptr->x, m_ptr->fy, m_ptr->fx)) ||
                             (disturb_high && ap_r_ptr->r_tkills && ap_r_ptr->level >= p_ptr->lev)))
                        {
-                               /* Disturb */
                                if (is_hostile(m_ptr))
-                                       disturb(0, 1);
+                                       disturb(FALSE, TRUE);
                        }
 
                        /* Take or Kill objects on the floor */
                        if (c_ptr->o_idx && (r_ptr->flags2 & (RF2_TAKE_ITEM | RF2_KILL_ITEM)) &&
                            (!is_pet(m_ptr) || ((p_ptr->pet_extra_flags & PF_PICKUP_ITEMS) && (r_ptr->flags2 & RF2_TAKE_ITEM))))
                        {
-                               s16b this_o_idx, next_o_idx;
+                               OBJECT_IDX this_o_idx, next_o_idx;
                                bool do_take = (r_ptr->flags2 & RF2_TAKE_ITEM) ? TRUE : FALSE;
 
                                /* Scan all objects in the grid */
                                for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
                                {
-                                       u32b flgs[TR_FLAG_SIZE], flg2 = 0L, flg3 = 0L, flgr = 0L;
+                                       BIT_FLAGS flgs[TR_FLAG_SIZE], flg2 = 0L, flg3 = 0L, flgr = 0L;
                                        char m_name[80], o_name[MAX_NLEN];
 
                                        /* Acquire object */
@@ -3257,7 +3221,6 @@ void process_monster(MONSTER_IDX m_idx)
                                                        msg_format(_("%^sが%sを破壊した。", "%^s destroys %s."), m_name, o_name);
                                                }
 
-                                               /* Delete the object */
                                                delete_object_idx(this_o_idx);
                                        }
                                }
@@ -3292,7 +3255,6 @@ void process_monster(MONSTER_IDX m_idx)
                /* Update some things */
                p_ptr->update |= (PU_FLOW);
 
-               /* Window stuff */
                p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
        }
 
@@ -3350,7 +3312,7 @@ void process_monster(MONSTER_IDX m_idx)
 
                if (m_ptr->ml) chg_virtue(V_COMPASSION, -1);
 
-               /* XXX XXX XXX Actually do something now (?) */
+               /* Actually do something now (?) */
        }
 }
 
@@ -3398,24 +3360,24 @@ void process_monsters(void)
        monster_type    *m_ptr;
        monster_race    *r_ptr;
 
-       int             old_monster_race_idx;
+       MONRACE_IDX old_monster_race_idx;
 
-       u32b    old_r_flags1 = 0L;
-       u32b    old_r_flags2 = 0L;
-       u32b    old_r_flags3 = 0L;
-       u32b    old_r_flags4 = 0L;
-       u32b    old_r_flags5 = 0L;
-       u32b    old_r_flags6 = 0L;
-       u32b    old_r_flagsr = 0L;
+       BIT_FLAGS old_r_flags1 = 0L;
+       BIT_FLAGS old_r_flags2 = 0L;
+       BIT_FLAGS old_r_flags3 = 0L;
+       BIT_FLAGS old_r_flags4 = 0L;
+       BIT_FLAGS old_r_flags5 = 0L;
+       BIT_FLAGS old_r_flags6 = 0L;
+       BIT_FLAGS old_r_flagsr = 0L;
 
-       byte    old_r_blows0 = 0;
-       byte    old_r_blows1 = 0;
-       byte    old_r_blows2 = 0;
-       byte    old_r_blows3 = 0;
+       byte old_r_blows0 = 0;
+       byte old_r_blows1 = 0;
+       byte old_r_blows2 = 0;
+       byte old_r_blows3 = 0;
 
-       byte    old_r_cast_spell = 0;
+       byte old_r_cast_spell = 0;
 
-       int speed;
+       SPEED speed;
 
        /* Clear monster fighting indicator */
        mon_fight = FALSE;
@@ -3592,7 +3554,6 @@ void process_monsters(void)
                        (old_r_blows3 != r_ptr->r_blows[3]) ||
                        (old_r_cast_spell != r_ptr->r_cast_spell))
                {
-                       /* Window stuff */
                        p_ptr->window |= (PW_MONSTER);
                }
        }