OSDN Git Service

Merge branch 'master' of git.osdn.net:/gitroot/hengband/hengband
[hengband/hengband.git] / src / core / disturbance.c
1 #include "core/disturbance.h"
2 #include "action/travel-execution.h"
3 #include "core/player-redraw-types.h"
4 #include "core/player-update-types.h"
5 #include "game-option/disturbance-options.h"
6 #include "game-option/map-screen-options.h"
7 #include "io/input-key-requester.h"
8 #include "player/attack-defense-types.h"
9 #include "status/action-setter.h"
10 #include "target/target-checker.h"
11 #include "term/screen-processor.h"
12
13 /*
14  * Something has happened to disturb the player.
15  * The first arg indicates a major disturbance, which affects search.
16  * The second arg is currently unused, but could induce output flush.
17  * All disturbance cancels repeated commands, resting, and running.
18  */
19 void disturb(player_type *creature_ptr, bool stop_search, bool stop_travel)
20 {
21     if (command_rep) {
22         command_rep = 0;
23         creature_ptr->redraw |= PR_STATE;
24     }
25
26     if ((creature_ptr->action == ACTION_REST) || (creature_ptr->action == ACTION_FISH) || (stop_search && (creature_ptr->action == ACTION_SEARCH)))
27         set_action(creature_ptr, ACTION_NONE);
28
29     if (creature_ptr->running) {
30         creature_ptr->running = 0;
31         if (center_player && !center_running)
32             verify_panel(creature_ptr);
33
34         creature_ptr->update |= PU_TORCH;
35         creature_ptr->update |= PU_FLOW;
36     }
37
38     if (stop_travel) {
39         travel.run = 0;
40         if (center_player && !center_running)
41             verify_panel(creature_ptr);
42
43         creature_ptr->update |= PU_TORCH;
44     }
45
46     if (flush_disturb)
47         flush();
48 }