OSDN Git Service

[Refactor] #37353 コメント整理 / Refactor comments.
[hengband/hengband.git] / src / xtra2.c
index ba27981..de4704b 100644 (file)
@@ -1929,7 +1929,7 @@ msg_format("%sを葬り去った。", m_name);
 
                        if (is_pet(m_ptr)) mode |= PM_FORCE_PET;
 
-                       /* Delete the monster */
+
                        delete_monster_idx(m_idx);
 
                        if (summon_named_creature(0, dummy_y, dummy_x, MON_BIKETAL, mode))
@@ -1939,7 +1939,7 @@ msg_format("%sを葬り去った。", m_name);
                }
                else
                {
-                       /* Delete the monster */
+
                        delete_monster_idx(m_idx);
                }
 
@@ -2037,7 +2037,6 @@ void panel_bounds_center(void)
 {
        int wid, hgt;
 
-       /* Get size */
        get_screen_size(&wid, &hgt);
 
        panel_row_max = panel_row_min + hgt - 1;
@@ -2133,7 +2132,6 @@ bool change_panel(POSITION dy, POSITION dx)
        POSITION y, x;
        TERM_LEN wid, hgt;
 
-       /* Get size */
        get_screen_size(&wid, &hgt);
 
        /* Apply the motion */
@@ -2189,7 +2187,6 @@ static bool change_panel_xy(POSITION y, POSITION x)
        POSITION dy = 0, dx = 0;
        TERM_LEN wid, hgt;
 
-       /* Get size */
        get_screen_size(&wid, &hgt);
 
        if (y < panel_row_min) dy = -1;
@@ -2223,7 +2220,6 @@ void verify_panel(void)
        int max_prow_min;
        int max_pcol_min;
 
-       /* Get size */
        get_screen_size(&wid, &hgt);
 
        max_prow_min = cur_hgt - hgt;
@@ -2300,7 +2296,7 @@ void verify_panel(void)
        panel_col_min = pcol_min;
 
        /* Hack -- optional disturb on "panel change" */
-       if (disturb_panel && !center_player) disturb(0, 0);
+       if (disturb_panel && !center_player) disturb(FALSE, FALSE);
 
        /* Recalculate the boundaries */
        panel_bounds_center();
@@ -2740,8 +2736,6 @@ static POSITION_IDX target_pick(POSITION y1, POSITION x1, POSITION dy, POSITION
                /* Track best */
                b_i = i; b_v = v;
        }
-
-       /* Result */
        return (b_i);
 }
 
@@ -2800,7 +2794,6 @@ static bool target_set_accept(POSITION y, POSITION x)
                if (have_flag(f_info[get_feat_mimic(c_ptr)].flags, FF_NOTICE)) return TRUE;
        }
 
-       /* Nope */
        return (FALSE);
 }
 
@@ -2982,8 +2975,6 @@ static char target_set_aux(POSITION y, POSITION x, BIT_FLAGS mode, cptr info)
        feature_type *f_ptr;
        char query = '\001';
        char out_val[MAX_NLEN+80];
-
-#ifdef ALLOW_EASY_FLOOR
        OBJECT_IDX floor_list[23];
        ITEM_NUMBER floor_num = 0;
 
@@ -2998,8 +2989,6 @@ static char target_set_aux(POSITION y, POSITION x, BIT_FLAGS mode, cptr info)
                }
        }
 
-#endif /* ALLOW_EASY_FLOOR */
-
        /* Hack -- under the player */
        if (player_bold(y, x))
        {
@@ -3164,7 +3153,6 @@ static char target_set_aux(POSITION y, POSITION x, BIT_FLAGS mode, cptr info)
                        /* Obtain an object description */
                        object_desc(o_name, o_ptr, 0);
 
-                       /* Describe the object */
 #ifdef JP
                        sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
 #else
@@ -3194,8 +3182,6 @@ static char target_set_aux(POSITION y, POSITION x, BIT_FLAGS mode, cptr info)
 #endif
        }
 
