From ae646073055b6809bd0735e702bc1092c944abd7 Mon Sep 17 00:00:00 2001 From: Hourier Date: Tue, 2 Jun 2020 21:03:37 +0900 Subject: [PATCH] [Refactor] #40399 Separated object-generator.c/h from object2.c/h --- Hengband/Hengband/Hengband.vcxproj | 2 + Hengband/Hengband/Hengband.vcxproj.filters | 6 +++ src/Makefile.am | 1 + src/birth/game-play-initializer.c | 1 + src/birth/inventory-initializer.c | 1 + src/cmd-item/cmd-eat.c | 1 + src/cmd-item/cmd-item.c | 1 + src/cmd-item/cmd-quaff.c | 2 +- src/cmd-item/cmd-smith.c | 2 +- src/cmd-item/cmd-usestaff.c | 1 + src/cmd/cmd-basic.c | 1 + src/cmd/cmd-visuals.c | 2 +- src/combat/monster-eating.c | 2 +- src/combat/shoot.c | 1 + src/dungeon/dungeon-file.c | 1 + src/dungeon/quest.c | 1 + src/effect/effect-monster-switcher.c | 2 +- src/effect/effect-monster.c | 1 + src/floor/floor-object.c | 1 + src/floor/floor.c | 2 +- src/inventory/inventory-object.c | 3 +- src/io/load.c | 1 + src/knowledge/knowledge-items.c | 1 + src/knowledge/knowledge-quests.c | 1 + src/market/bounty.c | 1 + src/market/building-craft-weapon.c | 40 ++++++++---------- src/market/building-craft-weapon.h | 2 + src/monster/monster1.c | 1 + src/monster/monster2.c | 1 + src/object/artifact.c | 1 + src/object/chest.c | 1 + src/object/object-appraiser.c | 2 +- src/object/object-generator.c | 66 ++++++++++++++++++++++++++++++ src/object/object-generator.h | 7 ++++ src/object/object2.c | 63 +--------------------------- src/object/object2.h | 3 -- src/player/player-effects.c | 1 + src/realm/realm-nature.c | 35 ++++++++-------- src/realm/realm-nature.h | 1 + src/spell/spells-object.c | 1 + src/spell/spells-status.c | 1 + src/spell/spells2.c | 1 + src/spell/spells3.c | 2 +- src/store/rumor.c | 21 +++++----- src/store/rumor.h | 4 +- src/store/store-util.c | 1 + src/store/store.c | 1 + src/view/object-describer.c | 2 +- src/wizard/wizard-special-process.c | 1 + src/wizard/wizard-spoiler.c | 1 + 50 files changed, 171 insertions(+), 128 deletions(-) create mode 100644 src/object/object-generator.c create mode 100644 src/object/object-generator.h diff --git a/Hengband/Hengband/Hengband.vcxproj b/Hengband/Hengband/Hengband.vcxproj index d5cc793b4..1aaea4161 100644 --- a/Hengband/Hengband/Hengband.vcxproj +++ b/Hengband/Hengband/Hengband.vcxproj @@ -213,6 +213,7 @@ + @@ -497,6 +498,7 @@ + diff --git a/Hengband/Hengband/Hengband.vcxproj.filters b/Hengband/Hengband/Hengband.vcxproj.filters index c7b44349f..515d37fd1 100644 --- a/Hengband/Hengband/Hengband.vcxproj.filters +++ b/Hengband/Hengband/Hengband.vcxproj.filters @@ -1088,6 +1088,9 @@ world + + object + @@ -2326,6 +2329,9 @@ world + + object + diff --git a/src/Makefile.am b/src/Makefile.am index e402a039b..43558e42c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -304,6 +304,7 @@ hengband_SOURCES = \ object/object-curse.c object/object-curse.h \ object/object-ego.c object/object-ego.h \ object/object-flavor.c object/object-flavor.h \ + object/object-generator.c object/object-generator.h \ object/object-hook.c object/object-hook.h \ object/object-kind.c object/object-kind.h \ object/object-kind-hook.c object/object-kind-hook.h \ diff --git a/src/birth/game-play-initializer.c b/src/birth/game-play-initializer.c index 64527a55c..dff655be0 100644 --- a/src/birth/game-play-initializer.c +++ b/src/birth/game-play-initializer.c @@ -4,6 +4,7 @@ #include "dungeon/quest.h" #include "market/arena.h" #include "object/artifact.h" +#include "object/object-generator.h" #include "object/object-kind.h" #include "object/object2.h" #include "pet/pet-util.h" diff --git a/src/birth/inventory-initializer.c b/src/birth/inventory-initializer.c index 435245538..13361764e 100644 --- a/src/birth/inventory-initializer.c +++ b/src/birth/inventory-initializer.c @@ -7,6 +7,7 @@ #include "object/item-apply-magic.h" #include "object/object-appraiser.h" #include "object/object-ego.h" +#include "object/object-generator.h" #include "object/object-kind.h" #include "object/object1.h" #include "object/object2.h" diff --git a/src/cmd-item/cmd-eat.c b/src/cmd-item/cmd-eat.c index 61364446d..c6b12ecf3 100644 --- a/src/cmd-item/cmd-eat.c +++ b/src/cmd-item/cmd-eat.c @@ -12,6 +12,7 @@ #include "object/item-use-flags.h" #include "object/object-appraiser.h" #include "object/object-flavor.h" +#include "object/object-generator.h" #include "object/object-hook.h" #include "object/object-kind.h" #include "object/object2.h" diff --git a/src/cmd-item/cmd-item.c b/src/cmd-item/cmd-item.c index a8704bda1..34e65c0e9 100644 --- a/src/cmd-item/cmd-item.c +++ b/src/cmd-item/cmd-item.c @@ -37,6 +37,7 @@ #include "object/object-appraiser.h" #include "object/object-ego.h" #include "object/object-flavor.h" +#include "object/object-generator.h" #include "object/object-hook.h" #include "object/object-mark-types.h" #include "object/object2.h" diff --git a/src/cmd-item/cmd-quaff.c b/src/cmd-item/cmd-quaff.c index a80babcd9..b40dadbdf 100644 --- a/src/cmd-item/cmd-quaff.c +++ b/src/cmd-item/cmd-quaff.c @@ -15,9 +15,9 @@ #include "object/item-use-flags.h" #include "object/object-appraiser.h" #include "object/object-broken.h" +#include "object/object-generator.h" #include "object/object-hook.h" #include "object/object-kind.h" -#include "object/object2.h" #include "object/sv-potion-types.h" #include "player/avatar.h" #include "player/mimic-info-table.h" diff --git a/src/cmd-item/cmd-smith.c b/src/cmd-item/cmd-smith.c index f3d940b92..fca34a1b9 100644 --- a/src/cmd-item/cmd-smith.c +++ b/src/cmd-item/cmd-smith.c @@ -12,8 +12,8 @@ #include "object/object-appraiser.h" #include "object/object-ego.h" #include "object/object-flavor.h" +#include "object/object-generator.h" #include "object/object-hook.h" -#include "object/object2.h" #include "object/special-object-flags.h" #include "object/tr-types.h" #include "object/trc-types.h" diff --git a/src/cmd-item/cmd-usestaff.c b/src/cmd-item/cmd-usestaff.c index 6decbee97..3bc9449df 100644 --- a/src/cmd-item/cmd-usestaff.c +++ b/src/cmd-item/cmd-usestaff.c @@ -6,6 +6,7 @@ #include "main/sound-definitions-table.h" #include "object/item-use-flags.h" #include "object/object-appraiser.h" +#include "object/object-generator.h" #include "object/object-hook.h" #include "object/object-kind.h" #include "object/object2.h" diff --git a/src/cmd/cmd-basic.c b/src/cmd/cmd-basic.c index 37132d9b7..8d1b0241e 100644 --- a/src/cmd/cmd-basic.c +++ b/src/cmd/cmd-basic.c @@ -41,6 +41,7 @@ #include "object/object-appraiser.h" #include "object/object-broken.h" #include "object/object-flavor.h" +#include "object/object-generator.h" #include "object/object-hook.h" #include "object/object-kind.h" #include "object/object2.h" diff --git a/src/cmd/cmd-visuals.c b/src/cmd/cmd-visuals.c index ac0124cc9..16f2ba6dd 100644 --- a/src/cmd/cmd-visuals.c +++ b/src/cmd/cmd-visuals.c @@ -7,8 +7,8 @@ #include "knowledge/knowledge-monsters.h" #include "knowledge/lighting-level-table.h" #include "object/object-flavor.h" +#include "object/object-generator.h" #include "object/object-kind.h" -#include "object/object2.h" #include "term/gameterm.h" #include "view/display-main-window.h" // 暫定。後で消す. diff --git a/src/combat/monster-eating.c b/src/combat/monster-eating.c index 901e03007..246a70668 100644 --- a/src/combat/monster-eating.c +++ b/src/combat/monster-eating.c @@ -8,8 +8,8 @@ #include "floor/floor.h" #include "inventory/inventory-object.h" #include "mind/racial-mirror-master.h" -#include "object/object2.h" #include "object/object-flavor.h" +#include "object/object-generator.h" #include "object/object-hook.h" #include "object/object-mark-types.h" #include "player/avatar.h" diff --git a/src/combat/shoot.c b/src/combat/shoot.c index a124787a2..cc6bd55b7 100644 --- a/src/combat/shoot.c +++ b/src/combat/shoot.c @@ -13,6 +13,7 @@ #include "object/artifact.h" #include "object/object-broken.h" #include "object/object-flavor.h" +#include "object/object-generator.h" #include "object/object-hook.h" #include "object/object-kind.h" #include "object/object-mark-types.h" diff --git a/src/dungeon/dungeon-file.c b/src/dungeon/dungeon-file.c index dec26b588..a33a5c774 100644 --- a/src/dungeon/dungeon-file.c +++ b/src/dungeon/dungeon-file.c @@ -53,6 +53,7 @@ #include "object/artifact.h" #include "object/item-apply-magic.h" #include "object/object-ego.h" +#include "object/object-generator.h" #include "object/object-kind.h" #include "object/object2.h" #include "object/sv-scroll-types.h" diff --git a/src/dungeon/quest.c b/src/dungeon/quest.c index 3d405ba58..857695066 100644 --- a/src/dungeon/quest.c +++ b/src/dungeon/quest.c @@ -14,6 +14,7 @@ #include "monster/monster.h" #include "object/artifact.h" #include "object/item-apply-magic.h" +#include "object/object-generator.h" #include "object/object2.h" #include "player/player-personalities-table.h" #include "player/player-status.h" diff --git a/src/effect/effect-monster-switcher.c b/src/effect/effect-monster-switcher.c index fca64d05c..95c3da85a 100644 --- a/src/effect/effect-monster-switcher.c +++ b/src/effect/effect-monster-switcher.c @@ -7,7 +7,7 @@ */ #include "system/angband.h" -#include "effect-monster-util.h" +#include "effect/effect-monster-util.h" #include "effect/effect-monster-switcher.h" #include "player/player-damage.h" #include "player/avatar.h" diff --git a/src/effect/effect-monster.c b/src/effect/effect-monster.c index a29b36af0..023f56ceb 100644 --- a/src/effect/effect-monster.c +++ b/src/effect/effect-monster.c @@ -19,6 +19,7 @@ #include "effect/effect-characteristics.h" #include "spell/spells3.h" #include "object/object2.h" +#include "object/object-generator.h" #include "object/special-object-flags.h" #include "object/sv-other-types.h" diff --git a/src/floor/floor-object.c b/src/floor/floor-object.c index c8d41c357..71e16ef64 100644 --- a/src/floor/floor-object.c +++ b/src/floor/floor-object.c @@ -9,6 +9,7 @@ #include "object/item-apply-magic.h" #include "object/object-appraiser.h" #include "object/object-flavor.h" +#include "object/object-generator.h" #include "object/object-hook.h" #include "object/object-kind-hook.h" #include "object/object-kind.h" diff --git a/src/floor/floor.c b/src/floor/floor.c index d8ca2b43c..c8776cd76 100644 --- a/src/floor/floor.c +++ b/src/floor/floor.c @@ -9,10 +9,10 @@ #include "grid/trap.h" #include "object/artifact.h" #include "object/object-appraiser.h" +#include "object/object-generator.h" #include "object/object-hook.h" #include "object/object-kind.h" #include "object/object1.h" -#include "object/object2.h" #include "object/special-object-flags.h" #include "player/player-effects.h" #include "room/rooms.h" diff --git a/src/inventory/inventory-object.c b/src/inventory/inventory-object.c index 979c3d957..b7e43091a 100644 --- a/src/inventory/inventory-object.c +++ b/src/inventory/inventory-object.c @@ -1,10 +1,11 @@ #include "inventory/inventory-object.h" #include "floor/floor-object.h" #include "object/object-flavor.h" +#include "object/object-generator.h" #include "object/object-hook.h" #include "object/object-mark-types.h" #include "object/object-value.h" -#include "object/object2.h" // 暫定、相互参照している. +#include "object/object2.h" #include "player/player-effects.h" // 暫定、相互参照している. #include "view/object-describer.h" diff --git a/src/io/load.c b/src/io/load.c index 3e2e68f22..7c0da6de8 100644 --- a/src/io/load.c +++ b/src/io/load.c @@ -65,6 +65,7 @@ #include "mutation/mutation.h" #include "object/artifact.h" #include "object/object-ego.h" +#include "object/object-generator.h" #include "object/object-hook.h" #include "object/object-kind.h" #include "object/object-mark-types.h" diff --git a/src/knowledge/knowledge-items.c b/src/knowledge/knowledge-items.c index ae92b3e51..57422b40f 100644 --- a/src/knowledge/knowledge-items.c +++ b/src/knowledge/knowledge-items.c @@ -13,6 +13,7 @@ #include "object/artifact.h" #include "object/object-appraiser.h" #include "object/object-flavor.h" +#include "object/object-generator.h" #include "object/object-hook.h" #include "object/object-kind.h" #include "object/object2.h" diff --git a/src/knowledge/knowledge-quests.c b/src/knowledge/knowledge-quests.c index 8421240ef..6dff7570e 100644 --- a/src/knowledge/knowledge-quests.c +++ b/src/knowledge/knowledge-quests.c @@ -12,6 +12,7 @@ #include "object/artifact.h" #include "object/object2.h" #include "object/object-flavor.h" +#include "object/object-generator.h" #include "object/special-object-flags.h" #include "dungeon/dungeon.h" #include "dungeon/dungeon-file.h" diff --git a/src/market/bounty.c b/src/market/bounty.c index d3e05bc7a..c95b9d023 100644 --- a/src/market/bounty.c +++ b/src/market/bounty.c @@ -9,6 +9,7 @@ #include "object/item-apply-magic.h" #include "object/object-appraiser.h" #include "object/object-flavor.h" +#include "object/object-generator.h" #include "object/object2.h" #include "object/sv-other-types.h" #include "player/avatar.h" diff --git a/src/market/building-craft-weapon.c b/src/market/building-craft-weapon.c index 2e634514e..3ca9d9939 100644 --- a/src/market/building-craft-weapon.c +++ b/src/market/building-craft-weapon.c @@ -1,20 +1,19 @@ -#include "system/angband.h" -#include "market/building-craft-weapon.h" -#include "term/gameterm.h" -#include "object/artifact.h" -#include "realm/realm-hex.h" -#include "object/object-flavor.h" -#include "world/world.h" -#include "object/object-hook.h" +#include "market/building-craft-weapon.h" +#include "combat/attack-accuracy.h" #include "combat/shoot.h" +#include "core/stuff-handler.h" #include "inventory/player-inventory.h" -#include "combat/attack-accuracy.h" #include "market/building-util.h" -#include "core/stuff-handler.h" -#include "object/object2.h" -#include "object/tr-types.h" +#include "object/artifact.h" #include "object/item-use-flags.h" +#include "object/object-flavor.h" +#include "object/object-generator.h" +#include "object/object-hook.h" #include "object/sv-weapon-types.h" +#include "object/tr-types.h" +#include "realm/realm-hex.h" +#include "term/gameterm.h" +#include "world/world.h" /*! * @brief 攻撃時スレイによるダメージ期待値修正計算 / critical happens at i / 10000 @@ -58,7 +57,8 @@ static HIT_POINT calc_slaydam(HIT_POINT dam, int mult, int div, bool force) * @param vorpal_div 切れ味倍率(割り算部分) * @return ダメージ期待値 */ -static u32b calc_expect_dice(player_type *owner_ptr, u32b dam, int mult, int div, bool force, WEIGHT weight, int plus, s16b meichuu, bool dokubari, int vorpal_mult, int vorpal_div) +static u32b calc_expect_dice( + player_type *owner_ptr, u32b dam, int mult, int div, bool force, WEIGHT weight, int plus, s16b meichuu, bool dokubari, int vorpal_mult, int vorpal_div) { dam = calc_slaydam(dam, mult, div, force); dam = calc_expect_crit(owner_ptr, weight, plus, dam, meichuu, dokubari); @@ -303,22 +303,16 @@ static void list_weapon(player_type *player_ptr, object_type *o_ptr, TERM_LEN ro sprintf(tmp_str, _("命中率: 0 50 100 150 200 (敵のAC)", "To Hit: 0 50 100 150 200 (AC)")); put_str(tmp_str, row + 2, col); - sprintf(tmp_str, " %2d %2d %2d %2d %2d (%%)", - (int)hit_chance(player_ptr, reli, 0), - (int)hit_chance(player_ptr, reli, 50), - (int)hit_chance(player_ptr, reli, 100), - (int)hit_chance(player_ptr, reli, 150), - (int)hit_chance(player_ptr, reli, 200)); + sprintf(tmp_str, " %2d %2d %2d %2d %2d (%%)", (int)hit_chance(player_ptr, reli, 0), (int)hit_chance(player_ptr, reli, 50), + (int)hit_chance(player_ptr, reli, 100), (int)hit_chance(player_ptr, reli, 150), (int)hit_chance(player_ptr, reli, 200)); put_str(tmp_str, row + 3, col); c_put_str(TERM_YELLOW, _("可能なダメージ:", "Possible Damage:"), row + 5, col); - sprintf(tmp_str, _("攻撃一回につき %d-%d", "One Strike: %d-%d damage"), - (int)(eff_dd + o_ptr->to_d + player_ptr->to_d[0]), + sprintf(tmp_str, _("攻撃一回につき %d-%d", "One Strike: %d-%d damage"), (int)(eff_dd + o_ptr->to_d + player_ptr->to_d[0]), (int)(eff_ds * eff_dd + o_ptr->to_d + player_ptr->to_d[0])); put_str(tmp_str, row + 6, col + 1); - sprintf(tmp_str, _("1ターンにつき %d-%d", "One Attack: %d-%d damage"), - (int)(player_ptr->num_blow[0] * (eff_dd + o_ptr->to_d + player_ptr->to_d[0])), + sprintf(tmp_str, _("1ターンにつき %d-%d", "One Attack: %d-%d damage"), (int)(player_ptr->num_blow[0] * (eff_dd + o_ptr->to_d + player_ptr->to_d[0])), (int)(player_ptr->num_blow[0] * (eff_ds * eff_dd + o_ptr->to_d + player_ptr->to_d[0]))); put_str(tmp_str, row + 7, col + 1); } diff --git a/src/market/building-craft-weapon.h b/src/market/building-craft-weapon.h index 3de14d54c..1925e69b2 100644 --- a/src/market/building-craft-weapon.h +++ b/src/market/building-craft-weapon.h @@ -1,3 +1,5 @@ #pragma once +#include "system/angband.h" + PRICE compare_weapons(player_type *customer_ptr, PRICE bcost); diff --git a/src/monster/monster1.c b/src/monster/monster1.c index d29d237da..0d347ca11 100644 --- a/src/monster/monster1.c +++ b/src/monster/monster1.c @@ -50,6 +50,7 @@ #include "object/sv-scroll-types.h" #include "object/sv-weapon-types.h" #include "object/object2.h" +#include "object/object-generator.h" /* * Pronoun arrays, by gender. diff --git a/src/monster/monster2.c b/src/monster/monster2.c index 7c8dde1c7..9c99dd3bc 100644 --- a/src/monster/monster2.c +++ b/src/monster/monster2.c @@ -23,6 +23,7 @@ #include "floor/floor-object.h" #include "object/object2.h" #include "object/object-flavor.h" +#include "object/object-generator.h" #include "monster/monster-race-hook.h" #include "monster/monster-status.h" #include "monster/monster.h" diff --git a/src/object/artifact.c b/src/object/artifact.c index 8050da441..34a9cbb31 100644 --- a/src/object/artifact.c +++ b/src/object/artifact.c @@ -22,6 +22,7 @@ #include "object/object-curse.h" #include "object/object-ego.h" #include "object/object-flavor.h" +#include "object/object-generator.h" #include "object/object-hook.h" #include "object/object-kind.h" #include "object/object1.h" diff --git a/src/object/chest.c b/src/object/chest.c index 4976c2c0b..d90fd5498 100644 --- a/src/object/chest.c +++ b/src/object/chest.c @@ -6,6 +6,7 @@ #include "main/sound-definitions-table.h" #include "object/item-apply-magic.h" #include "object/object-appraiser.h" +#include "object/object-generator.h" #include "object/object2.h" #include "object/sv-other-types.h" #include "player/player-class.h" diff --git a/src/object/object-appraiser.c b/src/object/object-appraiser.c index c33ce0bc0..9a7f3c41c 100644 --- a/src/object/object-appraiser.c +++ b/src/object/object-appraiser.c @@ -3,9 +3,9 @@ #include "object/artifact.h" #include "object/item-feeling.h" #include "object/object-flavor.h" +#include "object/object-generator.h" #include "object/object-hook.h" // 暫定、このファイルへ引っ越す. #include "object/object-kind.h" -#include "object/object2.h" // 暫定、相互参照している. #include "object/special-object-flags.h" /*! diff --git a/src/object/object-generator.c b/src/object/object-generator.c new file mode 100644 index 000000000..beb8482f5 --- /dev/null +++ b/src/object/object-generator.c @@ -0,0 +1,66 @@ +#include "object/object-generator.h" +#include "object/artifact.h" +#include "object/object-curse.h" +#include "object/object-kind.h" +#include "object/special-object-flags.h" +#include "object/trc-types.h" + +/*! + * @brief オブジェクトを初期化する + * Wipe an object clean. + * @param o_ptr 初期化したいオブジェクトの構造体参照ポインタ + * @return なし + */ +void object_wipe(object_type *o_ptr) { (void)WIPE(o_ptr, object_type); } + +/*! + * @brief オブジェクトを複製する + * Wipe an object clean. + * @param o_ptr 複製元のオブジェクトの構造体参照ポインタ + * @param j_ptr 複製先のオブジェクトの構造体参照ポインタ + * @return なし + */ +void object_copy(object_type *o_ptr, object_type *j_ptr) { (void)COPY(o_ptr, j_ptr, object_type); } + +/*! + * @brief オブジェクト構造体にベースアイテムを作成する + * Prepare an object based on an object kind. + * @param o_ptr 代入したいオブジェクトの構造体参照ポインタ + * @param k_idx 新たに作成したいベースアイテム情報のID + * @return なし + */ +void object_prep(object_type *o_ptr, KIND_OBJECT_IDX k_idx) +{ + object_kind *k_ptr = &k_info[k_idx]; + object_wipe(o_ptr); + o_ptr->k_idx = k_idx; + o_ptr->tval = k_ptr->tval; + o_ptr->sval = k_ptr->sval; + o_ptr->pval = k_ptr->pval; + o_ptr->number = 1; + o_ptr->weight = k_ptr->weight; + o_ptr->to_h = k_ptr->to_h; + o_ptr->to_d = k_ptr->to_d; + o_ptr->to_a = k_ptr->to_a; + o_ptr->ac = k_ptr->ac; + o_ptr->dd = k_ptr->dd; + o_ptr->ds = k_ptr->ds; + + if (k_ptr->act_idx > 0) + o_ptr->xtra2 = (XTRA8)k_ptr->act_idx; + if (k_info[o_ptr->k_idx].cost <= 0) + o_ptr->ident |= (IDENT_BROKEN); + + if (k_ptr->gen_flags & (TRG_CURSED)) + o_ptr->curse_flags |= (TRC_CURSED); + if (k_ptr->gen_flags & (TRG_HEAVY_CURSE)) + o_ptr->curse_flags |= (TRC_HEAVY_CURSE); + if (k_ptr->gen_flags & (TRG_PERMA_CURSE)) + o_ptr->curse_flags |= (TRC_PERMA_CURSE); + if (k_ptr->gen_flags & (TRG_RANDOM_CURSE0)) + o_ptr->curse_flags |= get_curse(0, o_ptr); + if (k_ptr->gen_flags & (TRG_RANDOM_CURSE1)) + o_ptr->curse_flags |= get_curse(1, o_ptr); + if (k_ptr->gen_flags & (TRG_RANDOM_CURSE2)) + o_ptr->curse_flags |= get_curse(2, o_ptr); +} diff --git a/src/object/object-generator.h b/src/object/object-generator.h new file mode 100644 index 000000000..8ddbe8b73 --- /dev/null +++ b/src/object/object-generator.h @@ -0,0 +1,7 @@ +#pragma once + +#include "system/angband.h" + +void object_wipe(object_type *o_ptr); +void object_copy(object_type *o_ptr, object_type *j_ptr); +void object_prep(object_type *o_ptr, KIND_OBJECT_IDX k_idx); diff --git a/src/object/object2.c b/src/object/object2.c index 403c2b2b4..730cffad3 100644 --- a/src/object/object2.c +++ b/src/object/object2.c @@ -16,7 +16,6 @@ #include "floor/floor.h" #include "grid/feature.h" #include "grid/grid.h" -#include "inventory/inventory-object.h" // 暫定、相互参照している. #include "io/write-diary.h" #include "main/sound-definitions-table.h" #include "monster/monster-race-hook.h" @@ -29,6 +28,7 @@ #include "object/object-curse.h" #include "object/object-ego.h" #include "object/object-flavor.h" +#include "object/object-generator.h" #include "object/object-hook.h" #include "object/object-kind.h" #include "object/object-mark-types.h" @@ -710,67 +710,6 @@ KIND_OBJECT_IDX lookup_kind(tval_type tval, OBJECT_SUBTYPE_VALUE sval) /*! - * @brief オブジェクトを初期化する - * Wipe an object clean. - * @param o_ptr 初期化したいオブジェクトの構造体参照ポインタ - * @return なし - */ -void object_wipe(object_type *o_ptr) -{ - (void)WIPE(o_ptr, object_type); -} - - -/*! - * @brief オブジェクトを複製する - * Wipe an object clean. - * @param o_ptr 複製元のオブジェクトの構造体参照ポインタ - * @param j_ptr 複製先のオブジェクトの構造体参照ポインタ - * @return なし - */ -void object_copy(object_type *o_ptr, object_type *j_ptr) -{ - (void)COPY(o_ptr, j_ptr, object_type); -} - - -/*! - * @brief オブジェクト構造体にベースアイテムを作成する - * Prepare an object based on an object kind. - * @param o_ptr 代入したいオブジェクトの構造体参照ポインタ - * @param k_idx 新たに作成したいベースアイテム情報のID - * @return なし - */ -void object_prep(object_type *o_ptr, KIND_OBJECT_IDX k_idx) -{ - object_kind *k_ptr = &k_info[k_idx]; - object_wipe(o_ptr); - o_ptr->k_idx = k_idx; - o_ptr->tval = k_ptr->tval; - o_ptr->sval = k_ptr->sval; - o_ptr->pval = k_ptr->pval; - o_ptr->number = 1; - o_ptr->weight = k_ptr->weight; - o_ptr->to_h = k_ptr->to_h; - o_ptr->to_d = k_ptr->to_d; - o_ptr->to_a = k_ptr->to_a; - o_ptr->ac = k_ptr->ac; - o_ptr->dd = k_ptr->dd; - o_ptr->ds = k_ptr->ds; - - if (k_ptr->act_idx > 0) o_ptr->xtra2 = (XTRA8)k_ptr->act_idx; - if (k_info[o_ptr->k_idx].cost <= 0) o_ptr->ident |= (IDENT_BROKEN); - - if (k_ptr->gen_flags & (TRG_CURSED)) o_ptr->curse_flags |= (TRC_CURSED); - if (k_ptr->gen_flags & (TRG_HEAVY_CURSE)) o_ptr->curse_flags |= (TRC_HEAVY_CURSE); - if (k_ptr->gen_flags & (TRG_PERMA_CURSE)) o_ptr->curse_flags |= (TRC_PERMA_CURSE); - if (k_ptr->gen_flags & (TRG_RANDOM_CURSE0)) o_ptr->curse_flags |= get_curse(0, o_ptr); - if (k_ptr->gen_flags & (TRG_RANDOM_CURSE1)) o_ptr->curse_flags |= get_curse(1, o_ptr); - if (k_ptr->gen_flags & (TRG_RANDOM_CURSE2)) o_ptr->curse_flags |= get_curse(2, o_ptr); -} - - -/*! * @brief アイテムのエゴをレア度の重みに合わせてランダムに選択する * Choose random ego type * @param slot 取得したいエゴの装備部位 diff --git a/src/object/object2.h b/src/object/object2.h index 8d62df1c3..6f118bd85 100644 --- a/src/object/object2.h +++ b/src/object/object2.h @@ -16,9 +16,6 @@ int object_similar_part(object_type *o_ptr, object_type *j_ptr); bool object_similar(object_type *o_ptr, object_type *j_ptr); void object_absorb(object_type *o_ptr, object_type *j_ptr); IDX lookup_kind(tval_type tval, OBJECT_SUBTYPE_VALUE sval); -void object_wipe(object_type *o_ptr); -void object_copy(object_type *o_ptr, object_type *j_ptr); -void object_prep(object_type *o_ptr, KIND_OBJECT_IDX k_idx); void apply_magic(player_type *owner_type, object_type *o_ptr, DEPTH lev, BIT_FLAGS mode); OBJECT_IDX drop_near(player_type *owner_type, object_type *o_ptr, PERCENTAGE chance, POSITION y, POSITION x); void floor_item_charges(floor_type *owner_ptr, INVENTORY_IDX item); diff --git a/src/player/player-effects.c b/src/player/player-effects.c index b112a6207..22a58efdd 100644 --- a/src/player/player-effects.c +++ b/src/player/player-effects.c @@ -37,6 +37,7 @@ #include "object/item-feeling.h" #include "object/object-appraiser.h" #include "object/object-ego.h" +#include "object/object-generator.h" #include "object/object-hook.h" #include "object/object-kind.h" #include "object/object-value.h" diff --git a/src/realm/realm-nature.c b/src/realm/realm-nature.c index 6711c6642..7f419320e 100644 --- a/src/realm/realm-nature.c +++ b/src/realm/realm-nature.c @@ -1,27 +1,26 @@ -#include "system/angband.h" -#include "util/util.h" - +#include "realm/realm-nature.h" #include "cmd-action/cmd-spell.h" -#include "spell/spells-summon.h" -#include "spell/spells-status.h" -#include "spell/spells-object.h" -#include "spell/spells-diceroll.h" +#include "effect/effect-characteristics.h" +#include "effect/spells-effect-util.h" +#include "io/targeting.h" +#include "object/object-generator.h" +#include "object/object2.h" +#include "object/sv-food-types.h" #include "player/avatar.h" -#include "spell/spells-floor.h" -#include "player/player-races-table.h" -#include "player/player-effects.h" #include "player/player-damage.h" -#include "io/targeting.h" -#include "effect/spells-effect-util.h" -#include "realm/realm-nature.h" -#include "spell/spells-type.h" +#include "player/player-effects.h" +#include "player/player-races-table.h" #include "spell/process-effect.h" -#include "effect/effect-characteristics.h" +#include "spell/spells-detection.h" +#include "spell/spells-diceroll.h" +#include "spell/spells-floor.h" +#include "spell/spells-object.h" +#include "spell/spells-status.h" +#include "spell/spells-summon.h" +#include "spell/spells-type.h" #include "spell/spells2.h" #include "spell/spells3.h" -#include "spell/spells-detection.h" -#include "object/object2.h" -#include "object/sv-food-types.h" +#include "util/util.h" /*! * @brief 自然領域魔法の各処理を行う diff --git a/src/realm/realm-nature.h b/src/realm/realm-nature.h index d91adccab..42368bfc1 100644 --- a/src/realm/realm-nature.h +++ b/src/realm/realm-nature.h @@ -1,5 +1,6 @@ #pragma once +#include "system/angband.h" #include "spell/spells-util.h" concptr do_nature_spell(player_type *caster_ptr, SPELL_IDX spell, spell_type mode); diff --git a/src/spell/spells-object.c b/src/spell/spells-object.c index 0386cb475..71702d317 100644 --- a/src/spell/spells-object.c +++ b/src/spell/spells-object.c @@ -21,6 +21,7 @@ #include "object/object-boost.h" #include "object/object-ego.h" #include "object/object-flavor.h" +#include "object/object-generator.h" #include "object/object-hook.h" #include "object/object-kind.h" #include "object/object2.h" diff --git a/src/spell/spells-status.c b/src/spell/spells-status.c index 9e3a1024b..02b5fc5c0 100644 --- a/src/spell/spells-status.c +++ b/src/spell/spells-status.c @@ -14,6 +14,7 @@ #include "mind/racial-force-trainer.h" #include "monster/monster.h" #include "object/object-flavor.h" +#include "object/object-generator.h" #include "object/object-kind.h" #include "object/object2.h" #include "player/avatar.h" diff --git a/src/spell/spells2.c b/src/spell/spells2.c index a9bdaaf73..f3ac04d04 100644 --- a/src/spell/spells2.c +++ b/src/spell/spells2.c @@ -39,6 +39,7 @@ #include "object/item-use-flags.h" #include "object/object-appraiser.h" #include "object/object-flavor.h" +#include "object/object-generator.h" #include "object/object-mark-types.h" #include "object/object2.h" #include "object/special-object-flags.h" diff --git a/src/spell/spells3.c b/src/spell/spells3.c index 051aa5cac..6ce0b5510 100644 --- a/src/spell/spells3.c +++ b/src/spell/spells3.c @@ -48,11 +48,11 @@ #include "object/object-boost.h" #include "object/object-ego.h" #include "object/object-flavor.h" +#include "object/object-generator.h" #include "object/object-hook.h" #include "object/object-kind.h" #include "object/object-mark-types.h" #include "object/object-value.h" -#include "object/object2.h" #include "object/special-object-flags.h" #include "object/tr-types.h" #include "object/trc-types.h" diff --git a/src/store/rumor.c b/src/store/rumor.c index 327e852d1..c8944a6d8 100644 --- a/src/store/rumor.c +++ b/src/store/rumor.c @@ -1,17 +1,16 @@ -#include "system/angband.h" -#include "store/rumor.h" -#include "util/util.h" - -#include "io/tokenizer.h" -#include "io/files-util.h" -#include "object/object2.h" -#include "object/object-flavor.h" -#include "object/artifact.h" -#include "object/special-object-flags.h" +#include "store/rumor.h" #include "dungeon/dungeon.h" -#include "monster/monster-race.h" #include "floor/floor-town.h" #include "floor/wild.h" +#include "io/files-util.h" +#include "io/tokenizer.h" +#include "monster/monster-race.h" +#include "object/artifact.h" +#include "object/object-flavor.h" +#include "object/object-generator.h" +#include "object/object2.h" +#include "object/special-object-flags.h" +#include "util/util.h" #include "world/world.h" /* diff --git a/src/store/rumor.h b/src/store/rumor.h index afbcfe37b..9f70a7722 100644 --- a/src/store/rumor.h +++ b/src/store/rumor.h @@ -1,3 +1,5 @@ #pragma once -extern void display_rumor(player_type *player_ptr, bool ex); +#include "system/angband.h" + +void display_rumor(player_type *player_ptr, bool ex); diff --git a/src/store/store-util.c b/src/store/store-util.c index d3ed78d3f..cc6482c90 100644 --- a/src/store/store-util.c +++ b/src/store/store-util.c @@ -8,6 +8,7 @@ #include "object/item-apply-magic.h" #include "object/item-feeling.h" #include "object/object-appraiser.h" +#include "object/object-generator.h" #include "object/object-hook.h" #include "object/object-kind.h" #include "object/object-value.h" diff --git a/src/store/store.c b/src/store/store.c index 89e74014b..cb4c63b33 100644 --- a/src/store/store.c +++ b/src/store/store.c @@ -46,6 +46,7 @@ #include "object/item-use-flags.h" #include "object/object-appraiser.h" #include "object/object-flavor.h" +#include "object/object-generator.h" #include "object/object-hook.h" #include "object/object-kind.h" #include "object/object-value.h" diff --git a/src/view/object-describer.c b/src/view/object-describer.c index 19178a9e4..49e9c90f0 100644 --- a/src/view/object-describer.c +++ b/src/view/object-describer.c @@ -2,7 +2,7 @@ #include "cmd-action/cmd-spell.h" #include "object/object-appraiser.h" #include "object/object-flavor.h" -#include "object/object2.h" +#include "object/object-generator.h" #include "object/special-object-flags.h" #include "spell/spells3.h" #include "term/gameterm.h" diff --git a/src/wizard/wizard-special-process.c b/src/wizard/wizard-special-process.c index 5919f36bd..22e7c1117 100644 --- a/src/wizard/wizard-special-process.c +++ b/src/wizard/wizard-special-process.c @@ -38,6 +38,7 @@ #include "object/item-use-flags.h" #include "object/object-appraiser.h" #include "object/object-flavor.h" +#include "object/object-generator.h" #include "object/object-hook.h" #include "object/object-kind.h" #include "object/object-value.h" diff --git a/src/wizard/wizard-spoiler.c b/src/wizard/wizard-spoiler.c index d24cdeeba..162cc540f 100644 --- a/src/wizard/wizard-spoiler.c +++ b/src/wizard/wizard-spoiler.c @@ -19,6 +19,7 @@ #include "object/object-appraiser.h" #include "object/object-ego.h" #include "object/object-flavor.h" +#include "object/object-generator.h" #include "object/object-kind.h" #include "object/object-value.h" #include "object/object2.h" -- 2.11.0