OSDN Git Service

[Add] @return を不要に書き込んだことによる警告をひとまず置換で修正.
[hengbandforosx/hengbandosx.git] / src / perception / object-perception.cpp
1 #include "perception/object-perception.h"
2 #include "flavor/flavor-describer.h"
3 #include "flavor/object-flavor-types.h"
4 #include "game-option/play-record-options.h"
5 #include "io/write-diary.h"
6 #include "object-enchant/item-feeling.h"
7 #include "object-enchant/special-object-flags.h"
8 #include "object-enchant/trg-types.h"
9 #include "object/item-tester-hooker.h" // 暫定、このファイルへ引っ越す.
10 #include "object/object-generator.h"
11 #include "object/object-kind.h"
12 #include "system/object-type-definition.h"
13 #include "system/player-type-definition.h"
14
15 /*!
16  * @brief オブジェクトを鑑定済にする /
17  * Known is true when the "attributes" of an object are "known".
18  * @param o_ptr 鑑定済にするオブジェクトの構造体参照ポインタ
19  * These include tohit, todam, toac, cost, and pval (charges).\n
20  *\n
21  * Note that "knowing" an object gives you everything that an "awareness"\n
22  * gives you, and much more.  In fact, the player is always "aware" of any\n
23  * item of which he has full "knowledge".\n
24  *\n
25  * But having full knowledge of, say, one "wand of wonder", does not, by\n
26  * itself, give you knowledge, or even awareness, of other "wands of wonder".\n
27  * It happens that most "identify" routines (including "buying from a shop")\n
28  * will make the player "aware" of the object as well as fully "know" it.\n
29  *\n
30  * This routine also removes any inscriptions generated by "feelings".\n
31  */
32 void object_known(object_type *o_ptr)
33 {
34     o_ptr->feeling = FEEL_NONE;
35     o_ptr->ident &= ~(IDENT_SENSE);
36     o_ptr->ident &= ~(IDENT_EMPTY);
37     o_ptr->ident |= (IDENT_KNOWN);
38 }
39
40 /*!
41  * @brief オブジェクトを*鑑定*済にする /
42  * The player is now aware of the effects of the given object.
43  * @param owner_ptr プレーヤーへの参照ポインタ
44  * @param o_ptr *鑑定*済にするオブジェクトの構造体参照ポインタ
45  */
46 void object_aware(player_type *owner_ptr, object_type *o_ptr)
47 {
48     const bool is_already_awared = object_is_aware(o_ptr);
49
50     k_info[o_ptr->k_idx].aware = TRUE;
51
52     // 以下、playrecordに記録しない場合はreturnする
53     if (!record_ident)
54         return;
55
56     if (is_already_awared || owner_ptr->is_dead)
57         return;
58
59     // アーティファクト専用ベースアイテムは記録しない
60     if (k_info[o_ptr->k_idx].gen_flags.has(TRG::INSTA_ART))
61         return;
62
63     // 未鑑定名の無いアイテムは記録しない
64     if (!((o_ptr->tval >= TV_AMULET && o_ptr->tval <= TV_POTION) || o_ptr->tval == TV_FOOD))
65         return;
66
67     // playrecordに識別したアイテムを記録
68     object_type forge;
69     object_type *q_ptr;
70     GAME_TEXT o_name[MAX_NLEN];
71
72     q_ptr = &forge;
73     object_copy(q_ptr, o_ptr);
74
75     q_ptr->number = 1;
76     describe_flavor(owner_ptr, o_name, q_ptr, OD_NAME_ONLY);
77
78     exe_write_diary(owner_ptr, DIARY_FOUND, 0, o_name);
79 }
80
81 /*!
82  * @brief オブジェクトを試行済にする /
83  * Something has been "sampled"
84  * @param o_ptr 試行済にするオブジェクトの構造体参照ポインタ
85  */
86 void object_tried(object_type *o_ptr) { k_info[o_ptr->k_idx].tried = TRUE; }
87
88 /*
89  * @brief 与えられたオブジェクトのベースアイテムが鑑定済かを返す / Determine if a given inventory item is "aware"
90  * @param o_ptr オブジェクトへの参照ポインタ
91  * @return 鑑定済ならTRUE
92  */
93 bool object_is_aware(object_type *o_ptr) { return k_info[(o_ptr)->k_idx].aware; }
94
95 /*
96  * Determine if a given inventory item is "tried"
97  */
98 bool object_is_tried(object_type *o_ptr) { return k_info[(o_ptr)->k_idx].tried; }
99
100 /*
101  * Determine if a given inventory item is "known"
102  * Test One -- Check for special "known" tag
103  * Test Two -- Check for "Easy Know" + "Aware"
104  */
105 bool object_is_known(object_type *o_ptr) { return ((o_ptr->ident & IDENT_KNOWN) != 0) || (k_info[(o_ptr)->k_idx].easy_know && k_info[(o_ptr)->k_idx].aware); }
106
107 bool object_is_fully_known(object_type *o_ptr) { return (o_ptr->ident & IDENT_FULL_KNOWN) != 0; }