-
-#ifdef ALLOW_EASY_FLOOR
        if (floor_num)
        {
                int min_width = 0;
@@ -3211,15 +3197,12 @@ static char target_set_aux(POSITION y, POSITION x, BIT_FLAGS mode, cptr info)
                                /* Acquire object */
                                o_ptr = &o_list[floor_list[0]];
 
-                               /* Describe the object */
                                object_desc(o_name, o_ptr, 0);
 
 #ifdef JP
-                               sprintf(out_val, "%s%s%s%s[%s]",
-                                       s1, o_name, s2, s3, info);
+                               sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
 #else
-                               sprintf(out_val, "%s%s%s%s [%s]",
-                                       s1, s2, s3, o_name, info);
+                               sprintf(out_val, "%s%s%s%s [%s]", s1, s2, s3, o_name, info);
 #endif
 
                                prt(out_val, 0, 0);
@@ -3317,8 +3300,6 @@ static char target_set_aux(POSITION y, POSITION x, BIT_FLAGS mode, cptr info)
 
                /* NOTREACHED */
        }
-#endif /* ALLOW_EASY_FLOOR */
-
 
        /* Scan all objects in the grid */
        for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
@@ -3342,7 +3323,6 @@ static char target_set_aux(POSITION y, POSITION x, BIT_FLAGS mode, cptr info)
                        /* Obtain an object description */
                        object_desc(o_name, o_ptr, 0);
 
-                       /* Describe the object */
 #ifdef JP
                        sprintf(out_val, "%s%s%s%s[%s]", s1, o_name, s2, s3, info);
 #else
@@ -3570,7 +3550,6 @@ bool target_set(BIT_FLAGS mode)
 
        int wid, hgt;
        
-       /* Get size */
        get_screen_size(&wid, &hgt);
 
        /* Cancel target */
@@ -4078,7 +4057,6 @@ bool get_aim_dir(DIRECTION *dp)
        cptr    p;
        COMMAND_CODE code;
 
-       /* Initialize */
        (*dp) = 0;
 
        /* Global direction */
@@ -4087,8 +4065,6 @@ bool get_aim_dir(DIRECTION *dp)
        /* Hack -- auto-target if requested */
        if (use_old_target && target_okay()) dir = 5;
 
-#ifdef ALLOW_REPEAT /* TNB */
-
        if (repeat_pull(&code))
        {
                /* Confusion? */
@@ -4102,8 +4078,6 @@ bool get_aim_dir(DIRECTION *dp)
        }
        *dp = (DIRECTION)code;
 
-#endif /* ALLOW_REPEAT -- TNB */
-
        /* Ask until satisfied */
        while (!dir)
        {
@@ -4191,59 +4165,33 @@ bool get_aim_dir(DIRECTION *dp)
        /* Save direction */
        (*dp) = dir;
 
-#ifdef ALLOW_REPEAT /* TNB */
-
 /*     repeat_push(dir); */
        repeat_push((COMMAND_CODE)command_dir);
 
-#endif /* ALLOW_REPEAT -- TNB */
-
        /* A "valid" direction was entered */
        return (TRUE);
 }
 
 
