From cb364a56889c11929fa39d987f8730d3bfd838d0 Mon Sep 17 00:00:00 2001
From: Hourier <66951241+Hourier@users.noreply.github.com>
Date: Sat, 16 Nov 2024 12:20:17 +0900
Subject: [PATCH 01/11] =?UTF-8?q?[Refactor]=20#4622=20system/baseitem-info?=
=?UTF-8?q?.cpp/h=20=E3=82=92system/baseitem/baseitem-definition.cpp/h=20?=
=?UTF-8?q?=E3=81=AB=E7=A7=BB=E3=81=97=E3=81=9F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
VisualStudio/Hengband/Hengband.vcxproj | 4 ++--
VisualStudio/Hengband/Hengband.vcxproj.filters | 15 +++++++++------
src/Makefile.am | 3 ++-
src/action/activation-execution.cpp | 2 +-
src/artifact/random-art-generator.cpp | 2 +-
src/autopick/autopick-entry.cpp | 2 +-
src/autopick/autopick-matcher.cpp | 2 +-
src/birth/game-play-initializer.cpp | 2 +-
src/cmd-action/cmd-spell.cpp | 2 +-
src/cmd-item/cmd-destroy.cpp | 2 +-
src/cmd-item/cmd-magiceat.cpp | 2 +-
src/cmd-item/cmd-zapwand.cpp | 2 +-
src/combat/shoot.cpp | 2 +-
src/core/object-compressor.cpp | 2 +-
src/core/visuals-reseter.cpp | 2 +-
src/flavor/flavor-describer.cpp | 2 +-
src/flavor/object-flavor.cpp | 2 +-
src/flavor/tval-description-switcher.cpp | 2 +-
src/floor/floor-events.cpp | 2 +-
src/info-reader/baseitem-reader.cpp | 2 +-
src/info-reader/general-parser.cpp | 2 +-
src/inventory/recharge-processor.cpp | 2 +-
src/io-dump/special-class-dump.cpp | 2 +-
src/io/interpret-pref-file.cpp | 2 +-
src/item-info/flavor-initializer.cpp | 2 +-
src/knowledge/knowledge-experiences.cpp | 2 +-
src/load/item/item-loader-base.cpp | 2 +-
src/load/old/item-loader-savefile50.cpp | 2 +-
src/load/old/load-v1-5-0.cpp | 2 +-
src/main/game-data-initializer.cpp | 2 +-
src/main/info-initializer.cpp | 2 +-
src/market/arena-entry.cpp | 2 +-
src/market/bounty-prize-table.cpp | 2 +-
src/market/building-craft-fix.cpp | 2 +-
src/market/building-initializer.cpp | 2 +-
src/market/building-recharger.cpp | 2 +-
src/mind/mind-mage.cpp | 2 +-
src/monster-attack/monster-eating.cpp | 2 +-
src/object-activation/activation-util.cpp | 2 +-
src/object-enchant/item-magic-applier.cpp | 2 +-
src/object-enchant/object-boost.cpp | 2 +-
src/object-enchant/others/apply-magic-amulet.cpp | 2 +-
src/object-enchant/others/apply-magic-others.cpp | 2 +-
src/object-enchant/others/apply-magic-ring.cpp | 2 +-
.../protector/apply-magic-soft-armor.cpp | 2 +-
src/object-hook/hook-expendable.cpp | 2 +-
src/object-hook/hook-magic.cpp | 2 +-
src/object-use/quaff/quaff-execution.cpp | 2 +-
src/object-use/read/read-execution.cpp | 2 +-
src/object-use/throw-execution.cpp | 2 +-
src/object-use/use-execution.cpp | 2 +-
src/object-use/zaprod-execution.cpp | 2 +-
src/object-use/zapwand-execution.cpp | 2 +-
src/object/object-broken.cpp | 2 +-
src/object/object-kind-hook.cpp | 2 +-
src/object/object-stack.cpp | 2 +-
src/object/object-value-calc.cpp | 2 +-
src/object/object-value.cpp | 2 +-
src/perception/identification.cpp | 2 +-
src/player-info/magic-eater-data-type.cpp | 2 +-
src/racial/racial-android.cpp | 2 +-
src/save/item-writer.cpp | 2 +-
src/save/save.cpp | 2 +-
src/spell-kind/magic-item-recharger.cpp | 2 +-
src/spell/spells-object.cpp | 2 +-
src/spell/spells-status.cpp | 2 +-
src/store/articles-on-sale.cpp | 2 +-
src/store/rumor.cpp | 2 +-
src/store/store-util.cpp | 2 +-
src/system/alloc-entries.cpp | 2 +-
src/system/artifact-type-definition.h | 2 +-
.../baseitem-definition.cpp} | 2 +-
.../baseitem-definition.h} | 0
src/system/item-entity.cpp | 3 ++-
src/system/item-entity.h | 2 +-
src/view/display-inventory.cpp | 2 +-
src/view/display-map.cpp | 2 +-
src/view/display-player.cpp | 2 +-
src/view/display-store.cpp | 2 +-
src/window/main-window-equipments.cpp | 2 +-
src/wizard/items-spoiler.cpp | 2 +-
src/wizard/wizard-special-process.cpp | 2 +-
src/world/world-object.cpp | 2 +-
83 files changed, 93 insertions(+), 88 deletions(-)
rename src/system/{baseitem-info.cpp => baseitem/baseitem-definition.cpp} (99%)
rename src/system/{baseitem-info.h => baseitem/baseitem-definition.h} (100%)
diff --git a/VisualStudio/Hengband/Hengband.vcxproj b/VisualStudio/Hengband/Hengband.vcxproj
index cee37b3259..d8d1ff758f 100644
--- a/VisualStudio/Hengband/Hengband.vcxproj
+++ b/VisualStudio/Hengband/Hengband.vcxproj
@@ -929,7 +929,7 @@
-
+
@@ -1993,7 +1993,7 @@
-
+
diff --git a/VisualStudio/Hengband/Hengband.vcxproj.filters b/VisualStudio/Hengband/Hengband.vcxproj.filters
index 7eefb0dd70..50edde9fea 100644
--- a/VisualStudio/Hengband/Hengband.vcxproj.filters
+++ b/VisualStudio/Hengband/Hengband.vcxproj.filters
@@ -2436,9 +2436,6 @@
system
-
- system
-
system
@@ -2529,6 +2526,9 @@
system
+
+ system\baseitem
+
@@ -5361,9 +5361,6 @@
timed-effect
-
- system
-
system
@@ -5478,6 +5475,9 @@
system\enums
+
+ system\baseitem
+
@@ -5751,6 +5751,9 @@
{123780c8-0bf5-47ac-aabd-c9f3dbe74855}
+
+ {b1f45c00-0add-4e05-8c05-bac1f29550c6}
+
diff --git a/src/Makefile.am b/src/Makefile.am
index 5a89c98b5c..899201220c 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -922,7 +922,6 @@ hengband_SOURCES = \
system/angband-system.h system/angband-system.cpp \
system/angband-version.cpp system/angband-version.h \
system/artifact-type-definition.cpp system/artifact-type-definition.h \
- system/baseitem-info.cpp system/baseitem-info.h \
system/building-type-definition.cpp system/building-type-definition.h \
system/dungeon-data-definition.cpp system/dungeon-data-definition.h \
system/dungeon-info.cpp system/dungeon-info.h \
@@ -941,6 +940,8 @@ hengband_SOURCES = \
system/terrain-type-definition.cpp system/terrain-type-definition.h \
system/gamevalue.h \
\
+ system/baseitem/baseitem-key.cpp system/baseitem/baseitem-key.h \
+ \
system/enums/game-option-page.h \
system/enums/grid-flow.h \
system/enums/monrace/monrace-id.h \
diff --git a/src/action/activation-execution.cpp b/src/action/activation-execution.cpp
index 7196aeeea1..064629689f 100644
--- a/src/action/activation-execution.cpp
+++ b/src/action/activation-execution.cpp
@@ -35,7 +35,7 @@
#include "sv-definition/sv-lite-types.h"
#include "sv-definition/sv-ring-types.h"
#include "system/artifact-type-definition.h"
-#include "system/baseitem-info.h"
+#include "system/baseitem/baseitem-definition.h"
#include "system/floor-type-definition.h"
#include "system/item-entity.h"
#include "system/monster-entity.h"
diff --git a/src/artifact/random-art-generator.cpp b/src/artifact/random-art-generator.cpp
index 52aec5429c..6fb775692d 100644
--- a/src/artifact/random-art-generator.cpp
+++ b/src/artifact/random-art-generator.cpp
@@ -29,7 +29,7 @@
#include "perception/identification.h"
#include "perception/object-perception.h"
#include "sv-definition/sv-weapon-types.h"
-#include "system/baseitem-info.h"
+#include "system/baseitem/baseitem-definition.h"
#include "system/item-entity.h"
#include "system/player-type-definition.h"
#include "system/redrawing-flags-updater.h"
diff --git a/src/autopick/autopick-entry.cpp b/src/autopick/autopick-entry.cpp
index 1d6de3dc6e..eabe36c9e0 100644
--- a/src/autopick/autopick-entry.cpp
+++ b/src/autopick/autopick-entry.cpp
@@ -17,7 +17,7 @@
#include "perception/object-perception.h"
#include "player-base/player-class.h"
#include "player/player-realm.h"
-#include "system/baseitem-info.h"
+#include "system/baseitem/baseitem-definition.h"
#include "system/item-entity.h"
#include "system/monster-race-info.h"
#include "system/player-type-definition.h"
diff --git a/src/autopick/autopick-matcher.cpp b/src/autopick/autopick-matcher.cpp
index 49cd80e183..802aeb6e49 100644
--- a/src/autopick/autopick-matcher.cpp
+++ b/src/autopick/autopick-matcher.cpp
@@ -20,7 +20,7 @@
#include "perception/object-perception.h"
#include "player-base/player-class.h"
#include "player/player-realm.h"
-#include "system/baseitem-info.h"
+#include "system/baseitem/baseitem-definition.h"
#include "system/floor-type-definition.h"
#include "system/item-entity.h"
#include "system/monster-race-info.h"
diff --git a/src/birth/game-play-initializer.cpp b/src/birth/game-play-initializer.cpp
index 4d6354d61b..8acec52135 100644
--- a/src/birth/game-play-initializer.cpp
+++ b/src/birth/game-play-initializer.cpp
@@ -15,7 +15,7 @@
#include "player/digestion-processor.h"
#include "player/player-spell-status.h"
#include "system/artifact-type-definition.h"
-#include "system/baseitem-info.h"
+#include "system/baseitem/baseitem-definition.h"
#include "system/building-type-definition.h"
#include "system/dungeon-info.h"
#include "system/floor-type-definition.h"
diff --git a/src/cmd-action/cmd-spell.cpp b/src/cmd-action/cmd-spell.cpp
index 48a8e4536c..ceed9e4368 100644
--- a/src/cmd-action/cmd-spell.cpp
+++ b/src/cmd-action/cmd-spell.cpp
@@ -56,7 +56,7 @@
#include "status/bad-status-setter.h"
#include "status/base-status.h"
#include "status/experience.h"
-#include "system/baseitem-info.h"
+#include "system/baseitem/baseitem-definition.h"
#include "system/floor-type-definition.h"
#include "system/item-entity.h"
#include "system/player-type-definition.h"
diff --git a/src/cmd-item/cmd-destroy.cpp b/src/cmd-item/cmd-destroy.cpp
index 0e5eaeecec..c547849239 100644
--- a/src/cmd-item/cmd-destroy.cpp
+++ b/src/cmd-item/cmd-destroy.cpp
@@ -30,7 +30,7 @@
#include "racial/racial-android.h"
#include "status/action-setter.h"
#include "status/experience.h"
-#include "system/baseitem-info.h"
+#include "system/baseitem/baseitem-definition.h"
#include "system/item-entity.h"
#include "system/player-type-definition.h"
#include "system/redrawing-flags-updater.h"
diff --git a/src/cmd-item/cmd-magiceat.cpp b/src/cmd-item/cmd-magiceat.cpp
index 376e7b296f..2d46ddec72 100644
--- a/src/cmd-item/cmd-magiceat.cpp
+++ b/src/cmd-item/cmd-magiceat.cpp
@@ -71,7 +71,7 @@
#include "player-status/player-energy.h"
#include "player/player-status-table.h"
#include "spell/spell-info.h"
-#include "system/baseitem-info.h"
+#include "system/baseitem/baseitem-definition.h"
#include "system/player-type-definition.h"
#include "target/target-getter.h"
#include "term/screen-processor.h"
diff --git a/src/cmd-item/cmd-zapwand.cpp b/src/cmd-item/cmd-zapwand.cpp
index fa24bf7574..666d13ed93 100644
--- a/src/cmd-item/cmd-zapwand.cpp
+++ b/src/cmd-item/cmd-zapwand.cpp
@@ -32,7 +32,7 @@
#include "status/action-setter.h"
#include "status/experience.h"
#include "sv-definition/sv-wand-types.h"
-#include "system/baseitem-info.h"
+#include "system/baseitem/baseitem-definition.h"
#include "system/item-entity.h"
#include "system/player-type-definition.h"
#include "target/target-getter.h"
diff --git a/src/combat/shoot.cpp b/src/combat/shoot.cpp
index a57515ce46..691cafec76 100644
--- a/src/combat/shoot.cpp
+++ b/src/combat/shoot.cpp
@@ -47,7 +47,7 @@
#include "player/player-status-table.h"
#include "sv-definition/sv-bow-types.h"
#include "system/artifact-type-definition.h"
-#include "system/baseitem-info.h"
+#include "system/baseitem/baseitem-definition.h"
#include "system/enums/monrace/monrace-id.h"
#include "system/floor-type-definition.h"
#include "system/grid-type-definition.h"
diff --git a/src/core/object-compressor.cpp b/src/core/object-compressor.cpp
index 3879037416..c62a415681 100644
--- a/src/core/object-compressor.cpp
+++ b/src/core/object-compressor.cpp
@@ -3,7 +3,7 @@
#include "floor/floor-object.h"
#include "floor/geometry.h"
#include "grid/grid.h"
-#include "system/baseitem-info.h"
+#include "system/baseitem/baseitem-definition.h"
#include "system/floor-type-definition.h"
#include "system/item-entity.h"
#include "system/monster-entity.h"
diff --git a/src/core/visuals-reseter.cpp b/src/core/visuals-reseter.cpp
index 2a42f7f0b6..2bb5ff0ac1 100644
--- a/src/core/visuals-reseter.cpp
+++ b/src/core/visuals-reseter.cpp
@@ -1,7 +1,7 @@
#include "core/visuals-reseter.h"
#include "game-option/special-options.h"
#include "io/read-pref-file.h"
-#include "system/baseitem-info.h"
+#include "system/baseitem/baseitem-definition.h"
#include "system/monster-race-info.h"
#include "system/player-type-definition.h"
#include "system/terrain-type-definition.h"
diff --git a/src/flavor/flavor-describer.cpp b/src/flavor/flavor-describer.cpp
index c08978c4be..9c14e98d29 100644
--- a/src/flavor/flavor-describer.cpp
+++ b/src/flavor/flavor-describer.cpp
@@ -29,7 +29,7 @@
#include "sv-definition/sv-lite-types.h"
#include "sv-definition/sv-ring-types.h"
#include "sv-definition/sv-weapon-types.h"
-#include "system/baseitem-info.h"
+#include "system/baseitem/baseitem-definition.h"
#include "system/floor-type-definition.h"
#include "system/item-entity.h"
#include "system/player-type-definition.h"
diff --git a/src/flavor/object-flavor.cpp b/src/flavor/object-flavor.cpp
index 40f1a00ada..7c5b1ae06f 100644
--- a/src/flavor/object-flavor.cpp
+++ b/src/flavor/object-flavor.cpp
@@ -32,7 +32,7 @@
#include "player/player-status.h"
#include "sv-definition/sv-food-types.h"
#include "sv-definition/sv-lite-types.h"
-#include "system/baseitem-info.h"
+#include "system/baseitem/baseitem-definition.h"
#include "util/bit-flags-calculator.h"
#include
#include
diff --git a/src/flavor/tval-description-switcher.cpp b/src/flavor/tval-description-switcher.cpp
index 2a063b8966..7d2a5bca9b 100644
--- a/src/flavor/tval-description-switcher.cpp
+++ b/src/flavor/tval-description-switcher.cpp
@@ -10,7 +10,7 @@
#include "locale/english.h"
#include "object-enchant/trg-types.h"
#include "object/tval-types.h"
-#include "system/baseitem-info.h"
+#include "system/baseitem/baseitem-definition.h"
#include "system/item-entity.h"
#include "system/monster-race-info.h"
#include "util/bit-flags-calculator.h"
diff --git a/src/floor/floor-events.cpp b/src/floor/floor-events.cpp
index 21ea5d7111..e74e47b2ea 100644
--- a/src/floor/floor-events.cpp
+++ b/src/floor/floor-events.cpp
@@ -28,7 +28,7 @@
#include "sv-definition/sv-protector-types.h"
#include "sv-definition/sv-ring-types.h"
#include "system/angband-system.h"
-#include "system/baseitem-info.h"
+#include "system/baseitem/baseitem-definition.h"
#include "system/dungeon-info.h"
#include "system/floor-type-definition.h"
#include "system/grid-type-definition.h"
diff --git a/src/info-reader/baseitem-reader.cpp b/src/info-reader/baseitem-reader.cpp
index bcc158cdda..f87dec1b5c 100644
--- a/src/info-reader/baseitem-reader.cpp
+++ b/src/info-reader/baseitem-reader.cpp
@@ -14,7 +14,7 @@
#include "main/angband-headers.h"
#include "object-enchant/tr-types.h"
#include "object/tval-types.h"
-#include "system/baseitem-info.h"
+#include "system/baseitem/baseitem-definition.h"
#include "term/gameterm.h"
#include "util/bit-flags-calculator.h"
#include "util/enum-converter.h"
diff --git a/src/info-reader/general-parser.cpp b/src/info-reader/general-parser.cpp
index 2a0342e077..60cba58d6f 100644
--- a/src/info-reader/general-parser.cpp
+++ b/src/info-reader/general-parser.cpp
@@ -12,7 +12,7 @@
#include "player-info/race-types.h"
#include "realm/realm-types.h"
#include "system/artifact-type-definition.h"
-#include "system/baseitem-info.h"
+#include "system/baseitem/baseitem-definition.h"
#include "system/building-type-definition.h"
#include "system/floor-type-definition.h"
#include "system/system-variables.h"
diff --git a/src/inventory/recharge-processor.cpp b/src/inventory/recharge-processor.cpp
index dd7ac060b4..4241b9bf18 100644
--- a/src/inventory/recharge-processor.cpp
+++ b/src/inventory/recharge-processor.cpp
@@ -6,7 +6,7 @@
#include "hpmp/hp-mp-regenerator.h"
#include "inventory/inventory-slot-types.h"
#include "object/tval-types.h"
-#include "system/baseitem-info.h"
+#include "system/baseitem/baseitem-definition.h"
#include "system/floor-type-definition.h"
#include "system/item-entity.h"
#include "system/player-type-definition.h"
diff --git a/src/io-dump/special-class-dump.cpp b/src/io-dump/special-class-dump.cpp
index 8e19f954eb..39acee98bc 100644
--- a/src/io-dump/special-class-dump.cpp
+++ b/src/io-dump/special-class-dump.cpp
@@ -14,7 +14,7 @@
#include "player-info/bluemage-data-type.h"
#include "player-info/magic-eater-data-type.h"
#include "smith/object-smith.h"
-#include "system/baseitem-info.h"
+#include "system/baseitem/baseitem-definition.h"
#include "system/player-type-definition.h"
#include "util/enum-converter.h"
#include "util/flag-group.h"
diff --git a/src/io/interpret-pref-file.cpp b/src/io/interpret-pref-file.cpp
index ce81c0c5eb..3ba4b8a92e 100644
--- a/src/io/interpret-pref-file.cpp
+++ b/src/io/interpret-pref-file.cpp
@@ -13,7 +13,7 @@
#include "io/gf-descriptions.h"
#include "io/input-key-requester.h"
#include "io/tokenizer.h"
-#include "system/baseitem-info.h"
+#include "system/baseitem/baseitem-definition.h"
#include "system/enums/game-option-page.h"
#include "system/monster-race-info.h"
#include "system/player-type-definition.h"
diff --git a/src/item-info/flavor-initializer.cpp b/src/item-info/flavor-initializer.cpp
index f63b81088c..a7161bdb18 100644
--- a/src/item-info/flavor-initializer.cpp
+++ b/src/item-info/flavor-initializer.cpp
@@ -7,7 +7,7 @@
#include "item-info/flavor-initializer.h"
#include "object/tval-types.h"
#include "system/angband-system.h"
-#include "system/baseitem-info.h"
+#include "system/baseitem/baseitem-definition.h"
/*!
* @brief ゲーム開始時に行われるベースアイテムの初期化ルーチン
diff --git a/src/knowledge/knowledge-experiences.cpp b/src/knowledge/knowledge-experiences.cpp
index 521a3651a4..2c29223703 100644
--- a/src/knowledge/knowledge-experiences.cpp
+++ b/src/knowledge/knowledge-experiences.cpp
@@ -16,7 +16,7 @@
#include "spell/spells-execution.h"
#include "spell/technic-info-table.h"
#include "sv-definition/sv-bow-types.h"
-#include "system/baseitem-info.h"
+#include "system/baseitem/baseitem-definition.h"
#include "system/player-type-definition.h"
#include "util/angband-files.h"
diff --git a/src/load/item/item-loader-base.cpp b/src/load/item/item-loader-base.cpp
index 0452b2a0c0..db1d772d93 100644
--- a/src/load/item/item-loader-base.cpp
+++ b/src/load/item/item-loader-base.cpp
@@ -3,7 +3,7 @@
#include "load/angband-version-comparer.h"
#include "load/load-util.h"
#include "system/artifact-type-definition.h"
-#include "system/baseitem-info.h"
+#include "system/baseitem/baseitem-definition.h"
#include "util/bit-flags-calculator.h"
#include "util/enum-converter.h"
diff --git a/src/load/old/item-loader-savefile50.cpp b/src/load/old/item-loader-savefile50.cpp
index 11266b7e6d..da606c5c06 100644
--- a/src/load/old/item-loader-savefile50.cpp
+++ b/src/load/old/item-loader-savefile50.cpp
@@ -11,7 +11,7 @@
#include "object/tval-types.h"
#include "sv-definition/sv-lite-types.h"
#include "system/angband.h"
-#include "system/baseitem-info.h"
+#include "system/baseitem/baseitem-definition.h"
#include "system/item-entity.h"
#include "system/player-type-definition.h"
#include "util/bit-flags-calculator.h"
diff --git a/src/load/old/load-v1-5-0.cpp b/src/load/old/load-v1-5-0.cpp
index d6b1ff8f50..0268d83eec 100644
--- a/src/load/old/load-v1-5-0.cpp
+++ b/src/load/old/load-v1-5-0.cpp
@@ -35,7 +35,7 @@
#include "sv-definition/sv-lite-types.h"
#include "system/angband-exceptions.h"
#include "system/artifact-type-definition.h"
-#include "system/baseitem-info.h"
+#include "system/baseitem/baseitem-definition.h"
#include "system/dungeon-info.h"
#include "system/enums/monrace/monrace-id.h"
#include "system/floor-type-definition.h"
diff --git a/src/main/game-data-initializer.cpp b/src/main/game-data-initializer.cpp
index 1677fea3bb..0aaf5119cb 100644
--- a/src/main/game-data-initializer.cpp
+++ b/src/main/game-data-initializer.cpp
@@ -12,7 +12,7 @@
#include "game-option/option-flags.h"
#include "game-option/option-types-table.h"
#include "system/alloc-entries.h"
-#include "system/baseitem-info.h"
+#include "system/baseitem/baseitem-definition.h"
#include "system/dungeon-info.h"
#include "system/floor-type-definition.h"
#include "system/grid-type-definition.h"
diff --git a/src/main/info-initializer.cpp b/src/main/info-initializer.cpp
index c7d6f8fe22..135b13aab2 100644
--- a/src/main/info-initializer.cpp
+++ b/src/main/info-initializer.cpp
@@ -28,7 +28,7 @@
#include "room/rooms-vault.h"
#include "system/angband-version.h"
#include "system/artifact-type-definition.h"
-#include "system/baseitem-info.h"
+#include "system/baseitem/baseitem-definition.h"
#include "system/dungeon-info.h"
#include "system/monster-race-info.h"
#include "system/player-type-definition.h"
diff --git a/src/market/arena-entry.cpp b/src/market/arena-entry.cpp
index c6e0bfd15f..2e86df23d4 100644
--- a/src/market/arena-entry.cpp
+++ b/src/market/arena-entry.cpp
@@ -8,7 +8,7 @@
#include "sv-definition/sv-scroll-types.h"
#include "sv-definition/sv-staff-types.h"
#include "sv-definition/sv-wand-types.h"
-#include "system/baseitem-info.h"
+#include "system/baseitem/baseitem-definition.h"
#include "system/enums/monrace/monrace-id.h"
#include "system/monster-race-info.h"
#ifndef JP
diff --git a/src/market/bounty-prize-table.cpp b/src/market/bounty-prize-table.cpp
index 5e16b21d1d..bc269c93e7 100644
--- a/src/market/bounty-prize-table.cpp
+++ b/src/market/bounty-prize-table.cpp
@@ -2,7 +2,7 @@
#include "object/tval-types.h"
#include "sv-definition/sv-potion-types.h"
#include "sv-definition/sv-scroll-types.h"
-#include "system/baseitem-info.h"
+#include "system/baseitem/baseitem-definition.h"
const std::vector prize_list = {
{ ItemKindType::POTION, SV_POTION_CURING },
diff --git a/src/market/building-craft-fix.cpp b/src/market/building-craft-fix.cpp
index 8e8ef62190..1e2b88e495 100644
--- a/src/market/building-craft-fix.cpp
+++ b/src/market/building-craft-fix.cpp
@@ -19,7 +19,7 @@
#include "spell-realm/spells-hex.h"
#include "sv-definition/sv-other-types.h"
#include "sv-definition/sv-weapon-types.h"
-#include "system/baseitem-info.h"
+#include "system/baseitem/baseitem-definition.h"
#include "system/item-entity.h"
#include "system/player-type-definition.h"
#include "system/redrawing-flags-updater.h"
diff --git a/src/market/building-initializer.cpp b/src/market/building-initializer.cpp
index 37d0cd4ce5..36b2e2228d 100644
--- a/src/market/building-initializer.cpp
+++ b/src/market/building-initializer.cpp
@@ -8,7 +8,7 @@
#include "store/store-util.h"
#include "store/store.h"
#include "system/angband.h"
-#include "system/baseitem-info.h"
+#include "system/baseitem/baseitem-definition.h"
#include "system/building-type-definition.h"
#include "system/item-entity.h"
#include "util/angband-files.h"
diff --git a/src/market/building-recharger.cpp b/src/market/building-recharger.cpp
index 23e90d35a9..f4b3aeae5f 100644
--- a/src/market/building-recharger.cpp
+++ b/src/market/building-recharger.cpp
@@ -13,7 +13,7 @@
#include "object/item-use-flags.h"
#include "perception/object-perception.h"
#include "spell-kind/spells-perception.h"
-#include "system/baseitem-info.h"
+#include "system/baseitem/baseitem-definition.h"
#include "system/item-entity.h"
#include "system/player-type-definition.h"
#include "system/redrawing-flags-updater.h"
diff --git a/src/mind/mind-mage.cpp b/src/mind/mind-mage.cpp
index 01bc448ea9..ee1c40eb63 100644
--- a/src/mind/mind-mage.cpp
+++ b/src/mind/mind-mage.cpp
@@ -15,7 +15,7 @@
#include "object/item-tester-hooker.h"
#include "object/item-use-flags.h"
#include "player-base/player-class.h"
-#include "system/baseitem-info.h"
+#include "system/baseitem/baseitem-definition.h"
#include "system/item-entity.h"
#include "system/player-type-definition.h"
#include "view/display-messages.h"
diff --git a/src/monster-attack/monster-eating.cpp b/src/monster-attack/monster-eating.cpp
index 50629617dc..ecd5abf156 100644
--- a/src/monster-attack/monster-eating.cpp
+++ b/src/monster-attack/monster-eating.cpp
@@ -22,7 +22,7 @@
#include "player/player-status-flags.h"
#include "player/player-status-table.h"
#include "status/experience.h"
-#include "system/baseitem-info.h"
+#include "system/baseitem/baseitem-definition.h"
#include "system/floor-type-definition.h"
#include "system/item-entity.h"
#include "system/monster-entity.h"
diff --git a/src/object-activation/activation-util.cpp b/src/object-activation/activation-util.cpp
index febe74fb39..788f18d0b4 100644
--- a/src/object-activation/activation-util.cpp
+++ b/src/object-activation/activation-util.cpp
@@ -1,6 +1,6 @@
#include "object-activation/activation-util.h"
#include "object/object-info.h"
-#include "system/baseitem-info.h"
+#include "system/baseitem/baseitem-definition.h"
#include "system/item-entity.h"
#include "system/player-type-definition.h"
diff --git a/src/object-enchant/item-magic-applier.cpp b/src/object-enchant/item-magic-applier.cpp
index e01a208917..bf32ccb365 100644
--- a/src/object-enchant/item-magic-applier.cpp
+++ b/src/object-enchant/item-magic-applier.cpp
@@ -13,7 +13,7 @@
#include "object-enchant/special-object-flags.h"
#include "player/player-status-flags.h"
#include "system/artifact-type-definition.h"
-#include "system/baseitem-info.h"
+#include "system/baseitem/baseitem-definition.h"
#include "system/dungeon-info.h"
#include "system/floor-type-definition.h"
#include "system/item-entity.h"
diff --git a/src/object-enchant/object-boost.cpp b/src/object-enchant/object-boost.cpp
index 0d20a2f112..1ac723a86c 100644
--- a/src/object-enchant/object-boost.cpp
+++ b/src/object-enchant/object-boost.cpp
@@ -2,7 +2,7 @@
#include "artifact/random-art-effects.h"
#include "object-enchant/tr-types.h"
#include "player-ability/player-ability-types.h"
-#include "system/baseitem-info.h"
+#include "system/baseitem/baseitem-definition.h"
#include "system/floor-type-definition.h"
#include "system/item-entity.h"
#include "util/bit-flags-calculator.h"
diff --git a/src/object-enchant/others/apply-magic-amulet.cpp b/src/object-enchant/others/apply-magic-amulet.cpp
index 7208ae22c3..0b0eda3a89 100644
--- a/src/object-enchant/others/apply-magic-amulet.cpp
+++ b/src/object-enchant/others/apply-magic-amulet.cpp
@@ -11,7 +11,7 @@
#include "object-enchant/special-object-flags.h"
#include "object-enchant/trc-types.h"
#include "sv-definition/sv-amulet-types.h"
-#include "system/baseitem-info.h"
+#include "system/baseitem/baseitem-definition.h"
#include "system/item-entity.h"
#include "system/player-type-definition.h"
#include "util/bit-flags-calculator.h"
diff --git a/src/object-enchant/others/apply-magic-others.cpp b/src/object-enchant/others/apply-magic-others.cpp
index 4428ec53c0..5afbfbb5ff 100644
--- a/src/object-enchant/others/apply-magic-others.cpp
+++ b/src/object-enchant/others/apply-magic-others.cpp
@@ -20,7 +20,7 @@
#include "perception/object-perception.h"
#include "sv-definition/sv-lite-types.h"
#include "sv-definition/sv-other-types.h"
-#include "system/baseitem-info.h"
+#include "system/baseitem/baseitem-definition.h"
#include "system/enums/monrace/monrace-id.h"
#include "system/floor-type-definition.h"
#include "system/item-entity.h"
diff --git a/src/object-enchant/others/apply-magic-ring.cpp b/src/object-enchant/others/apply-magic-ring.cpp
index 1d0718081e..7e2f6f7583 100644
--- a/src/object-enchant/others/apply-magic-ring.cpp
+++ b/src/object-enchant/others/apply-magic-ring.cpp
@@ -11,7 +11,7 @@
#include "object-enchant/special-object-flags.h"
#include "object-enchant/trc-types.h"
#include "sv-definition/sv-ring-types.h"
-#include "system/baseitem-info.h"
+#include "system/baseitem/baseitem-definition.h"
#include "system/item-entity.h"
#include "system/player-type-definition.h"
#include "util/bit-flags-calculator.h"
diff --git a/src/object-enchant/protector/apply-magic-soft-armor.cpp b/src/object-enchant/protector/apply-magic-soft-armor.cpp
index 2704563387..ca39da2359 100644
--- a/src/object-enchant/protector/apply-magic-soft-armor.cpp
+++ b/src/object-enchant/protector/apply-magic-soft-armor.cpp
@@ -7,7 +7,7 @@
#include "object-enchant/protector/apply-magic-soft-armor.h"
#include "object/tval-types.h"
#include "sv-definition/sv-armor-types.h"
-#include "system/baseitem-info.h"
+#include "system/baseitem/baseitem-definition.h"
#include "system/item-entity.h"
#include "system/player-type-definition.h"
diff --git a/src/object-hook/hook-expendable.cpp b/src/object-hook/hook-expendable.cpp
index 78707525f7..8a319d7182 100644
--- a/src/object-hook/hook-expendable.cpp
+++ b/src/object-hook/hook-expendable.cpp
@@ -9,7 +9,7 @@
#include "player-info/mimic-info-table.h"
#include "sv-definition/sv-lite-types.h"
#include "sv-definition/sv-other-types.h"
-#include "system/baseitem-info.h"
+#include "system/baseitem/baseitem-definition.h"
#include "system/item-entity.h"
#include "system/monster-race-info.h"
#include "system/player-type-definition.h"
diff --git a/src/object-hook/hook-magic.cpp b/src/object-hook/hook-magic.cpp
index ce257cf245..a5502126c4 100644
--- a/src/object-hook/hook-magic.cpp
+++ b/src/object-hook/hook-magic.cpp
@@ -5,7 +5,7 @@
#include "player-base/player-class.h"
#include "player-info/class-info.h"
#include "player/player-realm.h"
-#include "system/baseitem-info.h"
+#include "system/baseitem/baseitem-definition.h"
#include "system/item-entity.h"
#include "system/player-type-definition.h"
#include "util/bit-flags-calculator.h"
diff --git a/src/object-use/quaff/quaff-execution.cpp b/src/object-use/quaff/quaff-execution.cpp
index 3c4e2865f4..307fb04245 100644
--- a/src/object-use/quaff/quaff-execution.cpp
+++ b/src/object-use/quaff/quaff-execution.cpp
@@ -23,7 +23,7 @@
#include "spell-realm/spells-hex.h"
#include "spell-realm/spells-song.h"
#include "status/experience.h"
-#include "system/baseitem-info.h"
+#include "system/baseitem/baseitem-definition.h"
#include "system/item-entity.h"
#include "system/player-type-definition.h"
#include "system/redrawing-flags-updater.h"
diff --git a/src/object-use/read/read-execution.cpp b/src/object-use/read/read-execution.cpp
index 8ff4fdd03f..901b478b7c 100644
--- a/src/object-use/read/read-execution.cpp
+++ b/src/object-use/read/read-execution.cpp
@@ -20,7 +20,7 @@
#include "spell-realm/spells-hex.h"
#include "spell-realm/spells-song.h"
#include "status/experience.h"
-#include "system/baseitem-info.h"
+#include "system/baseitem/baseitem-definition.h"
#include "system/item-entity.h"
#include "system/player-type-definition.h"
#include "system/redrawing-flags-updater.h"
diff --git a/src/object-use/throw-execution.cpp b/src/object-use/throw-execution.cpp
index cca0fec99d..8b166384d2 100644
--- a/src/object-use/throw-execution.cpp
+++ b/src/object-use/throw-execution.cpp
@@ -51,7 +51,7 @@
#include "player/player-status-table.h"
#include "racial/racial-android.h"
#include "specific-object/torch.h"
-#include "system/baseitem-info.h"
+#include "system/baseitem/baseitem-definition.h"
#include "system/floor-type-definition.h"
#include "system/grid-type-definition.h"
#include "system/item-entity.h"
diff --git a/src/object-use/use-execution.cpp b/src/object-use/use-execution.cpp
index 5fdb0d2a18..6b705091d7 100644
--- a/src/object-use/use-execution.cpp
+++ b/src/object-use/use-execution.cpp
@@ -20,7 +20,7 @@
#include "player-base/player-class.h"
#include "player-status/player-energy.h"
#include "status/experience.h"
-#include "system/baseitem-info.h"
+#include "system/baseitem/baseitem-definition.h"
#include "system/item-entity.h"
#include "system/player-type-definition.h"
#include "system/redrawing-flags-updater.h"
diff --git a/src/object-use/zaprod-execution.cpp b/src/object-use/zaprod-execution.cpp
index 8c0b07ec81..8f7dbe6fbb 100644
--- a/src/object-use/zaprod-execution.cpp
+++ b/src/object-use/zaprod-execution.cpp
@@ -19,7 +19,7 @@
#include "status/experience.h"
#include "sv-definition/sv-other-types.h"
#include "sv-definition/sv-rod-types.h"
-#include "system/baseitem-info.h"
+#include "system/baseitem/baseitem-definition.h"
#include "system/item-entity.h"
#include "system/player-type-definition.h"
#include "system/redrawing-flags-updater.h"
diff --git a/src/object-use/zapwand-execution.cpp b/src/object-use/zapwand-execution.cpp
index f9680dd714..3f2f7f6381 100644
--- a/src/object-use/zapwand-execution.cpp
+++ b/src/object-use/zapwand-execution.cpp
@@ -16,7 +16,7 @@
#include "player-status/player-energy.h"
#include "status/experience.h"
#include "sv-definition/sv-wand-types.h"
-#include "system/baseitem-info.h"
+#include "system/baseitem/baseitem-definition.h"
#include "system/item-entity.h"
#include "system/player-type-definition.h"
#include "system/redrawing-flags-updater.h"
diff --git a/src/object/object-broken.cpp b/src/object/object-broken.cpp
index 6309173cae..b2fb45556b 100644
--- a/src/object/object-broken.cpp
+++ b/src/object/object-broken.cpp
@@ -11,7 +11,7 @@
#include "object-enchant/tr-types.h"
#include "object/tval-types.h"
#include "sv-definition/sv-potion-types.h"
-#include "system/baseitem-info.h"
+#include "system/baseitem/baseitem-definition.h"
#include "system/item-entity.h"
#include "system/player-type-definition.h"
#include "util/bit-flags-calculator.h"
diff --git a/src/object/object-kind-hook.cpp b/src/object/object-kind-hook.cpp
index c8179601fe..0186568841 100644
--- a/src/object/object-kind-hook.cpp
+++ b/src/object/object-kind-hook.cpp
@@ -9,7 +9,7 @@
#include "sv-definition/sv-amulet-types.h"
#include "sv-definition/sv-other-types.h"
#include "sv-definition/sv-ring-types.h"
-#include "system/baseitem-info.h"
+#include "system/baseitem/baseitem-definition.h"
#include
#include
@@ -5478,6 +5481,9 @@
system\baseitem
+
+ system\baseitem
+
diff --git a/src/Makefile.am b/src/Makefile.am
index 899201220c..87a5f7a525 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -940,6 +940,7 @@ hengband_SOURCES = \
system/terrain-type-definition.cpp system/terrain-type-definition.h \
system/gamevalue.h \
\
+ system/baseitem/baseitem-definition.cpp system/baseitem/baseitem-definition.h \
system/baseitem/baseitem-key.cpp system/baseitem/baseitem-key.h \
\
system/enums/game-option-page.h \
diff --git a/src/action/activation-execution.cpp b/src/action/activation-execution.cpp
index 064629689f..302564b07c 100644
--- a/src/action/activation-execution.cpp
+++ b/src/action/activation-execution.cpp
@@ -35,7 +35,7 @@
#include "sv-definition/sv-lite-types.h"
#include "sv-definition/sv-ring-types.h"
#include "system/artifact-type-definition.h"
-#include "system/baseitem/baseitem-definition.h"
+#include "system/baseitem/baseitem-key.h"
#include "system/floor-type-definition.h"
#include "system/item-entity.h"
#include "system/monster-entity.h"
diff --git a/src/birth/inventory-initializer.cpp b/src/birth/inventory-initializer.cpp
index 00230f6134..c8a8004ab7 100644
--- a/src/birth/inventory-initializer.cpp
+++ b/src/birth/inventory-initializer.cpp
@@ -29,6 +29,7 @@
#include "sv-definition/sv-staff-types.h"
#include "sv-definition/sv-wand-types.h"
#include "sv-definition/sv-weapon-types.h"
+#include "system/baseitem/baseitem-definition.h"
#include "system/item-entity.h"
#include "system/player-type-definition.h"
#include "util/enum-converter.h"
diff --git a/src/cmd-action/cmd-spell.cpp b/src/cmd-action/cmd-spell.cpp
index ceed9e4368..bbdff32236 100644
--- a/src/cmd-action/cmd-spell.cpp
+++ b/src/cmd-action/cmd-spell.cpp
@@ -56,7 +56,7 @@
#include "status/bad-status-setter.h"
#include "status/base-status.h"
#include "status/experience.h"
-#include "system/baseitem/baseitem-definition.h"
+#include "system/baseitem/baseitem-key.h"
#include "system/floor-type-definition.h"
#include "system/item-entity.h"
#include "system/player-type-definition.h"
diff --git a/src/cmd-item/cmd-destroy.cpp b/src/cmd-item/cmd-destroy.cpp
index c547849239..030309d455 100644
--- a/src/cmd-item/cmd-destroy.cpp
+++ b/src/cmd-item/cmd-destroy.cpp
@@ -30,7 +30,7 @@
#include "racial/racial-android.h"
#include "status/action-setter.h"
#include "status/experience.h"
-#include "system/baseitem/baseitem-definition.h"
+#include "system/baseitem/baseitem-key.h"
#include "system/item-entity.h"
#include "system/player-type-definition.h"
#include "system/redrawing-flags-updater.h"
diff --git a/src/cmd-item/cmd-eat.cpp b/src/cmd-item/cmd-eat.cpp
index 2aadd8e4d2..0a9495e7c2 100644
--- a/src/cmd-item/cmd-eat.cpp
+++ b/src/cmd-item/cmd-eat.cpp
@@ -41,6 +41,7 @@
#include "status/experience.h"
#include "sv-definition/sv-food-types.h"
#include "sv-definition/sv-other-types.h"
+#include "system/baseitem/baseitem-definition.h"
#include "system/item-entity.h"
#include "system/monster-race-info.h"
#include "system/player-type-definition.h"
diff --git a/src/cmd-item/cmd-zapwand.cpp b/src/cmd-item/cmd-zapwand.cpp
index 666d13ed93..8874facd64 100644
--- a/src/cmd-item/cmd-zapwand.cpp
+++ b/src/cmd-item/cmd-zapwand.cpp
@@ -32,7 +32,7 @@
#include "status/action-setter.h"
#include "status/experience.h"
#include "sv-definition/sv-wand-types.h"
-#include "system/baseitem/baseitem-definition.h"
+#include "system/baseitem/baseitem-key.h"
#include "system/item-entity.h"
#include "system/player-type-definition.h"
#include "target/target-getter.h"
diff --git a/src/cmd-visual/cmd-visuals.cpp b/src/cmd-visual/cmd-visuals.cpp
index 76e588e502..c1f14214fc 100644
--- a/src/cmd-visual/cmd-visuals.cpp
+++ b/src/cmd-visual/cmd-visuals.cpp
@@ -14,6 +14,7 @@
#include "knowledge/knowledge-monsters.h"
#include "knowledge/lighting-level-table.h"
#include "main/sound-of-music.h"
+#include "system/baseitem/baseitem-definition.h"
#include "system/item-entity.h"
#include "system/monster-race-info.h"
#include "system/player-type-definition.h"
diff --git a/src/combat/shoot.cpp b/src/combat/shoot.cpp
index 691cafec76..bb863d6167 100644
--- a/src/combat/shoot.cpp
+++ b/src/combat/shoot.cpp
@@ -47,7 +47,7 @@
#include "player/player-status-table.h"
#include "sv-definition/sv-bow-types.h"
#include "system/artifact-type-definition.h"
-#include "system/baseitem/baseitem-definition.h"
+#include "system/baseitem/baseitem-key.h"
#include "system/enums/monrace/monrace-id.h"
#include "system/floor-type-definition.h"
#include "system/grid-type-definition.h"
diff --git a/src/flavor/flavor-util.cpp b/src/flavor/flavor-util.cpp
index 6522316ce9..2eda4171b6 100644
--- a/src/flavor/flavor-util.cpp
+++ b/src/flavor/flavor-util.cpp
@@ -5,6 +5,7 @@
#include "object/tval-types.h"
#include "sv-definition/sv-food-types.h"
#include "system/artifact-type-definition.h"
+#include "system/baseitem/baseitem-definition.h"
#include "system/item-entity.h"
#include "util/string-processor.h"
#include
diff --git a/src/flavor/named-item-describer.cpp b/src/flavor/named-item-describer.cpp
index fd050f95d2..f5a331cd59 100644
--- a/src/flavor/named-item-describer.cpp
+++ b/src/flavor/named-item-describer.cpp
@@ -11,6 +11,7 @@
#include "object-enchant/tr-types.h"
#include "perception/object-perception.h"
#include "system/artifact-type-definition.h"
+#include "system/baseitem/baseitem-definition.h"
#include "system/item-entity.h"
#include "system/player-type-definition.h"
#include "util/bit-flags-calculator.h"
diff --git a/src/flavor/object-flavor.cpp b/src/flavor/object-flavor.cpp
index 7c5b1ae06f..36581dc2bd 100644
--- a/src/flavor/object-flavor.cpp
+++ b/src/flavor/object-flavor.cpp
@@ -32,7 +32,7 @@
#include "player/player-status.h"
#include "sv-definition/sv-food-types.h"
#include "sv-definition/sv-lite-types.h"
-#include "system/baseitem/baseitem-definition.h"
+#include "system/baseitem/baseitem-key.h"
#include "util/bit-flags-calculator.h"
#include
#include
diff --git a/src/floor/fixed-map-generator.cpp b/src/floor/fixed-map-generator.cpp
index fc0005384c..5fda65a4b6 100644
--- a/src/floor/fixed-map-generator.cpp
+++ b/src/floor/fixed-map-generator.cpp
@@ -25,6 +25,7 @@
#include "room/rooms-vault.h"
#include "sv-definition/sv-scroll-types.h"
#include "system/artifact-type-definition.h"
+#include "system/baseitem/baseitem-definition.h"
#include "system/dungeon-info.h"
#include "system/floor-type-definition.h"
#include "system/grid-type-definition.h"
diff --git a/src/knowledge/knowledge-items.cpp b/src/knowledge/knowledge-items.cpp
index 81902d5c91..3b16161aff 100644
--- a/src/knowledge/knowledge-items.cpp
+++ b/src/knowledge/knowledge-items.cpp
@@ -19,6 +19,7 @@
#include "perception/identification.h"
#include "perception/object-perception.h"
#include "system/artifact-type-definition.h"
+#include "system/baseitem/baseitem-definition.h"
#include "system/floor-type-definition.h"
#include "system/grid-type-definition.h"
#include "system/item-entity.h"
diff --git a/src/market/arena-entry.cpp b/src/market/arena-entry.cpp
index 2e86df23d4..2364e32a82 100644
--- a/src/market/arena-entry.cpp
+++ b/src/market/arena-entry.cpp
@@ -8,7 +8,7 @@
#include "sv-definition/sv-scroll-types.h"
#include "sv-definition/sv-staff-types.h"
#include "sv-definition/sv-wand-types.h"
-#include "system/baseitem/baseitem-definition.h"
+#include "system/baseitem/baseitem-key.h"
#include "system/enums/monrace/monrace-id.h"
#include "system/monster-race-info.h"
#ifndef JP
diff --git a/src/market/bounty-prize-table.cpp b/src/market/bounty-prize-table.cpp
index bc269c93e7..3a89f310dc 100644
--- a/src/market/bounty-prize-table.cpp
+++ b/src/market/bounty-prize-table.cpp
@@ -2,7 +2,7 @@
#include "object/tval-types.h"
#include "sv-definition/sv-potion-types.h"
#include "sv-definition/sv-scroll-types.h"
-#include "system/baseitem/baseitem-definition.h"
+#include "system/baseitem/baseitem-key.h"
const std::vector prize_list = {
{ ItemKindType::POTION, SV_POTION_CURING },
diff --git a/src/monster-floor/monster-death.cpp b/src/monster-floor/monster-death.cpp
index 4da3bc0cd0..3ce55ca0d1 100644
--- a/src/monster-floor/monster-death.cpp
+++ b/src/monster-floor/monster-death.cpp
@@ -30,6 +30,7 @@
#include "sv-definition/sv-scroll-types.h"
#include "system/angband-system.h"
#include "system/artifact-type-definition.h"
+#include "system/baseitem/baseitem-definition.h"
#include "system/building-type-definition.h"
#include "system/dungeon-info.h"
#include "system/enums/monrace/monrace-id.h"
diff --git a/src/object-hook/hook-expendable.cpp b/src/object-hook/hook-expendable.cpp
index 8a319d7182..3bbb88a30c 100644
--- a/src/object-hook/hook-expendable.cpp
+++ b/src/object-hook/hook-expendable.cpp
@@ -9,7 +9,7 @@
#include "player-info/mimic-info-table.h"
#include "sv-definition/sv-lite-types.h"
#include "sv-definition/sv-other-types.h"
-#include "system/baseitem/baseitem-definition.h"
+#include "system/baseitem/baseitem-key.h"
#include "system/item-entity.h"
#include "system/monster-race-info.h"
#include "system/player-type-definition.h"
diff --git a/src/object-hook/hook-magic.cpp b/src/object-hook/hook-magic.cpp
index a5502126c4..e04b3c2d94 100644
--- a/src/object-hook/hook-magic.cpp
+++ b/src/object-hook/hook-magic.cpp
@@ -5,7 +5,7 @@
#include "player-base/player-class.h"
#include "player-info/class-info.h"
#include "player/player-realm.h"
-#include "system/baseitem/baseitem-definition.h"
+#include "system/baseitem/baseitem-key.h"
#include "system/item-entity.h"
#include "system/player-type-definition.h"
#include "util/bit-flags-calculator.h"
diff --git a/src/object-use/throw-execution.cpp b/src/object-use/throw-execution.cpp
index 8b166384d2..b2353daea8 100644
--- a/src/object-use/throw-execution.cpp
+++ b/src/object-use/throw-execution.cpp
@@ -51,7 +51,6 @@
#include "player/player-status-table.h"
#include "racial/racial-android.h"
#include "specific-object/torch.h"
-#include "system/baseitem/baseitem-definition.h"
#include "system/floor-type-definition.h"
#include "system/grid-type-definition.h"
#include "system/item-entity.h"
@@ -66,6 +65,7 @@
#include "util/bit-flags-calculator.h"
#include "util/string-processor.h"
#include "view/display-messages.h"
+#include "view/display-symbol.h"
#include "view/object-describer.h"
#include "wizard/wizard-messages.h"
diff --git a/src/perception/object-perception.cpp b/src/perception/object-perception.cpp
index 9e268eee82..3963d84bed 100644
--- a/src/perception/object-perception.cpp
+++ b/src/perception/object-perception.cpp
@@ -3,6 +3,7 @@
#include "flavor/object-flavor-types.h"
#include "game-option/play-record-options.h"
#include "io/write-diary.h"
+#include "system/baseitem/baseitem-definition.h"
#include "system/item-entity.h"
#include "system/player-type-definition.h"
diff --git a/src/spell/spells-object.cpp b/src/spell/spells-object.cpp
index 48d07c0b2e..e9b3e68611 100644
--- a/src/spell/spells-object.cpp
+++ b/src/spell/spells-object.cpp
@@ -32,7 +32,7 @@
#include "sv-definition/sv-scroll-types.h"
#include "sv-definition/sv-weapon-types.h"
#include "system/artifact-type-definition.h"
-#include "system/baseitem/baseitem-definition.h"
+#include "system/baseitem/baseitem-key.h"
#include "system/floor-type-definition.h"
#include "system/item-entity.h"
#include "system/monster-race-info.h"
diff --git a/src/store/articles-on-sale.cpp b/src/store/articles-on-sale.cpp
index 9cc0a57920..7611d3bcaa 100644
--- a/src/store/articles-on-sale.cpp
+++ b/src/store/articles-on-sale.cpp
@@ -16,7 +16,7 @@
#include "sv-definition/sv-staff-types.h"
#include "sv-definition/sv-wand-types.h"
#include "sv-definition/sv-weapon-types.h"
-#include "system/baseitem/baseitem-definition.h"
+#include "system/baseitem/baseitem-key.h"
/*!
* @brief 店舗で常時販売するオブジェクトを定義する
diff --git a/src/store/rumor.cpp b/src/store/rumor.cpp
index 0ea5f4e741..8f1b20b532 100644
--- a/src/store/rumor.cpp
+++ b/src/store/rumor.cpp
@@ -57,7 +57,7 @@ static std::string bind_rumor_name(std::string_view base, std::string_view item_
* @return トークン読み込み成否 とトークン群の配列
* @todo tmp_tokensを使わず単なるsplitにすればもっと簡略化できそう
*/
-std::pair> get_rumor_tokens(std::string rumor)
+static std::pair> get_rumor_tokens(std::string rumor)
{
constexpr auto num_tokens = 3;
char *tmp_tokens[num_tokens];
diff --git a/src/system/artifact-type-definition.cpp b/src/system/artifact-type-definition.cpp
index d2b8fffbee..8c0642b15d 100644
--- a/src/system/artifact-type-definition.cpp
+++ b/src/system/artifact-type-definition.cpp
@@ -1,6 +1,7 @@
#include "system/artifact-type-definition.h"
#include "artifact/fixed-art-types.h"
#include "object/tval-types.h"
+#include "system/baseitem/baseitem-definition.h"
#include "system/item-entity.h"
ArtifactType::ArtifactType()
diff --git a/src/system/artifact-type-definition.h b/src/system/artifact-type-definition.h
index 32b2c3f9d6..34e96241ba 100644
--- a/src/system/artifact-type-definition.h
+++ b/src/system/artifact-type-definition.h
@@ -3,7 +3,7 @@
#include "object-enchant/tr-flags.h"
#include "object-enchant/trg-types.h"
#include "system/angband.h"
-#include "system/baseitem/baseitem-definition.h"
+#include "system/baseitem/baseitem-key.h"
#include "util/dice.h"
#include "util/flag-group.h"
#include
diff --git a/src/system/baseitem/baseitem-definition.cpp b/src/system/baseitem/baseitem-definition.cpp
index d5ed66e77e..ada68dabc9 100644
--- a/src/system/baseitem/baseitem-definition.cpp
+++ b/src/system/baseitem/baseitem-definition.cpp
@@ -1,37 +1,21 @@
/*!
- * @brief ベースアイテム情報の構造体 / Information about object "kinds", including player knowledge.
- * @date 2019/05/01
- * @author deskull
- * @details
- * ゲーム進行用のセーブファイル上では aware と tried のみ保存対象とすること。と英文ではあるが実際はもっとある様子である。 /
- * Only "aware" and "tried" are saved in the savefile
+ * @brief ベースアイテム定義
+ * @date 2024/11/16
+ * @author deskull, Hourier
*/
#include "system/baseitem/baseitem-definition.h"
#include "object/tval-types.h"
-#include "sv-definition/sv-armor-types.h"
-#include "sv-definition/sv-bow-types.h"
-#include "sv-definition/sv-food-types.h"
-#include "sv-definition/sv-lite-types.h"
-#include "sv-definition/sv-other-types.h"
#include "sv-definition/sv-potion-types.h"
-#include "sv-definition/sv-protector-types.h"
-#include "sv-definition/sv-rod-types.h"
#include "sv-definition/sv-staff-types.h"
-#include "sv-definition/sv-weapon-types.h"
#include "system/angband-exceptions.h"
#include "system/enums/monrace/monrace-id.h"
#include "util/enum-converter.h"
#include "util/string-processor.h"
#include
#include
-#include
-#include
namespace {
-constexpr auto ITEM_NOT_BOW = "This item is not a bow!";
-constexpr auto ITEM_NOT_ROD = "This item is not a rod!";
-constexpr auto ITEM_NOT_LITE = "This item is not a lite!";
constexpr auto INVALID_BI_ID_FORMAT = "Invalid Baseitem ID is specified! %d";
constexpr auto INVALID_BASEITEM_KEY = "Invalid Baseitem Key is specified! Type: %d, Subtype: %d";
const std::map GOLD_KINDS = {
@@ -57,600 +41,6 @@ const std::map CREEPING_COIN_DROPS = {
};
}
-bool BaseitemKey::operator==(const BaseitemKey &other) const
-{
- return (this->type_value == other.type_value) && (this->subtype_value == other.subtype_value);
-}
-
-// @details type_valueに大小があればそれを判定し、同一ならばsubtype_valueの大小を判定する.
-bool BaseitemKey::operator<(const BaseitemKey &other) const
-{
- if (this->type_value < other.type_value) {
- return true;
- }
-
- if (this->type_value > other.type_value) {
- return false;
- }
-
- return this->subtype_value < other.subtype_value;
-}
-
-ItemKindType BaseitemKey::tval() const
-{
- return this->type_value;
-}
-
-std::optional BaseitemKey::sval() const
-{
- return this->subtype_value;
-}
-
-bool BaseitemKey::is_valid() const
-{
- return (this->type_value > ItemKindType::NONE) && this->subtype_value.has_value();
-}
-
-bool BaseitemKey::is(ItemKindType tval) const
-{
- return this->type_value == tval;
-}
-
-/*!
- * @brief 射撃武器に対応する矢/弾薬のベースアイテムIDを返す
- * @return 対応する矢/弾薬のベースアイテムID
- */
-ItemKindType BaseitemKey::get_arrow_kind() const
-{
- if ((this->type_value != ItemKindType::BOW) || !this->subtype_value) {
- THROW_EXCEPTION(std::logic_error, ITEM_NOT_BOW);
- }
-
- switch (*this->subtype_value) {
- case SV_SLING:
- return ItemKindType::SHOT;
- case SV_SHORT_BOW:
- case SV_LONG_BOW:
- case SV_NAMAKE_BOW:
- return ItemKindType::ARROW;
- case SV_LIGHT_XBOW:
- case SV_HEAVY_XBOW:
- return ItemKindType::BOLT;
- case SV_CRIMSON:
- case SV_HARP:
- return ItemKindType::NO_AMMO;
- default:
- return ItemKindType::NONE;
- }
-}
-
-bool BaseitemKey::is_spell_book() const
-{
- switch (this->type_value) {
- case ItemKindType::LIFE_BOOK:
- case ItemKindType::SORCERY_BOOK:
- case ItemKindType::NATURE_BOOK:
- case ItemKindType::CHAOS_BOOK:
- case ItemKindType::DEATH_BOOK:
- case ItemKindType::TRUMP_BOOK:
- case ItemKindType::ARCANE_BOOK:
- case ItemKindType::CRAFT_BOOK:
- case ItemKindType::DEMON_BOOK:
- case ItemKindType::CRUSADE_BOOK:
- case ItemKindType::MUSIC_BOOK:
- case ItemKindType::HISSATSU_BOOK:
- case ItemKindType::HEX_BOOK:
- return true;
- default:
- return false;
- }
-}
-
-bool BaseitemKey::is_high_level_book() const
-{
- if (!this->is_spell_book()) {
- return false;
- }
-
- if (this->type_value == ItemKindType::ARCANE_BOOK) {
- return false;
- }
-
- return this->subtype_value >= 2;
-}
-
-bool BaseitemKey::is_melee_weapon() const
-{
- switch (this->type_value) {
- case ItemKindType::POLEARM:
- case ItemKindType::SWORD:
- case ItemKindType::DIGGING:
- case ItemKindType::HAFTED:
- return true;
- default:
- return false;
- }
-}
-
-bool BaseitemKey::is_ammo() const
-{
- switch (this->type_value) {
- case ItemKindType::SHOT:
- case ItemKindType::ARROW:
- case ItemKindType::BOLT:
- return true;
- default:
- return false;
- }
-}
-
-/*
- * @brief 未鑑定名を持つか否かの判定
- * @details FOODはキノコが該当する
- */
-bool BaseitemKey::has_unidentified_name() const
-{
- switch (this->type_value) {
- case ItemKindType::AMULET:
- case ItemKindType::RING:
- case ItemKindType::STAFF:
- case ItemKindType::WAND:
- case ItemKindType::ROD:
- case ItemKindType::SCROLL:
- case ItemKindType::POTION:
- return true;
- case ItemKindType::FOOD:
- return this->is_mushrooms();
- default:
- return false;
- }
-}
-
-bool BaseitemKey::can_recharge() const
-{
- switch (this->type_value) {
- case ItemKindType::STAFF:
- case ItemKindType::WAND:
- case ItemKindType::ROD:
- return true;
- default:
- return false;
- }
-}
-
-bool BaseitemKey::is_wand_rod() const
-{
- switch (this->type_value) {
- case ItemKindType::WAND:
- case ItemKindType::ROD:
- return true;
- default:
- return false;
- }
-}
-
-bool BaseitemKey::is_wand_staff() const
-{
- switch (this->type_value) {
- case ItemKindType::WAND:
- case ItemKindType::STAFF:
- return true;
- default:
- return false;
- }
-}
-
-bool BaseitemKey::is_protector() const
-{
- switch (this->type_value) {
- case ItemKindType::BOOTS:
- case ItemKindType::GLOVES:
- case ItemKindType::HELM:
- case ItemKindType::CROWN:
- case ItemKindType::SHIELD:
- case ItemKindType::CLOAK:
- case ItemKindType::SOFT_ARMOR:
- case ItemKindType::HARD_ARMOR:
- case ItemKindType::DRAG_ARMOR:
- return true;
- default:
- return false;
- }
-}
-
-bool BaseitemKey::can_be_aura_protector() const
-{
- switch (this->type_value) {
- case ItemKindType::CLOAK:
- case ItemKindType::SOFT_ARMOR:
- case ItemKindType::HARD_ARMOR:
- return true;
- default:
- return false;
- }
-}
-
-bool BaseitemKey::is_wearable() const
-{
- switch (this->type_value) {
- case ItemKindType::BOW:
- case ItemKindType::DIGGING:
- case ItemKindType::HAFTED:
- case ItemKindType::POLEARM:
- case ItemKindType::SWORD:
- case ItemKindType::BOOTS:
- case ItemKindType::GLOVES:
- case ItemKindType::HELM:
- case ItemKindType::CROWN:
- case ItemKindType::SHIELD:
- case ItemKindType::CLOAK:
- case ItemKindType::SOFT_ARMOR:
- case ItemKindType::HARD_ARMOR:
- case ItemKindType::DRAG_ARMOR:
- case ItemKindType::LITE:
- case ItemKindType::AMULET:
- case ItemKindType::RING:
- case ItemKindType::CARD:
- return true;
- default:
- return false;
- }
-}
-
-bool BaseitemKey::is_weapon() const
-{
- switch (this->type_value) {
- case ItemKindType::BOW:
- case ItemKindType::DIGGING:
- case ItemKindType::HAFTED:
- case ItemKindType::POLEARM:
- case ItemKindType::SWORD:
- return true;
- default:
- return false;
- }
-}
-
-bool BaseitemKey::is_equipement() const
-{
- return this->is_wearable() || this->is_ammo();
-}
-
-bool BaseitemKey::is_melee_ammo() const
-{
- switch (this->type_value) {
- case ItemKindType::HAFTED:
- case ItemKindType::POLEARM:
- case ItemKindType::DIGGING:
- case ItemKindType::BOLT:
- case ItemKindType::ARROW:
- case ItemKindType::SHOT:
- return true;
- case ItemKindType::SWORD:
- return this->subtype_value != SV_POISON_NEEDLE;
- default:
- return false;
- }
-}
-
-bool BaseitemKey::is_orthodox_melee_weapon() const
-{
- switch (this->type_value) {
- case ItemKindType::HAFTED:
- case ItemKindType::POLEARM:
- case ItemKindType::DIGGING:
- return true;
- case ItemKindType::SWORD:
- return this->subtype_value != SV_POISON_NEEDLE;
- default:
- return false;
- }
-}
-
-bool BaseitemKey::is_broken_weapon() const
-{
- if (this->type_value != ItemKindType::SWORD) {
- return false;
- }
-
- if (!this->subtype_value) {
- return false;
- }
-
- switch (*this->subtype_value) {
- case SV_BROKEN_DAGGER:
- case SV_BROKEN_SWORD:
- return true;
- default:
- return false;
- }
-}
-
-bool BaseitemKey::is_throwable() const
-{
- switch (this->type_value) {
- case ItemKindType::DIGGING:
- case ItemKindType::HAFTED:
- case ItemKindType::POLEARM:
- case ItemKindType::SWORD:
- return true;
- default:
- return false;
- }
-}
-
-bool BaseitemKey::is_wieldable_in_etheir_hand() const
-{
- switch (this->type_value) {
- case ItemKindType::DIGGING:
- case ItemKindType::HAFTED:
- case ItemKindType::POLEARM:
- case ItemKindType::SWORD:
- case ItemKindType::SHIELD:
- case ItemKindType::CAPTURE:
- case ItemKindType::CARD:
- return true;
- default:
- return false;
- }
-}
-
-bool BaseitemKey::is_rare() const
-{
- static const std::unordered_map> rare_table = {
- { ItemKindType::HAFTED, { SV_MACE_OF_DISRUPTION, SV_WIZSTAFF } },
- { ItemKindType::POLEARM, { SV_SCYTHE_OF_SLICING, SV_DEATH_SCYTHE } },
- { ItemKindType::SWORD, { SV_BLADE_OF_CHAOS, SV_DIAMOND_EDGE, SV_POISON_NEEDLE, SV_HAYABUSA } },
- { ItemKindType::SHIELD, { SV_DRAGON_SHIELD, SV_MIRROR_SHIELD } },
- { ItemKindType::HELM, { SV_DRAGON_HELM } },
- { ItemKindType::BOOTS, { SV_PAIR_OF_DRAGON_GREAVE } },
- { ItemKindType::CLOAK, { SV_ELVEN_CLOAK, SV_ETHEREAL_CLOAK, SV_SHADOW_CLOAK, SV_MAGIC_RESISTANCE_CLOAK } },
- { ItemKindType::GLOVES, { SV_SET_OF_DRAGON_GLOVES } },
- { ItemKindType::SOFT_ARMOR, { SV_KUROSHOUZOKU, SV_ABUNAI_MIZUGI } },
- { ItemKindType::HARD_ARMOR, { SV_MITHRIL_CHAIN_MAIL, SV_MITHRIL_PLATE_MAIL, SV_ADAMANTITE_PLATE_MAIL } },
- { ItemKindType::DRAG_ARMOR, { /* Any */ } },
- };
-
- if (!this->subtype_value) {
- return false;
- }
-
- if (auto it = rare_table.find(this->type_value); it != rare_table.end()) {
- const auto &svals = it->second;
- return svals.empty() || (svals.find(*this->subtype_value) != svals.end());
- }
-
- return false;
-}
-
-short BaseitemKey::get_bow_energy() const
-{
- if ((this->type_value != ItemKindType::BOW) || !this->subtype_value) {
- THROW_EXCEPTION(std::logic_error, ITEM_NOT_BOW);
- }
-
- switch (*this->subtype_value) {
- case SV_SLING:
- return 8000;
- case SV_NAMAKE_BOW:
- return 7777;
- case SV_LIGHT_XBOW:
- return 12000;
- case SV_HEAVY_XBOW:
- return 13333;
- default:
- return 10000;
- }
-}
-
-int BaseitemKey::get_arrow_magnification() const
-{
- if ((this->type_value != ItemKindType::BOW) || !this->subtype_value) {
- THROW_EXCEPTION(std::logic_error, ITEM_NOT_BOW);
- }
-
- switch (*this->subtype_value) {
- case SV_SLING:
- case SV_SHORT_BOW:
- return 2;
- case SV_LONG_BOW:
- case SV_NAMAKE_BOW:
- case SV_LIGHT_XBOW:
- return 3;
- case SV_HEAVY_XBOW:
- return 4;
- default:
- return 0;
- }
-}
-
-bool BaseitemKey::is_aiming_rod() const
-{
- if ((this->type_value != ItemKindType::ROD) || !this->subtype_value) {
- THROW_EXCEPTION(std::logic_error, ITEM_NOT_ROD);
- }
-
- switch (*this->subtype_value) {
- case SV_ROD_TELEPORT_AWAY:
- case SV_ROD_DISARMING:
- case SV_ROD_LITE:
- case SV_ROD_SLEEP_MONSTER:
- case SV_ROD_SLOW_MONSTER:
- case SV_ROD_HYPODYNAMIA:
- case SV_ROD_POLYMORPH:
- case SV_ROD_ACID_BOLT:
- case SV_ROD_ELEC_BOLT:
- case SV_ROD_FIRE_BOLT:
- case SV_ROD_COLD_BOLT:
- case SV_ROD_ACID_BALL:
- case SV_ROD_ELEC_BALL:
- case SV_ROD_FIRE_BALL:
- case SV_ROD_COLD_BALL:
- case SV_ROD_STONE_TO_MUD:
- return true;
- default:
- return false;
- }
-}
-
-bool BaseitemKey::is_lite_requiring_fuel() const
-{
- if ((this->type_value != ItemKindType::LITE) || !this->subtype_value) {
- THROW_EXCEPTION(std::logic_error, ITEM_NOT_LITE);
- }
-
- switch (*this->subtype_value) {
- case SV_LITE_TORCH:
- case SV_LITE_LANTERN:
- return true;
- default:
- return false;
- }
-}
-
-bool BaseitemKey::is_junk() const
-{
- switch (this->type_value) {
- case ItemKindType::FLAVOR_SKELETON:
- case ItemKindType::BOTTLE:
- case ItemKindType::JUNK:
- case ItemKindType::STATUE:
- return true;
- default:
- return false;
- }
-}
-
-bool BaseitemKey::is_armour() const
-{
- switch (this->type_value) {
- case ItemKindType::SOFT_ARMOR:
- case ItemKindType::HARD_ARMOR:
- case ItemKindType::DRAG_ARMOR:
- return true;
- default:
- return false;
- }
-}
-
-bool BaseitemKey::is_cross_bow() const
-{
- if ((this->type_value != ItemKindType::BOW) || !this->subtype_value) {
- return false;
- }
-
- switch (*this->subtype_value) {
- case SV_LIGHT_XBOW:
- case SV_HEAVY_XBOW:
- return true;
- default:
- return false;
- }
-}
-
-bool BaseitemKey::should_refuse_enchant() const
-{
- return *this == BaseitemKey(ItemKindType::SWORD, SV_POISON_NEEDLE);
-}
-
-bool BaseitemKey::is_convertible() const
-{
- auto is_convertible = this->is(ItemKindType::JUNK) || this->is(ItemKindType::FLAVOR_SKELETON);
- is_convertible |= *this == BaseitemKey(ItemKindType::MONSTER_REMAINS, SV_SKELETON);
- return is_convertible;
-}
-
-bool BaseitemKey::is_fuel() const
-{
- auto is_fuel = *this == BaseitemKey(ItemKindType::LITE, SV_LITE_TORCH);
- is_fuel |= *this == BaseitemKey(ItemKindType::LITE, SV_LITE_LANTERN);
- is_fuel |= *this == BaseitemKey(ItemKindType::FLASK, SV_FLASK_OIL);
- return is_fuel;
-}
-
-bool BaseitemKey::is_lance() const
-{
- auto is_lance = *this == BaseitemKey(ItemKindType::POLEARM, SV_LANCE);
- is_lance |= *this == BaseitemKey(ItemKindType::POLEARM, SV_HEAVY_LANCE);
- return is_lance;
-}
-
-bool BaseitemKey::is_readable() const
-{
- auto can_read = this->is(ItemKindType::SCROLL);
- can_read |= this->is(ItemKindType::PARCHMENT);
- return can_read;
-}
-
-bool BaseitemKey::is_corpse() const
-{
- return *this == BaseitemKey(ItemKindType::MONSTER_REMAINS, SV_CORPSE);
-}
-
-bool BaseitemKey::is_monster() const
-{
- switch (this->type_value) {
- case ItemKindType::FIGURINE:
- case ItemKindType::STATUE:
- case ItemKindType::MONSTER_REMAINS:
- case ItemKindType::CAPTURE:
- return true;
- default:
- return false;
- }
-}
-
-/*!
- * @brief 2つのアイテムが同時に「普通の」像であることを示す
- * @param チェック対象のベースアイテムキー
- * @return 両方が写真の時だけfalse、少なくとも片方が「普通の」像ならばtrue、像ですらないならば例外
- */
-bool BaseitemKey::are_both_statue(const BaseitemKey &other) const
-{
- if ((this->type_value != ItemKindType::STATUE)) {
- THROW_EXCEPTION(std::logic_error, "This item is not a statue!");
- }
-
- if (other.type_value != ItemKindType::STATUE) {
- THROW_EXCEPTION(std::logic_error, "The other item is not a statue!");
- }
-
- return (this->subtype_value != SV_PHOTO) || (other.subtype_value != SV_PHOTO);
-}
-
-bool BaseitemKey::is_mushrooms() const
-{
- if (!this->subtype_value) {
- return false;
- }
-
- switch (*this->subtype_value) {
- case SV_FOOD_POISON:
- case SV_FOOD_BLINDNESS:
- case SV_FOOD_PARANOIA:
- case SV_FOOD_CONFUSION:
- case SV_FOOD_HALLUCINATION:
- case SV_FOOD_PARALYSIS:
- case SV_FOOD_WEAKNESS:
- case SV_FOOD_SICKNESS:
- case SV_FOOD_STUPIDITY:
- case SV_FOOD_NAIVETY:
- case SV_FOOD_UNHEALTH:
- case SV_FOOD_DISEASE:
- case SV_FOOD_CURE_POISON:
- case SV_FOOD_CURE_BLINDNESS:
- case SV_FOOD_CURE_PARANOIA:
- case SV_FOOD_CURE_CONFUSION:
- case SV_FOOD_CURE_SERIOUS:
- case SV_FOOD_RESTORE_STR:
- case SV_FOOD_RESTORE_CON:
- case SV_FOOD_RESTORING:
- return true;
- default:
- return false;
- }
-}
-
BaseitemInfo::BaseitemInfo()
: bi_key(ItemKindType::NONE)
, symbol_definition(DisplaySymbol(0, '\0'))
diff --git a/src/system/baseitem/baseitem-definition.h b/src/system/baseitem/baseitem-definition.h
index f4bfca70dc..92e0cb9fea 100644
--- a/src/system/baseitem/baseitem-definition.h
+++ b/src/system/baseitem/baseitem-definition.h
@@ -4,6 +4,7 @@
#include "object-enchant/trg-types.h"
#include "object/tval-types.h"
#include "system/angband.h"
+#include "system/baseitem/baseitem-key.h"
#include "util/dice.h"
#include "util/enum-range.h"
#include "util/flag-group.h"
@@ -31,90 +32,6 @@ enum class MoneyKind {
constexpr EnumRange MONEY_KIND_RANGE(MoneyKind::COPPER, MoneyKind::MAX);
-class BaseitemKey {
-public:
- constexpr BaseitemKey()
- : type_value(ItemKindType::NONE)
- , subtype_value(std::nullopt)
- {
- }
-
- constexpr BaseitemKey(const ItemKindType type_value, const std::optional &subtype_value = std::nullopt)
- : type_value(type_value)
- , subtype_value(subtype_value)
- {
- }
-
- bool operator==(const BaseitemKey &other) const;
- bool operator!=(const BaseitemKey &other) const
- {
- return !(*this == other);
- }
-
- bool operator<(const BaseitemKey &other) const;
- bool operator>(const BaseitemKey &other) const
- {
- return other < *this;
- }
-
- bool operator<=(const BaseitemKey &other) const
- {
- return !(*this > other);
- }
-
- bool operator>=(const BaseitemKey &other) const
- {
- return !(*this < other);
- }
-
- ItemKindType tval() const;
- std::optional sval() const;
- bool is_valid() const;
- bool is(ItemKindType tval) const;
- ItemKindType get_arrow_kind() const;
- bool is_spell_book() const;
- bool is_high_level_book() const;
- bool is_melee_weapon() const;
- bool is_ammo() const;
- bool has_unidentified_name() const;
- bool can_recharge() const;
- bool is_wand_rod() const;
- bool is_wand_staff() const;
- bool is_protector() const;
- bool can_be_aura_protector() const;
- bool is_wearable() const;
- bool is_weapon() const;
- bool is_equipement() const;
- bool is_melee_ammo() const;
- bool is_orthodox_melee_weapon() const;
- bool is_broken_weapon() const;
- bool is_throwable() const;
- bool is_wieldable_in_etheir_hand() const;
- bool is_rare() const;
- short get_bow_energy() const;
- int get_arrow_magnification() const;
- bool is_aiming_rod() const;
- bool is_lite_requiring_fuel() const;
- bool is_junk() const;
- bool is_armour() const;
- bool is_cross_bow() const;
- bool should_refuse_enchant() const;
- bool is_convertible() const;
- bool is_fuel() const;
- bool is_lance() const;
- bool is_readable() const;
- bool is_corpse() const;
- bool is_monster() const;
- bool are_both_statue(const BaseitemKey &other) const;
-
-private:
- ItemKindType type_value;
- std::optional subtype_value;
-
- bool is_mushrooms() const;
-};
-
-enum class ItemKindType : short;
enum class RandomArtActType : short;
class BaseitemInfo {
public:
@@ -170,6 +87,7 @@ class BaseitemInfo {
void mark_as_aware();
};
+enum class ItemKindType : short;
enum class MonraceId : short;
class BaseitemList {
public:
diff --git a/src/system/baseitem/baseitem-key.cpp b/src/system/baseitem/baseitem-key.cpp
new file mode 100644
index 0000000000..7bc5e333d7
--- /dev/null
+++ b/src/system/baseitem/baseitem-key.cpp
@@ -0,0 +1,619 @@
+/*!
+ * @brief ベースアイテムキー (IDと1対1対応するアイテム種別)実装
+ * @author Hourier
+ * @date 2024/11/16
+ */
+
+#include "system/baseitem/baseitem-key.h"
+#include "object/tval-types.h"
+#include "sv-definition/sv-armor-types.h"
+#include "sv-definition/sv-bow-types.h"
+#include "sv-definition/sv-food-types.h"
+#include "sv-definition/sv-lite-types.h"
+#include "sv-definition/sv-other-types.h"
+#include "sv-definition/sv-potion-types.h"
+#include "sv-definition/sv-protector-types.h"
+#include "sv-definition/sv-rod-types.h"
+#include "sv-definition/sv-staff-types.h"
+#include "sv-definition/sv-weapon-types.h"
+#include "system/angband-exceptions.h"
+#include
+#include
+
+constexpr auto ITEM_NOT_BOW = "This item is not a bow!";
+constexpr auto ITEM_NOT_ROD = "This item is not a rod!";
+constexpr auto ITEM_NOT_LITE = "This item is not a lite!";
+
+bool BaseitemKey::operator==(const BaseitemKey &other) const
+{
+ return (this->type_value == other.type_value) && (this->subtype_value == other.subtype_value);
+}
+
+// @details type_valueに大小があればそれを判定し、同一ならばsubtype_valueの大小を判定する.
+bool BaseitemKey::operator<(const BaseitemKey &other) const
+{
+ if (this->type_value < other.type_value) {
+ return true;
+ }
+
+ if (this->type_value > other.type_value) {
+ return false;
+ }
+
+ return this->subtype_value < other.subtype_value;
+}
+
+ItemKindType BaseitemKey::tval() const
+{
+ return this->type_value;
+}
+
+std::optional BaseitemKey::sval() const
+{
+ return this->subtype_value;
+}
+
+bool BaseitemKey::is_valid() const
+{
+ return (this->type_value > ItemKindType::NONE) && this->subtype_value.has_value();
+}
+
+bool BaseitemKey::is(ItemKindType tval) const
+{
+ return this->type_value == tval;
+}
+
+/*!
+ * @brief 射撃武器に対応する矢/弾薬のベースアイテムIDを返す
+ * @return 対応する矢/弾薬のベースアイテムID
+ */
+ItemKindType BaseitemKey::get_arrow_kind() const
+{
+ if ((this->type_value != ItemKindType::BOW) || !this->subtype_value) {
+ THROW_EXCEPTION(std::logic_error, ITEM_NOT_BOW);
+ }
+
+ switch (*this->subtype_value) {
+ case SV_SLING:
+ return ItemKindType::SHOT;
+ case SV_SHORT_BOW:
+ case SV_LONG_BOW:
+ case SV_NAMAKE_BOW:
+ return ItemKindType::ARROW;
+ case SV_LIGHT_XBOW:
+ case SV_HEAVY_XBOW:
+ return ItemKindType::BOLT;
+ case SV_CRIMSON:
+ case SV_HARP:
+ return ItemKindType::NO_AMMO;
+ default:
+ return ItemKindType::NONE;
+ }
+}
+
+bool BaseitemKey::is_spell_book() const
+{
+ switch (this->type_value) {
+ case ItemKindType::LIFE_BOOK:
+ case ItemKindType::SORCERY_BOOK:
+ case ItemKindType::NATURE_BOOK:
+ case ItemKindType::CHAOS_BOOK:
+ case ItemKindType::DEATH_BOOK:
+ case ItemKindType::TRUMP_BOOK:
+ case ItemKindType::ARCANE_BOOK:
+ case ItemKindType::CRAFT_BOOK:
+ case ItemKindType::DEMON_BOOK:
+ case ItemKindType::CRUSADE_BOOK:
+ case ItemKindType::MUSIC_BOOK:
+ case ItemKindType::HISSATSU_BOOK:
+ case ItemKindType::HEX_BOOK:
+ return true;
+ default:
+ return false;
+ }
+}
+
+bool BaseitemKey::is_high_level_book() const
+{
+ if (!this->is_spell_book()) {
+ return false;
+ }
+
+ if (this->type_value == ItemKindType::ARCANE_BOOK) {
+ return false;
+ }
+
+ return this->subtype_value >= 2;
+}
+
+bool BaseitemKey::is_melee_weapon() const
+{
+ switch (this->type_value) {
+ case ItemKindType::POLEARM:
+ case ItemKindType::SWORD:
+ case ItemKindType::DIGGING:
+ case ItemKindType::HAFTED:
+ return true;
+ default:
+ return false;
+ }
+}
+
+bool BaseitemKey::is_ammo() const
+{
+ switch (this->type_value) {
+ case ItemKindType::SHOT:
+ case ItemKindType::ARROW:
+ case ItemKindType::BOLT:
+ return true;
+ default:
+ return false;
+ }
+}
+
+/*
+ * @brief 未鑑定名を持つか否かの判定
+ * @details FOODはキノコが該当する
+ */
+bool BaseitemKey::has_unidentified_name() const
+{
+ switch (this->type_value) {
+ case ItemKindType::AMULET:
+ case ItemKindType::RING:
+ case ItemKindType::STAFF:
+ case ItemKindType::WAND:
+ case ItemKindType::ROD:
+ case ItemKindType::SCROLL:
+ case ItemKindType::POTION:
+ return true;
+ case ItemKindType::FOOD:
+ return this->is_mushrooms();
+ default:
+ return false;
+ }
+}
+
+bool BaseitemKey::can_recharge() const
+{
+ switch (this->type_value) {
+ case ItemKindType::STAFF:
+ case ItemKindType::WAND:
+ case ItemKindType::ROD:
+ return true;
+ default:
+ return false;
+ }
+}
+
+bool BaseitemKey::is_wand_rod() const
+{
+ switch (this->type_value) {
+ case ItemKindType::WAND:
+ case ItemKindType::ROD:
+ return true;
+ default:
+ return false;
+ }
+}
+
+bool BaseitemKey::is_wand_staff() const
+{
+ switch (this->type_value) {
+ case ItemKindType::WAND:
+ case ItemKindType::STAFF:
+ return true;
+ default:
+ return false;
+ }
+}
+
+bool BaseitemKey::is_protector() const
+{
+ switch (this->type_value) {
+ case ItemKindType::BOOTS:
+ case ItemKindType::GLOVES:
+ case ItemKindType::HELM:
+ case ItemKindType::CROWN:
+ case ItemKindType::SHIELD:
+ case ItemKindType::CLOAK:
+ case ItemKindType::SOFT_ARMOR:
+ case ItemKindType::HARD_ARMOR:
+ case ItemKindType::DRAG_ARMOR:
+ return true;
+ default:
+ return false;
+ }
+}
+
+bool BaseitemKey::can_be_aura_protector() const
+{
+ switch (this->type_value) {
+ case ItemKindType::CLOAK:
+ case ItemKindType::SOFT_ARMOR:
+ case ItemKindType::HARD_ARMOR:
+ return true;
+ default:
+ return false;
+ }
+}
+
+bool BaseitemKey::is_wearable() const
+{
+ switch (this->type_value) {
+ case ItemKindType::BOW:
+ case ItemKindType::DIGGING:
+ case ItemKindType::HAFTED:
+ case ItemKindType::POLEARM:
+ case ItemKindType::SWORD:
+ case ItemKindType::BOOTS:
+ case ItemKindType::GLOVES:
+ case ItemKindType::HELM:
+ case ItemKindType::CROWN:
+ case ItemKindType::SHIELD:
+ case ItemKindType::CLOAK:
+ case ItemKindType::SOFT_ARMOR:
+ case ItemKindType::HARD_ARMOR:
+ case ItemKindType::DRAG_ARMOR:
+ case ItemKindType::LITE:
+ case ItemKindType::AMULET:
+ case ItemKindType::RING:
+ case ItemKindType::CARD:
+ return true;
+ default:
+ return false;
+ }
+}
+
+bool BaseitemKey::is_weapon() const
+{
+ switch (this->type_value) {
+ case ItemKindType::BOW:
+ case ItemKindType::DIGGING:
+ case ItemKindType::HAFTED:
+ case ItemKindType::POLEARM:
+ case ItemKindType::SWORD:
+ return true;
+ default:
+ return false;
+ }
+}
+
+bool BaseitemKey::is_equipement() const
+{
+ return this->is_wearable() || this->is_ammo();
+}
+
+bool BaseitemKey::is_melee_ammo() const
+{
+ switch (this->type_value) {
+ case ItemKindType::HAFTED:
+ case ItemKindType::POLEARM:
+ case ItemKindType::DIGGING:
+ case ItemKindType::BOLT:
+ case ItemKindType::ARROW:
+ case ItemKindType::SHOT:
+ return true;
+ case ItemKindType::SWORD:
+ return this->subtype_value != SV_POISON_NEEDLE;
+ default:
+ return false;
+ }
+}
+
+bool BaseitemKey::is_orthodox_melee_weapon() const
+{
+ switch (this->type_value) {
+ case ItemKindType::HAFTED:
+ case ItemKindType::POLEARM:
+ case ItemKindType::DIGGING:
+ return true;
+ case ItemKindType::SWORD:
+ return this->subtype_value != SV_POISON_NEEDLE;
+ default:
+ return false;
+ }
+}
+
+bool BaseitemKey::is_broken_weapon() const
+{
+ if (this->type_value != ItemKindType::SWORD) {
+ return false;
+ }
+
+ if (!this->subtype_value) {
+ return false;
+ }
+
+ switch (*this->subtype_value) {
+ case SV_BROKEN_DAGGER:
+ case SV_BROKEN_SWORD:
+ return true;
+ default:
+ return false;
+ }
+}
+
+bool BaseitemKey::is_throwable() const
+{
+ switch (this->type_value) {
+ case ItemKindType::DIGGING:
+ case ItemKindType::HAFTED:
+ case ItemKindType::POLEARM:
+ case ItemKindType::SWORD:
+ return true;
+ default:
+ return false;
+ }
+}
+
+bool BaseitemKey::is_wieldable_in_etheir_hand() const
+{
+ switch (this->type_value) {
+ case ItemKindType::DIGGING:
+ case ItemKindType::HAFTED:
+ case ItemKindType::POLEARM:
+ case ItemKindType::SWORD:
+ case ItemKindType::SHIELD:
+ case ItemKindType::CAPTURE:
+ case ItemKindType::CARD:
+ return true;
+ default:
+ return false;
+ }
+}
+
+bool BaseitemKey::is_rare() const
+{
+ static const std::unordered_map> rare_table = {
+ { ItemKindType::HAFTED, { SV_MACE_OF_DISRUPTION, SV_WIZSTAFF } },
+ { ItemKindType::POLEARM, { SV_SCYTHE_OF_SLICING, SV_DEATH_SCYTHE } },
+ { ItemKindType::SWORD, { SV_BLADE_OF_CHAOS, SV_DIAMOND_EDGE, SV_POISON_NEEDLE, SV_HAYABUSA } },
+ { ItemKindType::SHIELD, { SV_DRAGON_SHIELD, SV_MIRROR_SHIELD } },
+ { ItemKindType::HELM, { SV_DRAGON_HELM } },
+ { ItemKindType::BOOTS, { SV_PAIR_OF_DRAGON_GREAVE } },
+ { ItemKindType::CLOAK, { SV_ELVEN_CLOAK, SV_ETHEREAL_CLOAK, SV_SHADOW_CLOAK, SV_MAGIC_RESISTANCE_CLOAK } },
+ { ItemKindType::GLOVES, { SV_SET_OF_DRAGON_GLOVES } },
+ { ItemKindType::SOFT_ARMOR, { SV_KUROSHOUZOKU, SV_ABUNAI_MIZUGI } },
+ { ItemKindType::HARD_ARMOR, { SV_MITHRIL_CHAIN_MAIL, SV_MITHRIL_PLATE_MAIL, SV_ADAMANTITE_PLATE_MAIL } },
+ { ItemKindType::DRAG_ARMOR, { /* Any */ } },
+ };
+
+ if (!this->subtype_value) {
+ return false;
+ }
+
+ if (auto it = rare_table.find(this->type_value); it != rare_table.end()) {
+ const auto &svals = it->second;
+ return svals.empty() || (svals.find(*this->subtype_value) != svals.end());
+ }
+
+ return false;
+}
+
+short BaseitemKey::get_bow_energy() const
+{
+ if ((this->type_value != ItemKindType::BOW) || !this->subtype_value) {
+ THROW_EXCEPTION(std::logic_error, ITEM_NOT_BOW);
+ }
+
+ switch (*this->subtype_value) {
+ case SV_SLING:
+ return 8000;
+ case SV_NAMAKE_BOW:
+ return 7777;
+ case SV_LIGHT_XBOW:
+ return 12000;
+ case SV_HEAVY_XBOW:
+ return 13333;
+ default:
+ return 10000;
+ }
+}
+
+int BaseitemKey::get_arrow_magnification() const
+{
+ if ((this->type_value != ItemKindType::BOW) || !this->subtype_value) {
+ THROW_EXCEPTION(std::logic_error, ITEM_NOT_BOW);
+ }
+
+ switch (*this->subtype_value) {
+ case SV_SLING:
+ case SV_SHORT_BOW:
+ return 2;
+ case SV_LONG_BOW:
+ case SV_NAMAKE_BOW:
+ case SV_LIGHT_XBOW:
+ return 3;
+ case SV_HEAVY_XBOW:
+ return 4;
+ default:
+ return 0;
+ }
+}
+
+bool BaseitemKey::is_aiming_rod() const
+{
+ if ((this->type_value != ItemKindType::ROD) || !this->subtype_value) {
+ THROW_EXCEPTION(std::logic_error, ITEM_NOT_ROD);
+ }
+
+ switch (*this->subtype_value) {
+ case SV_ROD_TELEPORT_AWAY:
+ case SV_ROD_DISARMING:
+ case SV_ROD_LITE:
+ case SV_ROD_SLEEP_MONSTER:
+ case SV_ROD_SLOW_MONSTER:
+ case SV_ROD_HYPODYNAMIA:
+ case SV_ROD_POLYMORPH:
+ case SV_ROD_ACID_BOLT:
+ case SV_ROD_ELEC_BOLT:
+ case SV_ROD_FIRE_BOLT:
+ case SV_ROD_COLD_BOLT:
+ case SV_ROD_ACID_BALL:
+ case SV_ROD_ELEC_BALL:
+ case SV_ROD_FIRE_BALL:
+ case SV_ROD_COLD_BALL:
+ case SV_ROD_STONE_TO_MUD:
+ return true;
+ default:
+ return false;
+ }
+}
+
+bool BaseitemKey::is_lite_requiring_fuel() const
+{
+ if ((this->type_value != ItemKindType::LITE) || !this->subtype_value) {
+ THROW_EXCEPTION(std::logic_error, ITEM_NOT_LITE);
+ }
+
+ switch (*this->subtype_value) {
+ case SV_LITE_TORCH:
+ case SV_LITE_LANTERN:
+ return true;
+ default:
+ return false;
+ }
+}
+
+bool BaseitemKey::is_junk() const
+{
+ switch (this->type_value) {
+ case ItemKindType::FLAVOR_SKELETON:
+ case ItemKindType::BOTTLE:
+ case ItemKindType::JUNK:
+ case ItemKindType::STATUE:
+ return true;
+ default:
+ return false;
+ }
+}
+
+bool BaseitemKey::is_armour() const
+{
+ switch (this->type_value) {
+ case ItemKindType::SOFT_ARMOR:
+ case ItemKindType::HARD_ARMOR:
+ case ItemKindType::DRAG_ARMOR:
+ return true;
+ default:
+ return false;
+ }
+}
+
+bool BaseitemKey::is_cross_bow() const
+{
+ if ((this->type_value != ItemKindType::BOW) || !this->subtype_value) {
+ return false;
+ }
+
+ switch (*this->subtype_value) {
+ case SV_LIGHT_XBOW:
+ case SV_HEAVY_XBOW:
+ return true;
+ default:
+ return false;
+ }
+}
+
+bool BaseitemKey::should_refuse_enchant() const
+{
+ return *this == BaseitemKey(ItemKindType::SWORD, SV_POISON_NEEDLE);
+}
+
+bool BaseitemKey::is_convertible() const
+{
+ auto is_convertible = this->is(ItemKindType::JUNK) || this->is(ItemKindType::FLAVOR_SKELETON);
+ is_convertible |= *this == BaseitemKey(ItemKindType::MONSTER_REMAINS, SV_SKELETON);
+ return is_convertible;
+}
+
+bool BaseitemKey::is_fuel() const
+{
+ auto is_fuel = *this == BaseitemKey(ItemKindType::LITE, SV_LITE_TORCH);
+ is_fuel |= *this == BaseitemKey(ItemKindType::LITE, SV_LITE_LANTERN);
+ is_fuel |= *this == BaseitemKey(ItemKindType::FLASK, SV_FLASK_OIL);
+ return is_fuel;
+}
+
+bool BaseitemKey::is_lance() const
+{
+ auto is_lance = *this == BaseitemKey(ItemKindType::POLEARM, SV_LANCE);
+ is_lance |= *this == BaseitemKey(ItemKindType::POLEARM, SV_HEAVY_LANCE);
+ return is_lance;
+}
+
+bool BaseitemKey::is_readable() const
+{
+ auto can_read = this->is(ItemKindType::SCROLL);
+ can_read |= this->is(ItemKindType::PARCHMENT);
+ return can_read;
+}
+
+bool BaseitemKey::is_corpse() const
+{
+ return *this == BaseitemKey(ItemKindType::MONSTER_REMAINS, SV_CORPSE);
+}
+
+bool BaseitemKey::is_monster() const
+{
+ switch (this->type_value) {
+ case ItemKindType::FIGURINE:
+ case ItemKindType::STATUE:
+ case ItemKindType::MONSTER_REMAINS:
+ case ItemKindType::CAPTURE:
+ return true;
+ default:
+ return false;
+ }
+}
+
+/*!
+ * @brief 2つのアイテムが同時に「普通の」像であることを示す
+ * @param チェック対象のベースアイテムキー
+ * @return 両方が写真の時だけfalse、少なくとも片方が「普通の」像ならばtrue、像ですらないならば例外
+ */
+bool BaseitemKey::are_both_statue(const BaseitemKey &other) const
+{
+ if ((this->type_value != ItemKindType::STATUE)) {
+ THROW_EXCEPTION(std::logic_error, "This item is not a statue!");
+ }
+
+ if (other.type_value != ItemKindType::STATUE) {
+ THROW_EXCEPTION(std::logic_error, "The other item is not a statue!");
+ }
+
+ return (this->subtype_value != SV_PHOTO) || (other.subtype_value != SV_PHOTO);
+}
+
+bool BaseitemKey::is_mushrooms() const
+{
+ if (!this->subtype_value) {
+ return false;
+ }
+
+ switch (*this->subtype_value) {
+ case SV_FOOD_POISON:
+ case SV_FOOD_BLINDNESS:
+ case SV_FOOD_PARANOIA:
+ case SV_FOOD_CONFUSION:
+ case SV_FOOD_HALLUCINATION:
+ case SV_FOOD_PARALYSIS:
+ case SV_FOOD_WEAKNESS:
+ case SV_FOOD_SICKNESS:
+ case SV_FOOD_STUPIDITY:
+ case SV_FOOD_NAIVETY:
+ case SV_FOOD_UNHEALTH:
+ case SV_FOOD_DISEASE:
+ case SV_FOOD_CURE_POISON:
+ case SV_FOOD_CURE_BLINDNESS:
+ case SV_FOOD_CURE_PARANOIA:
+ case SV_FOOD_CURE_CONFUSION:
+ case SV_FOOD_CURE_SERIOUS:
+ case SV_FOOD_RESTORE_STR:
+ case SV_FOOD_RESTORE_CON:
+ case SV_FOOD_RESTORING:
+ return true;
+ default:
+ return false;
+ }
+}
diff --git a/src/system/baseitem/baseitem-key.h b/src/system/baseitem/baseitem-key.h
new file mode 100644
index 0000000000..b42a7185fa
--- /dev/null
+++ b/src/system/baseitem/baseitem-key.h
@@ -0,0 +1,94 @@
+/*!
+ * @brief ベースアイテムキー (IDと1対1対応するアイテム種別)定義
+ * @author Hourier
+ * @date 2024/11/16
+ */
+
+#pragma once
+
+#include "object/tval-types.h"
+#include
+
+enum class ItemKindType : short;
+class BaseitemKey {
+public:
+ constexpr BaseitemKey()
+ : type_value(ItemKindType::NONE)
+ , subtype_value(std::nullopt)
+ {
+ }
+
+ constexpr BaseitemKey(const ItemKindType type_value, const std::optional &subtype_value = std::nullopt)
+ : type_value(type_value)
+ , subtype_value(subtype_value)
+ {
+ }
+
+ bool operator==(const BaseitemKey &other) const;
+ bool operator!=(const BaseitemKey &other) const
+ {
+ return !(*this == other);
+ }
+
+ bool operator<(const BaseitemKey &other) const;
+ bool operator>(const BaseitemKey &other) const
+ {
+ return other < *this;
+ }
+
+ bool operator<=(const BaseitemKey &other) const
+ {
+ return !(*this > other);
+ }
+
+ bool operator>=(const BaseitemKey &other) const
+ {
+ return !(*this < other);
+ }
+
+ ItemKindType tval() const;
+ std::optional sval() const;
+ bool is_valid() const;
+ bool is(ItemKindType tval) const;
+ ItemKindType get_arrow_kind() const;
+ bool is_spell_book() const;
+ bool is_high_level_book() const;
+ bool is_melee_weapon() const;
+ bool is_ammo() const;
+ bool has_unidentified_name() const;
+ bool can_recharge() const;
+ bool is_wand_rod() const;
+ bool is_wand_staff() const;
+ bool is_protector() const;
+ bool can_be_aura_protector() const;
+ bool is_wearable() const;
+ bool is_weapon() const;
+ bool is_equipement() const;
+ bool is_melee_ammo() const;
+ bool is_orthodox_melee_weapon() const;
+ bool is_broken_weapon() const;
+ bool is_throwable() const;
+ bool is_wieldable_in_etheir_hand() const;
+ bool is_rare() const;
+ short get_bow_energy() const;
+ int get_arrow_magnification() const;
+ bool is_aiming_rod() const;
+ bool is_lite_requiring_fuel() const;
+ bool is_junk() const;
+ bool is_armour() const;
+ bool is_cross_bow() const;
+ bool should_refuse_enchant() const;
+ bool is_convertible() const;
+ bool is_fuel() const;
+ bool is_lance() const;
+ bool is_readable() const;
+ bool is_corpse() const;
+ bool is_monster() const;
+ bool are_both_statue(const BaseitemKey &other) const;
+
+private:
+ ItemKindType type_value;
+ std::optional subtype_value;
+
+ bool is_mushrooms() const;
+};
diff --git a/src/system/floor-type-definition.cpp b/src/system/floor-type-definition.cpp
index 4dc1fe3aee..6c9fa06884 100644
--- a/src/system/floor-type-definition.cpp
+++ b/src/system/floor-type-definition.cpp
@@ -5,6 +5,7 @@
#include "monster/monster-timed-effects.h"
#include "system/angband-system.h"
#include "system/artifact-type-definition.h"
+#include "system/baseitem/baseitem-definition.h"
#include "system/dungeon-info.h"
#include "system/enums/grid-count-kind.h"
#include "system/gamevalue.h"
diff --git a/src/system/item-entity.h b/src/system/item-entity.h
index b646862057..d38dfe560d 100644
--- a/src/system/item-entity.h
+++ b/src/system/item-entity.h
@@ -12,7 +12,7 @@
#include "object-enchant/trc-types.h"
#include "object/object-mark-types.h"
#include "system/angband.h"
-#include "system/baseitem/baseitem-definition.h"
+#include "system/baseitem/baseitem-key.h"
#include "system/system-variables.h"
#include "util/dice.h"
#include "util/flag-group.h"
diff --git a/src/view/display-player-stat-info.cpp b/src/view/display-player-stat-info.cpp
index 9304e51b93..260454a8b8 100644
--- a/src/view/display-player-stat-info.cpp
+++ b/src/view/display-player-stat-info.cpp
@@ -23,6 +23,7 @@
#include "term/term-color-types.h"
#include "term/z-form.h"
#include "util/bit-flags-calculator.h"
+#include "view/display-symbol.h"
/*!
* @brief プレイヤーのパラメータ基礎値 (腕力等)を18以下になるようにして返す
diff --git a/src/view/display-store.cpp b/src/view/display-store.cpp
index 96fce62ad2..8747c64ced 100644
--- a/src/view/display-store.cpp
+++ b/src/view/display-store.cpp
@@ -11,7 +11,7 @@
#include "store/store-owners.h"
#include "store/store-util.h"
#include "store/store.h" //!< @todo 相互依存している、こっちは残す?.
-#include "system/baseitem/baseitem-definition.h"
+#include "system/baseitem/baseitem-key.h"
#include "system/item-entity.h"
#include "system/player-type-definition.h"
#include "system/terrain-type-definition.h"
diff --git a/src/wizard/wizard-item-modifier.cpp b/src/wizard/wizard-item-modifier.cpp
index 4c6dd0f88e..827a730c94 100644
--- a/src/wizard/wizard-item-modifier.cpp
+++ b/src/wizard/wizard-item-modifier.cpp
@@ -27,6 +27,7 @@
#include "spell/spells-object.h"
#include "system/alloc-entries.h"
#include "system/artifact-type-definition.h"
+#include "system/baseitem/baseitem-definition.h"
#include "system/floor-type-definition.h"
#include "system/item-entity.h"
#include "system/player-type-definition.h"
From da6d1dace260e88ed47b05579aff029465552c9e Mon Sep 17 00:00:00 2001
From: Hourier <66951241+Hourier@users.noreply.github.com>
Date: Sat, 16 Nov 2024 16:46:17 +0900
Subject: [PATCH 03/11] =?UTF-8?q?[Refactor]=20#4622=20baseitem-definition.?=
=?UTF-8?q?cpp/h=20=E3=81=8B=E3=82=89baseitem-list.cpp/h=20=E3=82=92?=
=?UTF-8?q?=E5=88=86=E9=9B=A2=E3=81=97=E3=81=9F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
VisualStudio/Hengband/Hengband.vcxproj | 2 +
.../Hengband/Hengband.vcxproj.filters | 6 +
src/Makefile.am | 1 +
src/birth/game-play-initializer.cpp | 1 +
src/birth/inventory-initializer.cpp | 1 +
src/cmd-item/cmd-magiceat.cpp | 1 +
src/cmd-visual/cmd-visuals.cpp | 1 +
src/core/visuals-reseter.cpp | 1 +
src/flavor/tval-description-switcher.cpp | 1 +
src/floor/fixed-map-generator.cpp | 1 +
src/info-reader/baseitem-reader.cpp | 1 +
src/info-reader/general-parser.cpp | 1 +
src/io-dump/special-class-dump.cpp | 2 +
src/io/interpret-pref-file.cpp | 1 +
src/item-info/flavor-initializer.cpp | 1 +
src/knowledge/knowledge-experiences.cpp | 1 +
src/knowledge/knowledge-items.cpp | 1 +
src/load/item/item-loader-base.cpp | 1 +
src/load/old/load-v1-5-0.cpp | 1 +
src/main/game-data-initializer.cpp | 1 +
src/main/info-initializer.cpp | 1 +
src/market/building-craft-fix.cpp | 1 +
src/market/building-initializer.cpp | 1 +
src/monster-floor/monster-death.cpp | 1 +
.../protector/apply-magic-soft-armor.cpp | 1 +
src/object-use/quaff/quaff-execution.cpp | 2 +-
src/object/object-broken.cpp | 1 +
src/object/object-kind-hook.cpp | 1 +
src/player-info/magic-eater-data-type.cpp | 1 +
src/save/item-writer.cpp | 1 +
src/save/save.cpp | 1 +
src/spell/spells-status.cpp | 1 +
src/store/rumor.cpp | 1 +
src/system/alloc-entries.cpp | 1 +
src/system/artifact-type-definition.cpp | 1 +
src/system/baseitem/baseitem-definition.cpp | 430 -----------------
src/system/baseitem/baseitem-definition.h | 79 +---
src/system/baseitem/baseitem-list.cpp | 437 ++++++++++++++++++
src/system/baseitem/baseitem-list.h | 84 ++++
src/system/floor-type-definition.cpp | 1 +
src/system/item-entity.cpp | 1 +
src/view/display-map.cpp | 1 +
src/window/main-window-equipments.cpp | 2 +-
src/wizard/items-spoiler.cpp | 1 +
src/wizard/wizard-item-modifier.cpp | 1 +
src/wizard/wizard-special-process.cpp | 1 +
46 files changed, 571 insertions(+), 510 deletions(-)
create mode 100644 src/system/baseitem/baseitem-list.cpp
create mode 100644 src/system/baseitem/baseitem-list.h
diff --git a/VisualStudio/Hengband/Hengband.vcxproj b/VisualStudio/Hengband/Hengband.vcxproj
index f0f6798197..58d618c114 100644
--- a/VisualStudio/Hengband/Hengband.vcxproj
+++ b/VisualStudio/Hengband/Hengband.vcxproj
@@ -326,6 +326,7 @@
+
@@ -1431,6 +1432,7 @@
+
diff --git a/VisualStudio/Hengband/Hengband.vcxproj.filters b/VisualStudio/Hengband/Hengband.vcxproj.filters
index 6388082754..75bacac43b 100644
--- a/VisualStudio/Hengband/Hengband.vcxproj.filters
+++ b/VisualStudio/Hengband/Hengband.vcxproj.filters
@@ -2532,6 +2532,9 @@
system\baseitem
+
+ system\baseitem
+
@@ -5484,6 +5487,9 @@
system\baseitem
+
+ system\baseitem
+
diff --git a/src/Makefile.am b/src/Makefile.am
index 87a5f7a525..e7e4003618 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -942,6 +942,7 @@ hengband_SOURCES = \
\
system/baseitem/baseitem-definition.cpp system/baseitem/baseitem-definition.h \
system/baseitem/baseitem-key.cpp system/baseitem/baseitem-key.h \
+ system/baseitem/baseitem-list.cpp system/baseitem/baseitem-list.h \
\
system/enums/game-option-page.h \
system/enums/grid-flow.h \
diff --git a/src/birth/game-play-initializer.cpp b/src/birth/game-play-initializer.cpp
index 8acec52135..0f85c3c253 100644
--- a/src/birth/game-play-initializer.cpp
+++ b/src/birth/game-play-initializer.cpp
@@ -16,6 +16,7 @@
#include "player/player-spell-status.h"
#include "system/artifact-type-definition.h"
#include "system/baseitem/baseitem-definition.h"
+#include "system/baseitem/baseitem-list.h"
#include "system/building-type-definition.h"
#include "system/dungeon-info.h"
#include "system/floor-type-definition.h"
diff --git a/src/birth/inventory-initializer.cpp b/src/birth/inventory-initializer.cpp
index c8a8004ab7..d28b9bece5 100644
--- a/src/birth/inventory-initializer.cpp
+++ b/src/birth/inventory-initializer.cpp
@@ -30,6 +30,7 @@
#include "sv-definition/sv-wand-types.h"
#include "sv-definition/sv-weapon-types.h"
#include "system/baseitem/baseitem-definition.h"
+#include "system/baseitem/baseitem-list.h"
#include "system/item-entity.h"
#include "system/player-type-definition.h"
#include "util/enum-converter.h"
diff --git a/src/cmd-item/cmd-magiceat.cpp b/src/cmd-item/cmd-magiceat.cpp
index 2d46ddec72..c9bc04dea3 100644
--- a/src/cmd-item/cmd-magiceat.cpp
+++ b/src/cmd-item/cmd-magiceat.cpp
@@ -72,6 +72,7 @@
#include "player/player-status-table.h"
#include "spell/spell-info.h"
#include "system/baseitem/baseitem-definition.h"
+#include "system/baseitem/baseitem-list.h"
#include "system/player-type-definition.h"
#include "target/target-getter.h"
#include "term/screen-processor.h"
diff --git a/src/cmd-visual/cmd-visuals.cpp b/src/cmd-visual/cmd-visuals.cpp
index c1f14214fc..4cad915d16 100644
--- a/src/cmd-visual/cmd-visuals.cpp
+++ b/src/cmd-visual/cmd-visuals.cpp
@@ -15,6 +15,7 @@
#include "knowledge/lighting-level-table.h"
#include "main/sound-of-music.h"
#include "system/baseitem/baseitem-definition.h"
+#include "system/baseitem/baseitem-list.h"
#include "system/item-entity.h"
#include "system/monster-race-info.h"
#include "system/player-type-definition.h"
diff --git a/src/core/visuals-reseter.cpp b/src/core/visuals-reseter.cpp
index 2bb5ff0ac1..c7edab9722 100644
--- a/src/core/visuals-reseter.cpp
+++ b/src/core/visuals-reseter.cpp
@@ -2,6 +2,7 @@
#include "game-option/special-options.h"
#include "io/read-pref-file.h"
#include "system/baseitem/baseitem-definition.h"
+#include "system/baseitem/baseitem-list.h"
#include "system/monster-race-info.h"
#include "system/player-type-definition.h"
#include "system/terrain-type-definition.h"
diff --git a/src/flavor/tval-description-switcher.cpp b/src/flavor/tval-description-switcher.cpp
index 7d2a5bca9b..31479cc0d5 100644
--- a/src/flavor/tval-description-switcher.cpp
+++ b/src/flavor/tval-description-switcher.cpp
@@ -11,6 +11,7 @@
#include "object-enchant/trg-types.h"
#include "object/tval-types.h"
#include "system/baseitem/baseitem-definition.h"
+#include "system/baseitem/baseitem-list.h"
#include "system/item-entity.h"
#include "system/monster-race-info.h"
#include "util/bit-flags-calculator.h"
diff --git a/src/floor/fixed-map-generator.cpp b/src/floor/fixed-map-generator.cpp
index 5fda65a4b6..0c3babf840 100644
--- a/src/floor/fixed-map-generator.cpp
+++ b/src/floor/fixed-map-generator.cpp
@@ -26,6 +26,7 @@
#include "sv-definition/sv-scroll-types.h"
#include "system/artifact-type-definition.h"
#include "system/baseitem/baseitem-definition.h"
+#include "system/baseitem/baseitem-list.h"
#include "system/dungeon-info.h"
#include "system/floor-type-definition.h"
#include "system/grid-type-definition.h"
diff --git a/src/info-reader/baseitem-reader.cpp b/src/info-reader/baseitem-reader.cpp
index f87dec1b5c..6aefadee38 100644
--- a/src/info-reader/baseitem-reader.cpp
+++ b/src/info-reader/baseitem-reader.cpp
@@ -15,6 +15,7 @@
#include "object-enchant/tr-types.h"
#include "object/tval-types.h"
#include "system/baseitem/baseitem-definition.h"
+#include "system/baseitem/baseitem-list.h"
#include "term/gameterm.h"
#include "util/bit-flags-calculator.h"
#include "util/enum-converter.h"
diff --git a/src/info-reader/general-parser.cpp b/src/info-reader/general-parser.cpp
index 60cba58d6f..c172bfbc7b 100644
--- a/src/info-reader/general-parser.cpp
+++ b/src/info-reader/general-parser.cpp
@@ -13,6 +13,7 @@
#include "realm/realm-types.h"
#include "system/artifact-type-definition.h"
#include "system/baseitem/baseitem-definition.h"
+#include "system/baseitem/baseitem-list.h"
#include "system/building-type-definition.h"
#include "system/floor-type-definition.h"
#include "system/system-variables.h"
diff --git a/src/io-dump/special-class-dump.cpp b/src/io-dump/special-class-dump.cpp
index 39acee98bc..5af1cca9c7 100644
--- a/src/io-dump/special-class-dump.cpp
+++ b/src/io-dump/special-class-dump.cpp
@@ -10,11 +10,13 @@
#include "mind/mind-blue-mage.h"
#include "monster-race/race-ability-flags.h"
#include "mspell/monster-power-table.h"
+#include "object/tval-types.h"
#include "player-base/player-class.h"
#include "player-info/bluemage-data-type.h"
#include "player-info/magic-eater-data-type.h"
#include "smith/object-smith.h"
#include "system/baseitem/baseitem-definition.h"
+#include "system/baseitem/baseitem-list.h"
#include "system/player-type-definition.h"
#include "util/enum-converter.h"
#include "util/flag-group.h"
diff --git a/src/io/interpret-pref-file.cpp b/src/io/interpret-pref-file.cpp
index 3ba4b8a92e..946ad8066c 100644
--- a/src/io/interpret-pref-file.cpp
+++ b/src/io/interpret-pref-file.cpp
@@ -14,6 +14,7 @@
#include "io/input-key-requester.h"
#include "io/tokenizer.h"
#include "system/baseitem/baseitem-definition.h"
+#include "system/baseitem/baseitem-list.h"
#include "system/enums/game-option-page.h"
#include "system/monster-race-info.h"
#include "system/player-type-definition.h"
diff --git a/src/item-info/flavor-initializer.cpp b/src/item-info/flavor-initializer.cpp
index a7161bdb18..fa883edb72 100644
--- a/src/item-info/flavor-initializer.cpp
+++ b/src/item-info/flavor-initializer.cpp
@@ -8,6 +8,7 @@
#include "object/tval-types.h"
#include "system/angband-system.h"
#include "system/baseitem/baseitem-definition.h"
+#include "system/baseitem/baseitem-list.h"
/*!
* @brief ゲーム開始時に行われるベースアイテムの初期化ルーチン
diff --git a/src/knowledge/knowledge-experiences.cpp b/src/knowledge/knowledge-experiences.cpp
index 2c29223703..78b74b0ebc 100644
--- a/src/knowledge/knowledge-experiences.cpp
+++ b/src/knowledge/knowledge-experiences.cpp
@@ -17,6 +17,7 @@
#include "spell/technic-info-table.h"
#include "sv-definition/sv-bow-types.h"
#include "system/baseitem/baseitem-definition.h"
+#include "system/baseitem/baseitem-list.h"
#include "system/player-type-definition.h"
#include "util/angband-files.h"
diff --git a/src/knowledge/knowledge-items.cpp b/src/knowledge/knowledge-items.cpp
index 3b16161aff..28e73cff84 100644
--- a/src/knowledge/knowledge-items.cpp
+++ b/src/knowledge/knowledge-items.cpp
@@ -20,6 +20,7 @@
#include "perception/object-perception.h"
#include "system/artifact-type-definition.h"
#include "system/baseitem/baseitem-definition.h"
+#include "system/baseitem/baseitem-list.h"
#include "system/floor-type-definition.h"
#include "system/grid-type-definition.h"
#include "system/item-entity.h"
diff --git a/src/load/item/item-loader-base.cpp b/src/load/item/item-loader-base.cpp
index db1d772d93..c6f45758d9 100644
--- a/src/load/item/item-loader-base.cpp
+++ b/src/load/item/item-loader-base.cpp
@@ -4,6 +4,7 @@
#include "load/load-util.h"
#include "system/artifact-type-definition.h"
#include "system/baseitem/baseitem-definition.h"
+#include "system/baseitem/baseitem-list.h"
#include "util/bit-flags-calculator.h"
#include "util/enum-converter.h"
diff --git a/src/load/old/load-v1-5-0.cpp b/src/load/old/load-v1-5-0.cpp
index 0268d83eec..aa90ee900f 100644
--- a/src/load/old/load-v1-5-0.cpp
+++ b/src/load/old/load-v1-5-0.cpp
@@ -36,6 +36,7 @@
#include "system/angband-exceptions.h"
#include "system/artifact-type-definition.h"
#include "system/baseitem/baseitem-definition.h"
+#include "system/baseitem/baseitem-list.h"
#include "system/dungeon-info.h"
#include "system/enums/monrace/monrace-id.h"
#include "system/floor-type-definition.h"
diff --git a/src/main/game-data-initializer.cpp b/src/main/game-data-initializer.cpp
index 0aaf5119cb..77506b5ccc 100644
--- a/src/main/game-data-initializer.cpp
+++ b/src/main/game-data-initializer.cpp
@@ -13,6 +13,7 @@
#include "game-option/option-types-table.h"
#include "system/alloc-entries.h"
#include "system/baseitem/baseitem-definition.h"
+#include "system/baseitem/baseitem-list.h"
#include "system/dungeon-info.h"
#include "system/floor-type-definition.h"
#include "system/grid-type-definition.h"
diff --git a/src/main/info-initializer.cpp b/src/main/info-initializer.cpp
index 135b13aab2..ad95cbaed2 100644
--- a/src/main/info-initializer.cpp
+++ b/src/main/info-initializer.cpp
@@ -29,6 +29,7 @@
#include "system/angband-version.h"
#include "system/artifact-type-definition.h"
#include "system/baseitem/baseitem-definition.h"
+#include "system/baseitem/baseitem-list.h"
#include "system/dungeon-info.h"
#include "system/monster-race-info.h"
#include "system/player-type-definition.h"
diff --git a/src/market/building-craft-fix.cpp b/src/market/building-craft-fix.cpp
index 1e2b88e495..e90953903f 100644
--- a/src/market/building-craft-fix.cpp
+++ b/src/market/building-craft-fix.cpp
@@ -20,6 +20,7 @@
#include "sv-definition/sv-other-types.h"
#include "sv-definition/sv-weapon-types.h"
#include "system/baseitem/baseitem-definition.h"
+#include "system/baseitem/baseitem-list.h"
#include "system/item-entity.h"
#include "system/player-type-definition.h"
#include "system/redrawing-flags-updater.h"
diff --git a/src/market/building-initializer.cpp b/src/market/building-initializer.cpp
index 36b2e2228d..a2c8658621 100644
--- a/src/market/building-initializer.cpp
+++ b/src/market/building-initializer.cpp
@@ -9,6 +9,7 @@
#include "store/store.h"
#include "system/angband.h"
#include "system/baseitem/baseitem-definition.h"
+#include "system/baseitem/baseitem-list.h"
#include "system/building-type-definition.h"
#include "system/item-entity.h"
#include "util/angband-files.h"
diff --git a/src/monster-floor/monster-death.cpp b/src/monster-floor/monster-death.cpp
index 3ce55ca0d1..501ec12983 100644
--- a/src/monster-floor/monster-death.cpp
+++ b/src/monster-floor/monster-death.cpp
@@ -31,6 +31,7 @@
#include "system/angband-system.h"
#include "system/artifact-type-definition.h"
#include "system/baseitem/baseitem-definition.h"
+#include "system/baseitem/baseitem-list.h"
#include "system/building-type-definition.h"
#include "system/dungeon-info.h"
#include "system/enums/monrace/monrace-id.h"
diff --git a/src/object-enchant/protector/apply-magic-soft-armor.cpp b/src/object-enchant/protector/apply-magic-soft-armor.cpp
index ca39da2359..ae0940583b 100644
--- a/src/object-enchant/protector/apply-magic-soft-armor.cpp
+++ b/src/object-enchant/protector/apply-magic-soft-armor.cpp
@@ -8,6 +8,7 @@
#include "object/tval-types.h"
#include "sv-definition/sv-armor-types.h"
#include "system/baseitem/baseitem-definition.h"
+#include "system/baseitem/baseitem-list.h"
#include "system/item-entity.h"
#include "system/player-type-definition.h"
diff --git a/src/object-use/quaff/quaff-execution.cpp b/src/object-use/quaff/quaff-execution.cpp
index 307fb04245..0dfaa1b7d8 100644
--- a/src/object-use/quaff/quaff-execution.cpp
+++ b/src/object-use/quaff/quaff-execution.cpp
@@ -124,7 +124,7 @@ bool ObjectQuaffEntity::can_quaff()
ItemEntity ObjectQuaffEntity::copy_object(const INVENTORY_IDX i_idx)
{
auto *tmp_o_ptr = ref_item(this->player_ptr, i_idx);
- auto o_val = *tmp_o_ptr;
+ ItemEntity o_val = *tmp_o_ptr;
o_val.number = 1;
return o_val;
}
diff --git a/src/object/object-broken.cpp b/src/object/object-broken.cpp
index b2fb45556b..17870f21ce 100644
--- a/src/object/object-broken.cpp
+++ b/src/object/object-broken.cpp
@@ -12,6 +12,7 @@
#include "object/tval-types.h"
#include "sv-definition/sv-potion-types.h"
#include "system/baseitem/baseitem-definition.h"
+#include "system/baseitem/baseitem-list.h"
#include "system/item-entity.h"
#include "system/player-type-definition.h"
#include "util/bit-flags-calculator.h"
diff --git a/src/object/object-kind-hook.cpp b/src/object/object-kind-hook.cpp
index 0186568841..8f9b1b9fa3 100644
--- a/src/object/object-kind-hook.cpp
+++ b/src/object/object-kind-hook.cpp
@@ -10,6 +10,7 @@
#include "sv-definition/sv-other-types.h"
#include "sv-definition/sv-ring-types.h"
#include "system/baseitem/baseitem-definition.h"
+#include "system/baseitem/baseitem-list.h"
#include
#include
#include
diff --git a/src/player-info/magic-eater-data-type.cpp b/src/player-info/magic-eater-data-type.cpp
index 61d338df0d..a943231f6f 100644
--- a/src/player-info/magic-eater-data-type.cpp
+++ b/src/player-info/magic-eater-data-type.cpp
@@ -4,6 +4,7 @@
#include "sv-definition/sv-staff-types.h"
#include "sv-definition/sv-wand-types.h"
#include "system/baseitem/baseitem-definition.h"
+#include "system/baseitem/baseitem-list.h"
MagicEaterDataList::MagicEaterDataList()
: staves(SV_STAFF_MAX)
diff --git a/src/save/item-writer.cpp b/src/save/item-writer.cpp
index a5ca9e62d2..75b0a10656 100644
--- a/src/save/item-writer.cpp
+++ b/src/save/item-writer.cpp
@@ -3,6 +3,7 @@
#include "load/old/item-flag-types-savefile50.h"
#include "save/save-util.h"
#include "system/baseitem/baseitem-definition.h"
+#include "system/baseitem/baseitem-list.h"
#include "system/item-entity.h"
#include "util/bit-flags-calculator.h"
#include "util/enum-converter.h"
diff --git a/src/save/save.cpp b/src/save/save.cpp
index ff8c154d32..9048371b0f 100644
--- a/src/save/save.cpp
+++ b/src/save/save.cpp
@@ -34,6 +34,7 @@
#include "system/angband-system.h"
#include "system/artifact-type-definition.h"
#include "system/baseitem/baseitem-definition.h"
+#include "system/baseitem/baseitem-list.h"
#include "system/floor-type-definition.h"
#include "system/item-entity.h"
#include "system/monster-race-info.h"
diff --git a/src/spell/spells-status.cpp b/src/spell/spells-status.cpp
index a8510cc0fc..81caabf1b9 100644
--- a/src/spell/spells-status.cpp
+++ b/src/spell/spells-status.cpp
@@ -42,6 +42,7 @@
#include "status/shape-changer.h"
#include "status/sight-setter.h"
#include "system/baseitem/baseitem-definition.h"
+#include "system/baseitem/baseitem-list.h"
#include "system/floor-type-definition.h"
#include "system/grid-type-definition.h"
#include "system/item-entity.h"
diff --git a/src/store/rumor.cpp b/src/store/rumor.cpp
index 8f1b20b532..09f383a194 100644
--- a/src/store/rumor.cpp
+++ b/src/store/rumor.cpp
@@ -8,6 +8,7 @@
#include "system/angband-exceptions.h"
#include "system/artifact-type-definition.h"
#include "system/baseitem/baseitem-definition.h"
+#include "system/baseitem/baseitem-list.h"
#include "system/dungeon-info.h"
#include "system/item-entity.h"
#include "system/monster-race-info.h"
diff --git a/src/system/alloc-entries.cpp b/src/system/alloc-entries.cpp
index 32dd11a8d6..d722919f7e 100644
--- a/src/system/alloc-entries.cpp
+++ b/src/system/alloc-entries.cpp
@@ -1,5 +1,6 @@
#include "system/alloc-entries.h"
#include "system/baseitem/baseitem-definition.h"
+#include "system/baseitem/baseitem-list.h"
#include "system/monster-race-info.h"
MonraceAllocationEntry::MonraceAllocationEntry(MonraceId index, int level, short prob1, short prob2)
diff --git a/src/system/artifact-type-definition.cpp b/src/system/artifact-type-definition.cpp
index 8c0642b15d..b35af088ee 100644
--- a/src/system/artifact-type-definition.cpp
+++ b/src/system/artifact-type-definition.cpp
@@ -2,6 +2,7 @@
#include "artifact/fixed-art-types.h"
#include "object/tval-types.h"
#include "system/baseitem/baseitem-definition.h"
+#include "system/baseitem/baseitem-list.h"
#include "system/item-entity.h"
ArtifactType::ArtifactType()
diff --git a/src/system/baseitem/baseitem-definition.cpp b/src/system/baseitem/baseitem-definition.cpp
index ada68dabc9..62ea6fbd6b 100644
--- a/src/system/baseitem/baseitem-definition.cpp
+++ b/src/system/baseitem/baseitem-definition.cpp
@@ -5,41 +5,7 @@
*/
#include "system/baseitem/baseitem-definition.h"
-#include "object/tval-types.h"
-#include "sv-definition/sv-potion-types.h"
-#include "sv-definition/sv-staff-types.h"
-#include "system/angband-exceptions.h"
-#include "system/enums/monrace/monrace-id.h"
-#include "util/enum-converter.h"
#include "util/string-processor.h"
-#include
-#include
-
-namespace {
-constexpr auto INVALID_BI_ID_FORMAT = "Invalid Baseitem ID is specified! %d";
-constexpr auto INVALID_BASEITEM_KEY = "Invalid Baseitem Key is specified! Type: %d, Subtype: %d";
-const std::map GOLD_KINDS = {
- { MoneyKind::COPPER, _("銅塊", "copper") },
- { MoneyKind::SILVER, _("銀塊", "silver") },
- { MoneyKind::GARNET, _("ガーネット", "garnets") },
- { MoneyKind::GOLD, _("金塊", "gold") },
- { MoneyKind::OPAL, _("オパール", "opals") },
- { MoneyKind::SAPPHIRE, _("サファイア", "sapphires") },
- { MoneyKind::RUBY, _("ルビー", "rubies") },
- { MoneyKind::DIAMOND, _("ダイヤモンド", "diamonds") },
- { MoneyKind::EMERALD, _("エメラルド", "emeralds") },
- { MoneyKind::MITHRIL, _("ミスリル", "mithril") },
- { MoneyKind::ADAMANTITE, _("アダマンタイト", "adamantite") },
-};
-const std::map CREEPING_COIN_DROPS = {
- { MonraceId::COPPER_COINS, { ItemKindType::GOLD, 3 } },
- { MonraceId::SILVER_COINS, { ItemKindType::GOLD, 6 } },
- { MonraceId::GOLD_COINS, { ItemKindType::GOLD, 11 } },
- { MonraceId::MITHRIL_COINS, { ItemKindType::GOLD, 17 } },
- { MonraceId::MITHRIL_GOLEM, { ItemKindType::GOLD, 17 } },
- { MonraceId::ADAMANT_COINS, { ItemKindType::GOLD, 18 } },
-};
-}
BaseitemInfo::BaseitemInfo()
: bi_key(ItemKindType::NONE)
@@ -152,399 +118,3 @@ void BaseitemInfo::mark_as_aware()
{
this->aware = true;
}
-
-BaseitemList BaseitemList::instance{};
-
-BaseitemList &BaseitemList::get_instance()
-{
- return instance;
-}
-
-BaseitemInfo &BaseitemList::get_baseitem(const short bi_id)
-{
- if ((bi_id < 0) || (bi_id >= static_cast(this->baseitems.size()))) {
- THROW_EXCEPTION(std::logic_error, format(INVALID_BI_ID_FORMAT, bi_id));
- }
-
- return this->baseitems[bi_id];
-}
-
-const BaseitemInfo &BaseitemList::get_baseitem(const short bi_id) const
-{
- if ((bi_id < 0) || (bi_id >= static_cast(this->baseitems.size()))) {
- THROW_EXCEPTION(std::logic_error, format(INVALID_BI_ID_FORMAT, bi_id));
- }
-
- return this->baseitems[bi_id];
-}
-
-std::vector::iterator BaseitemList::begin()
-{
- return this->baseitems.begin();
-}
-
-std::vector::const_iterator BaseitemList::begin() const
-{
- return this->baseitems.begin();
-}
-
-std::vector::iterator BaseitemList::end()
-{
- return this->baseitems.end();
-}
-
-std::vector::const_iterator BaseitemList::end() const
-{
- return this->baseitems.end();
-}
-
-std::vector::reverse_iterator BaseitemList::rbegin()
-{
- return this->baseitems.rbegin();
-}
-
-std::vector::const_reverse_iterator BaseitemList::rbegin() const
-{
- return this->baseitems.rbegin();
-}
-
-std::vector::reverse_iterator BaseitemList::rend()
-{
- return this->baseitems.rend();
-}
-
-std::vector::const_reverse_iterator BaseitemList::rend() const
-{
- return this->baseitems.rend();
-}
-
-size_t BaseitemList::size() const
-{
- return this->baseitems.size();
-}
-
-bool BaseitemList::empty() const
-{
- return this->baseitems.empty();
-}
-
-void BaseitemList::resize(size_t new_size)
-{
- this->baseitems.resize(new_size);
-}
-
-void BaseitemList::shrink_to_fit()
-{
- this->baseitems.shrink_to_fit();
-}
-
-/*!
- * @brief ベースアイテムキーからIDを引いて返す
- * @param key ベースアイテムキー、但しsvalはランダム(nullopt) の可能性がある
- * @return ベースアイテムID
- * @details ベースアイテムIDが存在しなければ例外
- */
-short BaseitemList::lookup_baseitem_id(const BaseitemKey &bi_key) const
-{
- const auto sval = bi_key.sval();
- if (sval) {
- return exe_lookup(bi_key);
- }
-
- static const auto &cache = create_baseitems_cache();
- const auto itr = cache.find(bi_key.tval());
- if (itr == cache.end()) {
- constexpr auto fmt = "Specified ItemKindType has no subtype! %d";
- THROW_EXCEPTION(std::runtime_error, format(fmt, enum2i(bi_key.tval())));
- }
-
- const auto &svals = itr->second;
- return exe_lookup({ bi_key.tval(), rand_choice(svals) });
-}
-
-const BaseitemInfo &BaseitemList::lookup_baseitem(const BaseitemKey &bi_key) const
-{
- const auto bi_id = this->lookup_baseitem_id(bi_key);
- return this->baseitems[bi_id];
-}
-
-/*!
- * @brief モンスター種族IDから財宝アイテムの価値を引く
- * @param monrace_id モンスター種族ID
- * @return 特定の財宝を落とすならそのアイテムの価値オフセット、一般的な財宝ドロップならばnullopt
- */
-std::optional BaseitemList::lookup_creeping_coin_drop_offset(MonraceId monrace_id) const
-{
- const auto it = CREEPING_COIN_DROPS.find(monrace_id);
- if (it == CREEPING_COIN_DROPS.end()) {
- return std::nullopt;
- }
-
- return this->lookup_gold_offset(it->second);
-}
-
-/*!
- * @brief ベースアイテム定義群から財宝アイテムの数を計算する
- * @return 財宝を示すベースアイテム数
- */
-int BaseitemList::calc_num_gold_subtypes() const
-{
- static const auto &golds = this->create_sorted_golds();
- static const auto sum = std::accumulate(golds.begin(), golds.end(), 0,
- [](int count, const auto &pair) {
- return count + pair.second.size();
- });
- return sum;
-}
-
-/*!
- * @brief 財宝アイテムの価値からベースアイテムを引く
- * @param target_offset 財宝アイテムの価値
- * @return ベースアイテムID
- * @details 同一の財宝カテゴリ内ならば常に大きいほど価値が高い.
- * カテゴリが異なるならば価値の大小は保証しない. 即ち「最も高い銅貨>最も安い銀貨」はあり得る.
- */
-const BaseitemInfo &BaseitemList::lookup_gold(int target_offset) const
-{
- auto offset = 0;
- for (const auto &pair : this->create_sorted_golds()) {
- for (const auto &bi_key : pair.second) {
- if (offset == target_offset) {
- return this->get_baseitem(this->exe_lookup(bi_key));
- }
-
- offset++;
- }
- }
-
- THROW_EXCEPTION(std::runtime_error, format("Invalid gold offset is specified! %d", target_offset));
-}
-
-/*!
- * @brief ベースアイテムIDから財宝アイテムの価値を引く
- * @param bi_id ベースアイテムID
- * @return 財宝アイテムの価値オフセット
- * @details 同一の財宝カテゴリ内ならば常に大きいほど価値が高い.
- * カテゴリが異なるならば価値の大小は保証しない. 即ち「最も高い銅貨>最も安い銀貨」はあり得る.
- */
-int BaseitemList::lookup_gold_offset(short bi_id) const
-{
- auto offset = 0;
- for (const auto &pair : this->create_sorted_golds()) {
- for (const auto &bi_key : pair.second) {
- if (bi_id == this->exe_lookup(bi_key)) {
- return offset;
- }
-
- offset++;
- }
- }
-
- THROW_EXCEPTION(std::runtime_error, format(INVALID_BI_ID_FORMAT, bi_id));
-}
-
-void BaseitemList::reset_all_visuals()
-{
- for (auto &baseitem : this->baseitems) {
- baseitem.symbol_config = baseitem.symbol_definition;
- }
-}
-
-/*!
- * @brief ベースアイテムの鑑定済みフラグをリセットする
- * @details 不具合対策で0からリセットする(セーブは0から)
- */
-void BaseitemList::reset_identification_flags()
-{
- for (auto &baseitem : this->baseitems) {
- baseitem.tried = false;
- baseitem.aware = false;
- }
-}
-
-/*!
- * @brief 未鑑定アイテム種別の内、ゲーム開始時から鑑定済とするアイテムの鑑定済フラグをONにする
- * @todo 食料用の杖は該当種族 (ゴーレム/骸骨/ゾンビ/幽霊)では鑑定済だが、本来はこのメソッドで鑑定済にすべき.
- */
-void BaseitemList::mark_common_items_as_aware()
-{
- std::vector bi_keys;
- bi_keys.emplace_back(ItemKindType::POTION, SV_POTION_WATER);
- bi_keys.emplace_back(ItemKindType::STAFF, SV_STAFF_NOTHING);
- for (const auto &bi_key : bi_keys) {
- this->lookup_baseitem(bi_key).mark_as_aware();
- }
-}
-
-void BaseitemList::shuffle_flavors()
-{
- this->shuffle_flavors(ItemKindType::RING);
- this->shuffle_flavors(ItemKindType::AMULET);
- this->shuffle_flavors(ItemKindType::STAFF);
- this->shuffle_flavors(ItemKindType::WAND);
- this->shuffle_flavors(ItemKindType::ROD);
- this->shuffle_flavors(ItemKindType::FOOD);
- this->shuffle_flavors(ItemKindType::POTION);
- this->shuffle_flavors(ItemKindType::SCROLL);
-}
-
-/*!
- * @brief ベースアイテムキーに対応するベースアイテムのIDを検索する
- * @param key 検索したいベースアイテムキー
- * @return ベースアイテムID
- * @details ベースアイテムIDが存在しなければ例外
- */
-short BaseitemList::exe_lookup(const BaseitemKey &bi_key) const
-{
- static const auto &cache = create_baseitem_index_chache();
- const auto itr = cache.find(bi_key);
- if (itr == cache.end()) {
- THROW_EXCEPTION(std::runtime_error, format(INVALID_BASEITEM_KEY, enum2i(bi_key.tval()), *bi_key.sval()));
- }
-
- return itr->second;
-}
-
-/*
- * @brief tvalとbi_key.svalに対応する、BaseitenDefinitions のIDを返すためのキャッシュを生成する
- * @return tvalと(実在する)svalの組み合わせをキーに、ベースアイテムIDを値とした辞書
- */
-const std::map &BaseitemList::create_baseitem_index_chache() const
-{
- static std::map cache;
- for (const auto &baseitem : BaseitemList::get_instance()) {
- if (!baseitem.is_valid()) {
- continue;
- }
-
- const auto &bi_key = baseitem.bi_key;
- cache[bi_key] = baseitem.idx;
- }
-
- return cache;
-}
-
-/*
- * @brief 特定のtvalとランダムなsvalの組み合わせからベースアイテムを選択するためのキャッシュを生成する
- * @return tvalをキーに、svalのリストを値とした辞書
- */
-const std::map> &BaseitemList::create_baseitems_cache() const
-{
- static std::map> cache;
- for (const auto &baseitem : BaseitemList::get_instance()) {
- if (!baseitem.is_valid()) {
- continue;
- }
-
- const auto &bi_key = baseitem.bi_key;
- const auto tval = bi_key.tval();
- cache[tval].push_back(*bi_key.sval());
- }
-
- return cache;
-}
-
-/*!
- * @brief ベースアイテムキーから財宝アイテムの価値を引く
- * @param finding_bi_key 探索対象のベースアイテムキー
- * @return 財宝アイテムの価値番号 (大きいほど価値が高い)
- * @details 同一の財宝カテゴリ内ならば常に番号が大きいほど価値も高い.
- * カテゴリが異なるならば価値の大小は保証しない. 即ち「最も高い銅貨>最も安い銀貨」はあり得る.
- */
-int BaseitemList::lookup_gold_offset(const BaseitemKey &finding_bi_key) const
-{
- auto offset = 0;
- for (const auto &pair : this->create_sorted_golds()) {
- for (const auto &bi_key : pair.second) {
- if (finding_bi_key == bi_key) {
- return offset;
- }
-
- offset++;
- }
- }
-
- THROW_EXCEPTION(std::runtime_error, format(INVALID_BASEITEM_KEY, enum2i(finding_bi_key.tval()), *finding_bi_key.sval()));
-}
-
-/*!
- * @brief ベースアイテム定義リストから財宝の辞書を作る (価値順)
- * @return 財宝種別をキー、それに対応するベースアイテムキーの配列 (安い順にソート済)を値とした辞書
- */
-const std::map> &BaseitemList::create_sorted_golds() const
-{
- static std::map> list;
- if (!list.empty()) {
- return list;
- }
-
- list = this->create_unsorted_golds();
- for (auto &[money_kind, bi_keys] : list) {
- std::stable_sort(bi_keys.begin(), bi_keys.end(),
- [this](const auto &bi_key1, const auto &bi_key2) {
- const auto &baseitem1 = this->lookup_baseitem(bi_key1);
- const auto &baseitem2 = this->lookup_baseitem(bi_key2);
- return baseitem1.order_cost(baseitem2);
- });
- }
-
- return list;
-}
-
-/*!
- * @brief ベースアイテム定義リストから財宝の辞書を作る (ベースアイテムID順)
- * @return 財宝種別をキー、それに対応するベースアイテムキーの配列を値とした辞書
- */
-std::map> BaseitemList::create_unsorted_golds() const
-{
- std::map> list;
- for (const auto &baseitem : this->baseitems) {
- const auto &bi_key = baseitem.bi_key;
- if (bi_key.tval() != ItemKindType::GOLD) {
- continue;
- }
-
- for (const auto money_kind : MONEY_KIND_RANGE) {
- if (baseitem.name != GOLD_KINDS.at(money_kind)) {
- continue;
- }
-
- list[money_kind].push_back(bi_key);
- }
- }
-
- return list;
-}
-
-BaseitemInfo &BaseitemList::lookup_baseitem(const BaseitemKey &bi_key)
-{
- const auto bi_id = this->lookup_baseitem_id(bi_key);
- return this->baseitems[bi_id];
-}
-
-/*!
- * @brief ベースアイテムの未確定名を共通tval間でシャッフルする
- * @param tval シャッフルしたいtval
- * @details 巻物、各種魔道具などに利用される。
- */
-void BaseitemList::shuffle_flavors(ItemKindType tval)
-{
- std::vector> flavors;
- for (auto &baseitem : this->baseitems) {
- if (baseitem.bi_key.tval() != tval) {
- continue;
- }
-
- if (baseitem.flavor == 0) {
- continue;
- }
-
- if (baseitem.flags.has(TR_FIXED_FLAVOR)) {
- continue;
- }
-
- flavors.push_back(baseitem.flavor);
- }
-
- rand_shuffle(flavors.begin(), flavors.end());
-}
diff --git a/src/system/baseitem/baseitem-definition.h b/src/system/baseitem/baseitem-definition.h
index 92e0cb9fea..82f4e2caaf 100644
--- a/src/system/baseitem/baseitem-definition.h
+++ b/src/system/baseitem/baseitem-definition.h
@@ -2,36 +2,15 @@
#include "object-enchant/tr-flags.h"
#include "object-enchant/trg-types.h"
-#include "object/tval-types.h"
#include "system/angband.h"
#include "system/baseitem/baseitem-key.h"
#include "util/dice.h"
-#include "util/enum-range.h"
#include "util/flag-group.h"
#include "view/display-symbol.h"
#include
-#include
-#include
#include
-#include
-
-enum class MoneyKind {
- COPPER,
- SILVER,
- GARNET,
- GOLD,
- OPAL,
- SAPPHIRE,
- RUBY,
- DIAMOND,
- EMERALD,
- MITHRIL,
- ADAMANTITE,
- MAX,
-};
-
-constexpr EnumRange MONEY_KIND_RANGE(MoneyKind::COPPER, MoneyKind::MAX);
+enum class ItemKindType : short;
enum class RandomArtActType : short;
class BaseitemInfo {
public:
@@ -86,59 +65,3 @@ class BaseitemInfo {
void mark_as_tried();
void mark_as_aware();
};
-
-enum class ItemKindType : short;
-enum class MonraceId : short;
-class BaseitemList {
-public:
- BaseitemList(BaseitemList &&) = delete;
- BaseitemList(const BaseitemList &) = delete;
- BaseitemList &operator=(const BaseitemList &) = delete;
- BaseitemList &operator=(BaseitemList &&) = delete;
- ~BaseitemList() = default;
-
- static BaseitemList &get_instance();
- BaseitemInfo &get_baseitem(const short bi_id);
- const BaseitemInfo &get_baseitem(const short bi_id) const;
-
- std::vector::iterator begin();
- std::vector::const_iterator begin() const;
- std::vector::iterator end();
- std::vector::const_iterator end() const;
- std::vector::reverse_iterator rbegin();
- std::vector::const_reverse_iterator rbegin() const;
- std::vector::reverse_iterator rend();
- std::vector::const_reverse_iterator rend() const;
- size_t size() const;
- bool empty() const;
- void resize(size_t new_size);
- void shrink_to_fit();
-
- std::optional lookup_creeping_coin_drop_offset(MonraceId monrace_id) const;
- short lookup_baseitem_id(const BaseitemKey &bi_key) const;
- const BaseitemInfo &lookup_baseitem(const BaseitemKey &bi_key) const;
- int calc_num_gold_subtypes() const;
- const BaseitemInfo &lookup_gold(int target_offset) const;
- int lookup_gold_offset(short bi_id) const;
-
- void reset_all_visuals();
- void reset_identification_flags();
- void mark_common_items_as_aware();
- void shuffle_flavors();
-
-private:
- BaseitemList() = default;
-
- static BaseitemList instance;
- std::vector baseitems{};
-
- short exe_lookup(const BaseitemKey &bi_key) const;
- const std::map &create_baseitem_index_chache() const;
- const std::map> &create_baseitems_cache() const;
- int lookup_gold_offset(const BaseitemKey &finding_bi_key) const;
- const std::map> &create_sorted_golds() const;
- std::map> create_unsorted_golds() const;
-
- BaseitemInfo &lookup_baseitem(const BaseitemKey &bi_key);
- void shuffle_flavors(ItemKindType tval);
-};
diff --git a/src/system/baseitem/baseitem-list.cpp b/src/system/baseitem/baseitem-list.cpp
new file mode 100644
index 0000000000..6ac9b02658
--- /dev/null
+++ b/src/system/baseitem/baseitem-list.cpp
@@ -0,0 +1,437 @@
+/*!
+ * @brief ベースアイテムの集合論的処理実装
+ * @author Hourier
+ * @date 2024/11/16
+ */
+
+#include "system/baseitem/baseitem-list.h"
+#include "object/tval-types.h"
+#include "sv-definition/sv-potion-types.h"
+#include "sv-definition/sv-staff-types.h"
+#include "system/angband-exceptions.h"
+#include "system/baseitem/baseitem-definition.h"
+#include "system/baseitem/baseitem-key.h"
+#include "system/enums/monrace/monrace-id.h"
+#include "util/enum-converter.h"
+#include "util/enum-range.h"
+#include "util/string-processor.h"
+#include
+#include
+#include
+
+namespace {
+constexpr auto INVALID_BI_ID_FORMAT = "Invalid Baseitem ID is specified! %d";
+constexpr auto INVALID_BASEITEM_KEY = "Invalid Baseitem Key is specified! Type: %d, Subtype: %d";
+constexpr EnumRange MONEY_KIND_RANGE(MoneyKind::COPPER, MoneyKind::MAX);
+const std::map GOLD_KINDS = {
+ { MoneyKind::COPPER, _("銅塊", "copper") },
+ { MoneyKind::SILVER, _("銀塊", "silver") },
+ { MoneyKind::GARNET, _("ガーネット", "garnets") },
+ { MoneyKind::GOLD, _("金塊", "gold") },
+ { MoneyKind::OPAL, _("オパール", "opals") },
+ { MoneyKind::SAPPHIRE, _("サファイア", "sapphires") },
+ { MoneyKind::RUBY, _("ルビー", "rubies") },
+ { MoneyKind::DIAMOND, _("ダイヤモンド", "diamonds") },
+ { MoneyKind::EMERALD, _("エメラルド", "emeralds") },
+ { MoneyKind::MITHRIL, _("ミスリル", "mithril") },
+ { MoneyKind::ADAMANTITE, _("アダマンタイト", "adamantite") },
+};
+const std::map CREEPING_COIN_DROPS = {
+ { MonraceId::COPPER_COINS, { ItemKindType::GOLD, 3 } },
+ { MonraceId::SILVER_COINS, { ItemKindType::GOLD, 6 } },
+ { MonraceId::GOLD_COINS, { ItemKindType::GOLD, 11 } },
+ { MonraceId::MITHRIL_COINS, { ItemKindType::GOLD, 17 } },
+ { MonraceId::MITHRIL_GOLEM, { ItemKindType::GOLD, 17 } },
+ { MonraceId::ADAMANT_COINS, { ItemKindType::GOLD, 18 } },
+};
+}
+
+BaseitemList BaseitemList::instance{};
+
+BaseitemList &BaseitemList::get_instance()
+{
+ return instance;
+}
+
+BaseitemInfo &BaseitemList::get_baseitem(const short bi_id)
+{
+ if ((bi_id < 0) || (bi_id >= static_cast(this->baseitems.size()))) {
+ THROW_EXCEPTION(std::logic_error, format(INVALID_BI_ID_FORMAT, bi_id));
+ }
+
+ return this->baseitems[bi_id];
+}
+
+const BaseitemInfo &BaseitemList::get_baseitem(const short bi_id) const
+{
+ if ((bi_id < 0) || (bi_id >= static_cast(this->baseitems.size()))) {
+ THROW_EXCEPTION(std::logic_error, format(INVALID_BI_ID_FORMAT, bi_id));
+ }
+
+ return this->baseitems[bi_id];
+}
+
+std::vector::iterator BaseitemList::begin()
+{
+ return this->baseitems.begin();
+}
+
+std::vector::const_iterator BaseitemList::begin() const
+{
+ return this->baseitems.begin();
+}
+
+std::vector::iterator BaseitemList::end()
+{
+ return this->baseitems.end();
+}
+
+std::vector::const_iterator BaseitemList::end() const
+{
+ return this->baseitems.end();
+}
+
+std::vector::reverse_iterator BaseitemList::rbegin()
+{
+ return this->baseitems.rbegin();
+}
+
+std::vector::const_reverse_iterator BaseitemList::rbegin() const
+{
+ return this->baseitems.rbegin();
+}
+
+std::vector::reverse_iterator BaseitemList::rend()
+{
+ return this->baseitems.rend();
+}
+
+std::vector::const_reverse_iterator BaseitemList::rend() const
+{
+ return this->baseitems.rend();
+}
+
+size_t BaseitemList::size() const
+{
+ return this->baseitems.size();
+}
+
+bool BaseitemList::empty() const
+{
+ return this->baseitems.empty();
+}
+
+void BaseitemList::resize(size_t new_size)
+{
+ this->baseitems.resize(new_size);
+}
+
+void BaseitemList::shrink_to_fit()
+{
+ this->baseitems.shrink_to_fit();
+}
+
+/*!
+ * @brief ベースアイテムキーからIDを引いて返す
+ * @param key ベースアイテムキー、但しsvalはランダム(nullopt) の可能性がある
+ * @return ベースアイテムID
+ * @details ベースアイテムIDが存在しなければ例外
+ */
+short BaseitemList::lookup_baseitem_id(const BaseitemKey &bi_key) const
+{
+ const auto sval = bi_key.sval();
+ if (sval) {
+ return exe_lookup(bi_key);
+ }
+
+ static const auto &cache = this->create_baseitems_cache();
+ const auto it = cache.find(bi_key.tval());
+ if (it == cache.end()) {
+ constexpr auto fmt = "Specified ItemKindType has no subtype! %d";
+ THROW_EXCEPTION(std::runtime_error, format(fmt, enum2i(bi_key.tval())));
+ }
+
+ const auto &svals = it->second;
+ return exe_lookup({ bi_key.tval(), rand_choice(svals) });
+}
+
+const BaseitemInfo &BaseitemList::lookup_baseitem(const BaseitemKey &bi_key) const
+{
+ const auto bi_id = this->lookup_baseitem_id(bi_key);
+ return this->baseitems[bi_id];
+}
+
+/*!
+ * @brief モンスター種族IDから財宝アイテムの価値を引く
+ * @param monrace_id モンスター種族ID
+ * @return 特定の財宝を落とすならそのアイテムの価値オフセット、一般的な財宝ドロップならばnullopt
+ */
+std::optional BaseitemList::lookup_creeping_coin_drop_offset(MonraceId monrace_id) const
+{
+ const auto it = CREEPING_COIN_DROPS.find(monrace_id);
+ if (it == CREEPING_COIN_DROPS.end()) {
+ return std::nullopt;
+ }
+
+ return this->lookup_gold_offset(it->second);
+}
+
+/*!
+ * @brief ベースアイテム定義群から財宝アイテムの数を計算する
+ * @return 財宝を示すベースアイテム数
+ */
+int BaseitemList::calc_num_gold_subtypes() const
+{
+ static const auto &golds = this->create_sorted_golds();
+ static const auto sum = std::accumulate(golds.begin(), golds.end(), 0,
+ [](int count, const auto &pair) {
+ return count + pair.second.size();
+ });
+ return sum;
+}
+
+/*!
+ * @brief 財宝アイテムの価値からベースアイテムを引く
+ * @param target_offset 財宝アイテムの価値
+ * @return ベースアイテムID
+ * @details 同一の財宝カテゴリ内ならば常に大きいほど価値が高い.
+ * カテゴリが異なるならば価値の大小は保証しない. 即ち「最も高い銅貨>最も安い銀貨」はあり得る.
+ */
+const BaseitemInfo &BaseitemList::lookup_gold(int target_offset) const
+{
+ auto offset = 0;
+ for (const auto &pair : this->create_sorted_golds()) {
+ for (const auto &bi_key : pair.second) {
+ if (offset == target_offset) {
+ return this->get_baseitem(this->exe_lookup(bi_key));
+ }
+
+ offset++;
+ }
+ }
+
+ THROW_EXCEPTION(std::runtime_error, format("Invalid gold offset is specified! %d", target_offset));
+}
+
+/*!
+ * @brief ベースアイテムIDから財宝アイテムの価値を引く
+ * @param bi_id ベースアイテムID
+ * @return 財宝アイテムの価値オフセット
+ * @details 同一の財宝カテゴリ内ならば常に大きいほど価値が高い.
+ * カテゴリが異なるならば価値の大小は保証しない. 即ち「最も高い銅貨>最も安い銀貨」はあり得る.
+ */
+int BaseitemList::lookup_gold_offset(short bi_id) const
+{
+ auto offset = 0;
+ for (const auto &pair : this->create_sorted_golds()) {
+ for (const auto &bi_key : pair.second) {
+ if (bi_id == this->exe_lookup(bi_key)) {
+ return offset;
+ }
+
+ offset++;
+ }
+ }
+
+ THROW_EXCEPTION(std::runtime_error, format(INVALID_BI_ID_FORMAT, bi_id));
+}
+
+void BaseitemList::reset_all_visuals()
+{
+ for (auto &baseitem : this->baseitems) {
+ baseitem.symbol_config = baseitem.symbol_definition;
+ }
+}
+
+/*!
+ * @brief ベースアイテムの鑑定済みフラグをリセットする
+ * @details 不具合対策で0からリセットする(セーブは0から)
+ */
+void BaseitemList::reset_identification_flags()
+{
+ for (auto &baseitem : this->baseitems) {
+ baseitem.tried = false;
+ baseitem.aware = false;
+ }
+}
+
+/*!
+ * @brief 未鑑定アイテム種別の内、ゲーム開始時から鑑定済とするアイテムの鑑定済フラグをONにする
+ * @todo 食料用の杖は該当種族 (ゴーレム/骸骨/ゾンビ/幽霊)では鑑定済だが、本来はこのメソッドで鑑定済にすべき.
+ */
+void BaseitemList::mark_common_items_as_aware()
+{
+ std::vector bi_keys;
+ bi_keys.emplace_back(ItemKindType::POTION, SV_POTION_WATER);
+ bi_keys.emplace_back(ItemKindType::STAFF, SV_STAFF_NOTHING);
+ for (const auto &bi_key : bi_keys) {
+ this->lookup_baseitem(bi_key).mark_as_aware();
+ }
+}
+
+void BaseitemList::shuffle_flavors()
+{
+ this->shuffle_flavors(ItemKindType::RING);
+ this->shuffle_flavors(ItemKindType::AMULET);
+ this->shuffle_flavors(ItemKindType::STAFF);
+ this->shuffle_flavors(ItemKindType::WAND);
+ this->shuffle_flavors(ItemKindType::ROD);
+ this->shuffle_flavors(ItemKindType::FOOD);
+ this->shuffle_flavors(ItemKindType::POTION);
+ this->shuffle_flavors(ItemKindType::SCROLL);
+}
+
+/*!
+ * @brief ベースアイテムキーに対応するベースアイテムのIDを検索する
+ * @param key 検索したいベースアイテムキー
+ * @return ベースアイテムID
+ * @details ベースアイテムIDが存在しなければ例外
+ */
+short BaseitemList::exe_lookup(const BaseitemKey &bi_key) const
+{
+ static const auto &cache = this->create_baseitem_index_chache();
+ const auto it = cache.find(bi_key);
+ if (it == cache.end()) {
+ THROW_EXCEPTION(std::runtime_error, format(INVALID_BASEITEM_KEY, enum2i(bi_key.tval()), *bi_key.sval()));
+ }
+
+ return it->second;
+}
+
+/*
+ * @brief tvalとbi_key.svalに対応する、BaseitenDefinitions のIDを返すためのキャッシュを生成する
+ * @return tvalと(実在する)svalの組み合わせをキーに、ベースアイテムIDを値とした辞書
+ */
+const std::map &BaseitemList::create_baseitem_index_chache() const
+{
+ static std::map cache;
+ for (const auto &baseitem : this->baseitems) {
+ if (baseitem.is_valid()) {
+ const auto &bi_key = baseitem.bi_key;
+ cache[bi_key] = baseitem.idx;
+ }
+ }
+
+ return cache;
+}
+
+/*
+ * @brief 特定のtvalとランダムなsvalの組み合わせからベースアイテムを選択するためのキャッシュを生成する
+ * @return tvalをキーに、svalのリストを値とした辞書
+ */
+const std::map> &BaseitemList::create_baseitems_cache() const
+{
+ static std::map> cache;
+ for (const auto &baseitem : this->baseitems) {
+ if (baseitem.is_valid()) {
+ const auto &bi_key = baseitem.bi_key;
+ const auto tval = bi_key.tval();
+ cache[tval].push_back(*bi_key.sval());
+ }
+ }
+
+ return cache;
+}
+
+/*!
+ * @brief ベースアイテムキーから財宝アイテムの価値を引く
+ * @param finding_bi_key 探索対象のベースアイテムキー
+ * @return 財宝アイテムの価値番号 (大きいほど価値が高い)
+ * @details 同一の財宝カテゴリ内ならば常に番号が大きいほど価値も高い.
+ * カテゴリが異なるならば価値の大小は保証しない. 即ち「最も高い銅貨>最も安い銀貨」はあり得る.
+ */
+int BaseitemList::lookup_gold_offset(const BaseitemKey &finding_bi_key) const
+{
+ auto offset = 0;
+ for (const auto &pair : this->create_sorted_golds()) {
+ for (const auto &bi_key : pair.second) {
+ if (finding_bi_key == bi_key) {
+ return offset;
+ }
+
+ offset++;
+ }
+ }
+
+ THROW_EXCEPTION(std::runtime_error, format(INVALID_BASEITEM_KEY, enum2i(finding_bi_key.tval()), *finding_bi_key.sval()));
+}
+
+/*!
+ * @brief ベースアイテム定義リストから財宝の辞書を作る (価値順)
+ * @return 財宝種別をキー、それに対応するベースアイテムキーの配列 (安い順にソート済)を値とした辞書
+ */
+const std::map> &BaseitemList::create_sorted_golds() const
+{
+ static std::map> list;
+ if (!list.empty()) {
+ return list;
+ }
+
+ list = this->create_unsorted_golds();
+ for (auto &[money_kind, bi_keys] : list) {
+ std::stable_sort(bi_keys.begin(), bi_keys.end(),
+ [this](const auto &bi_key1, const auto &bi_key2) {
+ const auto &baseitem1 = this->lookup_baseitem(bi_key1);
+ const auto &baseitem2 = this->lookup_baseitem(bi_key2);
+ return baseitem1.order_cost(baseitem2);
+ });
+ }
+
+ return list;
+}
+
+/*!
+ * @brief ベースアイテム定義リストから財宝の辞書を作る (ベースアイテムID順)
+ * @return 財宝種別をキー、それに対応するベースアイテムキーの配列を値とした辞書
+ */
+std::map> BaseitemList::create_unsorted_golds() const
+{
+ std::map> list;
+ for (const auto &baseitem : this->baseitems) {
+ const auto &bi_key = baseitem.bi_key;
+ if (bi_key.tval() != ItemKindType::GOLD) {
+ continue;
+ }
+
+ for (const auto money_kind : MONEY_KIND_RANGE) {
+ if (baseitem.name == GOLD_KINDS.at(money_kind)) {
+ list[money_kind].push_back(bi_key);
+ }
+ }
+ }
+
+ return list;
+}
+
+BaseitemInfo &BaseitemList::lookup_baseitem(const BaseitemKey &bi_key)
+{
+ const auto bi_id = this->lookup_baseitem_id(bi_key);
+ return this->baseitems[bi_id];
+}
+
+/*!
+ * @brief ベースアイテムの未確定名を共通tval間でシャッフルする
+ * @param tval シャッフルしたいtval
+ * @details 巻物、各種魔道具などに利用される。
+ */
+void BaseitemList::shuffle_flavors(ItemKindType tval)
+{
+ std::vector> flavors;
+ for (auto &baseitem : this->baseitems) {
+ if (baseitem.bi_key.tval() != tval) {
+ continue;
+ }
+
+ if (baseitem.flavor == 0) {
+ continue;
+ }
+
+ if (baseitem.flags.has(TR_FIXED_FLAVOR)) {
+ continue;
+ }
+
+ flavors.push_back(baseitem.flavor);
+ }
+
+ rand_shuffle(flavors.begin(), flavors.end());
+}
diff --git a/src/system/baseitem/baseitem-list.h b/src/system/baseitem/baseitem-list.h
new file mode 100644
index 0000000000..4e097478a5
--- /dev/null
+++ b/src/system/baseitem/baseitem-list.h
@@ -0,0 +1,84 @@
+/*!
+ * @brief ベースアイテムの集合論的処理定義
+ * @author Hourier
+ * @date 2024/11/16
+ */
+
+#pragma once
+
+#include
+#include
+#include
+
+enum class MoneyKind {
+ COPPER,
+ SILVER,
+ GARNET,
+ GOLD,
+ OPAL,
+ SAPPHIRE,
+ RUBY,
+ DIAMOND,
+ EMERALD,
+ MITHRIL,
+ ADAMANTITE,
+ MAX,
+};
+
+enum class ItemKindType : short;
+enum class MonraceId : short;
+class BaseitemInfo;
+class BaseitemKey;
+class BaseitemList {
+public:
+ BaseitemList(BaseitemList &&) = delete;
+ BaseitemList(const BaseitemList &) = delete;
+ BaseitemList &operator=(const BaseitemList &) = delete;
+ BaseitemList &operator=(BaseitemList &&) = delete;
+ ~BaseitemList() = default;
+
+ static BaseitemList &get_instance();
+ BaseitemInfo &get_baseitem(const short bi_id);
+ const BaseitemInfo &get_baseitem(const short bi_id) const;
+
+ std::vector::iterator begin();
+ std::vector::const_iterator begin() const;
+ std::vector::iterator end();
+ std::vector::const_iterator end() const;
+ std::vector::reverse_iterator rbegin();
+ std::vector::const_reverse_iterator rbegin() const;
+ std::vector::reverse_iterator rend();
+ std::vector::const_reverse_iterator rend() const;
+ size_t size() const;
+ bool empty() const;
+ void resize(size_t new_size);
+ void shrink_to_fit();
+
+ std::optional lookup_creeping_coin_drop_offset(MonraceId monrace_id) const;
+ short lookup_baseitem_id(const BaseitemKey &bi_key) const;
+ const BaseitemInfo &lookup_baseitem(const BaseitemKey &bi_key) const;
+ int calc_num_gold_subtypes() const;
+ const BaseitemInfo &lookup_gold(int target_offset) const;
+ int lookup_gold_offset(short bi_id) const;
+
+ void reset_all_visuals();
+ void reset_identification_flags();
+ void mark_common_items_as_aware();
+ void shuffle_flavors();
+
+private:
+ BaseitemList() = default;
+
+ static BaseitemList instance;
+ std::vector baseitems{};
+
+ short exe_lookup(const BaseitemKey &bi_key) const;
+ const std::map &create_baseitem_index_chache() const;
+ const std::map> &create_baseitems_cache() const;
+ int lookup_gold_offset(const BaseitemKey &finding_bi_key) const;
+ const std::map> &create_sorted_golds() const;
+ std::map> create_unsorted_golds() const;
+
+ BaseitemInfo &lookup_baseitem(const BaseitemKey &bi_key);
+ void shuffle_flavors(ItemKindType tval);
+};
diff --git a/src/system/floor-type-definition.cpp b/src/system/floor-type-definition.cpp
index 6c9fa06884..731136f94a 100644
--- a/src/system/floor-type-definition.cpp
+++ b/src/system/floor-type-definition.cpp
@@ -6,6 +6,7 @@
#include "system/angband-system.h"
#include "system/artifact-type-definition.h"
#include "system/baseitem/baseitem-definition.h"
+#include "system/baseitem/baseitem-list.h"
#include "system/dungeon-info.h"
#include "system/enums/grid-count-kind.h"
#include "system/gamevalue.h"
diff --git a/src/system/item-entity.cpp b/src/system/item-entity.cpp
index 32a27b5b74..690389539a 100644
--- a/src/system/item-entity.cpp
+++ b/src/system/item-entity.cpp
@@ -26,6 +26,7 @@
#include "sv-definition/sv-weapon-types.h"
#include "system/artifact-type-definition.h"
#include "system/baseitem/baseitem-definition.h"
+#include "system/baseitem/baseitem-list.h"
#include "system/enums/monrace/monrace-id.h"
#include "system/monster-race-info.h"
#include "term/term-color-types.h"
diff --git a/src/view/display-map.cpp b/src/view/display-map.cpp
index f6801d4f55..0b8889d86b 100644
--- a/src/view/display-map.cpp
+++ b/src/view/display-map.cpp
@@ -12,6 +12,7 @@
#include "object/object-mark-types.h"
#include "player/player-status.h"
#include "system/baseitem/baseitem-definition.h"
+#include "system/baseitem/baseitem-list.h"
#include "system/floor-type-definition.h"
#include "system/grid-type-definition.h"
#include "system/item-entity.h"
diff --git a/src/window/main-window-equipments.cpp b/src/window/main-window-equipments.cpp
index 71421ce9a8..6e28284013 100644
--- a/src/window/main-window-equipments.cpp
+++ b/src/window/main-window-equipments.cpp
@@ -11,7 +11,6 @@
#include "object/item-use-flags.h"
#include "object/object-info.h"
#include "player/player-status-flags.h"
-#include "system/baseitem/baseitem-definition.h"
#include "system/item-entity.h"
#include "system/player-type-definition.h"
#include "term/gameterm.h"
@@ -20,6 +19,7 @@
#include "term/z-form.h"
#include "util/bit-flags-calculator.h"
#include "util/string-processor.h"
+#include "view/display-symbol.h"
#include
#include
diff --git a/src/wizard/items-spoiler.cpp b/src/wizard/items-spoiler.cpp
index 511a86996a..1fb1a97a92 100644
--- a/src/wizard/items-spoiler.cpp
+++ b/src/wizard/items-spoiler.cpp
@@ -7,6 +7,7 @@
#include "object/object-value.h"
#include "system/angband-system.h"
#include "system/baseitem/baseitem-definition.h"
+#include "system/baseitem/baseitem-list.h"
#include "system/item-entity.h"
#include "system/player-type-definition.h"
#include "term/z-form.h"
diff --git a/src/wizard/wizard-item-modifier.cpp b/src/wizard/wizard-item-modifier.cpp
index 827a730c94..ef25a60653 100644
--- a/src/wizard/wizard-item-modifier.cpp
+++ b/src/wizard/wizard-item-modifier.cpp
@@ -28,6 +28,7 @@
#include "system/alloc-entries.h"
#include "system/artifact-type-definition.h"
#include "system/baseitem/baseitem-definition.h"
+#include "system/baseitem/baseitem-list.h"
#include "system/floor-type-definition.h"
#include "system/item-entity.h"
#include "system/player-type-definition.h"
diff --git a/src/wizard/wizard-special-process.cpp b/src/wizard/wizard-special-process.cpp
index 01bc5de82a..e60d75b1a1 100644
--- a/src/wizard/wizard-special-process.cpp
+++ b/src/wizard/wizard-special-process.cpp
@@ -80,6 +80,7 @@
#include "system/angband-version.h"
#include "system/artifact-type-definition.h"
#include "system/baseitem/baseitem-definition.h"
+#include "system/baseitem/baseitem-list.h"
#include "system/dungeon-info.h"
#include "system/floor-type-definition.h"
#include "system/grid-type-definition.h"
From ff0fcfd59356eb0720b0c6dc705210318e96f536 Mon Sep 17 00:00:00 2001
From: Hourier <66951241+Hourier@users.noreply.github.com>
Date: Sun, 17 Nov 2024 14:07:37 +0900
Subject: [PATCH 04/11] =?UTF-8?q?[Refactor]=20#4622=20BaseitemInfo=20?=
=?UTF-8?q?=E3=82=92BaseitemDefinition=20=E3=81=AB=E5=A4=89=E3=81=88?=
=?UTF-8?q?=E3=81=9F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
ミュータブルなフィールドは後ほど分離予定
---
src/info-reader/baseitem-reader.cpp | 14 +++++-----
src/knowledge/knowledge-items.cpp | 2 +-
src/load/item/item-loader-base.cpp | 2 +-
src/system/alloc-entries.cpp | 2 +-
src/system/alloc-entries.h | 4 +--
src/system/baseitem/baseitem-definition.cpp | 14 +++++-----
src/system/baseitem/baseitem-definition.h | 6 ++---
src/system/baseitem/baseitem-list.cpp | 26 +++++++++---------
src/system/baseitem/baseitem-list.h | 30 ++++++++++-----------
src/system/item-entity.cpp | 2 +-
src/system/item-entity.h | 4 +--
src/view/display-map.cpp | 2 +-
12 files changed, 54 insertions(+), 54 deletions(-)
diff --git a/src/info-reader/baseitem-reader.cpp b/src/info-reader/baseitem-reader.cpp
index 6aefadee38..344d578fc1 100644
--- a/src/info-reader/baseitem-reader.cpp
+++ b/src/info-reader/baseitem-reader.cpp
@@ -28,7 +28,7 @@
* @param what 参照元の文字列
* @return 見つけたらtrue
*/
-static bool grab_one_baseitem_flag(BaseitemInfo &baseitem, std::string_view what)
+static bool grab_one_baseitem_flag(BaseitemDefinition &baseitem, std::string_view what)
{
if (TrFlags::grab_one_flag(baseitem.flags, baseitem_flags, what)) {
return true;
@@ -48,7 +48,7 @@ static bool grab_one_baseitem_flag(BaseitemInfo &baseitem, std::string_view what
* @param baseitem 保管先のベースアイテム情報インスタンス
* @return エラーコード
*/
-static errr set_baseitem_symbol(const nlohmann::json &symbol_data, BaseitemInfo &baseitem)
+static errr set_baseitem_symbol(const nlohmann::json &symbol_data, BaseitemDefinition &baseitem)
{
if (symbol_data.is_null()) {
return PARSE_ERROR_TOO_FEW_ARGUMENTS;
@@ -82,7 +82,7 @@ static errr set_baseitem_symbol(const nlohmann::json &symbol_data, BaseitemInfo
* @param baseitem 保管先のベースアイテム情報インスタンス
* @return エラーコード
*/
-static errr set_baseitem_kind(nlohmann::json &baseitem_data, BaseitemInfo &baseitem)
+static errr set_baseitem_kind(nlohmann::json &baseitem_data, BaseitemDefinition &baseitem)
{
if (baseitem_data.is_null()) {
return PARSE_ERROR_TOO_FEW_ARGUMENTS;
@@ -107,7 +107,7 @@ static errr set_baseitem_kind(nlohmann::json &baseitem_data, BaseitemInfo &basei
* @param baseitem 保管先のベースアイテム情報インスタンス
* @return エラーコード
*/
-static errr set_baseitem_parameter_value(const nlohmann::json &pval_data, BaseitemInfo &baseitem)
+static errr set_baseitem_parameter_value(const nlohmann::json &pval_data, BaseitemDefinition &baseitem)
{
if (auto err = info_set_integer(pval_data, baseitem.pval, false, Range(-9999, 9999))) {
return err;
@@ -125,7 +125,7 @@ static errr set_baseitem_parameter_value(const nlohmann::json &pval_data, Baseit
* @param baseitem 保管先のベースアイテム情報インスタンス
* @return エラーコード
*/
-static errr set_baseitem_allocations(nlohmann::json &allocations_data, BaseitemInfo &baseitem)
+static errr set_baseitem_allocations(nlohmann::json &allocations_data, BaseitemDefinition &baseitem)
{
if (allocations_data.is_null()) {
return PARSE_ERROR_NONE;
@@ -154,7 +154,7 @@ static errr set_baseitem_allocations(nlohmann::json &allocations_data, BaseitemI
* @param baseitem 保管先のベースアイテム情報インスタンス
* @return エラーコード
*/
-static errr set_baseitem_activate(const nlohmann::json &act_data, BaseitemInfo &baseitem)
+static errr set_baseitem_activate(const nlohmann::json &act_data, BaseitemDefinition &baseitem)
{
if (!act_data.is_string()) {
return PARSE_ERROR_NONE;
@@ -176,7 +176,7 @@ static errr set_baseitem_activate(const nlohmann::json &act_data, BaseitemInfo &
* @param baseitem 保管先のベースアイテム情報インスタンス
* @return エラーコード
*/
-static errr set_baseitem_flags(const nlohmann::json &flag_data, BaseitemInfo &baseitem)
+static errr set_baseitem_flags(const nlohmann::json &flag_data, BaseitemDefinition &baseitem)
{
if (flag_data.is_null()) {
return PARSE_ERROR_NONE;
diff --git a/src/knowledge/knowledge-items.cpp b/src/knowledge/knowledge-items.cpp
index 28e73cff84..efceb28cbb 100644
--- a/src/knowledge/knowledge-items.cpp
+++ b/src/knowledge/knowledge-items.cpp
@@ -122,7 +122,7 @@ void do_cmd_knowledge_artifacts(PlayerType *player_ptr)
* @param baseitem ベースアイテムへの参照
* @return collect_objects() の処理を続行するか否か
*/
-static bool check_baseitem_chance(const BIT_FLAGS8 mode, const BaseitemInfo &baseitem)
+static bool check_baseitem_chance(const BIT_FLAGS8 mode, const BaseitemDefinition &baseitem)
{
if (mode & 0x02) {
return true;
diff --git a/src/load/item/item-loader-base.cpp b/src/load/item/item-loader-base.cpp
index c6f45758d9..8b983f0718 100644
--- a/src/load/item/item-loader-base.cpp
+++ b/src/load/item/item-loader-base.cpp
@@ -14,7 +14,7 @@
void ItemLoaderBase::load_item()
{
auto loading_max_k_idx = rd_u16b();
- BaseitemInfo dummy;
+ BaseitemDefinition dummy;
auto &baseitems = BaseitemList::get_instance();
for (uint16_t i = 0; i < loading_max_k_idx; i++) {
auto &baseitem = i < baseitems.size() ? baseitems.get_baseitem(i) : dummy;
diff --git a/src/system/alloc-entries.cpp b/src/system/alloc-entries.cpp
index d722919f7e..7ef55325b7 100644
--- a/src/system/alloc-entries.cpp
+++ b/src/system/alloc-entries.cpp
@@ -111,7 +111,7 @@ MonraceAllocationEntry &MonraceAllocationTable::get_entry(int index)
/* The entries in the "kind allocator table" */
std::vector alloc_kind_table;
-BaseitemInfo &alloc_entry::get_baseitem() const
+BaseitemDefinition &alloc_entry::get_baseitem() const
{
return BaseitemList::get_instance().get_baseitem(this->index);
}
diff --git a/src/system/alloc-entries.h b/src/system/alloc-entries.h
index 7135529f07..b0f999e1fa 100644
--- a/src/system/alloc-entries.h
+++ b/src/system/alloc-entries.h
@@ -33,13 +33,13 @@ class MonraceAllocationEntry {
* Pass 1 is determined from allocation information
* Pass 2 is determined from allocation restriction
*/
-class BaseitemInfo;
+class BaseitemDefinition;
struct alloc_entry {
short index; /* The actual index */
int level; /* Base dungeon level */
short prob1; /* Probability, pass 1 */
short prob2; /* Probability, pass 2 */
- BaseitemInfo &get_baseitem() const;
+ BaseitemDefinition &get_baseitem() const;
};
class MonraceAllocationTable {
diff --git a/src/system/baseitem/baseitem-definition.cpp b/src/system/baseitem/baseitem-definition.cpp
index 62ea6fbd6b..831e682d33 100644
--- a/src/system/baseitem/baseitem-definition.cpp
+++ b/src/system/baseitem/baseitem-definition.cpp
@@ -7,7 +7,7 @@
#include "system/baseitem/baseitem-definition.h"
#include "util/string-processor.h"
-BaseitemInfo::BaseitemInfo()
+BaseitemDefinition::BaseitemDefinition()
: bi_key(ItemKindType::NONE)
, symbol_definition(DisplaySymbol(0, '\0'))
, symbol_config(DisplaySymbol(0, '\0'))
@@ -21,7 +21,7 @@ BaseitemInfo::BaseitemInfo()
* その他、ベースアイテムIDは歴史的事情により歯抜けが多数あり、それらは名前が空欄になるようにオブジェクトを生成している
* @todo v3.1以降で歯抜けを埋めるようにベースアイテムを追加していきたい (詳細未定)
*/
-bool BaseitemInfo::is_valid() const
+bool BaseitemDefinition::is_valid() const
{
return (this->idx > 0) && !this->name.empty();
}
@@ -30,7 +30,7 @@ bool BaseitemInfo::is_valid() const
* @brief ベースアイテム名を返す
* @return ベースアイテム名
*/
-std::string BaseitemInfo::stripped_name() const
+std::string BaseitemDefinition::stripped_name() const
{
const auto tokens = str_split(this->name, ' ');
std::stringstream ss;
@@ -62,7 +62,7 @@ std::string BaseitemInfo::stripped_name() const
return ss.str();
}
-bool BaseitemInfo::order_cost(const BaseitemInfo &other) const
+bool BaseitemDefinition::order_cost(const BaseitemDefinition &other) const
{
return this->cost < other.cost;
}
@@ -70,7 +70,7 @@ bool BaseitemInfo::order_cost(const BaseitemInfo &other) const
/*!
* @brief 最初から簡易な名称が明らかなベースアイテムにその旨のフラグを立てる
*/
-void BaseitemInfo::decide_easy_know()
+void BaseitemDefinition::decide_easy_know()
{
switch (this->bi_key.tval()) {
case ItemKindType::LIFE_BOOK:
@@ -109,12 +109,12 @@ void BaseitemInfo::decide_easy_know()
/*!
* @brief オブジェクトを試行済にする
*/
-void BaseitemInfo::mark_as_tried()
+void BaseitemDefinition::mark_as_tried()
{
this->tried = true;
}
-void BaseitemInfo::mark_as_aware()
+void BaseitemDefinition::mark_as_aware()
{
this->aware = true;
}
diff --git a/src/system/baseitem/baseitem-definition.h b/src/system/baseitem/baseitem-definition.h
index 82f4e2caaf..915ca3fcee 100644
--- a/src/system/baseitem/baseitem-definition.h
+++ b/src/system/baseitem/baseitem-definition.h
@@ -12,9 +12,9 @@
enum class ItemKindType : short;
enum class RandomArtActType : short;
-class BaseitemInfo {
+class BaseitemDefinition {
public:
- BaseitemInfo();
+ BaseitemDefinition();
short idx{};
std::string name; /*!< ベースアイテム名 */
@@ -51,7 +51,7 @@ class BaseitemInfo {
bool is_valid() const;
std::string stripped_name() const;
- bool order_cost(const BaseitemInfo &other) const;
+ bool order_cost(const BaseitemDefinition &other) const;
void decide_easy_know();
/* @todo ここから下はBaseitemDefinitions.txt に依存しないミュータブルなフィールド群なので、将来的に分離予定 */
diff --git a/src/system/baseitem/baseitem-list.cpp b/src/system/baseitem/baseitem-list.cpp
index 6ac9b02658..4781a0aa71 100644
--- a/src/system/baseitem/baseitem-list.cpp
+++ b/src/system/baseitem/baseitem-list.cpp
@@ -53,7 +53,7 @@ BaseitemList &BaseitemList::get_instance()
return instance;
}
-BaseitemInfo &BaseitemList::get_baseitem(const short bi_id)
+BaseitemDefinition &BaseitemList::get_baseitem(const short bi_id)
{
if ((bi_id < 0) || (bi_id >= static_cast(this->baseitems.size()))) {
THROW_EXCEPTION(std::logic_error, format(INVALID_BI_ID_FORMAT, bi_id));
@@ -62,7 +62,7 @@ BaseitemInfo &BaseitemList::get_baseitem(const short bi_id)
return this->baseitems[bi_id];
}
-const BaseitemInfo &BaseitemList::get_baseitem(const short bi_id) const
+const BaseitemDefinition &BaseitemList::get_baseitem(const short bi_id) const
{
if ((bi_id < 0) || (bi_id >= static_cast(this->baseitems.size()))) {
THROW_EXCEPTION(std::logic_error, format(INVALID_BI_ID_FORMAT, bi_id));
@@ -71,42 +71,42 @@ const BaseitemInfo &BaseitemList::get_baseitem(const short bi_id) const
return this->baseitems[bi_id];
}
-std::vector::iterator BaseitemList::begin()
+std::vector::iterator BaseitemList::begin()
{
return this->baseitems.begin();
}
-std::vector::const_iterator BaseitemList::begin() const
+std::vector::const_iterator BaseitemList::begin() const
{
return this->baseitems.begin();
}
-std::vector::iterator BaseitemList::end()
+std::vector::iterator BaseitemList::end()
{
return this->baseitems.end();
}
-std::vector::const_iterator BaseitemList::end() const
+std::vector::const_iterator BaseitemList::end() const
{
return this->baseitems.end();
}
-std::vector::reverse_iterator BaseitemList::rbegin()
+std::vector::reverse_iterator BaseitemList::rbegin()
{
return this->baseitems.rbegin();
}
-std::vector::const_reverse_iterator BaseitemList::rbegin() const
+std::vector::const_reverse_iterator BaseitemList::rbegin() const
{
return this->baseitems.rbegin();
}
-std::vector::reverse_iterator BaseitemList::rend()
+std::vector::reverse_iterator BaseitemList::rend()
{
return this->baseitems.rend();
}
-std::vector::const_reverse_iterator BaseitemList::rend() const
+std::vector::const_reverse_iterator BaseitemList::rend() const
{
return this->baseitems.rend();
}
@@ -155,7 +155,7 @@ short BaseitemList::lookup_baseitem_id(const BaseitemKey &bi_key) const
return exe_lookup({ bi_key.tval(), rand_choice(svals) });
}
-const BaseitemInfo &BaseitemList::lookup_baseitem(const BaseitemKey &bi_key) const
+const BaseitemDefinition &BaseitemList::lookup_baseitem(const BaseitemKey &bi_key) const
{
const auto bi_id = this->lookup_baseitem_id(bi_key);
return this->baseitems[bi_id];
@@ -197,7 +197,7 @@ int BaseitemList::calc_num_gold_subtypes() const
* @details 同一の財宝カテゴリ内ならば常に大きいほど価値が高い.
* カテゴリが異なるならば価値の大小は保証しない. 即ち「最も高い銅貨>最も安い銀貨」はあり得る.
*/
-const BaseitemInfo &BaseitemList::lookup_gold(int target_offset) const
+const BaseitemDefinition &BaseitemList::lookup_gold(int target_offset) const
{
auto offset = 0;
for (const auto &pair : this->create_sorted_golds()) {
@@ -403,7 +403,7 @@ std::map> BaseitemList::create_unsorted_gold
return list;
}
-BaseitemInfo &BaseitemList::lookup_baseitem(const BaseitemKey &bi_key)
+BaseitemDefinition &BaseitemList::lookup_baseitem(const BaseitemKey &bi_key)
{
const auto bi_id = this->lookup_baseitem_id(bi_key);
return this->baseitems[bi_id];
diff --git a/src/system/baseitem/baseitem-list.h b/src/system/baseitem/baseitem-list.h
index 4e097478a5..9173915b9d 100644
--- a/src/system/baseitem/baseitem-list.h
+++ b/src/system/baseitem/baseitem-list.h
@@ -27,7 +27,7 @@ enum class MoneyKind {
enum class ItemKindType : short;
enum class MonraceId : short;
-class BaseitemInfo;
+class BaseitemDefinition;
class BaseitemKey;
class BaseitemList {
public:
@@ -38,17 +38,17 @@ class BaseitemList {
~BaseitemList() = default;
static BaseitemList &get_instance();
- BaseitemInfo &get_baseitem(const short bi_id);
- const BaseitemInfo &get_baseitem(const short bi_id) const;
+ BaseitemDefinition &get_baseitem(const short bi_id);
+ const BaseitemDefinition &get_baseitem(const short bi_id) const;
- std::vector::iterator begin();
- std::vector::const_iterator begin() const;
- std::vector::iterator end();
- std::vector::const_iterator end() const;
- std::vector::reverse_iterator rbegin();
- std::vector::const_reverse_iterator rbegin() const;
- std::vector::reverse_iterator rend();
- std::vector::const_reverse_iterator rend() const;
+ std::vector::iterator begin();
+ std::vector::const_iterator begin() const;
+ std::vector::iterator end();
+ std::vector::const_iterator end() const;
+ std::vector::reverse_iterator rbegin();
+ std::vector::const_reverse_iterator rbegin() const;
+ std::vector::reverse_iterator rend();
+ std::vector::const_reverse_iterator rend() const;
size_t size() const;
bool empty() const;
void resize(size_t new_size);
@@ -56,9 +56,9 @@ class BaseitemList {
std::optional lookup_creeping_coin_drop_offset(MonraceId monrace_id) const;
short lookup_baseitem_id(const BaseitemKey &bi_key) const;
- const BaseitemInfo &lookup_baseitem(const BaseitemKey &bi_key) const;
+ const BaseitemDefinition &lookup_baseitem(const BaseitemKey &bi_key) const;
int calc_num_gold_subtypes() const;
- const BaseitemInfo &lookup_gold(int target_offset) const;
+ const BaseitemDefinition &lookup_gold(int target_offset) const;
int lookup_gold_offset(short bi_id) const;
void reset_all_visuals();
@@ -70,7 +70,7 @@ class BaseitemList {
BaseitemList() = default;
static BaseitemList instance;
- std::vector baseitems{};
+ std::vector baseitems{};
short exe_lookup(const BaseitemKey &bi_key) const;
const std::map &create_baseitem_index_chache() const;
@@ -79,6 +79,6 @@ class BaseitemList {
const std::map> &create_sorted_golds() const;
std::map> create_unsorted_golds() const;
- BaseitemInfo &lookup_baseitem(const BaseitemKey &bi_key);
+ BaseitemDefinition &lookup_baseitem(const BaseitemKey &bi_key);
void shuffle_flavors(ItemKindType tval);
};
diff --git a/src/system/item-entity.cpp b/src/system/item-entity.cpp
index 690389539a..e012fc1182 100644
--- a/src/system/item-entity.cpp
+++ b/src/system/item-entity.cpp
@@ -822,7 +822,7 @@ bool ItemEntity::is_target_of(QuestId quest_id) const
return this->bi_key == artifact.bi_key;
}
-BaseitemInfo &ItemEntity::get_baseitem() const
+BaseitemDefinition &ItemEntity::get_baseitem() const
{
return BaseitemList::get_instance().get_baseitem(this->bi_id);
}
diff --git a/src/system/item-entity.h b/src/system/item-entity.h
index d38dfe560d..8755c52ec2 100644
--- a/src/system/item-entity.h
+++ b/src/system/item-entity.h
@@ -29,7 +29,7 @@ enum class RandomArtActType : short;
enum class SmithEffectType : short;
class ActivationType;
class ArtifactType;
-class BaseitemInfo;
+class BaseitemDefinition;
class DisplaySymbol;
class EgoItemDefinition;
class MonraceDefinition;
@@ -151,7 +151,7 @@ class ItemEntity {
bool has_bias() const;
bool is_bounty() const;
bool is_target_of(QuestId quest_id) const;
- BaseitemInfo &get_baseitem() const;
+ BaseitemDefinition &get_baseitem() const;
EgoItemDefinition &get_ego() const;
ArtifactType &get_fixed_artifact() const;
TrFlags get_flags() const;
diff --git a/src/view/display-map.cpp b/src/view/display-map.cpp
index 0b8889d86b..629043295c 100644
--- a/src/view/display-map.cpp
+++ b/src/view/display-map.cpp
@@ -46,7 +46,7 @@ DisplaySymbol image_object()
{
if (use_graphics) {
auto &baseitems = BaseitemList::get_instance();
- const std::span candidates(baseitems.begin() + 1, baseitems.end());
+ const std::span candidates(baseitems.begin() + 1, baseitems.end());
const auto &baseitem = rand_choice(candidates);
return baseitem.symbol_config;
}
From c2e3c7cb7153f53de589907240cc7baa7915232f Mon Sep 17 00:00:00 2001
From: Hourier <66951241+Hourier@users.noreply.github.com>
Date: Sun, 24 Nov 2024 11:36:00 +0900
Subject: [PATCH 05/11] =?UTF-8?q?[Refactor]=20#4622=20=E3=82=BF=E3=82=A4?=
=?UTF-8?q?=E3=83=9D=E4=BF=AE=E6=AD=A3=E3=81=8C=E3=81=A6=E3=82=89=E3=80=81?=
=?UTF-8?q?BaseitemList=20=E3=81=AE=E3=82=AD=E3=83=A3=E3=83=83=E3=82=B7?=
=?UTF-8?q?=E3=83=A5=E7=94=9F=E6=88=90=E3=83=A1=E3=82=BD=E3=83=83=E3=83=89?=
=?UTF-8?q?=E5=90=8D=E3=82=92=E5=88=86=E3=81=8B=E3=82=8A=E3=82=84=E3=81=99?=
=?UTF-8?q?=E3=81=8F=E5=A4=89=E3=81=88=E3=81=9F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/system/baseitem/baseitem-list.cpp | 8 ++++----
src/system/baseitem/baseitem-list.h | 4 ++--
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/system/baseitem/baseitem-list.cpp b/src/system/baseitem/baseitem-list.cpp
index 4781a0aa71..22c557c354 100644
--- a/src/system/baseitem/baseitem-list.cpp
+++ b/src/system/baseitem/baseitem-list.cpp
@@ -144,7 +144,7 @@ short BaseitemList::lookup_baseitem_id(const BaseitemKey &bi_key) const
return exe_lookup(bi_key);
}
- static const auto &cache = this->create_baseitems_cache();
+ static const auto &cache = this->create_baseitem_subtypes_cache();
const auto it = cache.find(bi_key.tval());
if (it == cache.end()) {
constexpr auto fmt = "Specified ItemKindType has no subtype! %d";
@@ -289,7 +289,7 @@ void BaseitemList::shuffle_flavors()
*/
short BaseitemList::exe_lookup(const BaseitemKey &bi_key) const
{
- static const auto &cache = this->create_baseitem_index_chache();
+ static const auto &cache = this->create_baseitem_keys_cache();
const auto it = cache.find(bi_key);
if (it == cache.end()) {
THROW_EXCEPTION(std::runtime_error, format(INVALID_BASEITEM_KEY, enum2i(bi_key.tval()), *bi_key.sval()));
@@ -302,7 +302,7 @@ short BaseitemList::exe_lookup(const BaseitemKey &bi_key) const
* @brief tvalとbi_key.svalに対応する、BaseitenDefinitions のIDを返すためのキャッシュを生成する
* @return tvalと(実在する)svalの組み合わせをキーに、ベースアイテムIDを値とした辞書
*/
-const std::map &BaseitemList::create_baseitem_index_chache() const
+const std::map &BaseitemList::create_baseitem_keys_cache() const
{
static std::map cache;
for (const auto &baseitem : this->baseitems) {
@@ -319,7 +319,7 @@ const std::map &BaseitemList::create_baseitem_index_chache()
* @brief 特定のtvalとランダムなsvalの組み合わせからベースアイテムを選択するためのキャッシュを生成する
* @return tvalをキーに、svalのリストを値とした辞書
*/
-const std::map> &BaseitemList::create_baseitems_cache() const
+const std::map> &BaseitemList::create_baseitem_subtypes_cache() const
{
static std::map> cache;
for (const auto &baseitem : this->baseitems) {
diff --git a/src/system/baseitem/baseitem-list.h b/src/system/baseitem/baseitem-list.h
index 9173915b9d..5286c8552d 100644
--- a/src/system/baseitem/baseitem-list.h
+++ b/src/system/baseitem/baseitem-list.h
@@ -73,8 +73,8 @@ class BaseitemList {
std::vector baseitems{};
short exe_lookup(const BaseitemKey &bi_key) const;
- const std::map &create_baseitem_index_chache() const;
- const std::map> &create_baseitems_cache() const;
+ const std::map &create_baseitem_keys_cache() const;
+ const std::map> &create_baseitem_subtypes_cache() const;
int lookup_gold_offset(const BaseitemKey &finding_bi_key) const;
const std::map> &create_sorted_golds() const;
std::map> create_unsorted_golds() const;
From 3232e95e753535de87e0d12374d01cde2b3f48b0 Mon Sep 17 00:00:00 2001
From: Hourier <66951241+Hourier@users.noreply.github.com>
Date: Sun, 24 Nov 2024 22:25:19 +0900
Subject: [PATCH 06/11] =?UTF-8?q?[Refactor]=20is=5Fhidden=5Fdoor()=20?=
=?UTF-8?q?=E3=82=92Grid=20=E3=81=AE=E3=82=AA=E3=83=96=E3=82=B8=E3=82=A7?=
=?UTF-8?q?=E3=82=AF=E3=83=88=E3=83=A1=E3=82=BD=E3=83=83=E3=83=89=E3=81=B8?=
=?UTF-8?q?=E7=B9=B0=E3=82=8A=E8=BE=BC=E3=81=BF=E3=80=81PlayerType=20?=
=?UTF-8?q?=E3=81=B8=E3=81=AE=E4=BE=9D=E5=AD=98=E3=82=92=E5=A4=96=E3=81=97?=
=?UTF-8?q?=E3=81=9F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/action/tunnel-execution.cpp | 2 +-
src/effect/effect-feature.cpp | 2 +-
src/grid/grid.cpp | 12 ------------
src/grid/grid.h | 1 -
src/player/player-move.cpp | 2 +-
src/system/grid-type-definition.cpp | 10 ++++++++++
src/system/grid-type-definition.h | 1 +
7 files changed, 14 insertions(+), 16 deletions(-)
diff --git a/src/action/tunnel-execution.cpp b/src/action/tunnel-execution.cpp
index 80d8c8410e..c54f31bb40 100644
--- a/src/action/tunnel-execution.cpp
+++ b/src/action/tunnel-execution.cpp
@@ -118,7 +118,7 @@ bool exe_tunnel(PlayerType *player_ptr, POSITION y, POSITION x)
}
}
- if (is_hidden_door(player_ptr, grid) && one_in_(4)) {
+ if (grid.is_hidden_door() && one_in_(4)) {
search(player_ptr);
}
diff --git a/src/effect/effect-feature.cpp b/src/effect/effect-feature.cpp
index 1fc7248156..f95114c865 100644
--- a/src/effect/effect-feature.cpp
+++ b/src/effect/effect-feature.cpp
@@ -171,7 +171,7 @@ bool affect_feature(PlayerType *player_ptr, MONSTER_IDX src_idx, POSITION r, POS
break;
}
case AttributeType::KILL_TRAP: {
- if (is_hidden_door(player_ptr, grid)) {
+ if (grid.is_hidden_door()) {
disclose_grid(player_ptr, y, x);
if (known) {
obvious = true;
diff --git a/src/grid/grid.cpp b/src/grid/grid.cpp
index af1ba78a52..a5980dac73 100644
--- a/src/grid/grid.cpp
+++ b/src/grid/grid.cpp
@@ -145,18 +145,6 @@ bool new_player_spot(PlayerType *player_ptr)
return true;
}
-/*!
- * @brief マスに隠されたドアがあるかの判定を行う。 / Return TRUE if the given grid is a hidden closed door
- * @param player_ptr プレイヤーへの参照ポインタ
- * @param grid マス構造体の参照ポインタ
- * @return 隠されたドアがあるならTRUEを返す。
- */
-bool is_hidden_door(PlayerType *player_ptr, const Grid &grid)
-{
- (void)player_ptr; // 後でリファクタリングする.
- return (grid.mimic || grid.cave_has_flag(TerrainCharacteristics::SECRET)) && grid.get_terrain().is_closed_door();
-}
-
/*!
* @brief 指定された座標のマスが現在照らされているかを返す。 / Check for "local" illumination
* @param y y座標
diff --git a/src/grid/grid.h b/src/grid/grid.h
index 0d6501cf73..9ca06a4ef0 100644
--- a/src/grid/grid.h
+++ b/src/grid/grid.h
@@ -67,7 +67,6 @@ class MonraceDefinition;
enum class GridCountKind;
enum class TerrainCharacteristics;
bool new_player_spot(PlayerType *player_ptr);
-bool is_hidden_door(PlayerType *player_ptr, const Grid &grid);
bool player_can_enter(PlayerType *player_ptr, FEAT_IDX feature, BIT_FLAGS16 mode);
bool feat_uses_special(FEAT_IDX f_idx);
void update_local_illumination(PlayerType *player_ptr, POSITION y, POSITION x);
diff --git a/src/player/player-move.cpp b/src/player/player-move.cpp
index 6aa0ed8ce3..2f669ebaf3 100644
--- a/src/player/player-move.cpp
+++ b/src/player/player-move.cpp
@@ -73,7 +73,7 @@ static void discover_hidden_things(PlayerType *player_ptr, const Pos2D &pos)
disturb(player_ptr, false, true);
}
- if (is_hidden_door(player_ptr, grid)) {
+ if (grid.is_hidden_door()) {
msg_print(_("隠しドアを発見した。", "You have found a secret door."));
disclose_grid(player_ptr, pos.y, pos.x);
disturb(player_ptr, false, false);
diff --git a/src/system/grid-type-definition.cpp b/src/system/grid-type-definition.cpp
index 60532272e7..546428ea34 100644
--- a/src/system/grid-type-definition.cpp
+++ b/src/system/grid-type-definition.cpp
@@ -101,6 +101,16 @@ bool Grid::is_rune_explosion() const
return this->is_object() && TerrainList::get_instance().get_terrain(this->mimic).flags.has(TerrainCharacteristics::RUNE_EXPLOSION);
}
+/*!
+ * @brief マスに隠されたドアがあるかの判定
+ * @return 隠されたドアがあるか否か
+ */
+bool Grid::is_hidden_door() const
+{
+ const auto is_secret = (this->mimic > 0) || this->cave_has_flag(TerrainCharacteristics::SECRET);
+ return is_secret && this->get_terrain().is_closed_door();
+}
+
bool Grid::has_monster() const
{
return is_monster(this->m_idx);
diff --git a/src/system/grid-type-definition.h b/src/system/grid-type-definition.h
index e0845a7312..916c3f466d 100644
--- a/src/system/grid-type-definition.h
+++ b/src/system/grid-type-definition.h
@@ -79,6 +79,7 @@ class Grid {
bool is_mirror() const;
bool is_rune_protection() const;
bool is_rune_explosion() const;
+ bool is_hidden_door() const;
bool has_monster() const;
uint8_t get_cost(GridFlow gf) const;
uint8_t get_distance(GridFlow gf) const;
From cec1a17f6cec13ca2e9eb378791c1843b39fd2a8 Mon Sep 17 00:00:00 2001
From: Hourier <66951241+Hourier@users.noreply.github.com>
Date: Sat, 16 Nov 2024 17:15:15 +0900
Subject: [PATCH 07/11] =?UTF-8?q?[Refactor]=20#4624=20baseitem-definition.?=
=?UTF-8?q?h=20=E3=81=8B=E3=82=89angband.h=20=E3=81=B8=E3=81=AE=E5=8F=82?=
=?UTF-8?q?=E7=85=A7=E3=82=92=E5=A4=96=E3=81=97=E3=81=9F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/system/baseitem/baseitem-definition.cpp | 2 +-
src/system/baseitem/baseitem-definition.h | 23 +++++++++++++--------
2 files changed, 15 insertions(+), 10 deletions(-)
diff --git a/src/system/baseitem/baseitem-definition.cpp b/src/system/baseitem/baseitem-definition.cpp
index 831e682d33..75f4d1f10c 100644
--- a/src/system/baseitem/baseitem-definition.cpp
+++ b/src/system/baseitem/baseitem-definition.cpp
@@ -1,5 +1,5 @@
/*!
- * @brief ベースアイテム定義
+ * @brief ベースアイテム定義の実装
* @date 2024/11/16
* @author deskull, Hourier
*/
diff --git a/src/system/baseitem/baseitem-definition.h b/src/system/baseitem/baseitem-definition.h
index 915ca3fcee..9f5c3195ce 100644
--- a/src/system/baseitem/baseitem-definition.h
+++ b/src/system/baseitem/baseitem-definition.h
@@ -1,8 +1,13 @@
+/*!
+ * @brief ベースアイテムの定義
+ * @date 2024/11/16
+ * @author deskull, Hourier
+ */
+
#pragma once
#include "object-enchant/tr-flags.h"
#include "object-enchant/trg-types.h"
-#include "system/angband.h"
#include "system/baseitem/baseitem-key.h"
#include "util/dice.h"
#include "util/flag-group.h"
@@ -23,21 +28,21 @@ class BaseitemDefinition {
BaseitemKey bi_key;
- PARAMETER_VALUE pval{}; /*!< ベースアイテムのpval(能力修正共通値) Object extra info */
+ short pval{}; /*!< ベースアイテムのpval(能力修正共通値) Object extra info */
- HIT_PROB to_h{}; /*!< ベースアイテムの命中修正値 / Bonus to hit */
+ short to_h{}; /*!< ベースアイテムの命中修正値 / Bonus to hit */
int to_d{}; /*!< ベースアイテムのダメージ修正値 / Bonus to damage */
- ARMOUR_CLASS to_a{}; /*!< ベースアイテムのAC修正値 / Bonus to armor */
- ARMOUR_CLASS ac{}; /*!< ベースアイテムのAC基本値 / Base armor */
+ short to_a{}; /*!< ベースアイテムのAC修正値 / Bonus to armor */
+ short ac{}; /*!< ベースアイテムのAC基本値 / Base armor */
Dice damage_dice{}; /*!< ダメージダイス */
- WEIGHT weight{}; /*!< ベースアイテムの重量 / Weight */
- PRICE cost{}; /*!< ベースアイテムの基本価値 / Object "base cost" */
+ int weight{}; /*!< ベースアイテムの重量 / Weight */
+ int cost{}; /*!< ベースアイテムの基本価値 / Object "base cost" */
TrFlags flags{}; /*!< ベースアイテムの基本特性ビット配列 / Flags */
EnumClassFlagGroup gen_flags; /*!< ベースアイテムの生成特性ビット配列 / flags for generate */
- DEPTH level{}; /*!< ベースアイテムの基本生成階 / Level */
+ int level{}; /*!< ベースアイテムの基本生成階 / Level */
struct alloc_table {
int level; /*!< ベースアイテムの生成階 */
@@ -58,7 +63,7 @@ class BaseitemDefinition {
DisplaySymbol symbol_config; //!< ユーザ個別の設定シンボル (色/文字).
- IDX flavor{}; /*!< 未鑑定名の何番目を当てるか(0は未鑑定名なし) / Special object flavor (or zero) */
+ short flavor{}; /*!< 未鑑定名の何番目を当てるか(0は未鑑定名なし) / Special object flavor (or zero) */
bool aware{}; /*!< ベースアイテムが鑑定済かどうか / The player is "aware" of the item's effects */
bool tried{}; /*!< ベースアイテムを未鑑定のまま試したことがあるか / The player has "tried" one of the items */
From ec461a983c2e56d2e188d6de66b6c37b607da519 Mon Sep 17 00:00:00 2001
From: Hourier <66951241+Hourier@users.noreply.github.com>
Date: Sat, 16 Nov 2024 17:26:43 +0900
Subject: [PATCH 08/11] =?UTF-8?q?[Refactor]=20#4624=20tried/aware/symbol?=
=?UTF-8?q?=5Fconfig=20=E3=81=AE=E3=83=AA=E3=82=BB=E3=83=83=E3=83=88?=
=?UTF-8?q?=E5=87=A6=E7=90=86=E3=82=92BaseitemInfo=20=E3=81=B8=E7=A7=BB?=
=?UTF-8?q?=E3=81=97=E3=81=9F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/item-info/flavor-initializer.cpp | 2 +-
src/perception/object-perception.cpp | 2 +-
src/system/baseitem/baseitem-definition.cpp | 20 +++++++++++++++-----
src/system/baseitem/baseitem-definition.h | 5 +++--
src/system/baseitem/baseitem-list.cpp | 8 ++++----
src/system/item-entity.cpp | 2 +-
src/wizard/wizard-item-modifier.cpp | 2 +-
7 files changed, 26 insertions(+), 15 deletions(-)
diff --git a/src/item-info/flavor-initializer.cpp b/src/item-info/flavor-initializer.cpp
index fa883edb72..af75e99a8e 100644
--- a/src/item-info/flavor-initializer.cpp
+++ b/src/item-info/flavor-initializer.cpp
@@ -36,7 +36,7 @@ void initialize_items_flavor()
}
if (!baseitem.flavor) {
- baseitem.mark_as_aware();
+ baseitem.mark_awareness(true);
}
baseitem.decide_easy_know();
diff --git a/src/perception/object-perception.cpp b/src/perception/object-perception.cpp
index 3963d84bed..dd52a7bafd 100644
--- a/src/perception/object-perception.cpp
+++ b/src/perception/object-perception.cpp
@@ -17,7 +17,7 @@ void object_aware(PlayerType *player_ptr, const ItemEntity *o_ptr)
{
const bool is_already_awared = o_ptr->is_aware();
auto &baseitem = o_ptr->get_baseitem();
- baseitem.mark_as_aware();
+ baseitem.mark_awareness(true);
// 以下、playrecordに記録しない場合はreturnする
if (!record_ident) {
diff --git a/src/system/baseitem/baseitem-definition.cpp b/src/system/baseitem/baseitem-definition.cpp
index 75f4d1f10c..cc25464673 100644
--- a/src/system/baseitem/baseitem-definition.cpp
+++ b/src/system/baseitem/baseitem-definition.cpp
@@ -107,14 +107,24 @@ void BaseitemDefinition::decide_easy_know()
}
/*!
- * @brief オブジェクトを試行済にする
+ * @brief 試行状態を変える
+ * @param state trueなら試行済、falseなら未試行に変える
*/
-void BaseitemDefinition::mark_as_tried()
+void BaseitemDefinition::mark_trial(bool state)
{
- this->tried = true;
+ this->tried = state;
}
-void BaseitemDefinition::mark_as_aware()
+/*!
+ * @brief 鑑定状態を変える
+ * @param state trueなら鑑定済、falseなら未鑑定に変える
+ */
+void BaseitemDefinition::mark_awareness(bool state)
+{
+ this->aware = state;
+}
+
+void BaseitemDefinition::reset_visual()
{
- this->aware = true;
+ this->symbol_config = this->symbol_definition;
}
diff --git a/src/system/baseitem/baseitem-definition.h b/src/system/baseitem/baseitem-definition.h
index 9f5c3195ce..6d328dd9c5 100644
--- a/src/system/baseitem/baseitem-definition.h
+++ b/src/system/baseitem/baseitem-definition.h
@@ -67,6 +67,7 @@ class BaseitemDefinition {
bool aware{}; /*!< ベースアイテムが鑑定済かどうか / The player is "aware" of the item's effects */
bool tried{}; /*!< ベースアイテムを未鑑定のまま試したことがあるか / The player has "tried" one of the items */
- void mark_as_tried();
- void mark_as_aware();
+ void mark_trial(bool state);
+ void mark_awareness(bool state);
+ void reset_visual();
};
diff --git a/src/system/baseitem/baseitem-list.cpp b/src/system/baseitem/baseitem-list.cpp
index 22c557c354..9c93b4e114 100644
--- a/src/system/baseitem/baseitem-list.cpp
+++ b/src/system/baseitem/baseitem-list.cpp
@@ -239,7 +239,7 @@ int BaseitemList::lookup_gold_offset(short bi_id) const
void BaseitemList::reset_all_visuals()
{
for (auto &baseitem : this->baseitems) {
- baseitem.symbol_config = baseitem.symbol_definition;
+ baseitem.reset_visual();
}
}
@@ -250,8 +250,8 @@ void BaseitemList::reset_all_visuals()
void BaseitemList::reset_identification_flags()
{
for (auto &baseitem : this->baseitems) {
- baseitem.tried = false;
- baseitem.aware = false;
+ baseitem.mark_trial(false);
+ baseitem.mark_awareness(false);
}
}
@@ -265,7 +265,7 @@ void BaseitemList::mark_common_items_as_aware()
bi_keys.emplace_back(ItemKindType::POTION, SV_POTION_WATER);
bi_keys.emplace_back(ItemKindType::STAFF, SV_STAFF_NOTHING);
for (const auto &bi_key : bi_keys) {
- this->lookup_baseitem(bi_key).mark_as_aware();
+ this->lookup_baseitem(bi_key).mark_awareness(true);
}
}
diff --git a/src/system/item-entity.cpp b/src/system/item-entity.cpp
index e012fc1182..83275a0f78 100644
--- a/src/system/item-entity.cpp
+++ b/src/system/item-entity.cpp
@@ -1260,7 +1260,7 @@ void ItemEntity::mark_as_known()
*/
void ItemEntity::mark_as_tried() const
{
- this->get_baseitem().mark_as_tried();
+ this->get_baseitem().mark_trial(true);
}
/*!
diff --git a/src/wizard/wizard-item-modifier.cpp b/src/wizard/wizard-item-modifier.cpp
index ef25a60653..cd9c2cf3ba 100644
--- a/src/wizard/wizard-item-modifier.cpp
+++ b/src/wizard/wizard-item-modifier.cpp
@@ -278,7 +278,7 @@ void wiz_identify_full_inventory(PlayerType *player_ptr)
}
auto &baseitem = o_ptr->get_baseitem();
- baseitem.mark_as_aware(); //!< @note 記録には残さないためTRUEを立てるのみ
+ baseitem.mark_awareness(true); //!< @note 記録には残さない.
set_bits(o_ptr->ident, IDENT_KNOWN | IDENT_FULL_KNOWN);
o_ptr->marked.set(OmType::TOUCHED);
}
From 8ceb6fd905309734bdf0cd12858576cfd1e21562 Mon Sep 17 00:00:00 2001
From: Hourier <66951241+Hourier@users.noreply.github.com>
Date: Sat, 16 Nov 2024 17:47:11 +0900
Subject: [PATCH 09/11] =?UTF-8?q?[Refactor]=20#4624=20Baseitem::level=20?=
=?UTF-8?q?=E3=82=92=E9=96=93=E6=8E=A5=E7=9A=84=E3=81=AB=E5=8F=96=E5=BE=97?=
=?UTF-8?q?=E3=81=99=E3=82=8BItemEntity::get=5Fbaseitem=5Flevel()=20?=
=?UTF-8?q?=E3=82=92=E5=AE=9F=E8=A3=85=E3=81=97=E3=81=A6=E3=82=AB=E3=83=97?=
=?UTF-8?q?=E3=82=BB=E3=83=AB=E5=8C=96=E3=82=92=E5=90=91=E4=B8=8A=E3=81=97?=
=?UTF-8?q?=E3=81=9F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/cmd-item/cmd-eat.cpp | 5 ++---
src/core/object-compressor.cpp | 3 +--
src/floor/floor-events.cpp | 7 +++----
src/market/building-recharger.cpp | 10 +++++-----
src/mind/mind-mage.cpp | 10 +++++-----
src/monster-attack/monster-eating.cpp | 2 +-
src/object-activation/activation-util.cpp | 3 +--
src/object-enchant/others/apply-magic-others.cpp | 6 +++---
src/object-use/quaff/quaff-execution.cpp | 3 +--
src/object-use/read/read-execution.cpp | 5 ++---
src/object-use/use-execution.cpp | 11 +++++------
src/object-use/zaprod-execution.cpp | 6 +++---
src/object-use/zapwand-execution.cpp | 11 +++++------
src/racial/racial-android.cpp | 3 +--
src/spell-kind/magic-item-recharger.cpp | 11 ++++++-----
src/system/item-entity.cpp | 5 +++++
src/system/item-entity.h | 1 +
src/wizard/items-spoiler.cpp | 2 +-
src/wizard/wizard-item-modifier.cpp | 2 +-
19 files changed, 52 insertions(+), 54 deletions(-)
diff --git a/src/cmd-item/cmd-eat.cpp b/src/cmd-item/cmd-eat.cpp
index 0a9495e7c2..6218648523 100644
--- a/src/cmd-item/cmd-eat.cpp
+++ b/src/cmd-item/cmd-eat.cpp
@@ -41,7 +41,6 @@
#include "status/experience.h"
#include "sv-definition/sv-food-types.h"
#include "sv-definition/sv-other-types.h"
-#include "system/baseitem/baseitem-definition.h"
#include "system/item-entity.h"
#include "system/monster-race-info.h"
#include "system/player-type-definition.h"
@@ -228,7 +227,7 @@ void exe_eat_food(PlayerType *player_ptr, INVENTORY_IDX i_idx)
sound(SOUND_EAT);
PlayerEnergy(player_ptr).set_player_turn_energy(100);
- const auto lev = o_ptr->get_baseitem().level;
+ const auto level = o_ptr->get_baseitem_level();
/* Identity not known yet */
const auto &bi_key = o_ptr->bi_key;
@@ -264,7 +263,7 @@ void exe_eat_food(PlayerType *player_ptr, INVENTORY_IDX i_idx)
/* The player is now aware of the object */
if (ident && !o_ptr->is_aware()) {
object_aware(player_ptr, o_ptr);
- gain_exp(player_ptr, (lev + (player_ptr->lev >> 1)) / player_ptr->lev);
+ gain_exp(player_ptr, (level + (player_ptr->lev >> 1)) / player_ptr->lev);
}
static constexpr auto flags_swrf = {
diff --git a/src/core/object-compressor.cpp b/src/core/object-compressor.cpp
index c62a415681..fda13d1032 100644
--- a/src/core/object-compressor.cpp
+++ b/src/core/object-compressor.cpp
@@ -3,7 +3,6 @@
#include "floor/floor-object.h"
#include "floor/geometry.h"
#include "grid/grid.h"
-#include "system/baseitem/baseitem-definition.h"
#include "system/floor-type-definition.h"
#include "system/item-entity.h"
#include "system/monster-entity.h"
@@ -72,7 +71,7 @@ void compact_objects(PlayerType *player_ptr, int size)
for (OBJECT_IDX i = 1; i < floor_ptr->o_max; i++) {
o_ptr = &floor_ptr->o_list[i];
- if (!o_ptr->is_valid() || (o_ptr->get_baseitem().level > cur_lev)) {
+ if (!o_ptr->is_valid() || (o_ptr->get_baseitem_level() > cur_lev)) {
continue;
}
diff --git a/src/floor/floor-events.cpp b/src/floor/floor-events.cpp
index e74e47b2ea..132da3fb1e 100644
--- a/src/floor/floor-events.cpp
+++ b/src/floor/floor-events.cpp
@@ -28,7 +28,6 @@
#include "sv-definition/sv-protector-types.h"
#include "sv-definition/sv-ring-types.h"
#include "system/angband-system.h"
-#include "system/baseitem/baseitem-definition.h"
#include "system/dungeon-info.h"
#include "system/floor-type-definition.h"
#include "system/grid-type-definition.h"
@@ -231,9 +230,9 @@ static byte get_dungeon_feeling(PlayerType *player_ptr)
delta += 15 * base;
}
- const auto &baseitem = o_ptr->get_baseitem();
- if (!o_ptr->is_cursed() && !o_ptr->is_broken() && baseitem.level > floor_ptr->dun_level) {
- delta += (baseitem.level - floor_ptr->dun_level) * base;
+ const auto item_level = o_ptr->get_baseitem_level();
+ if (!o_ptr->is_cursed() && !o_ptr->is_broken() && item_level > floor_ptr->dun_level) {
+ delta += (item_level - floor_ptr->dun_level) * base;
}
rating += rating_boost(delta);
diff --git a/src/market/building-recharger.cpp b/src/market/building-recharger.cpp
index f4b3aeae5f..ee0fd11ec0 100644
--- a/src/market/building-recharger.cpp
+++ b/src/market/building-recharger.cpp
@@ -63,14 +63,14 @@ void building_recharge(PlayerType *player_ptr)
return;
}
- const auto &baseitem = o_ptr->get_baseitem();
- const auto lev = baseitem.level;
+ const auto item_level = o_ptr->get_baseitem_level();
const auto tval = o_ptr->bi_key.tval();
+ const auto &baseitem = o_ptr->get_baseitem();
int price;
switch (tval) {
case ItemKindType::ROD:
if (o_ptr->timeout > 0) {
- price = (lev * 50 * o_ptr->timeout) / baseitem.pval;
+ price = (item_level * 50 * o_ptr->timeout) / baseitem.pval;
break;
}
@@ -192,10 +192,10 @@ void building_recharge_all(PlayerType *player_ptr)
}
const auto &baseitem = item.get_baseitem();
- const auto lev = baseitem.level;
+ const auto item_level = item.get_baseitem_level();
switch (item.bi_key.tval()) {
case ItemKindType::ROD:
- price = (lev * 50 * item.timeout) / baseitem.pval;
+ price = (item_level * 50 * item.timeout) / baseitem.pval;
break;
case ItemKindType::STAFF:
price = (baseitem.cost / 10) * item.number;
diff --git a/src/mind/mind-mage.cpp b/src/mind/mind-mage.cpp
index ee1c40eb63..4010c28375 100644
--- a/src/mind/mind-mage.cpp
+++ b/src/mind/mind-mage.cpp
@@ -38,24 +38,24 @@ bool eat_magic(PlayerType *player_ptr, int power)
}
const auto &baseitem = o_ptr->get_baseitem();
- const auto lev = baseitem.level;
+ const auto item_level = o_ptr->get_baseitem_level();
const auto tval = o_ptr->bi_key.tval();
auto recharge_strength = 0;
auto is_eating_successful = true;
if (tval == ItemKindType::ROD) {
- recharge_strength = ((power > lev / 2) ? (power - lev / 2) : 0) / 5;
+ recharge_strength = ((power > item_level / 2) ? (power - item_level / 2) : 0) / 5;
if (one_in_(recharge_strength)) {
is_eating_successful = false;
} else {
if (o_ptr->timeout > (o_ptr->number - 1) * baseitem.pval) {
msg_print(_("充填中のロッドから魔力を吸収することはできません。", "You can't absorb energy from a discharged rod."));
} else {
- player_ptr->csp += lev;
+ player_ptr->csp += item_level;
o_ptr->timeout += baseitem.pval;
}
}
} else {
- recharge_strength = (100 + power - lev) / 15;
+ recharge_strength = (100 + power - item_level) / 15;
if (recharge_strength < 0) {
recharge_strength = 0;
}
@@ -64,7 +64,7 @@ bool eat_magic(PlayerType *player_ptr, int power)
is_eating_successful = false;
} else {
if (o_ptr->pval > 0) {
- player_ptr->csp += lev / 2;
+ player_ptr->csp += item_level / 2;
o_ptr->pval--;
if ((tval == ItemKindType::STAFF) && (i_idx >= 0) && (o_ptr->number > 1)) {
diff --git a/src/monster-attack/monster-eating.cpp b/src/monster-attack/monster-eating.cpp
index ecd5abf156..ec6be7031c 100644
--- a/src/monster-attack/monster-eating.cpp
+++ b/src/monster-attack/monster-eating.cpp
@@ -242,7 +242,7 @@ bool process_un_power(PlayerType *player_ptr, MonsterAttackPlayer *monap_ptr)
}
monap_ptr->obvious = true;
- auto recovery = drain * baseitem.level;
+ auto recovery = drain * monap_ptr->o_ptr->get_baseitem_level();
const auto tval = monap_ptr->o_ptr->bi_key.tval();
if (tval == ItemKindType::STAFF) {
recovery *= monap_ptr->o_ptr->number;
diff --git a/src/object-activation/activation-util.cpp b/src/object-activation/activation-util.cpp
index 788f18d0b4..480705b0d9 100644
--- a/src/object-activation/activation-util.cpp
+++ b/src/object-activation/activation-util.cpp
@@ -1,12 +1,11 @@
#include "object-activation/activation-util.h"
#include "object/object-info.h"
-#include "system/baseitem/baseitem-definition.h"
#include "system/item-entity.h"
#include "system/player-type-definition.h"
ae_type *initialize_ae_type(PlayerType *player_ptr, ae_type *ae_ptr, const INVENTORY_IDX i_idx)
{
ae_ptr->o_ptr = ref_item(player_ptr, i_idx);
- ae_ptr->lev = ae_ptr->o_ptr->get_baseitem().level;
+ ae_ptr->lev = ae_ptr->o_ptr->get_baseitem_level();
return ae_ptr;
}
diff --git a/src/object-enchant/others/apply-magic-others.cpp b/src/object-enchant/others/apply-magic-others.cpp
index 5afbfbb5ff..d50139562d 100644
--- a/src/object-enchant/others/apply-magic-others.cpp
+++ b/src/object-enchant/others/apply-magic-others.cpp
@@ -198,12 +198,12 @@ void OtherItemsEnchanter::generate_statue()
*/
void OtherItemsEnchanter::generate_chest()
{
- auto obj_level = this->o_ptr->get_baseitem().level;
- if (obj_level <= 0) {
+ const auto item_level = this->o_ptr->get_baseitem_level();
+ if (item_level <= 0) {
return;
}
- this->o_ptr->pval = randnum1(obj_level);
+ this->o_ptr->pval = randnum1(item_level);
if (this->o_ptr->bi_key.sval() == SV_CHEST_KANDUME) {
this->o_ptr->pval = 6;
}
diff --git a/src/object-use/quaff/quaff-execution.cpp b/src/object-use/quaff/quaff-execution.cpp
index 0dfaa1b7d8..c52e684929 100644
--- a/src/object-use/quaff/quaff-execution.cpp
+++ b/src/object-use/quaff/quaff-execution.cpp
@@ -23,7 +23,6 @@
#include "spell-realm/spells-hex.h"
#include "spell-realm/spells-song.h"
#include "status/experience.h"
-#include "system/baseitem/baseitem-definition.h"
#include "system/item-entity.h"
#include "system/player-type-definition.h"
#include "system/redrawing-flags-updater.h"
@@ -71,7 +70,7 @@ void ObjectQuaffEntity::execute(INVENTORY_IDX i_idx)
item.mark_as_tried();
if (ident && !item.is_aware()) {
object_aware(this->player_ptr, &item);
- gain_exp(this->player_ptr, (item.get_baseitem().level + (this->player_ptr->lev >> 1)) / this->player_ptr->lev);
+ gain_exp(this->player_ptr, (item.get_baseitem_level() + (this->player_ptr->lev >> 1)) / this->player_ptr->lev);
}
static constexpr auto flags = {
diff --git a/src/object-use/read/read-execution.cpp b/src/object-use/read/read-execution.cpp
index 901b478b7c..c16f985435 100644
--- a/src/object-use/read/read-execution.cpp
+++ b/src/object-use/read/read-execution.cpp
@@ -20,7 +20,6 @@
#include "spell-realm/spells-hex.h"
#include "spell-realm/spells-song.h"
#include "status/experience.h"
-#include "system/baseitem/baseitem-definition.h"
#include "system/item-entity.h"
#include "system/player-type-definition.h"
#include "system/redrawing-flags-updater.h"
@@ -119,6 +118,6 @@ void ObjectReadEntity::gain_exp_from_item_use(ItemEntity *o_ptr, bool is_identif
}
object_aware(this->player_ptr, o_ptr);
- auto lev = o_ptr->get_baseitem().level;
- gain_exp(this->player_ptr, (lev + (this->player_ptr->lev >> 1)) / this->player_ptr->lev);
+ const auto item_level = o_ptr->get_baseitem_level();
+ gain_exp(this->player_ptr, (item_level + (this->player_ptr->lev >> 1)) / this->player_ptr->lev);
}
diff --git a/src/object-use/use-execution.cpp b/src/object-use/use-execution.cpp
index 6b705091d7..4e5b5add84 100644
--- a/src/object-use/use-execution.cpp
+++ b/src/object-use/use-execution.cpp
@@ -20,7 +20,6 @@
#include "player-base/player-class.h"
#include "player-status/player-energy.h"
#include "status/experience.h"
-#include "system/baseitem/baseitem-definition.h"
#include "system/item-entity.h"
#include "system/player-type-definition.h"
#include "system/redrawing-flags-updater.h"
@@ -58,9 +57,9 @@ void ObjectUseEntity::execute()
return;
}
- auto lev = o_ptr->get_baseitem().level;
- if (lev > 50) {
- lev = 50 + (lev - 50) / 2;
+ auto item_level = o_ptr->get_baseitem_level();
+ if (item_level > 50) {
+ item_level = 50 + (item_level - 50) / 2;
}
auto chance = this->player_ptr->skill_dev;
@@ -68,7 +67,7 @@ void ObjectUseEntity::execute()
chance = chance / 2;
}
- chance = chance - lev;
+ chance = chance - item_level;
if ((chance < USE_DEVICE) && one_in_(USE_DEVICE - chance + 1)) {
chance = USE_DEVICE;
}
@@ -119,7 +118,7 @@ void ObjectUseEntity::execute()
o_ptr->mark_as_tried();
if (ident && !o_ptr->is_aware()) {
object_aware(this->player_ptr, o_ptr);
- gain_exp(this->player_ptr, (lev + (this->player_ptr->lev >> 1)) / this->player_ptr->lev);
+ gain_exp(this->player_ptr, (item_level + (this->player_ptr->lev >> 1)) / this->player_ptr->lev);
}
static constexpr auto flags_swrf = {
diff --git a/src/object-use/zaprod-execution.cpp b/src/object-use/zaprod-execution.cpp
index 8f7dbe6fbb..0e1699f63f 100644
--- a/src/object-use/zaprod-execution.cpp
+++ b/src/object-use/zaprod-execution.cpp
@@ -63,13 +63,13 @@ void ObjectZapRodEntity::execute(INVENTORY_IDX i_idx)
return;
}
- auto lev = o_ptr->get_baseitem().level;
+ const auto item_level = o_ptr->get_baseitem_level();
auto chance = this->player_ptr->skill_dev;
if (this->player_ptr->effects()->confusion().is_confused()) {
chance = chance / 2;
}
- auto fail = lev + 5;
+ auto fail = item_level + 5;
if (chance > fail) {
fail -= (chance - fail) * 2;
} else {
@@ -141,7 +141,7 @@ void ObjectZapRodEntity::execute(INVENTORY_IDX i_idx)
o_ptr->mark_as_tried();
if ((ident != 0) && !o_ptr->is_aware()) {
object_aware(this->player_ptr, o_ptr);
- gain_exp(this->player_ptr, (lev + (this->player_ptr->lev >> 1)) / this->player_ptr->lev);
+ gain_exp(this->player_ptr, (item_level + (this->player_ptr->lev >> 1)) / this->player_ptr->lev);
}
static constexpr auto flags_swrf = {
diff --git a/src/object-use/zapwand-execution.cpp b/src/object-use/zapwand-execution.cpp
index 3f2f7f6381..47b8a2b611 100644
--- a/src/object-use/zapwand-execution.cpp
+++ b/src/object-use/zapwand-execution.cpp
@@ -16,7 +16,6 @@
#include "player-status/player-energy.h"
#include "status/experience.h"
#include "sv-definition/sv-wand-types.h"
-#include "system/baseitem/baseitem-definition.h"
#include "system/item-entity.h"
#include "system/player-type-definition.h"
#include "system/redrawing-flags-updater.h"
@@ -62,9 +61,9 @@ void ObjectZapWandEntity::execute(INVENTORY_IDX i_idx)
return;
}
- auto lev = o_ptr->get_baseitem().level;
- if (lev > 50) {
- lev = 50 + (lev - 50) / 2;
+ auto item_level = o_ptr->get_baseitem_level();
+ if (item_level > 50) {
+ item_level = 50 + (item_level - 50) / 2;
}
auto chance = this->player_ptr->skill_dev;
@@ -72,7 +71,7 @@ void ObjectZapWandEntity::execute(INVENTORY_IDX i_idx)
chance = chance / 2;
}
- chance = chance - lev;
+ chance = chance - item_level;
if ((chance < USE_DEVICE) && one_in_(USE_DEVICE - chance + 1)) {
chance = USE_DEVICE;
}
@@ -122,7 +121,7 @@ void ObjectZapWandEntity::execute(INVENTORY_IDX i_idx)
o_ptr->mark_as_tried();
if (ident && !o_ptr->is_aware()) {
object_aware(this->player_ptr, o_ptr);
- gain_exp(this->player_ptr, (lev + (this->player_ptr->lev >> 1)) / this->player_ptr->lev);
+ gain_exp(this->player_ptr, (item_level + (this->player_ptr->lev >> 1)) / this->player_ptr->lev);
}
static constexpr auto flags_swrf = {
diff --git a/src/racial/racial-android.cpp b/src/racial/racial-android.cpp
index 36adb01869..84fe4c1782 100644
--- a/src/racial/racial-android.cpp
+++ b/src/racial/racial-android.cpp
@@ -15,7 +15,6 @@
#include "sv-definition/sv-protector-types.h"
#include "sv-definition/sv-weapon-types.h"
#include "system/artifact-type-definition.h"
-#include "system/baseitem/baseitem-definition.h"
#include "system/item-entity.h"
#include "system/player-type-definition.h"
#include "target/target-getter.h"
@@ -69,7 +68,7 @@ void calc_android_exp(PlayerType *player_ptr)
ItemEntity forge;
auto *q_ptr = &forge;
uint32_t value, exp;
- DEPTH level = std::max(o_ptr->get_baseitem().level - 8, 1);
+ DEPTH level = std::max(o_ptr->get_baseitem_level() - 8, 1);
if ((i == INVEN_MAIN_RING) || (i == INVEN_SUB_RING) || (i == INVEN_NECK) || (i == INVEN_LITE)) {
continue;
diff --git a/src/spell-kind/magic-item-recharger.cpp b/src/spell-kind/magic-item-recharger.cpp
index 8fd8d51492..bc81b0ccfd 100644
--- a/src/spell-kind/magic-item-recharger.cpp
+++ b/src/spell-kind/magic-item-recharger.cpp
@@ -59,15 +59,14 @@ bool recharge(PlayerType *player_ptr, int power)
return false;
}
- const auto &baseitem = o_ptr->get_baseitem();
- const auto lev = baseitem.level;
+ const auto item_level = o_ptr->get_baseitem_level();
TIME_EFFECT recharge_amount;
int recharge_strength;
auto is_recharge_successful = true;
const auto tval = o_ptr->bi_key.tval();
if (tval == ItemKindType::ROD) {
- recharge_strength = ((power > lev / 2) ? (power - lev / 2) : 0) / 5;
+ recharge_strength = ((power > item_level / 2) ? (power - item_level / 2) : 0) / 5;
if (one_in_(recharge_strength)) {
is_recharge_successful = false;
} else {
@@ -80,9 +79,9 @@ bool recharge(PlayerType *player_ptr, int power)
}
} else {
if ((tval == ItemKindType::WAND) && (o_ptr->number > 1)) {
- recharge_strength = (100 + power - lev - (8 * o_ptr->pval / o_ptr->number)) / 15;
+ recharge_strength = (100 + power - item_level - (8 * o_ptr->pval / o_ptr->number)) / 15;
} else {
- recharge_strength = (100 + power - lev - (8 * o_ptr->pval)) / 15;
+ recharge_strength = (100 + power - item_level - (8 * o_ptr->pval)) / 15;
}
if (recharge_strength < 0) {
@@ -92,6 +91,7 @@ bool recharge(PlayerType *player_ptr, int power)
if (one_in_(recharge_strength)) {
is_recharge_successful = false;
} else {
+ const auto &baseitem = o_ptr->get_baseitem();
recharge_amount = randnum1(1 + baseitem.pval / 2);
if ((tval == ItemKindType::WAND) && (o_ptr->number > 1)) {
recharge_amount += (randint1(recharge_amount * (o_ptr->number - 1))) / 2;
@@ -205,6 +205,7 @@ bool recharge(PlayerType *player_ptr, int power)
}
if (tval == ItemKindType::ROD) {
+ const auto &baseitem = o_ptr->get_baseitem();
o_ptr->timeout = (o_ptr->number - 1) * baseitem.pval;
}
diff --git a/src/system/item-entity.cpp b/src/system/item-entity.cpp
index 83275a0f78..b9261f45c0 100644
--- a/src/system/item-entity.cpp
+++ b/src/system/item-entity.cpp
@@ -1202,6 +1202,11 @@ bool ItemEntity::is_similar_for_store(const ItemEntity &other) const
return true;
}
+int ItemEntity::get_baseitem_level() const
+{
+ return this->get_baseitem().level;
+}
+
std::string ItemEntity::build_timeout_description(const ActivationType &act) const
{
const auto description = act.build_timeout_description();
diff --git a/src/system/item-entity.h b/src/system/item-entity.h
index 8755c52ec2..2ed558857d 100644
--- a/src/system/item-entity.h
+++ b/src/system/item-entity.h
@@ -163,6 +163,7 @@ class ItemEntity {
bool is_similar(const ItemEntity &other) const;
int is_similar_part(const ItemEntity &other) const;
bool is_similar_for_store(const ItemEntity &other) const;
+ int get_baseitem_level() const;
void mark_as_known();
void mark_as_tried() const;
diff --git a/src/wizard/items-spoiler.cpp b/src/wizard/items-spoiler.cpp
index 1fb1a97a92..bc34e3f18a 100644
--- a/src/wizard/items-spoiler.cpp
+++ b/src/wizard/items-spoiler.cpp
@@ -25,7 +25,7 @@
*/
static std::pair get_info(const ItemEntity &item)
{
- const auto level = item.get_baseitem().level;
+ const auto level = item.get_baseitem_level();
const auto price = item.calc_price();
return { level, price };
}
diff --git a/src/wizard/wizard-item-modifier.cpp b/src/wizard/wizard-item-modifier.cpp
index cd9c2cf3ba..661681ad5d 100644
--- a/src/wizard/wizard-item-modifier.cpp
+++ b/src/wizard/wizard-item-modifier.cpp
@@ -400,7 +400,7 @@ static void wiz_display_item(PlayerType *player_ptr, ItemEntity *o_ptr)
auto line = 4;
const auto &bi_key = o_ptr->bi_key;
- const auto item_level = o_ptr->get_baseitem().level;
+ const auto item_level = o_ptr->get_baseitem_level();
prt(format("kind = %-5d level = %-4d tval = %-5d sval = %-5d", o_ptr->bi_id, item_level, enum2i(bi_key.tval()), *bi_key.sval()), line, j);
prt(format("number = %-3d wgt = %-6d ac = %-5d damage = %s", o_ptr->number, o_ptr->weight, o_ptr->ac, o_ptr->damage_dice.to_string().data()), ++line, j);
prt(format("pval = %-5d toac = %-5d tohit = %-4d todam = %-4d", o_ptr->pval, o_ptr->to_a, o_ptr->to_h, o_ptr->to_d), ++line, j);
From e6c79a9e261c60025df1e908ddb6de5123ce0c60 Mon Sep 17 00:00:00 2001
From: Hourier <66951241+Hourier@users.noreply.github.com>
Date: Sat, 16 Nov 2024 18:02:03 +0900
Subject: [PATCH 10/11] =?UTF-8?q?[Refactor]=20#4624=20Baseitem::pval=20?=
=?UTF-8?q?=E3=82=92=E9=96=93=E6=8E=A5=E7=9A=84=E3=81=AB=E5=8F=96=E5=BE=97?=
=?UTF-8?q?=E3=81=99=E3=82=8BItemEntity::get=5Fbaseitem=5Fpval()=20?=
=?UTF-8?q?=E3=82=92=E5=AE=9F=E8=A3=85=E3=81=97=E3=81=A6=E3=82=AB=E3=83=97?=
=?UTF-8?q?=E3=82=BB=E3=83=AB=E5=8C=96=E3=82=92=E5=90=91=E4=B8=8A=E3=81=97?=
=?UTF-8?q?=E3=81=9F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/flavor/flavor-describer.cpp | 2 +-
src/inventory/recharge-processor.cpp | 35 ++++++++++---------
src/market/building-recharger.cpp | 28 ++++++++-------
src/mind/mind-mage.cpp | 13 ++++---
src/monster-attack/monster-eating.cpp | 6 ++--
.../others/apply-magic-others.cpp | 7 ++--
src/object-use/zaprod-execution.cpp | 7 ++--
src/object/object-stack.cpp | 1 -
src/object/object-value.cpp | 5 +--
src/spell-kind/magic-item-recharger.cpp | 7 ++--
src/store/store-util.cpp | 3 +-
src/system/item-entity.cpp | 5 +++
src/system/item-entity.h | 1 +
13 files changed, 60 insertions(+), 60 deletions(-)
diff --git a/src/flavor/flavor-describer.cpp b/src/flavor/flavor-describer.cpp
index 9c14e98d29..9ef2c0c433 100644
--- a/src/flavor/flavor-describer.cpp
+++ b/src/flavor/flavor-describer.cpp
@@ -345,7 +345,7 @@ static std::string describe_charges_rod(const ItemEntity &item)
return _("(充填中)", " (charging)");
}
- const auto timeout_per_one = item.get_baseitem().pval;
+ const auto timeout_per_one = item.get_baseitem_pval();
auto num_of_charging = (item.timeout + (timeout_per_one - 1)) / timeout_per_one;
if (num_of_charging > item.number) {
num_of_charging = item.number;
diff --git a/src/inventory/recharge-processor.cpp b/src/inventory/recharge-processor.cpp
index 4241b9bf18..0f451c16ed 100644
--- a/src/inventory/recharge-processor.cpp
+++ b/src/inventory/recharge-processor.cpp
@@ -6,7 +6,6 @@
#include "hpmp/hp-mp-regenerator.h"
#include "inventory/inventory-slot-types.h"
#include "object/tval-types.h"
-#include "system/baseitem/baseitem-definition.h"
#include "system/floor-type-definition.h"
#include "system/item-entity.h"
#include "system/player-type-definition.h"
@@ -84,28 +83,30 @@ void recharge_magic_items(PlayerType *player_ptr)
*/
for (changed = false, i = 0; i < INVEN_PACK; i++) {
auto &item = player_ptr->inventory_list[i];
- const auto &baseitem = item.get_baseitem();
if (!item.is_valid()) {
continue;
}
- if ((item.bi_key.tval() == ItemKindType::ROD) && (item.timeout)) {
- TIME_EFFECT temp = (item.timeout + (baseitem.pval - 1)) / baseitem.pval;
- if (temp > item.number) {
- temp = (TIME_EFFECT)item.number;
- }
+ if ((item.bi_key.tval() != ItemKindType::ROD) || (item.timeout == 0)) {
+ continue;
+ }
- item.timeout -= temp;
- if (item.timeout < 0) {
- item.timeout = 0;
- }
+ const auto base_pval = item.get_baseitem_pval();
+ short temp = (item.timeout + (base_pval - 1)) / base_pval;
+ if (temp > item.number) {
+ temp = static_cast(item.number);
+ }
- if (!(item.timeout)) {
- recharged_notice(player_ptr, item);
- changed = true;
- } else if (item.timeout % baseitem.pval) {
- changed = true;
- }
+ item.timeout -= temp;
+ if (item.timeout < 0) {
+ item.timeout = 0;
+ }
+
+ if (!(item.timeout)) {
+ recharged_notice(player_ptr, item);
+ changed = true;
+ } else if (item.timeout % base_pval) {
+ changed = true;
}
}
diff --git a/src/market/building-recharger.cpp b/src/market/building-recharger.cpp
index ee0fd11ec0..80aa11f1bd 100644
--- a/src/market/building-recharger.cpp
+++ b/src/market/building-recharger.cpp
@@ -65,12 +65,13 @@ void building_recharge(PlayerType *player_ptr)
const auto item_level = o_ptr->get_baseitem_level();
const auto tval = o_ptr->bi_key.tval();
+ const auto base_pval = o_ptr->get_baseitem_pval();
const auto &baseitem = o_ptr->get_baseitem();
int price;
switch (tval) {
case ItemKindType::ROD:
if (o_ptr->timeout > 0) {
- price = (item_level * 50 * o_ptr->timeout) / baseitem.pval;
+ price = (item_level * 50 * o_ptr->timeout) / base_pval;
break;
}
@@ -87,7 +88,7 @@ void building_recharge(PlayerType *player_ptr)
break;
}
- if ((tval == ItemKindType::WAND) && (o_ptr->pval / o_ptr->number >= baseitem.pval)) {
+ if ((tval == ItemKindType::WAND) && (o_ptr->pval / o_ptr->number >= base_pval)) {
if (o_ptr->number > 1) {
msg_print(_("この魔法棒はもう充分に充填されています。", "These wands are already fully charged."));
} else {
@@ -95,7 +96,7 @@ void building_recharge(PlayerType *player_ptr)
}
return;
- } else if ((tval == ItemKindType::STAFF) && o_ptr->pval >= baseitem.pval) {
+ } else if ((tval == ItemKindType::STAFF) && o_ptr->pval >= base_pval) {
if (o_ptr->number > 1) {
msg_print(_("この杖はもう充分に充填されています。", "These staffs are already fully charged."));
} else {
@@ -130,9 +131,9 @@ void building_recharge(PlayerType *player_ptr)
} else {
int max_charges;
if (tval == ItemKindType::STAFF) {
- max_charges = baseitem.pval - o_ptr->pval;
+ max_charges = base_pval - o_ptr->pval;
} else {
- max_charges = o_ptr->number * baseitem.pval - o_ptr->pval;
+ max_charges = o_ptr->number * base_pval - o_ptr->pval;
}
const auto mes = _("一回分$%d で何回分充填しますか?", "Add how many charges for %d gold apiece? ");
@@ -193,19 +194,20 @@ void building_recharge_all(PlayerType *player_ptr)
const auto &baseitem = item.get_baseitem();
const auto item_level = item.get_baseitem_level();
+ const auto base_pval = item.get_baseitem_pval();
switch (item.bi_key.tval()) {
case ItemKindType::ROD:
- price = (item_level * 50 * item.timeout) / baseitem.pval;
+ price = (item_level * 50 * item.timeout) / base_pval;
break;
case ItemKindType::STAFF:
price = (baseitem.cost / 10) * item.number;
price = std::max(10, price);
- price = (baseitem.pval - item.pval) * price;
+ price = (base_pval - item.pval) * price;
break;
case ItemKindType::WAND:
price = (baseitem.cost / 10);
price = std::max(10, price);
- price = (item.number * baseitem.pval - item.pval) * price;
+ price = (item.number * base_pval - item.pval) * price;
break;
default:
break;
@@ -234,7 +236,6 @@ void building_recharge_all(PlayerType *player_ptr)
for (short i = 0; i < INVEN_PACK; i++) {
auto *o_ptr = &player_ptr->inventory_list[i];
- const auto &baseitem = o_ptr->get_baseitem();
if (!o_ptr->can_recharge()) {
continue;
}
@@ -244,20 +245,21 @@ void building_recharge_all(PlayerType *player_ptr)
autopick_alter_item(player_ptr, i, false);
}
+ const auto base_pval = o_ptr->get_baseitem_pval();
switch (o_ptr->bi_key.tval()) {
case ItemKindType::ROD:
o_ptr->timeout = 0;
break;
case ItemKindType::STAFF:
- if (o_ptr->pval < baseitem.pval) {
- o_ptr->pval = baseitem.pval;
+ if (o_ptr->pval < base_pval) {
+ o_ptr->pval = base_pval;
}
o_ptr->ident &= ~(IDENT_EMPTY);
break;
case ItemKindType::WAND:
- if (o_ptr->pval < o_ptr->number * baseitem.pval) {
- o_ptr->pval = o_ptr->number * baseitem.pval;
+ if (o_ptr->pval < o_ptr->number * base_pval) {
+ o_ptr->pval = o_ptr->number * base_pval;
}
o_ptr->ident &= ~(IDENT_EMPTY);
diff --git a/src/mind/mind-mage.cpp b/src/mind/mind-mage.cpp
index 4010c28375..e00d05ce57 100644
--- a/src/mind/mind-mage.cpp
+++ b/src/mind/mind-mage.cpp
@@ -15,7 +15,6 @@
#include "object/item-tester-hooker.h"
#include "object/item-use-flags.h"
#include "player-base/player-class.h"
-#include "system/baseitem/baseitem-definition.h"
#include "system/item-entity.h"
#include "system/player-type-definition.h"
#include "view/display-messages.h"
@@ -37,7 +36,7 @@ bool eat_magic(PlayerType *player_ptr, int power)
return false;
}
- const auto &baseitem = o_ptr->get_baseitem();
+ const auto base_pval = o_ptr->get_baseitem_pval();
const auto item_level = o_ptr->get_baseitem_level();
const auto tval = o_ptr->bi_key.tval();
auto recharge_strength = 0;
@@ -47,11 +46,11 @@ bool eat_magic(PlayerType *player_ptr, int power)
if (one_in_(recharge_strength)) {
is_eating_successful = false;
} else {
- if (o_ptr->timeout > (o_ptr->number - 1) * baseitem.pval) {
+ if (o_ptr->timeout > (o_ptr->number - 1) * base_pval) {
msg_print(_("充填中のロッドから魔力を吸収することはできません。", "You can't absorb energy from a discharged rod."));
} else {
player_ptr->csp += item_level;
- o_ptr->timeout += baseitem.pval;
+ o_ptr->timeout += base_pval;
}
}
} else {
@@ -98,7 +97,7 @@ bool eat_magic(PlayerType *player_ptr, int power)
const auto item_name = describe_flavor(player_ptr, *o_ptr, OD_NAME_ONLY);
msg_format(_("魔力が逆流した!%sは完全に魔力を失った。", "The recharging backfires - %s is completely drained!"), item_name.data());
if (tval == ItemKindType::ROD) {
- o_ptr->timeout = baseitem.pval * o_ptr->number;
+ o_ptr->timeout = base_pval * o_ptr->number;
} else if (o_ptr->is_wand_staff()) {
o_ptr->pval = 0;
}
@@ -163,7 +162,7 @@ bool eat_magic(PlayerType *player_ptr, int power)
if (fail_type == 1) {
if (tval == ItemKindType::ROD) {
msg_print(_("ロッドは破損を免れたが、魔力は全て失なわれた。", "You save your rod from destruction, but all charges are lost."));
- o_ptr->timeout = baseitem.pval * o_ptr->number;
+ o_ptr->timeout = base_pval * o_ptr->number;
} else if (tval == ItemKindType::WAND) {
constexpr auto mes = _("%sは破損を免れたが、魔力が全て失われた。", "You save your %s from destruction, but all charges are lost.");
msg_format(mes, item_name.data());
@@ -176,7 +175,7 @@ bool eat_magic(PlayerType *player_ptr, int power)
msg_format(_("乱暴な魔法のために%sが一本壊れた!", "Wild magic consumes one of your %s!"), item_name.data());
/* Reduce rod stack maximum timeout, drain wands. */
if (tval == ItemKindType::ROD) {
- o_ptr->timeout = std::min(o_ptr->timeout, baseitem.pval * (o_ptr->number - 1));
+ o_ptr->timeout = std::min(o_ptr->timeout, base_pval * (o_ptr->number - 1));
} else if (tval == ItemKindType::WAND) {
o_ptr->pval = o_ptr->pval * (o_ptr->number - 1) / o_ptr->number;
}
diff --git a/src/monster-attack/monster-eating.cpp b/src/monster-attack/monster-eating.cpp
index ec6be7031c..fa66b4fe11 100644
--- a/src/monster-attack/monster-eating.cpp
+++ b/src/monster-attack/monster-eating.cpp
@@ -22,7 +22,6 @@
#include "player/player-status-flags.h"
#include "player/player-status-table.h"
#include "status/experience.h"
-#include "system/baseitem/baseitem-definition.h"
#include "system/floor-type-definition.h"
#include "system/item-entity.h"
#include "system/monster-entity.h"
@@ -227,10 +226,9 @@ bool process_un_power(PlayerType *player_ptr, MonsterAttackPlayer *monap_ptr)
}
const auto is_magic_mastery = has_magic_mastery(player_ptr) != 0;
- const auto &baseitem = monap_ptr->o_ptr->get_baseitem();
- const auto pval = baseitem.pval;
+ const auto base_pval = monap_ptr->o_ptr->get_baseitem_pval();
const auto level = monap_ptr->rlev;
- auto drain = is_magic_mastery ? std::min(pval, pval * level / 400 + pval * randint1(level) / 400) : pval;
+ auto drain = is_magic_mastery ? std::min(base_pval, base_pval * level / 400 + base_pval * randint1(level) / 400) : base_pval;
drain = std::min(drain, monap_ptr->o_ptr->pval);
if (drain <= 0) {
return false;
diff --git a/src/object-enchant/others/apply-magic-others.cpp b/src/object-enchant/others/apply-magic-others.cpp
index d50139562d..acd795e20d 100644
--- a/src/object-enchant/others/apply-magic-others.cpp
+++ b/src/object-enchant/others/apply-magic-others.cpp
@@ -20,7 +20,6 @@
#include "perception/object-perception.h"
#include "sv-definition/sv-lite-types.h"
#include "sv-definition/sv-other-types.h"
-#include "system/baseitem/baseitem-definition.h"
#include "system/enums/monrace/monrace-id.h"
#include "system/floor-type-definition.h"
#include "system/item-entity.h"
@@ -60,7 +59,7 @@ void OtherItemsEnchanter::apply_magic()
this->enchant_wand_staff();
break;
case ItemKindType::ROD:
- this->o_ptr->pval = this->o_ptr->get_baseitem().pval;
+ this->o_ptr->pval = this->o_ptr->get_baseitem_pval();
break;
case ItemKindType::CAPTURE:
this->o_ptr->pval = 0;
@@ -91,8 +90,8 @@ void OtherItemsEnchanter::apply_magic()
*/
void OtherItemsEnchanter::enchant_wand_staff()
{
- const auto &baseitem = this->o_ptr->get_baseitem();
- this->o_ptr->pval = baseitem.pval / 2 + randint1((baseitem.pval + 1) / 2);
+ const auto base_pval = this->o_ptr->get_baseitem_pval();
+ this->o_ptr->pval = base_pval / 2 + randint1((base_pval + 1) / 2);
}
/*
diff --git a/src/object-use/zaprod-execution.cpp b/src/object-use/zaprod-execution.cpp
index 0e1699f63f..c26644c8cd 100644
--- a/src/object-use/zaprod-execution.cpp
+++ b/src/object-use/zaprod-execution.cpp
@@ -19,7 +19,6 @@
#include "status/experience.h"
#include "sv-definition/sv-other-types.h"
#include "sv-definition/sv-rod-types.h"
-#include "system/baseitem/baseitem-definition.h"
#include "system/item-entity.h"
#include "system/player-type-definition.h"
#include "system/redrawing-flags-updater.h"
@@ -103,7 +102,7 @@ void ObjectZapRodEntity::execute(INVENTORY_IDX i_idx)
return;
}
- const auto &baseitem = o_ptr->get_baseitem();
+ const auto base_pval = o_ptr->get_baseitem_pval();
if ((o_ptr->number == 1) && (o_ptr->timeout)) {
if (flush_failure) {
flush();
@@ -111,7 +110,7 @@ void ObjectZapRodEntity::execute(INVENTORY_IDX i_idx)
msg_print(_("このロッドはまだ魔力を充填している最中だ。", "The rod is still charging."));
return;
- } else if ((o_ptr->number > 1) && (o_ptr->timeout > baseitem.pval * (o_ptr->number - 1))) {
+ } else if ((o_ptr->number > 1) && (o_ptr->timeout > base_pval * (o_ptr->number - 1))) {
if (flush_failure) {
flush();
}
@@ -123,7 +122,7 @@ void ObjectZapRodEntity::execute(INVENTORY_IDX i_idx)
sound(SOUND_ZAP);
auto ident = rod_effect(this->player_ptr, *o_ptr->bi_key.sval(), dir, &use_charge, false);
if (use_charge) {
- o_ptr->timeout += baseitem.pval;
+ o_ptr->timeout += base_pval;
}
auto &rfu = RedrawingFlagsUpdater::get_instance();
diff --git a/src/object/object-stack.cpp b/src/object/object-stack.cpp
index f049dfa5f2..04cbf10bb7 100644
--- a/src/object/object-stack.cpp
+++ b/src/object/object-stack.cpp
@@ -13,7 +13,6 @@
#include "object/tval-types.h"
#include "smith/object-smith.h"
#include "sv-definition/sv-other-types.h"
-#include "system/baseitem/baseitem-definition.h"
#include "system/item-entity.h"
#include "util/bit-flags-calculator.h"
diff --git a/src/object/object-value.cpp b/src/object/object-value.cpp
index 9958386395..0853008db5 100644
--- a/src/object/object-value.cpp
+++ b/src/object/object-value.cpp
@@ -140,19 +140,20 @@ PRICE object_value_real(const ItemEntity *o_ptr)
break;
}
+ const auto base_pval = o_ptr->get_baseitem_pval();
switch (o_ptr->bi_key.tval()) {
case ItemKindType::WAND: {
/* Pay extra for charges, depending on standard number of
* charges. Handle new-style wands correctly. -LM-
*/
- value += (value * o_ptr->pval / o_ptr->number / (baseitem.pval * 2));
+ value += (value * o_ptr->pval / o_ptr->number / (base_pval * 2));
break;
}
case ItemKindType::STAFF: {
/* Pay extra for charges, depending on standard number of
* charges. -LM-
*/
- value += (value * o_ptr->pval / (baseitem.pval * 2));
+ value += (value * o_ptr->pval / (base_pval * 2));
break;
}
case ItemKindType::RING:
diff --git a/src/spell-kind/magic-item-recharger.cpp b/src/spell-kind/magic-item-recharger.cpp
index bc81b0ccfd..cf9e163579 100644
--- a/src/spell-kind/magic-item-recharger.cpp
+++ b/src/spell-kind/magic-item-recharger.cpp
@@ -22,7 +22,6 @@
#include "object/item-use-flags.h"
#include "player-base/player-class.h"
#include "system/angband-exceptions.h"
-#include "system/baseitem/baseitem-definition.h"
#include "system/item-entity.h"
#include "system/player-type-definition.h"
#include "view/display-messages.h"
@@ -91,8 +90,7 @@ bool recharge(PlayerType *player_ptr, int power)
if (one_in_(recharge_strength)) {
is_recharge_successful = false;
} else {
- const auto &baseitem = o_ptr->get_baseitem();
- recharge_amount = randnum1(1 + baseitem.pval / 2);
+ recharge_amount = randnum1(1 + o_ptr->get_baseitem_pval() / 2);
if ((tval == ItemKindType::WAND) && (o_ptr->number > 1)) {
recharge_amount += (randint1(recharge_amount * (o_ptr->number - 1))) / 2;
if (recharge_amount < 1) {
@@ -205,8 +203,7 @@ bool recharge(PlayerType *player_ptr, int power)
}
if (tval == ItemKindType::ROD) {
- const auto &baseitem = o_ptr->get_baseitem();
- o_ptr->timeout = (o_ptr->number - 1) * baseitem.pval;
+ o_ptr->timeout = (o_ptr->number - 1) * o_ptr->get_baseitem_pval();
}
if (tval == ItemKindType::WAND) {
diff --git a/src/store/store-util.cpp b/src/store/store-util.cpp
index bb602a491e..c3db53de48 100644
--- a/src/store/store-util.cpp
+++ b/src/store/store-util.cpp
@@ -9,7 +9,6 @@
#include "object-enchant/special-object-flags.h"
#include "object/object-value.h"
#include "object/tval-types.h"
-#include "system/baseitem/baseitem-definition.h"
#include "system/item-entity.h"
#include
@@ -103,7 +102,7 @@ std::vector store_same_magic_device_pvals(ItemEntity *j_ptr)
*/
static void store_object_absorb(ItemEntity &item1, const ItemEntity &item2)
{
- const auto max_num = (item1.bi_key.tval() == ItemKindType::ROD) ? std::min(99, MAX_SHORT / item1.get_baseitem().pval) : 99;
+ const auto max_num = (item1.bi_key.tval() == ItemKindType::ROD) ? std::min(99, MAX_SHORT / item1.get_baseitem_pval()) : 99;
const auto total = item1.number + item2.number;
const auto diff = (total > max_num) ? total - max_num : 0;
item1.number = (total > max_num) ? max_num : total;
diff --git a/src/system/item-entity.cpp b/src/system/item-entity.cpp
index b9261f45c0..9b4a3b71de 100644
--- a/src/system/item-entity.cpp
+++ b/src/system/item-entity.cpp
@@ -1207,6 +1207,11 @@ int ItemEntity::get_baseitem_level() const
return this->get_baseitem().level;
}
+short ItemEntity::get_baseitem_pval() const
+{
+ return this->get_baseitem().pval;
+}
+
std::string ItemEntity::build_timeout_description(const ActivationType &act) const
{
const auto description = act.build_timeout_description();
diff --git a/src/system/item-entity.h b/src/system/item-entity.h
index 2ed558857d..9de14a83e8 100644
--- a/src/system/item-entity.h
+++ b/src/system/item-entity.h
@@ -164,6 +164,7 @@ class ItemEntity {
int is_similar_part(const ItemEntity &other) const;
bool is_similar_for_store(const ItemEntity &other) const;
int get_baseitem_level() const;
+ short get_baseitem_pval() const;
void mark_as_known();
void mark_as_tried() const;
From 8d96d3ac496dac1fed79dd6c6d1e17f971efdee2 Mon Sep 17 00:00:00 2001
From: Hourier <66951241+Hourier@users.noreply.github.com>
Date: Sat, 16 Nov 2024 18:11:56 +0900
Subject: [PATCH 11/11] =?UTF-8?q?[Refactor]=20#4624=20Baseitem::cost=20?=
=?UTF-8?q?=E3=82=92=E9=96=93=E6=8E=A5=E7=9A=84=E3=81=AB=E5=8F=96=E5=BE=97?=
=?UTF-8?q?=E3=81=99=E3=82=8BItemEntity::get=5Fbaseitem=5Fcost()/is=5Fwort?=
=?UTF-8?q?hless()=20=E3=82=92=E5=AE=9F=E8=A3=85=E3=81=97=E3=81=A6?=
=?UTF-8?q?=E3=82=AB=E3=83=97=E3=82=BB=E3=83=AB=E5=8C=96=E3=82=92=E5=90=91?=
=?UTF-8?q?=E4=B8=8A=E3=81=97=E3=81=9F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/market/building-recharger.cpp | 13 ++++++-------
src/object-enchant/item-magic-applier.cpp | 4 ++--
src/object/object-value.cpp | 7 +++----
src/system/item-entity.cpp | 12 +++++++++++-
src/system/item-entity.h | 2 ++
5 files changed, 24 insertions(+), 14 deletions(-)
diff --git a/src/market/building-recharger.cpp b/src/market/building-recharger.cpp
index 80aa11f1bd..139ca07f62 100644
--- a/src/market/building-recharger.cpp
+++ b/src/market/building-recharger.cpp
@@ -13,7 +13,6 @@
#include "object/item-use-flags.h"
#include "perception/object-perception.h"
#include "spell-kind/spells-perception.h"
-#include "system/baseitem/baseitem-definition.h"
#include "system/item-entity.h"
#include "system/player-type-definition.h"
#include "system/redrawing-flags-updater.h"
@@ -66,7 +65,7 @@ void building_recharge(PlayerType *player_ptr)
const auto item_level = o_ptr->get_baseitem_level();
const auto tval = o_ptr->bi_key.tval();
const auto base_pval = o_ptr->get_baseitem_pval();
- const auto &baseitem = o_ptr->get_baseitem();
+ const auto base_cost = o_ptr->get_baseitem_cost();
int price;
switch (tval) {
case ItemKindType::ROD:
@@ -79,11 +78,11 @@ void building_recharge(PlayerType *player_ptr)
msg_format(_("それは再充填する必要はありません。", "That doesn't need to be recharged."));
return;
case ItemKindType::STAFF:
- price = (baseitem.cost / 10) * o_ptr->number;
+ price = (base_cost / 10) * o_ptr->number;
price = std::max(10, price);
break;
default:
- price = baseitem.cost / 10;
+ price = base_cost / 10;
price = std::max(10, price);
break;
}
@@ -192,20 +191,20 @@ void building_recharge_all(PlayerType *player_ptr)
total_cost += 50;
}
- const auto &baseitem = item.get_baseitem();
const auto item_level = item.get_baseitem_level();
const auto base_pval = item.get_baseitem_pval();
+ const auto base_cost = item.get_baseitem_cost();
switch (item.bi_key.tval()) {
case ItemKindType::ROD:
price = (item_level * 50 * item.timeout) / base_pval;
break;
case ItemKindType::STAFF:
- price = (baseitem.cost / 10) * item.number;
+ price = (base_cost / 10) * item.number;
price = std::max(10, price);
price = (base_pval - item.pval) * price;
break;
case ItemKindType::WAND:
- price = (baseitem.cost / 10);
+ price = (base_cost / 10);
price = std::max(10, price);
price = (item.number * base_pval - item.pval) * price;
break;
diff --git a/src/object-enchant/item-magic-applier.cpp b/src/object-enchant/item-magic-applier.cpp
index bf32ccb365..fbb0c11929 100644
--- a/src/object-enchant/item-magic-applier.cpp
+++ b/src/object-enchant/item-magic-applier.cpp
@@ -204,11 +204,11 @@ void ItemMagicApplier::apply_cursed()
return;
}
- const auto &baseitem = this->o_ptr->get_baseitem();
- if (!baseitem.cost) {
+ if (this->o_ptr->is_worthless()) {
set_bits(this->o_ptr->ident, IDENT_BROKEN);
}
+ const auto &baseitem = this->o_ptr->get_baseitem();
if (baseitem.gen_flags.has(ItemGenerationTraitType::CURSED)) {
this->o_ptr->curse_flags.set(CurseTraitType::CURSED);
}
diff --git a/src/object/object-value.cpp b/src/object/object-value.cpp
index 0853008db5..3a89684769 100644
--- a/src/object/object-value.cpp
+++ b/src/object/object-value.cpp
@@ -35,13 +35,11 @@
*/
PRICE object_value_real(const ItemEntity *o_ptr)
{
- const auto &baseitem = o_ptr->get_baseitem();
-
- if (!baseitem.cost) {
+ if (o_ptr->is_worthless()) {
return 0;
}
- PRICE value = baseitem.cost;
+ auto value = o_ptr->get_baseitem_cost();
const auto flags = o_ptr->get_flags();
if (o_ptr->is_fixed_artifact()) {
const auto &artifact = o_ptr->get_fixed_artifact();
@@ -67,6 +65,7 @@ PRICE object_value_real(const ItemEntity *o_ptr)
}
/* Analyze pval bonus for normal object */
+ const auto &baseitem = o_ptr->get_baseitem();
switch (o_ptr->bi_key.tval()) {
case ItemKindType::SHOT:
case ItemKindType::ARROW:
diff --git a/src/system/item-entity.cpp b/src/system/item-entity.cpp
index 9b4a3b71de..c0e9821cdd 100644
--- a/src/system/item-entity.cpp
+++ b/src/system/item-entity.cpp
@@ -103,7 +103,7 @@ void ItemEntity::generate(short new_bi_id)
this->activation_id = baseitem.act_idx;
}
- if (this->get_baseitem().cost <= 0) {
+ if (this->is_worthless()) {
this->ident |= (IDENT_BROKEN);
}
@@ -1212,6 +1212,16 @@ short ItemEntity::get_baseitem_pval() const
return this->get_baseitem().pval;
}
+bool ItemEntity::is_worthless() const
+{
+ return this->get_baseitem().cost <= 0;
+}
+
+int ItemEntity::get_baseitem_cost() const
+{
+ return this->get_baseitem().cost;
+}
+
std::string ItemEntity::build_timeout_description(const ActivationType &act) const
{
const auto description = act.build_timeout_description();
diff --git a/src/system/item-entity.h b/src/system/item-entity.h
index 9de14a83e8..85a37093b9 100644
--- a/src/system/item-entity.h
+++ b/src/system/item-entity.h
@@ -165,6 +165,8 @@ class ItemEntity {
bool is_similar_for_store(const ItemEntity &other) const;
int get_baseitem_level() const;
short get_baseitem_pval() const;
+ bool is_worthless() const;
+ int get_baseitem_cost() const;
void mark_as_known();
void mark_as_tried() const;