OSDN Git Service

[Refactor] EFFECT_IDの削除
authordis- <dis.rogue@gmail.com>
Thu, 13 Jan 2022 07:59:52 +0000 (16:59 +0900)
committerdis- <dis.rogue@gmail.com>
Fri, 14 Jan 2022 15:27:03 +0000 (00:27 +0900)
enum AttributeTypeを定義したため不要となったtypedefの削除。

実質int型であったことから紛れていたroom_build()とalloc_object()のEFFECT_IDを適切な型に修正して混乱をなくす。
aura_shadow_by_monster_attack()では実質int型であることを利用した手の込んだ手抜きがあったので少し整理する。

コード可読性の向上のみで実際の処理は変更しない。

28 files changed:
src/blue-magic/blue-magic-caster.cpp
src/cmd-action/cmd-attack.cpp
src/cmd-action/cmd-mane.cpp
src/combat/aura-counterattack.cpp
src/effect/attribute-types.h
src/effect/effect-feature.cpp
src/effect/effect-item.cpp
src/effect/effect-monster-switcher.cpp
src/floor/object-allocator.cpp
src/floor/object-allocator.h
src/grid/trap.cpp
src/melee/melee-spell-flags-checker.cpp
src/mind/mind-elementalist.cpp
src/mspell/assign-monster-spell.cpp
src/mspell/mspell-particularity.cpp
src/mspell/specified-summon.cpp
src/object-use/read-execution.cpp
src/object/warning.cpp
src/player/patron.cpp
src/racial/racial-switcher.cpp
src/realm/realm-death.cpp
src/realm/realm-song.cpp
src/room/room-generator.cpp
src/room/room-info-table.cpp
src/room/room-info-table.h
src/spell-realm/spells-hex.cpp
src/spell/spells-summon.cpp
src/system/h-type.h

index d299f02..dfdf164 100644 (file)
@@ -27,7 +27,6 @@
 #include "spell-kind/spells-sight.h"
 #include "spell-kind/spells-teleport.h"
 #include "spell-kind/spells-world.h"
-#include "effect/attribute-types.h"
 #include "spell/spells-status.h"
 #include "status/bad-status-setter.h"
 #include "status/body-improvement.h"
index cd984d6..0e2d3a5 100644 (file)
@@ -44,7 +44,6 @@
 #include "player/player-status-flags.h"
 #include "player/player-status.h"
 #include "player/special-defense-types.h"
-#include "effect/attribute-types.h"
 #include "status/action-setter.h"
 #include "system/floor-type-definition.h"
 #include "system/grid-type-definition.h"
index 4f36aab..b403f1f 100644 (file)
@@ -47,7 +47,6 @@
 #include "spell-kind/spells-sight.h"
 #include "spell-kind/spells-teleport.h"
 #include "spell-kind/spells-world.h"
-#include "effect/attribute-types.h"
 #include "spell/spells-status.h"
 #include "spell/spells-summon.h"
 #include "spell/summon-types.h"
index 700334a..ccf210f 100644 (file)
@@ -207,16 +207,23 @@ static void aura_shadow_by_monster_attack(PlayerType *player_ptr, monap_type *mo
         monap_ptr->alive = false;
         return;
     }
+    
+    struct attribute_table {
+        inventory_slot_type slot;
+        AttributeType type;
+    };
+
+    const int TABLE_SIZE = 4;
+    attribute_table table[TABLE_SIZE] = { { INVEN_HEAD, AttributeType::OLD_CONF }, { INVEN_SUB_HAND, AttributeType::OLD_SLEEP }, 
+                            { INVEN_ARMS, AttributeType::TURN_ALL }, { INVEN_FEET, AttributeType::OLD_SLOW } };
 
     BIT_FLAGS flg = PROJECT_STOP | PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