-
-/*
- * Request a "movement" direction (1,2,3,4,6,7,8,9) from the user,
- * and place it into "command_dir", unless we already have one.
- *
- * This function should be used for all "repeatable" commands, such as
- * run, walk, open, close, bash, disarm, spike, tunnel, etc, as well
- * as all commands which must reference a grid adjacent to the player,
- * and which may not reference the grid under the player.  Note that,
- * for example, it is no longer possible to "disarm" or "open" chests
- * in the same grid as the player.
- *
- * Direction "5" is illegal and will (cleanly) abort the command.
- *
- * This function tracks and uses the "global direction", and uses
- * that as the "desired direction", to which "confusion" is applied.
- */
-bool get_rep_dir(DIRECTION *dp, bool under)
+bool get_direction(DIRECTION *dp, bool allow_under, bool with_steed)
 {
        DIRECTION dir;
        cptr prompt;
        COMMAND_CODE code;
 
-       /* Initialize */
        (*dp) = 0;
 
        /* Global direction */
        dir = command_dir;
 
-#ifdef ALLOW_REPEAT /* TNB */
-
        if (repeat_pull(&code))
        {
                dir = (DIRECTION)code;
-/*             return (TRUE); */
+               /*              return (TRUE); */
        }
        *dp = (DIRECTION)code;
 
-#endif /* ALLOW_REPEAT -- TNB */
-
-       if (under)
+       if (allow_under)
        {
                prompt = _("方向 ('.'足元, ESCで中断)? ", "Direction ('.' at feet, Escape to cancel)? ");
        }
@@ -4251,7 +4199,7 @@ bool get_rep_dir(DIRECTION *dp, bool under)
        {
                prompt = _("方向 (ESCで中断)? ", "Direction (Escape to cancel)? ");
        }
-       
+
        /* Get a direction */
        while (!dir)
        {
@@ -4261,7 +4209,7 @@ bool get_rep_dir(DIRECTION *dp, bool under)
                if (!get_com(prompt, &ch, TRUE)) break;
 
                /* Look down */
-               if ((under) && ((ch == '5') || (ch == '-') || (ch == '.')))
+               if ((allow_under) && ((ch == '5') || (ch == '-') || (ch == '.')))
                {
                        dir = 5;
                }
@@ -4275,7 +4223,7 @@ bool get_rep_dir(DIRECTION *dp, bool under)
        }
 
        /* Prevent weirdness */
-       if ((dir == 5) && (!under)) dir = 0;
+       if ((dir == 5) && (!allow_under)) dir = 0;
 
        /* Aborted */
        if (!dir) return (FALSE);
@@ -4293,7 +4241,7 @@ bool get_rep_dir(DIRECTION *dp, bool under)
                        dir = ddd[randint0(8)];
                }
        }
-       else if (p_ptr->riding)
+       else if (p_ptr->riding && with_steed)
        {
                monster_type *m_ptr = &m_list[p_ptr->riding];
                monster_race *r_ptr = &r_info[m_ptr->r_idx];
@@ -4347,31 +4295,40 @@ bool get_rep_dir(DIRECTION *dp, bool under)
        /* Save direction */
        (*dp) = dir;
 
-#ifdef ALLOW_REPEAT /* TNB */
-
-/*     repeat_push(dir); */
+       /*      repeat_push(dir); */
        repeat_push((COMMAND_CODE)command_dir);
 
-#endif /* ALLOW_REPEAT -- TNB */
-
        /* Success */
        return (TRUE);
 }
 
-
-bool get_rep_dir2(DIRECTION *dp)
+/*
+ * @brief 進行方向を指定する(騎乗対象の混乱の影響を受ける) / Request a "movement" direction (1,2,3,4,6,7,8,9) from the user,
+ * and place it into "command_dir", unless we already have one.
+ *
+ * This function should be used for all "repeatable" commands, such as
+ * run, walk, open, close, bash, disarm, spike, tunnel, etc, as well
+ * as all commands which must reference a grid adjacent to the player,
+ * and which may not reference the grid under the player.  Note that,
+ * for example, it is no longer possible to "disarm" or "open" chests
+ * in the same grid as the player.
+ *
+ * Direction "5" is illegal and will (cleanly) abort the command.
+ *
+ * This function tracks and uses the "global direction", and uses
+ * that as the "desired direction", to which "confusion" is applied.
+ */
+bool get_rep_dir(DIRECTION *dp, bool under)
 {
        DIRECTION dir;
+       cptr prompt;
        COMMAND_CODE code;
 
-       /* Initialize */
        (*dp) = 0;
 
        /* Global direction */
        dir = command_dir;
 
-#ifdef ALLOW_REPEAT /* TNB */
-
        if (repeat_pull(&code))
        {
                dir = (DIRECTION)code;
@@ -4379,24 +4336,39 @@ bool get_rep_dir2(DIRECTION *dp)
        }
        *dp = (DIRECTION)code;
 
-#endif /* ALLOW_REPEAT -- TNB */
-
+       if (under)
+       {
+               prompt = _("方向 ('.'足元, ESCで中断)? ", "Direction ('.' at feet, Escape to cancel)? ");
+       }
+       else
+       {
+               prompt = _("方向 (ESCで中断)? ", "Direction (Escape to cancel)? ");
+       }
+       
        /* Get a direction */
        while (!dir)
        {
                char ch;
 
                /* Get a command (or Cancel) */
-               if (!get_com(_("方向 (ESCで中断)? ", "Direction (Escape to cancel)? "), &ch, TRUE)) break;
+               if (!get_com(prompt, &ch, TRUE)) break;
 
-               /* Look up the direction */
-               dir = get_keymap_dir(ch);
+               /* Look down */
+               if ((under) && ((ch == '5') || (ch == '-') || (ch == '.')))
+               {
+                       dir = 5;
+               }
+               else
+               {
+                       /* Look up the direction */
+                       dir = get_keymap_dir(ch);
 
-               if (!dir) bell();
+                       if (!dir) bell();
+               }
        }
 
        /* Prevent weirdness */
-       if (dir == 5) dir = 0;
+       if ((dir == 5) && (!under)) dir = 0;
 
        /* Aborted */
        if (!dir) return (FALSE);
@@ -4414,24 +4386,63 @@ bool get_rep_dir2(DIRECTION *dp)
                        dir = ddd[randint0(8)];
                }
        }
