OSDN Git Service

Merge remote-tracking branch 'remotes/hengbandosx/english-market-edits' into feature...
[hengband/hengband.git] / src / pet / pet-util.c
1 #include "pet/pet-util.h"
2 #include "core/player-update-types.h"
3 #include "core/stuff-handler.h"
4 #include "monster/monster-info.h"
5 #include "world/world.h"
6
7 /*!
8  * @brief プレイヤーの騎乗/下馬処理判定
9  * @param g_ptr プレイヤーの移動先マスの構造体参照ポインタ
10  * @param now_riding TRUEなら下馬処理、FALSEならば騎乗処理
11  * @return 可能ならばTRUEを返す
12  */
13 bool can_player_ride_pet(player_type *creature_ptr, grid_type *g_ptr, bool now_riding)
14 {
15     bool old_character_xtra = current_world_ptr->character_xtra;
16     MONSTER_IDX old_riding = creature_ptr->riding;
17     bool old_riding_two_hands = creature_ptr->riding_ryoute;
18     bool old_old_riding_two_hands = creature_ptr->old_riding_ryoute;
19     bool old_pf_two_hands = (creature_ptr->pet_extra_flags & PF_TWO_HANDS) ? TRUE : FALSE;
20     current_world_ptr->character_xtra = TRUE;
21
22     if (now_riding)
23         creature_ptr->riding = g_ptr->m_idx;
24     else {
25         creature_ptr->riding = 0;
26         creature_ptr->pet_extra_flags &= ~(PF_TWO_HANDS);
27         creature_ptr->riding_ryoute = creature_ptr->old_riding_ryoute = FALSE;
28     }
29
30     creature_ptr->update |= PU_BONUS;
31     handle_stuff(creature_ptr);
32
33     bool p_can_enter = player_can_enter(creature_ptr, g_ptr->feat, CEM_P_CAN_ENTER_PATTERN);
34     creature_ptr->riding = old_riding;
35     if (old_pf_two_hands)
36         creature_ptr->pet_extra_flags |= (PF_TWO_HANDS);
37     else
38         creature_ptr->pet_extra_flags &= ~(PF_TWO_HANDS);
39
40     creature_ptr->riding_ryoute = old_riding_two_hands;
41     creature_ptr->old_riding_ryoute = old_old_riding_two_hands;
42     creature_ptr->update |= PU_BONUS;
43     handle_stuff(creature_ptr);
44
45     current_world_ptr->character_xtra = old_character_xtra;
46     return p_can_enter;
47 }