-    EFFECT_ID typ[4][2] = { { INVEN_HEAD, (EFFECT_ID)AttributeType::OLD_CONF }, { INVEN_SUB_HAND, (EFFECT_ID)AttributeType::OLD_SLEEP }, 
-                            { INVEN_ARMS, (EFFECT_ID)AttributeType::TURN_ALL }, { INVEN_FEET, (EFFECT_ID)AttributeType::OLD_SLOW } };
 
     /* Some cursed armours gives an extra effect */
-    for (int j = 0; j < 4; j++) {
-        o_armed_ptr = &player_ptr->inventory_list[typ[j][0]];
+    for (int j = 0; j < TABLE_SIZE; j++) {
+        o_armed_ptr = &player_ptr->inventory_list[table[j].slot];
         if ((o_armed_ptr->k_idx) && o_armed_ptr->is_cursed() && o_armed_ptr->is_armour())
-            project(player_ptr, 0, 0, monap_ptr->m_ptr->fy, monap_ptr->m_ptr->fx, (player_ptr->lev * 2), (AttributeType)typ[j][1], flg);
+            project(player_ptr, 0, 0, monap_ptr->m_ptr->fy, monap_ptr->m_ptr->fx, (player_ptr->lev * 2), table[j].type, flg);
     }
 }
 
index a1e3067..8ac67b3 100644 (file)
@@ -1,7 +1,7 @@
 #pragma once
 #include "util/flag-group.h"
 
-enum class AttributeType : EFFECT_ID {
+enum class AttributeType : int {
     NONE = 0,
     ELEC = 1,                   /*!< 魔法効果: 電撃*/
     POIS = 2,                   /*!< 魔法効果: 毒*/
index 8ee664d..10a9807 100644 (file)
@@ -2,7 +2,6 @@
 #include "core/player-update-types.h"
 #include "dungeon/dungeon-flag-types.h"
 #include "dungeon/dungeon.h"
-#include "effect/attribute-types.h"
 #include "effect/effect-characteristics.h"
 #include "effect/effect-processor.h" // 暫定、後で消す.
 #include "floor/cave.h"
index 1b7d574..5550728 100644 (file)
@@ -1,6 +1,5 @@
 #include "effect/effect-item.h"
 #include "autopick/autopick.h"
-#include "effect/attribute-types.h"
 #include "flavor/flavor-describer.h"
 #include "flavor/object-flavor-types.h"
 #include "floor/cave.h"
index 28ccb53..f1a4f8b 100644 (file)
@@ -30,7 +30,6 @@
 #include "monster/monster-status.h"
 #include "player/player-damage.h"
 #include "spell-kind/spells-genocide.h"
-#include "effect/attribute-types.h"
 #include "system/grid-type-definition.h"
 #include "system/monster-race-definition.h"
 #include "system/monster-type-definition.h"
index df6e9b0..fd68576 100644 (file)
@@ -161,7 +161,7 @@ static void place_rubble(floor_type *floor_ptr, POSITION y, POSITION x)
  * @param num 配置したい数
  * @return 規定数通りに生成に成功したらTRUEを返す。
  */
-void alloc_object(PlayerType *player_ptr, dap_type set, EFFECT_ID typ, int num)
+void alloc_object(PlayerType *player_ptr, dap_type set, dungeon_allocation_type typ, int num)
 {
     POSITION y = 0;
     POSITION x = 0;
@@ -208,6 +208,8 @@ void alloc_object(PlayerType *player_ptr, dap_type set, EFFECT_ID typ, int num)
         case ALLOC_TYP_OBJECT:
             place_object(player_ptr, y, x, 0L);
             break;
+        default:
+            break;
         }
     }
 }
index 6a96c05..7049da8 100644 (file)
@@ -1,9 +1,9 @@
 #pragma once
 
 #include "system/angband.h"
-#include "effect/attribute-types.h"
+#include "floor/floor-allocation-types.h"
 
 enum dap_type : int;
 class PlayerType;
 bool alloc_stairs(PlayerType *player_ptr, FEAT_IDX feat, int num, int walls);
