OSDN Git Service

[Refactor] curse_flags の FlagGroup化
authorHabu <habu1010+github@gmail.com>
Fri, 7 May 2021 14:48:17 +0000 (23:48 +0900)
committerHabu <habu1010+github@gmail.com>
Sat, 8 May 2021 15:49:45 +0000 (00:49 +0900)
TRC_* を enum class TRC にし、object_type の curse_flags と
player_type の cursed を FlagGroup化 する。
trc_special_type の TRC_TELEPORT_SELF と TRC_CHAINSWOD は
trc_curse_type の下位 bit を共有して使うという Hacky な事を
しているので、素直に player_type に cursed_special を新設し
enum class TRCS とした上でそちらで扱うようにする。

なお、FlagGroup化により以下のバグが発見、修正された。

- flag_cost() で curse_flags と TRC_ ではなく TR_ との論理演算を
  行っているため、アイテムの価値の算出が誤った値になる事が
  ある
- get_curse() で狂戦士かの発作の呪いが選ばれることがない

37 files changed:
src/artifact/fixed-art-generator.cpp
src/artifact/random-art-characteristics.cpp
src/cmd-item/cmd-equipment.cpp
src/cmd-item/cmd-smith.cpp
src/hpmp/hp-mp-processor.cpp
src/inventory/inventory-curse.cpp
src/load/item-loader.cpp
src/load/load-v1-5-0.cpp
src/mind/mind-priest.cpp
src/object-enchant/apply-magic-amulet.cpp
src/object-enchant/apply-magic-armor.cpp
src/object-enchant/apply-magic-others.cpp
src/object-enchant/apply-magic-ring.cpp
src/object-enchant/apply-magic-weapon.cpp
src/object-enchant/apply-magic.cpp
src/object-enchant/object-curse.cpp
src/object-enchant/object-curse.h
src/object-enchant/object-ego.cpp
src/object-enchant/trc-types.h
src/object-hook/hook-checker.cpp
src/object/object-value-calc.cpp
src/perception/identification.cpp
src/player-info/self-info.cpp
src/player/digestion-processor.cpp
src/player/player-status-flags.cpp
src/player/player-status.cpp
src/racial/racial-android.cpp
src/realm/realm-hex.cpp
src/save/item-writer.cpp
src/spell-kind/spells-curse-removal.cpp
src/spell/spells-object.cpp
src/system/angband-version.h
src/system/object-type-definition.cpp
src/system/object-type-definition.h
src/system/player-type-definition.h
src/view/display-characteristic.cpp
src/wizard/artifact-analyzer.cpp

index b0213bc..e3b8aa3 100644 (file)
@@ -53,8 +53,8 @@ static bool invest_terror_mask(player_type *player_ptr, object_type *o_ptr)
     default:
         add_flag(o_ptr->art_flags, TR_AGGRAVATE);
         add_flag(o_ptr->art_flags, TR_TY_CURSE);
-        o_ptr->curse_flags |= (TRC_CURSED | TRC_HEAVY_CURSE);
-        o_ptr->curse_flags |= get_curse(player_ptr, 2, o_ptr);
+        o_ptr->curse_flags.set({ TRC::CURSED, TRC::HEAVY_CURSE });
+        o_ptr->curse_flags.set(get_curse(player_ptr, 2, o_ptr));
         return false;
     }
 }
