OSDN Git Service

[Refactor] #38997 health_track() にplayer_type * 引数を追加 / Added player_type * argument...
authorHourier <hourier@users.sourceforge.jp>
Sun, 12 Jan 2020 14:39:59 +0000 (23:39 +0900)
committerHourier <hourier@users.sourceforge.jp>
Sun, 12 Jan 2020 16:06:59 +0000 (01:06 +0900)
13 files changed:
src/cmd/cmd-basic.c
src/cmd/cmd-pet.c
src/combat/melee1.c
src/combat/shoot.c
src/core.c
src/mind.c
src/monster2.c
src/player-move.c
src/spells1.c
src/spells3.c
src/targeting.c
src/view-mainwindow.c
src/view-mainwindow.h

index 39c1212..8c86c22 100644 (file)
@@ -2589,7 +2589,7 @@ bool do_cmd_throw(player_type *creature_ptr, int mult, bool boomerang, OBJECT_ID
                                        if (m_ptr->ml)
                                        {
                                                if (!creature_ptr->image) monster_race_track(m_ptr->ap_r_idx);
-                                               health_track(g_ptr->m_idx);
+                                               health_track(creature_ptr, g_ptr->m_idx);
                                        }
                                }
 
index 29209e7..9acb816 100644 (file)
@@ -178,7 +178,7 @@ void do_cmd_pet_dismiss(player_type *creature_ptr)
                if (!all_pets)
                {
                        /* Hack -- health bar for this monster */
-                       health_track(pet_ctr);
+                       health_track(creature_ptr, pet_ctr);
                        handle_stuff(creature_ptr);
 
                        msg_format(_("%sを放しますか? [Yes/No/Unnamed (%d体)]", "Dismiss %s? [Yes/No/Unnamed (%d remain)]"), friend_name, max_pet - i);
@@ -373,7 +373,7 @@ bool do_cmd_riding(player_type *creature_ptr, bool force)
                creature_ptr->riding = g_ptr->m_idx;
 
                /* Hack -- remove tracked monster */
-               if (creature_ptr->riding == creature_ptr->health_who) health_track(0);
+               if (creature_ptr->riding == creature_ptr->health_who) health_track(creature_ptr, 0);
        }
 
        take_turn(creature_ptr, 100);
index 9876f33..7741146 100644 (file)
@@ -2198,7 +2198,7 @@ bool py_attack(player_type *attacker_ptr, POSITION y, POSITION x, COMBAT_OPTION_
                /* Auto-Recall if possible and visible */
                if (!attacker_ptr->image) monster_race_track(m_ptr->ap_r_idx);
 
-               health_track(g_ptr->m_idx);
+               health_track(attacker_ptr, g_ptr->m_idx);
        }
 
        if ((r_ptr->flags1 & RF1_FEMALE) &&
index 67a4468..08eb16c 100644 (file)
@@ -673,7 +673,7 @@ void exe_fire(player_type *shooter_ptr, INVENTORY_IDX item, object_type *j_ptr,
                                                if (m_ptr->ml)
                                                {
                                                        if (!shooter_ptr->image) monster_race_track(m_ptr->ap_r_idx);
-                                                       health_track(c_mon_ptr->m_idx);
+                                                       health_track(shooter_ptr, c_mon_ptr->m_idx);
                                                }
                                        }
 
index e3f2691..aae93b0 100644 (file)
@@ -4927,8 +4927,7 @@ static void dungeon(player_type *player_ptr, bool load_game)
        player_ptr->riding_t_m_idx = 0;
        player_ptr->ambush_flag = FALSE;
 
-       /* Cancel the health bar */
-       health_track(0);
+       health_track(player_ptr, 0);
 
        /* Check visual effects */
        repair_monsters = TRUE;
@@ -5615,8 +5614,7 @@ void play_game(player_type *player_ptr, bool new_game)
                /* Cancel the target */
                target_who = 0;
 
-               /* Cancel the health bar */
-               health_track(0);
+               health_track(player_ptr, 0);
 
                forget_lite(player_ptr->current_floor_ptr);
                forget_view(player_ptr->current_floor_ptr);
index f8e1f1c..3fd5d29 100644 (file)
@@ -1694,7 +1694,7 @@ static bool cast_ninja_spell(player_type *caster_ptr, int spell)
                {
                        /* Auto-Recall if possible and visible */
                        if (!caster_ptr->image) monster_race_track(m_ptr->ap_r_idx);
-                       health_track(m_idx);
+                       health_track(caster_ptr, m_idx);
                }
 
                break;
index 92fc6bc..baca5a2 100644 (file)
@@ -139,7 +139,7 @@ void delete_monster_idx(MONSTER_IDX i)
        if (i == target_who) target_who = 0;
 
        /* Hack -- remove tracked monster */
-       if (i == p_ptr->health_who) health_track(0);
+       if (i == p_ptr->health_who) health_track(p_ptr, 0);
 
        if (p_ptr->pet_t_m_idx == i ) p_ptr->pet_t_m_idx = 0;
        if (p_ptr->riding_t_m_idx == i) p_ptr->riding_t_m_idx = 0;
@@ -225,7 +225,7 @@ static void compact_monsters_aux(MONSTER_IDX i1, MONSTER_IDX i2)
        if (p_ptr->riding == i1) p_ptr->riding = i2;
 
        /* Hack -- Update the health bar */
-       if (p_ptr->health_who == i1) health_track(i2);
+       if (p_ptr->health_who == i1) health_track(p_ptr, i2);
 
        /* Hack -- Update parent index */
        if (is_pet(m_ptr))
@@ -418,8 +418,7 @@ void wipe_m_list(void)
        p_ptr->pet_t_m_idx = 0;
        p_ptr->riding_t_m_idx = 0;
 
-       /* Hack -- no more tracking */
-       health_track(0);
+       health_track(p_ptr, 0);
 }
 
 