-void alloc_object(PlayerType *player_ptr, dap_type set, EFFECT_ID typ, int num);
+void alloc_object(PlayerType *player_ptr, dap_type set, dungeon_allocation_type typ, int num);
index a63df00..ef53f7e 100644 (file)
@@ -31,7 +31,6 @@
 #include "spell-kind/spells-random.h"
 #include "spell-kind/spells-sight.h"
 #include "spell-kind/spells-teleport.h"
-#include "effect/attribute-types.h"
 #include "spell/summon-types.h"
 #include "status/bad-status-setter.h"
 #include "status/base-status.h"
index 06e21c8..688d303 100644 (file)
@@ -19,7 +19,6 @@
 #include "mspell/mspell-util.h"
 #include "pet/pet-util.h"
 #include "spell-kind/spells-world.h"
-#include "effect/attribute-types.h"
 #include "system/floor-type-definition.h"
 #include "system/grid-type-definition.h"
 #include "system/monster-race-definition.h"
index 0b9d273..bb854af 100644 (file)
@@ -53,7 +53,6 @@
 #include "spell-kind/spells-sight.h"
 #include "spell-kind/spells-teleport.h"
 #include "spell-kind/spells-world.h"
-#include "effect/attribute-types.h"
 #include "status/bad-status-setter.h"
 #include "status/base-status.h"
 #include "system/floor-type-definition.h"
index 560ad48..09761bd 100644 (file)
@@ -21,7 +21,6 @@
 #include "mspell/mspell-summon.h"
 #include "mspell/mspell-util.h"
 #include "mspell/mspell-result.h"
-#include "effect/attribute-types.h"
 #include "system/player-type-definition.h"
 #include "util/enum-converter.h"
 
index 10e2f94..ce0391c 100644 (file)
@@ -18,7 +18,6 @@
 #include "mspell/mspell-result.h"
 #include "mspell/mspell-util.h"
 #include "mspell/mspell-result.h"
-#include "effect/attribute-types.h"
 #include "system/player-type-definition.h"
 
 /*!
index ed2ed66..56e386c 100644 (file)
@@ -11,7 +11,6 @@
 #include "mspell/mspell-checker.h"
 #include "mspell/mspell-util.h"
 #include "spell-kind/spells-launcher.h"
-#include "effect/attribute-types.h"
 #include "spell/summon-types.h"
 #include "system/monster-race-definition.h"
 #include "system/player-type-definition.h"
index bbe3251..e6fd455 100644 (file)
@@ -48,7 +48,6 @@
 #include "spell-kind/spells-world.h"
 #include "spell-realm/spells-hex.h"
 #include "spell-realm/spells-song.h"
-#include "effect/attribute-types.h"
 #include "spell/spells-object.h"
 #include "spell/spells-summon.h"
 #include "spell/summon-types.h"
index 7fdd0db..45dc21a 100644 (file)
@@ -4,7 +4,6 @@
 #include "core/disturbance.h"
 #include "dungeon/dungeon-flag-types.h"
 #include "dungeon/dungeon.h"
-#include "effect/attribute-types.h"
 #include "flavor/flavor-describer.h"
 #include "flavor/object-flavor-types.h"
 #include "floor/cave.h"
index c2c06c6..84cb2f3 100644 (file)
@@ -22,7 +22,6 @@
 #include "spell-kind/spells-launcher.h"
 #include "spell-kind/spells-random.h"
 #include "spell-kind/spells-sight.h"
-#include "effect/attribute-types.h"
 #include "spell/spells-object.h"
 #include "spell/spells-status.h"
 #include "spell/spells-summon.h"
index 87bdd7e..68987ec 100644 (file)
@@ -72,7 +72,6 @@
 #include "spell-kind/spells-world.h"
 #include "spell-realm/spells-hex.h"
 #include "spell-realm/spells-song.h"
-#include "effect/attribute-types.h"
 #include "spell/spells-status.h"
 #include "status/action-setter.h"
 #include "status/bad-status-setter.h"
index 33f2bc3..684de37 100644 (file)
@@ -16,7 +16,6 @@
 #include "spell-kind/spells-perception.h"
 #include "spell-kind/spells-sight.h"
 #include "spell-kind/spells-specific-bolt.h"
-#include "effect/attribute-types.h"
 #include "spell/spells-diceroll.h"
 #include "spell/spells-object.h"
 #include "spell/spells-status.h"
index 4899087..740042b 100644 (file)
@@ -19,7 +19,6 @@
 #include "spell-kind/spells-sight.h"
 #include "spell-kind/spells-world.h"
 #include "spell-realm/spells-song.h"
-#include "effect/attribute-types.h"
 #include "spell/spells-status.h"
 #include "status/action-setter.h"
 #include "status/bad-status-setter.h"
index f0dd256..51beebd 100644 (file)
@@ -27,7 +27,7 @@
  * @note that we restrict the number of "crowded" rooms to reduce the chance of overflowing the monster list during level creation.
  * @return 部屋の生成に成功した場合 TRUE を返す。
  */
