• R/O
  • HTTP
  • SSH
  • HTTPS

hengband: Commit

変愚蛮怒のメインリポジトリです


Commit MetaInfo

Revision4c1ca9537627ec14c006802131e234ba2f2c2cd0 (tree)
Time2019-03-14 14:58:17
Authordeskull <deskull@user...>
Commiterdeskull

Log Message

[Refactor] #37353 kind_is_good() to objectkind-hook.c.

Change Summary

Incremental Difference

--- a/src/object2.c
+++ b/src/object2.c
@@ -15,6 +15,7 @@
1515 #include "object-boost.h"
1616 #include "object-hook.h"
1717 #include "object-curse.h"
18+#include "objectkind-hook.h"
1819 #include "artifact.h"
1920 #include "player-status.h"
2021 #include "feature.h"
@@ -4299,92 +4300,6 @@ void apply_magic(object_type *o_ptr, DEPTH lev, BIT_FLAGS mode)
42994300
43004301
43014302 /*!
4302- * @brief ベースアイテムが上質として扱われるかどうかを返す。
4303- * Hack -- determine if a template is "good"
4304- * @param k_idx 判定したいベースアイテムのID
4305- * @return ベースアイテムが上質ならばTRUEを返す。
4306- */
4307-static bool kind_is_good(KIND_OBJECT_IDX k_idx)
4308-{
4309- object_kind *k_ptr = &k_info[k_idx];
4310-
4311- /* Analyze the item type */
4312- switch (k_ptr->tval)
4313- {
4314- /* Armor -- Good unless damaged */
4315- case TV_HARD_ARMOR:
4316- case TV_SOFT_ARMOR:
4317- case TV_DRAG_ARMOR:
4318- case TV_SHIELD:
4319- case TV_CLOAK:
4320- case TV_BOOTS:
4321- case TV_GLOVES:
4322- case TV_HELM:
4323- case TV_CROWN:
4324- {
4325- if (k_ptr->to_a < 0) return (FALSE);
4326- return (TRUE);
4327- }
4328-
4329- /* Weapons -- Good unless damaged */
4330- case TV_BOW:
4331- case TV_SWORD:
4332- case TV_HAFTED:
4333- case TV_POLEARM:
4334- case TV_DIGGING:
4335- {
4336- if (k_ptr->to_h < 0) return (FALSE);
4337- if (k_ptr->to_d < 0) return (FALSE);
4338- return (TRUE);
4339- }
4340-
4341- /* Ammo -- Arrows/Bolts are good */
4342- case TV_BOLT:
4343- case TV_ARROW:
4344- {
4345- return (TRUE);
4346- }
4347-
4348- /* Books -- High level books are good (except Arcane books) */
4349- case TV_LIFE_BOOK:
4350- case TV_SORCERY_BOOK:
4351- case TV_NATURE_BOOK:
4352- case TV_CHAOS_BOOK:
4353- case TV_DEATH_BOOK:
4354- case TV_TRUMP_BOOK:
4355- case TV_CRAFT_BOOK:
4356- case TV_DAEMON_BOOK:
4357- case TV_CRUSADE_BOOK:
4358- case TV_MUSIC_BOOK:
4359- case TV_HISSATSU_BOOK:
4360- case TV_HEX_BOOK:
4361- {
4362- if (k_ptr->sval >= SV_BOOK_MIN_GOOD) return (TRUE);
4363- return (FALSE);
4364- }
4365-
4366- /* Rings -- Rings of Speed are good */
4367- case TV_RING:
4368- {
4369- if (k_ptr->sval == SV_RING_SPEED) return (TRUE);
4370- if (k_ptr->sval == SV_RING_LORDLY) return (TRUE);
4371- return (FALSE);
4372- }
4373-
4374- /* Amulets -- Amulets of the Magi and Resistance are good */
4375- case TV_AMULET:
4376- {
4377- if (k_ptr->sval == SV_AMULET_THE_MAGI) return (TRUE);
4378- if (k_ptr->sval == SV_AMULET_RESISTANCE) return (TRUE);
4379- return (FALSE);
4380- }
4381- }
4382-
4383- /* Assume not good */
4384- return (FALSE);
4385-}
4386-
4387-/*!
43884303 * @brief 生成階に応じたベースアイテムの生成を行う。
43894304 * Attempt to make an object (normal or good/great)
43904305 * @param j_ptr 生成結果を収めたいオブジェクト構造体の参照ポインタ
--- a/src/objectkind-hook.c
+++ b/src/objectkind-hook.c
@@ -154,3 +154,89 @@ bool kind_is_potion(KIND_OBJECT_IDX k_idx)
154154 {
155155 return k_info[k_idx].tval == TV_POTION;
156156 }
157+
158+/*!
159+ * @brief ベースアイテムが上質として扱われるかどうかを返す。
160+ * Hack -- determine if a template is "good"
161+ * @param k_idx 判定したいベースアイテムのID
162+ * @return ベースアイテムが上質ならばTRUEを返す。
163+ */
164+bool kind_is_good(KIND_OBJECT_IDX k_idx)
165+{
166+ object_kind *k_ptr = &k_info[k_idx];
167+
168+ /* Analyze the item type */
169+ switch (k_ptr->tval)
170+ {
171+ /* Armor -- Good unless damaged */
172+ case TV_HARD_ARMOR:
173+ case TV_SOFT_ARMOR:
174+ case TV_DRAG_ARMOR:
175+ case TV_SHIELD:
176+ case TV_CLOAK:
177+ case TV_BOOTS:
178+ case TV_GLOVES:
179+ case TV_HELM:
180+ case TV_CROWN:
181+ {
182+ if (k_ptr->to_a < 0) return (FALSE);
183+ return (TRUE);
184+ }
185+
186+ /* Weapons -- Good unless damaged */
187+ case TV_BOW:
188+ case TV_SWORD:
189+ case TV_HAFTED:
190+ case TV_POLEARM:
191+ case TV_DIGGING:
192+ {
193+ if (k_ptr->to_h < 0) return (FALSE);
194+ if (k_ptr->to_d < 0) return (FALSE);
195+ return (TRUE);
196+ }
197+
198+ /* Ammo -- Arrows/Bolts are good */
199+ case TV_BOLT:
200+ case TV_ARROW:
201+ {
202+ return (TRUE);
203+ }
204+
205+ /* Books -- High level books are good (except Arcane books) */
206+ case TV_LIFE_BOOK:
207+ case TV_SORCERY_BOOK:
208+ case TV_NATURE_BOOK:
209+ case TV_CHAOS_BOOK:
210+ case TV_DEATH_BOOK:
211+ case TV_TRUMP_BOOK:
212+ case TV_CRAFT_BOOK:
213+ case TV_DAEMON_BOOK:
214+ case TV_CRUSADE_BOOK:
215+ case TV_MUSIC_BOOK:
216+ case TV_HISSATSU_BOOK:
217+ case TV_HEX_BOOK:
218+ {
219+ if (k_ptr->sval >= SV_BOOK_MIN_GOOD) return (TRUE);
220+ return (FALSE);
221+ }
222+
223+ /* Rings -- Rings of Speed are good */
224+ case TV_RING:
225+ {
226+ if (k_ptr->sval == SV_RING_SPEED) return (TRUE);
227+ if (k_ptr->sval == SV_RING_LORDLY) return (TRUE);
228+ return (FALSE);
229+ }
230+
231+ /* Amulets -- Amulets of the Magi and Resistance are good */
232+ case TV_AMULET:
233+ {
234+ if (k_ptr->sval == SV_AMULET_THE_MAGI) return (TRUE);
235+ if (k_ptr->sval == SV_AMULET_RESISTANCE) return (TRUE);
236+ return (FALSE);
237+ }
238+ }
239+
240+ /* Assume not good */
241+ return (FALSE);
242+}
--- a/src/objectkind-hook.h
+++ b/src/objectkind-hook.h
@@ -7,6 +7,7 @@ bool kind_is_good_book(KIND_OBJECT_IDX k_idx);
77 bool kind_is_armor(KIND_OBJECT_IDX k_idx);
88 bool kind_is_hafted(KIND_OBJECT_IDX k_idx);
99 bool kind_is_potion(KIND_OBJECT_IDX k_idx);
10+bool kind_is_good(KIND_OBJECT_IDX k_idx);
1011
1112
1213
Show on old repository browser