From 3a57e3e165b133bc0fa23084ec15a805ccf99953 Mon Sep 17 00:00:00 2001 From: Hourier Date: Sat, 25 Jul 2020 12:41:42 +0900 Subject: [PATCH] [Refactor] #40571 Separated target-setter.c/h from targeting.c/h --- Hengband/Hengband/Hengband.vcxproj | 2 + Hengband/Hengband/Hengband.vcxproj.filters | 6 + src/Makefile.am | 1 + src/blue-magic/blue-magic-caster.c | 1 + src/cmd-action/cmd-mane.c | 1 + src/cmd-action/cmd-pet.c | 1 + src/cmd-item/cmd-item.c | 1 + src/mind/mind-switcher.c | 1 + src/mutation/mutation-processor.c | 1 + src/realm/realm-trump.c | 1 + src/spell-kind/spells-fetcher.c | 1 + src/spell-kind/spells-world.c | 1 + src/target/target-setter.c | 400 +++++++++++++++++++++++++++++ src/target/target-setter.h | 6 + src/target/targeting.c | 381 +-------------------------- src/target/targeting.h | 3 - 16 files changed, 426 insertions(+), 382 deletions(-) create mode 100644 src/target/target-setter.c create mode 100644 src/target/target-setter.h diff --git a/Hengband/Hengband/Hengband.vcxproj b/Hengband/Hengband/Hengband.vcxproj index a478e1e0e..c6bf0529e 100644 --- a/Hengband/Hengband/Hengband.vcxproj +++ b/Hengband/Hengband/Hengband.vcxproj @@ -360,6 +360,7 @@ + @@ -935,6 +936,7 @@ + diff --git a/Hengband/Hengband/Hengband.vcxproj.filters b/Hengband/Hengband/Hengband.vcxproj.filters index 2f5935089..93df0c429 100644 --- a/Hengband/Hengband/Hengband.vcxproj.filters +++ b/Hengband/Hengband/Hengband.vcxproj.filters @@ -1910,6 +1910,9 @@ target + + target + @@ -4156,6 +4159,9 @@ target + + target + diff --git a/src/Makefile.am b/src/Makefile.am index b1357e750..77761d344 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -733,6 +733,7 @@ hengband_SOURCES = \ target/grid-selector.c target/grid-selector.h \ target/target-describer.c target/target-describer.h \ target/target-preparation.c target/target-preparation.h \ + target/target-setter.c target/target-setter.h \ target/target-types.h \ target/targeting.c target/targeting.h \ \ diff --git a/src/blue-magic/blue-magic-caster.c b/src/blue-magic/blue-magic-caster.c index 50f6dc260..aaaf963af 100644 --- a/src/blue-magic/blue-magic-caster.c +++ b/src/blue-magic/blue-magic-caster.c @@ -29,6 +29,7 @@ #include "status/body-improvement.h" #include "status/buff-setter.h" #include "system/floor-type-definition.h" +#include "target/target-setter.h" #include "target/target-types.h" #include "target/targeting.h" #include "view/display-messages.h" diff --git a/src/cmd-action/cmd-mane.c b/src/cmd-action/cmd-mane.c index 55350d1fc..3afafcdba 100644 --- a/src/cmd-action/cmd-mane.c +++ b/src/cmd-action/cmd-mane.c @@ -50,6 +50,7 @@ #include "status/body-improvement.h" #include "status/buff-setter.h" #include "system/floor-type-definition.h" +#include "target/target-setter.h" #include "target/target-types.h" #include "target/targeting.h" #include "term/screen-processor.h" diff --git a/src/cmd-action/cmd-pet.c b/src/cmd-action/cmd-pet.c index c94802a05..3957ae449 100644 --- a/src/cmd-action/cmd-pet.c +++ b/src/cmd-action/cmd-pet.c @@ -42,6 +42,7 @@ #include "player/special-defense-types.h" #include "status/action-setter.h" #include "system/floor-type-definition.h" +#include "target/target-setter.h" #include "target/target-types.h" #include "target/targeting.h" #include "term/screen-processor.h" diff --git a/src/cmd-item/cmd-item.c b/src/cmd-item/cmd-item.c index c9cab5610..3a151a77c 100644 --- a/src/cmd-item/cmd-item.c +++ b/src/cmd-item/cmd-item.c @@ -84,6 +84,7 @@ #include "status/experience.h" #include "status/shape-changer.h" #include "sv-definition/sv-lite-types.h" +#include "target/target-setter.h" #include "target/target-types.h" #include "target/targeting.h" #include "term/screen-processor.h" diff --git a/src/mind/mind-switcher.c b/src/mind/mind-switcher.c index 7de5706c8..c2187dd78 100644 --- a/src/mind/mind-switcher.c +++ b/src/mind/mind-switcher.c @@ -79,6 +79,7 @@ #include "status/sight-setter.h" #include "status/temporary-resistance.h" #include "system/floor-type-definition.h" +#include "target/target-setter.h" #include "target/target-types.h" #include "target/targeting.h" #include "term/screen-processor.h" diff --git a/src/mutation/mutation-processor.c b/src/mutation/mutation-processor.c index 94a64d069..6c852648a 100644 --- a/src/mutation/mutation-processor.c +++ b/src/mutation/mutation-processor.c @@ -38,6 +38,7 @@ #include "store/store-util.h" #include "store/store.h" #include "system/floor-type-definition.h" +#include "target/target-setter.h" #include "target/target-types.h" #include "target/targeting.h" #include "term/screen-processor.h" diff --git a/src/realm/realm-trump.c b/src/realm/realm-trump.c index 53eb4873f..c82c00b12 100644 --- a/src/realm/realm-trump.c +++ b/src/realm/realm-trump.c @@ -20,6 +20,7 @@ #include "spell/spells-status.h" #include "spell/spells-summon.h" #include "status/sight-setter.h" +#include "target/target-setter.h" #include "target/target-types.h" #include "target/targeting.h" #include "view/display-messages.h" diff --git a/src/spell-kind/spells-fetcher.c b/src/spell-kind/spells-fetcher.c index e9b2ba984..8e5f46401 100644 --- a/src/spell-kind/spells-fetcher.c +++ b/src/spell-kind/spells-fetcher.c @@ -16,6 +16,7 @@ #include "system/floor-type-definition.h" #include "system/object-type-definition.h" #include "target/target-preparation.h" +#include "target/target-setter.h" #include "target/target-types.h" #include "target/targeting.h" #include "util/bit-flags-calculator.h" diff --git a/src/spell-kind/spells-world.c b/src/spell-kind/spells-world.c index 3fb4d6db8..f69967656 100644 --- a/src/spell-kind/spells-world.c +++ b/src/spell-kind/spells-world.c @@ -28,6 +28,7 @@ #include "monster/monster-info.h" #include "system/floor-type-definition.h" #include "system/monster-type-definition.h" +#include "target/target-setter.h" #include "target/target-types.h" #include "target/targeting.h" #include "term/screen-processor.h" diff --git a/src/target/target-setter.c b/src/target/target-setter.c new file mode 100644 index 000000000..8049aacb3 --- /dev/null +++ b/src/target/target-setter.c @@ -0,0 +1,400 @@ +#include "target/target-setter.h" +#include "core/player-redraw-types.h" +#include "core/player-update-types.h" +#include "core/window-redrawer.h" +#include "core/stuff-handler.h" +#include "floor/floor.h" +#include "game-option/cheat-options.h" +#include "game-option/game-play-options.h" +#include "game-option/input-options.h" +#include "grid/grid.h" +#include "io/cursor.h" +#include "io/input-key-requester.h" +#include "io/screen-util.h" +#include "main/sound-of-music.h" +#include "system/floor-type-definition.h" +#include "target/target-describer.h" +#include "target/target-preparation.h" +#include "target/target-types.h" +#include "target/targeting.h" // todo 相互依存. +#include "term/screen-processor.h" +#include "util/int-char-converter.h" +#include "window/main-window-util.h" + +/*! + * @brief フォーカスを当てるべきマップ描画の基準座標を指定する + * @param creature_ptr プレーヤーへの参照ポインタ + * @param y 変更先のフロアY座標 + * @param x 変更先のフロアX座標 + * @details + * Handle a request to change the current panel + * Return TRUE if the panel was changed. + * Also used in do_cmd_locate + * @return 実際に再描画が必要だった場合TRUEを返す + */ +static bool change_panel_xy(player_type *creature_ptr, POSITION y, POSITION x) +{ + POSITION dy = 0, dx = 0; + TERM_LEN wid, hgt; + get_screen_size(&wid, &hgt); + if (y < panel_row_min) + dy = -1; + + if (y > panel_row_max) + dy = 1; + + if (x < panel_col_min) + dx = -1; + + if (x > panel_col_max) + dx = 1; + + if (!dy && !dx) + return FALSE; + + return change_panel(creature_ptr, dy, dx); +} + +/* + * Help "select" a location (see below) + */ +static POSITION_IDX target_pick(POSITION y1, POSITION x1, POSITION dy, POSITION dx) +{ + POSITION_IDX b_i = -1, b_v = 9999; + for (POSITION_IDX i = 0; i < tmp_pos.n; i++) { + POSITION x2 = tmp_pos.x[i]; + POSITION y2 = tmp_pos.y[i]; + POSITION x3 = (x2 - x1); + POSITION y3 = (y2 - y1); + if (dx && (x3 * dx <= 0)) + continue; + + if (dy && (y3 * dy <= 0)) + continue; + + POSITION x4 = ABS(x3); + POSITION y4 = ABS(y3); + if (dy && !dx && (x4 > y4)) + continue; + + if (dx && !dy && (y4 > x4)) + continue; + + POSITION_IDX v = ((x4 > y4) ? (x4 + x4 + y4) : (y4 + y4 + x4)); + if ((b_i >= 0) && (v >= b_v)) + continue; + + b_i = i; + b_v = v; + } + + return b_i; +} + +/* + * Handle "target" and "look". + */ +bool target_set(player_type *creature_ptr, target_type mode) +{ + POSITION y = creature_ptr->y; + POSITION x = creature_ptr->x; + bool done = FALSE; + bool flag = TRUE; + char query; + char info[80]; + grid_type *g_ptr; + TERM_LEN wid, hgt; + get_screen_size(&wid, &hgt); + target_who = 0; + const char same_key = rogue_like_commands ? 'x' : 'l'; + target_set_prepare(creature_ptr, mode); + int m = 0; + floor_type *floor_ptr = creature_ptr->current_floor_ptr; + while (!done) { + if (flag && tmp_pos.n) { + y = tmp_pos.y[m]; + x = tmp_pos.x[m]; + change_panel_xy(creature_ptr, y, x); + if (!(mode & TARGET_LOOK)) + print_path(creature_ptr, y, x); + + g_ptr = &floor_ptr->grid_array[y][x]; + if (target_able(creature_ptr, g_ptr->m_idx)) + strcpy(info, _("q止 t決 p自 o現 +次 -前", "q,t,p,o,+,-,")); + else + strcpy(info, _("q止 p自 o現 +次 -前", "q,p,o,+,-,")); + + if (cheat_sight) { + char cheatinfo[30]; + sprintf(cheatinfo, " LOS:%d, PROJECTABLE:%d", los(creature_ptr, creature_ptr->y, creature_ptr->x, y, x), + projectable(creature_ptr, creature_ptr->y, creature_ptr->x, y, x)); + strcat(info, cheatinfo); + } + + while (TRUE) { + query = examine_grid(creature_ptr, y, x, mode, info); + if (query) + break; + } + + int d = 0; + if (use_menu) { + if (query == '\r') + query = 't'; + } + + switch (query) { + case ESCAPE: + case 'q': { + done = TRUE; + break; + } + case 't': + case '.': + case '5': + case '0': { + if (!target_able(creature_ptr, g_ptr->m_idx)) { + bell(); + break; + } + + health_track(creature_ptr, g_ptr->m_idx); + target_who = g_ptr->m_idx; + target_row = y; + target_col = x; + done = TRUE; + break; + } + case ' ': + case '*': + case '+': { + if (++m == tmp_pos.n) { + m = 0; + if (!expand_list) + done = TRUE; + } + + break; + } + case '-': { + if (m-- == 0) { + m = tmp_pos.n - 1; + if (!expand_list) + done = TRUE; + } + + break; + } + case 'p': { + verify_panel(creature_ptr); + creature_ptr->update |= PU_MONSTERS; + creature_ptr->redraw |= PR_MAP; + creature_ptr->window |= PW_OVERHEAD; + handle_stuff(creature_ptr); + target_set_prepare(creature_ptr, mode); + y = creature_ptr->y; + x = creature_ptr->x; + } + /* Fall through */ + case 'o': + flag = FALSE; + break; + case 'm': + break; + default: { + if (query == same_key) { + if (++m == tmp_pos.n) { + m = 0; + if (!expand_list) + done = TRUE; + } + } else { + d = get_keymap_dir(query); + if (!d) + bell(); + + break; + } + } + } + + if (d) { + POSITION y2 = panel_row_min; + POSITION x2 = panel_col_min; + int i = target_pick(tmp_pos.y[m], tmp_pos.x[m], ddy[d], ddx[d]); + while (flag && (i < 0)) { + if (change_panel(creature_ptr, ddy[d], ddx[d])) { + int v = tmp_pos.y[m]; + int u = tmp_pos.x[m]; + target_set_prepare(creature_ptr, mode); + flag = TRUE; + i = target_pick(v, u, ddy[d], ddx[d]); + if (i >= 0) + m = i; + + continue; + } + + POSITION dx = ddx[d]; + POSITION dy = ddy[d]; + panel_row_min = y2; + panel_col_min = x2; + panel_bounds_center(); + creature_ptr->update |= (PU_MONSTERS); + creature_ptr->redraw |= (PR_MAP); + creature_ptr->window |= (PW_OVERHEAD); + handle_stuff(creature_ptr); + target_set_prepare(creature_ptr, mode); + flag = FALSE; + x += dx; + y += dy; + if (((x < panel_col_min + wid / 2) && (dx > 0)) || ((x > panel_col_min + wid / 2) && (dx < 0))) + dx = 0; + + if (((y < panel_row_min + hgt / 2) && (dy > 0)) || ((y > panel_row_min + hgt / 2) && (dy < 0))) + dy = 0; + + if ((y >= panel_row_min + hgt) || (y < panel_row_min) || (x >= panel_col_min + wid) || (x < panel_col_min)) { + if (change_panel(creature_ptr, dy, dx)) + target_set_prepare(creature_ptr, mode); + } + + if (x >= floor_ptr->width - 1) + x = floor_ptr->width - 2; + else if (x <= 0) + x = 1; + + if (y >= floor_ptr->height - 1) + y = floor_ptr->height - 2; + else if (y <= 0) + y = 1; + } + + m = i; + } + + continue; + } + + bool move_fast = FALSE; + if (!(mode & TARGET_LOOK)) + print_path(creature_ptr, y, x); + + g_ptr = &floor_ptr->grid_array[y][x]; + strcpy(info, _("q止 t決 p自 m近 +次 -前", "q,t,p,m,+,-,")); + if (cheat_sight) { + char cheatinfo[100]; + sprintf(cheatinfo, " LOS:%d, PROJECTABLE:%d, SPECIAL:%d", los(creature_ptr, creature_ptr->y, creature_ptr->x, y, x), + projectable(creature_ptr, creature_ptr->y, creature_ptr->x, y, x), g_ptr->special); + strcat(info, cheatinfo); + } + + /* Describe and Prompt (enable "TARGET_LOOK") */ + while ((query = examine_grid(creature_ptr, y, x, mode | TARGET_LOOK, info)) == 0) + ; + + int d = 0; + if (use_menu && (query == '\r')) + query = 't'; + + switch (query) { + case ESCAPE: + case 'q': + done = TRUE; + break; + case 't': + case '.': + case '5': + case '0': + target_who = -1; + target_row = y; + target_col = x; + done = TRUE; + break; + case 'p': + verify_panel(creature_ptr); + creature_ptr->update |= (PU_MONSTERS); + creature_ptr->redraw |= (PR_MAP); + creature_ptr->window |= (PW_OVERHEAD); + handle_stuff(creature_ptr); + target_set_prepare(creature_ptr, mode); + y = creature_ptr->y; + x = creature_ptr->x; + case 'o': + break; + case ' ': + case '*': + case '+': + case '-': + case 'm': { + flag = TRUE; + m = 0; + int bd = 999; + for (int i = 0; i < tmp_pos.n; i++) { + int t = distance(y, x, tmp_pos.y[i], tmp_pos.x[i]); + if (t < bd) { + m = i; + bd = t; + } + } + + if (bd == 999) + flag = FALSE; + + break; + } + default: { + d = get_keymap_dir(query); + if (isupper(query)) + move_fast = TRUE; + + if (!d) + bell(); + break; + } + } + + if (d) { + POSITION dx = ddx[d]; + POSITION dy = ddy[d]; + if (move_fast) { + int mag = MIN(wid / 2, hgt / 2); + x += dx * mag; + y += dy * mag; + } else { + x += dx; + y += dy; + } + + if (((x < panel_col_min + wid / 2) && (dx > 0)) || ((x > panel_col_min + wid / 2) && (dx < 0))) + dx = 0; + + if (((y < panel_row_min + hgt / 2) && (dy > 0)) || ((y > panel_row_min + hgt / 2) && (dy < 0))) + dy = 0; + + if ((y >= panel_row_min + hgt) || (y < panel_row_min) || (x >= panel_col_min + wid) || (x < panel_col_min)) { + if (change_panel(creature_ptr, dy, dx)) + target_set_prepare(creature_ptr, mode); + } + + if (x >= floor_ptr->width - 1) + x = floor_ptr->width - 2; + else if (x <= 0) + x = 1; + + if (y >= floor_ptr->height - 1) + y = floor_ptr->height - 2; + else if (y <= 0) + y = 1; + } + } + + tmp_pos.n = 0; + prt("", 0, 0); + verify_panel(creature_ptr); + creature_ptr->update |= (PU_MONSTERS); + creature_ptr->redraw |= (PR_MAP); + creature_ptr->window |= (PW_OVERHEAD); + handle_stuff(creature_ptr); + return target_who != 0; +} diff --git a/src/target/target-setter.h b/src/target/target-setter.h new file mode 100644 index 000000000..87bffdc13 --- /dev/null +++ b/src/target/target-setter.h @@ -0,0 +1,6 @@ +#pragma once + +#include "system/angband.h" + +typedef enum target_type target_type; +bool target_set(player_type *creature_ptr, target_type mode); diff --git a/src/target/targeting.c b/src/target/targeting.c index 99f7fb721..42c275a84 100644 --- a/src/target/targeting.c +++ b/src/target/targeting.c @@ -65,7 +65,8 @@ #include "system/system-variables.h" #include "target/target-describer.h" #include "target/target-preparation.h" -#include "target/target-types.h" +#include "target/target-setter.h" +#include "target/target-types.h" // todo 相互依存. #include "term/screen-processor.h" #include "term/term-color-types.h" #include "util/bit-flags-calculator.h" @@ -186,384 +187,6 @@ bool target_okay(player_type *creature_ptr) return TRUE; } -/*! - * @brief フォーカスを当てるべきマップ描画の基準座標を指定する - * @param creature_ptr プレーヤーへの参照ポインタ - * @param y 変更先のフロアY座標 - * @param x 変更先のフロアX座標 - * @details - * Handle a request to change the current panel - * Return TRUE if the panel was changed. - * Also used in do_cmd_locate - * @return 実際に再描画が必要だった場合TRUEを返す - */ -static bool change_panel_xy(player_type *creature_ptr, POSITION y, POSITION x) -{ - POSITION dy = 0, dx = 0; - TERM_LEN wid, hgt; - get_screen_size(&wid, &hgt); - if (y < panel_row_min) - dy = -1; - - if (y > panel_row_max) - dy = 1; - - if (x < panel_col_min) - dx = -1; - - if (x > panel_col_max) - dx = 1; - - if (!dy && !dx) - return FALSE; - - return change_panel(creature_ptr, dy, dx); -} - -/* - * Help "select" a location (see below) - */ -static POSITION_IDX target_pick(POSITION y1, POSITION x1, POSITION dy, POSITION dx) -{ - POSITION_IDX b_i = -1, b_v = 9999; - for (POSITION_IDX i = 0; i < tmp_pos.n; i++) { - POSITION x2 = tmp_pos.x[i]; - POSITION y2 = tmp_pos.y[i]; - POSITION x3 = (x2 - x1); - POSITION y3 = (y2 - y1); - if (dx && (x3 * dx <= 0)) - continue; - - if (dy && (y3 * dy <= 0)) - continue; - - POSITION x4 = ABS(x3); - POSITION y4 = ABS(y3); - if (dy && !dx && (x4 > y4)) - continue; - - if (dx && !dy && (y4 > x4)) - continue; - - POSITION_IDX v = ((x4 > y4) ? (x4 + x4 + y4) : (y4 + y4 + x4)); - if ((b_i >= 0) && (v >= b_v)) - continue; - - b_i = i; - b_v = v; - } - - return b_i; -} - -/* - * Handle "target" and "look". - */ -bool target_set(player_type *creature_ptr, target_type mode) -{ - POSITION y = creature_ptr->y; - POSITION x = creature_ptr->x; - bool done = FALSE; - bool flag = TRUE; - char query; - char info[80]; - grid_type *g_ptr; - TERM_LEN wid, hgt; - get_screen_size(&wid, &hgt); - target_who = 0; - const char same_key = rogue_like_commands ? 'x' : 'l'; - target_set_prepare(creature_ptr, mode); - int m = 0; - floor_type *floor_ptr = creature_ptr->current_floor_ptr; - while (!done) { - if (flag && tmp_pos.n) { - y = tmp_pos.y[m]; - x = tmp_pos.x[m]; - change_panel_xy(creature_ptr, y, x); - if (!(mode & TARGET_LOOK)) - print_path(creature_ptr, y, x); - - g_ptr = &floor_ptr->grid_array[y][x]; - if (target_able(creature_ptr, g_ptr->m_idx)) - strcpy(info, _("q止 t決 p自 o現 +次 -前", "q,t,p,o,+,-,")); - else - strcpy(info, _("q止 p自 o現 +次 -前", "q,p,o,+,-,")); - - if (cheat_sight) { - char cheatinfo[30]; - sprintf(cheatinfo, " LOS:%d, PROJECTABLE:%d", los(creature_ptr, creature_ptr->y, creature_ptr->x, y, x), - projectable(creature_ptr, creature_ptr->y, creature_ptr->x, y, x)); - strcat(info, cheatinfo); - } - - while (TRUE) { - query = examine_grid(creature_ptr, y, x, mode, info); - if (query) - break; - } - - int d = 0; - if (use_menu) { - if (query == '\r') - query = 't'; - } - - switch (query) { - case ESCAPE: - case 'q': { - done = TRUE; - break; - } - case 't': - case '.': - case '5': - case '0': { - if (!target_able(creature_ptr, g_ptr->m_idx)) { - bell(); - break; - } - - health_track(creature_ptr, g_ptr->m_idx); - target_who = g_ptr->m_idx; - target_row = y; - target_col = x; - done = TRUE; - break; - } - case ' ': - case '*': - case '+': { - if (++m == tmp_pos.n) { - m = 0; - if (!expand_list) - done = TRUE; - } - - break; - } - case '-': { - if (m-- == 0) { - m = tmp_pos.n - 1; - if (!expand_list) - done = TRUE; - } - - break; - } - case 'p': { - verify_panel(creature_ptr); - creature_ptr->update |= (PU_MONSTERS); - creature_ptr->redraw |= (PR_MAP); - creature_ptr->window |= (PW_OVERHEAD); - handle_stuff(creature_ptr); - target_set_prepare(creature_ptr, mode); - y = creature_ptr->y; - x = creature_ptr->x; - } - /* Fall through */ - case 'o': - flag = FALSE; - break; - case 'm': - break; - default: { - if (query == same_key) { - if (++m == tmp_pos.n) { - m = 0; - if (!expand_list) - done = TRUE; - } - } else { - d = get_keymap_dir(query); - if (!d) - bell(); - - break; - } - } - } - - if (d) { - POSITION y2 = panel_row_min; - POSITION x2 = panel_col_min; - int i = target_pick(tmp_pos.y[m], tmp_pos.x[m], ddy[d], ddx[d]); - while (flag && (i < 0)) { - if (change_panel(creature_ptr, ddy[d], ddx[d])) { - int v = tmp_pos.y[m]; - int u = tmp_pos.x[m]; - target_set_prepare(creature_ptr, mode); - flag = TRUE; - i = target_pick(v, u, ddy[d], ddx[d]); - if (i >= 0) - m = i; - - continue; - } - - POSITION dx = ddx[d]; - POSITION dy = ddy[d]; - panel_row_min = y2; - panel_col_min = x2; - panel_bounds_center(); - creature_ptr->update |= (PU_MONSTERS); - creature_ptr->redraw |= (PR_MAP); - creature_ptr->window |= (PW_OVERHEAD); - handle_stuff(creature_ptr); - target_set_prepare(creature_ptr, mode); - flag = FALSE; - x += dx; - y += dy; - if (((x < panel_col_min + wid / 2) && (dx > 0)) || ((x > panel_col_min + wid / 2) && (dx < 0))) - dx = 0; - - if (((y < panel_row_min + hgt / 2) && (dy > 0)) || ((y > panel_row_min + hgt / 2) && (dy < 0))) - dy = 0; - - if ((y >= panel_row_min + hgt) || (y < panel_row_min) || (x >= panel_col_min + wid) || (x < panel_col_min)) { - if (change_panel(creature_ptr, dy, dx)) - target_set_prepare(creature_ptr, mode); - } - - if (x >= floor_ptr->width - 1) - x = floor_ptr->width - 2; - else if (x <= 0) - x = 1; - - if (y >= floor_ptr->height - 1) - y = floor_ptr->height - 2; - else if (y <= 0) - y = 1; - } - - m = i; - } - - continue; - } - - bool move_fast = FALSE; - if (!(mode & TARGET_LOOK)) - print_path(creature_ptr, y, x); - - g_ptr = &floor_ptr->grid_array[y][x]; - strcpy(info, _("q止 t決 p自 m近 +次 -前", "q,t,p,m,+,-,")); - if (cheat_sight) { - char cheatinfo[100]; - sprintf(cheatinfo, " LOS:%d, PROJECTABLE:%d, SPECIAL:%d", los(creature_ptr, creature_ptr->y, creature_ptr->x, y, x), - projectable(creature_ptr, creature_ptr->y, creature_ptr->x, y, x), g_ptr->special); - strcat(info, cheatinfo); - } - - /* Describe and Prompt (enable "TARGET_LOOK") */ - while ((query = examine_grid(creature_ptr, y, x, mode | TARGET_LOOK, info)) == 0) - ; - - int d = 0; - if (use_menu && (query == '\r')) - query = 't'; - - switch (query) { - case ESCAPE: - case 'q': - done = TRUE; - break; - case 't': - case '.': - case '5': - case '0': - target_who = -1; - target_row = y; - target_col = x; - done = TRUE; - break; - case 'p': - verify_panel(creature_ptr); - creature_ptr->update |= (PU_MONSTERS); - creature_ptr->redraw |= (PR_MAP); - creature_ptr->window |= (PW_OVERHEAD); - handle_stuff(creature_ptr); - target_set_prepare(creature_ptr, mode); - y = creature_ptr->y; - x = creature_ptr->x; - case 'o': - break; - case ' ': - case '*': - case '+': - case '-': - case 'm': { - flag = TRUE; - m = 0; - int bd = 999; - for (int i = 0; i < tmp_pos.n; i++) { - int t = distance(y, x, tmp_pos.y[i], tmp_pos.x[i]); - if (t < bd) { - m = i; - bd = t; - } - } - - if (bd == 999) - flag = FALSE; - - break; - } - default: { - d = get_keymap_dir(query); - if (isupper(query)) - move_fast = TRUE; - - if (!d) - bell(); - break; - } - } - - if (d) { - POSITION dx = ddx[d]; - POSITION dy = ddy[d]; - if (move_fast) { - int mag = MIN(wid / 2, hgt / 2); - x += dx * mag; - y += dy * mag; - } else { - x += dx; - y += dy; - } - - if (((x < panel_col_min + wid / 2) && (dx > 0)) || ((x > panel_col_min + wid / 2) && (dx < 0))) - dx = 0; - - if (((y < panel_row_min + hgt / 2) && (dy > 0)) || ((y > panel_row_min + hgt / 2) && (dy < 0))) - dy = 0; - - if ((y >= panel_row_min + hgt) || (y < panel_row_min) || (x >= panel_col_min + wid) || (x < panel_col_min)) { - if (change_panel(creature_ptr, dy, dx)) - target_set_prepare(creature_ptr, mode); - } - - if (x >= floor_ptr->width - 1) - x = floor_ptr->width - 2; - else if (x <= 0) - x = 1; - - if (y >= floor_ptr->height - 1) - y = floor_ptr->height - 2; - else if (y <= 0) - y = 1; - } - } - - tmp_pos.n = 0; - prt("", 0, 0); - verify_panel(creature_ptr); - creature_ptr->update |= (PU_MONSTERS); - creature_ptr->redraw |= (PR_MAP); - creature_ptr->window |= (PW_OVERHEAD); - handle_stuff(creature_ptr); - return target_who != 0; -} - /* * Get an "aiming direction" from the user. * diff --git a/src/target/targeting.h b/src/target/targeting.h index b022d9f14..36ac3e910 100644 --- a/src/target/targeting.h +++ b/src/target/targeting.h @@ -6,9 +6,6 @@ extern MONSTER_IDX target_who; extern POSITION target_col; extern POSITION target_row; -typedef enum target_type target_type; -bool target_set(player_type *creature_ptr, target_type mode); - void verify_panel(player_type *creature_ptr); bool target_okay(player_type *creature_ptr); bool get_aim_dir(player_type *creature_ptr, DIRECTION *dp); -- 2.11.0