From: Hourier Date: Sun, 12 Jan 2020 13:59:48 +0000 (+0900) Subject: [Refactor] #38997 change_panel() にplayer_type * 引数を追加 / Added player_type * argument... X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=f7b3a969be5fdef99e9f885b0c6104f8bf615860;p=hengband%2Fhengband.git [Refactor] #38997 change_panel() にplayer_type * 引数を追加 / Added player_type * argument to change_panel() --- diff --git a/src/cmd/cmd-item.c b/src/cmd/cmd-item.c index fe8489569..00870b97d 100644 --- a/src/cmd/cmd-item.c +++ b/src/cmd/cmd-item.c @@ -1165,7 +1165,7 @@ void do_cmd_locate(player_type *creature_ptr) if (!dir) break; /* Apply the motion */ - if (change_panel(ddy[dir], ddx[dir])) + if (change_panel(creature_ptr, ddy[dir], ddx[dir])) { y2 = panel_row_min; x2 = panel_col_min; diff --git a/src/targeting.c b/src/targeting.c index 9b4ef99d0..05e5a1d5b 100644 --- a/src/targeting.c +++ b/src/targeting.c @@ -60,6 +60,7 @@ void panel_bounds_center(void) /*! * @brief フォーカスを当てるべきマップ描画の基準座標を指定する + * @param creature_ptr プレーヤーへの参照ポインタ * @param y 変更先のフロアY座標 * @param x 変更先のフロアX座標 * @details @@ -68,7 +69,7 @@ void panel_bounds_center(void) * Also used in do_cmd_locate * @return 実際に再描画が必要だった場合TRUEを返す */ -static bool change_panel_xy(POSITION y, POSITION x) +static bool change_panel_xy(player_type *creature_ptr, POSITION y, POSITION x) { POSITION dy = 0, dx = 0; TERM_LEN wid, hgt; @@ -82,7 +83,7 @@ static bool change_panel_xy(POSITION y, POSITION x) if (!dy && !dx) return FALSE; - return change_panel(dy, dx); + return change_panel(creature_ptr, dy, dx); } @@ -1095,7 +1096,7 @@ bool target_set(player_type *creature_ptr, BIT_FLAGS mode) x = tmp_pos.x[m]; /* Set forcus */ - change_panel_xy(y, x); + change_panel_xy(creature_ptr, y, x); if (!(mode & TARGET_LOOK)) print_path(floor_ptr, y, x); @@ -1250,7 +1251,7 @@ bool target_set(player_type *creature_ptr, BIT_FLAGS mode) while (flag && (i < 0)) { /* Note the change */ - if (change_panel(ddy[d], ddx[d])) + if (change_panel(creature_ptr, ddy[d], ddx[d])) { int v = tmp_pos.y[m]; int u = tmp_pos.x[m]; @@ -1312,7 +1313,7 @@ bool target_set(player_type *creature_ptr, BIT_FLAGS mode) if ((y >= panel_row_min+hgt) || (y < panel_row_min) || (x >= panel_col_min+wid) || (x < panel_col_min)) { - if (change_panel(dy, dx)) target_set_prepare(mode); + if (change_panel(creature_ptr, dy, dx)) target_set_prepare(mode); } /* Slide into legality */ @@ -1486,7 +1487,7 @@ bool target_set(player_type *creature_ptr, BIT_FLAGS mode) if ((y >= panel_row_min + hgt) || (y < panel_row_min) || (x >= panel_col_min + wid) || (x < panel_col_min)) { - if (change_panel(dy, dx)) target_set_prepare(mode); + if (change_panel(creature_ptr, dy, dx)) target_set_prepare(mode); } /* Slide into legality */ @@ -2086,7 +2087,7 @@ bool tgt_pt(player_type *creature_ptr, POSITION *x_ptr, POSITION *y_ptr) dy = 2 * (y - cy) / hgt; dx = 2 * (x - cx) / wid; - if (dy || dx) change_panel(dy, dx); + if (dy || dx) change_panel(creature_ptr, dy, dx); } } break; @@ -2135,8 +2136,7 @@ bool tgt_pt(player_type *creature_ptr, POSITION *x_ptr, POSITION *y_ptr) if ((y >= panel_row_min + hgt) || (y < panel_row_min) || (x >= panel_col_min + wid) || (x < panel_col_min)) { - /* if (change_panel(dy, dx)) target_set_prepare(mode); */ - change_panel(dy, dx); + change_panel(creature_ptr, dy, dx); } /* Slide into legality */ diff --git a/src/view-mainwindow.c b/src/view-mainwindow.c index 43123094d..ba354e202 100644 --- a/src/view-mainwindow.c +++ b/src/view-mainwindow.c @@ -2360,6 +2360,7 @@ void window_stuff(player_type *player_ptr) /*! + * todo ここにplayer_type を追加するとz-termに影響が行くので保留 * @brief コンソールのリサイズに合わせてマップを再描画する / * Map resizing whenever the main term changes size * @return なし @@ -2397,7 +2398,9 @@ void resize_map(void) Term_fresh(); } + /*! + * todo ここにplayer_type を追加するとz-termに影響が行くので保留 * @brief コンソールを再描画する / * Redraw a term when it is resized * @return なし @@ -2417,6 +2420,7 @@ void redraw_window(void) /*! * @brief フォーカスを当てるべきマップ描画の基準座標を指定する(サブルーチン) + * @param creature_ptr プレーヤーへの参照ポインタ * @param dy 変更先のフロアY座標 * @param dx 変更先のフロアX座標 * Handle a request to change the current panel @@ -2424,7 +2428,7 @@ void redraw_window(void) * Also used in do_cmd_locate * @return 実際に再描画が必要だった場合TRUEを返す */ -bool change_panel(POSITION dy, POSITION dx) +bool change_panel(player_type *player_ptr, POSITION dy, POSITION dx) { POSITION y, x; TERM_LEN wid, hgt; @@ -2436,11 +2440,12 @@ bool change_panel(POSITION dy, POSITION dx) x = panel_col_min + dx * wid / 2; /* Verify the row */ - if (y > p_ptr->current_floor_ptr->height - hgt) y = p_ptr->current_floor_ptr->height - hgt; + floor_type *floor_ptr = player_ptr->current_floor_ptr; + if (y > floor_ptr->height - hgt) y = floor_ptr->height - hgt; if (y < 0) y = 0; /* Verify the col */ - if (x > p_ptr->current_floor_ptr->width - wid) x = p_ptr->current_floor_ptr->width - wid; + if (x > floor_ptr->width - wid) x = floor_ptr->width - wid; if (x < 0) x = 0; /* Handle "changes" */ @@ -2452,9 +2457,9 @@ bool change_panel(POSITION dy, POSITION dx) panel_bounds_center(); - p_ptr->update |= (PU_MONSTERS); - p_ptr->redraw |= (PR_MAP); - handle_stuff(p_ptr); + player_ptr->update |= (PU_MONSTERS); + player_ptr->redraw |= (PR_MAP); + handle_stuff(player_ptr); /* Success */ return TRUE; diff --git a/src/view-mainwindow.h b/src/view-mainwindow.h index e5a90e267..b6ee06090 100644 --- a/src/view-mainwindow.h +++ b/src/view-mainwindow.h @@ -19,7 +19,7 @@ extern void monster_race_track(MONRACE_IDX r_idx); extern void object_kind_track(KIND_OBJECT_IDX k_idx); extern void resize_map(void); extern void redraw_window(void); -extern bool change_panel(POSITION dy, POSITION dx); +extern bool change_panel(player_type *player_ptr, POSITION dy, POSITION dx); extern void window_stuff(player_type *player_ptr); extern void update_playtime(void);