+       else if (p_ptr->riding)
+       {
+               monster_type *m_ptr = &m_list[p_ptr->riding];
+               monster_race *r_ptr = &r_info[m_ptr->r_idx];
+
+               if (MON_CONFUSED(m_ptr))
+               {
+                       /* Standard confusion */
+                       if (randint0(100) < 75)
+                       {
+                               /* Random direction */
+                               dir = ddd[randint0(8)];
+                       }
+               }
+               else if ((r_ptr->flags1 & RF1_RAND_50) && (r_ptr->flags1 & RF1_RAND_25) && (randint0(100) < 50))
+               {
+                       /* Random direction */
+                       dir = ddd[randint0(8)];
+               }
+               else if ((r_ptr->flags1 & RF1_RAND_50) && (randint0(100) < 25))
+               {
+                       /* Random direction */
+                       dir = ddd[randint0(8)];
+               }
+       }
 
        /* Notice confusion */
        if (command_dir != dir)
        {
-               /* Warn the user */
-               msg_print(_("あなたは混乱している。", "You are confused."));
+               if (p_ptr->confused)
+               {
+                       /* Warn the user */
+                       msg_print(_("あなたは混乱している。", "You are confused."));
+               }
+               else
+               {
+                       char m_name[80];
+                       monster_type *m_ptr = &m_list[p_ptr->riding];
+
+                       monster_desc(m_name, m_ptr, 0);
+                       if (MON_CONFUSED(m_ptr))
+                       {
+                               msg_format(_("%sは混乱している。", "%^s is confusing."), m_name);
+                       }
+                       else
+                       {
+                               msg_format(_("%sは思い通りに動いてくれない。", "You cannot control %s."), m_name);
+                       }
+               }
        }
 
        /* Save direction */
        (*dp) = dir;
 
-#ifdef ALLOW_REPEAT /* TNB */
-
 /*     repeat_push(dir); */
        repeat_push((COMMAND_CODE)command_dir);
 
-#endif /* ALLOW_REPEAT -- TNB */
-
        /* Success */
        return (TRUE);
 }
@@ -5046,7 +5057,6 @@ static bool tgt_pt_accept(POSITION y, POSITION x)
                if (cave_have_flag_grid(c_ptr, FF_QUEST_EXIT)) return (TRUE);
        }
 
-       /* Nope */
        return (FALSE);
 }
 
@@ -5099,7 +5109,6 @@ bool tgt_pt(POSITION *x_ptr, POSITION *y_ptr)
 
        int wid, hgt;
 
-       /* Get size */
        get_screen_size(&wid, &hgt);
 
        x = p_ptr->x;
@@ -5278,7 +5287,6 @@ bool get_hack_dir(DIRECTION *dp)
        cptr    p;
        char    command;
 
-       /* Initialize */
        (*dp) = 0;
 
        /* Global direction */