index af7dd17..b1f9cb8 100644 (file)
@@ -1000,7 +1000,7 @@ void move_player(player_type *creature_ptr, DIRECTION dir, bool do_pickup, bool
                        {
                                /* Auto-Recall if possible and visible */
                                if (!creature_ptr->image) monster_race_track(m_ptr->ap_r_idx);
-                               health_track(g_ptr->m_idx);
+                               health_track(creature_ptr, g_ptr->m_idx);
                        }
 
                        /* displace? */
index c70c601..60b239e 100644 (file)
@@ -5813,7 +5813,7 @@ bool project(player_type *caster_ptr, MONSTER_IDX who, POSITION rad, POSITION y,
                                                        if (m_ptr->ml)
                                                        {
                                                                if (!caster_ptr->image) monster_race_track(m_ptr->ap_r_idx);
-                                                               health_track(caster_ptr->current_floor_ptr->grid_array[project_m_y][project_m_x].m_idx);
+                                                               health_track(caster_ptr, caster_ptr->current_floor_ptr->grid_array[project_m_y][project_m_x].m_idx);
                                                        }
                                                }
                                        }
@@ -5840,7 +5840,7 @@ bool project(player_type *caster_ptr, MONSTER_IDX who, POSITION rad, POSITION y,
                                        if (m_ptr->ml)
                                        {
                                                if (!caster_ptr->image) monster_race_track(m_ptr->ap_r_idx);
-                                               health_track(caster_ptr->current_floor_ptr->grid_array[project_m_y][project_m_x].m_idx);
+                                               health_track(caster_ptr, caster_ptr->current_floor_ptr->grid_array[project_m_y][project_m_x].m_idx);
                                        }
                                }
                        }
@@ -5974,7 +5974,7 @@ bool project(player_type *caster_ptr, MONSTER_IDX who, POSITION rad, POSITION y,
                                        if (m_ptr->ml)
                                        {
                                                if (!caster_ptr->image) monster_race_track(m_ptr->ap_r_idx);
-                                               health_track(caster_ptr->current_floor_ptr->grid_array[project_m_y][project_m_x].m_idx);
+                                               health_track(caster_ptr, caster_ptr->current_floor_ptr->grid_array[project_m_y][project_m_x].m_idx);
                                        }
                                }
                        }
@@ -6394,7 +6394,6 @@ bool project(player_type *caster_ptr, MONSTER_IDX who, POSITION rad, POSITION y,
                                }
                        }
 
