OSDN Git Service

[Fix] #41266 名前の長いモンスターを検索するとソフトウェアがクラッシュする問題を解消した / Resolved the issue that software...
[hengband/hengband.git] / src / object / lite-processor.c
1 #include "object/lite-processor.h"
2 #include "core/disturbance.h"
3 #include "core/player-update-types.h"
4 #include "core/window-redrawer.h"
5 #include "game-option/disturbance-options.h"
6 #include "inventory/inventory-slot-types.h"
7 #include "object-enchant/object-ego.h"
8 #include "object-hook/hook-enchant.h"
9 #include "sv-definition/sv-lite-types.h"
10 #include "view/display-messages.h"
11 #include "world/world.h"
12
13 /*!
14  * @brief 10ゲームターンが進行する毎に光源の寿命を減らす処理
15  * / Handle burning fuel every 10 game turns
16  * @return なし
17  */
18 void reduce_lite_life(player_type* creature_ptr)
19 {
20     object_type* o_ptr = &creature_ptr->inventory_list[INVEN_LITE];
21     if (o_ptr->tval != TV_LITE)
22         return;
23
24     if (object_is_fixed_artifact(o_ptr) || (o_ptr->sval == SV_LITE_FEANOR) || (o_ptr->xtra4 <= 0))
25         return;
26
27     if (o_ptr->name2 == EGO_LITE_LONG) {
28         if (current_world_ptr->game_turn % (TURNS_PER_TICK * 2))
29             o_ptr->xtra4--;
30     } else
31         o_ptr->xtra4--;
32
33     notice_lite_change(creature_ptr, o_ptr);
34 }
35
36 /*!
37  * @brief 寿命つき光源の警告メッセージ処理
38  * @param creature_ptr プレーヤーへの参照ポインタ
39  * @param o_ptr 現在光源として使っているオブジェクトの構造体参照ポインタ
40  * @return なし
41  */
42 void notice_lite_change(player_type* creature_ptr, object_type* o_ptr)
43 {
44     if ((o_ptr->xtra4 < 100) || (!(o_ptr->xtra4 % 100))) {
45         creature_ptr->window |= (PW_EQUIP);
46     }
47
48     if (creature_ptr->blind) {
49         if (o_ptr->xtra4 == 0)
50             o_ptr->xtra4++;
51     } else if (o_ptr->xtra4 == 0) {
52         disturb(creature_ptr, FALSE, TRUE);
53         msg_print(_("明かりが消えてしまった!", "Your light has gone out!"));
54         creature_ptr->update |= (PU_TORCH);
55         creature_ptr->update |= (PU_BONUS);
56     } else if (o_ptr->name2 == EGO_LITE_LONG) {
57         if ((o_ptr->xtra4 < 50) && (!(o_ptr->xtra4 % 5))
58             && (current_world_ptr->game_turn % (TURNS_PER_TICK * 2))) {
59             if (disturb_minor)
60                 disturb(creature_ptr, FALSE, TRUE);
61             msg_print(_("明かりが微かになってきている。", "Your light is growing faint."));
62         }
63     } else if ((o_ptr->xtra4 < 100) && (!(o_ptr->xtra4 % 10))) {
64         if (disturb_minor)
65             disturb(creature_ptr, FALSE, TRUE);
66         msg_print(_("明かりが微かになってきている。", "Your light is growing faint."));
67     }
68 }