From 6b560a32ebe818bb9f5de3fb9d3910bdbf738e01 Mon Sep 17 00:00:00 2001 From: deskull Date: Mon, 4 Mar 2019 13:53:32 +0900 Subject: [PATCH] =?utf8?q?[Refactor]=20#37353=20disturb()=20=E3=82=92=20pl?= =?utf8?q?ayer-move.c=20=E3=81=AB=E7=A7=BB=E5=8B=95=E3=80=82=20/=20Move=20?= =?utf8?q?to=20disturb()=20to=20player-move.c.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/externs.h | 2 +- src/grid.c | 71 ------------------------------------------------------- src/player-move.c | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 68 insertions(+), 72 deletions(-) diff --git a/src/externs.h b/src/externs.h index c03dbd184..03c519258 100644 --- a/src/externs.h +++ b/src/externs.h @@ -469,7 +469,6 @@ extern void scatter(POSITION *yp, POSITION *xp, POSITION y, POSITION x, POSITION extern void health_track(MONSTER_IDX m_idx); extern void monster_race_track(MONRACE_IDX r_idx); extern void object_kind_track(KIND_OBJECT_IDX k_idx); -extern void disturb(bool stop_search, bool flush_output); extern void glow_deep_lava_and_bldg(void); extern bool cave_monster_teleportable_bold(MONSTER_IDX m_idx, POSITION y, POSITION x, BIT_FLAGS mode); extern bool cave_player_teleportable_bold(POSITION y, POSITION x, BIT_FLAGS mode); @@ -1398,3 +1397,4 @@ extern void kamaenaoshi(INVENTORY_IDX item); extern bool ang_sort_comp_hook(vptr u, vptr v, int a, int b); extern void ang_sort_swap_hook(vptr u, vptr v, int a, int b); +extern void disturb(bool stop_search, bool flush_output); \ No newline at end of file diff --git a/src/grid.c b/src/grid.c index 945dfab04..e462d5ea7 100644 --- a/src/grid.c +++ b/src/grid.c @@ -5517,77 +5517,6 @@ void object_kind_track(KIND_OBJECT_IDX k_idx) /* - * Something has happened to disturb the player. - * - * The first arg indicates a major disturbance, which affects search. - * - * The second arg is currently unused, but could induce output flush. - * - * All disturbance cancels repeated commands, resting, and running. - */ -void disturb(bool stop_search, bool stop_travel) -{ -#ifndef TRAVEL - /* Unused */ - stop_travel = stop_travel; -#endif - - /* Cancel auto-commands */ - /* command_new = 0; */ - - /* Cancel repeated commands */ - if (command_rep) - { - /* Cancel */ - command_rep = 0; - - /* Redraw the state (later) */ - p_ptr->redraw |= (PR_STATE); - } - - /* Cancel Resting */ - if ((p_ptr->action == ACTION_REST) || (p_ptr->action == ACTION_FISH) || (stop_search && (p_ptr->action == ACTION_SEARCH))) - { - /* Cancel */ - set_action(ACTION_NONE); - } - - /* Cancel running */ - if (running) - { - /* Cancel */ - running = 0; - - /* Check for new panel if appropriate */ - if (center_player && !center_running) verify_panel(); - - /* Calculate torch radius */ - p_ptr->update |= (PU_TORCH); - - /* Update monster flow */ - p_ptr->update |= (PU_FLOW); - } - -#ifdef TRAVEL - if (stop_travel) - { - /* Cancel */ - travel.run = 0; - - /* Check for new panel if appropriate */ - if (center_player && !center_running) verify_panel(); - - /* Calculate torch radius */ - p_ptr->update |= (PU_TORCH); - } -#endif - - /* Flush the input if requested */ - if (flush_disturb) flush(); -} - - -/* * Glow deep lava and building entrances in the floor */ void glow_deep_lava_and_bldg(void) diff --git a/src/player-move.c b/src/player-move.c index eb5ee4a63..f3cbca0b2 100644 --- a/src/player-move.c +++ b/src/player-move.c @@ -2496,3 +2496,70 @@ void do_cmd_travel(void) } } #endif + +/* + * Something has happened to disturb the player. + * The first arg indicates a major disturbance, which affects search. + * The second arg is currently unused, but could induce output flush. + * All disturbance cancels repeated commands, resting, and running. + */ +void disturb(bool stop_search, bool stop_travel) +{ +#ifndef TRAVEL + /* Unused */ + stop_travel = stop_travel; +#endif + + /* Cancel auto-commands */ + /* command_new = 0; */ + + /* Cancel repeated commands */ + if (command_rep) + { + /* Cancel */ + command_rep = 0; + + /* Redraw the state (later) */ + p_ptr->redraw |= (PR_STATE); + } + + /* Cancel Resting */ + if ((p_ptr->action == ACTION_REST) || (p_ptr->action == ACTION_FISH) || (stop_search && (p_ptr->action == ACTION_SEARCH))) + { + /* Cancel */ + set_action(ACTION_NONE); + } + + /* Cancel running */ + if (running) + { + /* Cancel */ + running = 0; + + /* Check for new panel if appropriate */ + if (center_player && !center_running) verify_panel(); + + /* Calculate torch radius */ + p_ptr->update |= (PU_TORCH); + + /* Update monster flow */ + p_ptr->update |= (PU_FLOW); + } + +#ifdef TRAVEL + if (stop_travel) + { + /* Cancel */ + travel.run = 0; + + /* Check for new panel if appropriate */ + if (center_player && !center_running) verify_panel(); + + /* Calculate torch radius */ + p_ptr->update |= (PU_TORCH); + } +#endif + + /* Flush the input if requested */ + if (flush_disturb) flush(); +} -- 2.11.0