@@ -94,7 +94,7 @@ static void invest_special_artifact_abilities(player_type *player_ptr, object_ty
     case ART_MURAMASA:
         if (player_ptr->pclass != CLASS_SAMURAI) {
             add_flag(o_ptr->art_flags, TR_NO_MAGIC);
-            o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
+            o_ptr->curse_flags.set(TRC::HEAVY_CURSE);
         }
         return;
     case ART_ROBINTON:
@@ -179,22 +179,22 @@ static void invest_curse_to_fixed_artifact(player_type *player_ptr, artifact_typ
         set_bits(o_ptr->ident, IDENT_BROKEN);
 
     if (a_ptr->gen_flags.has(TRG::CURSED))
-        set_bits(o_ptr->curse_flags, TRC_CURSED);
+        o_ptr->curse_flags.set(TRC::CURSED);
 
     if (a_ptr->gen_flags.has(TRG::HEAVY_CURSE))
-        set_bits(o_ptr->curse_flags, TRC_HEAVY_CURSE);
+        o_ptr->curse_flags.set(TRC::HEAVY_CURSE);
 
     if (a_ptr->gen_flags.has(TRG::PERMA_CURSE))
-        set_bits(o_ptr->curse_flags, TRC_PERMA_CURSE);
+        o_ptr->curse_flags.set(TRC::PERMA_CURSE);
 
     if (a_ptr->gen_flags.has(TRG::RANDOM_CURSE0))
-        set_bits(o_ptr->curse_flags, get_curse(player_ptr, 0, o_ptr));
+        o_ptr->curse_flags.set(get_curse(player_ptr, 0, o_ptr));
 
     if (a_ptr->gen_flags.has(TRG::RANDOM_CURSE1))
-        set_bits(o_ptr->curse_flags, get_curse(player_ptr, 1, o_ptr));
+        o_ptr->curse_flags.set(get_curse(player_ptr, 1, o_ptr));
 
     if (a_ptr->gen_flags.has(TRG::RANDOM_CURSE2))
-        set_bits(o_ptr->curse_flags, get_curse(player_ptr, 2, o_ptr));
+        o_ptr->curse_flags.set(get_curse(player_ptr, 2, o_ptr));
 }
 
 /*!
index 6b0c039..4fc5fdd 100644 (file)
@@ -33,7 +33,7 @@ static void pval_subtraction(object_type *o_ptr)
 static void add_negative_flags(object_type *o_ptr)
 {
     if (one_in_(4))
-        o_ptr->curse_flags |= TRC_PERMA_CURSE;
+        o_ptr->curse_flags.set(TRC::PERMA_CURSE);
 
     if (one_in_(3))
         add_flag(o_ptr->art_flags, TR_TY_CURSE);
@@ -74,7 +74,7 @@ static void add_negative_flags(object_type *o_ptr)
 void curse_artifact(player_type *player_ptr, object_type *o_ptr)
 {
     pval_subtraction(o_ptr);
-    o_ptr->curse_flags |= (TRC_HEAVY_CURSE | TRC_CURSED);
+    o_ptr->curse_flags.set({ TRC::HEAVY_CURSE, TRC::CURSED });
     remove_flag(o_ptr->art_flags, TR_BLESSED);
     add_negative_flags(o_ptr);
     if ((player_ptr->pclass != CLASS_WARRIOR) && (player_ptr->pclass != CLASS_ARCHER) && (player_ptr->pclass != CLASS_CAVALRY)
index 92af737..a7fd0b2 100644 (file)
@@ -313,15 +313,15 @@ void do_cmd_takeoff(player_type *creature_ptr)
     PlayerEnergy energy(creature_ptr);
     if (object_is_cursed(o_ptr))
     {
-        if ((o_ptr->curse_flags & TRC_PERMA_CURSE) || (creature_ptr->pclass != CLASS_BERSERKER)) {
+        if (o_ptr->curse_flags.has(TRC::PERMA_CURSE) || (creature_ptr->pclass != CLASS_BERSERKER)) {
             msg_print(_("ふーむ、どうやら呪われているようだ。", "Hmmm, it seems to be cursed."));
             return;
         }
 
-        if (((o_ptr->curse_flags & TRC_HEAVY_CURSE) && one_in_(7)) || one_in_(4)) {
+        if ((o_ptr->curse_flags.has(TRC::HEAVY_CURSE) && one_in_(7)) || one_in_(4)) {
             msg_print(_("呪われた装備を力づくで剥がした!", "You tore off a piece of cursed equipment by sheer strength!"));
             o_ptr->ident |= (IDENT_SENSE);
-            o_ptr->curse_flags = 0L;
+            o_ptr->curse_flags.clear();
             o_ptr->feeling = FEEL_NONE;
             creature_ptr->update |= PU_BONUS;
             creature_ptr->window_flags |= PW_EQUIP;
index 33b0548..84e13bc 100644 (file)
@@ -288,7 +288,7 @@ static void drain_essence(player_type *creature_ptr)
     old_pval = o_ptr->pval;
     old_name2 = o_ptr->name2;
     old_timeout = o_ptr->timeout;
-    if (o_ptr->curse_flags & (TRC_CURSED | TRC_HEAVY_CURSE | TRC_PERMA_CURSE))
+    if (o_ptr->curse_flags.has_any_of({ TRC::CURSED, TRC::HEAVY_CURSE, TRC::PERMA_CURSE }))
         dec--;
     if (has_flag(old_flgs, TR_ADD_L_CURSE))
         dec--;
index 77984e7..f16a118 100644 (file)
@@ -275,7 +275,7 @@ void process_player_hp_mp(player_type *creature_ptr)
         if (creature_ptr->special_defense & (KAMAE_MASK | KATA_MASK)) {
             regen_amount /= 2;
         }
-        if (creature_ptr->cursed & TRC_SLOW_REGEN) {
+        if (creature_ptr->cursed.has(TRC::SLOW_REGEN)) {
             regen_amount /= 5;
         }
     }
index 45d258e..32d5b8d 100644 (file)
 #include "util/string-processor.h"
 #include "view/display-messages.h"
 
-#define TRC_P_FLAG_MASK                                                                                                                                        \
-    (TRC_TELEPORT_SELF | TRC_CHAINSWORD | TRC_TY_CURSE | TRC_DRAIN_EXP | TRC_ADD_L_CURSE | TRC_ADD_H_CURSE | TRC_CALL_ANIMAL | TRC_CALL_DEMON                  \
-        | TRC_CALL_DRAGON | TRC_COWARDICE | TRC_TELEPORT | TRC_DRAIN_HP | TRC_DRAIN_MANA | TRC_CALL_UNDEAD | TRC_BERS_RAGE)
+namespace {
+const EnumClassFlagGroup<TRC> TRC_P_FLAG_MASK({ TRC::TY_CURSE, TRC::DRAIN_EXP, TRC::ADD_L_CURSE, TRC::ADD_H_CURSE, TRC::CALL_ANIMAL, TRC::CALL_DEMON, TRC::CALL_DRAGON,
+    TRC::COWARDICE, TRC::TELEPORT, TRC::DRAIN_HP, TRC::DRAIN_MANA, TRC::CALL_UNDEAD, TRC::BERS_RAGE });
+const EnumClassFlagGroup<TRCS> TRCS_P_FLAG_MASK({ TRCS::TELEPORT_SELF, TRCS::CHAINSWORD });
+}
 
-static bool is_specific_curse(BIT_FLAGS flag)
+static bool is_specific_curse(TRC flag)
 {
-    return (flag == TRC_ADD_L_CURSE) || (flag == TRC_ADD_H_CURSE) || (flag == TRC_DRAIN_HP) || (flag == TRC_DRAIN_MANA) || (flag == TRC_CALL_ANIMAL)
-        || (flag == TRC_CALL_DEMON) || (flag == TRC_CALL_DRAGON) || (flag == TRC_CALL_UNDEAD) || (flag == TRC_COWARDICE) || (flag == TRC_LOW_MELEE)
-        || (flag == TRC_LOW_AC) || (flag == TRC_HARD_SPELL) || (flag == TRC_FAST_DIGEST) || (flag == TRC_SLOW_REGEN || flag == TRC_BERS_RAGE);
+    switch (flag) {
+    case TRC::ADD_L_CURSE:
+    case TRC::ADD_H_CURSE:
+    case TRC::DRAIN_HP:
+    case TRC::DRAIN_MANA:
+    case TRC::CALL_ANIMAL:
+    case TRC::CALL_DEMON:
+    case TRC::CALL_DRAGON:
+    case TRC::CALL_UNDEAD:
+    case TRC::COWARDICE:
+    case TRC::LOW_MELEE:
+    case TRC::LOW_AC:
+    case TRC::HARD_SPELL:
+    case TRC::FAST_DIGEST:
+    case TRC::SLOW_REGEN:
+    case TRC::BERS_RAGE:
+        return true;
+    default:
+        return false;
+    }
 }
 
-static void choise_cursed_item(player_type *creature_ptr, BIT_FLAGS flag, object_type *o_ptr, int *choices, int *number, int item_num)
+static void choise_cursed_item(player_type *creature_ptr, TRC flag, object_type *o_ptr, int *choices, int *number, int item_num)
 {
     if (!is_specific_curse(flag))
         return;
@@ -54,49 +73,49 @@ static void choise_cursed_item(player_type *creature_ptr, BIT_FLAGS flag, object
     BIT_FLAGS flgs[TR_FLAG_SIZE];
     object_flags(creature_ptr, o_ptr, flgs);
     switch (flag) {
-    case TRC_ADD_L_CURSE:
+    case TRC::ADD_L_CURSE:
         cf = TR_ADD_L_CURSE;
         break;
-    case TRC_ADD_H_CURSE:
+    case TRC::ADD_H_CURSE:
         cf = TR_ADD_H_CURSE;
         break;
-    case TRC_DRAIN_HP:
+    case TRC::DRAIN_HP:
         cf = TR_DRAIN_HP;
         break;
-    case TRC_DRAIN_MANA:
+    case TRC::DRAIN_MANA:
         cf = TR_DRAIN_MANA;
         break;
-    case TRC_CALL_ANIMAL:
+    case TRC::CALL_ANIMAL:
         cf = TR_CALL_ANIMAL;
         break;
-    case TRC_CALL_DEMON:
+    case TRC::CALL_DEMON:
         cf = TR_CALL_DEMON;
         break;
-    case TRC_CALL_DRAGON:
+    case TRC::CALL_DRAGON:
         cf = TR_CALL_DRAGON;
         break;
-    case TRC_CALL_UNDEAD:
+    case TRC::CALL_UNDEAD:
         cf = TR_CALL_UNDEAD;
         break;
-    case TRC_COWARDICE:
+    case TRC::COWARDICE:
         cf = TR_COWARDICE;
         break;
-    case TRC_LOW_MELEE:
+    case TRC::LOW_MELEE:
         cf = TR_LOW_MELEE;
         break;
-    case TRC_LOW_AC:
+    case TRC::LOW_AC:
         cf = TR_LOW_AC;
         break;
-    case TRC_HARD_SPELL:
+    case TRC::HARD_SPELL:
         cf = TR_HARD_SPELL;
         break;
-    case TRC_FAST_DIGEST:
+    case TRC::FAST_DIGEST:
         cf = TR_FAST_DIGEST;
         break;
-    case TRC_SLOW_REGEN:
+    case TRC::SLOW_REGEN:
         cf = TR_SLOW_REGEN;
         break;
-    case TRC_BERS_RAGE:
+    case TRC::BERS_RAGE:
         cf = TR_BERS_RAGE;
         break;
     default:
@@ -116,16 +135,16 @@ static void choise_cursed_item(player_type *creature_ptr, BIT_FLAGS flag, object
  * @return 該当の呪いが一つでもあった場合にランダムに選ばれた装備品のオブジェクト構造体参照ポインタを返す。\n
  * 呪いがない場合NULLを返す。
  */
-object_type *choose_cursed_obj_name(player_type *creature_ptr, BIT_FLAGS flag)
+object_type *choose_cursed_obj_name(player_type *creature_ptr, TRC flag)
 {
     int choices[INVEN_TOTAL - INVEN_MAIN_HAND];
     int number = 0;
-    if (!(creature_ptr->cursed & flag))
+    if (creature_ptr->cursed.has_not(flag))
         return NULL;
 
     for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
         object_type *o_ptr = &creature_ptr->inventory_list[i];
-        if (o_ptr->curse_flags & flag) {
+        if (o_ptr->curse_flags.has(flag)) {
             choices[number] = i;
             number++;
             continue;
@@ -143,7 +162,7 @@ object_type *choose_cursed_obj_name(player_type *creature_ptr, BIT_FLAGS flag)
  */
 static void curse_teleport(player_type *creature_ptr)
 {
-    if (((creature_ptr->cursed & TRC_TELEPORT_SELF) == 0) || !one_in_(200))
+    if ((creature_ptr->cursed_special.has_not(TRCS::TELEPORT_SELF)) || !one_in_(200))
         return;
 
     GAME_TEXT o_name[MAX_NLEN];
@@ -185,7 +204,7 @@ static void curse_teleport(player_type *creature_ptr)
  */
 static void occur_chainsword_effect(player_type *creature_ptr)
 {
-    if (((creature_ptr->cursed & TRC_CHAINSWORD) == 0) || !one_in_(CHAINSWORD_NOISE))
+    if ((creature_ptr->cursed_special.has_not(TRCS::CHAINSWORD)) || !one_in_(CHAINSWORD_NOISE))
         return;
 
     char noise[1024];
@@ -196,7 +215,7 @@ static void occur_chainsword_effect(player_type *creature_ptr)
 
 static void curse_drain_exp(player_type *creature_ptr)
 {
-    if ((creature_ptr->prace == RACE_ANDROID) || ((creature_ptr->cursed & TRC_DRAIN_EXP) == 0) || !one_in_(4))
+    if ((creature_ptr->prace == RACE_ANDROID) || (creature_ptr->cursed.has_not(TRC::DRAIN_EXP)) || !one_in_(4))
         return;
 
     creature_ptr->exp -= (creature_ptr->lev + 1) / 2;
@@ -212,18 +231,18 @@ static void curse_drain_exp(player_type *creature_ptr)
 
 static void multiply_low_curse(player_type *creature_ptr)
 {
-    if (((creature_ptr->cursed & TRC_ADD_L_CURSE) == 0) || !one_in_(2000))
+    if ((creature_ptr->cursed.has_not(TRC::ADD_L_CURSE)) || !one_in_(2000))
         return;
 
     object_type *o_ptr;
-    o_ptr = choose_cursed_obj_name(creature_ptr, TRC_ADD_L_CURSE);
-    BIT_FLAGS new_curse = get_curse(creature_ptr, 0, o_ptr);
-    if ((o_ptr->curse_flags & new_curse))
+    o_ptr = choose_cursed_obj_name(creature_ptr, TRC::ADD_L_CURSE);
+    auto new_curse = get_curse(creature_ptr, 0, o_ptr);
+    if (o_ptr->curse_flags.has(new_curse))
         return;
 
     GAME_TEXT o_name[MAX_NLEN];
     describe_flavor(creature_ptr, o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
-    o_ptr->curse_flags |= new_curse;
+    o_ptr->curse_flags.set(new_curse);
     msg_format(_("悪意に満ちた黒いオーラが%sをとりまいた...", "There is a malignant black aura surrounding your %s..."), o_name);
     o_ptr->feeling = FEEL_NONE;
     creature_ptr->update |= (PU_BONUS);
@@ -231,18 +250,18 @@ static void multiply_low_curse(player_type *creature_ptr)
 
 static void multiply_high_curse(player_type *creature_ptr)
 {
-    if (((creature_ptr->cursed & TRC_ADD_H_CURSE) == 0) || !one_in_(2000))
+    if ((creature_ptr->cursed.has_not(TRC::ADD_H_CURSE)) || !one_in_(2000))
         return;
 
     object_type *o_ptr;
-    o_ptr = choose_cursed_obj_name(creature_ptr, TRC_ADD_H_CURSE);
-    BIT_FLAGS new_curse = get_curse(creature_ptr, 1, o_ptr);
-    if ((o_ptr->curse_flags & new_curse))
+    o_ptr = choose_cursed_obj_name(creature_ptr, TRC::ADD_H_CURSE);
+    auto new_curse = get_curse(creature_ptr, 1, o_ptr);
+    if (o_ptr->curse_flags.has(new_curse))
         return;
 
     GAME_TEXT o_name[MAX_NLEN];
     describe_flavor(creature_ptr, o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
-    o_ptr->curse_flags |= new_curse;
+    o_ptr->curse_flags.set(new_curse);
     msg_format(_("悪意に満ちた黒いオーラが%sをとりまいた...", "There is a malignant black aura surrounding your %s..."), o_name);
     o_ptr->feeling = FEEL_NONE;
     creature_ptr->update |= (PU_BONUS);
@@ -253,37 +272,37 @@ static void curse_call_monster(player_type *creature_ptr)
     const int call_type = PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET;
     const int obj_desc_type = OD_OMIT_PREFIX | OD_NAME_ONLY;
     floor_type *floor_ptr = creature_ptr->current_floor_ptr;
-    if ((creature_ptr->cursed & TRC_CALL_ANIMAL) && one_in_(2500)) {
+    if (creature_ptr->cursed.has(TRC::CALL_ANIMAL) && one_in_(2500)) {
         if (summon_specific(creature_ptr, 0, creature_ptr->y, creature_ptr->x, floor_ptr->dun_level, SUMMON_ANIMAL, call_type)) {
             GAME_TEXT o_name[MAX_NLEN];
-            describe_flavor(creature_ptr, o_name, choose_cursed_obj_name(creature_ptr, TRC_CALL_ANIMAL), obj_desc_type);
+            describe_flavor(creature_ptr, o_name, choose_cursed_obj_name(creature_ptr, TRC::CALL_ANIMAL), obj_desc_type);
             msg_format(_("%sが動物を引き寄せた!", "Your %s has attracted an animal!"), o_name);
             disturb(creature_ptr, FALSE, TRUE);
         }
     }
 
-    if ((creature_ptr->cursed & TRC_CALL_DEMON) && one_in_(1111)) {
+    if (creature_ptr->cursed.has(TRC::CALL_DEMON) && one_in_(1111)) {
         if (summon_specific(creature_ptr, 0, creature_ptr->y, creature_ptr->x, floor_ptr->dun_level, SUMMON_DEMON, call_type)) {
             GAME_TEXT o_name[MAX_NLEN];
-            describe_flavor(creature_ptr, o_name, choose_cursed_obj_name(creature_ptr, TRC_CALL_DEMON), obj_desc_type);
+            describe_flavor(creature_ptr, o_name, choose_cursed_obj_name(creature_ptr, TRC::CALL_DEMON), obj_desc_type);
             msg_format(_("%sが悪魔を引き寄せた!", "Your %s has attracted a demon!"), o_name);
             disturb(creature_ptr, FALSE, TRUE);
         }
     }
 
-    if ((creature_ptr->cursed & TRC_CALL_DRAGON) && one_in_(800)) {
+    if (creature_ptr->cursed.has(TRC::CALL_DRAGON) && one_in_(800)) {
         if (summon_specific(creature_ptr, 0, creature_ptr->y, creature_ptr->x, floor_ptr->dun_level, SUMMON_DRAGON, call_type)) {
             GAME_TEXT o_name[MAX_NLEN];
-            describe_flavor(creature_ptr, o_name, choose_cursed_obj_name(creature_ptr, TRC_CALL_DRAGON), obj_desc_type);
+            describe_flavor(creature_ptr, o_name, choose_cursed_obj_name(creature_ptr, TRC::CALL_DRAGON), obj_desc_type);
             msg_format(_("%sがドラゴンを引き寄せた!", "Your %s has attracted a dragon!"), o_name);
             disturb(creature_ptr, FALSE, TRUE);
         }
     }
 
-    if ((creature_ptr->cursed & TRC_CALL_UNDEAD) && one_in_(1111)) {
+    if (creature_ptr->cursed.has(TRC::CALL_UNDEAD) && one_in_(1111)) {
         if (summon_specific(creature_ptr, 0, creature_ptr->y, creature_ptr->x, floor_ptr->dun_level, SUMMON_UNDEAD, call_type)) {
             GAME_TEXT o_name[MAX_NLEN];
-            describe_flavor(creature_ptr, o_name, choose_cursed_obj_name(creature_ptr, TRC_CALL_UNDEAD), obj_desc_type);
+            describe_flavor(creature_ptr, o_name, choose_cursed_obj_name(creature_ptr, TRC::CALL_UNDEAD), obj_desc_type);
             msg_format(_("%sが死霊を引き寄せた!", "Your %s has attracted an undead!"), o_name);
             disturb(creature_ptr, FALSE, TRUE);
         }
@@ -292,7 +311,7 @@ static void curse_call_monster(player_type *creature_ptr)
 
 static void curse_cowardice(player_type *creature_ptr)
 {
-    if (((creature_ptr->cursed & TRC_COWARDICE) == 0) || !one_in_(1500))
+    if ((creature_ptr->cursed.has_not(TRC::COWARDICE)) || !one_in_(1500))
         return;
 
     if (has_resist_fear(creature_ptr))
@@ -309,7 +328,7 @@ static void curse_cowardice(player_type *creature_ptr)
  */
 static void curse_berserk_rage(player_type *creature_ptr)
 {
-    if (((creature_ptr->cursed & TRC_BERS_RAGE) == 0) || !one_in_(1500))
+    if ((creature_ptr->cursed.has_not(TRC::BERS_RAGE)) || !one_in_(1500))
         return;
 
     disturb(creature_ptr, FALSE, TRUE);
@@ -321,22 +340,22 @@ static void curse_berserk_rage(player_type *creature_ptr)
 
 static void curse_drain_hp(player_type *creature_ptr)
 {
-    if (((creature_ptr->cursed & TRC_DRAIN_HP) == 0) || !one_in_(666))
+    if ((creature_ptr->cursed.has_not(TRC::DRAIN_HP)) || !one_in_(666))
         return;
 
     GAME_TEXT o_name[MAX_NLEN];
-    describe_flavor(creature_ptr, o_name, choose_cursed_obj_name(creature_ptr, TRC_DRAIN_HP), (OD_OMIT_PREFIX | OD_NAME_ONLY));
+    describe_flavor(creature_ptr, o_name, choose_cursed_obj_name(creature_ptr, TRC::DRAIN_HP), (OD_OMIT_PREFIX | OD_NAME_ONLY));
     msg_format(_("%sはあなたの体力を吸収した!", "Your %s drains HP from you!"), o_name);
     take_hit(creature_ptr, DAMAGE_LOSELIFE, MIN(creature_ptr->lev * 2, 100), o_name);
 }
 
 static void curse_drain_mp(player_type *creature_ptr)
 {
-    if (((creature_ptr->cursed & TRC_DRAIN_MANA) == 0) || (creature_ptr->csp == 0) || !one_in_(666))
+    if ((creature_ptr->cursed.has_not(TRC::DRAIN_MANA)) || (creature_ptr->csp == 0) || !one_in_(666))
         return;
 
     GAME_TEXT o_name[MAX_NLEN];
-    describe_flavor(creature_ptr, o_name, choose_cursed_obj_name(creature_ptr, TRC_DRAIN_MANA), (OD_OMIT_PREFIX | OD_NAME_ONLY));
+    describe_flavor(creature_ptr, o_name, choose_cursed_obj_name(creature_ptr, TRC::DRAIN_MANA), (OD_OMIT_PREFIX | OD_NAME_ONLY));
     msg_format(_("%sはあなたの魔力を吸収した!", "Your %s drains mana from you!"), o_name);
     creature_ptr->csp -= MIN(creature_ptr->lev, 50);
     if (creature_ptr->csp < 0) {
@@ -349,12 +368,12 @@ static void curse_drain_mp(player_type *creature_ptr)
 
 static void occur_curse_effects(player_type *creature_ptr)
 {
-    if (((creature_ptr->cursed & TRC_P_FLAG_MASK) == 0) || creature_ptr->phase_out || creature_ptr->wild_mode)
+    if ((creature_ptr->cursed.has_none_of(TRC_P_FLAG_MASK) && creature_ptr->cursed_special.has_none_of(TRCS_P_FLAG_MASK)) || creature_ptr->phase_out || creature_ptr->wild_mode)
         return;
 
     curse_teleport(creature_ptr);
     occur_chainsword_effect(creature_ptr);
-    if ((creature_ptr->cursed & TRC_TY_CURSE) && one_in_(TY_CURSE_CHANCE)) {
+    if (creature_ptr->cursed.has(TRC::TY_CURSE) && one_in_(TY_CURSE_CHANCE)) {
         int count = 0;
         (void)activate_ty_curse(creature_ptr, FALSE, &count);
     }
@@ -365,7 +384,7 @@ static void occur_curse_effects(player_type *creature_ptr)
     curse_call_monster(creature_ptr);
     curse_cowardice(creature_ptr);
     curse_berserk_rage(creature_ptr);
-    if ((creature_ptr->cursed & TRC_TELEPORT) && one_in_(200) && !creature_ptr->anti_tele) {
+    if (creature_ptr->cursed.has(TRC::TELEPORT) && one_in_(200) && !creature_ptr->anti_tele) {
         disturb(creature_ptr, FALSE, TRUE);
         teleport_player(creature_ptr, 40, TELEPORT_PASSIVE);
     }
index 4fcd6af..6d26463 100644 (file)
@@ -153,10 +153,21 @@ void rd_item(player_type *player_ptr, object_type *o_ptr)
     else
         o_ptr->art_flags[4] = 0;
 
-    if (flags & SAVE_ITEM_CURSE_FLAGS)
-        rd_u32b(&o_ptr->curse_flags);
-    else
-        o_ptr->curse_flags = 0;
+    if (flags & SAVE_ITEM_CURSE_FLAGS) {
+        if (loading_savefile_version_is_older_than(5)) {
+            u32b tmp32u;
+            rd_u32b(&tmp32u);
+            std::bitset<32> rd_bits_cursed_flags(tmp32u);
+            for (size_t i = 0; i < std::min(o_ptr->curse_flags.size(), rd_bits_cursed_flags.size()); i++) {
+                auto f = static_cast<TRC>(i);
+                o_ptr->curse_flags[f] = rd_bits_cursed_flags[i];
+            }
+        } else {
+            rd_FlagGroup(o_ptr->curse_flags, rd_byte);
+        }
+    } else {
+        o_ptr->curse_flags.clear();
+    }
 
     /* Monster holding object */
     if (flags & SAVE_ITEM_HELD_M_IDX)
index d35e7dc..b87332d 100644 (file)
@@ -128,30 +128,36 @@ void rd_item_old(player_type *player_ptr, object_type *o_ptr)
     }
 
     if (h_older_than(1, 0, 11)) {
-        o_ptr->curse_flags = 0L;
+        o_ptr->curse_flags.clear();
         if (o_ptr->ident & 0x40) {
-            o_ptr->curse_flags |= TRC_CURSED;
+            o_ptr->curse_flags.set(TRC::CURSED);
             if (o_ptr->art_flags[2] & 0x40000000L)
-                o_ptr->curse_flags |= TRC_HEAVY_CURSE;
+                o_ptr->curse_flags.set(TRC::HEAVY_CURSE);
             if (o_ptr->art_flags[2] & 0x80000000L)
-                o_ptr->curse_flags |= TRC_PERMA_CURSE;
+                o_ptr->curse_flags.set(TRC::PERMA_CURSE);
             if (object_is_fixed_artifact(o_ptr)) {
                 artifact_type *a_ptr = &a_info[o_ptr->name1];
                 if (a_ptr->gen_flags.has(TRG::HEAVY_CURSE))
-                    o_ptr->curse_flags |= TRC_HEAVY_CURSE;
+                    o_ptr->curse_flags.set(TRC::HEAVY_CURSE);
                 if (a_ptr->gen_flags.has(TRG::PERMA_CURSE))
-                    o_ptr->curse_flags |= TRC_PERMA_CURSE;
+                    o_ptr->curse_flags.set(TRC::PERMA_CURSE);
             } else if (object_is_ego(o_ptr)) {
                 ego_item_type *e_ptr = &e_info[o_ptr->name2];
                 if (e_ptr->gen_flags.has(TRG::HEAVY_CURSE))
-                    o_ptr->curse_flags |= TRC_HEAVY_CURSE;
+                    o_ptr->curse_flags.set(TRC::HEAVY_CURSE);
                 if (e_ptr->gen_flags.has(TRG::PERMA_CURSE))
-                    o_ptr->curse_flags |= TRC_PERMA_CURSE;
+                    o_ptr->curse_flags.set(TRC::PERMA_CURSE);
             }
         }
         o_ptr->art_flags[2] &= (0x1FFFFFFFL);
     } else {
-        rd_u32b(&o_ptr->curse_flags);
+        u32b tmp32u;
+        rd_u32b(&tmp32u);
+        std::bitset<32> rd_bits_cursed_flags(tmp32u);
+        for (size_t i = 0; i < std::min(o_ptr->curse_flags.size(), rd_bits_cursed_flags.size()); i++) {
+            auto f = static_cast<TRC>(i);
+            o_ptr->curse_flags[f] = rd_bits_cursed_flags[i];
+        }
     }
 
     rd_s16b(&o_ptr->held_m_idx);
index f3375de..ab9f628 100644 (file)
@@ -43,8 +43,8 @@ bool bless_weapon(player_type *caster_ptr)
     object_flags(caster_ptr, o_ptr, flgs);
 
     if (object_is_cursed(o_ptr)) {
-        if (((o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint1(100) < 33)) || has_flag(flgs, TR_ADD_L_CURSE) || has_flag(flgs, TR_ADD_H_CURSE)
-            || (o_ptr->curse_flags & TRC_PERMA_CURSE)) {
+        if ((o_ptr->curse_flags.has(TRC::HEAVY_CURSE) && (randint1(100) < 33)) || has_flag(flgs, TR_ADD_L_CURSE) || has_flag(flgs, TR_ADD_H_CURSE)
+            || o_ptr->curse_flags.has(TRC::PERMA_CURSE)) {
 #ifdef JP
             msg_format("%sを覆う黒いオーラは祝福を跳ね返した!", o_name);
 #else
@@ -59,7 +59,7 @@ bool bless_weapon(player_type *caster_ptr)
 #else
         msg_format("A malignant aura leaves %s %s.", ((item >= 0) ? "your" : "the"), o_name);
 #endif
-        o_ptr->curse_flags = 0L;
+        o_ptr->curse_flags.clear();
         set_bits(o_ptr->ident, IDENT_SENSE);
         set_bits(o_ptr->feeling, FEEL_NONE);
         set_bits(caster_ptr->update, PU_BONUS);
index 56e77d8..2e23a58 100644 (file)
@@ -46,7 +46,7 @@ void AmuletEnchanter::apply_magic()
 
     if ((this->power == 2) && one_in_(2)) {
         give_ego_index();
-        this->o_ptr->curse_flags = 0L;
+        this->o_ptr->curse_flags.clear();
         return;
     }
 
@@ -65,7 +65,7 @@ void AmuletEnchanter::enchant()
         this->o_ptr->pval = 1 + (PARAMETER_VALUE)m_bonus(5, this->level);
         if (this->power < 0) {
             set_bits(this->o_ptr->ident, IDENT_BROKEN);
-            set_bits(this->o_ptr->curse_flags, TRC_CURSED);
+            this->o_ptr->curse_flags.set(TRC::CURSED);
             this->o_ptr->pval = 0 - this->o_ptr->pval;
         }
 
@@ -78,7 +78,7 @@ void AmuletEnchanter::enchant()
 
         if (this->power < 0) {
             set_bits(this->o_ptr->ident, IDENT_BROKEN);
-            set_bits(this->o_ptr->curse_flags, TRC_CURSED);
+            this->o_ptr->curse_flags.set(TRC::CURSED);
             this->o_ptr->pval = 0 - this->o_ptr->pval;
         }
 
@@ -86,7 +86,7 @@ void AmuletEnchanter::enchant()
     case SV_AMULET_NO_MAGIC:
     case SV_AMULET_NO_TELE:
         if (this->power < 0) {
-            set_bits(this->o_ptr->curse_flags, TRC_CURSED);
+            this->o_ptr->curse_flags.set(TRC::CURSED);
         }
 
         break;
@@ -108,7 +108,7 @@ void AmuletEnchanter::enchant()
         }
 
         set_bits(this->o_ptr->ident, IDENT_BROKEN);
-        set_bits(this->o_ptr->curse_flags, TRC_CURSED);
+        this->o_ptr->curse_flags.set(TRC::CURSED);
         this->o_ptr->pval = 0 - (this->o_ptr->pval);
         break;
     case SV_AMULET_THE_MAGI:
@@ -118,7 +118,7 @@ void AmuletEnchanter::enchant()
         break;
     case SV_AMULET_DOOM:
         set_bits(this->o_ptr->ident, IDENT_BROKEN);
-        set_bits(this->o_ptr->curse_flags, TRC_CURSED);
+        this->o_ptr->curse_flags.set(TRC::CURSED);
         this->o_ptr->pval = 0 - (randint1(5) + (PARAMETER_VALUE)m_bonus(5, this->level));
         this->o_ptr->to_a = 0 - (randint1(5) + (ARMOUR_CLASS)m_bonus(5, this->level));
         if (this->power > 0) {
@@ -133,7 +133,7 @@ void AmuletEnchanter::enchant()
         }
 
         set_bits(this->o_ptr->ident, IDENT_BROKEN);
-        set_bits(this->o_ptr->curse_flags, TRC_CURSED);
+        this->o_ptr->curse_flags.set(TRC::CURSED);
         this->o_ptr->pval = 0 - this->o_ptr->pval;
         break;
     }
@@ -366,5 +366,5 @@ void AmuletEnchanter::give_cursed()
     }
 
     set_bits(this->o_ptr->ident, IDENT_BROKEN);
-    set_bits(this->o_ptr->curse_flags, TRC_CURSED | TRC_HEAVY_CURSE);
+    this->o_ptr->curse_flags.set({ TRC::CURSED, TRC::HEAVY_CURSE });
 }
index e9555e6..29a8952 100644 (file)
@@ -47,7 +47,7 @@ void apply_magic_armor(player_type *owner_ptr, object_type *o_ptr, DEPTH level,
         }
 
         if (o_ptr->to_a < 0)
-            o_ptr->curse_flags |= TRC_CURSED;
+            o_ptr->curse_flags.set(TRC::CURSED);
     }
 
     switch (o_ptr->tval) {
index a36ed47..5cc1c25 100644 (file)
@@ -148,7 +148,7 @@ void apply_magic_others(player_type *owner_ptr, object_type *o_ptr, int power)
 
         o_ptr->pval = i;
         if (one_in_(6))
-            o_ptr->curse_flags |= TRC_CURSED;
+            o_ptr->curse_flags.set(TRC::CURSED);
 
         break;
     }
index 8383d21..b710e0c 100644 (file)
@@ -46,7 +46,7 @@ void RingEnchanter::apply_magic()
 
     if ((this->power == 2) && one_in_(2)) {
         give_ego_index();
-        this->o_ptr->curse_flags = 0L;
+        this->o_ptr->curse_flags.clear();
         return;
     }
 
@@ -70,7 +70,7 @@ void RingEnchanter::enchant()
 
         if (this->power < 0) {
             set_bits(this->o_ptr->ident, IDENT_BROKEN);
-            set_bits(this->o_ptr->curse_flags, TRC_CURSED);
+            this->o_ptr->curse_flags.set(TRC::CURSED);
             this->o_ptr->pval = 0 - (this->o_ptr->pval);
         }
 
@@ -83,7 +83,7 @@ void RingEnchanter::enchant()
         this->o_ptr->pval = 1 + (PARAMETER_VALUE)m_bonus(5, this->level);
         if (this->power < 0) {
             set_bits(this->o_ptr->ident, IDENT_BROKEN);
-            set_bits(this->o_ptr->curse_flags, TRC_CURSED);
+            this->o_ptr->curse_flags.set(TRC::CURSED);
             this->o_ptr->pval = 0 - (this->o_ptr->pval);
         }
 
@@ -96,7 +96,7 @@ void RingEnchanter::enchant()
 
         if (this->power < 0) {
             set_bits(this->o_ptr->ident, IDENT_BROKEN);
-            set_bits(this->o_ptr->curse_flags, TRC_CURSED);
+            this->o_ptr->curse_flags.set(TRC::CURSED);
             this->o_ptr->pval = 0 - (this->o_ptr->pval);
             break;
         }
@@ -119,7 +119,7 @@ void RingEnchanter::enchant()
         this->o_ptr->pval = 1 + (PARAMETER_VALUE)m_bonus(5, this->level);
         if (this->power < 0) {
             set_bits(this->o_ptr->ident, IDENT_BROKEN);
-            set_bits(this->o_ptr->curse_flags, TRC_CURSED);
+            this->o_ptr->curse_flags.set(TRC::CURSED);
             this->o_ptr->pval = 0 - (this->o_ptr->pval);
         }
 
@@ -133,7 +133,7 @@ void RingEnchanter::enchant()
     case SV_RING_WEAKNESS:
     case SV_RING_STUPIDITY:
         set_bits(this->o_ptr->ident, IDENT_BROKEN);
-        set_bits(this->o_ptr->curse_flags, TRC_CURSED);
+        this->o_ptr->curse_flags.set(TRC::CURSED);
         this->o_ptr->pval = 0 - (1 + (PARAMETER_VALUE)m_bonus(5, this->level));
         if (this->power > 0) {
             this->power = 0 - this->power;
@@ -142,7 +142,7 @@ void RingEnchanter::enchant()
         break;
     case SV_RING_WOE:
         set_bits(this->o_ptr->ident, IDENT_BROKEN);
-        set_bits(this->o_ptr->curse_flags, TRC_CURSED);
+        this->o_ptr->curse_flags.set(TRC::CURSED);
         this->o_ptr->to_a = 0 - (5 + (ARMOUR_CLASS)m_bonus(10, this->level));
         this->o_ptr->pval = 0 - (1 + (PARAMETER_VALUE)m_bonus(5, this->level));
         if (this->power > 0) {
@@ -154,7 +154,7 @@ void RingEnchanter::enchant()
         this->o_ptr->to_d = 1 + randint1(5) + (HIT_POINT)m_bonus(16, this->level);
         if (this->power < 0) {
             set_bits(this->o_ptr->ident, IDENT_BROKEN);
-            set_bits(this->o_ptr->curse_flags, TRC_CURSED);
+            this->o_ptr->curse_flags.set(TRC::CURSED);
             this->o_ptr->to_d = 0 - this->o_ptr->to_d;
         }
 
@@ -163,7 +163,7 @@ void RingEnchanter::enchant()
         this->o_ptr->to_h = 1 + randint1(5) + (HIT_PROB)m_bonus(16, this->level);
         if (this->power < 0) {
             set_bits(this->o_ptr->ident, IDENT_BROKEN);
-            set_bits(this->o_ptr->curse_flags, TRC_CURSED);
+            this->o_ptr->curse_flags.set(TRC::CURSED);
             this->o_ptr->to_h = 0 - this->o_ptr->to_h;
         }
 
@@ -172,7 +172,7 @@ void RingEnchanter::enchant()
         this->o_ptr->to_a = 5 + randint1(8) + (ARMOUR_CLASS)m_bonus(10, this->level);
         if (this->power < 0) {
             set_bits(this->o_ptr->ident, IDENT_BROKEN);
-            set_bits(this->o_ptr->curse_flags, TRC_CURSED);
+            this->o_ptr->curse_flags.set(TRC::CURSED);
             this->o_ptr->to_a = 0 - this->o_ptr->to_a;
         }
 
@@ -183,7 +183,7 @@ void RingEnchanter::enchant()
 
         if (this->power < 0) {
             set_bits(this->o_ptr->ident, IDENT_BROKEN);
-            set_bits(this->o_ptr->curse_flags, TRC_CURSED);
+            this->o_ptr->curse_flags.set(TRC::CURSED);
             this->o_ptr->to_h = 0 - this->o_ptr->to_h;
             this->o_ptr->to_d = 0 - this->o_ptr->to_d;
         }
@@ -197,14 +197,14 @@ void RingEnchanter::enchant()
 
         if (this->power < 0) {
             set_bits(this->o_ptr->ident, IDENT_BROKEN);
-            set_bits(this->o_ptr->curse_flags, TRC_CURSED);
+            this->o_ptr->curse_flags.set(TRC::CURSED);
             this->o_ptr->pval = 0 - this->o_ptr->pval;
         }
 
         break;
     case SV_RING_AGGRAVATION:
         set_bits(this->o_ptr->ident, IDENT_BROKEN);
-        set_bits(this->o_ptr->curse_flags, TRC_CURSED);
+        this->o_ptr->curse_flags.set(TRC::CURSED);
         if (this->power > 0) {
             this->power = 0 - this->power;
         }
@@ -525,5 +525,5 @@ void RingEnchanter::give_cursed()
     }
 
     set_bits(this->o_ptr->ident, IDENT_BROKEN);
-    set_bits(this->o_ptr->curse_flags, TRC_CURSED | TRC_HEAVY_CURSE);
+    this->o_ptr->curse_flags.set({ TRC::CURSED, TRC::HEAVY_CURSE });
 }
index 335d232..3210c30 100644 (file)
@@ -58,7 +58,7 @@ void apply_magic_weapon(player_type *owner_ptr, object_type *o_ptr, DEPTH level,
         }
 
         if (o_ptr->to_h + o_ptr->to_d < 0)
-            o_ptr->curse_flags |= TRC_CURSED;
+            o_ptr->curse_flags.set(TRC::CURSED);
     }
 
     if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DIAMOND_EDGE))
index d51b52c..9cd27ad 100644 (file)
@@ -196,16 +196,16 @@ void apply_magic_to_object(player_type *owner_ptr, object_type *o_ptr, DEPTH lev
             o_ptr->ident |= (IDENT_BROKEN);
 
         if (k_ptr->gen_flags.has(TRG::CURSED))
-            o_ptr->curse_flags |= (TRC_CURSED);
+            o_ptr->curse_flags.set(TRC::CURSED);
         if (k_ptr->gen_flags.has(TRG::HEAVY_CURSE))
-            o_ptr->curse_flags |= TRC_HEAVY_CURSE;
+            o_ptr->curse_flags.set(TRC::HEAVY_CURSE);
         if (k_ptr->gen_flags.has(TRG::PERMA_CURSE))
-            o_ptr->curse_flags |= TRC_PERMA_CURSE;
+            o_ptr->curse_flags.set(TRC::PERMA_CURSE);
         if (k_ptr->gen_flags.has(TRG::RANDOM_CURSE0))
-            o_ptr->curse_flags |= get_curse(owner_ptr, 0, o_ptr);
+            o_ptr->curse_flags.set(get_curse(owner_ptr, 0, o_ptr));
         if (k_ptr->gen_flags.has(TRG::RANDOM_CURSE1))
-            o_ptr->curse_flags |= get_curse(owner_ptr, 1, o_ptr);
+            o_ptr->curse_flags.set(get_curse(owner_ptr, 1, o_ptr));
         if (k_ptr->gen_flags.has(TRG::RANDOM_CURSE2))
-            o_ptr->curse_flags |= get_curse(owner_ptr, 2, o_ptr);
+            o_ptr->curse_flags.set(get_curse(owner_ptr, 2, o_ptr));
     }
 }
index ab4436b..227d3af 100644 (file)
 #include "util/bit-flags-calculator.h"
 #include "view/display-messages.h"
 
-#define MAX_CURSE 18
-#define TRC_SPECIAL_MASK (TRC_TY_CURSE | TRC_AGGRAVATE)
-#define TRC_HEAVY_MASK (TRC_TY_CURSE | TRC_AGGRAVATE | TRC_DRAIN_EXP | TRC_ADD_H_CURSE | TRC_CALL_DEMON | TRC_CALL_DRAGON | TRC_CALL_UNDEAD | TRC_TELEPORT)
+namespace {
+const EnumClassFlagGroup<TRC> TRC_SPECIAL_MASK({TRC::TY_CURSE, TRC::AGGRAVATE});
+const EnumClassFlagGroup<TRC> TRC_HEAVY_MASK({TRC::TY_CURSE, TRC::AGGRAVATE, TRC::DRAIN_EXP, TRC::ADD_H_CURSE, TRC::CALL_DEMON, TRC::CALL_DRAGON, TRC::CALL_UNDEAD, TRC::TELEPORT});
+}
 
 /*!
  * @brief アイテムに付加される可能性のある呪いを指定する。
  * @param o_ptr 呪いをかけられる装備オブジェクトの構造体参照ポインタ
  * @return 与える呪いのID
  */
-BIT_FLAGS get_curse(player_type *owner_ptr, int power, object_type *o_ptr)
+TRC get_curse(player_type *owner_ptr, int power, object_type *o_ptr)
 {
-    BIT_FLAGS new_curse;
+    TRC new_curse;
 
     while (TRUE) {
-        new_curse = (1U << (randint0(MAX_CURSE) + 4));
+        new_curse = static_cast<TRC>(rand_range(static_cast<int>(TRC::TY_CURSE), static_cast<int>(TRC::MAX) - 1));
         if (power == 2) {
-            if (!(new_curse & TRC_HEAVY_MASK))
+            if (TRC_HEAVY_MASK.has_not(new_curse))
                 continue;
         } else if (power == 1) {
-            if (new_curse & TRC_SPECIAL_MASK)
+            if (TRC_SPECIAL_MASK.has(new_curse))
                 continue;
         } else if (power == 0) {
-            if (new_curse & TRC_HEAVY_MASK)
+            if (TRC_HEAVY_MASK.has(new_curse))
                 continue;
         }
 
-        if (new_curse == TRC_LOW_MELEE && !object_is_weapon(owner_ptr, o_ptr))
+        if (new_curse == TRC::LOW_MELEE && !object_is_weapon(owner_ptr, o_ptr))
             continue;
-        if (new_curse == TRC_LOW_AC && !object_is_armour(owner_ptr, o_ptr))
+        if (new_curse == TRC::LOW_AC && !object_is_armour(owner_ptr, o_ptr))
             continue;
         break;
     }
@@ -86,24 +87,24 @@ void curse_equipment(player_type *owner_ptr, PERCENTAGE chance, PERCENTAGE heavy
     bool changed = FALSE;
     int curse_power = 0;
     if ((randint1(100) <= heavy_chance) && (object_is_artifact(o_ptr) || object_is_ego(o_ptr))) {
-        if (!(o_ptr->curse_flags & TRC_HEAVY_CURSE))
+        if (o_ptr->curse_flags.has_not(TRC::HEAVY_CURSE))
             changed = TRUE;
-        o_ptr->curse_flags |= TRC_HEAVY_CURSE;
-        o_ptr->curse_flags |= TRC_CURSED;
+        o_ptr->curse_flags.set(TRC::HEAVY_CURSE);
+        o_ptr->curse_flags.set(TRC::CURSED);
         curse_power++;
     } else {
         if (!object_is_cursed(o_ptr))
             changed = TRUE;
-        o_ptr->curse_flags |= TRC_CURSED;
+        o_ptr->curse_flags.set(TRC::CURSED);
     }
 
     if (heavy_chance >= 50)
         curse_power++;
 
-    BIT_FLAGS new_curse = get_curse(owner_ptr, curse_power, o_ptr);
-    if (!(o_ptr->curse_flags & new_curse)) {
+    auto new_curse = get_curse(owner_ptr, curse_power, o_ptr);
+    if (o_ptr->curse_flags.has_not(new_curse)) {
         changed = TRUE;
-        o_ptr->curse_flags |= new_curse;
+        o_ptr->curse_flags.set(new_curse);
     }
 
     if (changed) {
index 2283a9a..b51b622 100644 (file)
@@ -4,5 +4,6 @@
 
 typedef struct object_type object_type;
 typedef struct player_type player_type;
-BIT_FLAGS get_curse(player_type *owner_ptr, int power, object_type *o_ptr);
+enum class TRC;
+TRC get_curse(player_type *owner_ptr, int power, object_type *o_ptr);
 void curse_equipment(player_type *owner_ptr, PERCENTAGE chance, PERCENTAGE heavy_chance);
index e85fa20..8eeaff7 100644 (file)
@@ -67,17 +67,17 @@ byte get_random_ego(byte slot, bool good)
 static void ego_invest_curse(player_type *player_ptr, object_type *o_ptr, EnumClassFlagGroup<TRG> &gen_flags)
 {
     if (gen_flags.has(TRG::CURSED))
-        o_ptr->curse_flags |= (TRC_CURSED);
+        o_ptr->curse_flags.set(TRC::CURSED);
     if (gen_flags.has(TRG::HEAVY_CURSE))
-        o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
+        o_ptr->curse_flags.set(TRC::HEAVY_CURSE);
     if (gen_flags.has(TRG::PERMA_CURSE))
-        o_ptr->curse_flags |= (TRC_PERMA_CURSE);
+        o_ptr->curse_flags.set(TRC::PERMA_CURSE);
     if (gen_flags.has(TRG::RANDOM_CURSE0))
-        o_ptr->curse_flags |= get_curse(player_ptr, 0, o_ptr);
+        o_ptr->curse_flags.set(get_curse(player_ptr, 0, o_ptr));
     if (gen_flags.has(TRG::RANDOM_CURSE1))
-        o_ptr->curse_flags |= get_curse(player_ptr, 1, o_ptr);
+        o_ptr->curse_flags.set(get_curse(player_ptr, 1, o_ptr));
     if (gen_flags.has(TRG::RANDOM_CURSE2))
-        o_ptr->curse_flags |= get_curse(player_ptr, 2, o_ptr);
+        o_ptr->curse_flags.set(get_curse(player_ptr, 2, o_ptr));
 }
 
 /*!
index 659f961..ba9058e 100644 (file)
@@ -1,33 +1,35 @@
 #pragma once
 
 /* TRCが何の略かは分からない (type / ??? / curse)*/
-enum trc_curse_type {
-       TRC_CURSED = 0x00000001L,
-    TRC_HEAVY_CURSE = 0x00000002L,
-    TRC_PERMA_CURSE = 0x00000004L,
-    TRC_XXX1 = 0x00000008L,
-    TRC_TY_CURSE = 0x00000010L,
-    TRC_AGGRAVATE = 0x00000020L,
-    TRC_DRAIN_EXP = 0x00000040L,
-    TRC_SLOW_REGEN = 0x00000080L,
-    TRC_ADD_L_CURSE = 0x00000100L,
-    TRC_ADD_H_CURSE = 0x00000200L,
-    TRC_CALL_ANIMAL = 0x00000400L,
-    TRC_CALL_DEMON = 0x00000800L,
-    TRC_CALL_DRAGON = 0x00001000L,
-    TRC_COWARDICE = 0x00002000L,
-    TRC_TELEPORT = 0x00004000L,
-    TRC_LOW_MELEE = 0x00008000L,
-    TRC_LOW_AC = 0x00010000L,
-    TRC_HARD_SPELL = 0x00020000L,
-    TRC_FAST_DIGEST = 0x00040000L,
-    TRC_DRAIN_HP = 0x00080000L,
-    TRC_DRAIN_MANA = 0x00100000L,
-    TRC_CALL_UNDEAD = 0x00200000L,
-    TRC_BERS_RAGE = 0x00400000L,
+enum class TRC {
+       CURSED = 0,
+    HEAVY_CURSE = 1,
+    PERMA_CURSE = 2,
+    XXX1 = 3,
+    TY_CURSE = 4,
+    AGGRAVATE = 5,
+    DRAIN_EXP = 6,
+    SLOW_REGEN = 7,
+    ADD_L_CURSE = 8,
+    ADD_H_CURSE = 9,
+    CALL_ANIMAL = 10,
+    CALL_DEMON = 11,
+    CALL_DRAGON = 12,
+    COWARDICE = 13,
+    TELEPORT = 14,
+    LOW_MELEE = 15,
+    LOW_AC = 16,
+    HARD_SPELL = 17,
+    FAST_DIGEST = 18,
+    DRAIN_HP = 19,
+    DRAIN_MANA = 20,
+    CALL_UNDEAD = 21,
+    BERS_RAGE = 22,
+    MAX,
 };
 
-enum trc_special_type {
-    TRC_TELEPORT_SELF = 0x00000001L,
-    TRC_CHAINSWORD = 0x00000002L
+enum class TRCS {
+    TELEPORT_SELF = 0,
+    CHAINSWORD = 1,
+    MAX,
 };
index 0982d58..bab896a 100644 (file)
@@ -8,4 +8,4 @@ bool object_is_held_monster(object_type *o_ptr) { return o_ptr->held_m_idx != 0;
 
 bool object_is_broken(object_type *o_ptr) { return (o_ptr->ident & IDENT_BROKEN) != 0; }
 
-bool object_is_cursed(object_type *o_ptr) { return o_ptr->curse_flags != 0; }
+bool object_is_cursed(object_type *o_ptr) { return o_ptr->curse_flags.any(); }
index 008fa50..183f629 100644 (file)
@@ -437,15 +437,15 @@ PRICE flag_cost(player_type *player_ptr, object_type *o_ptr, int plusses)
         total -= 10000;
     if (has_flag(flgs, TR_BLESSED))
         total += 750;
-    if (o_ptr->curse_flags & TR_ADD_L_CURSE)
+    if (o_ptr->curse_flags.has(TRC::ADD_L_CURSE))
         total -= 5000;
-    if (o_ptr->curse_flags & TR_ADD_H_CURSE)
+    if (o_ptr->curse_flags.has(TRC::ADD_H_CURSE))
         total -= 12500;
-    if (o_ptr->curse_flags & TRC_CURSED)
+    if (o_ptr->curse_flags.has(TRC::CURSED))
         total -= 5000;
-    if (o_ptr->curse_flags & TRC_HEAVY_CURSE)
+    if (o_ptr->curse_flags.has(TRC::HEAVY_CURSE))
         total -= 12500;
-    if (o_ptr->curse_flags & TRC_PERMA_CURSE)
+    if (o_ptr->curse_flags.has(TRC::PERMA_CURSE))
         total -= 15000;
 
     /* Also, give some extra for activatable powers... */
index ec5b63c..c451190 100644 (file)
@@ -595,9 +595,9 @@ bool screen_object(player_type *player_ptr, object_type *o_ptr, BIT_FLAGS mode)
     }
 
     if (object_is_cursed(o_ptr)) {
-        if (o_ptr->curse_flags & TRC_PERMA_CURSE) {
+        if (o_ptr->curse_flags.has(TRC::PERMA_CURSE)) {
             info[i++] = _("それは永遠の呪いがかけられている。", "It is permanently cursed.");
-        } else if (o_ptr->curse_flags & TRC_HEAVY_CURSE) {
+        } else if (o_ptr->curse_flags.has(TRC::HEAVY_CURSE)) {
             info[i++] = _("それは強力な呪いがかけられている。", "It is heavily cursed.");
         } else {
             info[i++] = _("それは呪われている。", "It is cursed.");
@@ -610,78 +610,78 @@ bool screen_object(player_type *player_ptr, object_type *o_ptr, BIT_FLAGS mode)
         }
     }
 
-    if ((has_flag(flgs, TR_TY_CURSE)) || (o_ptr->curse_flags & TRC_TY_CURSE)) {
+    if ((has_flag(flgs, TR_TY_CURSE)) || o_ptr->curse_flags.has(TRC::TY_CURSE)) {
         info[i++] = _("それは太古の禍々しい怨念が宿っている。", "It carries an ancient foul curse.");
     }
 
-    if ((has_flag(flgs, TR_AGGRAVATE)) || (o_ptr->curse_flags & TRC_AGGRAVATE)) {
+    if ((has_flag(flgs, TR_AGGRAVATE)) || o_ptr->curse_flags.has(TRC::AGGRAVATE)) {
         info[i++] = _("それは付近のモンスターを怒らせる。", "It aggravates nearby creatures.");
     }
 
-    if ((has_flag(flgs, TR_DRAIN_EXP)) || (o_ptr->curse_flags & TRC_DRAIN_EXP)) {
+    if ((has_flag(flgs, TR_DRAIN_EXP)) || o_ptr->curse_flags.has(TRC::DRAIN_EXP)) {
         info[i++] = _("それは経験値を吸い取る。", "It drains experience.");
     }
 
-    if (o_ptr->curse_flags & TRC_SLOW_REGEN) {
+    if (o_ptr->curse_flags.has(TRC::SLOW_REGEN)) {
         info[i++] = _("それは回復力を弱める。", "It slows your regenerative powers.");
     }
 
-    if ((o_ptr->curse_flags & TRC_ADD_L_CURSE) || has_flag(flgs, TR_ADD_L_CURSE)) {
+    if (o_ptr->curse_flags.has(TRC::ADD_L_CURSE) || has_flag(flgs, TR_ADD_L_CURSE)) {
         info[i++] = _("それは弱い呪いを増やす。", "It adds weak curses.");
     }
 
-    if ((o_ptr->curse_flags & TRC_ADD_H_CURSE) || has_flag(flgs, TR_ADD_H_CURSE)) {
+    if (o_ptr->curse_flags.has(TRC::ADD_H_CURSE) || has_flag(flgs, TR_ADD_H_CURSE)) {
         info[i++] = _("それは強力な呪いを増やす。", "It adds heavy curses.");
     }
 
-    if ((has_flag(flgs, TR_CALL_ANIMAL)) || (o_ptr->curse_flags & TRC_CALL_ANIMAL)) {
+    if ((has_flag(flgs, TR_CALL_ANIMAL)) || o_ptr->curse_flags.has(TRC::CALL_ANIMAL)) {
         info[i++] = _("それは動物を呼び寄せる。", "It attracts animals.");
     }
 
-    if ((has_flag(flgs, TR_CALL_DEMON)) || (o_ptr->curse_flags & TRC_CALL_DEMON)) {
+    if ((has_flag(flgs, TR_CALL_DEMON)) || o_ptr->curse_flags.has(TRC::CALL_DEMON)) {
         info[i++] = _("それは悪魔を呼び寄せる。", "It attracts demons.");
     }
 
-    if ((has_flag(flgs, TR_CALL_DRAGON)) || (o_ptr->curse_flags & TRC_CALL_DRAGON)) {
+    if ((has_flag(flgs, TR_CALL_DRAGON)) || o_ptr->curse_flags.has(TRC::CALL_DRAGON)) {
         info[i++] = _("それはドラゴンを呼び寄せる。", "It attracts dragons.");
     }
 
-    if ((has_flag(flgs, TR_CALL_UNDEAD)) || (o_ptr->curse_flags & TRC_CALL_UNDEAD)) {
+    if ((has_flag(flgs, TR_CALL_UNDEAD)) || o_ptr->curse_flags.has(TRC::CALL_UNDEAD)) {
         info[i++] = _("それは死霊を呼び寄せる。", "It attracts undead.");
     }
 
-    if ((has_flag(flgs, TR_COWARDICE)) || (o_ptr->curse_flags & TRC_COWARDICE)) {
+    if ((has_flag(flgs, TR_COWARDICE)) || o_ptr->curse_flags.has(TRC::COWARDICE)) {
         info[i++] = _("それは恐怖感を引き起こす。", "It makes you subject to cowardice.");
     }
 
     if (has_flag(flgs, TR_BERS_RAGE))
         info[i++] = _("それは狂戦士化の発作を引き起こす。", "It makes you subject to berserker fits.");
 
-    if ((has_flag(flgs, TR_TELEPORT)) || (o_ptr->curse_flags & TRC_TELEPORT)) {
+    if ((has_flag(flgs, TR_TELEPORT)) || o_ptr->curse_flags.has(TRC::TELEPORT)) {
         info[i++] = _("それはランダムなテレポートを引き起こす。", "It induces random teleportation.");
     }
 
-    if ((has_flag(flgs, TR_LOW_MELEE)) || o_ptr->curse_flags & TRC_LOW_MELEE) {
+    if ((has_flag(flgs, TR_LOW_MELEE)) || o_ptr->curse_flags.has(TRC::LOW_MELEE)) {
         info[i++] = _("それは攻撃を外しやすい。", "It causes you to miss blows.");
     }
 
-    if ((has_flag(flgs, TR_LOW_AC)) || (o_ptr->curse_flags & TRC_LOW_AC)) {
+    if ((has_flag(flgs, TR_LOW_AC)) || o_ptr->curse_flags.has(TRC::LOW_AC)) {
         info[i++] = _("それは攻撃を受けやすい。", "It helps your enemies' blows.");
     }
 
-    if ((has_flag(flgs, TR_HARD_SPELL)) || (o_ptr->curse_flags & TRC_HARD_SPELL)) {
+    if ((has_flag(flgs, TR_HARD_SPELL)) || o_ptr->curse_flags.has(TRC::HARD_SPELL)) {
         info[i++] = _("それは魔法を唱えにくくする。", "It encumbers you while spellcasting.");
     }
 
-    if ((has_flag(flgs, TR_FAST_DIGEST)) || (o_ptr->curse_flags & TRC_FAST_DIGEST)) {
+    if ((has_flag(flgs, TR_FAST_DIGEST)) || o_ptr->curse_flags.has(TRC::FAST_DIGEST)) {
         info[i++] = _("それはあなたの新陳代謝を速くする。", "It speeds your metabolism.");
     }
 
-    if ((has_flag(flgs, TR_DRAIN_HP)) || (o_ptr->curse_flags & TRC_DRAIN_HP)) {
+    if ((has_flag(flgs, TR_DRAIN_HP)) || o_ptr->curse_flags.has(TRC::DRAIN_HP)) {
         info[i++] = _("それはあなたの体力を吸い取る。", "It drains you.");
     }
 
-    if ((has_flag(flgs, TR_DRAIN_MANA)) || (o_ptr->curse_flags & TRC_DRAIN_MANA)) {
+    if ((has_flag(flgs, TR_DRAIN_MANA)) || o_ptr->curse_flags.has(TRC::DRAIN_MANA)) {
         info[i++] = _("それはあなたの魔力を吸い取る。", "It drains your mana.");
     }
 
index b3ae124..d455666 100644 (file)
@@ -55,58 +55,58 @@ static void set_bad_status_info(player_type *creature_ptr, self_info_type *self_
 
 static void set_curse_info(player_type *creature_ptr, self_info_type *self_ptr)
 {
-    if (creature_ptr->cursed & TRC_TY_CURSE)
+    if (creature_ptr->cursed.has(TRC::TY_CURSE))
         self_ptr->info[self_ptr->line++] = _("あなたは邪悪な怨念に包まれている。", "You carry an ancient foul curse.");
 
     if (has_aggravate(creature_ptr))
         self_ptr->info[self_ptr->line++] = _("あなたはモンスターを怒らせている。", "You aggravate monsters.");
 
-    if (creature_ptr->cursed & TRC_DRAIN_EXP)
+    if (creature_ptr->cursed.has(TRC::DRAIN_EXP))
         self_ptr->info[self_ptr->line++] = _("あなたは経験値を吸われている。", "You occasionally lose experience for no reason.");
 
-    if (creature_ptr->cursed & TRC_SLOW_REGEN)
+    if (creature_ptr->cursed.has(TRC::SLOW_REGEN))
         self_ptr->info[self_ptr->line++] = _("あなたの回復力は非常に遅い。", "You regenerate slowly.");
 
-    if (creature_ptr->cursed & TRC_ADD_L_CURSE)
+    if (creature_ptr->cursed.has(TRC::ADD_L_CURSE))
         self_ptr->info[self_ptr->line++] = _("あなたの弱い呪いは増える。", "Your weak curses multiply."); /* 暫定的 -- henkma */
 
-    if (creature_ptr->cursed & TRC_ADD_H_CURSE)
+    if (creature_ptr->cursed.has(TRC::ADD_H_CURSE))
         self_ptr->info[self_ptr->line++] = _("あなたの強い呪いは増える。", "Your heavy curses multiply."); /* 暫定的 -- henkma */
 
-    if (creature_ptr->cursed & TRC_CALL_ANIMAL)
+    if (creature_ptr->cursed.has(TRC::CALL_ANIMAL))
         self_ptr->info[self_ptr->line++] = _("あなたは動物に狙われている。", "You attract animals.");
 
-    if (creature_ptr->cursed & TRC_CALL_DEMON)
+    if (creature_ptr->cursed.has(TRC::CALL_DEMON))
         self_ptr->info[self_ptr->line++] = _("あなたは悪魔に狙われている。", "You attract demons.");
 
-    if (creature_ptr->cursed & TRC_CALL_DRAGON)
+    if (creature_ptr->cursed.has(TRC::CALL_DRAGON))
         self_ptr->info[self_ptr->line++] = _("あなたはドラゴンに狙われている。", "You attract dragons.");
 
-    if (creature_ptr->cursed & TRC_COWARDICE)
+    if (creature_ptr->cursed.has(TRC::COWARDICE))
         self_ptr->info[self_ptr->line++] = _("あなたは時々臆病になる。", "You are subject to cowardice.");
 
-    if (creature_ptr->cursed & TRC_BERS_RAGE)
+    if (creature_ptr->cursed.has(TRC::BERS_RAGE))
         self_ptr->info[self_ptr->line++] = _("あなたは狂戦士化の発作を起こす。", "You are subject to berserker fits.");
 
-    if (creature_ptr->cursed & TRC_TELEPORT)
+    if (creature_ptr->cursed.has(TRC::TELEPORT))
         self_ptr->info[self_ptr->line++] = _("あなたの位置はひじょうに不安定だ。", "Your position is very uncertain.");
 
-    if (creature_ptr->cursed & TRC_LOW_MELEE)
+    if (creature_ptr->cursed.has(TRC::LOW_MELEE))
         self_ptr->info[self_ptr->line++] = _("あなたの武器は攻撃を外しやすい。", "Your weapon causes you to miss blows.");
 
-    if (creature_ptr->cursed & TRC_LOW_AC)
+    if (creature_ptr->cursed.has(TRC::LOW_AC))
         self_ptr->info[self_ptr->line++] = _("あなたは攻撃を受けやすい。", "You are subject to be hit.");
 
-    if (creature_ptr->cursed & TRC_HARD_SPELL)
+    if (creature_ptr->cursed.has(TRC::HARD_SPELL))
         self_ptr->info[self_ptr->line++] = _("あなたは魔法を失敗しやすい。", "Your spells fail more frequently.");
 
-    if (creature_ptr->cursed & TRC_FAST_DIGEST)
+    if (creature_ptr->cursed.has(TRC::FAST_DIGEST))
         self_ptr->info[self_ptr->line++] = _("あなたはすぐお腹がへる。", "You have a good appetite.");
 
-    if (creature_ptr->cursed & TRC_DRAIN_HP)
+    if (creature_ptr->cursed.has(TRC::DRAIN_HP))
         self_ptr->info[self_ptr->line++] = _("あなたは体力を吸われている。", "You occasionally lose hit points for no reason.");
 
-    if (creature_ptr->cursed & TRC_DRAIN_MANA)
+    if (creature_ptr->cursed.has(TRC::DRAIN_MANA))
         self_ptr->info[self_ptr->line++] = _("あなたは魔力を吸われている。", "You occasionally lose spell points for no reason.");
 }
 
index 9d05a84..622eeb2 100644 (file)
@@ -33,7 +33,7 @@ void starve_player(player_type *creature_ptr)
             digestion += 20;
         if (creature_ptr->special_defense & (KAMAE_MASK | KATA_MASK))
             digestion += 20;
-        if (creature_ptr->cursed & TRC_FAST_DIGEST)
+        if (creature_ptr->cursed.has(TRC::FAST_DIGEST))
             digestion += 30;
 
         if (creature_ptr->slow_digest)
index 16aac31..f3d268b 100644 (file)
@@ -1186,10 +1186,11 @@ void update_curses(player_type *creature_ptr)
 {
     object_type *o_ptr;
     BIT_FLAGS flgs[TR_FLAG_SIZE];
-    creature_ptr->cursed = 0L;
+    creature_ptr->cursed.clear();
+    creature_ptr->cursed_special.clear();
 
     if (creature_ptr->pseikaku == PERSONALITY_SEXY)
-        creature_ptr->cursed |= (TRC_AGGRAVATE);
+        creature_ptr->cursed.set(TRC::AGGRAVATE);
 
     for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
         o_ptr = &creature_ptr->inventory_list[i];
@@ -1197,63 +1198,65 @@ void update_curses(player_type *creature_ptr)
             continue;
         object_flags(creature_ptr, o_ptr, flgs);
         if (has_flag(flgs, TR_AGGRAVATE))
-            creature_ptr->cursed |= TRC_AGGRAVATE;
+            creature_ptr->cursed.set(TRC::AGGRAVATE);
         if (has_flag(flgs, TR_DRAIN_EXP))
-            creature_ptr->cursed |= TRC_DRAIN_EXP;
+            creature_ptr->cursed.set(TRC::DRAIN_EXP);
         if (has_flag(flgs, TR_TY_CURSE))
-            creature_ptr->cursed |= TRC_TY_CURSE;
+            creature_ptr->cursed.set(TRC::TY_CURSE);
         if (has_flag(flgs, TR_ADD_L_CURSE))
-            creature_ptr->cursed |= TRC_ADD_L_CURSE;
+            creature_ptr->cursed.set(TRC::ADD_L_CURSE);
         if (has_flag(flgs, TR_ADD_H_CURSE))
-            creature_ptr->cursed |= TRC_ADD_H_CURSE;
+            creature_ptr->cursed.set(TRC::ADD_H_CURSE);
         if (has_flag(flgs, TR_DRAIN_HP))
-            creature_ptr->cursed |= TRC_DRAIN_HP;
+            creature_ptr->cursed.set(TRC::DRAIN_HP);
         if (has_flag(flgs, TR_DRAIN_MANA))
-            creature_ptr->cursed |= TRC_DRAIN_MANA;
+            creature_ptr->cursed.set(TRC::DRAIN_MANA);
         if (has_flag(flgs, TR_CALL_ANIMAL))
-            creature_ptr->cursed |= TRC_CALL_ANIMAL;
+            creature_ptr->cursed.set(TRC::CALL_ANIMAL);
         if (has_flag(flgs, TR_CALL_DEMON))
-            creature_ptr->cursed |= TRC_CALL_DEMON;
+            creature_ptr->cursed.set(TRC::CALL_DEMON);
         if (has_flag(flgs, TR_CALL_DRAGON))
-            creature_ptr->cursed |= TRC_CALL_DRAGON;
+            creature_ptr->cursed.set(TRC::CALL_DRAGON);
         if (has_flag(flgs, TR_CALL_UNDEAD))
-            creature_ptr->cursed |= TRC_CALL_UNDEAD;
+            creature_ptr->cursed.set(TRC::CALL_UNDEAD);
         if (has_flag(flgs, TR_COWARDICE))
-            creature_ptr->cursed |= TRC_COWARDICE;
+            creature_ptr->cursed.set(TRC::COWARDICE);
         if (has_flag(flgs, TR_LOW_MELEE))
-            creature_ptr->cursed |= TRC_LOW_MELEE;
+            creature_ptr->cursed.set(TRC::LOW_MELEE);
         if (has_flag(flgs, TR_LOW_AC))
-            creature_ptr->cursed |= TRC_LOW_AC;
+            creature_ptr->cursed.set(TRC::LOW_AC);
         if (has_flag(flgs, TR_HARD_SPELL))
-            creature_ptr->cursed |= TRC_HARD_SPELL;
+            creature_ptr->cursed.set(TRC::HARD_SPELL);
         if (has_flag(flgs, TR_FAST_DIGEST))
-            creature_ptr->cursed |= TRC_FAST_DIGEST;
+            creature_ptr->cursed.set(TRC::FAST_DIGEST);
         if (has_flag(flgs, TR_SLOW_REGEN))
-            creature_ptr->cursed |= TRC_SLOW_REGEN;
+            creature_ptr->cursed.set(TRC::SLOW_REGEN);
         if (has_flag(flgs, TR_BERS_RAGE))
-            creature_ptr->cursed |= TRC_BERS_RAGE;
+            creature_ptr->cursed.set(TRC::BERS_RAGE);
 
-        creature_ptr->cursed |= (o_ptr->curse_flags & (0xFFFFFFF0L));
+        auto obj_curse_flags = o_ptr->curse_flags;
+        obj_curse_flags.reset({ TRC::CURSED, TRC::HEAVY_CURSE, TRC::PERMA_CURSE });
+        creature_ptr->cursed.set(obj_curse_flags);
         if (o_ptr->name1 == ART_CHAINSWORD)
-            creature_ptr->cursed |= TRC_CHAINSWORD;
+            creature_ptr->cursed_special.set(TRCS::CHAINSWORD);
 
         if (has_flag(flgs, TR_TELEPORT)) {
             if (object_is_cursed(o_ptr))
-                creature_ptr->cursed |= TRC_TELEPORT;
+                creature_ptr->cursed.set(TRC::TELEPORT);
             else {
                 concptr insc = quark_str(o_ptr->inscription);
 
                 /* {.} will stop random teleportation. */
                 if (o_ptr->inscription && angband_strchr(insc, '.')) {
                 } else {
-                    creature_ptr->cursed |= TRC_TELEPORT_SELF;
+                    creature_ptr->cursed_special.set(TRCS::TELEPORT_SELF);
                 }
             }
         }
     }
 
-    if (creature_ptr->cursed & TRC_TELEPORT)
-        creature_ptr->cursed &= ~(TRC_TELEPORT_SELF);
+    if (creature_ptr->cursed.has(TRC::TELEPORT))
+        creature_ptr->cursed_special.reset(TRCS::TELEPORT_SELF);
 }
 
 BIT_FLAGS has_impact(player_type *creature_ptr)
@@ -2090,7 +2093,7 @@ bool has_good_luck(player_type *creature_ptr)
 
 BIT_FLAGS player_aggravate_state(player_type *creature_ptr)
 {
-    if (creature_ptr->cursed & TRC_AGGRAVATE) {
+    if (creature_ptr->cursed.has(TRC::AGGRAVATE)) {
         if ((is_specific_player_race(creature_ptr, RACE_S_FAIRY)) && (creature_ptr->pseikaku != PERSONALITY_SEXY)) {
             return AGGRAVATE_S_FAIRY;
         }
index 2be8317..ad4d7ab 100644 (file)
@@ -1559,7 +1559,7 @@ static s16b calc_num_blow(player_type *creature_ptr, int i)
  * * 性格きれものなら減算(-3)
  * * 性格ちからじまんとがまんづよいなら加算(+1)
  * * 性格チャージマンなら加算(+5)
- * * 装備品にTRC_HARD_SPELLがあるなら加算(軽い呪いなら+3/重い呪いなら+10)
+ * * 装備品にTRC::HARD_SPELLがあるなら加算(軽い呪いなら+3/重い呪いなら+10)
  */
 static s16b calc_to_magic_chance(player_type *creature_ptr)
 {
@@ -1581,8 +1581,8 @@ static s16b calc_to_magic_chance(player_type *creature_ptr)
         if (!o_ptr->k_idx)
             continue;
         object_flags(creature_ptr, o_ptr, flgs);
-        if (any_bits(o_ptr->curse_flags, TRC_HARD_SPELL)) {
-            if (any_bits(o_ptr->curse_flags, TRC_HEAVY_CURSE)) {
+        if (o_ptr->curse_flags.has(TRC::HARD_SPELL)) {
+            if (o_ptr->curse_flags.has(TRC::HEAVY_CURSE)) {
                 chance += 10;
             } else {
                 chance += 3;
@@ -1652,8 +1652,8 @@ static ARMOUR_CLASS calc_to_ac(player_type *creature_ptr, bool is_real_value)
         if (is_real_value || object_is_known(o_ptr))
             ac += o_ptr->to_a;
 
-        if (any_bits(o_ptr->curse_flags, TRC_LOW_AC)) {
-            if (any_bits(o_ptr->curse_flags, TRC_HEAVY_CURSE)) {
+        if (o_ptr->curse_flags.has(TRC::LOW_AC)) {
+            if (o_ptr->curse_flags.has(TRC::HEAVY_CURSE)) {
                 if (is_real_value || object_is_fully_known(o_ptr))
                     ac -= 30;
             } else {
@@ -1730,11 +1730,11 @@ static ARMOUR_CLASS calc_to_ac(player_type *creature_ptr, bool is_real_value)
                 continue;
             if (!object_is_cursed(o_ptr))
                 continue;
-            if (any_bits(o_ptr->curse_flags, TRC_CURSED))
+            if (o_ptr->curse_flags.has(TRC::CURSED))
                 ac += 5;
-            if (any_bits(o_ptr->curse_flags, TRC_HEAVY_CURSE))
+            if (o_ptr->curse_flags.has(TRC::HEAVY_CURSE))
                 ac += 7;
-            if (any_bits(o_ptr->curse_flags, TRC_PERMA_CURSE))
+            if (o_ptr->curse_flags.has(TRC::PERMA_CURSE))
                 ac += 13;
         }
     }
@@ -2006,13 +2006,13 @@ static s16b calc_to_damage(player_type *creature_ptr, INVENTORY_IDX slot, bool i
 
     if ((creature_ptr->realm1 == REALM_HEX) && object_is_cursed(o_ptr)) {
         if (hex_spelling(creature_ptr, HEX_RUNESWORD)) {
-            if (any_bits(o_ptr->curse_flags, (TRC_CURSED))) {
+            if (o_ptr->curse_flags.has(TRC::CURSED)) {
                 damage += 5;
             }
-            if (any_bits(o_ptr->curse_flags, (TRC_HEAVY_CURSE))) {
+            if (o_ptr->curse_flags.has(TRC::HEAVY_CURSE)) {
                 damage += 7;
             }
-            if (any_bits(o_ptr->curse_flags, (TRC_PERMA_CURSE))) {
+            if (o_ptr->curse_flags.has(TRC::PERMA_CURSE)) {
                 damage += 13;
             }
         }
@@ -2184,8 +2184,8 @@ static s16b calc_to_hit(player_type *creature_ptr, INVENTORY_IDX slot, bool is_r
         }
 
         /* Low melee penalty */
-        if ((object_is_fully_known(o_ptr) || is_real_value) && any_bits(o_ptr->curse_flags, TRC_LOW_MELEE)) {
-            if (any_bits(o_ptr->curse_flags, TRC_HEAVY_CURSE)) {
+        if ((object_is_fully_known(o_ptr) || is_real_value) && o_ptr->curse_flags.has(TRC::LOW_MELEE)) {
+            if (o_ptr->curse_flags.has(TRC::HEAVY_CURSE)) {
                 hit -= 15;
             } else {
                 hit -= 5;
@@ -2235,16 +2235,16 @@ static s16b calc_to_hit(player_type *creature_ptr, INVENTORY_IDX slot, bool is_r
 
         /* Hex realm bonuses */
         if ((creature_ptr->realm1 == REALM_HEX) && object_is_cursed(o_ptr)) {
-            if (any_bits(o_ptr->curse_flags, (TRC_CURSED))) {
+            if (o_ptr->curse_flags.has(TRC::CURSED)) {
                 hit += 5;
             }
-            if (any_bits(o_ptr->curse_flags, (TRC_HEAVY_CURSE))) {
+            if (o_ptr->curse_flags.has(TRC::HEAVY_CURSE)) {
                 hit += 7;
             }
-            if (any_bits(o_ptr->curse_flags, (TRC_PERMA_CURSE))) {
+            if (o_ptr->curse_flags.has(TRC::PERMA_CURSE)) {
                 hit += 13;
             }
-            if (any_bits(o_ptr->curse_flags, (TRC_TY_CURSE))) {
+            if (o_ptr->curse_flags.has(TRC::TY_CURSE)) {
                 hit += 5;
             }
         }
@@ -2347,8 +2347,8 @@ static s16b calc_to_hit_bow(player_type *creature_ptr, bool is_real_value)
         if (o_ptr->k_idx) {
             object_flags(creature_ptr, o_ptr, flgs);
 
-            if (any_bits(o_ptr->curse_flags, TRC_LOW_MELEE)) {
-                if (any_bits(o_ptr->curse_flags, TRC_HEAVY_CURSE)) {
+            if (o_ptr->curse_flags.has(TRC::LOW_MELEE)) {
+                if (o_ptr->curse_flags.has(TRC::HEAVY_CURSE)) {
                     pow -= 15;
                 } else {
                     pow -= 5;
index 28663fb..194cb1a 100644 (file)
@@ -76,7 +76,7 @@ void calc_android_exp(player_type *creature_ptr)
         q_ptr->wipe();
         q_ptr->copy_from(o_ptr);
         q_ptr->discount = 0;
-        q_ptr->curse_flags = 0L;
+        q_ptr->curse_flags.clear();
 
         if (object_is_fixed_artifact(o_ptr)) {
             level = (level + MAX(a_info[o_ptr->name1].level - 8, 5)) / 2;
index cadf33c..f4da2e1 100644 (file)
@@ -234,16 +234,16 @@ concptr do_hex_spell(player_type *caster_ptr, SPELL_IDX spell, spell_type mode)
             } else {
                 int curse_rank = 0;
                 msg_format(_("恐怖の暗黒オーラがあなたの%sを包み込んだ!", "A terrible black aura blasts your %s!"), o_name);
-                o_ptr->curse_flags |= (TRC_CURSED);
+                o_ptr->curse_flags.set(TRC::CURSED);
 
                 if (object_is_artifact(o_ptr) || object_is_ego(o_ptr)) {
 
                     if (one_in_(3))
-                        o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
+                        o_ptr->curse_flags.set(TRC::HEAVY_CURSE);
                     if (one_in_(666)) {
-                        o_ptr->curse_flags |= (TRC_TY_CURSE);
+                        o_ptr->curse_flags.set(TRC::TY_CURSE);
                         if (one_in_(666))
-                            o_ptr->curse_flags |= (TRC_PERMA_CURSE);
+                            o_ptr->curse_flags.set(TRC::PERMA_CURSE);
 
                         add_flag(o_ptr->art_flags, TR_AGGRAVATE);
                         add_flag(o_ptr->art_flags, TR_VORPAL);
@@ -253,7 +253,7 @@ concptr do_hex_spell(player_type *caster_ptr, SPELL_IDX spell, spell_type mode)
                     }
                 }
 
-                o_ptr->curse_flags |= get_curse(caster_ptr, curse_rank, o_ptr);
+                o_ptr->curse_flags.set(get_curse(caster_ptr, curse_rank, o_ptr));
             }
 
             caster_ptr->update |= (PU_BONUS);
@@ -542,16 +542,16 @@ concptr do_hex_spell(player_type *caster_ptr, SPELL_IDX spell, spell_type mode)
             } else {
                 int curse_rank = 0;
                 msg_format(_("恐怖の暗黒オーラがあなたの%sを包み込んだ!", "A terrible black aura blasts your %s!"), o_name);
-                o_ptr->curse_flags |= (TRC_CURSED);
+                o_ptr->curse_flags.set(TRC::CURSED);
 
                 if (object_is_artifact(o_ptr) || object_is_ego(o_ptr)) {
 
                     if (one_in_(3))
-                        o_ptr->curse_flags |= (TRC_HEAVY_CURSE);
+                        o_ptr->curse_flags.set(TRC::HEAVY_CURSE);
                     if (one_in_(666)) {
-                        o_ptr->curse_flags |= (TRC_TY_CURSE);
+                        o_ptr->curse_flags.set(TRC::TY_CURSE);
                         if (one_in_(666))
-                            o_ptr->curse_flags |= (TRC_PERMA_CURSE);
+                            o_ptr->curse_flags.set(TRC::PERMA_CURSE);
 
                         add_flag(o_ptr->art_flags, TR_AGGRAVATE);
                         add_flag(o_ptr->art_flags, TR_RES_POIS);
@@ -562,7 +562,7 @@ concptr do_hex_spell(player_type *caster_ptr, SPELL_IDX spell, spell_type mode)
                     }
                 }
 
-                o_ptr->curse_flags |= get_curse(caster_ptr, curse_rank, o_ptr);
+                o_ptr->curse_flags.set(get_curse(caster_ptr, curse_rank, o_ptr));
             }
 
             caster_ptr->update |= (PU_BONUS);
@@ -716,21 +716,21 @@ concptr do_hex_spell(player_type *caster_ptr, SPELL_IDX spell, spell_type mode)
             object_flags(caster_ptr, o_ptr, f);
 
             caster_ptr->csp += (caster_ptr->lev / 5) + randint1(caster_ptr->lev / 5);
-            if (has_flag(f, TR_TY_CURSE) || (o_ptr->curse_flags & TRC_TY_CURSE))
+            if (has_flag(f, TR_TY_CURSE) || o_ptr->curse_flags.has(TRC::TY_CURSE))
                 caster_ptr->csp += randint1(5);
             if (caster_ptr->csp > caster_ptr->msp)
                 caster_ptr->csp = caster_ptr->msp;
 
-            if (o_ptr->curse_flags & TRC_PERMA_CURSE) {
+            if (o_ptr->curse_flags.has(TRC::PERMA_CURSE)) {
                 /* Nothing */
-            } else if (o_ptr->curse_flags & TRC_HEAVY_CURSE) {
+            } else if (o_ptr->curse_flags.has(TRC::HEAVY_CURSE)) {
                 if (one_in_(7)) {
                     msg_print(_("呪いを全て吸い取った。", "A heavy curse vanished."));
-                    o_ptr->curse_flags = 0L;
+                    o_ptr->curse_flags.clear();
                 }
-            } else if ((o_ptr->curse_flags & (TRC_CURSED)) && one_in_(3)) {
+            } else if (o_ptr->curse_flags.has(TRC::CURSED) && one_in_(3)) {
                 msg_print(_("呪いを全て吸い取った。", "A curse vanished."));
-                o_ptr->curse_flags = 0L;
+                o_ptr->curse_flags.clear();
             }
 
             add = FALSE;
index bc616fa..dc19a43 100644 (file)
@@ -64,7 +64,7 @@ static void write_item_flags(object_type *o_ptr, BIT_FLAGS *flags)
     if (o_ptr->art_flags[4])
         *flags |= SAVE_ITEM_ART_FLAGS4;
 
-    if (o_ptr->curse_flags)
+    if (o_ptr->curse_flags.any())
         *flags |= SAVE_ITEM_CURSE_FLAGS;
 
     if (o_ptr->held_m_idx)
@@ -152,7 +152,7 @@ static void write_item_info(object_type *o_ptr, const BIT_FLAGS flags)
         wr_u32b(o_ptr->art_flags[4]);
 
     if (flags & SAVE_ITEM_CURSE_FLAGS)
-        wr_u32b(o_ptr->curse_flags);
+        wr_FlagGroup(o_ptr->curse_flags, wr_byte);
 
     if (flags & SAVE_ITEM_HELD_M_IDX)
         wr_s16b(o_ptr->held_m_idx);
index 8913bdf..1110ad4 100644 (file)
@@ -26,14 +26,14 @@ static int exe_curse_removal(player_type *creature_ptr, int all)
             continue;
         if (!object_is_cursed(o_ptr))
             continue;
-        if (!all && (o_ptr->curse_flags & TRC_HEAVY_CURSE))
+        if (!all && o_ptr->curse_flags.has(TRC::HEAVY_CURSE))
             continue;
-        if (o_ptr->curse_flags & TRC_PERMA_CURSE) {
-            o_ptr->curse_flags &= (TRC_CURSED | TRC_HEAVY_CURSE | TRC_PERMA_CURSE);
+        if (o_ptr->curse_flags.has(TRC::PERMA_CURSE)) {
+            o_ptr->curse_flags &= {TRC::CURSED, TRC::HEAVY_CURSE, TRC::PERMA_CURSE};
             continue;
         }
 
-        o_ptr->curse_flags = 0L;
+        o_ptr->curse_flags.clear();
         o_ptr->ident |= IDENT_SENSE;
         o_ptr->feeling = FEEL_NONE;
 
index b7218e8..e99b1d3 100644 (file)
@@ -255,7 +255,7 @@ bool curse_armor(player_type *owner_ptr)
         o_ptr->art_flags[i] = 0;
 
     /* Curse it */
-    o_ptr->curse_flags = TRC_CURSED;
+    o_ptr->curse_flags.set(TRC::CURSED);
 
     /* Break it */
     o_ptr->ident |= (IDENT_BROKEN);
@@ -310,7 +310,7 @@ bool curse_weapon_object(player_type *owner_ptr, bool force, object_type *o_ptr)
         o_ptr->art_flags[i] = 0;
 
     /* Curse it */
-    o_ptr->curse_flags = TRC_CURSED;
+    o_ptr->curse_flags.set(TRC::CURSED);
 
     /* Break it */
     o_ptr->ident |= (IDENT_BROKEN);
@@ -409,14 +409,14 @@ bool perilous_secrets(player_type *user_ptr)
 static void break_curse(object_type *o_ptr)
 {
     BIT_FLAGS is_curse_broken
-        = object_is_cursed(o_ptr) && !(o_ptr->curse_flags & TRC_PERMA_CURSE) && !(o_ptr->curse_flags & TRC_HEAVY_CURSE) && (randint0(100) < 25);
+        = object_is_cursed(o_ptr) && o_ptr->curse_flags.has_not(TRC::PERMA_CURSE) && o_ptr->curse_flags.has_not(TRC::HEAVY_CURSE) && (randint0(100) < 25);
     if (!is_curse_broken) {
         return;
     }
 
     msg_print(_("かけられていた呪いが打ち破られた!", "The curse is broken!"));
 
-    o_ptr->curse_flags = 0L;
+    o_ptr->curse_flags.clear();
     o_ptr->ident |= (IDENT_SENSE);
     o_ptr->feeling = FEEL_NONE;
 }
index 9932a75..cd59c34 100644 (file)
@@ -22,7 +22,7 @@
 /*!
  * @brief セーブファイルのバージョン(3.0.0から導入)
  */
-constexpr u32b SAVEFILE_VERSION = 4;
+constexpr u32b SAVEFILE_VERSION = 5;
 
 /*!
  * @brief バージョンが開発版が安定版かを返す(廃止予定)
index 8757902..722efc9 100644 (file)
@@ -61,15 +61,15 @@ void object_type::prep(player_type *player_ptr, KIND_OBJECT_IDX ko_idx)
         this->ident |= (IDENT_BROKEN);
 
     if (k_ptr->gen_flags.has(TRG::CURSED))
-        this->curse_flags |= (TRC_CURSED);
+        this->curse_flags.set(TRC::CURSED);
     if (k_ptr->gen_flags.has(TRG::HEAVY_CURSE))
-        this->curse_flags |= (TRC_HEAVY_CURSE);
+        this->curse_flags.set(TRC::HEAVY_CURSE);
     if (k_ptr->gen_flags.has(TRG::PERMA_CURSE))
-        this->curse_flags |= (TRC_PERMA_CURSE);
+        this->curse_flags.set(TRC::PERMA_CURSE);
     if (k_ptr->gen_flags.has(TRG::RANDOM_CURSE0))
-        this->curse_flags |= get_curse(player_ptr, 0, this);
+        this->curse_flags.set(get_curse(player_ptr, 0, this));
     if (k_ptr->gen_flags.has(TRG::RANDOM_CURSE1))
-        this->curse_flags |= get_curse(player_ptr, 1, this);
+        this->curse_flags.set(get_curse(player_ptr, 1, this));
     if (k_ptr->gen_flags.has(TRG::RANDOM_CURSE2))
-        this->curse_flags |= get_curse(player_ptr, 2, this);
+        this->curse_flags.set(get_curse(player_ptr, 2, this));
 }
index b251835..5e890f1 100644 (file)
@@ -7,50 +7,52 @@
  * @date 2021/05/02
  */
 
+#include "object-enchant/trc-types.h"
 #include "object/tval-types.h"
 #include "system/angband.h"
 #include "system/system-variables.h"
+#include "util/flag-group.h"
 
 struct player_type;
 typedef struct object_type {
-    KIND_OBJECT_IDX k_idx; /* Kind index (zero if "dead") */
-    POSITION iy; /* Y-position on map, or zero */
-    POSITION ix; /* X-position on map, or zero */
-    IDX stack_idx; /*!< このアイテムを含むアイテムリスト内の位置(降順) */
-    tval_type tval; /* Item type (from kind) */
-
-    OBJECT_SUBTYPE_VALUE sval; /* Item sub-type (from kind) */
-    PARAMETER_VALUE pval; /* Item extra-parameter */
-    DISCOUNT_RATE discount; /* Discount (if any) */
-    ITEM_NUMBER number; /* Number of items */
-    WEIGHT weight; /* Item weight */
-    ARTIFACT_IDX name1; /* Artifact type, if any */
-    EGO_IDX name2; /* Ego-Item type, if any */
-
-    XTRA8 xtra1; /* Extra info type (now unused) */
-    XTRA16 xtra2; /*!< エゴ/アーティファクトの発動ID / Extra info activation index */
-    XTRA8 xtra3; /*!< 複数の使用用途 捕らえたモンスターの速度,付加した特殊なエッセンスID / Extra info for weaponsmith */
-    XTRA16 xtra4; /*!< 複数の使用用途 光源の残り寿命、あるいは捕らえたモンスターの現HP / Extra info fuel or captured monster's current HP */
-    XTRA16 xtra5; /*!< 複数の使用用途 捕らえたモンスターの最大HP / Extra info captured monster's max HP */
-
-    HIT_PROB to_h; /* Plusses to hit */
-    HIT_POINT to_d; /* Plusses to damage */
-    ARMOUR_CLASS to_a; /* Plusses to AC */
-    ARMOUR_CLASS ac; /* Normal AC */
-
-    DICE_NUMBER dd;
-    DICE_SID ds; /* Damage dice/sides */
-    TIME_EFFECT timeout; /* Timeout Counter */
-    byte ident; /* Special flags  */
-    byte marked; /* Object is marked */
-    u16b inscription; /* Inscription index */
-    u16b art_name; /* Artifact name (random artifacts) */
-    byte feeling; /* Game generated inscription number (eg, pseudo-id) */
-
-    BIT_FLAGS art_flags[TR_FLAG_SIZE]; /* Extra Flags for ego and artifacts */
-    BIT_FLAGS curse_flags; /* Flags for curse */
-    MONSTER_IDX held_m_idx; /*!< アイテムを所持しているモンスターID (いないなら 0) / Monster holding us (if any) */
-    ARTIFACT_BIAS_IDX artifact_bias; /*!< ランダムアーティファクト生成時のバイアスID */
+    KIND_OBJECT_IDX k_idx{}; /*!< Kind index (zero if "dead") */
+    POSITION iy{}; /*!< Y-position on map, or zero */
+    POSITION ix{}; /*!< X-position on map, or zero */
+    IDX stack_idx{}; /*!< このアイテムを含むアイテムリスト内の位置(降順) */
+    tval_type tval{}; /*!< Item type (from kind) */
+
+    OBJECT_SUBTYPE_VALUE sval{}; /*!< Item sub-type (from kind) */
+    PARAMETER_VALUE pval{}; /*!< Item extra-parameter */
+    DISCOUNT_RATE discount{}; /*!< Discount (if any) */
+    ITEM_NUMBER number{}; /*!< Number of items */
+    WEIGHT weight{}; /*!< Item weight */
+    ARTIFACT_IDX name1{}; /*!< Artifact type, if any */
+    EGO_IDX name2{}; /*!< Ego-Item type, if any */
+
+    XTRA8 xtra1{}; /*!< Extra info type (now unused) */
+    XTRA16 xtra2{}; /*!< エゴ/アーティファクトの発動ID / Extra info activation index */
+    XTRA8 xtra3{}; /*!< 複数の使用用途 捕らえたモンスターの速度,付加した特殊なエッセンスID / Extra info for weaponsmith */
+    XTRA16 xtra4{}; /*!< 複数の使用用途 光源の残り寿命、あるいは捕らえたモンスターの現HP / Extra info fuel or captured monster's current HP */
+    XTRA16 xtra5{}; /*!< 複数の使用用途 捕らえたモンスターの最大HP / Extra info captured monster's max HP */
+
+    HIT_PROB to_h{}; /*!< Plusses to hit */
+    HIT_POINT to_d{}; /*!< Plusses to damage */
+    ARMOUR_CLASS to_a{}; /*!< Plusses to AC */
+    ARMOUR_CLASS ac{}; /*!< Normal AC */
+
+    DICE_NUMBER dd{}; /*!< Damage dice/nums */
+    DICE_SID ds{}; /*!< Damage dice/sides */
+    TIME_EFFECT timeout{}; /*!< Timeout Counter */
+    byte ident{}; /*!< Special flags  */
+    byte marked{}; /*!< Object is marked */
+    u16b inscription{}; /*!< Inscription index */
+    u16b art_name{}; /*!< Artifact name (random artifacts) */
+    byte feeling{}; /*!< Game generated inscription number (eg, pseudo-id) */
+
+    BIT_FLAGS art_flags[TR_FLAG_SIZE]{}; /*!< Extra Flags for ego and artifacts */
+    EnumClassFlagGroup<TRC> curse_flags{}; /*!< Flags for curse */
+    MONSTER_IDX held_m_idx{}; /*!< アイテムを所持しているモンスターID (いないなら 0) / Monster holding us (if any) */
+    ARTIFACT_BIAS_IDX artifact_bias{}; /*!< ランダムアーティファクト生成時のバイアスID */
 
     void wipe();
     void copy_from(object_type *j_ptr);
index 392669e..0a7b83a 100644 (file)
@@ -1,6 +1,7 @@
 #pragma once
 
 #include "mutation/mutation-flag-types.h"
+#include "object-enchant/trc-types.h"
 #include "player-ability/player-ability-types.h"
 #include "player/player-race-types.h"
 #include "player/player-class-types.h"
@@ -324,7 +325,8 @@ typedef struct player_type {
     BIT_FLAGS anti_magic{}; /* Anti-magic */
     BIT_FLAGS anti_tele{}; /* Prevent teleportation */
 
-    BIT_FLAGS cursed{}; /* Player is cursed */
+    EnumClassFlagGroup<TRC> cursed{}; /* Player is cursed */
+    EnumClassFlagGroup<TRCS> cursed_special{}; /* Player is special type cursed */
 
     bool can_swim{}; /* No damage falling */
     BIT_FLAGS levitation{}; /* No damage falling */
index 0f8af1c..1a0c9a7 100644 (file)
@@ -120,7 +120,7 @@ static void process_cursed_equipment_characteristics(player_type *creature_ptr,
             }
         }
 
-        if (any_bits(o_ptr->curse_flags, TRC_PERMA_CURSE)) {
+        if (o_ptr->curse_flags.has(TRC::PERMA_CURSE)) {
             if (is_known) {
                 char_stat.syms.emplace_back("*");
                 char_stat.has_imm = true;
@@ -128,7 +128,7 @@ static void process_cursed_equipment_characteristics(player_type *creature_ptr,
             }
         }
 
-        if (any_bits(o_ptr->curse_flags, TRC_CURSED | TRC_HEAVY_CURSE | TRC_PERMA_CURSE)) {
+        if (o_ptr->curse_flags.has_any_of({ TRC::CURSED, TRC::HEAVY_CURSE, TRC::PERMA_CURSE })) {
             if (is_sensed) {
                 char_stat.syms.emplace_back("+");
                 char_stat.has_res = true;
index 3bce75a..4b49e8c 100644 (file)
@@ -213,11 +213,11 @@ static void analyze_misc_magic(player_type *player_ptr, object_type *o_ptr, conc
     if (has_flag(flgs, TR_TY_CURSE))
         *misc_list++ = _("太古の怨念", "Ancient Curse");
 
-    if (o_ptr->curse_flags & TRC_PERMA_CURSE)
+    if (o_ptr->curse_flags.has(TRC::PERMA_CURSE))
         *misc_list++ = _("永遠の呪い", "Permanently Cursed");
-    else if (o_ptr->curse_flags & TRC_HEAVY_CURSE)
+    else if (o_ptr->curse_flags.has(TRC::HEAVY_CURSE))
         *misc_list++ = _("強力な呪い", "Heavily Cursed");
-    else if (o_ptr->curse_flags & TRC_CURSED)
+    else if (o_ptr->curse_flags.has(TRC::CURSED))
         *misc_list++ = _("呪い", "Cursed");
 
     if (has_flag(flgs, TR_ADD_L_CURSE))