-
                        /* Find the closest point in the blast */
                        if (breath)
                        {
@@ -6405,7 +6404,6 @@ bool project(player_type *caster_ptr, MONSTER_IDX who, POSITION rad, POSITION y,
                                effective_dist = dist;
                        }
 
-
                        /* There is the riding player on this monster */
                        if (caster_ptr->riding && player_bold(caster_ptr, y, x))
                        {
@@ -6496,13 +6494,12 @@ bool project(player_type *caster_ptr, MONSTER_IDX who, POSITION rad, POSITION y,
                                if (m_ptr->ml)
                                {
                                        if (!caster_ptr->image) monster_race_track(m_ptr->ap_r_idx);
-                                       health_track(caster_ptr->current_floor_ptr->grid_array[y][x].m_idx);
+                                       health_track(caster_ptr, caster_ptr->current_floor_ptr->grid_array[y][x].m_idx);
                                }
                        }
                }
        }
 
-
        /* Check player */
        if (flg & (PROJECT_KILL))
        {
index 1c9015a..a9ea26a 100644 (file)
@@ -2805,7 +2805,7 @@ bool polymorph_monster(player_type *caster_ptr, POSITION y, POSITION x)
        }
 
        if (targeted) target_who = hack_m_idx_ii;
-       if (health_tracked) health_track(hack_m_idx_ii);
+       if (health_tracked) health_track(caster_ptr, hack_m_idx_ii);
        return polymorphed;
 }
 
index 05e5a1d..3629484 100644 (file)
@@ -606,7 +606,7 @@ static char target_set_aux(player_type *subject_ptr, POSITION y, POSITION x, BIT
 
                monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
                monster_race_track(m_ptr->ap_r_idx);
-               health_track(g_ptr->m_idx);
+               health_track(subject_ptr, g_ptr->m_idx);
                handle_stuff(subject_ptr);
 
                /* Interact */
@@ -1155,7 +1155,7 @@ bool target_set(player_type *creature_ptr, BIT_FLAGS mode)
                                {
                                        if (target_able(g_ptr->m_idx))
                                        {
-                                               health_track(g_ptr->m_idx);
+                                               health_track(creature_ptr, g_ptr->m_idx);
                                                target_who = g_ptr->m_idx;
                                                target_row = y;
                                                target_col = x;
index cab8e73..65d13ac 100644 (file)
@@ -3780,19 +3780,23 @@ void do_cmd_view_map(player_type *player_ptr)
        screen_load();
 }
 
+
 /*
  * Track a new monster
+ * @param player_ptr プレーヤーへの参照ポインタ
+ * @param m_idx トラッキング対象のモンスターID。0の時キャンセル
+ * @param なし
  */
-void health_track(MONSTER_IDX m_idx)
+void health_track(player_type *player_ptr, MONSTER_IDX m_idx)
 {
        /* Mount monster is already tracked */
-       if (m_idx && m_idx == p_ptr->riding) return;
+       if (m_idx && m_idx == player_ptr->riding) return;
 
        /* Track a new guy */
-       p_ptr->health_who = m_idx;
+       player_ptr->health_who = m_idx;
 
        /* Redraw (later) */
-       p_ptr->redraw |= (PR_HEALTH);
+       player_ptr->redraw |= (PR_HEALTH);
 }
 
 
index c2f5965..21bbbc7 100644 (file)
@@ -7,7 +7,7 @@ extern void apply_default_feat_lighting(TERM_COLOR f_attr[F_LIT_MAX], SYMBOL_COD
 extern void map_info(POSITION y, POSITION x, TERM_COLOR *ap, SYMBOL_CODE *cp, TERM_COLOR *tap, SYMBOL_CODE *tcp);
 extern void do_cmd_view_map(player_type *player_ptr);
 
-extern void health_track(MONSTER_IDX m_idx);
+extern void health_track(player_type *player_ptr, MONSTER_IDX m_idx);
 extern void print_time(void);
 extern concptr map_name(player_type *creature_ptr);
 extern void print_monster_list(floor_type *floor_ptr, TERM_LEN x, TERM_LEN y, TERM_LEN max_lines);