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;
}
}
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:
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));
}
/*!
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);
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)
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;
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--;
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;
}
}
#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;
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:
* @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;
*/
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];
*/
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];
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;
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);
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);
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);
}
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))
*/
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);
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) {
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);
}
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);
}
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)
}
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);
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
#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);
if ((this->power == 2) && one_in_(2)) {
give_ego_index();
- this->o_ptr->curse_flags = 0L;
+ this->o_ptr->curse_flags.clear();
return;
}
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;
}
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;
}
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;
}
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:
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) {
}
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;
}
}
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 });
}
}
if (o_ptr->to_a < 0)
- o_ptr->curse_flags |= TRC_CURSED;
+ o_ptr->curse_flags.set(TRC::CURSED);
}
switch (o_ptr->tval) {
o_ptr->pval = i;
if (one_in_(6))
- o_ptr->curse_flags |= TRC_CURSED;
+ o_ptr->curse_flags.set(TRC::CURSED);
break;
}
if ((this->power == 2) && one_in_(2)) {
give_ego_index();
- this->o_ptr->curse_flags = 0L;
+ this->o_ptr->curse_flags.clear();
return;
}
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);
}
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);
}
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;
}
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);
}
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;
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) {
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;
}
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;
}
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;
}
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;
}
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;
}
}
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 });
}
}
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))
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));
}
}
#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;
}
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) {
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);
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));
}
/*!
#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,
};
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(); }
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... */
}
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.");
}
}
- 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.");
}
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.");
}
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)
{
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];
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)
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;
}
* * 性格きれものなら減算(-3)
* * 性格ちからじまんとがまんづよいなら加算(+1)
* * 性格チャージマンなら加算(+5)
- * * 装備品にTRC_HARD_SPELLがあるなら加算(軽い呪いなら+3/重い呪いなら+10)
+ * * 装備品にTRC::HARD_SPELLがあるなら加算(軽い呪いなら+3/重い呪いなら+10)
*/
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;
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 {
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;
}
}
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;
}
}
}
/* 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;
/* 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;
}
}
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;
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;
} 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);
}
}
- 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);
} 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);
}
}
- 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);
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;
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)
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);
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;
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);
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);
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;
}
/*!
* @brief セーブファイルのバージョン(3.0.0から導入)
*/
-constexpr u32b SAVEFILE_VERSION = 4;
+constexpr u32b SAVEFILE_VERSION = 5;
/*!
* @brief バージョンが開発版が安定版かを返す(廃止予定)
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));
}
* @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);
#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"
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 */
}
}
- 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;
}
}
- 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;
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))