-static bool room_build(PlayerType *player_ptr, dun_data_type *dd_ptr, EFFECT_ID typ)
+static bool room_build(PlayerType *player_ptr, dun_data_type *dd_ptr, room_type typ)
 {
     switch (typ) {
     case ROOM_T_NORMAL:
@@ -184,7 +184,7 @@ bool generate_rooms(PlayerType *player_ptr, dun_data_type *dd_ptr)
     while (true) {
         remain = false;
         for (int i = 0; i < ROOM_T_MAX; i++) {
-            int room_type = room_build_order[i];
+            room_type room_type = room_build_order[i];
             if (!room_num[room_type])
                 continue;
 
@@ -208,6 +208,8 @@ bool generate_rooms(PlayerType *player_ptr, dun_data_type *dd_ptr)
             case ROOM_T_ARCADE:
                 room_num[ROOM_T_ARCADE] = 0;
                 break;
+            default:
+                break;
             }
         }
 
index 6926a8c..a2b59bb 100644 (file)
@@ -39,7 +39,7 @@ room_info_type room_info_normal[ROOM_T_MAX] = {
 };
 
 /*! 部屋の生成処理順 / Build rooms in descending order of difficulty. */
-byte room_build_order[ROOM_T_MAX] = {
+room_type room_build_order[ROOM_T_MAX] = {
     ROOM_T_GREATER_VAULT,
     ROOM_T_ARCADE,
     ROOM_T_RANDOM_VAULT,
index da2cae4..2df421a 100644 (file)
@@ -10,4 +10,4 @@ typedef struct room_info_type {
 } room_info_type;
 
 extern room_info_type room_info_normal[ROOM_T_MAX];
-extern byte room_build_order[ROOM_T_MAX];
+extern room_type room_build_order[ROOM_T_MAX];
index d97c727..6627c2a 100644 (file)
@@ -16,7 +16,6 @@
 #include "spell-realm/spells-crusade.h"
 #include "spell-realm/spells-song.h"
 #include "spell/spell-info.h"
-#include "effect/attribute-types.h"
 #include "spell/spells-execution.h"
 #include "spell/technic-info-table.h"
 #include "status/action-setter.h"
index 46eeab0..bc6951b 100644 (file)
@@ -22,7 +22,6 @@
 #include "spell-kind/spells-lite.h"
 #include "spell-kind/spells-sight.h"
 #include "spell-kind/spells-specific-bolt.h"
-#include "effect/attribute-types.h"
 #include "spell/spells-diceroll.h"
 #include "spell/spells-status.h"
 #include "spell/summon-types.h"
index b733a90..92e432f 100644 (file)
@@ -182,8 +182,6 @@ typedef byte FEAT_POWER; /*!< 地形強度の型定義 */
 
 typedef int QUANTITY; /*!< インターフェース上の指定個数 */
 
-typedef int EFFECT_ID; /*!< 効果属性ID */
-
 typedef int16_t ACTION_SKILL_POWER; /*!< 行動技能値 */
 
 enum process_result {