OSDN Git Service

Merge pull request #1186 from dis-/feature/Fix-calc_num_fire
[hengbandforosx/hengbandosx.git] / src / core / stuff-handler.cpp
1 #include "core/stuff-handler.h"
2 #include "core/player-redraw-types.h"
3 #include "core/player-update-types.h"
4 #include "core/window-redrawer.h"
5 #include "player/player-status.h"
6 #include "system/player-type-definition.h"
7
8 /*!
9  * @brief 全更新処理をチェックして処理していく
10  * Handle "player_ptr->update" and "player_ptr->redraw" and "player_ptr->window"
11  */
12 void handle_stuff(player_type* player_ptr)
13 {
14     if (player_ptr->update)
15         update_creature(player_ptr);
16     if (player_ptr->redraw)
17         redraw_stuff(player_ptr);
18     if (player_ptr->window_flags)
19         window_stuff(player_ptr);
20 }
21
22 /*
23  * Track the given monster race
24  */
25 void monster_race_track(player_type *player_ptr, MONRACE_IDX r_idx)
26 {
27     player_ptr->monster_race_idx = r_idx;
28     player_ptr->window_flags |= (PW_MONSTER);
29 }
30
31 /*
32  * Track the given object kind
33  */
34 void object_kind_track(player_type *player_ptr, KIND_OBJECT_IDX k_idx)
35 {
36     player_ptr->object_kind_idx = k_idx;
37     player_ptr->window_flags |= (PW_OBJECT);
38 }
39
40 /*
41  * Track a new monster
42  * @param player_ptr プレーヤーへの参照ポインタ
43  * @param m_idx トラッキング対象のモンスターID。0の時キャンセル
44  * @param なし
45  */
46 void health_track(player_type *player_ptr, MONSTER_IDX m_idx)
47 {
48     if (m_idx && m_idx == player_ptr->riding)
49         return;
50
51     player_ptr->health_who = m_idx;
52     player_ptr->redraw |= (PR_HEALTH);
53 }
54
55 bool update_player(player_type *caster_ptr)
56 {
57     caster_ptr->update |= PU_COMBINE | PU_REORDER;
58     caster_ptr->window_flags |= PW_INVEN;
59     return true;
60 }
61
62 bool redraw_player(player_type *caster_ptr)
63 {
64     if (caster_ptr->csp > caster_ptr->msp) {
65         caster_ptr->csp = caster_ptr->msp;
66     }
67
68     caster_ptr->redraw |= PR_MANA;
69     caster_ptr->update |= PU_COMBINE | PU_REORDER;
70     caster_ptr->window_flags |= PW_INVEN;
71     return true;
72 }