summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBardur Arantsson <bardur@scientician.net>2016-06-21 13:37:02 +0200
committerBardur Arantsson <bardur@scientician.net>2016-06-21 13:37:02 +0200
commit073ad3584fbf781ce10bef61ad4ff38850282f47 (patch)
treeeb2db284b91ad7987655401406a2d57843337875 /src
parentb9e4f471c2e23283945ba9324912c7e29dd8fbd8 (diff)
Rework TR{1,2,3,4,5}_* flags to flag_set<>
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/artifact_type.hpp17
-rw-r--r--src/bldg.cc64
-rw-r--r--src/cave.cc10
-rw-r--r--src/cmd1.cc70
-rw-r--r--src/cmd2.cc6
-rw-r--r--src/cmd3.cc62
-rw-r--r--src/cmd4.cc18
-rw-r--r--src/cmd5.cc25
-rw-r--r--src/cmd6.cc61
-rw-r--r--src/cmd7.cc3
-rw-r--r--src/corrupt.cc17
-rw-r--r--src/defines.h219
-rw-r--r--src/dungeon.cc70
-rw-r--r--src/ego_item_type.hpp43
-rw-r--r--src/files.cc926
-rw-r--r--src/files.hpp3
-rw-r--r--src/flag_set.hpp8
-rw-r--r--src/flags_group.hpp7
-rw-r--r--src/generate.cc3
-rw-r--r--src/help.cc6
-rw-r--r--src/init1.cc634
-rw-r--r--src/init2.cc9
-rw-r--r--src/loadsave.cc30
-rw-r--r--src/melee2.cc62
-rw-r--r--src/mimic.cc135
-rw-r--r--src/monoid.hpp37
-rw-r--r--src/monster2.cc36
-rw-r--r--src/object1.cc871
-rw-r--r--src/object1.hpp8
-rw-r--r--src/object2.cc698
-rw-r--r--src/object_filter.cc29
-rw-r--r--src/object_filter.hpp15
-rw-r--r--src/object_flag.hpp12
-rw-r--r--src/object_flag_list.hpp196
-rw-r--r--src/object_flag_meta.cc59
-rw-r--r--src/object_flag_meta.hpp75
-rw-r--r--src/object_flag_set.hpp7
-rw-r--r--src/object_kind.hpp16
-rw-r--r--src/object_type.hpp16
-rw-r--r--src/player_class.hpp8
-rw-r--r--src/player_race.hpp8
-rw-r--r--src/player_race_mod.hpp8
-rw-r--r--src/player_type.hpp13
-rw-r--r--src/q_fireprof.cc3
-rw-r--r--src/q_rand.cc3
-rw-r--r--src/q_ultrag.cc7
-rw-r--r--src/q_wight.cc24
-rw-r--r--src/randart.cc42
-rw-r--r--src/randart_part_type.hpp58
-rw-r--r--src/set_component.hpp14
-rw-r--r--src/spells1.cc53
-rw-r--r--src/spells2.cc328
-rw-r--r--src/squelch/rule.cc7
-rw-r--r--src/store.cc43
-rw-r--r--src/tables.cc86
-rw-r--r--src/traps.cc67
-rw-r--r--src/wizard2.cc85
-rw-r--r--src/xtra1.cc268
-rw-r--r--src/xtra1.hpp3
-rw-r--r--src/xtra2.cc54
61 files changed, 2602 insertions, 3164 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index d0e34707..e3dd63fb 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -54,6 +54,7 @@ SET(SRCS_COMMON
object1.cc
object2.cc
object_filter.cc
+ object_flag_meta.cc
options.cc
powers.cc
q_betwen.cc
diff --git a/src/artifact_type.hpp b/src/artifact_type.hpp
index ea962bc2..8ff53433 100644
--- a/src/artifact_type.hpp
+++ b/src/artifact_type.hpp
@@ -1,6 +1,7 @@
#pragma once
#include "h-basic.h"
+#include "object_flag_set.hpp"
/**
* Artifact descriptor.
@@ -34,17 +35,8 @@ struct artifact_type
s32b cost = 0; /* Artifact "cost" */
- u32b flags1 = 0; /* Artifact Flags, set 1 */
- u32b flags2 = 0; /* Artifact Flags, set 2 */
- u32b flags3 = 0; /* Artifact Flags, set 3 */
- u32b flags4 = 0; /* Artifact Flags, set 4 */
- u32b flags5 = 0; /* Artifact Flags, set 5 */
-
- u32b oflags1 = 0; /* Obvious Flags, set 1 */
- u32b oflags2 = 0; /* Obvious Flags, set 2 */
- u32b oflags3 = 0; /* Obvious Flags, set 3 */
- u32b oflags4 = 0; /* Obvious Flags, set 4 */
- u32b oflags5 = 0; /* Obvious Flags, set 5 */
+ object_flag_set flags; /* Artifact Flags */
+ object_flag_set oflags; /* Obvious Flags */
byte level = 0; /* Artifact level */
byte rarity = 0; /* Artifact rarity */
@@ -52,9 +44,6 @@ struct artifact_type
byte cur_num = 0; /* Number created (0 or 1) */
byte max_num = 0; /* Unused (should be "1") */
- u32b esp = 0; /* ESP flags */
- u32b oesp = 0; /* ESP flags */
-
s16b power = 0; /* Power granted, if any */
s16b set = 0; /* Which set does it belong it, if any? */
diff --git a/src/bldg.cc b/src/bldg.cc
index db76b92a..4f1747db 100644
--- a/src/bldg.cc
+++ b/src/bldg.cc
@@ -23,6 +23,7 @@
#include "mimic.hpp"
#include "object1.hpp"
#include "object2.hpp"
+#include "object_flag.hpp"
#include "owner_type.hpp"
#include "player_type.hpp"
#include "q_library.hpp"
@@ -770,7 +771,7 @@ static void town_history(void)
/*
* compare_weapon_aux2 -KMW-
*/
-static void compare_weapon_aux2(object_type *o_ptr, int numblows, int r, int c, int mult, const char *attr, u32b f1, u32b f2, u32b f3, byte color)
+static void compare_weapon_aux2(object_type *o_ptr, int numblows, int r, int c, int mult, const char *attr, byte color)
{
char tmp_str[80];
@@ -788,80 +789,77 @@ static void compare_weapon_aux2(object_type *o_ptr, int numblows, int r, int c,
*/
static void compare_weapon_aux1(object_type *o_ptr, int col, int r)
{
- u32b f1, f2, f3, f4, f5, esp;
+ auto const f = object_flags(o_ptr);
- object_flags(o_ptr, &f1, &f2, &f3, &f4, &f5, &esp);
-
-
- if (f1 & (TR1_SLAY_ANIMAL))
+ if (f & TR_SLAY_ANIMAL)
{
compare_weapon_aux2(o_ptr, p_ptr->num_blow, r++, col, 2, "Animals:",
- f1, f2, f3, TERM_YELLOW);
+ TERM_YELLOW);
}
- if (f1 & (TR1_SLAY_EVIL))
+ if (f & TR_SLAY_EVIL)
{
compare_weapon_aux2(o_ptr, p_ptr->num_blow, r++, col, 2, "Evil:",
- f1, f2, f3, TERM_YELLOW);
+ TERM_YELLOW);
}
- if (f1 & (TR1_SLAY_UNDEAD))
+ if (f & TR_SLAY_UNDEAD)
{
compare_weapon_aux2(o_ptr, p_ptr->num_blow, r++, col, 3, "Undead:",
- f1, f2, f3, TERM_YELLOW);
+ TERM_YELLOW);
}
- if (f1 & (TR1_SLAY_DEMON))
+ if (f & TR_SLAY_DEMON)
{
compare_weapon_aux2(o_ptr, p_ptr->num_blow, r++, col, 3, "Demons:",
- f1, f2, f3, TERM_YELLOW);
+ TERM_YELLOW);
}
- if (f1 & (TR1_SLAY_ORC))
+ if (f & TR_SLAY_ORC)
{
compare_weapon_aux2(o_ptr, p_ptr->num_blow, r++, col, 3, "Orcs:",
- f1, f2, f3, TERM_YELLOW);
+ TERM_YELLOW);
}
- if (f1 & (TR1_SLAY_TROLL))
+ if (f & TR_SLAY_TROLL)
{
compare_weapon_aux2(o_ptr, p_ptr->num_blow, r++, col, 3, "Trolls:",
- f1, f2, f3, TERM_YELLOW);
+ TERM_YELLOW);
}
- if (f1 & (TR1_SLAY_GIANT))
+ if (f & TR_SLAY_GIANT)
{
compare_weapon_aux2(o_ptr, p_ptr->num_blow, r++, col, 3, "Giants:",
- f1, f2, f3, TERM_YELLOW);
+ TERM_YELLOW);
}
- if (f1 & (TR1_SLAY_DRAGON))
+ if (f & TR_SLAY_DRAGON)
{
compare_weapon_aux2(o_ptr, p_ptr->num_blow, r++, col, 3, "Dragons:",
- f1, f2, f3, TERM_YELLOW);
+ TERM_YELLOW);
}
- if (f1 & (TR1_KILL_DRAGON))
+ if (f & TR_KILL_DRAGON)
{
compare_weapon_aux2(o_ptr, p_ptr->num_blow, r++, col, 5, "Dragons:",
- f1, f2, f3, TERM_YELLOW);
+ TERM_YELLOW);
}
- if (f1 & (TR1_BRAND_ACID))
+ if (f & TR_BRAND_ACID)
{
compare_weapon_aux2(o_ptr, p_ptr->num_blow, r++, col, 3, "Acid:",
- f1, f2, f3, TERM_RED);
+ TERM_RED);
}
- if (f1 & (TR1_BRAND_ELEC))
+ if (f & TR_BRAND_ELEC)
{
compare_weapon_aux2(o_ptr, p_ptr->num_blow, r++, col, 3, "Elec:",
- f1, f2, f3, TERM_RED);
+ TERM_RED);
}
- if (f1 & (TR1_BRAND_FIRE))
+ if (f & TR_BRAND_FIRE)
{
compare_weapon_aux2(o_ptr, p_ptr->num_blow, r++, col, 3, "Fire:",
- f1, f2, f3, TERM_RED);
+ TERM_RED);
}
- if (f1 & (TR1_BRAND_COLD))
+ if (f & TR_BRAND_COLD)
{
compare_weapon_aux2(o_ptr, p_ptr->num_blow, r++, col, 3, "Cold:",
- f1, f2, f3, TERM_RED);
+ TERM_RED);
}
- if (f1 & (TR1_BRAND_POIS))
+ if (f & TR_BRAND_POIS)
{
compare_weapon_aux2(o_ptr, p_ptr->num_blow, r++, col, 3, "Poison:",
- f1, f2, f3, TERM_RED);
+ TERM_RED);
}
}
diff --git a/src/cave.cc b/src/cave.cc
index 48aa7740..97f022c1 100644
--- a/src/cave.cc
+++ b/src/cave.cc
@@ -10,6 +10,7 @@
#include "monster_spell_flag.hpp"
#include "monster_type.hpp"
#include "object1.hpp"
+#include "object_flag.hpp"
#include "object_kind.hpp"
#include "options.hpp"
#include "player_type.hpp"
@@ -1090,7 +1091,7 @@ static void map_info(int y, int x, byte *ap, char *cp)
*ap = object_attr(o_ptr);
/* Multi-hued attr */
- if (!avoid_other && (k_info[o_ptr->k_idx].flags5 & TR5_ATTR_MULTI))
+ if (!avoid_other && (k_info[o_ptr->k_idx].flags & TR_ATTR_MULTI))
{
*ap = get_shimmer_color();
}
@@ -1127,7 +1128,7 @@ static void map_info(int y, int x, byte *ap, char *cp)
*ap = object_attr(o_ptr);
/* Multi-hued attr */
- if (!avoid_other && (k_info[o_ptr->k_idx].flags5 & TR5_ATTR_MULTI))
+ if (!avoid_other && (k_info[o_ptr->k_idx].flags & TR_ATTR_MULTI))
{
*ap = get_shimmer_color();
}
@@ -1519,8 +1520,7 @@ void map_info_default(int y, int x, byte *ap, char *cp)
*ap = object_attr_default(o_ptr);
/* Multi-hued attr */
- if (!avoid_other &&
- (k_info[o_ptr->k_idx].flags5 & TR5_ATTR_MULTI))
+ if (!avoid_other && (k_info[o_ptr->k_idx].flags & TR_ATTR_MULTI))
{
*ap = get_shimmer_color();
}
@@ -1557,7 +1557,7 @@ void map_info_default(int y, int x, byte *ap, char *cp)
*ap = object_attr_default(o_ptr);
/* Multi-hued attr */
- if (!avoid_other && (k_info[o_ptr->k_idx].flags5 & TR5_ATTR_MULTI))
+ if (!avoid_other && (k_info[o_ptr->k_idx].flags & TR_ATTR_MULTI))
{
*ap = get_shimmer_color();
}
diff --git a/src/cmd1.cc b/src/cmd1.cc
index b69d3602..bb0aa5f3 100644
--- a/src/cmd1.cc
+++ b/src/cmd1.cc
@@ -28,6 +28,7 @@
#include "monster_race_flag.hpp"
#include "monster_spell_flag.hpp"
#include "monster_type.hpp"
+#include "object_flag.hpp"
#include "object1.hpp"
#include "object2.hpp"
#include "options.hpp"
@@ -241,11 +242,8 @@ s16b tot_dam_aux(object_type *o_ptr, int tdam, monster_type *m_ptr,
auto const r_ptr = m_ptr->race();
- u32b f1, f2, f3, f4, f5, esp;
-
-
/* Extract the flags */
- object_flags(o_ptr, &f1, &f2, &f3, &f4, &f5, &esp);
+ auto const f = object_flags(o_ptr);
/* Some "weapons" and "ammo" do extra damage */
switch (o_ptr->tval)
@@ -261,75 +259,75 @@ s16b tot_dam_aux(object_type *o_ptr, int tdam, monster_type *m_ptr,
case TV_DIGGING:
{
/* Slay Animal */
- if ((f1 & (TR1_SLAY_ANIMAL)) && (r_ptr->flags & RF_ANIMAL))
+ if ((f & TR_SLAY_ANIMAL) && (r_ptr->flags & RF_ANIMAL))
{
if (mult < 2) mult = 2;
}
/* Slay Evil */
- if ((f1 & (TR1_SLAY_EVIL)) && (r_ptr->flags & RF_EVIL))
+ if ((f & TR_SLAY_EVIL) && (r_ptr->flags & RF_EVIL))
{
if (mult < 2) mult = 2;
}
/* Slay Undead */
- if ((f1 & (TR1_SLAY_UNDEAD)) && (r_ptr->flags & RF_UNDEAD))
+ if ((f & TR_SLAY_UNDEAD) && (r_ptr->flags & RF_UNDEAD))
{
if (mult < 3) mult = 3;
}
/* Slay Demon */
- if ((f1 & (TR1_SLAY_DEMON)) && (r_ptr->flags & RF_DEMON))
+ if ((f & TR_SLAY_DEMON) && (r_ptr->flags & RF_DEMON))
{
if (mult < 3) mult = 3;
}
/* Slay Orc */
- if ((f1 & (TR1_SLAY_ORC)) && (r_ptr->flags & RF_ORC))
+ if ((f & TR_SLAY_ORC) && (r_ptr->flags & RF_ORC))
{
if (mult < 3) mult = 3;
}
/* Slay Troll */
- if ((f1 & (TR1_SLAY_TROLL)) && (r_ptr->flags & RF_TROLL))
+ if ((f & TR_SLAY_TROLL) && (r_ptr->flags & RF_TROLL))
{
if (mult < 3) mult = 3;
}
/* Slay Giant */
- if ((f1 & (TR1_SLAY_GIANT)) && (r_ptr->flags & RF_GIANT))
+ if ((f & TR_SLAY_GIANT) && (r_ptr->flags & RF_GIANT))
{
if (mult < 3) mult = 3;
}
/* Slay Dragon */
- if ((f1 & (TR1_SLAY_DRAGON)) && (r_ptr->flags & RF_DRAGON))
+ if ((f & TR_SLAY_DRAGON) && (r_ptr->flags & RF_DRAGON))
{
if (mult < 3) mult = 3;
}
/* Execute Dragon */
- if ((f1 & (TR1_KILL_DRAGON)) && (r_ptr->flags & RF_DRAGON))
+ if ((f & TR_KILL_DRAGON) && (r_ptr->flags & RF_DRAGON))
{
if (mult < 5) mult = 5;
}
/* Execute Undead */
- if ((f5 & (TR5_KILL_UNDEAD)) && (r_ptr->flags & RF_UNDEAD))
+ if ((f & TR_KILL_UNDEAD) && (r_ptr->flags & RF_UNDEAD))
{
if (mult < 5) mult = 5;
}
/* Execute Demon */
- if ((f5 & (TR5_KILL_DEMON)) && (r_ptr->flags & RF_DEMON))
+ if ((f & TR_KILL_DEMON) && (r_ptr->flags & RF_DEMON))
{
if (mult < 5) mult = 5;
}
/* Brand (Acid) */
- if (f1 & (TR1_BRAND_ACID))
+ if (f & TR_BRAND_ACID)
{
if (r_ptr->flags & RF_IM_ACID)
{
@@ -346,7 +344,7 @@ s16b tot_dam_aux(object_type *o_ptr, int tdam, monster_type *m_ptr,
}
/* Brand (Elec) */
- if (f1 & (TR1_BRAND_ELEC))
+ if (f & TR_BRAND_ELEC)
{
if (r_ptr->flags & RF_IM_ELEC)
{
@@ -363,7 +361,7 @@ s16b tot_dam_aux(object_type *o_ptr, int tdam, monster_type *m_ptr,
}
/* Brand (Fire) */
- if (f1 & (TR1_BRAND_FIRE))
+ if (f & TR_BRAND_FIRE)
{
if (r_ptr->flags & RF_IM_FIRE)
{
@@ -380,7 +378,7 @@ s16b tot_dam_aux(object_type *o_ptr, int tdam, monster_type *m_ptr,
}
/* Brand (Cold) */
- if (f1 & (TR1_BRAND_COLD))
+ if (f & TR_BRAND_COLD)
{
if (r_ptr->flags & RF_IM_COLD)
{
@@ -397,7 +395,7 @@ s16b tot_dam_aux(object_type *o_ptr, int tdam, monster_type *m_ptr,
}
/* Brand (Poison) */
- if (f1 & (TR1_BRAND_POIS) || (p_ptr->tim_poison))
+ if ((f & TR_BRAND_POIS) || (p_ptr->tim_poison))
{
if (r_ptr->flags & RF_IM_POIS)
{
@@ -416,7 +414,7 @@ s16b tot_dam_aux(object_type *o_ptr, int tdam, monster_type *m_ptr,
}
/* Wounding */
- if (f5 & (TR5_WOUNDING))
+ if (f & TR_WOUNDING)
{
if (r_ptr->flags & RF_NO_CUT)
{
@@ -1883,21 +1881,22 @@ static void py_attack_hand(int *k, monster_type *m_ptr, s32b *special)
static void do_nazgul(int *k, int *num, int num_blow, int weap, std::shared_ptr<monster_race> r_ptr,
object_type *o_ptr)
{
- u32b f1, f2, f3, f4, f5, esp;
-
- bool_ mundane;
bool_ allow_shatter = TRUE;
/* Extract mundane-ness of the current weapon */
- object_flags(o_ptr, &f1, &f2, &f3, &f4, &f5, &esp);
+ auto const f = object_flags(o_ptr);
/* It should be Slay Evil, Slay Undead, or *Slay Undead* */
- mundane = !(f1 & TR1_SLAY_EVIL) && !(f1 & TR1_SLAY_UNDEAD) &&
- !(f5 & TR5_KILL_UNDEAD);
+ bool_ const mundane =
+ !(f & TR_SLAY_EVIL) &&
+ !(f & TR_SLAY_UNDEAD) &&
+ !(f & TR_KILL_UNDEAD);
/* Some blades can resist shattering */
- if (f5 & TR5_RES_MORGUL)
+ if (f & TR_RES_MORGUL)
+ {
allow_shatter = FALSE;
+ }
/* Mega Hack -- Hitting Nazgul is REALY dangerous (ideas from Akhronath) */
if (r_ptr->flags & RF_NAZGUL)
@@ -2007,9 +2006,6 @@ void py_attack(int y, int x, int max_blow)
int drain_left = MAX_VAMPIRIC_DRAIN;
- /* A massive hack -- life-draining weapons */
- u32b f1, f2, f3, f4, f5, esp;
-
int weap;
/* Disturb the player */
@@ -2128,9 +2124,9 @@ void py_attack(int y, int x, int max_blow)
bonus = p_ptr->to_h + p_ptr->to_h_melee + o_ptr->to_h;
chance = p_ptr->skill_thn + (bonus * BTH_PLUS_ADJ);
- object_flags(o_ptr, &f1, &f2, &f3, &f4, &f5, &esp);
+ auto const flags = object_flags(o_ptr);
- if (!(f4 & TR4_NEVER_BLOW))
+ if (!(flags & TR_NEVER_BLOW))
{
int num_blow = p_ptr->num_blow;
@@ -2151,7 +2147,7 @@ void py_attack(int y, int x, int max_blow)
k = 1;
/* Select a chaotic effect (50% chance) */
- if ((f1 & TR1_CHAOTIC) && (rand_int(2) == 0))
+ if ((flags & TR_CHAOTIC) && (rand_int(2) == 0))
{
if (randint(5) < 3)
{
@@ -2181,7 +2177,7 @@ void py_attack(int y, int x, int max_blow)
}
/* Vampiric drain */
- if ((f1 & TR1_VAMPIRIC) || (chaos_effect == 1))
+ if ((flags & TR_VAMPIRIC) || (chaos_effect == 1))
{
if (!
((r_ptr->flags & RF_UNDEAD) ||
@@ -2191,7 +2187,7 @@ void py_attack(int y, int x, int max_blow)
drain_result = 0;
}
- if (f1 & TR1_VORPAL && (randint(6) == 1))
+ if ((flags & TR_VORPAL) && (randint(6) == 1))
vorpal_cut = TRUE;
else
vorpal_cut = FALSE;
@@ -2308,7 +2304,7 @@ void py_attack(int y, int x, int max_blow)
}
/* May it clone the monster ? */
- if ((f4 & TR4_CLONE) && magik(30))
+ if ((flags & TR_CLONE) && magik(30))
{
msg_format("Oh no! Your weapon clones %^s!",
m_name);
diff --git a/src/cmd2.cc b/src/cmd2.cc
index 5bd508b2..c57518bb 100644
--- a/src/cmd2.cc
+++ b/src/cmd2.cc
@@ -31,6 +31,7 @@
#include "monster_type.hpp"
#include "object1.hpp"
#include "object2.hpp"
+#include "object_flag.hpp"
#include "object_kind.hpp"
#include "options.hpp"
#include "player_type.hpp"
@@ -3594,11 +3595,10 @@ void do_cmd_throw(void)
/* Access the item */
object_type *o_ptr = get_object(item);
- u32b f1, f2, f3, f4, f5, esp;
- object_flags(o_ptr, &f1, &f2, &f3, &f4, &f5, &esp);
+ auto const flags = object_flags(o_ptr);
/* Hack - Cannot throw away 'no drop' cursed items */
- if (cursed_p(o_ptr) && (f4 & TR4_CURSE_NO_DROP))
+ if (cursed_p(o_ptr) && (flags & TR_CURSE_NO_DROP))
{
/* Oops */
msg_print("Hmmm, you seem to be unable to throw it.");
diff --git a/src/cmd3.cc b/src/cmd3.cc
index 473f5c0d..4d9c0bcf 100644
--- a/src/cmd3.cc
+++ b/src/cmd3.cc
@@ -21,6 +21,7 @@
#include "monster_race_flag.hpp"
#include "object1.hpp"
#include "object2.hpp"
+#include "object_flag.hpp"
#include "object_kind.hpp"
#include "object_type.hpp"
#include "options.hpp"
@@ -161,28 +162,18 @@ void do_cmd_equip(void)
*/
static bool item_tester_hook_wear(object_type const *o_ptr)
{
- u32b f1, f2, f3, f4, f5, esp;
int slot = wield_slot(o_ptr);
-
- /* Extract the flags */
- object_flags(o_ptr, &f1, &f2, &f3, &f4, &f5, &esp);
-
/* Only one ultimate at a time */
- if (f4 & TR4_ULTIMATE)
+ if (object_flags(o_ptr) & TR_ULTIMATE)
{
- int i;
-
- for (i = INVEN_WIELD; i < INVEN_TOTAL; i++)
+ for (int i = INVEN_WIELD; i < INVEN_TOTAL; i++)
{
object_type *q_ptr = &p_ptr->inventory[i];
- /* Extract the flags */
- object_flags(q_ptr, &f1, &f2, &f3, &f4, &f5, &esp);
-
if (!q_ptr->k_idx) continue;
- if (f4 & TR4_ULTIMATE) return (FALSE);
+ if (object_flags(q_ptr) & TR_ULTIMATE) return (FALSE);
}
}
@@ -227,9 +218,6 @@ void do_cmd_wield(void)
char o_name[80];
- u32b f1, f2, f3, f4, f5, esp;
-
-
/* Get an item */
if (!get_item(&item,
"Wear/Wield which item? ",
@@ -283,11 +271,11 @@ void do_cmd_wield(void)
}
/* Extract the flags */
- object_flags(o_ptr, &f1, &f2, &f3, &f4, &f5, &esp);
+ auto const flags = object_flags(o_ptr);
/* Two handed weapons can't be wielded with a shield */
if ((is_slot_ok(slot - INVEN_WIELD + INVEN_ARM)) &&
- (f4 & TR4_MUST2H) &&
+ (flags & TR_MUST2H) &&
(p_ptr->inventory[slot - INVEN_WIELD + INVEN_ARM].k_idx != 0))
{
object_desc(o_name, o_ptr, FALSE, 0);
@@ -300,10 +288,10 @@ void do_cmd_wield(void)
i_ptr = &p_ptr->inventory[slot - INVEN_ARM + INVEN_WIELD];
/* Extract the flags */
- object_flags(i_ptr, &f1, &f2, &f3, &f4, &f5, &esp);
+ auto const i_flags = object_flags(i_ptr);
/* Prevent shield from being put on if wielding 2H */
- if ((f4 & TR4_MUST2H) && (i_ptr->k_idx) &&
+ if ((i_flags & TR_MUST2H) && (i_ptr->k_idx) &&
(p_ptr->body_parts[slot - INVEN_WIELD] == INVEN_ARM))
{
object_desc(o_name, o_ptr, FALSE, 0);
@@ -312,7 +300,7 @@ void do_cmd_wield(void)
}
if ((p_ptr->body_parts[slot - INVEN_WIELD] == INVEN_ARM) &&
- (f4 & TR4_COULD2H))
+ (i_flags & TR_COULD2H))
{
if (!get_check("Are you sure you want to restrict your fighting? "))
{
@@ -321,13 +309,9 @@ void do_cmd_wield(void)
}
}
-
- /* Extract the flags */
- object_flags(o_ptr, &f1, &f2, &f3, &f4, &f5, &esp);
-
if ((is_slot_ok(slot - INVEN_WIELD + INVEN_ARM)) &&
(p_ptr->inventory[slot - INVEN_WIELD + INVEN_ARM].k_idx != 0) &&
- (f4 & TR4_COULD2H))
+ (flags & TR_COULD2H))
{
if (!get_check("Are you sure you want to use this weapon with a shield?"))
{
@@ -519,8 +503,7 @@ void do_cmd_drop(void)
/* Get the item */
object_type *o_ptr = get_object(item);
- u32b f1, f2, f3, f4, f5, esp;
- object_flags(o_ptr, &f1, &f2, &f3, &f4, &f5, &esp);
+ auto const flags = object_flags(o_ptr);
/* Can we drop */
struct hook_drop_in in = { item };
@@ -539,7 +522,7 @@ void do_cmd_drop(void)
}
else
{
- if (f4 & TR4_CURSE_NO_DROP)
+ if (flags & TR_CURSE_NO_DROP)
{
/* Oops */
msg_print("Hmmm, you seem to be unable to drop it.");
@@ -628,10 +611,8 @@ void do_cmd_destroy(void)
/* Take no time, just like the automatizer */
energy_use = 0;
- u32b f1, f2, f3, f4, f5, esp;
- object_flags(o_ptr, &f1, &f2, &f3, &f4, &f5, &esp);
-
- if ((f4 & TR4_CURSE_NO_DROP) && cursed_p(o_ptr))
+ auto const flags = object_flags(o_ptr);
+ if ((flags & TR_CURSE_NO_DROP) && cursed_p(o_ptr))
{
/* Oops */
msg_print("Hmmm, you seem to be unable to destroy it.");
@@ -691,8 +672,10 @@ void do_cmd_destroy(void)
}
/* Eru wont be happy */
- if (f3 & TR3_BLESSED)
+ if (flags & TR_BLESSED)
+ {
inc_piety(GOD_ERU, -10 * k_info[o_ptr->k_idx].level);
+ }
/* Eliminate the item */
inc_stack_size(item, -amt);
@@ -958,13 +941,8 @@ static void do_cmd_refill_torch(void)
*/
void do_cmd_refill(void)
{
- object_type *o_ptr;
-
- u32b f1, f2, f3, f4, f5, esp;
-
-
/* Get the light */
- o_ptr = &p_ptr->inventory[INVEN_LITE];
+ auto o_ptr = &p_ptr->inventory[INVEN_LITE];
/* It is nothing */
if (o_ptr->tval != TV_LITE)
@@ -973,9 +951,9 @@ void do_cmd_refill(void)
return;
}
- object_flags(o_ptr, &f1, &f2, &f3, &f4, &f5, &esp);
+ auto const flags = object_flags(o_ptr);
- if (f4 & TR4_FUEL_LITE)
+ if (flags & TR_FUEL_LITE)
{
/* It's a torch */
if (o_ptr->sval == SV_LITE_TORCH ||
diff --git a/src/cmd4.cc b/src/cmd4.cc
index 45ee0363..b8a92ddd 100644
--- a/src/cmd4.cc
+++ b/src/cmd4.cc
@@ -25,6 +25,7 @@
#include "notes.hpp"
#include "object1.hpp"
#include "object2.hpp"
+#include "object_flag.hpp"
#include "object_kind.hpp"
#include "player_type.hpp"
#include "skills.hpp"
@@ -3046,7 +3047,7 @@ void do_cmd_knowledge_artifacts(void)
okayk[k] = FALSE;
/* Skip "empty" artifacts */
- if (!(k_ptr->flags3 & TR3_NORM_ART)) continue;
+ if (!(k_ptr->flags & TR_NORM_ART)) continue;
/* Skip "uncreated" artifacts */
if (!k_ptr->artifact) continue;
@@ -3078,7 +3079,7 @@ void do_cmd_knowledge_artifacts(void)
if (object_known_p(o_ptr)) continue;
/* Note the artifact */
- if (k_info[o_ptr->k_idx].flags3 & TR3_NORM_ART)
+ if (k_info[o_ptr->k_idx].flags & TR_NORM_ART)
{
okayk[o_ptr->k_idx] = FALSE;
}
@@ -3111,7 +3112,7 @@ void do_cmd_knowledge_artifacts(void)
if (object_known_p(o_ptr)) continue;
/* Note the artifact */
- if (k_info[o_ptr->k_idx].flags3 & TR3_NORM_ART)
+ if (k_info[o_ptr->k_idx].flags & TR_NORM_ART)
{
okayk[o_ptr->k_idx] = FALSE;
}
@@ -3140,7 +3141,7 @@ void do_cmd_knowledge_artifacts(void)
if (object_known_p(o_ptr)) continue;
/* Note the artifact */
- if (k_info[o_ptr->k_idx].flags3 & TR3_NORM_ART)
+ if (k_info[o_ptr->k_idx].flags & TR_NORM_ART)
{
okayk[o_ptr->k_idx] = FALSE;
}
@@ -3172,7 +3173,6 @@ void do_cmd_knowledge_artifacts(void)
{
object_type forge;
object_type *q_ptr;
- u32b f1, f2, f3, f4, f5, esp;
/* Get local object */
q_ptr = &forge;
@@ -3184,9 +3184,11 @@ void do_cmd_knowledge_artifacts(void)
q_ptr->name1 = k;
/* Spell in it ? no ! */
- object_flags(q_ptr, &f1, &f2, &f3, &f4, &f5, &esp);
- if (f5 & TR5_SPELL_CONTAIN)
+ auto const flags = object_flags(q_ptr);
+ if (flags & TR_SPELL_CONTAIN)
+ {
q_ptr->pval2 = -1;
+ }
/* Describe the artifact */
object_desc_store(base_name, q_ptr, FALSE, 0);
@@ -3589,7 +3591,7 @@ static void do_cmd_knowledge_objects(void)
object_kind *k_ptr = &k_info[k];
/* Hack -- skip artifacts */
- if (k_ptr->flags3 & (TR3_INSTA_ART)) continue;
+ if (k_ptr->flags & (TR_INSTA_ART)) continue;
/* List known flavored objects */
if (k_ptr->flavor && k_ptr->aware)
diff --git a/src/cmd5.cc b/src/cmd5.cc
index 29651cf2..5850f3ce 100644
--- a/src/cmd5.cc
+++ b/src/cmd5.cc
@@ -20,6 +20,7 @@
#include "monster_spell_flag.hpp"
#include "object1.hpp"
#include "object2.hpp"
+#include "object_flag.hpp"
#include "object_type.hpp"
#include "player_class.hpp"
#include "player_race.hpp"
@@ -72,7 +73,7 @@ static object_filter_t const &hook_school_spellable()
static auto instance = Or(
is_school_book(),
And(
- HasFlag5(TR5_SPELL_CONTAIN),
+ HasFlags(TR_SPELL_CONTAIN),
has_pval2));
return instance;
}
@@ -226,14 +227,13 @@ static void browse_school_spell(int book, int spell_idx, object_type *o_ptr)
extern void do_cmd_browse_aux(object_type *o_ptr)
{
- u32b f1, f2, f3, f4, f5, esp;
- object_flags(o_ptr, &f1, &f2, &f3, &f4, &f5, &esp);
+ auto const flags = object_flags(o_ptr);
if (is_school_book()(o_ptr))
{
browse_school_spell(o_ptr->sval, o_ptr->pval, o_ptr);
}
- else if (f5 & TR5_SPELL_CONTAIN && o_ptr->pval2 != -1)
+ else if ((flags & TR_SPELL_CONTAIN) && (o_ptr->pval2 != -1))
{
browse_school_spell(255, o_ptr->pval2, o_ptr);
}
@@ -1867,11 +1867,10 @@ boost::optional<int> get_item_hook_find_spell(object_filter_t const &)
object_type *o_ptr = &p_ptr->inventory[i];
/* Extract object flags */
- u32b f1, f2, f3, f4, f5, esp;
- object_flags(o_ptr, &f1, &f2, &f3, &f4, &f5, &esp);
+ auto const flags = object_flags(o_ptr);
/* Must we wield it to cast from it? */
- if ((wield_slot(o_ptr) != -1) && (i < INVEN_WIELD) && (f5 & TR5_WIELD_CAST))
+ if ((wield_slot(o_ptr) != -1) && (i < INVEN_WIELD) && (flags & TR_WIELD_CAST))
{
continue;
}
@@ -1880,7 +1879,7 @@ boost::optional<int> get_item_hook_find_spell(object_filter_t const &)
if (!is_school_book()(o_ptr))
{
/* Does it contain the appropriate spell? */
- if ((f5 & TR5_SPELL_CONTAIN) && (o_ptr->pval2 == spell))
+ if ((flags & TR_SPELL_CONTAIN) && (o_ptr->pval2 == spell))
{
hack_force_spell = spell;
hack_force_spell_pval = o_ptr->pval;
@@ -1940,7 +1939,6 @@ s32b get_school_spell(cptr do_what, s16b force_book)
object_type *o_ptr, forge;
int tmp;
int sval, pval;
- u32b f1, f2, f3, f4, f5, esp;
hack_force_spell = -1;
hack_force_spell_pval = -1;
@@ -1966,10 +1964,10 @@ s32b get_school_spell(cptr do_what, s16b force_book)
/* Get the item */
o_ptr = get_object(item);
- object_flags(o_ptr, &f1, &f2, &f3, &f4, &f5, &esp);
+ auto const f = object_flags(o_ptr);
/* If it can be wielded, it must */
- if ((wield_slot(o_ptr) != -1) && (item < INVEN_WIELD) && (f5 & TR5_WIELD_CAST))
+ if ((wield_slot(o_ptr) != -1) && (item < INVEN_WIELD) && (f & TR_WIELD_CAST))
{
msg_format("You cannot %s from that object; it must be wielded first.", do_what);
return -1;
@@ -2157,10 +2155,9 @@ void cast_school_spell()
/* Can it contains a schooled spell ? */
static bool hook_school_can_spellable(object_type const *o_ptr)
{
- u32b f1, f2, f3, f4, f5, esp;
- object_flags(o_ptr, &f1, &f2, &f3, &f4, &f5, &esp);
+ auto const f = object_flags(o_ptr);
- return ((f5 & TR5_SPELL_CONTAIN) && (o_ptr->pval2 == -1));
+ return ((f & TR_SPELL_CONTAIN) && (o_ptr->pval2 == -1));
}
/*
diff --git a/src/cmd6.cc b/src/cmd6.cc
index b34efeb3..0c0fb63d 100644
--- a/src/cmd6.cc
+++ b/src/cmd6.cc
@@ -30,6 +30,7 @@
#include "monster_type.hpp"
#include "object1.hpp"
#include "object2.hpp"
+#include "object_flag.hpp"
#include "object_kind.hpp"
#include "object_type.hpp"
#include "options.hpp"
@@ -2767,10 +2768,7 @@ bool_ curse_armor(void)
o_ptr->ac = 0;
o_ptr->dd = 0;
o_ptr->ds = 0;
- o_ptr->art_flags1 = 0;
- o_ptr->art_flags2 = 0;
- o_ptr->art_flags3 = 0;
- o_ptr->art_flags4 = 0;
+ o_ptr->art_flags = object_flag_set();
/* Curse it */
o_ptr->ident |= (IDENT_CURSED);
@@ -2832,10 +2830,7 @@ bool_ curse_weapon(void)
o_ptr->ac = 0;
o_ptr->dd = 0;
o_ptr->ds = 0;
- o_ptr->art_flags1 = 0;
- o_ptr->art_flags2 = 0;
- o_ptr->art_flags3 = 0;
- o_ptr->art_flags4 = 0;
+ o_ptr->art_flags = object_flag_set();
/* Curse it */
@@ -3701,8 +3696,6 @@ void do_cmd_use_staff(void)
{
bool_ obvious, use_charge;
- u32b f1, f2, f3, f4, f5, esp;
-
/* No magic */
if (p_ptr->antimagic)
{
@@ -3749,10 +3742,10 @@ void do_cmd_use_staff(void)
unset_stick_mode();
/* Extract object flags */
- object_flags(o_ptr, &f1, &f2, &f3, &f4, &f5, &esp);
+ auto const flags = object_flags(o_ptr);
/* Is it simple to use ? */
- if (f4 & TR4_EASY_USE)
+ if (flags & TR_EASY_USE)
{
chance /= 3;
}
@@ -3878,9 +3871,6 @@ void do_cmd_aim_wand(void)
{
bool_ obvious, use_charge;
- u32b f1, f2, f3, f4, f5, esp;
-
-
/* No magic */
if (p_ptr->antimagic)
{
@@ -3927,10 +3917,10 @@ void do_cmd_aim_wand(void)
unset_stick_mode();
/* Extract object flags */
- object_flags(o_ptr, &f1, &f2, &f3, &f4, &f5, &esp);
+ auto const flags = object_flags(o_ptr);
/* Is it simple to use ? */
- if (f4 & TR4_EASY_USE)
+ if (flags & TR_EASY_USE)
{
chance /= 3;
}
@@ -4041,12 +4031,6 @@ static bool item_tester_hook_attachable(object_type const *o_ptr)
*/
void zap_combine_rod_tip(object_type *q_ptr, int tip_item)
{
- int item;
-
- u32b f1, f2, f3, f4, f5, esp;
- s32b cost;
-
-
/* No magic */
if (p_ptr->antimagic)
{
@@ -4055,6 +4039,7 @@ void zap_combine_rod_tip(object_type *q_ptr, int tip_item)
}
/* Get an item */
+ int item;
if (!get_item(&item,
"Attach the rod tip with which rod? ",
"You have no rod to attach to.",
@@ -4068,12 +4053,11 @@ void zap_combine_rod_tip(object_type *q_ptr, int tip_item)
object_type *o_ptr = get_object(item);
/* Examine the rod */
- object_flags(o_ptr, &f1, &f2, &f3, &f4, &f5, &esp);
+ auto const flags = object_flags(o_ptr);
/* Calculate rod tip's mana cost */
- cost = q_ptr->pval;
-
- if (f4 & TR4_CHEAPNESS)
+ s32b cost = q_ptr->pval;
+ if (flags & TR_CHEAPNESS)
{
cost /= 2;
}
@@ -4109,8 +4093,6 @@ void do_cmd_zap_rod(void)
object_kind *tip_ptr;
- u32b f1, f2, f3, f4, f5, esp;
-
/* Hack -- let perception get aborted */
bool_ use_charge = TRUE;
@@ -4191,9 +4173,12 @@ void do_cmd_zap_rod(void)
energy_use = 100;
/* Examine the rod */
- object_flags(o_ptr, &f1, &f2, &f3, &f4, &f5, &esp);
+ auto const flags = object_flags(o_ptr);
- if (f4 & TR4_FAST_CAST) energy_use /= 2;
+ if (flags & TR_FAST_CAST)
+ {
+ energy_use /= 2;
+ }
/* Not identified yet */
ident = FALSE;
@@ -4217,7 +4202,7 @@ void do_cmd_zap_rod(void)
}
/* Is it simple to use ? */
- if (f4 & TR4_EASY_USE)
+ if (flags & TR_EASY_USE)
{
chance *= 10;
}
@@ -4246,7 +4231,7 @@ void do_cmd_zap_rod(void)
cost = tip_ptr->pval;
/* "Cheapness" ego halven the cost */
- if (f4 & TR4_CHEAPNESS) cost = cost / 2;
+ if (flags & TR_CHEAPNESS) cost = cost / 2;
/* A single rod is still charging */
if (o_ptr->timeout < cost)
@@ -4565,7 +4550,7 @@ static object_filter_t const &item_tester_hook_activate()
using namespace object_filter;
static auto instance = And(
IsKnown(),
- HasFlag3(TR3_ACTIVATE));
+ HasFlags(TR_ACTIVATE));
return instance;
}
@@ -4878,8 +4863,6 @@ void do_cmd_activate(void)
char ch, spell_choice;
- u32b f1, f2, f3, f4, f5, esp;
-
/* Get an item */
command_wrk = USE_EQUIP;
if (!get_item(&item,
@@ -4895,10 +4878,10 @@ void do_cmd_activate(void)
object_type *o_ptr = get_object(item);
/* Extract object flags */
- object_flags(o_ptr, &f1, &f2, &f3, &f4, &f5, &esp);
+ auto const flags = object_flags(o_ptr);
/* Wearable items have to be worn */
- if (!(f5 & TR5_ACTIVATE_NO_WIELD))
+ if (!(flags & TR_ACTIVATE_NO_WIELD))
{
if (item < INVEN_WIELD)
{
@@ -4941,7 +4924,7 @@ void do_cmd_activate(void)
}
/* Is it simple to use ? */
- if (f4 & TR4_EASY_USE)
+ if (flags & TR_EASY_USE)
{
chance *= 10;
}
diff --git a/src/cmd7.cc b/src/cmd7.cc
index 1d6718a9..42f82ea3 100644
--- a/src/cmd7.cc
+++ b/src/cmd7.cc
@@ -24,6 +24,7 @@
#include "monster_type.hpp"
#include "object1.hpp"
#include "object2.hpp"
+#include "object_flag.hpp"
#include "object_kind.hpp"
#include "options.hpp"
#include "player_type.hpp"
@@ -2311,7 +2312,7 @@ void do_cmd_necromancer(void)
object_prep(o_ptr, k_idx);
apply_magic(o_ptr, plev * 2, TRUE, TRUE, TRUE);
- o_ptr->art_flags5 |= TR5_TEMPORARY;
+ o_ptr->art_flags |= TR_TEMPORARY;
o_ptr->timeout = dur;
/* These objects are "storebought" */
diff --git a/src/corrupt.cc b/src/corrupt.cc
index 47d79d53..8d5670c6 100644
--- a/src/corrupt.cc
+++ b/src/corrupt.cc
@@ -1,6 +1,7 @@
#include "corrupt.hpp"
#include "init1.hpp"
+#include "object_flag.hpp"
#include "player_race.hpp"
#include "player_race_mod.hpp"
#include "player_type.hpp"
@@ -105,14 +106,14 @@ static void player_gain_vampire()
/* Bonus/and .. not bonus :) */
rmp_ptr->flags1 = rmp_ptr->flags1 | PR1_HURT_LITE;
- rmp_ptr->oflags2[2] = rmp_ptr->oflags2[2]
- | TR2_RES_POIS
- | TR2_RES_NETHER
- | TR2_RES_COLD
- | TR2_RES_DARK
- | TR2_HOLD_LIFE;
- rmp_ptr->oflags3[2] = rmp_ptr->oflags3[2]
- | TR3_LITE1;
+ rmp_ptr->oflags[2] = rmp_ptr->oflags[2]
+ | TR_RES_POIS
+ | TR_RES_NETHER
+ | TR_RES_COLD
+ | TR_RES_DARK
+ | TR_HOLD_LIFE;
+ rmp_ptr->oflags[2] = rmp_ptr->oflags[2]
+ | TR_LITE1;
}
/**
diff --git a/src/defines.h b/src/defines.h
index c99bcb39..1d078609 100644
--- a/src/defines.h
+++ b/src/defines.h
@@ -2270,227 +2270,8 @@
MFLAG_PARTIAL | MFLAG_CONTROL | MFLAG_NO_DROP \
)
-
-/*
- * As of 2.7.8, the "object flags" are valid for all objects, and as
- * of 2.7.9, these flags are not actually stored with the object.
- *
- * Note that "flags1" contains all flags dependant on "pval" (including
- * stat bonuses, but NOT stat sustainers), plus all "extra attack damage"
- * flags (SLAY_XXX and BRAND_XXX).
- *
- * Note that "flags2" contains all "resistances" (including "Stat Sustainers",
- * actual immunities, and resistances). Note that "Hold Life" is really an
- * "immunity" to ExpLoss, and "Free Action" is "immunity to paralysis".
- *
- * Note that "flags3" contains everything else -- including the three "CURSED"
- * flags, and the "BLESSED" flag, several "item display" parameters, some new
- * flags for powerful Bows, and flags which affect the player in a "general"
- * way (LITE, TELEPATHY, SEE_INVIS, SLOW_DIGEST, REGEN, FEATHER), including
- * all the "general" curses (TELEPORT, AGGRAVATE, EXP_DRAIN). It also has
- * four new flags called "ITEM_IGNORE_XXX" which lets an item specify that
- * it can not be affected by various forms of destruction. This is NOT as
- * powerful as actually granting resistance/immunity to the wearer.
- */
-
-#define TR1_STR 0x00000001L /* STR += "pval" */
-#define TR1_INT 0x00000002L /* INT += "pval" */
-#define TR1_WIS 0x00000004L /* WIS += "pval" */
-#define TR1_DEX 0x00000008L /* DEX += "pval" */
-#define TR1_CON 0x00000010L /* CON += "pval" */
-#define TR1_CHR 0x00000020L /* CHR += "pval" */
-#define TR1_MANA 0x00000040L /* Mana multipler */
-#define TR1_SPELL 0x00000080L /* Spell power increase */
-#define TR1_STEALTH 0x00000100L /* Stealth += "pval" */
-#define TR1_SEARCH 0x00000200L /* Search += "pval" */
-#define TR1_INFRA 0x00000400L /* Infra += "pval" */
-#define TR1_TUNNEL 0x00000800L /* Tunnel += "pval" */
-#define TR1_SPEED 0x00001000L /* Speed += "pval" */
-#define TR1_BLOWS 0x00002000L /* Blows += "pval" */
-#define TR1_CHAOTIC 0x00004000L
-#define TR1_VAMPIRIC 0x00008000L
-#define TR1_SLAY_ANIMAL 0x00010000L
-#define TR1_SLAY_EVIL 0x00020000L
-#define TR1_SLAY_UNDEAD 0x00040000L
-#define TR1_SLAY_DEMON 0x00080000L
-#define TR1_SLAY_ORC 0x00100000L
-#define TR1_SLAY_TROLL 0x00200000L
-#define TR1_SLAY_GIANT 0x00400000L
-#define TR1_SLAY_DRAGON 0x00800000L
-#define TR1_KILL_DRAGON 0x01000000L /* Execute Dragon */
-#define TR1_VORPAL 0x02000000L /* Later */
-#define TR1_IMPACT 0x04000000L /* Cause Earthquakes */
-#define TR1_BRAND_POIS 0x08000000L
-#define TR1_BRAND_ACID 0x10000000L
-#define TR1_BRAND_ELEC 0x20000000L
-#define TR1_BRAND_FIRE 0x40000000L
-#define TR1_BRAND_COLD 0x80000000L
-#define TR1_NULL_MASK 0x00000000L
-
-#define TRAP2_AUTOMATIC_5 0x00000001L /* Trap automatically rearms itself, 1 in 5 failure */
-#define TRAP2_AUTOMATIC_99 0x00000002L /* Trap automatically rearms itself */
-#define TRAP2_KILL_GHOST 0x00000004L /* Trap also affects PASS_WALL creatures */
-#define TRAP2_TELEPORT_TO 0x00000008L /* After everything else, teleport to player */
-#define TRAP2_ONLY_DRAGON 0x00000010L /* Affect only dragons & other AFFECTed creatures */
-#define TRAP2_ONLY_DEMON 0x00000020L /* Affect only demons & other AFFECTed creatures */
-#define TRAP2_ONLY_ANIMAL 0x00000100L /* Affect only animals & other AFFECTed creatures */
-#define TRAP2_ONLY_UNDEAD 0x00000200L /* Affect only undead & others */
-#define TRAP2_ONLY_EVIL 0x00000400L /* Affect only evil creatures &c. */
-
-#define TRAP2_ONLY_MASK (TRAP2_ONLY_DRAGON | TRAP2_ONLY_DEMON | TRAP2_ONLY_ANIMAL | \
- TRAP2_ONLY_UNDEAD | TRAP2_ONLY_EVIL )
-
-#define TR2_SUST_STR 0x00000001L
-#define TR2_SUST_INT 0x00000002L
-#define TR2_SUST_WIS 0x00000004L
-#define TR2_SUST_DEX 0x00000008L
-#define TR2_SUST_CON 0x00000010L
-#define TR2_SUST_CHR 0x00000020L
-#define TR2_INVIS 0x00000040L /* Invisibility */
-#define TR2_LIFE 0x00000080L /* Life multiplier */
-#define TR2_IM_ACID 0x00000100L
-#define TR2_IM_ELEC 0x00000200L
-#define TR2_IM_FIRE 0x00000400L
-#define TR2_IM_COLD 0x00000800L
-#define TR2_SENS_FIRE 0x00001000L /* Sensibility to fire */
-#define TR2_REFLECT 0x00002000L /* Reflect 'bolts' */
-#define TR2_FREE_ACT 0x00004000L /* Free Action */
-#define TR2_HOLD_LIFE 0x00008000L /* Hold Life */
-#define TR2_RES_ACID 0x00010000L
-#define TR2_RES_ELEC 0x00020000L
-#define TR2_RES_FIRE 0x00040000L
-#define TR2_RES_COLD 0x00080000L
-#define TR2_RES_POIS 0x00100000L
-#define TR2_RES_FEAR 0x00200000L
-#define TR2_RES_LITE 0x00400000L
-#define TR2_RES_DARK 0x00800000L
-#define TR2_RES_BLIND 0x01000000L
-#define TR2_RES_CONF 0x02000000L
-#define TR2_RES_SOUND 0x04000000L
-#define TR2_RES_SHARDS 0x08000000L
-#define TR2_RES_NETHER 0x10000000L
-#define TR2_RES_NEXUS 0x20000000L
-#define TR2_RES_CHAOS 0x40000000L
-#define TR2_RES_DISEN 0x80000000L
-#define TR2_NULL_MASK 0x00000000L
-
-#define TR3_SH_FIRE 0x00000001L /* Immolation (Fire) */
-#define TR3_SH_ELEC 0x00000002L /* Electric Sheath */
-#define TR3_AUTO_CURSE 0x00000004L /* The obj will recurse itself */
-#define TR3_DECAY 0x00000008L /* Decay */
-#define TR3_NO_TELE 0x00000010L /* Anti-teleportation */
-#define TR3_NO_MAGIC 0x00000020L /* Anti-magic */
-#define TR3_WRAITH 0x00000040L /* Wraithform */
-#define TR3_TY_CURSE 0x00000080L /* The Ancient Curse */
-#define TR3_EASY_KNOW 0x00000100L /* Aware -> Known */
-#define TR3_HIDE_TYPE 0x00000200L /* Hide "pval" description */
-#define TR3_SHOW_MODS 0x00000400L /* Always show Tohit/Todam */
-#define TR3_INSTA_ART 0x00000800L /* Item must be an artifact */
-#define TR3_FEATHER 0x00001000L /* Feather Falling */
-#define TR3_LITE1 0x00002000L /* lite radius 1 */
-#define TR3_SEE_INVIS 0x00004000L /* See Invisible */
-#define TR3_NORM_ART 0x00008000L /* Artifact in k_info */
-#define TR3_SLOW_DIGEST 0x00010000L /* Item slows down digestion */
-#define TR3_REGEN 0x00020000L /* Item induces regeneration */
-#define TR3_XTRA_MIGHT 0x00040000L /* Bows get extra multiplier */
-#define TR3_XTRA_SHOTS 0x00080000L /* Bows get extra shots */
-#define TR3_IGNORE_ACID 0x00100000L /* Item ignores Acid Damage */
-#define TR3_IGNORE_ELEC 0x00200000L /* Item ignores Elec Damage */
-#define TR3_IGNORE_FIRE 0x00400000L /* Item ignores Fire Damage */
-#define TR3_IGNORE_COLD 0x00800000L /* Item ignores Cold Damage */
-#define TR3_ACTIVATE 0x01000000L /* Item can be activated */
-#define TR3_DRAIN_EXP 0x02000000L /* Item drains Experience */
-#define TR3_TELEPORT 0x04000000L /* Item teleports player */
-#define TR3_AGGRAVATE 0x08000000L /* Item aggravates monsters */
-#define TR3_BLESSED 0x10000000L /* Item is Blessed */
-#define TR3_CURSED 0x20000000L /* Item is Cursed */
-#define TR3_HEAVY_CURSE 0x40000000L /* Item is Heavily Cursed */
-#define TR3_PERMA_CURSE 0x80000000L /* Item is Perma Cursed */
-#define TR3_NULL_MASK 0x00000000L
-
-
-#define TR4_NEVER_BLOW 0x00000001L /* Weapon can't attack */
-#define TR4_PRECOGNITION 0x00000002L /* Like activating the cheat mode */
-#define TR4_BLACK_BREATH 0x00000004L /* Tolkien's Black Breath */
-#define TR4_RECHARGE 0x00000008L /* For artifact Wands and Staffs */
-#define TR4_FLY 0x00000010L /* This one and ONLY this one allow you to fly over trees */
-#define TR4_DG_CURSE 0x00000020L /* The Ancient Morgothian Curse */
-#define TR4_COULD2H 0x00000040L /* Can wield it 2 Handed */
-#define TR4_MUST2H 0x00000080L /* Must wield it 2 Handed */
-#define TR4_LEVELS 0x00000100L /* Can gain exp/exp levels !! */
-#define TR4_CLONE 0x00000200L /* Can clone monsters */
-#define TR4_SPECIAL_GENE 0x00000400L /* The object can only be generated in special conditions like quests, special dungeons, ... */
-#define TR4_CLIMB 0x00000800L /* Allow climbing mountains */
-#define TR4_FAST_CAST 0x00001000L /* Rod is x2 time faster to use */
-#define TR4_CAPACITY 0x00002000L /* Rod can take x2 mana */
-#define TR4_CHARGING 0x00004000L /* Rod recharge faster */
-#define TR4_CHEAPNESS 0x00008000L /* Rod spells are cheaper(in mana cost) to cast */
-#define TR4_FOUNTAIN 0x00010000L /* Available as fountain (for potions) */
-#define TR4_ANTIMAGIC_50 0x00020000L /* Forbid magic */
-#define TR4_EASY_USE 0x00200000L /* Easily activable */
-#define TR4_IM_NETHER 0x00400000L /* Immunity to nether */
-#define TR4_RECHARGED 0x00800000L /* Object has been recharged once */
-#define TR4_ULTIMATE 0x01000000L /* ULTIMATE artifact */
-#define TR4_AUTO_ID 0x02000000L /* Id stuff on floor */
-#define TR4_LITE2 0x04000000L /* lite radius 2 */
-#define TR4_LITE3 0x08000000L /* lite radius 3 */
-#define TR4_FUEL_LITE 0x10000000L /* fuelable lite */
-#define TR4_CURSE_NO_DROP 0x40000000L /* The obj wont be dropped */
-#define TR4_NO_RECHARGE 0x80000000L /* Object Cannot be recharged */
-#define TR4_NULL_MASK 0xFFFFFFFCL
-
-#define TR5_TEMPORARY 0x00000001L /* In timeout turns it is destroyed */
-#define TR5_DRAIN_MANA 0x00000002L /* Drains mana */
-#define TR5_DRAIN_HP 0x00000004L /* Drains hp */
-#define TR5_KILL_DEMON 0x00000008L /* Execute Demon */
-#define TR5_KILL_UNDEAD 0x00000010L /* Execute Undead */
-#define TR5_CRIT 0x00000020L /* More critical hits */
-#define TR5_ATTR_MULTI 0x00000040L /* Object shimmer -- only allowed in k_info */
-#define TR5_WOUNDING 0x00000080L /* Wounds monsters */
-#define TR5_FULL_NAME 0x00000100L /* Uses direct name from k_info */
-#define TR5_LUCK 0x00000200L /* Luck += pval */
-#define TR5_IMMOVABLE 0x00000400L /* Cannot move */
-#define TR5_SPELL_CONTAIN 0x00000800L /* Can contain a spell */
-#define TR5_RES_MORGUL 0x00001000L /* Is not shattered by morgul fiends(nazguls) */
-#define TR5_ACTIVATE_NO_WIELD 0x00002000L /* Can be 'A'ctivated without being wielded */
-#define TR5_MAGIC_BREATH 0x00004000L /* Can breath anywere */
-#define TR5_WATER_BREATH 0x00008000L /* Can breath underwater */
-#define TR5_WIELD_CAST 0x00010000L /* Must be wielded to cast spell from it */
-#define TR5_RANDOM_RESIST 0x00020000L /* Grants random resistance */
-#define TR5_RANDOM_POWER 0x00040000L /* Grants random power */
-#define TR5_RANDOM_RES_OR_POWER 0x00080000L /* Grants random resistance OR power (50-50 chance) */
-
-/* ESP defines */
-#define ESP_ORC 0x00000001L
-#define ESP_TROLL 0x00000002L
-#define ESP_DRAGON 0x00000004L
-#define ESP_GIANT 0x00000008L
-#define ESP_DEMON 0x00000010L
-#define ESP_UNDEAD 0x00000020L
-#define ESP_EVIL 0x00000040L
-#define ESP_ANIMAL 0x00000080L
-#define ESP_THUNDERLORD 0x00000100L
-#define ESP_GOOD 0x00000200L
-#define ESP_NONLIVING 0x00000400L
-#define ESP_UNIQUE 0x00000800L
-#define ESP_SPIDER 0x00001000L
-#define ESP_ALL 0x80000000L
-
#define NEW_GROUP_CHANCE 40 /* Chance to get a new group */
-/*
- * Hack masks for "pval-dependant" flags.
- */
-#define TR1_PVAL_MASK \
- (TR1_STR | TR1_INT | TR1_WIS | TR1_DEX | \
- TR1_CON | TR1_CHR | \
- TR1_STEALTH | TR1_SEARCH | TR1_INFRA | TR1_TUNNEL | \
- TR1_SPEED | TR1_BLOWS | TR1_SPELL)
-
-#define TR5_PVAL_MASK \
- (TR5_CRIT | TR5_LUCK)
-
-
/*** Ego flags ***/
#define ETR4_SUSTAIN 0x00000001L /* Ego-Item gives a Random Sustain */
#define ETR4_OLD_RESIST 0x00000002L /* The old "extra power" random high resist */
diff --git a/src/dungeon.cc b/src/dungeon.cc
index c05c6ed3..d70ffcde 100644
--- a/src/dungeon.cc
+++ b/src/dungeon.cc
@@ -46,6 +46,7 @@
#include "notes.hpp"
#include "object1.hpp"
#include "object2.hpp"
+#include "object_flag.hpp"
#include "object_kind.hpp"
#include "object_type.hpp"
#include "options.hpp"
@@ -849,17 +850,10 @@ static void regen_monsters(void)
*
* Should belong to object1.c, renamed to object_decays() -- pelpel
*/
-static bool_ decays(object_type *o_ptr)
+static bool decays(object_type *o_ptr)
{
- u32b f1, f2, f3, f4, f5, esp;
-
-
- /* Extract some flags */
- object_flags(o_ptr, &f1, &f2, &f3, &f4, &f5, &esp);
-
- if (f3 & TR3_DECAY) return (TRUE);
-
- return (FALSE);
+ auto const flags = object_flags(o_ptr);
+ return bool(flags & TR_DECAY);
}
@@ -1233,8 +1227,6 @@ static void process_world(void)
cave_type *c_ptr;
object_type *o_ptr;
- u32b f1 = 0 , f2 = 0 , f3 = 0, f4 = 0, f5 = 0, esp = 0;
-
/*
* Every 10 game turns -- which means this section is invoked once
@@ -1582,10 +1574,10 @@ static void process_world(void)
o_ptr = &p_ptr->inventory[INVEN_WIELD];
/* Examine the sword */
- object_flags(o_ptr, &f1, &f2, &f3, &f4, &f5, &esp);
+ auto const flags = object_flags(o_ptr);
/* Hitpoints multiplier consume a lot of food */
- if (o_ptr->k_idx && (f2 & (TR2_LIFE))) i += o_ptr->pval * 5;
+ if (o_ptr->k_idx && (flags & TR_LIFE)) i += o_ptr->pval * 5;
/* Slow digestion takes less food */
if (p_ptr->slow_digest) i -= 10;
@@ -2580,8 +2572,6 @@ static void process_world(void)
*/
if (((turn % 3000) == 0) && p_ptr->black_breath)
{
- u32b f1, f2, f3, f4, f5;
-
bool_ be_silent = FALSE;
/* check all equipment for the Black Breath flag. */
@@ -2593,10 +2583,10 @@ static void process_world(void)
if (!o_ptr->k_idx) continue;
/* Extract the item flags */
- object_flags(o_ptr, &f1, &f2, &f3, &f4, &f5, &esp);
+ auto const flags = object_flags(o_ptr);
/* No messages if object has the flag, to avoid annoyance. */
- if (f4 & (TR4_BLACK_BREATH)) be_silent = TRUE;
+ if (flags & TR_BLACK_BREATH) be_silent = TRUE;
}
/* If we are allowed to speak, warn and disturb. */
@@ -2618,10 +2608,10 @@ static void process_world(void)
if (o_ptr->tval == TV_LITE)
{
/* Extract the item flags */
- object_flags(o_ptr, &f1, &f2, &f3, &f4, &f5, &esp);
+ auto const flags = object_flags(o_ptr);
/* Hack -- Use some fuel */
- if ((f4 & TR4_FUEL_LITE) && (o_ptr->timeout > 0))
+ if ((flags & TR_FUEL_LITE) && (o_ptr->timeout > 0))
{
/* Decrease life-span */
o_ptr->timeout--;
@@ -2767,17 +2757,17 @@ static void process_world(void)
/* Get the object */
o_ptr = &p_ptr->inventory[i];
- object_flags(o_ptr, &f1, &f2, &f3, &f4, &f5, &esp);
+ auto const flags = object_flags(o_ptr);
/* TY Curse */
- if ((f3 & TR3_TY_CURSE) && (rand_int(TY_CURSE_CHANCE) == 0))
+ if ((flags & TR_TY_CURSE) && (rand_int(TY_CURSE_CHANCE) == 0))
{
activate_ty_curse();
}
/* DG Curse */
- if ((f4 & TR4_DG_CURSE) && (rand_int(DG_CURSE_CHANCE) == 0))
+ if ((flags & TR_DG_CURSE) && (rand_int(DG_CURSE_CHANCE) == 0))
{
activate_dg_curse();
@@ -2786,7 +2776,7 @@ static void process_world(void)
}
/* Auto Curse */
- if ((f3 & TR3_AUTO_CURSE) && (rand_int(AUTO_CURSE_CHANCE) == 0))
+ if ((flags & TR_AUTO_CURSE) && (rand_int(AUTO_CURSE_CHANCE) == 0))
{
/* The object recurse itself ! */
o_ptr->ident |= IDENT_CURSED;
@@ -2796,7 +2786,7 @@ static void process_world(void)
* Hack: Uncursed teleporting items (e.g. Dragon Weapons)
* can actually be useful!
*/
- if ((f3 & TR3_TELEPORT) && (rand_int(100) < 1))
+ if ((flags & TR_TELEPORT) && (rand_int(100) < 1))
{
if ((o_ptr->ident & IDENT_CURSED) && !p_ptr->anti_tele)
{
@@ -2826,7 +2816,7 @@ static void process_world(void)
if (!o_ptr->k_idx) continue;
/* Hack: Skip wielded lights that need fuel (already handled above) */
- if ((i == INVEN_LITE) && (o_ptr->tval == TV_LITE) && (f4 & TR4_FUEL_LITE)) continue;
+ if ((i == INVEN_LITE) && (o_ptr->tval == TV_LITE) && (flags & TR_FUEL_LITE)) continue;
/* Recharge activatable objects */
if (o_ptr->timeout > 0)
@@ -2869,10 +2859,10 @@ static void process_world(void)
if (!o_ptr->k_idx) continue;
/* Examine the rod */
- object_flags(o_ptr, &f1, &f2, &f3, &f4, &f5, &esp);
+ auto const flags = object_flags(o_ptr);
/* Temporary items are destroyed */
- if (f5 & TR5_TEMPORARY)
+ if (flags & TR_TEMPORARY)
{
o_ptr->timeout--;
@@ -2889,7 +2879,7 @@ static void process_world(void)
if ((o_ptr->tval == TV_ROD_MAIN) && (o_ptr->timeout < o_ptr->pval2))
{
/* Increase the rod's mana. */
- o_ptr->timeout += (f4 & TR4_CHARGING) ? 2 : 1;
+ o_ptr->timeout += (flags & TR_CHARGING) ? 2 : 1;
/* Always notice */
j++;
@@ -2903,7 +2893,7 @@ static void process_world(void)
}
/* Examine all charging random artifacts */
- if ((f5 & TR5_ACTIVATE_NO_WIELD) && (o_ptr->timeout > 0))
+ if ((flags & TR_ACTIVATE_NO_WIELD) && (o_ptr->timeout > 0))
{
/* Charge it */
o_ptr->timeout--;
@@ -3004,10 +2994,10 @@ static void process_world(void)
if (!o_ptr->k_idx) continue;
/* Examine the rod */
- object_flags(o_ptr, &f1, &f2, &f3, &f4, &f5, &esp);
+ auto const flags = object_flags(o_ptr);
/* Temporary items are destroyed */
- if (f5 & TR5_TEMPORARY)
+ if (flags & TR_TEMPORARY)
{
o_ptr->timeout--;
@@ -3025,7 +3015,7 @@ static void process_world(void)
if ((o_ptr->tval == TV_ROD_MAIN) && (o_ptr->timeout < o_ptr->pval2))
{
/* Increase the rod's mana. */
- o_ptr->timeout += (f4 & TR4_CHARGING) ? 2 : 1;
+ o_ptr->timeout += (flags & TR_CHARGING) ? 2 : 1;
/* Do not overflow */
if (o_ptr->timeout >= o_ptr->pval2)
@@ -3493,16 +3483,8 @@ static void process_command(void)
/* Go up staircase */
case '<':
{
- object_type *o_ptr;
- u32b f1 = 0 , f2 = 0 , f3 = 0, f4 = 0, f5 = 0, esp = 0;
-
-
- /* Check for light being wielded */
- o_ptr = &p_ptr->inventory[INVEN_LITE];
- /* Burn some fuel in the current lite */
- if (o_ptr->tval == TV_LITE)
- /* Extract the item flags */
- object_flags(o_ptr, &f1, &f2, &f3, &f4, &f5, &esp);
+ /* Get the light being wielded */
+ auto o_ptr = &p_ptr->inventory[INVEN_LITE];
/* Cannot move if rooted in place */
if (p_ptr->tim_roots) break;
@@ -4540,7 +4522,7 @@ static void process_player(void)
if ((!o_ptr->k_idx) || (!o_ptr->ix)) continue;
/* Skip non-multi-hued monsters */
- if (!(k_ptr->flags5 & (TR5_ATTR_MULTI))) continue;
+ if (!(k_ptr->flags & TR_ATTR_MULTI)) continue;
/* Reset the flag */
shimmer_objects = TRUE;
diff --git a/src/ego_item_type.hpp b/src/ego_item_type.hpp
index b5cf2781..77fe6637 100644
--- a/src/ego_item_type.hpp
+++ b/src/ego_item_type.hpp
@@ -1,6 +1,9 @@
#pragma once
#include "h-basic.h"
+#include "object_flag_set.hpp"
+
+#include <array>
/*
* Size of flag rarity tables
@@ -38,33 +41,21 @@ struct ego_item_type
byte rar[FLAG_RARITY_MAX] = { 0 };
- u32b flags1[FLAG_RARITY_MAX] = { 0 }; /* Ego-Item Flags, set 1 */
- u32b flags2[FLAG_RARITY_MAX] = { 0 }; /* Ego-Item Flags, set 2 */
- u32b flags3[FLAG_RARITY_MAX] = { 0 }; /* Ego-Item Flags, set 3 */
- u32b flags4[FLAG_RARITY_MAX] = { 0 }; /* Ego-Item Flags, set 4 */
- u32b flags5[FLAG_RARITY_MAX] = { 0 }; /* Ego-Item Flags, set 5 */
- u32b esp[FLAG_RARITY_MAX] = { 0 }; /* ESP flags */
- u32b oflags1[FLAG_RARITY_MAX] = { 0 }; /* Ego-Item Obvious Flags, set 1 */
- u32b oflags2[FLAG_RARITY_MAX] = { 0 }; /* Ego-Item Obvious Flags, set 2 */
- u32b oflags3[FLAG_RARITY_MAX] = { 0 }; /* Ego-Item Obvious Flags, set 3 */
- u32b oflags4[FLAG_RARITY_MAX] = { 0 }; /* Ego-Item Obvious Flags, set 4 */
- u32b oflags5[FLAG_RARITY_MAX] = { 0 }; /* Ego-Item Obvious Flags, set 5 */
- u32b oesp[FLAG_RARITY_MAX] = { 0 }; /* Obvious ESP flags */
+ std::array<object_flag_set, FLAG_RARITY_MAX> flags;
+ std::array<object_flag_set, FLAG_RARITY_MAX> oflags;
u32b fego[FLAG_RARITY_MAX] = { 0 }; /* ego flags */
- u32b need_flags1 = 0; /* Ego-Item Flags, set 1 */
- u32b need_flags2 = 0; /* Ego-Item Flags, set 2 */
- u32b need_flags3 = 0; /* Ego-Item Flags, set 3 */
- u32b need_flags4 = 0; /* Ego-Item Flags, set 4 */
- u32b need_flags5 = 0; /* Ego-Item Flags, set 5 */
- u32b need_esp = 0; /* ESP flags */
- u32b forbid_flags1 = 0; /* Ego-Item Flags, set 1 */
- u32b forbid_flags2 = 0; /* Ego-Item Flags, set 2 */
- u32b forbid_flags3 = 0; /* Ego-Item Flags, set 3 */
- u32b forbid_flags4 = 0; /* Ego-Item Flags, set 4 */
- u32b forbid_flags5 = 0; /* Ego-Item Flags, set 5 */
- u32b forbid_esp = 0; /* ESP flags */
-
- s16b power = 0; /* Power granted, if any */
+ object_flag_set need_flags;
+ object_flag_set forbid_flags;
+
+ s16b power = -1; /* Power granted, if any */
+
+public:
+ ego_item_type()
+ {
+ std::fill(std::begin(tval),
+ std::end(tval),
+ 255);
+ }
};
diff --git a/src/files.cc b/src/files.cc
index e375e7b0..9ebc18ab 100644
--- a/src/files.cc
+++ b/src/files.cc
@@ -23,6 +23,7 @@
#include "loadsave.h"
#include "loadsave.hpp"
#include "mimic.hpp"
+#include "monoid.hpp"
#include "monster2.hpp"
#include "monster3.hpp"
#include "monster_ego.hpp"
@@ -32,6 +33,8 @@
#include "notes.hpp"
#include "object1.hpp"
#include "object2.hpp"
+#include "object_flag.hpp"
+#include "object_flag_meta.hpp"
#include "object_kind.hpp"
#include "options.hpp"
#include "player_class.hpp"
@@ -56,9 +59,10 @@
#include "z-rand.hpp"
#include <boost/filesystem.hpp>
-#include <memory>
#include <iostream>
#include <fstream>
+#include <limits>
+#include <memory>
#include <unordered_set>
/*
@@ -1546,620 +1550,642 @@ static void display_player_various(void)
* Obtain the "flags" of the wielded symbiote
*/
-void wield_monster_flags(u32b *f1, u32b *f2, u32b *f3, u32b *f4, u32b *f5, u32b *esp)
+static object_flag_set wield_monster_flags()
{
- object_type *o_ptr;
- monster_race *r_ptr;
-
- /* Clear */
- (*f1) = (*f2) = (*f3) = (*f4) = (*f5) = (*esp) = 0L;
+ object_flag_set flags;
/* Get the carried monster */
- o_ptr = &p_ptr->inventory[INVEN_CARRY];
-
+ auto o_ptr = &p_ptr->inventory[INVEN_CARRY];
if (o_ptr->k_idx)
{
- r_ptr = &r_info[o_ptr->pval];
+ auto r_ptr = &r_info[o_ptr->pval];
if (r_ptr->flags & RF_INVISIBLE)
- (*f2) |= TR2_INVIS;
+ flags |= TR_INVIS;
if (r_ptr->flags & RF_REFLECTING)
- (*f2) |= TR2_REFLECT;
+ flags |= TR_REFLECT;
if (r_ptr->flags & RF_CAN_FLY)
- (*f3) |= TR3_FEATHER;
+ flags |= TR_FEATHER;
if (r_ptr->flags & RF_AQUATIC)
- (*f5) |= TR5_WATER_BREATH;
+ flags |= TR_WATER_BREATH;
}
+
+ return flags;
}
/*
* Obtain the "flags" for the player as if he was an item
*/
-void player_flags(u32b *f1, u32b *f2, u32b *f3, u32b *f4, u32b *f5, u32b *esp)
+object_flag_set player_flags()
{
- int i;
-
/* Clear */
- (*f1) = (*f2) = (*f3) = (*f4) = (*f5) = (*esp) = 0L;
+ object_flag_set f;
/* Astral chars */
if (p_ptr->astral)
{
- (*f3) |= TR3_WRAITH;
+ f |= TR_WRAITH;
}
/* Skills */
- if (get_skill(SKILL_DAEMON) > 20) (*f2) |= TR2_RES_CONF;
- if (get_skill(SKILL_DAEMON) > 30) (*f2) |= TR2_RES_FEAR;
- if (get_skill(SKILL_MINDCRAFT) >= 40) (*esp) |= ESP_ALL;
+ if (get_skill(SKILL_DAEMON) > 20) f |= TR_RES_CONF;
+ if (get_skill(SKILL_DAEMON) > 30) f |= TR_RES_FEAR;
+ if (get_skill(SKILL_MINDCRAFT) >= 40) f |= ESP_ALL;
if (p_ptr->melee_style == SKILL_HAND && get_skill(SKILL_HAND) > 24 && !monk_heavy_armor())
- (*f2) |= TR2_FREE_ACT;
-/* Hack - from Lua */
- if (get_skill(SKILL_MANA) >= 35) (*f1) |= TR1_MANA;
- if (get_skill(SKILL_AIR) >= 50) (*f5) |= (TR5_MAGIC_BREATH | TR5_WATER_BREATH);
- if (get_skill(SKILL_WATER) >= 30) (*f5) |= TR5_WATER_BREATH;
+ {
+ f |= TR_FREE_ACT;
+ }
+ if (get_skill(SKILL_MANA) >= 35) f |= TR_MANA;
+ if (get_skill(SKILL_AIR) >= 50) f |= (TR_MAGIC_BREATH | TR_WATER_BREATH);
+ if (get_skill(SKILL_WATER) >= 30) f |= TR_WATER_BREATH;
/* Gods */
if (p_ptr->pgod == GOD_ERU)
{
- if ((p_ptr->grace >= 100) || (p_ptr->grace <= -100)) (*f1) |= TR1_MANA;
- if (p_ptr->grace > 10000) (*f1) |= TR1_WIS;
+ if ((p_ptr->grace >= 100) || (p_ptr->grace <= -100)) f |= TR_MANA;
+ if (p_ptr->grace > 10000) f |= TR_WIS;
}
if (p_ptr->pgod == GOD_MELKOR)
{
- (*f2) |= TR2_RES_FIRE;
- if (p_ptr->melkor_sacrifice > 0) (*f2) |= TR2_LIFE;
- if (p_ptr->grace > 10000) (*f1) |= (TR1_STR | TR1_CON | TR1_INT | TR1_WIS | TR1_CHR);
+ f |= TR_RES_FIRE;
+ if (p_ptr->melkor_sacrifice > 0) f |= TR_LIFE;
+ if (p_ptr->grace > 10000) f |= (TR_STR | TR_CON | TR_INT | TR_WIS | TR_CHR);
if (p_ptr->praying)
{
- if (p_ptr->grace > 5000) (*f2) |= TR2_INVIS;
- if (p_ptr->grace > 15000) (*f2) |= TR2_IM_FIRE;
+ if (p_ptr->grace > 5000) f |= TR_INVIS;
+ if (p_ptr->grace > 15000) f |= TR_IM_FIRE;
}
}
if (p_ptr->pgod == GOD_MANWE)
{
- if (p_ptr->grace >= 2000) (*f3) |= TR3_FEATHER;
+ if (p_ptr->grace >= 2000) f |= TR_FEATHER;
if (p_ptr->praying)
{
- if (p_ptr->grace >= 7000) (*f2) |= TR2_FREE_ACT;
- if (p_ptr->grace >= 15000) (*f4) |= TR4_FLY;
- if ((p_ptr->grace >= 5000) || (p_ptr->grace <= -5000)) (*f1) |= TR1_SPEED;
+ if (p_ptr->grace >= 7000) f |= TR_FREE_ACT;
+ if (p_ptr->grace >= 15000) f |= TR_FLY;
+ if ((p_ptr->grace >= 5000) || (p_ptr->grace <= -5000)) f |= TR_SPEED;
}
}
if (p_ptr->pgod == GOD_TULKAS)
{
- if (p_ptr->grace > 5000) (*f1) |= TR1_CON;
- if (p_ptr->grace > 10000) (*f1) |= TR1_STR;
+ if (p_ptr->grace > 5000) f |= TR_CON;
+ if (p_ptr->grace > 10000) f |= TR_STR;
}
if (p_ptr->pgod == GOD_AULE)
{
if (p_ptr->grace > 5000)
{
- (*f2) |= TR2_RES_FIRE;
+ f |= TR_RES_FIRE;
}
}
if (p_ptr->pgod == GOD_MANDOS)
{
- (*f2) |= TR2_RES_NETHER;
+ f |= TR_RES_NETHER;
if ((p_ptr->grace > 10000) &&
(p_ptr->praying == TRUE))
{
- (*f3) |= TR3_NO_TELE;
+ f |= TR_NO_TELE;
}
if ((p_ptr->grace > 20000) &&
(p_ptr->praying == TRUE))
{
- (*f4) |= TR4_IM_NETHER;
+ f |= TR_IM_NETHER;
}
}
if (p_ptr->pgod == GOD_ULMO)
{
- (*f5) |= TR5_WATER_BREATH;
+ f |= TR_WATER_BREATH;
if ((p_ptr->grace > 1000) &&
(p_ptr->praying == TRUE))
{
- (*f2) |= TR2_RES_POIS;
+ f |= TR_RES_POIS;
}
if ((p_ptr->grace > 15000) &&
(p_ptr->praying == TRUE))
{
- (*f5) |= TR5_MAGIC_BREATH;
+ f |= TR_MAGIC_BREATH;
}
}
/* Classes */
- for (i = 1; i <= p_ptr->lev; i++)
+ for (int i = 1; i <= p_ptr->lev; i++)
{
- (*f1) |= cp_ptr->oflags1[i];
- (*f2) |= cp_ptr->oflags2[i];
- (*f3) |= cp_ptr->oflags3[i];
- (*f4) |= cp_ptr->oflags4[i];
- (*f5) |= cp_ptr->oflags5[i];
- (*esp) |= cp_ptr->oesp[i];
+ f |= cp_ptr->oflags[i];
}
/* Races */
if ((!p_ptr->mimic_form) && (!p_ptr->body_monster))
{
- for (i = 1; i <= p_ptr->lev; i++)
+ for (int i = 1; i <= p_ptr->lev; i++)
{
- (*f1) |= rp_ptr->oflags1[i];
- (*f2) |= rp_ptr->oflags2[i];
- (*f3) |= rp_ptr->oflags3[i];
- (*f4) |= rp_ptr->oflags4[i];
- (*f5) |= rp_ptr->oflags5[i];
- (*esp) |= rp_ptr->oesp[i];
+ f |= rp_ptr->oflags[i];
- (*f1) |= rmp_ptr->oflags1[i];
- (*f2) |= rmp_ptr->oflags2[i];
- (*f3) |= rmp_ptr->oflags3[i];
- (*f4) |= rmp_ptr->oflags4[i];
- (*f5) |= rmp_ptr->oflags5[i];
- (*esp) |= rmp_ptr->oesp[i];
+ f |= rmp_ptr->oflags[i];
}
}
else
{
monster_race *r_ptr = &r_info[p_ptr->body_monster];
- if (r_ptr->flags & RF_REFLECTING) (*f2) |= TR2_REFLECT;
- if (r_ptr->flags & RF_REGENERATE) (*f3) |= TR3_REGEN;
- if (r_ptr->flags & RF_AURA_FIRE) (*f3) |= TR3_SH_FIRE;
- if (r_ptr->flags & RF_AURA_ELEC) (*f3) |= TR3_SH_ELEC;
- if (r_ptr->flags & RF_PASS_WALL) (*f3) |= TR3_WRAITH;
- if (r_ptr->flags & RF_SUSCEP_FIRE) (*f2) |= TR2_SENS_FIRE;
- if (r_ptr->flags & RF_IM_ACID) (*f2) |= TR2_RES_ACID;
- if (r_ptr->flags & RF_IM_ELEC) (*f2) |= TR2_RES_ELEC;
- if (r_ptr->flags & RF_IM_FIRE) (*f2) |= TR2_RES_FIRE;
- if (r_ptr->flags & RF_IM_POIS) (*f2) |= TR2_RES_POIS;
- if (r_ptr->flags & RF_IM_COLD) (*f2) |= TR2_RES_COLD;
- if (r_ptr->flags & RF_RES_NETH) (*f2) |= TR2_RES_NETHER;
- if (r_ptr->flags & RF_RES_NEXU) (*f2) |= TR2_RES_NEXUS;
- if (r_ptr->flags & RF_RES_DISE) (*f2) |= TR2_RES_DISEN;
- if (r_ptr->flags & RF_NO_FEAR) (*f2) |= TR2_RES_FEAR;
- if (r_ptr->flags & RF_NO_SLEEP) (*f2) |= TR2_FREE_ACT;
- if (r_ptr->flags & RF_NO_CONF) (*f2) |= TR2_RES_CONF;
- if (r_ptr->flags & RF_CAN_FLY) (*f3) |= TR3_FEATHER;
- }
-
- (*f1) |= p_ptr->xtra_f1;
- (*f2) |= p_ptr->xtra_f2;
- (*f3) |= p_ptr->xtra_f3;
- (*f4) |= p_ptr->xtra_f4;
- (*f5) |= p_ptr->xtra_f5;
- (*esp) |= p_ptr->xtra_esp;
+ if (r_ptr->flags & RF_REFLECTING) f |= TR_REFLECT;
+ if (r_ptr->flags & RF_REGENERATE) f |= TR_REGEN;
+ if (r_ptr->flags & RF_AURA_FIRE) f |= TR_SH_FIRE;
+ if (r_ptr->flags & RF_AURA_ELEC) f |= TR_SH_ELEC;
+ if (r_ptr->flags & RF_PASS_WALL) f |= TR_WRAITH;
+ if (r_ptr->flags & RF_SUSCEP_FIRE) f |= TR_SENS_FIRE;
+ if (r_ptr->flags & RF_IM_ACID) f |= TR_RES_ACID;
+ if (r_ptr->flags & RF_IM_ELEC) f |= TR_RES_ELEC;
+ if (r_ptr->flags & RF_IM_FIRE) f |= TR_RES_FIRE;
+ if (r_ptr->flags & RF_IM_POIS) f |= TR_RES_POIS;
+ if (r_ptr->flags & RF_IM_COLD) f |= TR_RES_COLD;
+ if (r_ptr->flags & RF_RES_NETH) f |= TR_RES_NETHER;
+ if (r_ptr->flags & RF_RES_NEXU) f |= TR_RES_NEXUS;
+ if (r_ptr->flags & RF_RES_DISE) f |= TR_RES_DISEN;
+ if (r_ptr->flags & RF_NO_FEAR) f |= TR_RES_FEAR;
+ if (r_ptr->flags & RF_NO_SLEEP) f |= TR_FREE_ACT;
+ if (r_ptr->flags & RF_NO_CONF) f |= TR_RES_CONF;
+ if (r_ptr->flags & RF_CAN_FLY) f |= TR_FEATHER;
+ }
+
+ f |= p_ptr->xtra_flags;
if (p_ptr->black_breath)
{
- (*f4) |= TR4_BLACK_BREATH;
+ f |= TR_BLACK_BREATH;
}
if (p_ptr->hp_mod != 0)
{
- (*f2) |= TR2_LIFE;
+ f |= TR_LIFE;
}
+
+ return f;
}
+namespace { // <anonymous>
+
/*
- * Object flag names
+ * Build an return a (static) index of all the object_flag_meta
+ * information indexed by page->column->row.
*/
-static cptr object_flag_names[192] =
+static std::vector<object_flag_meta const *> const &object_flag_metas_by_pcr(int page, int column, int row)
{
- "Add Str",
- "Add Int",
- "Add Wis",
- "Add Dex",
- "Add Con",
- "Add Chr",
- "Mul Mana",
- "Mul SPower",
- "Add Stea.",
- "Add Sear.",
- "Add Infra",
- "Add Tun..",
- "Add Speed",
- "Add Blows",
- "Chaotic",
- "Vampiric",
- "Slay Anim.",
- "Slay Evil",
- "Slay Und.",
- "Slay Demon",
- "Slay Orc",
- "Slay Troll",
- "Slay Giant",
- "Slay Drag.",
- "Kill Drag.",
- "Sharpness",
- "Impact",
- "Poison Brd",
- "Acid Brand",
- "Elec Brand",
- "Fire Brand",
- "Cold Brand",
-
- "Sust Str",
- "Sust Int",
- "Sust Wis",
- "Sust Dex",
- "Sust Con",
- "Sust Chr",
- "Invisible",
- "Mul life",
- "Imm Acid",
- "Imm Elec",
- "Imm Fire",
- "Imm Cold",
- "Sens Fire",
- "Reflect",
- "Free Act",
- "Hold Life",
- "Res Acid",
- "Res Elec",
- "Res Fire",
- "Res Cold",
- "Res Pois",
- "Res Fear",
- "Res Light",
- "Res Dark",
- "Res Blind",
- "Res Conf",
- "Res Sound",
- "Res Shard",
- "Res Neth",
- "Res Nexus",
- "Res Chaos",
- "Res Disen",
-
-
-
- "Aura Fire",
- "Aura Elec",
- "Auto Curse",
- NULL,
- "NoTeleport",
- "AntiMagic",
- "WraithForm",
- "EvilCurse",
- NULL,
- NULL,
- NULL,
- NULL,
- "Levitate",
- "Lite",
- "See Invis",
- NULL,
- "Digestion",
- "Regen",
- "Xtra Might",
- "Xtra Shots",
- NULL,
- NULL,
- NULL,
- NULL,
- "Activate",
- "Drain Exp",
- "Teleport",
- "Aggravate",
- "Blessed",
- "Cursed",
- "Hvy Curse",
- "Prm Curse",
-
- "No blows",
- "Precogn.",
- "B.Breath",
- "Recharge",
- "Fly",
- "Mrg.Curse",
- NULL,
- NULL,
- "Sentient",
- "Clone",
- NULL,
- "Climb",
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- "Imm Neth",
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
-
- "Orc.ESP",
- "Troll.ESP",
- "Dragon.ESP",
- "Giant.ESP",
- "Demon.ESP",
- "Undead.ESP",
- "Evil.ESP",
- "Animal.ESP",
- "TLord.ESP",
- "Good.ESP",
- "Nlive.ESP",
- "Unique.ESP",
- "Spider ESP",
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- "Full ESP",
+ static std::vector<std::vector<std::vector<std::vector<object_flag_meta const *>>>> instance;
+
+ if (instance.empty())
+ {
+ // Find number of pages, columns and rows.
+ std::size_t n_pages = 0;
+ std::size_t n_columns = 0;
+ std::size_t n_rows = 0;
+
+ for (auto const &object_flag_meta: object_flags_meta())
+ {
+ n_pages = std::max<std::size_t>(n_pages, object_flag_meta->c_page + 1);
+ n_columns = std::max<std::size_t>(n_columns, object_flag_meta->c_column + 1);
+ n_rows = std::max<std::size_t>(n_rows, object_flag_meta->c_row + 1);
+ }
+
+ // Sanity check; we should always have enough data.
+ assert(n_pages > 0);
+ assert(n_columns > 0);
+ assert(n_rows > 0);
+
+ // Build the scaffolding structure without the actual data.
+ instance.reserve(n_pages);
+ for (std::size_t i = 0; i < n_pages; i++)
+ {
+ std::vector<std::vector<std::vector<object_flag_meta const *>>> page;
+ page.reserve(n_columns);
+
+ for (std::size_t j = 0; j < n_columns; j++)
+ {
+ std::vector<std::vector<object_flag_meta const *>> column;
+ column.reserve(n_rows);
+
+ for (std::size_t k = 0; k < n_rows; k++)
+ {
+ std::vector<object_flag_meta const *> row;
+ column.push_back(row);
+ }
+
+ page.push_back(column);
+ }
+
+ instance.push_back(page);
+ }
+
+ // Insert all the data.
+ for (auto const object_flag_meta: object_flags_meta())
+ {
+ // Ignore if not mapped to any page.
+ if (!object_flag_meta->c_name)
+ {
+ continue;
+ }
+
+ // Find the row
+ auto &row = instance
+ .at(object_flag_meta->c_page)
+ .at(object_flag_meta->c_column)
+ .at(object_flag_meta->c_row);
+
+ // Insert
+ row.push_back(object_flag_meta);
+ }
+ }
+
+ return instance.at(page).at(column).at(row);
+}
+
+
+/**
+ * Convert a number to a digit, capping at '9'. Ignores the sign of the number.
+ */
+static char number_to_digit(int n) {
+ // Throw away sign.
+ n = std::abs(n);
+ // Convert to digit or '*'
+ return (n > 9 ? '*' : I2D(n));
};
-/*
- * Summarize resistances
+
+/**
+ * Check that two object_flag types are compatible.
*/
-static void display_player_ben_one(int mode)
+static bool object_flag_types_are_compatible(char type_a, char type_b)
{
- int i, n, x, y, z, dispx, modetemp, xtemp;
+ switch (type_a)
+ {
+ case 'n':
+ return (type_b == 'n');
+ case 'b':
+ return (type_b == 'b');
+ case '+':
+ case '*':
+ return (type_b == '+') || (type_b == '*');
+ case 'f':
+ return (type_b == 'f');
+ case '\0':
+ return true;
+ default:
+ abort();
+ }
+}
- object_type *o_ptr;
+/**
+ * Object flag data for calculating cells on the character sheet.
+ */
+struct object_flag_cell {
+ /**
+ * Type designator for the cell, if any.
+ */
+ char type;
+
+ /**
+ * Associated PVAL, if any.
+ */
+ int pval;
- char dummy[80], c;
+ /**
+ * Label for the cell, given its current contents.
+ */
+ const char *label;
- u32b f1, f2, f3, f4, f5, esp;
+ /**
+ * Create object_flag_cell from object_flag_meta.
+ */
+ static object_flag_cell from_object_flag_meta(object_flag_meta const &object_flag_meta, int pval)
+ {
+ // The FIXED type flags require special handling.
+ if ((object_flag_meta.c_type == '1') || (object_flag_meta.c_type == '2') || (object_flag_meta.c_type == '3'))
+ {
+ return object_flag_cell {
+ 'f',
+ D2I(object_flag_meta.c_type),
+ object_flag_meta.c_name
+ };
+ }
+ else
+ {
+ return object_flag_cell {
+ object_flag_meta.c_type,
+ pval,
+ object_flag_meta.c_name
+ };
+ }
+ }
- u16b b[INVEN_TOTAL - INVEN_WIELD + 1][10];
+};
- int d[INVEN_TOTAL - INVEN_WIELD + 1];
+namespace detail { // "hide" from surrounding scope; should only be accessed through the monoid
- bool_ got;
+static object_flag_cell object_flag_cell_append(object_flag_cell const &a, object_flag_cell const &b)
+{
+ // The "empty" value automatically gets swallowed, whatever
+ // "side" of the append it's on.
+ if (a.type == '\0')
+ {
+ return b;
+ }
- byte a;
+ if (b.type == '\0')
+ {
+ return a;
+ }
- cptr name;
+ // The rest of the code assumes compatible types, so we
+ // assert this to a) avoid over-complicated logic, and
+ // b) breaking under 'unexpected' changes to the object
+ // flag list.
+ if (!object_flag_types_are_compatible(a.type, b.type))
+ {
+ abort();
+ }
- /* Scan equipment */
- for (i = INVEN_WIELD; i < INVEN_TOTAL; i++)
+ // Any boolean flag which is "set" overrides the previous
+ // flag. (If the flag was already set we won't lose any
+ // information.)
+ if (b.type == 'b')
{
- /* Index */
- n = (i - INVEN_WIELD);
+ return b;
+ }
- /* Object */
- o_ptr = &p_ptr->inventory[i];
+ // Flags with a numerical value get added together.
+ if (b.type == 'n') // (a.type == 'n') by symmetry and object_flag_types_are_compatible()
+ {
+ // Arbitrary choice of label -- the labels *should* be the same, by definition
+ return object_flag_cell { 'n', a.pval + b.pval, a.label };
+ }
- /* Known object flags */
- object_flags_known(o_ptr, &f1, &f2, &f3, &f4, &f5, &esp);
+ // Fixed-value flags.
+ if (a.type == 'f') // (b.type == 'f') by symmetry and object_flag_types_are_compatible()
+ {
+ // Arbitrary choice of label -- the labels *should* be the same, by definition
+ return object_flag_cell { 'f', a.pval + b.pval, a.label };
+ }
- /* Incorporate */
- b[n][0] = (u16b)(f1 & 0xFFFF);
- b[n][1] = (u16b)(f1 >> 16);
- b[n][2] = (u16b)(f2 & 0xFFFF);
- b[n][3] = (u16b)(f2 >> 16);
- b[n][4] = (u16b)(f3 & 0xFFFF);
- b[n][5] = (u16b)(f3 >> 16);
- b[n][6] = (u16b)(f4 & 0xFFFF);
- b[n][7] = (u16b)(f4 >> 16);
- b[n][8] = (u16b)(esp & 0xFFFF);
- b[n][9] = (u16b)(esp >> 16);
- d[n] = o_ptr->pval;
+ // Flags of the TERNARY variety have a "supercedes" rule
+ // where immunity supercedes resistance.
+ if (a.type == '*')
+ {
+ return object_flag_cell { '*', 0, a.label };
+ }
+ else if (b.type == '*')
+ {
+ return object_flag_cell { '*', 0, b.label };
+ }
+ else // Both must be '+'
+ {
+ // Arbitrary choice of label -- the labels *should* be the same, by definition
+ return object_flag_cell { '+', 0, a.label };
}
+}
- /* Carried symbiote */
- n = INVEN_CARRY - INVEN_WIELD;
+constexpr object_flag_cell object_flag_cell_empty { '\0', 0, nullptr };
- /* Player flags */
- wield_monster_flags(&f1, &f2, &f3, &f4, &f5, &esp);
+} // namespace "detail"
- /* Incorporate */
- b[n][0] = (u16b)(f1 & 0xFFFF);
- b[n][1] = (u16b)(f1 >> 16);
- b[n][2] = (u16b)(f2 & 0xFFFF);
- b[n][3] = (u16b)(f2 >> 16);
- b[n][4] = (u16b)(f3 & 0xFFFF);
- b[n][5] = (u16b)(f3 >> 16);
- b[n][6] = (u16b)(f4 & 0xFFFF);
- b[n][7] = (u16b)(f4 >> 16);
- b[n][8] = (u16b)(esp & 0xFFFF);
- b[n][9] = (u16b)(esp >> 16);
+using object_flag_cell_monoid = monoid<object_flag_cell, detail::object_flag_cell_append, detail::object_flag_cell_empty>;
- /* Index */
- n = INVEN_TOTAL - INVEN_WIELD;
+} // namespace <anonymous>
- /* Player flags */
- player_flags(&f1, &f2, &f3, &f4, &f5, &esp);
+namespace { // <anonymous>
- /* Incorporate */
- b[n][0] = (u16b)(f1 & 0xFFFF);
- b[n][1] = (u16b)(f1 >> 16);
- b[n][2] = (u16b)(f2 & 0xFFFF);
- b[n][3] = (u16b)(f2 >> 16);
- b[n][4] = (u16b)(f3 & 0xFFFF);
- b[n][5] = (u16b)(f3 >> 16);
- b[n][6] = (u16b)(f4 & 0xFFFF);
- b[n][7] = (u16b)(f4 >> 16);
- b[n][8] = (u16b)(esp & 0xFFFF);
- b[n][9] = (u16b)(esp >> 16);
+static object_flag_meta const *get_lowest_priority_object_flag_meta(std::vector<object_flag_meta const *> const &object_flag_metas)
+{
+ object_flag_meta const *found = nullptr;
- /* Generate the equip chars */
- sprintf(dummy, " ");
- for (i = 0; i < INVEN_TOTAL - INVEN_WIELD; i++)
+ for (auto object_flag_meta: object_flag_metas)
{
- /* If you have that body part then show it */
- if (p_ptr->body_parts[i])
+ if ((!found) || (found->c_priority > object_flag_meta->c_priority))
{
- strcat(dummy, format("%c", i + 'a'));
+ found = object_flag_meta;
}
}
- strcat(dummy, "@");
- /* Scan cols */
- for (x = 1; x > -1; x--)
+ return found;
+}
+
+
+static std::tuple<char, int> object_flag_cell_to_char(object_flag_cell const &object_flag_cell)
+{
+ switch (object_flag_cell.type)
{
- /* Label */
- Term_putstr(x * 40 + 11, 3, -1, TERM_WHITE, dummy);
+ case 'n':
+ case 'f':
+ // If we have no pval, we use a simple '+'. This applies
+ // to the 'player' slot.
+ if (object_flag_cell.pval == 0)
+ {
+ return std::make_tuple('+', 1);
+ }
+ else
+ {
+ return std::make_tuple(
+ number_to_digit(object_flag_cell.pval),
+ (object_flag_cell.pval >= 0) ? 1 : -1);
+ }
+ break;
+
+ case 'b':
+ case '+':
+ return std::make_tuple('+', 1);
+ break;
+
+ case '*':
+ return std::make_tuple('*', 1);
+ break;
+
+ default:
+ return std::make_tuple('.', 0);
+ break;
+ }
+
+ abort();
+}
+
- /* Scan rows */
- for (y = 0; y < 16; y++)
+/*
+ * Output a slot
+ */
+static void display_flag_row(
+ int y,
+ int x0,
+ std::vector<std::tuple<char, int, object_flag_set>> const &slots,
+ std::vector<object_flag_meta const *> const &object_flag_metas_at_pcr)
+{
+ assert(!object_flag_metas_at_pcr.empty());
+
+ // Accumulated value of all of the slots
+ auto acc = object_flag_cell_monoid::empty;
+
+ // Go through each slot
+ for (std::size_t i = 0; i < slots.size(); i++)
+ {
+ object_flag_cell combined = object_flag_cell_monoid::empty;
+
+ // Go through all flags that are actually set for this 'cell'.
{
- if (mode == 3 && x == 1)
- {
- modetemp = 4;
- xtemp = 0;
- }
- else
+ auto const &slot = slots[i];
+ auto const pval = std::get<1>(slot);
+ auto const flags = std::get<2>(slot);
+
+ for (auto const object_flag_meta: object_flag_metas_at_pcr)
{
- modetemp = mode;
- xtemp = x;
+ if (object_flag_meta->flag_set & flags)
+ {
+ combined = object_flag_cell_monoid::append(
+ combined,
+ object_flag_cell::from_object_flag_meta(*object_flag_meta, pval));
+ }
}
+ }
- for (z = mode; z <= modetemp; z++)
- {
- if (mode == 3 && x == 1 && z == modetemp) xtemp = 1;
- name = object_flag_names[32 * modetemp + 16 * xtemp + y];
- got = FALSE;
+ // Accumulate into the global accumulator
+ acc = object_flag_cell_monoid::append(acc, combined);
- /* No name */
- if (!name) continue;
+ // Write the cell's value.
+ auto const char_and_rating = object_flag_cell_to_char(combined);
+ auto const ch = std::get<0>(char_and_rating);
+ auto const rating = std::get<1>(char_and_rating);
- /* Dump colon */
- if (!(modetemp == 1 && x == 0 && y > 7 && y < 12))
- {
- Term_putch(x * 40 + 10, y + 4, TERM_WHITE, ':');
- }
+ // Convert good flag into a color.
+ byte a;
+ if (rating == 0)
+ {
+ a = (i & 0x02) ? TERM_GREEN : TERM_SLATE;
+ }
+ else if (rating < 0)
+ {
+ a = TERM_RED;
+ }
+ else
+ {
+ a = TERM_L_GREEN;
+ }
- /* Check flags */
- dispx = 0;
- for (n = 0; n < INVEN_TOTAL - INVEN_WIELD + 1; n++)
- {
- /* Change colour every two columns */
- bool_ is_green = (dispx & 0x02);
- a = (is_green ? TERM_GREEN : TERM_SLATE);
- c = '.';
+ // Output the flag
+ Term_putch(x0 + 11 + i, y, a, ch);
+ }
- /* If the body part doesn't exists then skip it :) */
- if ((n < INVEN_TOTAL - INVEN_WIELD) && (!p_ptr->body_parts[n])) continue;
+ // Extract the label. If the flag isn't set at all then we don't have
+ // an actual label, so we'll use the one from the meta-level object
+ // flag definition. Note that the prioritization is crucial for the
+ // labeling to work properly; e.g. IMM_FIRE comes *before* the
+ // RES_FIRE flag in the object flag list, but we don't want the *label*
+ // from IMM_FIRE to be used when the flag is not set at all.
+ auto const label = (acc.label != nullptr)
+ ? acc.label
+ : get_lowest_priority_object_flag_meta(object_flag_metas_at_pcr)->c_name;
- /* Increment the drawing coordinates */
- dispx++;
+ // Get the "rating" for the label.
+ auto const rating = std::get<1>(object_flag_cell_to_char(acc));
- /* Check flag */
- if (b[n][2 * modetemp + xtemp] & (1 << y))
- {
- a = (is_green ? TERM_L_GREEN : TERM_WHITE);
- if (modetemp == 1 && x == 0 && y > 7 && y < 12)
- {
- c = '*';
- }
- else if (modetemp == 0 && x == 0 && y < 14 && (y < 6 || y > 7))
- {
- if (n == INVEN_TOTAL - INVEN_WIELD)
- {
- c = '+';
- }
- else
- {
- c = d[n];
- if (c < 0)
- {
- c = -c;
- a = TERM_RED;
- }
- c = (c > 9 ? '*' : I2D(c));
- }
- }
- else
- {
- c = '+';
- }
- got = TRUE;
- }
+ byte label_attr;
+ if (rating == 0) {
+ label_attr = TERM_WHITE;
+ } else if (rating < 0) {
+ label_attr = TERM_RED;
+ } else {
+ label_attr = TERM_L_GREEN;
+ }
- /* HACK - Check for nether immunity and
- apply to Res Neth line */
- if (modetemp == 1 && x == 1 && y == 12)
- {
- if (b[n][7] & (1 << 6))
- {
- a = (is_green ? TERM_L_GREEN : TERM_WHITE);
- c = '*';
- got = TRUE;
- }
- }
+ Term_putch(x0 + 10, y, TERM_WHITE, ':');
+ Term_putstr(x0, y, -1, label_attr, label);
+}
- /* Dump flag */
- if (modetemp == 1 && x == 0 && y > 7 && y < 12)
- {
- if (c == '*') Term_putch(40 + 11 + dispx, y - 4, a, c);
- }
- else
- {
- Term_putch(x * 40 + 11 + dispx, y + 4, a, c);
- }
- }
+/*
+ * Summarize resistances
+ */
+static void display_player_ben_one(int page)
+{
+ // Slots of flags to show.
+ std::vector<std::tuple<char, int, object_flag_set>> slots;
+ slots.reserve(INVEN_TOTAL - INVEN_WIELD + 1);
- a = TERM_WHITE;
- if (got)
- {
- if (modetemp == 1 && x == 0 && y > 7 && y < 12)
- {
- a = TERM_L_GREEN;
- }
- else if (modetemp != 0)
- {
- a = TERM_GREEN;
- }
- }
+ // Scan equipment
+ for (std::size_t i = INVEN_WIELD; i < INVEN_TOTAL; i++)
+ {
+ // Skip inventory slots that don't exist on the body.
+ auto n = i - INVEN_WIELD;
+ if ((n < INVEN_TOTAL - INVEN_WIELD) && (!p_ptr->body_parts[n])) continue;
- /* HACK - Check for nether immunity and change "Res Neth" */
- if (modetemp == 1 && x == 1 && y == 12 && p_ptr->immune_neth)
- {
- name = "Imm Neth";
- a = TERM_L_GREEN;
- }
+ // Extract object flags
+ auto const o_ptr = &p_ptr->inventory[i];
+ auto const flags = object_flags_known(o_ptr);
+ // Add slot
+ slots.emplace_back(
+ std::make_tuple('a' + i - INVEN_WIELD, o_ptr->pval, flags));
+ }
- /* Dump name */
- if (modetemp == 1 && x == 0 && y > 7 && y < 12)
- {
- if (got) Term_putstr(40, y - 4, -1, a, name);
- }
- else
- {
- Term_putstr(x * 40, y + 4, -1, a, name);
- }
+ // Carried symbiote
+ {
+ // Extract flags
+ auto const flags = wield_monster_flags();
+ // Add slot
+ slots.emplace_back(
+ std::make_tuple('z', 0, flags));
+ }
+
+ // Player
+ slots.emplace_back(
+ std::make_tuple('@', 0, player_flags()));
+
+ // Go through each column
+ for (int col = 0; col < 2; col++)
+ {
+ // Base coordinate for output
+ const auto x0 = col * 40;
+ const auto y0 = 3;
+
+ // Add slot headings.
+ {
+ std::string buf;
+ buf.reserve(slots.size());
+
+ for (auto const &slot: slots)
+ {
+ buf += std::get<0>(slot);
+ }
+
+ Term_putstr(x0 + 11, y0, -1, TERM_WHITE, buf.c_str());
+ }
+
+ // Scan rows
+ for (int row = 0; row < 16; row++)
+ {
+ // Extract the flag metadata for the current page/col/row
+ auto const object_flag_metas_at_pcr =
+ object_flag_metas_by_pcr(page, col, row);
+
+ // Ignore flags which we don't actually map to anything.
+ if (object_flag_metas_at_pcr.empty())
+ {
+ continue;
}
+
+ // Y coordinate for the row
+ auto const y = y0 + 1 + row;
+
+ // Show the row
+ display_flag_row(y, x0, slots, object_flag_metas_at_pcr);
}
}
}
+} // namespace <anonymous>
/*
* Display the character on the screen (various modes)
@@ -4030,7 +4056,7 @@ static long total_points(void)
object_kind *k_ptr = &k_info[k];
/* Hack -- skip artifacts */
- if (k_ptr->flags3 & (TR3_INSTA_ART)) continue;
+ if (k_ptr->flags & TR_INSTA_ART) continue;
/* List known flavored objects */
if (k_ptr->flavor && k_ptr->aware)
diff --git a/src/files.hpp b/src/files.hpp
index d90f6660..35a10079 100644
--- a/src/files.hpp
+++ b/src/files.hpp
@@ -2,13 +2,14 @@
#include "h-basic.h"
#include "monster_type_fwd.hpp"
+#include "object_flag_set.hpp"
#include <string>
#include <vector>
extern void html_screenshot(cptr name);
extern void help_file_screenshot(cptr name);
-extern void player_flags(u32b* f1, u32b* f2, u32b* f3, u32b* f4, u32b* f5, u32b* esp);
+extern object_flag_set player_flags();
extern void wipe_saved(void);
extern s16b tokenize(char *buf, s16b num, char **tokens, char delim1, char delim2);
extern void display_player(int mode);
diff --git a/src/flag_set.hpp b/src/flag_set.hpp
index 737513d5..7960de42 100644
--- a/src/flag_set.hpp
+++ b/src/flag_set.hpp
@@ -50,6 +50,14 @@ public:
return f;
}
+ static constexpr flag_set make_bit(std::size_t ibit)
+ {
+ assert(ibit < nbits);
+ flag_set f;
+ f.m_data[ibit / 32] = (1UL << (ibit % 32));
+ return f;
+ }
+
constexpr std::size_t size() const
{
return tiers;
diff --git a/src/flags_group.hpp b/src/flags_group.hpp
index 8bd4bacb..84809e37 100644
--- a/src/flags_group.hpp
+++ b/src/flags_group.hpp
@@ -1,6 +1,7 @@
#pragma once
#include "h-basic.h"
+#include "object_flag_set.hpp"
/**
* For level gaining artifacts
@@ -12,9 +13,5 @@ struct flags_group
byte price = 0; /* Price to "buy" it */
- u32b flags1 = 0; /* Flags set 1 */
- u32b flags2 = 0; /* Flags set 2 */
- u32b flags3 = 0; /* Flags set 3 */
- u32b flags4 = 0; /* Flags set 4 */
- u32b esp = 0; /* ESP flags set */
+ object_flag_set flags; /* Flags set */
};
diff --git a/src/generate.cc b/src/generate.cc
index 6474f6de..d1bcbe31 100644
--- a/src/generate.cc
+++ b/src/generate.cc
@@ -25,6 +25,7 @@
#include "monster_spell_flag.hpp"
#include "monster_type.hpp"
#include "object2.hpp"
+#include "object_flag.hpp"
#include "object_kind.hpp"
#include "options.hpp"
#include "player_type.hpp"
@@ -823,7 +824,7 @@ static void place_fountain(int y, int x)
object_kind *k_ptr = &k_info[k];
if (((k_ptr->tval == TV_POTION) || (k_ptr->tval == TV_POTION2)) &&
- (k_ptr->level <= dun_level) && (k_ptr->flags4 & TR4_FOUNTAIN))
+ (k_ptr->level <= dun_level) && (k_ptr->flags & TR_FOUNTAIN))
{
if (k_ptr->tval == TV_POTION2) svals[maxsval] = k_ptr->sval + SV_POTION_LAST;
else svals[maxsval] = k_ptr->sval;
diff --git a/src/help.cc b/src/help.cc
index e8eec115..a0847af1 100644
--- a/src/help.cc
+++ b/src/help.cc
@@ -16,6 +16,7 @@
#include "hook_move_in.hpp"
#include "hooks.hpp"
#include "object1.hpp"
+#include "object_flag.hpp"
#include "options.hpp"
#include "player_type.hpp"
#include "skills.hpp"
@@ -389,9 +390,8 @@ static bool_ trigger_identify_spell_item(void *in_, void *out) {
if (in->mode == IDENT_FULL)
{
- u32b f1, f2, f3, f4, f5, esp;
- object_flags(in->o_ptr, &f1, &f2, &f3, &f4, &f5, &esp);
- if (f5 & TR5_SPELL_CONTAIN)
+ auto const f = object_flags(in->o_ptr);
+ if (f & TR_SPELL_CONTAIN)
{
return TRUE;
}
diff --git a/src/init1.cc b/src/init1.cc
index 38736f0e..0a6ecff0 100644
--- a/src/init1.cc
+++ b/src/init1.cc
@@ -21,6 +21,8 @@
#include "monster_type.hpp"
#include "object1.hpp"
#include "object2.hpp"
+#include "object_flag.hpp"
+#include "object_flag_meta.hpp"
#include "object_kind.hpp"
#include "owner_type.hpp"
#include "player_class.hpp"
@@ -153,280 +155,6 @@ static cptr r_info_blow_effect[] =
};
-/*
- * Object flags
- */
-static cptr k_info_flags1[] =
-{
- "STR",
- "INT",
- "WIS",
- "DEX",
- "CON",
- "CHR",
- "MANA",
- "SPELL",
- "STEALTH",
- "SEARCH",
- "INFRA",
- "TUNNEL",
- "SPEED",
- "BLOWS",
- "CHAOTIC",
- "VAMPIRIC",
- "SLAY_ANIMAL",
- "SLAY_EVIL",
- "SLAY_UNDEAD",
- "SLAY_DEMON",
- "SLAY_ORC",
- "SLAY_TROLL",
- "SLAY_GIANT",
- "SLAY_DRAGON",
- "KILL_DRAGON",
- "VORPAL",
- "IMPACT",
- "BRAND_POIS",
- "BRAND_ACID",
- "BRAND_ELEC",
- "BRAND_FIRE",
- "BRAND_COLD"
-};
-
-/*
- * Object flags
- */
-static cptr k_info_flags2[] =
-{
- "SUST_STR",
- "SUST_INT",
- "SUST_WIS",
- "SUST_DEX",
- "SUST_CON",
- "SUST_CHR",
- "INVIS",
- "LIFE",
- "IM_ACID",
- "IM_ELEC",
- "IM_FIRE",
- "IM_COLD",
- "SENS_FIRE",
- "REFLECT",
- "FREE_ACT",
- "HOLD_LIFE",
- "RES_ACID",
- "RES_ELEC",
- "RES_FIRE",
- "RES_COLD",
- "RES_POIS",
- "RES_FEAR",
- "RES_LITE",
- "RES_DARK",
- "RES_BLIND",
- "RES_CONF",
- "RES_SOUND",
- "RES_SHARDS",
- "RES_NETHER",
- "RES_NEXUS",
- "RES_CHAOS",
- "RES_DISEN"
-};
-
-/*
- * Trap flags
- */
-static cptr k_info_flags2_trap[] =
-{
- "AUTOMATIC_5",
- "AUTOMATIC_99",
- "KILL_GHOST",
- "TELEPORT_TO",
- "ONLY_DRAGON",
- "ONLY_DEMON",
- "XXX3",
- "XXX3",
- "ONLY_ANIMAL",
- "ONLY_UNDEAD",
- "ONLY_EVIL",
- "XXX3",
- "XXX3",
- "XXX3",
- "XXX3",
- "XXX3",
- "XXX3",
- "XXX3",
- "XXX3",
- "XXX3",
- "XXX3",
- "XXX3",
- "XXX3",
- "XXX3",
- "XXX3",
- "XXX3",
- "XXX3",
- "XXX3",
- "XXX3",
- "XXX3",
- "XXX3",
- "XXX3",
-};
-
-
-/*
- * Object flags
- */
-static cptr k_info_flags3[] =
-{
- "SH_FIRE",
- "SH_ELEC",
- "AUTO_CURSE",
- "DECAY",
- "NO_TELE",
- "NO_MAGIC",
- "WRAITH",
- "TY_CURSE",
- "EASY_KNOW",
- "HIDE_TYPE",
- "SHOW_MODS",
- "INSTA_ART",
- "FEATHER",
- "LITE1",
- "SEE_INVIS",
- "NORM_ART",
- "SLOW_DIGEST",
- "REGEN",
- "XTRA_MIGHT",
- "XTRA_SHOTS",
- "IGNORE_ACID",
- "IGNORE_ELEC",
- "IGNORE_FIRE",
- "IGNORE_COLD",
- "ACTIVATE",
- "DRAIN_EXP",
- "TELEPORT",
- "AGGRAVATE",
- "BLESSED",
- "CURSED",
- "HEAVY_CURSE",
- "PERMA_CURSE"
-};
-
-/*
- * Object flags
- */
-static cptr k_info_flags4[] =
-{
- "NEVER_BLOW",
- "PRECOGNITION",
- "BLACK_BREATH",
- "RECHARGE",
- "FLY",
- "DG_CURSE",
- "COULD2H",
- "MUST2H",
- "LEVELS",
- "CLONE",
- "SPECIAL_GENE",
- "CLIMB",
- "FAST_CAST",
- "CAPACITY",
- "CHARGING",
- "CHEAPNESS",
- "FOUNTAIN",
- "ANTIMAGIC_50",
- "XXX5",
- "XXX5",
- "XXX5",
- "EASY_USE",
- "IM_NETHER",
- "RECHARGED",
- "ULTIMATE",
- "AUTO_ID",
- "LITE2",
- "LITE3",
- "FUEL_LITE",
- "XXX5",
- "CURSE_NO_DROP",
- "NO_RECHARGE"
-};
-
-/*
- * Object flags
- */
-static cptr k_info_flags5[] =
-{
- "TEMPORARY",
- "DRAIN_MANA",
- "DRAIN_HP",
- "KILL_DEMON",
- "KILL_UNDEAD",
- "CRIT",
- "ATTR_MULTI",
- "WOUNDING",
- "FULL_NAME",
- "LUCK",
- "IMMOVABLE",
- "SPELL_CONTAIN",
- "RES_MORGUL",
- "ACTIVATE_NO_WIELD",
- "MAGIC_BREATH",
- "WATER_BREATH",
- "WIELD_CAST",
- "RANDOM_RESIST",
- "RANDOM_POWER",
- "RANDOM_RES_OR_POWER",
- "XXX8X20",
- "XXX8X21",
- "XXX8X22",
- "XXX8X23",
- "XXX8X24",
- "XXX8X25",
- "XXX8X26",
- "XXX8X27",
- "XXX8X28",
- "XXX8X29",
- "XXX8X02",
- "XXX8X22",
-};
-
-/*
- * ESP flags
- */
-static cptr esp_flags[] =
-{
- "ESP_ORC",
- "ESP_TROLL",
- "ESP_DRAGON",
- "ESP_GIANT",
- "ESP_DEMON",
- "ESP_UNDEAD",
- "ESP_EVIL",
- "ESP_ANIMAL",
- "ESP_THUNDERLORD",
- "ESP_GOOD",
- "ESP_NONLIVING",
- "ESP_UNIQUE",
- "ESP_SPIDER",
- "XXX8X02",
- "XXX8X02",
- "XXX8X02",
- "XXX8X02",
- "XXX8X17",
- "XXX8X18",
- "XXX8X19",
- "XXX8X20",
- "XXX8X21",
- "XXX8X22",
- "XXX8X23",
- "XXX8X24",
- "XXX8X25",
- "XXX8X26",
- "XXX8X27",
- "XXX8X28",
- "XXX8X29",
- "XXX8X02",
- "ESP_ALL",
-};
-
/* Specially handled properties for ego-items */
static cptr ego_flags[] =
@@ -1190,6 +918,7 @@ static errr grab_one_class_flag(u32b *choice, cptr what)
/* Failure */
return (1);
}
+
static errr grab_one_race_allow_flag(u32b *choice, cptr what)
{
int i;
@@ -1264,18 +993,29 @@ static int get_activation(char *activation)
}
/*
+ * Convert string to object_flag_set value
+ */
+static object_flag_set object_flag_set_from_string(cptr what)
+{
+ for (auto const flag_meta: object_flags_meta())
+ {
+ if (streq(what, flag_meta->e_name))
+ {
+ return flag_meta->flag_set;
+ };
+ }
+
+ return object_flag_set();
+}
+
+/*
* Grab one flag in an object_kind from a textual string
*/
-static errr grab_one_race_kind_flag(u32b *f1, u32b *f2, u32b *f3, u32b *f4, u32b *f5, u32b *esp, cptr what)
+static errr grab_object_flag(object_flag_set *flags, cptr what)
{
- if (lookup_flags(what,
- flag_tie(f1, k_info_flags1),
- flag_tie(f2, k_info_flags2),
- flag_tie(f3, k_info_flags3),
- flag_tie(f4, k_info_flags4),
- flag_tie(f5, k_info_flags5),
- flag_tie(esp, esp_flags)))
+ if (object_flag_set f = object_flag_set_from_string(what))
{
+ *flags |= f;
return 0;
}
@@ -1620,7 +1360,7 @@ errr init_player_info_txt(FILE *fp)
/* Process 'F' for "level Flags" (multiple lines) */
if ((buf[0] == 'R') && (buf[2] == 'F'))
{
- if (0 != grab_one_race_kind_flag(&rp_ptr->oflags1[lev], &rp_ptr->oflags2[lev], &rp_ptr->oflags3[lev], &rp_ptr->oflags4[lev], &rp_ptr->oflags5[lev], &rp_ptr->oesp[lev], buf + 4))
+ if (grab_object_flag(&rp_ptr->oflags[lev], buf + 4))
{
return (5);
}
@@ -1916,7 +1656,7 @@ errr init_player_info_txt(FILE *fp)
/* Process 'F' for "level Flags" (multiple lines) */
if ((buf[0] == 'S') && (buf[2] == 'F'))
{
- if (0 != grab_one_race_kind_flag(&rmp_ptr->oflags1[lev], &rmp_ptr->oflags2[lev], &rmp_ptr->oflags3[lev], &rmp_ptr->oflags4[lev], &rmp_ptr->oflags5[lev], &rmp_ptr->oesp[lev], buf + 4))
+ if (0 != grab_object_flag(&rmp_ptr->oflags[lev], buf + 4))
{
return (5);
}
@@ -2370,7 +2110,10 @@ errr init_player_info_txt(FILE *fp)
}
/* Parse this entry */
- if (0 != grab_one_race_kind_flag(&c_ptr->oflags1[lev], &c_ptr->oflags2[lev], &c_ptr->oflags3[lev], &c_ptr->oflags4[lev], &c_ptr->oflags5[lev], &c_ptr->oesp[lev], s)) return (5);
+ if (0 != grab_object_flag(&c_ptr->oflags[lev], s))
+ {
+ return (5);
+ }
/* Start the next entry */
s = t;
@@ -3059,39 +2802,6 @@ errr init_f_info_txt(FILE *fp)
/*
- * Grab one flag in an object_kind from a textual string
- */
-static errr grab_one_kind_flag(object_kind *k_ptr, cptr what, bool_ obvious)
-{
- /* Dispatch to correct set of flags */
- u32b *f1 = obvious ? &k_ptr->oflags1 : &k_ptr->flags1;
- u32b *f2 = obvious ? &k_ptr->oflags2 : &k_ptr->flags2;
- u32b *f3 = obvious ? &k_ptr->oflags3 : &k_ptr->flags3;
- u32b *f4 = obvious ? &k_ptr->oflags4 : &k_ptr->flags4;
- u32b *f5 = obvious ? &k_ptr->oflags5 : &k_ptr->flags5;
- u32b *esp = obvious ? &k_ptr->oesp : &k_ptr->esp;
-
- /* Lookup */
- if (lookup_flags(what,
- flag_tie(f1, k_info_flags1),
- flag_tie(f2, k_info_flags2),
- flag_tie(f2, k_info_flags2_trap),
- flag_tie(f3, k_info_flags3),
- flag_tie(f4, k_info_flags4),
- flag_tie(f5, k_info_flags5),
- flag_tie(esp, esp_flags)))
- {
- return 0;
- }
-
- /* Oops */
- msg_format("Unknown object flag '%s'.", what);
-
- /* Error */
- return (1);
-}
-
-/*
* Initialize the "k_info" array, by parsing an ascii "template" file
*/
errr init_k_info_txt(FILE *fp)
@@ -3162,7 +2872,6 @@ errr init_k_info_txt(FILE *fp)
k_ptr->text = my_strdup("");
/* Needed hack */
- k_ptr->esp = 0;
k_ptr->power = -1;
/* Next... */
@@ -3388,7 +3097,7 @@ errr init_k_info_txt(FILE *fp)
/* Hack -- Process 'F' for flags */
if (buf[0] == 'F')
{
- if (0 != grab_one_kind_flag(k_ptr, buf + 2, FALSE))
+ if (0 != grab_object_flag(&k_ptr->flags, buf + 2))
{
return (5);
}
@@ -3400,7 +3109,7 @@ errr init_k_info_txt(FILE *fp)
/* Hack -- Process 'f' for obvious flags */
if (buf[0] == 'f')
{
- if (0 != grab_one_kind_flag(k_ptr, buf + 2, TRUE))
+ if (0 != grab_object_flag(&k_ptr->oflags, buf + 2))
{
return (5);
}
@@ -3418,40 +3127,6 @@ errr init_k_info_txt(FILE *fp)
return (0);
}
-/*
- * Grab one flag in an artifact_type from a textual string
- */
-static errr grab_one_artifact_flag(artifact_type *a_ptr, cptr what, bool_ obvious)
-{
- /* Dispatch to correct set of flags */
- u32b *f1 = obvious ? &a_ptr->oflags1 : &a_ptr->flags1;
- u32b *f2 = obvious ? &a_ptr->oflags2 : &a_ptr->flags2;
- u32b *f3 = obvious ? &a_ptr->oflags3 : &a_ptr->flags3;
- u32b *f4 = obvious ? &a_ptr->oflags4 : &a_ptr->flags4;
- u32b *f5 = obvious ? &a_ptr->oflags5 : &a_ptr->flags5;
- u32b *esp = obvious ? &a_ptr->oesp : &a_ptr->esp;
-
- /* Lookup */
- if (lookup_flags(what,
- flag_tie(f1, k_info_flags1),
- flag_tie(f2, k_info_flags2),
- flag_tie(f2, k_info_flags2_trap),
- flag_tie(f3, k_info_flags3),
- flag_tie(f4, k_info_flags4),
- flag_tie(f5, k_info_flags5),
- flag_tie(esp, esp_flags)))
- {
- return 0;
- }
-
- /* Oops */
- msg_format("Unknown artifact flag '%s'.", what);
-
- /* Error */
- return (1);
-}
-
-
/*
@@ -3524,17 +3199,16 @@ errr init_a_info_txt(FILE *fp)
a_ptr->text = my_strdup("");
/* Ignore everything */
- a_ptr->flags3 |= (TR3_IGNORE_ACID);
- a_ptr->flags3 |= (TR3_IGNORE_ELEC);
- a_ptr->flags3 |= (TR3_IGNORE_FIRE);
- a_ptr->flags3 |= (TR3_IGNORE_COLD);
+ a_ptr->flags |= TR_IGNORE_ACID |
+ TR_IGNORE_ELEC |
+ TR_IGNORE_FIRE |
+ TR_IGNORE_COLD;
/* Needed hack */
- a_ptr->esp = 0;
a_ptr->power = -1;
/*Require activating artifacts to have a activation type */
- if (a_ptr && a_ptr->flags3 & TR3_ACTIVATE && !a_ptr->activate)
+ if (a_ptr && (a_ptr->flags & TR_ACTIVATE) && !a_ptr->activate)
{
msg_print("Activate flag without activate type");
return 1;
@@ -3654,7 +3328,10 @@ errr init_a_info_txt(FILE *fp)
/* Hack -- Process 'F' for flags */
if (buf[0] == 'F')
{
- if (0 != grab_one_artifact_flag(a_ptr, buf+2, FALSE)) return (5);
+ if (grab_object_flag(&a_ptr->flags, buf+2))
+ {
+ return (5);
+ }
/* Next... */
continue;
@@ -3663,7 +3340,10 @@ errr init_a_info_txt(FILE *fp)
/* Hack -- Process 'f' for obvious flags */
if (buf[0] == 'f')
{
- if (0 != grab_one_artifact_flag(a_ptr, buf+2, TRUE)) return (5);
+ if (grab_object_flag(&a_ptr->oflags, buf+2))
+ {
+ return (5);
+ }
/* Next... */
continue;
@@ -3759,26 +3439,6 @@ errr init_set_info_txt(FILE *fp)
assert(!set_ptr->name);
set_ptr->name = my_strdup(s);
- /* Initialize */
- set_ptr->num = 0;
- set_ptr->num_use = 0;
-
- for (std::size_t z = 0; z < SET_MAX_SIZE; z++)
- {
- set_ptr->arts[z].a_idx = 0;
- set_ptr->arts[z].present = FALSE;
- for (std::size_t y = 0; y < SET_MAX_SIZE; y++)
- {
- set_ptr->arts[z].flags1[y] = 0;
- set_ptr->arts[z].flags2[y] = 0;
- set_ptr->arts[z].flags3[y] = 0;
- set_ptr->arts[z].flags4[y] = 0;
- set_ptr->arts[z].flags5[y] = 0;
- set_ptr->arts[z].esp[y] = 0;
- set_ptr->arts[z].pval[y] = 0;
- }
- }
-
/* Next... */
continue;
}
@@ -3832,14 +3492,7 @@ errr init_set_info_txt(FILE *fp)
/* Process 'F' for flags */
if (buf[0] == 'F')
{
- /* Parse this entry */
- if (0 != grab_one_race_kind_flag(&set_ptr->arts[cur_art].flags1[cur_num],
- &set_ptr->arts[cur_art].flags2[cur_num],
- &set_ptr->arts[cur_art].flags3[cur_num],
- &set_ptr->arts[cur_art].flags4[cur_num],
- &set_ptr->arts[cur_art].flags5[cur_num],
- &set_ptr->arts[cur_art].esp[cur_num],
- buf + 2))
+ if (grab_object_flag(&set_ptr->arts[cur_art].flags[cur_num], buf + 2))
{
return (5);
}
@@ -4429,67 +4082,30 @@ errr init_ab_info_txt(FILE *fp)
/*
- * Grab one flag in a ego-item_type from a textual string
+ * Grab one flag in a ego-item_type from a textual string.
+ *
+ * We explicitly allow nullptr for the "ego" parameter.
*/
-static bool_ grab_one_ego_item_flag(ego_item_type *e_ptr, cptr what, int n, bool_ obvious)
+static bool_ grab_one_ego_item_flag(object_flag_set *flags, u32b *ego, cptr what)
{
- assert(n < FLAG_RARITY_MAX);
-
- /* Dispatch to correct set of flags */
- u32b *f1 = obvious ? &e_ptr->oflags1[n] : &e_ptr->flags1[n];
- u32b *f2 = obvious ? &e_ptr->oflags2[n] : &e_ptr->flags2[n];
- u32b *f3 = obvious ? &e_ptr->oflags3[n] : &e_ptr->flags3[n];
- u32b *f4 = obvious ? &e_ptr->oflags4[n] : &e_ptr->flags4[n];
- u32b *f5 = obvious ? &e_ptr->oflags5[n] : &e_ptr->flags5[n];
- u32b *esp = obvious ? &e_ptr->oesp[n] : &e_ptr->esp[n];
- u32b *ego = obvious ? &e_ptr->fego[n] : &e_ptr->fego[n];
-
- /* Lookup */
- if (lookup_flags(what,
- flag_tie(f1, k_info_flags1),
- flag_tie(f2, k_info_flags2),
- flag_tie(f2, k_info_flags2_trap),
- flag_tie(f3, k_info_flags3),
- flag_tie(f4, k_info_flags4),
- flag_tie(f5, k_info_flags5),
- flag_tie(esp, esp_flags),
- flag_tie(ego, ego_flags)))
+ /* Lookup as an object_flag */
+ if (auto f = object_flag_set_from_string(what))
{
- return (0);
+ *flags |= f;
+ return 0;
}
- /* Oops */
- msg_format("Unknown ego-item flag '%s'.", what);
-
- /* Error */
- return (1);
-}
-
-static bool_ grab_one_ego_item_flag_restrict(ego_item_type *e_ptr, cptr what, bool_ need)
-{
- /* Dispatch to correct set of flags */
- u32b *f1 = need ? &e_ptr->need_flags1 : &e_ptr->forbid_flags1;
- u32b *f2 = need ? &e_ptr->need_flags2 : &e_ptr->forbid_flags2;
- u32b *f3 = need ? &e_ptr->need_flags3 : &e_ptr->forbid_flags3;
- u32b *f4 = need ? &e_ptr->need_flags4 : &e_ptr->forbid_flags4;
- u32b *f5 = need ? &e_ptr->need_flags5 : &e_ptr->forbid_flags5;
- u32b *esp = need ? &e_ptr->need_esp : &e_ptr->forbid_esp;
-
- /* Lookup */
- if (lookup_flags(what,
- flag_tie(f1, k_info_flags1),
- flag_tie(f2, k_info_flags2),
- flag_tie(f2, k_info_flags2_trap),
- flag_tie(f3, k_info_flags3),
- flag_tie(f4, k_info_flags4),
- flag_tie(f5, k_info_flags5),
- flag_tie(esp, esp_flags)))
+ /* Lookup as ego flag */
+ if (ego)
{
- return 0;
+ if (lookup_flags(what, flag_tie(ego, ego_flags)))
+ {
+ return (0);
+ }
}
/* Oops */
- msg_format("Unknown ego-item restrict flag '%s'.", what);
+ msg_format("Unknown ego-item flag '%s'.", what);
/* Error */
return (1);
@@ -4497,13 +4113,12 @@ static bool_ grab_one_ego_item_flag_restrict(ego_item_type *e_ptr, cptr what, bo
-
/*
* Initialize the "e_info" array, by parsing an ascii "template" file
*/
errr init_e_info_txt(FILE *fp)
{
- int i, cur_r = -1, cur_t = 0, j;
+ int i, cur_r = -1, cur_t = 0;
char buf[1024];
char *s, *t;
@@ -4557,6 +4172,10 @@ errr init_e_info_txt(FILE *fp)
/* Save the index */
error_idx = i;
+ /* Reset cur_* variables */
+ cur_r = -1;
+ cur_t = 0;
+
/* Point at the "info" */
e_ptr = &e_info[i];
@@ -4564,33 +4183,6 @@ errr init_e_info_txt(FILE *fp)
assert(!e_ptr->name);
e_ptr->name = my_strdup(s);
- /* Needed hack */
- e_ptr->power = -1;
- cur_r = -1;
- cur_t = 0;
-
- for (j = 0; j < 10; j++)
- {
- e_ptr->tval[j] = 255;
- }
- for (j = 0; j < FLAG_RARITY_MAX; j++)
- {
- e_ptr->rar[j] = 0;
- e_ptr->flags1[j] = 0;
- e_ptr->flags2[j] = 0;
- e_ptr->flags3[j] = 0;
- e_ptr->flags4[j] = 0;
- e_ptr->flags5[j] = 0;
- e_ptr->esp[j] = 0;
- e_ptr->oflags1[j] = 0;
- e_ptr->oflags2[j] = 0;
- e_ptr->oflags3[j] = 0;
- e_ptr->oflags4[j] = 0;
- e_ptr->oflags5[j] = 0;
- e_ptr->oesp[j] = 0;
- e_ptr->fego[j] = 0;
- }
-
/* Next... */
continue;
}
@@ -4751,7 +4343,10 @@ errr init_e_info_txt(FILE *fp)
}
/* Parse this entry */
- if (0 != grab_one_ego_item_flag_restrict(e_ptr, s, TRUE)) return (5);
+ if (grab_object_flag(&e_ptr->need_flags, s))
+ {
+ return (5);
+ }
/* Start the next entry */
s = t;
@@ -4764,7 +4359,7 @@ errr init_e_info_txt(FILE *fp)
/* Hack -- Process 'r:F' for forbidden flags */
if ((buf[0] == 'r') && (buf[2] == 'F'))
{
- if (0 != grab_one_ego_item_flag_restrict(e_ptr, buf + 4, FALSE))
+ if (grab_object_flag(&e_ptr->forbid_flags, buf + 4))
{
return (5);
}
@@ -4792,7 +4387,14 @@ errr init_e_info_txt(FILE *fp)
}
/* Parse this entry */
- if (0 != grab_one_ego_item_flag(e_ptr, s, cur_r, FALSE)) return (5);
+ assert(cur_r < FLAG_RARITY_MAX);
+ if (0 != grab_one_ego_item_flag(
+ &e_ptr->flags[cur_r],
+ &e_ptr->fego[cur_r],
+ s))
+ {
+ return (5);
+ }
/* Start the next entry */
s = t;
@@ -4821,7 +4423,14 @@ errr init_e_info_txt(FILE *fp)
}
/* Parse this entry */
- if (0 != grab_one_ego_item_flag(e_ptr, s, cur_r, TRUE)) return (5);
+ assert(cur_r < FLAG_RARITY_MAX);
+ if (0 != grab_one_ego_item_flag(
+ &e_ptr->oflags[cur_r],
+ nullptr,
+ s))
+ {
+ return (5);
+ }
/* Start the next entry */
s = t;
@@ -4839,51 +4448,6 @@ errr init_e_info_txt(FILE *fp)
return (0);
}
-/*
- * Grab one flag in a randart_part_type from a textual string
- */
-static bool_ grab_one_randart_item_flag(randart_part_type *ra_ptr, cptr what, char c)
-{
- bool regular = (c == 'F');
-
- /* Dispatch to correct set of flags */
- u32b *f1 = regular ? &ra_ptr->flags1 : &ra_ptr->aflags1;
- u32b *f2 = regular ? &ra_ptr->flags2 : &ra_ptr->aflags2;
- u32b *f3 = regular ? &ra_ptr->flags3 : &ra_ptr->aflags3;
- u32b *f4 = regular ? &ra_ptr->flags4 : &ra_ptr->aflags4;
- u32b *f5 = regular ? &ra_ptr->flags5 : &ra_ptr->aflags5;
- u32b *esp = regular ? &ra_ptr->esp : &ra_ptr->aesp;
-
- /* Check flags */
- if (lookup_flags(what,
- flag_tie(f1, k_info_flags1),
- flag_tie(f2, k_info_flags2),
- flag_tie(f2, k_info_flags2_trap),
- flag_tie(f3, k_info_flags3),
- flag_tie(f4, k_info_flags4),
- flag_tie(f5, k_info_flags5),
- flag_tie(esp, esp_flags)))
- {
- return 0;
- }
-
- /* Check ego_flags */
- if (regular)
- {
- if (lookup_flags(what, flag_tie(&ra_ptr->fego, ego_flags)))
- {
- return 0;
- }
- }
-
- /* Oops */
- msg_format("Unknown ego-item flag '%s'.", what);
-
- /* Error */
- return (1);
-}
-
-
/*
@@ -4964,12 +4528,7 @@ errr init_ra_info_txt(FILE *fp)
{
ra_ptr->tval[j] = 255;
}
- ra_ptr->flags1 = 0;
- ra_ptr->flags2 = 0;
- ra_ptr->flags3 = 0;
- ra_ptr->flags4 = 0;
- ra_ptr->flags5 = 0;
- ra_ptr->esp = 0;
+ ra_ptr->flags = object_flag_set();
ra_ptr->fego = 0;
/* Next... */
@@ -5076,10 +4635,13 @@ errr init_ra_info_txt(FILE *fp)
continue;
}
- /* Hack -- Process 'F' for flags */
+ /* Process 'F' for flags */
if (buf[0] == 'F')
{
- if (0 != grab_one_randart_item_flag(ra_ptr, buf + 2, 'F'))
+ if (0 != grab_one_ego_item_flag(
+ &ra_ptr->flags,
+ &ra_ptr->fego,
+ buf + 2))
{
return (5);
}
@@ -5088,10 +4650,13 @@ errr init_ra_info_txt(FILE *fp)
continue;
}
- /* Hack -- Process 'A' for antagonic flags */
+ /* Process 'A' for antagonic flags */
if (buf[0] == 'A')
{
- if (0 != grab_one_randart_item_flag(ra_ptr, buf + 2, 'A'))
+ if (0 != grab_one_ego_item_flag(
+ &ra_ptr->aflags,
+ nullptr,
+ buf + 2))
{
return (5);
}
@@ -7659,10 +7224,11 @@ static errr process_dungeon_file_aux(char *buf, int *yval, int *xval, int xvalst
Let's just HACK around one observed bug: Shadow Cloak
of Luthien [Globe of Light] */
{
- u32b f1, f2, f3, f4, f5, esp;
- object_flags(q_ptr, &f1, &f2, &f3, &f4, &f5, &esp);
- if (f5 & TR5_SPELL_CONTAIN)
+ auto const flags = object_flags(q_ptr);
+ if (flags & TR_SPELL_CONTAIN)
+ {
q_ptr->pval2 = -1;
+ }
}
/* Drop the artifact */
diff --git a/src/init2.cc b/src/init2.cc
index a539a470..678a018c 100644
--- a/src/init2.cc
+++ b/src/init2.cc
@@ -25,6 +25,7 @@
#include "monster_race.hpp"
#include "monster_race_flag.hpp"
#include "monster_type.hpp"
+#include "object_flag.hpp"
#include "object_kind.hpp"
#include "object_type.hpp"
#include "owner_type.hpp"
@@ -390,7 +391,7 @@ namespace {
static void allocate()
{
- ra_info = make_array<randart_part_type>(max_ra_idx);
+ ra_info = new randart_part_type[max_ra_idx];
}
static errr parse(FILE *fp)
@@ -1110,16 +1111,14 @@ static void init_guardians(void)
if (d_ptr->final_artifact)
{
artifact_type *a_ptr = &a_info[d_ptr->final_artifact];
-
- a_ptr->flags4 |= TR4_SPECIAL_GENE;
+ a_ptr->flags |= TR_SPECIAL_GENE;
}
/* Mark the final object */
if (d_ptr->final_object)
{
object_kind *k_ptr = &k_info[d_ptr->final_object];
-
- k_ptr->flags4 |= TR4_SPECIAL_GENE;
+ k_ptr->flags |= TR_SPECIAL_GENE;
}
/* Give randart if there are no final artifacts */
diff --git a/src/loadsave.cc b/src/loadsave.cc
index 3be0c39f..93f2679c 100644
--- a/src/loadsave.cc
+++ b/src/loadsave.cc
@@ -358,12 +358,7 @@ static void do_subrace(ls_flag_t flag)
for (i = 0; i < PY_MAX_LEVEL + 1; i++)
{
- do_u32b(&sr_ptr->oflags1[i], flag);
- do_u32b(&sr_ptr->oflags2[i], flag);
- do_u32b(&sr_ptr->oflags3[i], flag);
- do_u32b(&sr_ptr->oflags4[i], flag);
- do_u32b(&sr_ptr->oflags5[i], flag);
- do_u32b(&sr_ptr->oesp[i], flag);
+ do_flag_set(&sr_ptr->oflags[i], flag);
do_s16b(&sr_ptr->opval[i], flag);
}
@@ -1043,10 +1038,6 @@ static void do_item(object_type *o_ptr, ls_flag_t flag)
byte old_dd;
byte old_ds;
- u32b f1, f2, f3, f4, f5, esp;
-
- object_kind *k_ptr;
-
/* Kind */
do_s16b(&o_ptr->k_idx, flag);
@@ -1099,20 +1090,10 @@ static void do_item(object_type *o_ptr, ls_flag_t flag)
do_byte(&o_ptr->marked, flag);
/* flags */
- do_u32b(&o_ptr->art_flags1, flag);
- do_u32b(&o_ptr->art_flags2, flag);
- do_u32b(&o_ptr->art_flags3, flag);
- do_u32b(&o_ptr->art_flags4, flag);
- do_u32b(&o_ptr->art_flags5, flag);
- do_u32b(&o_ptr->art_esp, flag);
+ do_flag_set(&o_ptr->art_flags, flag);
/* obvious flags */
- do_u32b(&o_ptr->art_oflags1, flag);
- do_u32b(&o_ptr->art_oflags2, flag);
- do_u32b(&o_ptr->art_oflags3, flag);
- do_u32b(&o_ptr->art_oflags4, flag);
- do_u32b(&o_ptr->art_oflags5, flag);
- do_u32b(&o_ptr->art_oesp, flag);
+ do_flag_set(&o_ptr->art_oflags, flag);
/* Monster holding object */
do_s16b(&o_ptr->held_m_idx, flag);
@@ -1177,7 +1158,7 @@ static void do_item(object_type *o_ptr, ls_flag_t flag)
/*********** END OF ls_flag_t::SAVE ***************/
/* Obtain the "kind" template */
- k_ptr = &k_info[o_ptr->k_idx];
+ object_kind *k_ptr = &k_info[o_ptr->k_idx];
/* Obtain tval/sval from k_info */
o_ptr->tval = k_ptr->tval;
@@ -1202,9 +1183,6 @@ static void do_item(object_type *o_ptr, ls_flag_t flag)
}
- /* Extract the flags */
- object_flags(o_ptr, &f1, &f2, &f3, &f4, &f5, &esp);
-
/* Paranoia */
if (o_ptr->name1)
{
diff --git a/src/melee2.cc b/src/melee2.cc
index 9d09fb67..f52c7061 100644
--- a/src/melee2.cc
+++ b/src/melee2.cc
@@ -34,6 +34,7 @@
#include "monster_type.hpp"
#include "object1.hpp"
#include "object2.hpp"
+#include "object_flag.hpp"
#include "options.hpp"
#include "player_type.hpp"
#include "quark.hpp"
@@ -2571,7 +2572,6 @@ static bool_ monst_spell_monst(int m_idx)
void curse_equipment(int chance, int heavy_chance)
{
bool_ changed = FALSE;
- u32b o1, o2, o3, o4, esp, o5;
object_type * o_ptr =
&p_ptr->inventory[rand_range(INVEN_WIELD, INVEN_TOTAL - 1)];
@@ -2579,11 +2579,11 @@ void curse_equipment(int chance, int heavy_chance)
if (!(o_ptr->k_idx)) return;
- object_flags(o_ptr, &o1, &o2, &o3, &o4, &o5, &esp);
+ auto const flags = object_flags(o_ptr);
/* Extra, biased saving throw for blessed items */
- if ((o3 & (TR3_BLESSED)) && (randint(888) > chance))
+ if ((flags & TR_BLESSED) && (randint(888) > chance))
{
char o_name[256];
object_desc(o_name, o_ptr, FALSE, 0);
@@ -2596,17 +2596,17 @@ void curse_equipment(int chance, int heavy_chance)
if ((randint(100) <= heavy_chance) &&
(o_ptr->name1 || o_ptr->name2 || o_ptr->art_name))
{
- if (!(o3 & TR3_HEAVY_CURSE))
+ if (!(flags & TR_HEAVY_CURSE))
changed = TRUE;
- o_ptr->art_flags3 |= TR3_HEAVY_CURSE;
- o_ptr->art_flags3 |= TR3_CURSED;
+ o_ptr->art_flags |= TR_HEAVY_CURSE;
+ o_ptr->art_flags |= TR_CURSED;
o_ptr->ident |= IDENT_CURSED;
}
else
{
- if (!(o_ptr->ident & (IDENT_CURSED)))
+ if (!(o_ptr->ident & IDENT_CURSED))
changed = TRUE;
- o_ptr->art_flags3 |= TR3_CURSED;
+ o_ptr->art_flags |= TR_CURSED;
o_ptr->ident |= IDENT_CURSED;
}
@@ -2627,7 +2627,7 @@ void curse_equipment(int chance, int heavy_chance)
void curse_equipment_dg(int chance, int heavy_chance)
{
bool_ changed = FALSE;
- u32b o1, o2, o3, o4, esp, o5;
+
object_type * o_ptr =
&p_ptr->inventory[rand_range(INVEN_WIELD, INVEN_TOTAL - 1)];
@@ -2635,37 +2635,35 @@ void curse_equipment_dg(int chance, int heavy_chance)
if (!(o_ptr->k_idx)) return;
- object_flags(o_ptr, &o1, &o2, &o3, &o4, &o5, &esp);
+ auto const flags = object_flags(o_ptr);
/* Extra, biased saving throw for blessed items */
- if ((o3 & (TR3_BLESSED)) && (randint(888) > chance))
+ if ((flags & TR_BLESSED) && (randint(888) > chance))
{
char o_name[256];
object_desc(o_name, o_ptr, FALSE, 0);
msg_format("Your %s resist%s cursing!", o_name,
((o_ptr->number > 1) ? "" : "s"));
- /* Hmmm -- can we wear multiple items? If not, this is unnecessary */
- /* DG -- Yes we can, in the quiver */
return;
}
if ((randint(100) <= heavy_chance) &&
(o_ptr->name1 || o_ptr->name2 || o_ptr->art_name))
{
- if (!(o3 & TR3_HEAVY_CURSE))
+ if (!(flags & TR_HEAVY_CURSE))
changed = TRUE;
- o_ptr->art_flags3 |= TR3_HEAVY_CURSE;
- o_ptr->art_flags3 |= TR3_CURSED;
- o_ptr->art_flags4 |= TR4_DG_CURSE;
+ o_ptr->art_flags |= TR_HEAVY_CURSE;
+ o_ptr->art_flags |= TR_CURSED;
+ o_ptr->art_flags |= TR_DG_CURSE;
o_ptr->ident |= IDENT_CURSED;
}
else
{
- if (!(o_ptr->ident & (IDENT_CURSED)))
+ if (!(o_ptr->ident & IDENT_CURSED))
changed = TRUE;
- o_ptr->art_flags3 |= TR3_CURSED;
- o_ptr->art_flags4 |= TR4_DG_CURSE;
+ o_ptr->art_flags |= TR_CURSED;
+ o_ptr->art_flags |= TR_DG_CURSE;
o_ptr->ident |= IDENT_CURSED;
}
@@ -6584,13 +6582,11 @@ static void process_monster(int m_idx, bool_ is_frien)
(r_ptr->flags & RF_KILL_ITEM)) &&
(is_friend(m_ptr) <= 0))
{
- u32b f1, f2, f3, f4, f5, esp;
-
char m_name[80];
char o_name[80];
/* Extract some flags */
- object_flags(o_ptr, &f1, &f2, &f3, &f4, &f5, &esp);
+ auto const flags = object_flags(o_ptr);
/* Acquire the object name */
object_desc(o_name, o_ptr, TRUE, 3);
@@ -6600,16 +6596,16 @@ static void process_monster(int m_idx, bool_ is_frien)
/* React to objects that hurt the monster */
monster_race_flag_set flg;
- if (f5 & (TR5_KILL_DEMON)) flg |= RF_DEMON;
- if (f5 & (TR5_KILL_UNDEAD)) flg |= RF_UNDEAD;
- if (f1 & (TR1_SLAY_DRAGON)) flg |= RF_DRAGON;
- if (f1 & (TR1_SLAY_TROLL)) flg |= RF_TROLL;
- if (f1 & (TR1_SLAY_GIANT)) flg |= RF_GIANT;
- if (f1 & (TR1_SLAY_ORC)) flg |= RF_ORC;
- if (f1 & (TR1_SLAY_DEMON)) flg |= RF_DEMON;
- if (f1 & (TR1_SLAY_UNDEAD)) flg |= RF_UNDEAD;
- if (f1 & (TR1_SLAY_ANIMAL)) flg |= RF_ANIMAL;
- if (f1 & (TR1_SLAY_EVIL)) flg |= RF_EVIL;
+ if (flags & TR_KILL_DEMON) flg |= RF_DEMON;
+ if (flags & TR_KILL_UNDEAD) flg |= RF_UNDEAD;
+ if (flags & TR_SLAY_DRAGON) flg |= RF_DRAGON;
+ if (flags & TR_SLAY_TROLL) flg |= RF_TROLL;
+ if (flags & TR_SLAY_GIANT) flg |= RF_GIANT;
+ if (flags & TR_SLAY_ORC) flg |= RF_ORC;
+ if (flags & TR_SLAY_DEMON) flg |= RF_DEMON;
+ if (flags & TR_SLAY_UNDEAD) flg |= RF_UNDEAD;
+ if (flags & TR_SLAY_ANIMAL) flg |= RF_ANIMAL;
+ if (flags & TR_SLAY_EVIL) flg |= RF_EVIL;
/* The object cannot be picked up by the monster */
if (artifact_p(o_ptr) || (r_ptr->flags & flg) ||
diff --git a/src/mimic.cc b/src/mimic.cc
index 55622a41..c540c732 100644
--- a/src/mimic.cc
+++ b/src/mimic.cc
@@ -1,5 +1,6 @@
#include "mimic.hpp"
+#include "object_flag.hpp"
#include "player_type.hpp"
#include "skill_type.hpp"
#include "stats.hpp"
@@ -37,8 +38,8 @@ struct mimic_form_type
static s32b abomination_calc()
{
- apply_flags(TR1_SPEED + TR1_STR + TR1_INT + TR1_WIS + TR1_DEX + TR1_CON + TR1_CHR, 0, 0, 0, 0, 0, -10, 0, 0, 0, 0);
- p_ptr->xtra_f3 |= TR3_AGGRAVATE;
+ apply_flags(TR_SPEED | TR_STR | TR_INT | TR_WIS | TR_DEX | TR_CON | TR_CHR, -10, 0, 0, 0, 0);
+ p_ptr->xtra_flags |= TR_AGGRAVATE;
return 0;
}
@@ -89,23 +90,23 @@ static s32b eagle_calc()
if (p_ptr->mimic_level >= 20)
{
- p_ptr->xtra_f4 |= TR4_FLY;
- p_ptr->xtra_f3 |= TR3_SEE_INVIS;
+ p_ptr->xtra_flags |= TR_FLY;
+ p_ptr->xtra_flags |= TR_SEE_INVIS;
}
if (p_ptr->mimic_level >= 25)
{
- p_ptr->xtra_f2 |= TR2_FREE_ACT;
+ p_ptr->xtra_flags |= TR_FREE_ACT;
}
if (p_ptr->mimic_level >= 30)
{
- p_ptr->xtra_f2 |= TR2_RES_ELEC;
+ p_ptr->xtra_flags |= TR_RES_ELEC;
}
if (p_ptr->mimic_level >= 35)
{
- p_ptr->xtra_f3 |= TR3_SH_ELEC;
+ p_ptr->xtra_flags |= TR_SH_ELEC;
}
return 0;
@@ -120,27 +121,27 @@ static s32b wolf_calc()
p_ptr->pspeed = p_ptr->pspeed + 10 + (p_ptr->mimic_level / 5);
- p_ptr->xtra_f2 |= TR2_FREE_ACT;
- p_ptr->xtra_f2 |= TR2_RES_FEAR;
+ p_ptr->xtra_flags |= TR_FREE_ACT;
+ p_ptr->xtra_flags |= TR_RES_FEAR;
if (p_ptr->mimic_level >= 10)
{
- p_ptr->xtra_f2 |= TR2_RES_COLD;
+ p_ptr->xtra_flags |= TR_RES_COLD;
}
if (p_ptr->mimic_level >= 15)
{
- p_ptr->xtra_f3 |= TR3_SEE_INVIS;
+ p_ptr->xtra_flags |= TR_SEE_INVIS;
}
if (p_ptr->mimic_level >= 30)
{
- p_ptr->xtra_f2 |= TR2_RES_DARK;
+ p_ptr->xtra_flags |= TR_RES_DARK;
}
if (p_ptr->mimic_level >= 35)
{
- p_ptr->xtra_f2 |= TR2_RES_CONF;
+ p_ptr->xtra_flags |= TR_RES_CONF;
}
return 0;
@@ -157,13 +158,13 @@ static s32b spider_calc()
p_ptr->pspeed = p_ptr->pspeed + 5;
- p_ptr->xtra_f2 |= TR2_RES_POIS;
- p_ptr->xtra_f2 |= TR2_RES_FEAR;
- p_ptr->xtra_f2 |= TR2_RES_DARK;
+ p_ptr->xtra_flags |= TR_RES_POIS;
+ p_ptr->xtra_flags |= TR_RES_FEAR;
+ p_ptr->xtra_flags |= TR_RES_DARK;
if (p_ptr->mimic_level >= 40)
{
- p_ptr->xtra_f4 |= TR4_CLIMB;
+ p_ptr->xtra_flags |= TR_CLIMB;
}
return 0;
@@ -191,12 +192,12 @@ static s32b ent_calc()
p_ptr->stat_add[A_CON] += p_ptr->mimic_level / 5;
p_ptr->stat_add[A_CHR] += -7;
- p_ptr->xtra_f2 |= TR2_RES_POIS;
- p_ptr->xtra_f2 |= TR2_RES_COLD;
- p_ptr->xtra_f2 |= TR2_FREE_ACT;
- p_ptr->xtra_f3 |= TR3_REGEN;
- p_ptr->xtra_f3 |= TR3_SEE_INVIS;
- p_ptr->xtra_f2 |= TR2_SENS_FIRE;
+ p_ptr->xtra_flags |= TR_RES_POIS;
+ p_ptr->xtra_flags |= TR_RES_COLD;
+ p_ptr->xtra_flags |= TR_FREE_ACT;
+ p_ptr->xtra_flags |= TR_REGEN;
+ p_ptr->xtra_flags |= TR_SEE_INVIS;
+ p_ptr->xtra_flags |= TR_SENS_FIRE;
return 0;
}
@@ -226,14 +227,14 @@ static s32b vapour_calc()
/* But they are stealthy */
p_ptr->skill_stl = p_ptr->skill_stl + 10 + (p_ptr->mimic_level / 5);
- p_ptr->xtra_f2 |= TR2_RES_POIS;
- p_ptr->xtra_f2 |= TR2_RES_SHARDS;
- p_ptr->xtra_f2 |= TR2_IM_COLD;
- p_ptr->xtra_f2 |= TR2_FREE_ACT;
- p_ptr->xtra_f3 |= TR3_REGEN;
- p_ptr->xtra_f3 |= TR3_SEE_INVIS;
- p_ptr->xtra_f2 |= TR2_SENS_FIRE;
- p_ptr->xtra_f3 |= TR3_FEATHER;
+ p_ptr->xtra_flags |= TR_RES_POIS;
+ p_ptr->xtra_flags |= TR_RES_SHARDS;
+ p_ptr->xtra_flags |= TR_IM_COLD;
+ p_ptr->xtra_flags |= TR_FREE_ACT;
+ p_ptr->xtra_flags |= TR_REGEN;
+ p_ptr->xtra_flags |= TR_SEE_INVIS;
+ p_ptr->xtra_flags |= TR_SENS_FIRE;
+ p_ptr->xtra_flags |= TR_FEATHER;
return 0;
}
@@ -252,10 +253,10 @@ static s32b serpent_calc()
p_ptr->stat_add[A_CON] += p_ptr->mimic_level / 7;
p_ptr->stat_add[A_CHR] += -6;
- p_ptr->xtra_f2 |= TR2_RES_POIS;
+ p_ptr->xtra_flags |= TR_RES_POIS;
if (p_ptr->mimic_level >= 25)
{
- p_ptr->xtra_f2 |= TR2_FREE_ACT;
+ p_ptr->xtra_flags |= TR_FREE_ACT;
}
return 0;
@@ -279,22 +280,22 @@ static s32b mumak_calc()
if (p_ptr->mimic_level >= 10)
{
- p_ptr->xtra_f2 |= TR2_RES_FEAR;
+ p_ptr->xtra_flags |= TR_RES_FEAR;
}
if (p_ptr->mimic_level >= 25)
{
- p_ptr->xtra_f2 |= TR2_RES_CONF;
+ p_ptr->xtra_flags |= TR_RES_CONF;
}
if (p_ptr->mimic_level >= 30)
{
- p_ptr->xtra_f2 |= TR2_FREE_ACT;
+ p_ptr->xtra_flags |= TR_FREE_ACT;
}
if (p_ptr->mimic_level >= 35)
{
- p_ptr->xtra_f2 |= TR2_RES_NEXUS;
+ p_ptr->xtra_flags |= TR_RES_NEXUS;
}
return 0;
@@ -316,22 +317,22 @@ static s32b bear_calc()
if (p_ptr->mimic_level >= 10)
{
- p_ptr->xtra_f2 |= TR2_FREE_ACT;
+ p_ptr->xtra_flags |= TR_FREE_ACT;
}
if (p_ptr->mimic_level >= 20)
{
- p_ptr->xtra_f3 |= TR3_REGEN;
+ p_ptr->xtra_flags |= TR_REGEN;
}
if (p_ptr->mimic_level >= 30)
{
- p_ptr->xtra_f2 |= TR2_RES_CONF;
+ p_ptr->xtra_flags |= TR_RES_CONF;
}
if (p_ptr->mimic_level >= 35)
{
- p_ptr->xtra_f2 |= TR2_RES_NEXUS;
+ p_ptr->xtra_flags |= TR_RES_NEXUS;
}
/* activate the skill */
@@ -349,17 +350,17 @@ static s32b balrog_calc()
p_ptr->stat_add[A_CON] += 5 + p_ptr->mimic_level / 5;
p_ptr->stat_add[A_CHR] += - ( 5 + p_ptr->mimic_level / 10);
- p_ptr->xtra_f2 |= TR2_IM_ACID;
- p_ptr->xtra_f2 |= TR2_IM_FIRE;
- p_ptr->xtra_f2 |= TR2_IM_ELEC;
- p_ptr->xtra_f2 |= TR2_RES_DARK;
- p_ptr->xtra_f2 |= TR2_RES_CHAOS;
- p_ptr->xtra_f2 |= TR2_RES_POIS;
- p_ptr->xtra_f2 |= TR2_HOLD_LIFE;
- p_ptr->xtra_f3 |= TR3_FEATHER;
- p_ptr->xtra_f3 |= TR3_REGEN;
- p_ptr->xtra_f3 |= TR3_SH_FIRE;
- p_ptr->xtra_f3 |= TR3_LITE1;
+ p_ptr->xtra_flags |= TR_IM_ACID;
+ p_ptr->xtra_flags |= TR_IM_FIRE;
+ p_ptr->xtra_flags |= TR_IM_ELEC;
+ p_ptr->xtra_flags |= TR_RES_DARK;
+ p_ptr->xtra_flags |= TR_RES_CHAOS;
+ p_ptr->xtra_flags |= TR_RES_POIS;
+ p_ptr->xtra_flags |= TR_HOLD_LIFE;
+ p_ptr->xtra_flags |= TR_FEATHER;
+ p_ptr->xtra_flags |= TR_REGEN;
+ p_ptr->xtra_flags |= TR_SH_FIRE;
+ p_ptr->xtra_flags |= TR_LITE1;
return 1; /* Adds a blow */
}
@@ -373,17 +374,17 @@ static s32b maia_calc()
p_ptr->stat_add[A_CON] += 5 + p_ptr->mimic_level / 5;
p_ptr->stat_add[A_CHR] += 5 + p_ptr->mimic_level / 5;
- p_ptr->xtra_f2 |= TR2_IM_FIRE;
- p_ptr->xtra_f2 |= TR2_IM_ELEC;
- p_ptr->xtra_f2 |= TR2_IM_ACID;
- p_ptr->xtra_f2 |= TR2_IM_COLD;
- p_ptr->xtra_f2 |= TR2_RES_POIS;
- p_ptr->xtra_f2 |= TR2_RES_LITE;
- p_ptr->xtra_f2 |= TR2_RES_DARK;
- p_ptr->xtra_f2 |= TR2_RES_CHAOS;
- p_ptr->xtra_f2 |= TR2_HOLD_LIFE;
- p_ptr->xtra_f3 |= TR3_FEATHER;
- p_ptr->xtra_f3 |= TR3_REGEN;
+ p_ptr->xtra_flags |= TR_IM_FIRE;
+ p_ptr->xtra_flags |= TR_IM_ELEC;
+ p_ptr->xtra_flags |= TR_IM_ACID;
+ p_ptr->xtra_flags |= TR_IM_COLD;
+ p_ptr->xtra_flags |= TR_RES_POIS;
+ p_ptr->xtra_flags |= TR_RES_LITE;
+ p_ptr->xtra_flags |= TR_RES_DARK;
+ p_ptr->xtra_flags |= TR_RES_CHAOS;
+ p_ptr->xtra_flags |= TR_HOLD_LIFE;
+ p_ptr->xtra_flags |= TR_FEATHER;
+ p_ptr->xtra_flags |= TR_REGEN;
return 2; /* Add two blows */
}
@@ -394,10 +395,10 @@ static s32b fire_elemental_calc()
p_ptr->stat_add[A_DEX] += 5 + (p_ptr->mimic_level / 5);
p_ptr->stat_add[A_WIS] += -5 - (p_ptr->mimic_level / 5);
- p_ptr->xtra_f2 |= TR2_IM_FIRE;
- p_ptr->xtra_f2 |= TR2_RES_POIS;
- p_ptr->xtra_f3 |= TR3_SH_FIRE;
- p_ptr->xtra_f3 |= TR3_LITE1;
+ p_ptr->xtra_flags |= TR_IM_FIRE;
+ p_ptr->xtra_flags |= TR_RES_POIS;
+ p_ptr->xtra_flags |= TR_SH_FIRE;
+ p_ptr->xtra_flags |= TR_LITE1;
return 0;
}
diff --git a/src/monoid.hpp b/src/monoid.hpp
new file mode 100644
index 00000000..465e58af
--- /dev/null
+++ b/src/monoid.hpp
@@ -0,0 +1,37 @@
+#pragma once
+
+#include <numeric>
+#include <vector>
+
+/**
+ * A monoid is an algebraic structure with a single associative
+ * binary operation ('append') and an identity element ('empty').
+ *
+ * See https://en.wikipedia.org/wiki/Monoid
+ *
+ * Shamelessly adapted from:
+ *
+ * https://gist.github.com/evincarofautumn/2b5f004ca81e33c62ff0
+ */
+template<typename T, T append_(T const&, T const&), const T &empty_>
+struct monoid {
+ /* Access the type the monoid operates on */
+ typedef T type;
+
+ /* Append two T's */
+ static T append(T const& a, T const& b) {
+ return append_(a, b);
+ }
+
+ /* The value of an empty T */
+ static constexpr T empty = empty_;
+};
+
+/**
+ * mconcat :: (Monoid m mappend) -> [m] -> m
+ * mconcat = fold mappend mempty
+ */
+template<typename M>
+typename M::type mconcat(const std::vector<typename M::type>& xs) {
+ return std::accumulate(std::begin(xs), std::end(xs), M::empty, M::append);
+}
diff --git a/src/monster2.cc b/src/monster2.cc
index b1419b0a..e5957770 100644
--- a/src/monster2.cc
+++ b/src/monster2.cc
@@ -27,6 +27,7 @@
#include "monster_type.hpp"
#include "object1.hpp"
#include "object2.hpp"
+#include "object_flag.hpp"
#include "object_kind.hpp"
#include "object_type.hpp"
#include "options.hpp"
@@ -484,7 +485,7 @@ void delete_monster_idx(int i)
{
random_artifacts[o_ptr->sval].generated = FALSE;
}
- else if (k_info[o_ptr->k_idx].flags3 & TR3_NORM_ART)
+ else if (k_info[o_ptr->k_idx].flags & TR_NORM_ART)
{
k_info[o_ptr->k_idx].artifact = FALSE;
}
@@ -1670,26 +1671,25 @@ void update_mon(int m_idx, bool_ full)
}
/* Telepathy can see all "nearby" monsters with "minds" */
- if (p_ptr->telepathy)
{
/* Assume we cant see */
- bool_ can_esp = FALSE;
+ bool can_esp = false;
/* Different ESP */
- if ((p_ptr->telepathy & ESP_ORC) && (r_ptr->flags & RF_ORC)) can_esp = TRUE;
- if ((p_ptr->telepathy & ESP_SPIDER) && (r_ptr->flags & RF_SPIDER)) can_esp = TRUE;
- if ((p_ptr->telepathy & ESP_TROLL) && (r_ptr->flags & RF_TROLL)) can_esp = TRUE;
- if ((p_ptr->telepathy & ESP_DRAGON) && (r_ptr->flags & RF_DRAGON)) can_esp = TRUE;
- if ((p_ptr->telepathy & ESP_GIANT) && (r_ptr->flags & RF_GIANT)) can_esp = TRUE;
- if ((p_ptr->telepathy & ESP_DEMON) && (r_ptr->flags & RF_DEMON)) can_esp = TRUE;
- if ((p_ptr->telepathy & ESP_UNDEAD) && (r_ptr->flags & RF_UNDEAD)) can_esp = TRUE;
- if ((p_ptr->telepathy & ESP_EVIL) && (r_ptr->flags & RF_EVIL)) can_esp = TRUE;
- if ((p_ptr->telepathy & ESP_ANIMAL) && (r_ptr->flags & RF_ANIMAL)) can_esp = TRUE;
- if ((p_ptr->telepathy & ESP_THUNDERLORD) && (r_ptr->flags & RF_THUNDERLORD)) can_esp = TRUE;
- if ((p_ptr->telepathy & ESP_GOOD) && (r_ptr->flags & RF_GOOD)) can_esp = TRUE;
- if ((p_ptr->telepathy & ESP_NONLIVING) && (r_ptr->flags & RF_NONLIVING)) can_esp = TRUE;
- if ((p_ptr->telepathy & ESP_UNIQUE) && ((r_ptr->flags & RF_UNIQUE) || (r_ptr->flags & RF_UNIQUE_4))) can_esp = TRUE;
- if (p_ptr->telepathy & ESP_ALL) can_esp = TRUE;
+ can_esp |= ((p_ptr->computed_flags & ESP_ORC) && (r_ptr->flags & RF_ORC));
+ can_esp |= ((p_ptr->computed_flags & ESP_SPIDER) && (r_ptr->flags & RF_SPIDER));
+ can_esp |= ((p_ptr->computed_flags & ESP_TROLL) && (r_ptr->flags & RF_TROLL));
+ can_esp |= ((p_ptr->computed_flags & ESP_DRAGON) && (r_ptr->flags & RF_DRAGON));
+ can_esp |= ((p_ptr->computed_flags & ESP_GIANT) && (r_ptr->flags & RF_GIANT));
+ can_esp |= ((p_ptr->computed_flags & ESP_DEMON) && (r_ptr->flags & RF_DEMON));
+ can_esp |= ((p_ptr->computed_flags & ESP_UNDEAD) && (r_ptr->flags & RF_UNDEAD));
+ can_esp |= ((p_ptr->computed_flags & ESP_EVIL) && (r_ptr->flags & RF_EVIL));
+ can_esp |= ((p_ptr->computed_flags & ESP_ANIMAL) && (r_ptr->flags & RF_ANIMAL));
+ can_esp |= ((p_ptr->computed_flags & ESP_THUNDERLORD) && (r_ptr->flags & RF_THUNDERLORD));
+ can_esp |= ((p_ptr->computed_flags & ESP_GOOD) && (r_ptr->flags & RF_GOOD));
+ can_esp |= ((p_ptr->computed_flags & ESP_NONLIVING) && (r_ptr->flags & RF_NONLIVING));
+ can_esp |= ((p_ptr->computed_flags & ESP_UNIQUE) && ((r_ptr->flags & RF_UNIQUE) || (r_ptr->flags & RF_UNIQUE_4)));
+ can_esp |= bool(p_ptr->computed_flags & ESP_ALL);
/* Only do this when we can really detect monster */
if (can_esp)
@@ -1880,7 +1880,7 @@ void monster_carry(monster_type *m_ptr, int m_idx, object_type *q_ptr)
{
a_info[q_ptr->name1].cur_num = 0;
}
- else if (k_info[q_ptr->k_idx].flags3 & TR3_NORM_ART)
+ else if (k_info[q_ptr->k_idx].flags & TR_NORM_ART)
{
k_info[q_ptr->k_idx].artifact = 0;
}
diff --git a/src/object1.cc b/src/object1.cc
index d68775df..5aa53c7f 100644
--- a/src/object1.cc
+++ b/src/object1.cc
@@ -29,6 +29,9 @@
#include "monster_race_flag.hpp"
#include "monster_type.hpp"
#include "object2.hpp"
+#include "object_flag.hpp"
+#include "object_flag_meta.hpp"
+#include "object_flag_set.hpp"
#include "object_kind.hpp"
#include "object_type.hpp"
#include "options.hpp"
@@ -60,8 +63,7 @@
using boost::starts_with;
-static bool_ apply_flags_set(s16b a_idx, s16b set_idx,
- u32b *f1, u32b *f2, u32b *f3, u32b *f4, u32b *f5, u32b *esp);
+static void apply_flags_set(s16b a_idx, s16b set_idx, object_flag_set *f);
/*
* Hack -- note that "TERM_MULTI" is now just "TERM_VIOLET".
@@ -433,7 +435,7 @@ static bool_ object_easy_know(int i)
case TV_ROD:
case TV_ROD_MAIN:
{
- if (k_ptr->flags3 & TR3_NORM_ART)
+ if (k_ptr->flags & TR_NORM_ART)
return ( FALSE );
return (TRUE);
}
@@ -443,7 +445,7 @@ static bool_ object_easy_know(int i)
case TV_AMULET:
case TV_LITE:
{
- if (k_ptr->flags3 & (TR3_EASY_KNOW)) return (TRUE);
+ if (k_ptr->flags & TR_EASY_KNOW) return (TRUE);
return (FALSE);
}
}
@@ -779,8 +781,15 @@ void reset_visuals(void)
/*
* Extract "xtra" flags from object.
*/
-static void object_flags_xtra(object_type const *o_ptr, u32b *f2, u32b *f3, u32b *esp)
+static void object_flags_xtra(object_type const *o_ptr, object_flag_set *f)
{
+ // Artifacts don't get *ego* extra powers.
+ if (o_ptr->art_name)
+ {
+ return;
+ }
+
+ // Add sustain or power.
switch (o_ptr->xtra1)
{
case EGO_XTRA_SUSTAIN:
@@ -789,22 +798,22 @@ static void object_flags_xtra(object_type const *o_ptr, u32b *f2, u32b *f3, u32b
switch (o_ptr->xtra2 % 6)
{
case 0:
- (*f2) |= (TR2_SUST_STR);
+ (*f) |= TR_SUST_STR;
break;
case 1:
- (*f2) |= (TR2_SUST_INT);
+ (*f) |= TR_SUST_INT;
break;
case 2:
- (*f2) |= (TR2_SUST_WIS);
+ (*f) |= TR_SUST_WIS;
break;
case 3:
- (*f2) |= (TR2_SUST_DEX);
+ (*f) |= TR_SUST_DEX;
break;
case 4:
- (*f2) |= (TR2_SUST_CON);
+ (*f) |= TR_SUST_CON;
break;
case 5:
- (*f2) |= (TR2_SUST_CHR);
+ (*f) |= TR_SUST_CHR;
break;
}
@@ -817,37 +826,37 @@ static void object_flags_xtra(object_type const *o_ptr, u32b *f2, u32b *f3, u32b
switch (o_ptr->xtra2 % 11)
{
case 0:
- (*f2) |= (TR2_RES_BLIND);
+ (*f) |= TR_RES_BLIND;
break;
case 1:
- (*f2) |= (TR2_RES_CONF);
+ (*f) |= TR_RES_CONF;
break;
case 2:
- (*f2) |= (TR2_RES_SOUND);
+ (*f) |= TR_RES_SOUND;
break;
case 3:
- (*f2) |= (TR2_RES_SHARDS);
+ (*f) |= TR_RES_SHARDS;
break;
case 4:
- (*f2) |= (TR2_RES_NETHER);
+ (*f) |= TR_RES_NETHER;
break;
case 5:
- (*f2) |= (TR2_RES_NEXUS);
+ (*f) |= TR_RES_NEXUS;
break;
case 6:
- (*f2) |= (TR2_RES_CHAOS);
+ (*f) |= TR_RES_CHAOS;
break;
case 7:
- (*f2) |= (TR2_RES_DISEN);
+ (*f) |= TR_RES_DISEN;
break;
case 8:
- (*f2) |= (TR2_RES_POIS);
+ (*f) |= TR_RES_POIS;
break;
case 9:
- (*f2) |= (TR2_RES_DARK);
+ (*f) |= TR_RES_DARK;
break;
case 10:
- (*f2) |= (TR2_RES_LITE);
+ (*f) |= TR_RES_LITE;
break;
}
@@ -857,52 +866,41 @@ static void object_flags_xtra(object_type const *o_ptr, u32b *f2, u32b *f3, u32b
}
}
+/*
+ * Disregard sets when calculating flags?
+ */
+bool_ object_flags_no_set = FALSE;
/*
* Obtain the "flags" for an item
*/
-bool_ object_flags_no_set = FALSE;
-void object_flags(object_type const *o_ptr, u32b *f1, u32b *f2, u32b *f3, u32b *f4, u32b *f5, u32b *esp)
+object_flag_set object_flags(object_type const *o_ptr)
{
object_kind *k_ptr = &k_info[o_ptr->k_idx];
/* Base object */
- (*f1) = k_ptr->flags1;
- (*f2) = k_ptr->flags2;
- (*f3) = k_ptr->flags3;
- (*f4) = k_ptr->flags4;
- (*f5) = k_ptr->flags5;
- (*esp) = k_ptr->esp;
+ auto f = k_ptr->flags;
/* Artifact */
if (o_ptr->name1)
{
artifact_type *a_ptr = &a_info[o_ptr->name1];
- (*f1) = a_ptr->flags1;
- (*f2) = a_ptr->flags2;
- (*f3) = a_ptr->flags3;
- (*f4) = a_ptr->flags4;
- (*f5) = a_ptr->flags5;
- (*esp) = a_ptr->esp;
+ f = a_ptr->flags;
if ((!object_flags_no_set) && (a_ptr->set != -1))
- apply_flags_set(o_ptr->name1, a_ptr->set, f1, f2, f3, f4, f5, esp);
+ {
+ apply_flags_set(o_ptr->name1, a_ptr->set, &f);
+ }
}
- /* Mix in art_{flagsX,esp} */
- (*f1) |= o_ptr->art_flags1;
- (*f2) |= o_ptr->art_flags2;
- (*f3) |= o_ptr->art_flags3;
- (*f4) |= o_ptr->art_flags4;
- (*f5) |= o_ptr->art_flags5;
- (*esp) |= o_ptr->art_esp;
+ /* Mix in art_{flags,esp} */
+ f |= o_ptr->art_flags;
/* Extra powers */
- if (!(o_ptr->art_name))
- {
- object_flags_xtra(o_ptr, f2, f3, esp);
- }
+ object_flags_xtra(o_ptr, &f);
+
+ return f;
}
/* Return object granted power */
@@ -945,30 +943,21 @@ int object_power(object_type *o_ptr)
/*
* Obtain the "flags" for an item which are known to the player
*/
-void object_flags_known(object_type const *o_ptr, u32b *f1, u32b *f2, u32b *f3, u32b *f4, u32b *f5, u32b *esp)
+object_flag_set object_flags_known(object_type const *o_ptr)
{
object_kind *k_ptr = &k_info[o_ptr->k_idx];
- /* Clear */
- (*f1) = (*f2) = (*f3) = (*f4) = (*esp) = (*f5) = 0L;
-
/* Must be identified */
- if (!object_known_p(o_ptr)) return;
+ if (!object_known_p(o_ptr))
+ {
+ return object_flag_set();
+ }
/* Base object */
- (*f1) = k_ptr->flags1;
- (*f2) = k_ptr->flags2;
- (*f3) = k_ptr->flags3;
- (*f4) = k_ptr->flags4;
- (*f5) = k_ptr->flags5;
- (*esp) = k_ptr->esp;
-
- (*f1) |= k_ptr->oflags1;
- (*f2) |= k_ptr->oflags2;
- (*f3) |= k_ptr->oflags3;
- (*f4) |= k_ptr->oflags4;
- (*f5) |= k_ptr->oflags5;
- (*esp) |= k_ptr->oesp;
+ auto flags = k_ptr->flags;
+
+ /* Obvious flags */
+ flags |= k_ptr->oflags;
/* Artifact */
if (o_ptr->name1)
@@ -978,61 +967,50 @@ void object_flags_known(object_type const *o_ptr, u32b *f1, u32b *f2, u32b *f3,
/* Need full knowledge or spoilers */
if ((o_ptr->ident & IDENT_MENTAL))
{
- (*f1) = a_ptr->flags1;
- (*f2) = a_ptr->flags2;
- (*f3) = a_ptr->flags3;
- (*f4) = a_ptr->flags4;
- (*f5) = a_ptr->flags5;
- (*esp) = a_ptr->esp;
+ flags = a_ptr->flags;
if ((!object_flags_no_set) && (a_ptr->set != -1))
- apply_flags_set(o_ptr->name1, a_ptr->set, f1, f2, f3, f4, f5, esp);
+ {
+ apply_flags_set(o_ptr->name1, a_ptr->set, &flags);
+ }
}
else
{
- (*f1) = (*f2) = (*f3) = (*f4) = (*esp) = (*f5) = 0L;
+ flags = object_flag_set();
}
- (*f1) |= a_ptr->oflags1;
- (*f2) |= a_ptr->oflags2;
- (*f3) |= a_ptr->oflags3;
- (*f4) |= a_ptr->oflags4;
- (*f5) |= a_ptr->oflags5;
- (*esp) |= a_ptr->oesp;
+ flags |= a_ptr->oflags;
}
/* Random artifact or ego item! */
- if (o_ptr->art_flags1 || o_ptr->art_flags2 || o_ptr->art_flags3 || o_ptr->art_flags4 || o_ptr->art_flags5 || o_ptr->art_esp)
+ if (o_ptr->art_flags)
{
/* Need full knowledge or spoilers */
if ((o_ptr->ident & IDENT_MENTAL))
{
- (*f1) |= o_ptr->art_flags1;
- (*f2) |= o_ptr->art_flags2;
- (*f3) |= o_ptr->art_flags3;
- (*f4) |= o_ptr->art_flags4;
- (*f5) |= o_ptr->art_flags5;
- (*esp) |= o_ptr->art_esp;
+ flags |= o_ptr->art_flags;
}
- (*f1) |= o_ptr->art_oflags1;
- (*f2) |= o_ptr->art_oflags2;
- (*f3) |= o_ptr->art_oflags3;
- (*f4) |= o_ptr->art_oflags4;
- (*f5) |= o_ptr->art_oflags5;
- (*esp) |= o_ptr->art_oesp;
+ flags |= o_ptr->art_oflags;
}
/* Full knowledge for *identified* objects */
- if (!(o_ptr->ident & IDENT_MENTAL)) return;
-
- if (!(o_ptr->art_name))
+ if (!(o_ptr->ident & IDENT_MENTAL))
{
- object_flags_xtra(o_ptr, f2, f3, esp);
+ return flags;
}
+ /* Extra powers */
+ object_flags_xtra(o_ptr, &flags);
+
/* Hack - Res Chaos -> Res Confusion */
- if (*f2 & TR2_RES_CHAOS) (*f2) |= (TR2_RES_CONF);
+ if (flags & TR_RES_CHAOS)
+ {
+ flags |= TR_RES_CONF;
+ }
+
+ // Done
+ return flags;
}
@@ -1046,6 +1024,23 @@ s32b calc_object_need_exp(object_type const *o_ptr)
}
+/**
+ * Calculate the PVAL mask.
+ */
+static object_flag_set compute_pval_mask()
+{
+ object_flag_set f;
+ for (auto const object_flag_meta: object_flags_meta())
+ {
+ if (object_flag_meta->is_pval)
+ {
+ f |= object_flag_meta->flag_set;
+ }
+ }
+ return f;
+}
+
+
/*
* Creates a description of the item "o_ptr", and stores it in "out_val".
@@ -1094,6 +1089,8 @@ s32b calc_object_need_exp(object_type const *o_ptr)
*/
static std::string object_desc_aux(object_type const *o_ptr, int pref, int mode)
{
+ static auto const TR_PVAL_MASK = compute_pval_mask();
+
bool_ hack_name = FALSE;
bool_ append_name = FALSE;
@@ -1104,8 +1101,7 @@ static std::string object_desc_aux(object_type const *o_ptr, int pref, int mode)
object_kind *k_ptr = &k_info[o_ptr->k_idx];
/* Extract some flags */
- u32b f1, f2, f3, f4, f5, esp;
- object_flags(o_ptr, &f1, &f2, &f3, &f4, &f5, &esp);
+ auto const flags = object_flags(o_ptr);
/* See if the object is "aware" */
bool_ aware = object_aware_p(o_ptr);
@@ -1468,7 +1464,7 @@ static std::string object_desc_aux(object_type const *o_ptr, int pref, int mode)
}
/* Mega Hack */
- if ((!hack_name) && known && (k_ptr->flags5 & TR5_FULL_NAME))
+ if ((!hack_name) && known && (k_ptr->flags & TR_FULL_NAME))
{
basenm = k_ptr->name;
}
@@ -1804,7 +1800,7 @@ static std::string object_desc_aux(object_type const *o_ptr, int pref, int mode)
}
/* It contains a spell */
- if ((known) && (f5 & TR5_SPELL_CONTAIN) && (o_ptr->pval2 != -1))
+ if (known && (flags & TR_SPELL_CONTAIN) && (o_ptr->pval2 != -1))
{
t += fmt::format(" [{}]", spell_type_name(spell_at(o_ptr->pval2)));
}
@@ -1822,7 +1818,7 @@ static std::string object_desc_aux(object_type const *o_ptr, int pref, int mode)
}
/* Hack -- Some objects can have an exp level */
- if ((f4 & TR4_LEVELS) && known)
+ if ((flags & TR_LEVELS) && known)
{
auto need_exp = (o_ptr->elevel < PY_MAX_LEVEL)
? std::to_string(calc_object_need_exp(o_ptr) - o_ptr->exp)
@@ -1865,7 +1861,7 @@ static std::string object_desc_aux(object_type const *o_ptr, int pref, int mode)
/* Display the item like a weapon */
- if (f3 & (TR3_SHOW_MODS)) show_weapon = TRUE;
+ if (flags & TR_SHOW_MODS) show_weapon = TRUE;
/* Display the item like a weapon */
if (o_ptr->to_h && o_ptr->to_d) show_weapon = TRUE;
@@ -1908,7 +1904,7 @@ static std::string object_desc_aux(object_type const *o_ptr, int pref, int mode)
s32b power = (o_ptr->sval % 10);
/* Apply the "Extra Might" flag */
- if (f3 & (TR3_XTRA_MIGHT)) power += o_ptr->pval;
+ if (flags & TR_XTRA_MIGHT) power += o_ptr->pval;
/* Append a special "damage" string */
t += fmt::format(" (x{:d})", power);
@@ -1931,7 +1927,7 @@ static std::string object_desc_aux(object_type const *o_ptr, int pref, int mode)
else if (o_ptr->to_h)
{
t += fmt::format(" ({:+d}", o_ptr->to_h);
- if (!(f3 & (TR3_HIDE_TYPE)) || o_ptr->art_name)
+ if (!(flags & TR_HIDE_TYPE) || o_ptr->art_name)
{
t += " to accuracy";
}
@@ -1942,7 +1938,7 @@ static std::string object_desc_aux(object_type const *o_ptr, int pref, int mode)
else if (o_ptr->to_d)
{
t += fmt::format(" ({:+d}", o_ptr->to_d);
- if (!(f3 & (TR3_HIDE_TYPE)) || o_ptr->art_name)
+ if (!(flags & TR_HIDE_TYPE) || o_ptr->art_name)
{
t += " to damage";
}
@@ -1973,12 +1969,12 @@ static std::string object_desc_aux(object_type const *o_ptr, int pref, int mode)
t += fmt::format(" [{:d}]", o_ptr->ac);
}
- if ((f1 & TR1_MANA) && (known) && (o_ptr->pval > 0))
+ if ((flags & TR_MANA) && known && (o_ptr->pval > 0))
{
t += fmt::format("({:d}%)", 100 * o_ptr->pval / 5);
}
- if ((known) && (f2 & TR2_LIFE) ) /* Can disp neg now -- Improv */
+ if (known && (flags & TR_LIFE) ) /* Can disp neg now -- Improv */
{
t += fmt::format("({:d}%)", 100 * o_ptr->pval / 5);
}
@@ -2016,32 +2012,32 @@ static std::string object_desc_aux(object_type const *o_ptr, int pref, int mode)
}
/* Hack -- Process Lanterns/Torches */
- else if ((o_ptr->tval == TV_LITE) && (f4 & TR4_FUEL_LITE))
+ else if ((o_ptr->tval == TV_LITE) && (flags & TR_FUEL_LITE))
{
t += fmt::format(" (with {:d} turns of light)", o_ptr->timeout);
}
/* Dump "pval" flags for wearable items */
- if (known && ((f1 & (TR1_PVAL_MASK)) || (f5 & (TR5_PVAL_MASK))))
+ if (known && (flags & TR_PVAL_MASK))
{
/* Start the display */
t += fmt::format(" ({:+d}", o_ptr->pval);
/* Do not display the "pval" flags */
- if (f3 & (TR3_HIDE_TYPE))
+ if (flags & TR_HIDE_TYPE)
{
/* Nothing */
}
/* Speed */
- else if (f1 & (TR1_SPEED))
+ else if (flags & TR_SPEED)
{
t += " to speed";
}
/* Attack speed */
- else if (f1 & (TR1_BLOWS))
+ else if (flags & TR_BLOWS)
{
t += " attack";
if (ABS(o_ptr->pval) != 1)
@@ -2051,31 +2047,31 @@ static std::string object_desc_aux(object_type const *o_ptr, int pref, int mode)
}
/* Critical chance */
- else if (f5 & (TR5_CRIT))
+ else if (flags & TR_CRIT)
{
t += "% of critical hits";
}
/* Stealth */
- else if (f1 & (TR1_STEALTH))
+ else if (flags & TR_STEALTH)
{
t += " to stealth";
}
/* Search */
- else if (f1 & (TR1_SEARCH))
+ else if (flags & TR_SEARCH)
{
t += " to searching";
}
/* Infravision */
- else if (f1 & (TR1_INFRA))
+ else if (flags & TR_INFRA)
{
t += " to infravision";
}
/* Tunneling */
- else if (f1 & (TR1_TUNNEL))
+ else if (flags & TR_TUNNEL)
{
/* Nothing */
}
@@ -2086,7 +2082,7 @@ static std::string object_desc_aux(object_type const *o_ptr, int pref, int mode)
/* Indicate "charging" artifacts XXX XXX XXX */
- if (known && (f3 & TR3_ACTIVATE) && o_ptr->timeout)
+ if (known && (flags & TR_ACTIVATE) && o_ptr->timeout)
{
if (o_ptr->tval == TV_EGG)
{
@@ -2227,16 +2223,14 @@ void object_desc_store(char *buf, object_type *o_ptr, int pref, int mode)
*/
cptr item_activation(object_type *o_ptr, byte num)
{
- u32b f1, f2, f3, f4, f5, esp;
-
/* Needed hacks */
static char rspell[2][80];
/* Extract the flags */
- object_flags(o_ptr, &f1, &f2, &f3, &f4, &f5, &esp);
+ auto const flags = object_flags(o_ptr);
/* Require activation ability */
- if (!(f3 & (TR3_ACTIVATE))) return (NULL);
+ if (!(flags & TR_ACTIVATE)) return (NULL);
/*
@@ -2366,12 +2360,11 @@ void output_dam(object_type *o_ptr, int mult, int mult2, cptr against, cptr agai
void display_weapon_damage(object_type *o_ptr)
{
object_type forge, *old_ptr = &forge;
- u32b f1, f2, f3, f4, f5, esp;
bool_ first = TRUE;
bool_ full = o_ptr->ident & (IDENT_MENTAL);
/* Extract the flags */
- object_flags(o_ptr, &f1, &f2, &f3, &f4, &f5, &esp);
+ auto const flags = object_flags(o_ptr);
/* Ok now the hackish stuff, we replace the current weapon with this one */
object_copy(old_ptr, &p_ptr->inventory[INVEN_WIELD]);
@@ -2382,23 +2375,23 @@ void display_weapon_damage(object_type *o_ptr)
text_out_c(TERM_L_GREEN, format("%d ", p_ptr->num_blow));
text_out(format("blow%s and do an average damage per turn of ", (p_ptr->num_blow) ? "s" : ""));
- if (full && (f1 & TR1_SLAY_ANIMAL)) output_dam(o_ptr, 2, 0, "animals", NULL, &first);
- if (full && (f1 & TR1_SLAY_EVIL)) output_dam(o_ptr, 2, 0, "evil creatures", NULL, &first);
- if (full && (f1 & TR1_SLAY_ORC)) output_dam(o_ptr, 3, 0, "orcs", NULL, &first);
- if (full && (f1 & TR1_SLAY_TROLL)) output_dam(o_ptr, 3, 0, "trolls", NULL, &first);
- if (full && (f1 & TR1_SLAY_GIANT)) output_dam(o_ptr, 3, 0, "giants", NULL, &first);
- if (full && (f1 & TR1_KILL_DRAGON)) output_dam(o_ptr, 5, 0, "dragons", NULL, &first);
- else if (full && (f1 & TR1_SLAY_DRAGON)) output_dam(o_ptr, 3, 0, "dragons", NULL, &first);
- if (full && (f5 & TR5_KILL_UNDEAD)) output_dam(o_ptr, 5, 0, "undead", NULL, &first);
- else if (full && (f1 & TR1_SLAY_UNDEAD)) output_dam(o_ptr, 3, 0, "undead", NULL, &first);
- if (full && (f5 & TR5_KILL_DEMON)) output_dam(o_ptr, 5, 0, "demons", NULL, &first);
- else if (full && (f1 & TR1_SLAY_DEMON)) output_dam(o_ptr, 3, 0, "demons", NULL, &first);
-
- if (full && (f1 & TR1_BRAND_FIRE)) output_dam(o_ptr, 3, 6, "non fire resistant creatures", "fire susceptible creatures", &first);
- if (full && (f1 & TR1_BRAND_COLD)) output_dam(o_ptr, 3, 6, "non cold resistant creatures", "cold susceptible creatures", &first);
- if (full && (f1 & TR1_BRAND_ELEC)) output_dam(o_ptr, 3, 6, "non lightning resistant creatures", "lightning susceptible creatures", &first);
- if (full && (f1 & TR1_BRAND_ACID)) output_dam(o_ptr, 3, 6, "non acid resistant creatures", "acid susceptible creatures", &first);
- if (full && (f1 & TR1_BRAND_POIS)) output_dam(o_ptr, 3, 6, "non poison resistant creatures", "poison susceptible creatures", &first);
+ if (full && (flags & TR_SLAY_ANIMAL)) output_dam(o_ptr, 2, 0, "animals", NULL, &first);
+ if (full && (flags & TR_SLAY_EVIL)) output_dam(o_ptr, 2, 0, "evil creatures", NULL, &first);
+ if (full && (flags & TR_SLAY_ORC)) output_dam(o_ptr, 3, 0, "orcs", NULL, &first);
+ if (full && (flags & TR_SLAY_TROLL)) output_dam(o_ptr, 3, 0, "trolls", NULL, &first);
+ if (full && (flags & TR_SLAY_GIANT)) output_dam(o_ptr, 3, 0, "giants", NULL, &first);
+ if (full && (flags & TR_KILL_DRAGON)) output_dam(o_ptr, 5, 0, "dragons", NULL, &first);
+ else if (full && (flags & TR_SLAY_DRAGON)) output_dam(o_ptr, 3, 0, "dragons", NULL, &first);
+ if (full && (flags & TR_KILL_UNDEAD)) output_dam(o_ptr, 5, 0, "undead", NULL, &first);
+ else if (full && (flags & TR_SLAY_UNDEAD)) output_dam(o_ptr, 3, 0, "undead", NULL, &first);
+ if (full && (flags & TR_KILL_DEMON)) output_dam(o_ptr, 5, 0, "demons", NULL, &first);
+ else if (full && (flags & TR_SLAY_DEMON)) output_dam(o_ptr, 3, 0, "demons", NULL, &first);
+
+ if (full && (flags & TR_BRAND_FIRE)) output_dam(o_ptr, 3, 6, "non fire resistant creatures", "fire susceptible creatures", &first);
+ if (full && (flags & TR_BRAND_COLD)) output_dam(o_ptr, 3, 6, "non cold resistant creatures", "cold susceptible creatures", &first);
+ if (full && (flags & TR_BRAND_ELEC)) output_dam(o_ptr, 3, 6, "non lightning resistant creatures", "lightning susceptible creatures", &first);
+ if (full && (flags & TR_BRAND_ACID)) output_dam(o_ptr, 3, 6, "non acid resistant creatures", "acid susceptible creatures", &first);
+ if (full && (flags & TR_BRAND_POIS)) output_dam(o_ptr, 3, 6, "non poison resistant creatures", "poison susceptible creatures", &first);
output_dam(o_ptr, 1, 0, (first) ? "all monsters" : "other monsters", NULL, &first);
@@ -2465,35 +2458,34 @@ void output_ammo_dam(object_type *o_ptr, int mult, int mult2, cptr against, cptr
*/
void display_ammo_damage(object_type *o_ptr)
{
- u32b f1, f2, f3, f4, f5, esp;
bool_ first = TRUE;
int i;
bool_ full = o_ptr->ident & (IDENT_MENTAL);
/* Extract the flags */
- object_flags(o_ptr, &f1, &f2, &f3, &f4, &f5, &esp);
+ auto const flags = object_flags(o_ptr);
if (o_ptr->tval == TV_BOOMERANG)
text_out("\nUsing it you would do an average damage per throw of ");
else
text_out("\nUsing it with your current shooter you would do an average damage per shot of ");
- if (full && (f1 & TR1_SLAY_ANIMAL)) output_ammo_dam(o_ptr, 2, 0, "animals", NULL, &first);
- if (full && (f1 & TR1_SLAY_EVIL)) output_ammo_dam(o_ptr, 2, 0, "evil creatures", NULL, &first);
- if (full && (f1 & TR1_SLAY_ORC)) output_ammo_dam(o_ptr, 3, 0, "orcs", NULL, &first);
- if (full && (f1 & TR1_SLAY_TROLL)) output_ammo_dam(o_ptr, 3, 0, "trolls", NULL, &first);
- if (full && (f1 & TR1_SLAY_GIANT)) output_ammo_dam(o_ptr, 3, 0, "giants", NULL, &first);
- if (full && (f1 & TR1_KILL_DRAGON)) output_ammo_dam(o_ptr, 5, 0, "dragons", NULL, &first);
- else if (full && (f1 & TR1_SLAY_DRAGON)) output_ammo_dam(o_ptr, 3, 0, "dragons", NULL, &first);
- if (full && (f5 & TR5_KILL_UNDEAD)) output_ammo_dam(o_ptr, 5, 0, "undeads", NULL, &first);
- else if (full && (f1 & TR1_SLAY_UNDEAD)) output_ammo_dam(o_ptr, 3, 0, "undeads", NULL, &first);
- if (full && (f5 & TR5_KILL_DEMON)) output_ammo_dam(o_ptr, 5, 0, "demons", NULL, &first);
- else if (full && (f1 & TR1_SLAY_DEMON)) output_ammo_dam(o_ptr, 3, 0, "demons", NULL, &first);
-
- if (full && (f1 & TR1_BRAND_FIRE)) output_ammo_dam(o_ptr, 3, 6, "non fire resistant creatures", "fire susceptible creatures", &first);
- if (full && (f1 & TR1_BRAND_COLD)) output_ammo_dam(o_ptr, 3, 6, "non cold resistant creatures", "cold susceptible creatures", &first);
- if (full && (f1 & TR1_BRAND_ELEC)) output_ammo_dam(o_ptr, 3, 6, "non lightning resistant creatures", "lightning susceptible creatures", &first);
- if (full && (f1 & TR1_BRAND_ACID)) output_ammo_dam(o_ptr, 3, 6, "non acid resistant creatures", "acid susceptible creatures", &first);
- if (full && (f1 & TR1_BRAND_POIS)) output_ammo_dam(o_ptr, 3, 6, "non poison resistant creatures", "poison susceptible creatures", &first);
+ if (full && (flags & TR_SLAY_ANIMAL)) output_ammo_dam(o_ptr, 2, 0, "animals", NULL, &first);
+ if (full && (flags & TR_SLAY_EVIL)) output_ammo_dam(o_ptr, 2, 0, "evil creatures", NULL, &first);
+ if (full && (flags & TR_SLAY_ORC)) output_ammo_dam(o_ptr, 3, 0, "orcs", NULL, &first);
+ if (full && (flags & TR_SLAY_TROLL)) output_ammo_dam(o_ptr, 3, 0, "trolls", NULL, &first);
+ if (full && (flags & TR_SLAY_GIANT)) output_ammo_dam(o_ptr, 3, 0, "giants", NULL, &first);
+ if (full && (flags & TR_KILL_DRAGON)) output_ammo_dam(o_ptr, 5, 0, "dragons", NULL, &first);
+ else if (full && (flags & TR_SLAY_DRAGON)) output_ammo_dam(o_ptr, 3, 0, "dragons", NULL, &first);
+ if (full && (flags & TR_KILL_UNDEAD)) output_ammo_dam(o_ptr, 5, 0, "undeads", NULL, &first);
+ else if (full && (flags & TR_SLAY_UNDEAD)) output_ammo_dam(o_ptr, 3, 0, "undeads", NULL, &first);
+ if (full && (flags & TR_KILL_DEMON)) output_ammo_dam(o_ptr, 5, 0, "demons", NULL, &first);
+ else if (full && (flags & TR_SLAY_DEMON)) output_ammo_dam(o_ptr, 3, 0, "demons", NULL, &first);
+
+ if (full && (flags & TR_BRAND_FIRE)) output_ammo_dam(o_ptr, 3, 6, "non fire resistant creatures", "fire susceptible creatures", &first);
+ if (full && (flags & TR_BRAND_COLD)) output_ammo_dam(o_ptr, 3, 6, "non cold resistant creatures", "cold susceptible creatures", &first);
+ if (full && (flags & TR_BRAND_ELEC)) output_ammo_dam(o_ptr, 3, 6, "non lightning resistant creatures", "lightning susceptible creatures", &first);
+ if (full && (flags & TR_BRAND_ACID)) output_ammo_dam(o_ptr, 3, 6, "non acid resistant creatures", "acid susceptible creatures", &first);
+ if (full && (flags & TR_BRAND_POIS)) output_ammo_dam(o_ptr, 3, 6, "non poison resistant creatures", "poison susceptible creatures", &first);
output_ammo_dam(o_ptr, 1, 0, (first) ? "all monsters" : "other monsters", NULL, &first);
text_out(". ");
@@ -2597,25 +2589,20 @@ static cptr object_out_desc_where_found(s16b level, s16b dungeon)
*/
bool_ object_out_desc(object_type *o_ptr, FILE *fff, bool_ trim_down, bool_ wait_for_it)
{
- u32b f1, f2, f3, f4, f5, esp;
-
cptr vp[64];
byte vc[64];
int vn;
+ object_flag_set flags;
+
/* Extract the flags */
if ((!(o_ptr->ident & (IDENT_MENTAL))) && (!fff))
{
- f1 = o_ptr->art_oflags1;
- f2 = o_ptr->art_oflags2;
- f3 = o_ptr->art_oflags3;
- f4 = o_ptr->art_oflags4;
- f5 = o_ptr->art_oflags5;
- esp = o_ptr->art_oesp;
+ flags = o_ptr->art_oflags;
}
else
{
- object_flags(o_ptr, &f1, &f2, &f3, &f4, &f5, &esp);
+ flags = object_flags(o_ptr);
}
if (fff)
@@ -2665,9 +2652,9 @@ bool_ object_out_desc(object_type *o_ptr, FILE *fff, bool_ trim_down, bool_ wait
}
}
- if ((f4 & TR4_LEVELS) && (!trim_down))
+ if ((flags & TR_LEVELS) && (!trim_down))
{
- if (count_bits(o_ptr->pval3) == 0) text_out("It is sentient");
+ if (o_ptr->pval3 == 0) text_out("It is sentient");
else if (count_bits(o_ptr->pval3) > 1) text_out("It is sentient and can have access to the realms of ");
else text_out("It is sentient and can have access to the realm of ");
@@ -2684,7 +2671,7 @@ bool_ object_out_desc(object_type *o_ptr, FILE *fff, bool_ trim_down, bool_ wait
text_out(". ");
}
- if (f4 & TR4_ULTIMATE)
+ if (flags & TR_ULTIMATE)
{
if ((wield_slot(o_ptr) == INVEN_WIELD) ||
(wield_slot(o_ptr) == INVEN_BOW))
@@ -2693,11 +2680,11 @@ bool_ object_out_desc(object_type *o_ptr, FILE *fff, bool_ trim_down, bool_ wait
text_out_c(TERM_VIOLET, "It is the ultimate armor. ");
}
- if (f4 & TR4_COULD2H) text_out("It can be wielded two-handed. ");
- if (f4 & TR4_MUST2H) text_out("It must be wielded two-handed. ");
+ if (flags & TR_COULD2H) text_out("It can be wielded two-handed. ");
+ if (flags & TR_MUST2H) text_out("It must be wielded two-handed. ");
/* Mega-Hack -- describe activation */
- if (f3 & (TR3_ACTIVATE))
+ if (flags & TR_ACTIVATE)
{
text_out("It can be activated for ");
if (is_ego_p(o_ptr, EGO_MSTAFF_SPELL))
@@ -2710,7 +2697,7 @@ bool_ object_out_desc(object_type *o_ptr, FILE *fff, bool_ trim_down, bool_ wait
text_out(item_activation(o_ptr, 0));
/* Mega-hack -- get rid of useless line for e.g. randarts */
- if (f5 & (TR5_ACTIVATE_NO_WIELD))
+ if (flags & TR_ACTIVATE_NO_WIELD)
text_out(". ");
else
text_out(" if it is being worn. ");
@@ -2723,23 +2710,25 @@ bool_ object_out_desc(object_type *o_ptr, FILE *fff, bool_ trim_down, bool_ wait
text_out(" if it is being worn. ");
}
- /* Hack -- describe lites */
- if ((o_ptr->tval == TV_LITE) || (f3 & TR3_LITE1) || (f4 & TR4_LITE2) || (f4 & TR4_LITE3))
+ /* Describe light sources */
{
int radius = 0;
- if (f3 & TR3_LITE1) radius++;
- if (f4 & TR4_LITE2) radius += 2;
- if (f4 & TR4_LITE3) radius += 3;
+ if (flags & TR_LITE1) radius += 1;
+ if (flags & TR_LITE2) radius += 2;
+ if (flags & TR_LITE3) radius += 3;
if (radius > 5) radius = 5;
- if (f4 & TR4_FUEL_LITE)
+ if (radius > 0)
{
- text_out(format("It provides light (radius %d) when fueled. ", radius));
- }
- else
- {
- text_out(format("It provides light (radius %d) forever. ", radius));
+ if (flags & TR_FUEL_LITE)
+ {
+ text_out(format("It provides light (radius %d) when fueled. ", radius));
+ }
+ else
+ {
+ text_out(format("It provides light (radius %d) forever. ", radius));
+ }
}
}
@@ -2749,12 +2738,12 @@ bool_ object_out_desc(object_type *o_ptr, FILE *fff, bool_ trim_down, bool_ wait
text_out("It prevents the space-time continuum from being disrupted. ");
}
- if (f4 & TR4_ANTIMAGIC_50)
+ if (flags & TR_ANTIMAGIC_50)
{
text_out("It generates an antimagic field. ");
}
- if (f5 & TR5_SPELL_CONTAIN)
+ if (flags & TR_SPELL_CONTAIN)
{
if (o_ptr->pval2 == -1)
text_out("It can be used to store a spell. ");
@@ -2764,21 +2753,21 @@ bool_ object_out_desc(object_type *o_ptr, FILE *fff, bool_ trim_down, bool_ wait
/* Pick up stat bonuses */
vn = 0;
- if (f1 & (TR1_STR)) vp[vn++] = "strength";
- if (f1 & (TR1_INT)) vp[vn++] = "intelligence";
- if (f1 & (TR1_WIS)) vp[vn++] = "wisdom";
- if (f1 & (TR1_DEX)) vp[vn++] = "dexterity";
- if (f1 & (TR1_CON)) vp[vn++] = "constitution";
- if (f1 & (TR1_CHR)) vp[vn++] = "charisma";
- if ((o_ptr->tval != TV_TRAPKIT) && (f1 & (TR1_STEALTH))) vp[vn++] = "stealth";
- if (f1 & (TR1_SEARCH)) vp[vn++] = "searching";
- if (f1 & (TR1_INFRA)) vp[vn++] = "infravision";
- if (f1 & (TR1_TUNNEL)) vp[vn++] = "ability to tunnel";
- if (f1 & (TR1_SPEED)) vp[vn++] = "speed";
- if (f1 & (TR1_BLOWS)) vp[vn++] = "attack speed";
- if (f5 & (TR5_CRIT)) vp[vn++] = "ability to score critical hits";
- if (f5 & (TR5_LUCK)) vp[vn++] = "luck";
- if (f1 & (TR1_SPELL)) vp[vn++] = "spell power";
+ if (flags & TR_STR) vp[vn++] = "strength";
+ if (flags & TR_INT) vp[vn++] = "intelligence";
+ if (flags & TR_WIS) vp[vn++] = "wisdom";
+ if (flags & TR_DEX) vp[vn++] = "dexterity";
+ if (flags & TR_CON) vp[vn++] = "constitution";
+ if (flags & TR_CHR) vp[vn++] = "charisma";
+ if ((o_ptr->tval != TV_TRAPKIT) && (flags & TR_STEALTH)) vp[vn++] = "stealth";
+ if (flags & TR_SEARCH) vp[vn++] = "searching";
+ if (flags & TR_INFRA) vp[vn++] = "infravision";
+ if (flags & TR_TUNNEL) vp[vn++] = "ability to tunnel";
+ if (flags & TR_SPEED) vp[vn++] = "speed";
+ if (flags & TR_BLOWS) vp[vn++] = "attack speed";
+ if (flags & TR_CRIT) vp[vn++] = "ability to score critical hits";
+ if (flags & TR_LUCK) vp[vn++] = "luck";
+ if (flags & TR_SPELL) vp[vn++] = "spell power";
/* Describe */
if (vn)
@@ -2814,8 +2803,8 @@ bool_ object_out_desc(object_type *o_ptr, FILE *fff, bool_ trim_down, bool_ wait
vn = 0;
- if (f1 & (TR1_MANA)) vp[vn++] = "mana capacity";
- if (f2 & (TR2_LIFE)) vp[vn++] = "hit points";
+ if (flags & TR_MANA) vp[vn++] = "mana capacity";
+ if (flags & TR_LIFE) vp[vn++] = "hit points";
/* Describe with percentuals */
if (vn)
@@ -2847,28 +2836,28 @@ bool_ object_out_desc(object_type *o_ptr, FILE *fff, bool_ trim_down, bool_ wait
text_out(". ");
}
- if ((o_ptr->tval == TV_TRAPKIT) && (f1 & (TR1_STEALTH)))
+ if ((o_ptr->tval == TV_TRAPKIT) && (flags & TR_STEALTH))
{
text_out("It is well-hidden. ");
}
vn = 0;
- if (f1 & (TR1_BRAND_ACID))
+ if (flags & TR_BRAND_ACID)
{
vc[vn] = TERM_GREEN;
vp[vn++] = "acid";
}
- if (f1 & (TR1_BRAND_ELEC))
+ if (flags & TR_BRAND_ELEC)
{
vc[vn] = TERM_L_BLUE;
vp[vn++] = "electricity";
}
- if (f1 & (TR1_BRAND_FIRE))
+ if (flags & TR_BRAND_FIRE)
{
vc[vn] = TERM_RED;
vp[vn++] = "fire";
}
- if (f1 & (TR1_BRAND_COLD))
+ if (flags & TR_BRAND_COLD)
{
vc[vn] = TERM_L_WHITE;
vp[vn++] = "frost";
@@ -2896,84 +2885,91 @@ bool_ object_out_desc(object_type *o_ptr, FILE *fff, bool_ trim_down, bool_ wait
}
- if (f1 & (TR1_BRAND_POIS))
+ if (flags & TR_BRAND_POIS)
{
text_out("It ");
text_out_c(TERM_L_GREEN, "poisons your foes");
text_out(". ");
}
- if (f1 & (TR1_CHAOTIC))
+ if (flags & TR_CHAOTIC)
{
text_out("It produces chaotic effects. ");
}
- if (f1 & (TR1_VAMPIRIC))
+ if (flags & TR_VAMPIRIC)
{
text_out("It drains life from your foes. ");
}
- if (f1 & (TR1_IMPACT))
+ if (flags & TR_IMPACT)
{
text_out("It can cause earthquakes. ");
}
- if (f1 & (TR1_VORPAL))
+ if (flags & TR_VORPAL)
{
text_out("It is very sharp and can cut your foes. ");
}
- if (f5 & (TR5_WOUNDING))
+ if (flags & TR_WOUNDING)
{
text_out("It is very sharp and can make your foes bleed. ");
}
- if (f1 & (TR1_KILL_DRAGON))
+ if (flags & TR_KILL_DRAGON)
{
text_out("It is a great bane of dragons. ");
}
- else if (f1 & (TR1_SLAY_DRAGON))
+ else if (flags & TR_SLAY_DRAGON)
{
text_out("It is especially deadly against dragons. ");
}
- if (f1 & (TR1_SLAY_ORC))
+
+ if (flags & TR_SLAY_ORC)
{
text_out("It is especially deadly against orcs. ");
}
- if (f1 & (TR1_SLAY_TROLL))
+
+ if (flags & TR_SLAY_TROLL)
{
text_out("It is especially deadly against trolls. ");
}
- if (f1 & (TR1_SLAY_GIANT))
+
+ if (flags & TR_SLAY_GIANT)
{
text_out("It is especially deadly against giants. ");
}
- if (f5 & (TR5_KILL_DEMON))
+
+ if (flags & TR_KILL_DEMON)
{
text_out("It is a great bane of demons. ");
}
- else if (f1 & (TR1_SLAY_DEMON))
+ else if (flags & TR_SLAY_DEMON)
{
text_out("It strikes at demons with holy wrath. ");
}
- if (f5 & (TR5_KILL_UNDEAD))
+
+ if (flags & TR_KILL_UNDEAD)
{
text_out("It is a great bane of undead. ");
}
- else if (f1 & (TR1_SLAY_UNDEAD))
+ else if (flags & TR_SLAY_UNDEAD)
{
text_out("It strikes at undead with holy wrath. ");
}
- if (f1 & (TR1_SLAY_EVIL))
+
+ if (flags & TR_SLAY_EVIL)
{
text_out("It fights against evil with holy fury. ");
}
- if (f1 & (TR1_SLAY_ANIMAL))
+
+ if (flags & TR_SLAY_ANIMAL)
{
text_out("It is especially deadly against natural creatures. ");
}
- if (f2 & (TR2_INVIS))
+ if (flags & TR_INVIS)
{
text_out("It makes you invisible. ");
}
@@ -2981,27 +2977,27 @@ bool_ object_out_desc(object_type *o_ptr, FILE *fff, bool_ trim_down, bool_ wait
if (o_ptr->tval != TV_TRAPKIT)
{
vn = 0;
- if (f2 & (TR2_SUST_STR))
+ if (flags & TR_SUST_STR)
{
vp[vn++] = "strength";
}
- if (f2 & (TR2_SUST_INT))
+ if (flags & TR_SUST_INT)
{
vp[vn++] = "intelligence";
}
- if (f2 & (TR2_SUST_WIS))
+ if (flags & TR_SUST_WIS)
{
vp[vn++] = "wisdom";
}
- if (f2 & (TR2_SUST_DEX))
+ if (flags & TR_SUST_DEX)
{
vp[vn++] = "dexterity";
}
- if (f2 & (TR2_SUST_CON))
+ if (flags & TR_SUST_CON)
{
vp[vn++] = "constitution";
}
- if (f2 & (TR2_SUST_CHR))
+ if (flags & TR_SUST_CHR)
{
vp[vn++] = "charisma";
}
@@ -3028,27 +3024,27 @@ bool_ object_out_desc(object_type *o_ptr, FILE *fff, bool_ trim_down, bool_ wait
}
vn = 0;
- if (f2 & (TR2_IM_ACID))
+ if (flags & TR_IM_ACID)
{
vc[vn] = TERM_GREEN;
vp[vn++] = "acid";
}
- if (f2 & (TR2_IM_ELEC))
+ if (flags & TR_IM_ELEC)
{
vc[vn] = TERM_L_BLUE;
vp[vn++] = "electricity";
}
- if (f2 & (TR2_IM_FIRE))
+ if (flags & TR_IM_FIRE)
{
vc[vn] = TERM_RED;
vp[vn++] = "fire";
}
- if (f2 & (TR2_IM_COLD))
+ if (flags & TR_IM_COLD)
{
vc[vn] = TERM_L_WHITE;
vp[vn++] = "cold";
}
- if (f4 & (TR4_IM_NETHER))
+ if (flags & TR_IM_NETHER)
{
vc[vn] = TERM_L_GREEN;
vp[vn++] = "nether";
@@ -3077,115 +3073,115 @@ bool_ object_out_desc(object_type *o_ptr, FILE *fff, bool_ trim_down, bool_ wait
}
else
{
- if (f2 & (TRAP2_AUTOMATIC_5))
+ if (flags & TR_AUTOMATIC_5)
{
text_out("It can rearm itself. ");
}
- if (f2 & (TRAP2_AUTOMATIC_99))
+ if (flags & TR_AUTOMATIC_99)
{
text_out("It rearms itself. ");
}
- if (f2 & (TRAP2_KILL_GHOST))
+ if (flags & TR_KILL_GHOST)
{
text_out("It is effective against Ghosts. ");
}
- if (f2 & (TRAP2_TELEPORT_TO))
+ if (flags & TR_TELEPORT_TO)
{
text_out("It can teleport monsters to you. ");
}
- if (f2 & (TRAP2_ONLY_DRAGON))
+ if (flags & TR_ONLY_DRAGON)
{
text_out("It can only be set off by dragons. ");
}
- if (f2 & (TRAP2_ONLY_DEMON))
+ if (flags & TR_ONLY_DEMON)
{
text_out("It can only be set off by demons. ");
}
- if (f2 & (TRAP2_ONLY_UNDEAD))
+ if (flags & TR_ONLY_UNDEAD)
{
text_out("It can only be set off by undead. ");
}
- if (f2 & (TRAP2_ONLY_ANIMAL))
+ if (flags & TR_ONLY_ANIMAL)
{
text_out("It can only be set off by animals. ");
}
- if (f2 & (TRAP2_ONLY_EVIL))
+ if (flags & TR_ONLY_EVIL)
{
text_out("It can only be set off by evil creatures. ");
}
}
- if (f2 & (TR2_FREE_ACT))
+ if (flags & TR_FREE_ACT)
{
text_out("It provides immunity to paralysis. ");
}
- if (f2 & (TR2_RES_FEAR))
+ if (flags & TR_RES_FEAR)
{
text_out("It makes you completely fearless. ");
}
vn = 0;
- if (f2 & (TR2_HOLD_LIFE))
+ if (flags & TR_HOLD_LIFE)
{
vp[vn++] = "life draining";
}
- if ((f2 & (TR2_RES_ACID)) && !(f2 & (TR2_IM_ACID)))
+ if ((flags & TR_RES_ACID) && !(flags & TR_IM_ACID))
{
vp[vn++] = "acid";
}
- if ((f2 & (TR2_RES_ELEC)) && !(f2 & (TR2_IM_ELEC)))
+ if ((flags & TR_RES_ELEC) && !(flags & TR_IM_ELEC))
{
vp[vn++] = "electricity";
}
- if ((f2 & (TR2_RES_FIRE)) && !(f2 & (TR2_IM_FIRE)))
+ if ((flags & TR_RES_FIRE) && !(flags & TR_IM_FIRE))
{
vp[vn++] = "fire";
}
- if ((f2 & (TR2_RES_COLD)) && !(f2 & (TR2_IM_COLD)))
+ if ((flags & TR_RES_COLD) && !(flags & TR_IM_COLD))
{
vp[vn++] = "cold";
}
- if (f2 & (TR2_RES_POIS))
+ if (flags & TR_RES_POIS)
{
vp[vn++] = "poison";
}
- if (f2 & (TR2_RES_LITE))
+ if (flags & TR_RES_LITE)
{
vp[vn++] = "light";
}
- if (f2 & (TR2_RES_DARK))
+ if (flags & TR_RES_DARK)
{
vp[vn++] = "dark";
}
- if (f2 & (TR2_RES_BLIND))
+ if (flags & TR_RES_BLIND)
{
vp[vn++] = "blindness";
}
- if (f2 & (TR2_RES_CONF))
+ if (flags & TR_RES_CONF)
{
vp[vn++] = "confusion";
}
- if (f2 & (TR2_RES_SOUND))
+ if (flags & TR_RES_SOUND)
{
vp[vn++] = "sound";
}
- if (f2 & (TR2_RES_SHARDS))
+ if (flags & TR_RES_SHARDS)
{
vp[vn++] = "shards";
}
- if ((f2 & (TR2_RES_NETHER)) && !(f4 & (TR4_IM_NETHER)))
+ if ((flags & TR_RES_NETHER) && !(flags & TR_IM_NETHER))
{
vp[vn++] = "nether";
}
- if (f2 & (TR2_RES_NEXUS))
+ if (flags & TR_RES_NEXUS)
{
vp[vn++] = "nexus";
}
- if (f2 & (TR2_RES_CHAOS))
+ if (flags & TR_RES_CHAOS)
{
vp[vn++] = "chaos";
}
- if (f2 & (TR2_RES_DISEN))
+ if (flags & TR_RES_DISEN)
{
vp[vn++] = "disenchantment";
}
@@ -3211,61 +3207,65 @@ bool_ object_out_desc(object_type *o_ptr, FILE *fff, bool_ trim_down, bool_ wait
text_out(". ");
}
- if (f2 & (TR2_SENS_FIRE))
+ if (flags & TR_SENS_FIRE)
{
text_out("It renders you especially vulnerable to fire. ");
}
- if (f3 & (TR3_WRAITH))
+ if (flags & TR_WRAITH)
{
text_out("It renders you incorporeal. ");
}
- if (f5 & (TR5_WATER_BREATH))
+ if (flags & TR_WATER_BREATH)
{
text_out("It allows you to breathe underwater. ");
}
- if (f5 & (TR5_MAGIC_BREATH))
+ if (flags & TR_MAGIC_BREATH)
{
text_out("It allows you to breathe without air. ");
}
- if (f3 & (TR3_FEATHER))
+ if (flags & TR_FEATHER)
{
text_out("It allows you to levitate. ");
}
- if (f4 & (TR4_FLY))
+ if (flags & TR_FLY)
{
text_out("It allows you to fly. ");
}
- if (f4 & (TR4_CLIMB))
+ if (flags & TR_CLIMB)
{
text_out("It allows you to climb mountains. ");
}
- if (f5 & (TR5_IMMOVABLE))
+ if (flags & TR_IMMOVABLE)
{
text_out("It renders you immovable. ");
}
- if (f3 & (TR3_SEE_INVIS))
+ if (flags & TR_SEE_INVIS)
{
text_out("It allows you to see invisible monsters. ");
}
- if (esp)
+
+ // ESP_*
{
- if (esp & ESP_ALL) text_out("It gives telepathic powers. ");
+ if (flags & ESP_ALL)
+ {
+ text_out("It gives telepathic powers. ");
+ }
else
{
vn = 0;
- if (esp & ESP_ORC) vp[vn++] = "orcs";
- if (esp & ESP_TROLL) vp[vn++] = "trolls";
- if (esp & ESP_DRAGON) vp[vn++] = "dragons";
- if (esp & ESP_SPIDER) vp[vn++] = "spiders";
- if (esp & ESP_GIANT) vp[vn++] = "giants";
- if (esp & ESP_DEMON) vp[vn++] = "demons";
- if (esp & ESP_UNDEAD) vp[vn++] = "undead";
- if (esp & ESP_EVIL) vp[vn++] = "evil beings";
- if (esp & ESP_ANIMAL) vp[vn++] = "animals";
- if (esp & ESP_THUNDERLORD) vp[vn++] = "thunderlords";
- if (esp & ESP_GOOD) vp[vn++] = "good beings";
- if (esp & ESP_NONLIVING) vp[vn++] = "non-living things";
- if (esp & ESP_UNIQUE) vp[vn++] = "unique beings";
+ if (flags & ESP_ORC) vp[vn++] = "orcs";
+ if (flags & ESP_TROLL) vp[vn++] = "trolls";
+ if (flags & ESP_DRAGON) vp[vn++] = "dragons";
+ if (flags & ESP_SPIDER) vp[vn++] = "spiders";
+ if (flags & ESP_GIANT) vp[vn++] = "giants";
+ if (flags & ESP_DEMON) vp[vn++] = "demons";
+ if (flags & ESP_UNDEAD) vp[vn++] = "undead";
+ if (flags & ESP_EVIL) vp[vn++] = "evil beings";
+ if (flags & ESP_ANIMAL) vp[vn++] = "animals";
+ if (flags & ESP_THUNDERLORD) vp[vn++] = "thunderlords";
+ if (flags & ESP_GOOD) vp[vn++] = "good beings";
+ if (flags & ESP_NONLIVING) vp[vn++] = "non-living things";
+ if (flags & ESP_UNIQUE) vp[vn++] = "unique beings";
/* Describe */
if (vn)
{
@@ -3290,55 +3290,55 @@ bool_ object_out_desc(object_type *o_ptr, FILE *fff, bool_ trim_down, bool_ wait
}
}
- if (f3 & (TR3_SLOW_DIGEST))
+ if (flags & TR_SLOW_DIGEST)
{
text_out("It slows your metabolism. ");
}
- if (f3 & (TR3_REGEN))
+ if (flags & TR_REGEN)
{
text_out("It speeds your regenerative powers. ");
}
- if (f2 & (TR2_REFLECT))
+ if (flags & TR_REFLECT)
{
text_out("It reflects bolts and arrows. ");
}
- if (f3 & (TR3_SH_FIRE))
+ if (flags & TR_SH_FIRE)
{
text_out("It produces a fiery sheath. ");
}
- if (f3 & (TR3_SH_ELEC))
+ if (flags & TR_SH_ELEC)
{
text_out("It produces an electric sheath. ");
}
- if (f3 & (TR3_NO_MAGIC))
+ if (flags & TR_NO_MAGIC)
{
text_out("It produces an anti-magic shell. ");
}
- if (f3 & (TR3_NO_TELE))
+ if (flags & TR_NO_TELE)
{
text_out("It prevents teleportation. ");
}
- if (f3 & (TR3_XTRA_MIGHT))
+ if (flags & TR_XTRA_MIGHT)
{
text_out("It fires missiles with extra might. ");
}
- if (f3 & (TR3_XTRA_SHOTS))
+ if (flags & TR_XTRA_SHOTS)
{
text_out("It fires missiles excessively fast. ");
}
vn = 0;
- if (f5 & (TR5_DRAIN_MANA))
+ if (flags & TR_DRAIN_MANA)
{
vc[vn] = TERM_BLUE;
vp[vn++] = "mana";
}
- if (f5 & (TR5_DRAIN_HP))
+ if (flags & TR_DRAIN_HP)
{
vc[vn] = TERM_RED;
vp[vn++] = "life";
}
- if (f3 & (TR3_DRAIN_EXP))
+ if (flags & TR_DRAIN_EXP)
{
vc[vn] = TERM_L_DARK;
vp[vn++] = "experience";
@@ -3365,38 +3365,38 @@ bool_ object_out_desc(object_type *o_ptr, FILE *fff, bool_ trim_down, bool_ wait
text_out(". ");
}
- if (f3 & (TR3_BLESSED))
+ if (flags & TR_BLESSED)
{
text_out("It has been blessed by the gods. ");
}
- if (f4 & (TR4_AUTO_ID))
+ if (flags & TR_AUTO_ID)
{
text_out("It identifies all items for you. ");
}
- if (f3 & (TR3_TELEPORT))
+ if (flags & TR_TELEPORT)
{
text_out("It induces random teleportation. ");
}
- if (f3 & (TR3_AGGRAVATE))
+ if (flags & TR_AGGRAVATE)
{
text_out("It aggravates nearby creatures. ");
}
- if (f4 & (TR4_NEVER_BLOW))
+ if (flags & TR_NEVER_BLOW)
{
text_out("It can't attack. ");
}
- if (f4 & (TR4_BLACK_BREATH))
+ if (flags & TR_BLACK_BREATH)
{
text_out("It fills you with the Black Breath. ");
}
if (cursed_p(o_ptr))
{
- if (f3 & (TR3_PERMA_CURSE))
+ if (flags & TR_PERMA_CURSE)
{
text_out("It is permanently cursed. ");
}
- else if (f3 & (TR3_HEAVY_CURSE))
+ else if (flags & TR_HEAVY_CURSE)
{
text_out("It is heavily cursed. ");
}
@@ -3405,68 +3405,68 @@ bool_ object_out_desc(object_type *o_ptr, FILE *fff, bool_ trim_down, bool_ wait
text_out("It is cursed. ");
}
}
- if (f3 & (TR3_TY_CURSE))
+ if (flags & TR_TY_CURSE)
{
text_out("It carries an ancient foul curse. ");
}
- if (f4 & (TR4_DG_CURSE))
+ if (flags & TR_DG_CURSE)
{
text_out("It carries an ancient Morgothian curse. ");
}
- if (f4 & (TR4_CLONE))
+ if (flags & TR_CLONE)
{
text_out("It can clone monsters. ");
}
- if (f4 & (TR4_CURSE_NO_DROP))
+ if (flags & TR_CURSE_NO_DROP)
{
text_out("It cannot be dropped while cursed. ");
}
- if (f3 & (TR3_AUTO_CURSE))
+ if (flags & TR_AUTO_CURSE)
{
text_out("It can re-curse itself. ");
}
- if (f4 & (TR4_CAPACITY))
+ if (flags & TR_CAPACITY)
{
text_out("It can hold more mana. ");
}
- if (f4 & (TR4_CHEAPNESS))
+ if (flags & TR_CHEAPNESS)
{
text_out("It can cast spells for a lesser mana cost. ");
}
- if (f4 & (TR4_FAST_CAST))
+ if (flags & TR_FAST_CAST)
{
text_out("It can cast spells faster. ");
}
- if (f4 & (TR4_CHARGING))
+ if (flags & TR_CHARGING)
{
text_out("It regenerates its mana faster. ");
}
- if (f5 & (TR5_RES_MORGUL))
+ if (flags & TR_RES_MORGUL)
{
text_out("It can resist being shattered by morgul beings. ");
}
- if ((f3 & (TR3_IGNORE_ACID)) && (f3 & (TR3_IGNORE_FIRE)) && (f3 & (TR3_IGNORE_COLD)) && (f3 & (TR3_IGNORE_ELEC)))
+ if ((flags & TR_IGNORE_ACID) && (flags & TR_IGNORE_FIRE) && (flags & TR_IGNORE_COLD) && (flags & TR_IGNORE_ELEC))
{
text_out("It cannot be harmed by acid, cold, lightning or fire. ");
}
else
{
- if (f3 & (TR3_IGNORE_ACID))
+ if (flags & TR_IGNORE_ACID)
{
text_out("It cannot be harmed by acid. ");
}
- if (f3 & (TR3_IGNORE_ELEC))
+ if (flags & TR_IGNORE_ELEC)
{
text_out("It cannot be harmed by electricity. ");
}
- if (f3 & (TR3_IGNORE_FIRE))
+ if (flags & TR_IGNORE_FIRE)
{
text_out("It cannot be harmed by fire. ");
}
- if (f3 & (TR3_IGNORE_COLD))
+ if (flags & TR_IGNORE_COLD)
{
text_out("It cannot be harmed by cold. ");
}
@@ -4162,7 +4162,7 @@ byte get_item_letter_color(object_type const *o_ptr)
if (ego_item_p(o_ptr)) color = TERM_L_BLUE;
if (artifact_p(o_ptr)) color = TERM_YELLOW;
if (o_ptr->name1 && ( -1 != a_info[o_ptr->name1].set)) color = TERM_GREEN;
- if (o_ptr->name1 && (a_info[o_ptr->name1].flags4 & TR4_ULTIMATE) && (o_ptr->ident & (IDENT_MENTAL))) color = TERM_VIOLET;
+ if (o_ptr->name1 && (a_info[o_ptr->name1].flags & TR_ULTIMATE) && (o_ptr->ident & (IDENT_MENTAL))) color = TERM_VIOLET;
return (color);
}
@@ -4415,7 +4415,6 @@ void show_equip_aux(bool_ mirror, bool_ everything, object_filter_t const &filte
!o_ptr->k_idx &&
p_ptr->inventory[i - INVEN_ARM + INVEN_WIELD].k_idx)
{
- u32b f1, f2, f3, f4, f5, esp;
object_type *q_ptr = &p_ptr->inventory[i - INVEN_ARM + INVEN_WIELD];
char q_name[80];
@@ -4423,9 +4422,9 @@ void show_equip_aux(bool_ mirror, bool_ everything, object_filter_t const &filte
object_desc(q_name, q_ptr, TRUE, 3);
/* Get weapon flags */
- object_flags(q_ptr, &f1, &f2, &f3, &f4, &f5, &esp);
+ auto const flags = object_flags(q_ptr);
- if (f4 & TR4_MUST2H)
+ if (flags & TR_MUST2H)
{
sprintf(o_name, "(two handed) %s", q_name);
@@ -6082,120 +6081,79 @@ static void gain_flag_group(object_type *o_ptr)
}
}
-static u32b get_flag(object_type *o_ptr, int grp, int k)
+static object_flag_set get_flag(object_type *o_ptr, int grp)
{
- u32b f = 0, flag_set = 0;
int tries = 1000;
- u32b f1, f2, f3, f4, f5, esp, flag_test;
-
- /* Extract some flags */
- object_flags(o_ptr, &f1, &f2, &f3, &f4, &f5, &esp);
/* get the corresponding flag set of the group */
- switch (k)
- {
- case 0:
- flag_set = flags_groups()[grp].flags1;
- flag_test = f1;
- break;
- case 1:
- flag_set = flags_groups()[grp].flags2;
- flag_test = f2;
- break;
- case 2:
- flag_set = flags_groups()[grp].flags3;
- flag_test = f3;
- break;
- case 3:
- flag_set = flags_groups()[grp].flags4;
- flag_test = f4;
- break;
- case 4:
- flag_set = flags_groups()[grp].esp;
- flag_test = esp;
- break;
- default:
- flag_set = flags_groups()[grp].flags1;
- flag_test = f1;
- break;
- }
+ auto const flag_set = flags_groups()[grp].flags;
+ auto const flag_test = object_flags(o_ptr);
/* If no flags, no need to look */
- if (!count_bits(flag_set)) return 0;
+ if (flag_set.empty())
+ {
+ return object_flag_set();
+ }
while (tries--)
{
- /* get a random flag */
- f = BIT(rand_int(32));
+ // Choose a random flag
+ auto const f = object_flag_set::make_bit(rand_int(object_flag_set::nbits));
- /* is it part of the group */
- if (!(f & flag_set)) continue;
+ // Ignore if not part of the group
+ if (!(f & flag_set))
+ {
+ continue;
+ }
- /* Already got it */
- if (f & flag_test) continue;
+ // Ignore if already present
+ if (f & flag_test)
+ {
+ continue;
+ }
- /* Ok one */
- break;
+ // Got a match!
+ return f;
}
- if (tries <= 1) return (0);
- else return (f);
+ // Exhausted the number of tries
+ return object_flag_set();
}
/* Add a flags from a flag group */
static void gain_flag_group_flag(object_type *o_ptr)
{
- int grp = 0, k = 0;
- u32b f = 0;
- int tries = 20000;
-
- if (!count_bits(o_ptr->pval3)) return;
-
- while (tries--)
+ // Try a "few" times to see if we can't find a flag.
+ for (int tries = 20000; tries > 0; tries--)
{
- /* Get a flag set */
- k = rand_int(5);
-
- /* get a flag group */
- grp = rand_int(flags_groups().size());
-
- if (!(BIT(grp) & o_ptr->pval3)) continue;
+ // Choose a random flag group
+ auto grp = rand_int(flags_groups().size());
- /* Return a flag from the group/set */
- f = get_flag(o_ptr, grp, k);
+ // If that group isn't available to the object, then choose a new one.
+ if (!(BIT(grp) & o_ptr->pval3))
+ {
+ continue;
+ }
- if (!f) continue;
+ // Get an as-yet unused flag from the group, if possible.
+ auto const f = get_flag(o_ptr, grp);
- break;
- }
+ // If we couldn't find a flag, then we try again.
+ if (f.empty())
+ {
+ continue;
+ }
- if (tries <= 1) return;
+ // Got a flag; mix it into the object.
+ o_ptr->art_flags |= f;
- switch (k)
- {
- case 0:
- o_ptr->art_flags1 |= f;
- break;
- case 1:
- o_ptr->art_flags2 |= f;
- break;
- case 2:
- o_ptr->art_flags3 |= f;
- break;
- case 3:
- o_ptr->art_flags4 |= f;
- break;
- case 4:
- o_ptr->art_esp |= f;
- break;
- }
-
- /* Message */
- {
+ // Describe what happened
char o_name[80];
-
object_desc(o_name, o_ptr, FALSE, 0);
msg_format("%s gains a new power from the %s realm.", o_name, flags_groups()[grp].name);
+
+ // We're done.
+ return;
}
}
@@ -6204,11 +6162,6 @@ static void gain_flag_group_flag(object_type *o_ptr)
*/
void object_gain_level(object_type *o_ptr)
{
- u32b f1, f2, f3, f4, f5, esp;
-
- /* Extract some flags */
- object_flags(o_ptr, &f1, &f2, &f3, &f4, &f5, &esp);
-
/* First it can gain some tohit and todam */
if ((o_ptr->tval == TV_AXE) || (o_ptr->tval == TV_SWORD) || (o_ptr->tval == TV_POLEARM) ||
(o_ptr->tval == TV_HAFTED) || (o_ptr->tval == TV_MSTAFF))
@@ -6231,16 +6184,31 @@ void object_gain_level(object_type *o_ptr)
}
else
{
- if (!o_ptr->pval3) gain_flag_group(o_ptr);
+ // Gain a group if none are available.
+ if (!o_ptr->pval3)
+ {
+ gain_flag_group(o_ptr);
+ }
+ // Gain a flag
gain_flag_group_flag(o_ptr);
- if (!o_ptr->pval) o_ptr->pval = 1;
+ // Increase/grant PVAL
+ if (!o_ptr->pval)
+ {
+ o_ptr->pval = 1;
+ }
else
{
- while (magik(20 - (o_ptr->pval * 2))) o_ptr->pval++;
+ while (magik(20 - (o_ptr->pval * 2)))
+ {
+ o_ptr->pval++;
+ }
- if (o_ptr->pval > 5) o_ptr->pval = 5;
+ if (o_ptr->pval > 5)
+ {
+ o_ptr->pval = 5;
+ }
}
}
}
@@ -6301,40 +6269,42 @@ bool_ takeoff_set(s16b a_idx, s16b set_idx)
return (FALSE);
}
-bool_ apply_set(s16b a_idx, s16b set_idx)
+void apply_set(s16b a_idx, s16b set_idx)
{
set_type *s_ptr = &set_info[set_idx];
- int i, j;
- if ( -1 == a_info[a_idx].set) return (FALSE);
+ if ( -1 == a_info[a_idx].set)
+ {
+ return;
+ }
+
+ int i;
for (i = 0; i < s_ptr->num; i++)
+ {
if (a_idx == s_ptr->arts[i].a_idx) break;
+ }
+
if (s_ptr->arts[i].present)
{
- for (j = 0; j < s_ptr->num_use; j++)
+ for (int j = 0; j < s_ptr->num_use; j++)
{
- apply_flags(s_ptr->arts[i].flags1[j],
- s_ptr->arts[i].flags2[j],
- s_ptr->arts[i].flags3[j],
- s_ptr->arts[i].flags4[j],
- s_ptr->arts[i].flags5[j],
- s_ptr->arts[i].esp[j],
+ apply_flags(s_ptr->arts[i].flags[j],
s_ptr->arts[i].pval[j],
0, 0, 0, 0);
}
- return (TRUE);
}
- return (FALSE);
}
-static bool_ apply_flags_set(s16b a_idx, s16b set_idx,
- u32b *f1, u32b *f2, u32b *f3, u32b *f4, u32b *f5, u32b *esp)
+static void apply_flags_set(s16b a_idx, s16b set_idx, object_flag_set *f)
{
- set_type *s_ptr = &set_info[set_idx];
- int i, j;
+ if ( -1 == a_info[a_idx].set)
+ {
+ return;
+ }
- if ( -1 == a_info[a_idx].set) return (FALSE);
+ set_type *s_ptr = &set_info[set_idx];
+ int i;
for (i = 0; i < s_ptr->num; i++)
{
if (a_idx == s_ptr->arts[i].a_idx) break;
@@ -6342,18 +6312,11 @@ static bool_ apply_flags_set(s16b a_idx, s16b set_idx,
if (s_ptr->arts[i].present)
{
- for (j = 0; j < s_ptr->num_use; j++)
+ for (int j = 0; j < s_ptr->num_use; j++)
{
- (*f1) |= s_ptr->arts[i].flags1[j];
- (*f2) |= s_ptr->arts[i].flags2[j];
- (*f3) |= s_ptr->arts[i].flags3[j];
- (*f4) |= s_ptr->arts[i].flags4[j];
- (*f5) |= s_ptr->arts[i].flags5[j];
- (*esp) |= s_ptr->arts[i].esp[j];
+ (*f) |= s_ptr->arts[i].flags[j];
}
- return (TRUE);
}
- return (FALSE);
}
/*
@@ -6433,7 +6396,7 @@ bool artifact_p(object_type const *o_ptr)
(o_ptr->tval == TV_RANDART) ||
(o_ptr->name1 ? true : false) ||
(o_ptr->art_name ? true : false) ||
- ((k_info[o_ptr->k_idx].flags3 & TR3_NORM_ART) ? true : false);
+ ((k_info[o_ptr->k_idx].flags & TR_NORM_ART) ? true : false);
}
/**
diff --git a/src/object1.hpp b/src/object1.hpp
index da4a6ead..af055985 100644
--- a/src/object1.hpp
+++ b/src/object1.hpp
@@ -2,6 +2,7 @@
#include "h-basic.h"
#include "object_filter.hpp"
+#include "object_flag_set.hpp"
#include <boost/optional.hpp>
#include <functional>
@@ -10,7 +11,7 @@ typedef std::function<boost::optional<int>(object_filter_t const &filter)> selec
extern byte get_item_letter_color(object_type const *o_ptr);
extern void object_pickup(int this_o_idx);
-extern bool_ apply_set(s16b a_idx, s16b set_idx);
+extern void apply_set(s16b a_idx, s16b set_idx);
extern bool_ takeoff_set(s16b a_idx, s16b set_idx);
extern bool_ wield_set(s16b a_idx, s16b set_idx, bool_ silent);
extern bool_ verify(cptr prompt, int item);
@@ -18,8 +19,9 @@ extern void flavor_init(void);
extern void reset_visuals(void);
extern int object_power(object_type *o_ptr);
extern bool_ object_flags_no_set;
-extern void object_flags(object_type const *o_ptr, u32b *f1, u32b *f2, u32b *f3, u32b *f4, u32b *f5, u32b *esp);
-extern void object_flags_known(object_type const *o_ptr, u32b *f1, u32b *f2, u32b *f3, u32b *f4, u32b *f5, u32b *esp);
+extern object_flag_set object_flags(object_type const *o_ptr);
+extern object_flag_set object_flags_known(object_type const *o_ptr);
+
extern s32b calc_object_need_exp(object_type const *o_ptr);
extern void object_desc(char *buf, object_type const *o_ptr, int pref, int mode);
extern void object_desc_store(char *buf, object_type *o_ptr, int pref, int mode);
diff --git a/src/object2.cc b/src/object2.cc
index d9c0b5f7..f6b526f6 100644
--- a/src/object2.cc
+++ b/src/object2.cc
@@ -24,6 +24,8 @@
#include "monster_race_flag.hpp"
#include "monster_type.hpp"
#include "object1.hpp"
+#include "object_flag.hpp"
+#include "object_flag_meta.hpp"
#include "object_kind.hpp"
#include "object_type.hpp"
#include "options.hpp"
@@ -315,7 +317,7 @@ void compact_objects(int size)
continue;
/* That's 400 + level for fixed artifacts */
- if ( (k_ptr->flags3 & TR3_NORM_ART) && cur_lev < 400 + k_ptr->level )
+ if ( (k_ptr->flags & TR_NORM_ART) && cur_lev < 400 + k_ptr->level )
continue;
/* Never protect if level is high enough; so we don't wipe a better artifact */
@@ -393,7 +395,7 @@ void wipe_o_list(void)
{
random_artifacts[o_ptr->sval].generated = FALSE;
}
- else if (k_info[o_ptr->k_idx].flags3 & TR3_NORM_ART)
+ else if (k_info[o_ptr->k_idx].flags & TR_NORM_ART)
{
k_info[o_ptr->k_idx].artifact = FALSE;
}
@@ -826,139 +828,140 @@ static s32b object_value_base(object_type const *o_ptr)
}
/* Return the value of the flags the object has... */
-s32b flag_cost(object_type const * o_ptr, int plusses)
+s32b flag_cost(object_type const *o_ptr, int plusses)
{
- s32b total = 0;
- u32b f1, f2, f3, f4, f5, esp;
-
- object_flags(o_ptr, &f1, &f2, &f3, &f4, &f5, &esp);
+ auto const flags = object_flags(o_ptr);
- if (f5 & TR5_TEMPORARY)
+ if (flags & TR_TEMPORARY)
{
return 0;
}
- if (f4 & TR4_CURSE_NO_DROP)
+
+ if (flags & TR_CURSE_NO_DROP)
{
return 0;
}
- if (f1 & TR1_STR) total += (1000 * plusses);
- if (f1 & TR1_INT) total += (1000 * plusses);
- if (f1 & TR1_WIS) total += (1000 * plusses);
- if (f1 & TR1_DEX) total += (1000 * plusses);
- if (f1 & TR1_CON) total += (1000 * plusses);
- if (f1 & TR1_CHR) total += (250 * plusses);
- if (f1 & TR1_CHAOTIC) total += 10000;
- if (f1 & TR1_VAMPIRIC) total += 13000;
- if (f1 & TR1_STEALTH) total += (250 * plusses);
- if (f1 & TR1_SEARCH) total += (100 * plusses);
- if (f1 & TR1_INFRA) total += (150 * plusses);
- if (f1 & TR1_TUNNEL) total += (175 * plusses);
- if ((f1 & TR1_SPEED) && (plusses > 0))
+
+ s32b total = 0;
+
+ if (flags & TR_STR) total += (1000 * plusses);
+ if (flags & TR_INT) total += (1000 * plusses);
+ if (flags & TR_WIS) total += (1000 * plusses);
+ if (flags & TR_DEX) total += (1000 * plusses);
+ if (flags & TR_CON) total += (1000 * plusses);
+ if (flags & TR_CHR) total += (250 * plusses);
+ if (flags & TR_CHAOTIC) total += 10000;
+ if (flags & TR_VAMPIRIC) total += 13000;
+ if (flags & TR_STEALTH) total += (250 * plusses);
+ if (flags & TR_SEARCH) total += (100 * plusses);
+ if (flags & TR_INFRA) total += (150 * plusses);
+ if (flags & TR_TUNNEL) total += (175 * plusses);
+ if ((flags & TR_SPEED) && (plusses > 0))
total += (10000 + (2500 * plusses));
- if ((f1 & TR1_BLOWS) && (plusses > 0))
+ if ((flags & TR_BLOWS) && (plusses > 0))
total += (10000 + (2500 * plusses));
- if (f1 & TR1_MANA) total += (1000 * plusses);
- if (f1 & TR1_SPELL) total += (2000 * plusses);
- if (f1 & TR1_SLAY_ANIMAL) total += 3500;
- if (f1 & TR1_SLAY_EVIL) total += 4500;
- if (f1 & TR1_SLAY_UNDEAD) total += 3500;
- if (f1 & TR1_SLAY_DEMON) total += 3500;
- if (f1 & TR1_SLAY_ORC) total += 3000;
- if (f1 & TR1_SLAY_TROLL) total += 3500;
- if (f1 & TR1_SLAY_GIANT) total += 3500;
- if (f1 & TR1_SLAY_DRAGON) total += 3500;
- if (f5 & TR5_KILL_DEMON) total += 5500;
- if (f5 & TR5_KILL_UNDEAD) total += 5500;
- if (f1 & TR1_KILL_DRAGON) total += 5500;
- if (f1 & TR1_VORPAL) total += 5000;
- if (f1 & TR1_IMPACT) total += 5000;
- if (f1 & TR1_BRAND_POIS) total += 7500;
- if (f1 & TR1_BRAND_ACID) total += 7500;
- if (f1 & TR1_BRAND_ELEC) total += 7500;
- if (f1 & TR1_BRAND_FIRE) total += 5000;
- if (f1 & TR1_BRAND_COLD) total += 5000;
- if (f2 & TR2_SUST_STR) total += 850;
- if (f2 & TR2_SUST_INT) total += 850;
- if (f2 & TR2_SUST_WIS) total += 850;
- if (f2 & TR2_SUST_DEX) total += 850;
- if (f2 & TR2_SUST_CON) total += 850;
- if (f2 & TR2_SUST_CHR) total += 250;
- if (f2 & TR2_INVIS) total += 3000;
- if (f2 & TR2_LIFE) total += (5000 * plusses);
- if (f2 & TR2_IM_ACID) total += 10000;
- if (f2 & TR2_IM_ELEC) total += 10000;
- if (f2 & TR2_IM_FIRE) total += 10000;
- if (f2 & TR2_IM_COLD) total += 10000;
- if (f2 & TR2_SENS_FIRE) total -= 100;
- if (f2 & TR2_REFLECT) total += 10000;
- if (f2 & TR2_FREE_ACT) total += 4500;
- if (f2 & TR2_HOLD_LIFE) total += 8500;
- if (f2 & TR2_RES_ACID) total += 1250;
- if (f2 & TR2_RES_ELEC) total += 1250;
- if (f2 & TR2_RES_FIRE) total += 1250;
- if (f2 & TR2_RES_COLD) total += 1250;
- if (f2 & TR2_RES_POIS) total += 2500;
- if (f2 & TR2_RES_FEAR) total += 2500;
- if (f2 & TR2_RES_LITE) total += 1750;
- if (f2 & TR2_RES_DARK) total += 1750;
- if (f2 & TR2_RES_BLIND) total += 2000;
- if (f2 & TR2_RES_CONF) total += 2000;
- if (f2 & TR2_RES_SOUND) total += 2000;
- if (f2 & TR2_RES_SHARDS) total += 2000;
- if (f2 & TR2_RES_NETHER) total += 2000;
- if (f2 & TR2_RES_NEXUS) total += 2000;
- if (f2 & TR2_RES_CHAOS) total += 2000;
- if (f2 & TR2_RES_DISEN) total += 10000;
- if (f3 & TR3_SH_FIRE) total += 5000;
- if (f3 & TR3_SH_ELEC) total += 5000;
- if (f3 & TR3_DECAY) total += 0;
- if (f3 & TR3_NO_TELE) total += 2500;
- if (f3 & TR3_NO_MAGIC) total += 2500;
- if (f3 & TR3_WRAITH) total += 250000;
- if (f3 & TR3_TY_CURSE) total -= 15000;
- if (f3 & TR3_EASY_KNOW) total += 0;
- if (f3 & TR3_HIDE_TYPE) total += 0;
- if (f3 & TR3_SHOW_MODS) total += 0;
- if (f3 & TR3_INSTA_ART) total += 0;
- if (f3 & TR3_LITE1) total += 750;
- if (f4 & TR4_LITE2) total += 1250;
- if (f4 & TR4_LITE3) total += 2750;
- if (f3 & TR3_SEE_INVIS) total += 2000;
- if (esp) total += (12500 * count_bits(esp));
- if (f3 & TR3_SLOW_DIGEST) total += 750;
- if (f3 & TR3_REGEN) total += 2500;
- if (f3 & TR3_XTRA_MIGHT) total += 2250;
- if (f3 & TR3_XTRA_SHOTS) total += 10000;
- if (f3 & TR3_IGNORE_ACID) total += 100;
- if (f3 & TR3_IGNORE_ELEC) total += 100;
- if (f3 & TR3_IGNORE_FIRE) total += 100;
- if (f3 & TR3_IGNORE_COLD) total += 100;
- if (f3 & TR3_ACTIVATE) total += 100;
- if (f3 & TR3_DRAIN_EXP) total -= 12500;
- if (f3 & TR3_TELEPORT)
+ if (flags & TR_MANA) total += (1000 * plusses);
+ if (flags & TR_SPELL) total += (2000 * plusses);
+ if (flags & TR_SLAY_ANIMAL) total += 3500;
+ if (flags & TR_SLAY_EVIL) total += 4500;
+ if (flags & TR_SLAY_UNDEAD) total += 3500;
+ if (flags & TR_SLAY_DEMON) total += 3500;
+ if (flags & TR_SLAY_ORC) total += 3000;
+ if (flags & TR_SLAY_TROLL) total += 3500;
+ if (flags & TR_SLAY_GIANT) total += 3500;
+ if (flags & TR_SLAY_DRAGON) total += 3500;
+ if (flags & TR_KILL_DEMON) total += 5500;
+ if (flags & TR_KILL_UNDEAD) total += 5500;
+ if (flags & TR_KILL_DRAGON) total += 5500;
+ if (flags & TR_VORPAL) total += 5000;
+ if (flags & TR_IMPACT) total += 5000;
+ if (flags & TR_BRAND_POIS) total += 7500;
+ if (flags & TR_BRAND_ACID) total += 7500;
+ if (flags & TR_BRAND_ELEC) total += 7500;
+ if (flags & TR_BRAND_FIRE) total += 5000;
+ if (flags & TR_BRAND_COLD) total += 5000;
+ if (flags & TR_SUST_STR) total += 850;
+ if (flags & TR_SUST_INT) total += 850;
+ if (flags & TR_SUST_WIS) total += 850;
+ if (flags & TR_SUST_DEX) total += 850;
+ if (flags & TR_SUST_CON) total += 850;
+ if (flags & TR_SUST_CHR) total += 250;
+ if (flags & TR_INVIS) total += 3000;
+ if (flags & TR_LIFE) total += (5000 * plusses);
+ if (flags & TR_IM_ACID) total += 10000;
+ if (flags & TR_IM_ELEC) total += 10000;
+ if (flags & TR_IM_FIRE) total += 10000;
+ if (flags & TR_IM_COLD) total += 10000;
+ if (flags & TR_SENS_FIRE) total -= 100;
+ if (flags & TR_REFLECT) total += 10000;
+ if (flags & TR_FREE_ACT) total += 4500;
+ if (flags & TR_HOLD_LIFE) total += 8500;
+ if (flags & TR_RES_ACID) total += 1250;
+ if (flags & TR_RES_ELEC) total += 1250;
+ if (flags & TR_RES_FIRE) total += 1250;
+ if (flags & TR_RES_COLD) total += 1250;
+ if (flags & TR_RES_POIS) total += 2500;
+ if (flags & TR_RES_FEAR) total += 2500;
+ if (flags & TR_RES_LITE) total += 1750;
+ if (flags & TR_RES_DARK) total += 1750;
+ if (flags & TR_RES_BLIND) total += 2000;
+ if (flags & TR_RES_CONF) total += 2000;
+ if (flags & TR_RES_SOUND) total += 2000;
+ if (flags & TR_RES_SHARDS) total += 2000;
+ if (flags & TR_RES_NETHER) total += 2000;
+ if (flags & TR_RES_NEXUS) total += 2000;
+ if (flags & TR_RES_CHAOS) total += 2000;
+ if (flags & TR_RES_DISEN) total += 10000;
+ if (flags & TR_SH_FIRE) total += 5000;
+ if (flags & TR_SH_ELEC) total += 5000;
+ if (flags & TR_DECAY) total += 0;
+ if (flags & TR_NO_TELE) total += 2500;
+ if (flags & TR_NO_MAGIC) total += 2500;
+ if (flags & TR_WRAITH) total += 250000;
+ if (flags & TR_TY_CURSE) total -= 15000;
+ if (flags & TR_EASY_KNOW) total += 0;
+ if (flags & TR_HIDE_TYPE) total += 0;
+ if (flags & TR_SHOW_MODS) total += 0;
+ if (flags & TR_INSTA_ART) total += 0;
+ if (flags & TR_LITE1) total += 750;
+ if (flags & TR_LITE2) total += 1250;
+ if (flags & TR_LITE3) total += 2750;
+ if (flags & TR_SEE_INVIS) total += 2000;
+ total += 12500 * ((flags & object_flags_esp()).count());
+ if (flags & TR_SLOW_DIGEST) total += 750;
+ if (flags & TR_REGEN) total += 2500;
+ if (flags & TR_XTRA_MIGHT) total += 2250;
+ if (flags & TR_XTRA_SHOTS) total += 10000;
+ if (flags & TR_IGNORE_ACID) total += 100;
+ if (flags & TR_IGNORE_ELEC) total += 100;
+ if (flags & TR_IGNORE_FIRE) total += 100;
+ if (flags & TR_IGNORE_COLD) total += 100;
+ if (flags & TR_ACTIVATE) total += 100;
+ if (flags & TR_DRAIN_EXP) total -= 12500;
+ if (flags & TR_TELEPORT)
{
if (o_ptr->ident & IDENT_CURSED)
total -= 7500;
else
total += 250;
}
- if (f3 & TR3_AGGRAVATE) total -= 10000;
- if (f3 & TR3_BLESSED) total += 750;
- if ((f3 & TR3_CURSED) && (o_ptr->ident & IDENT_CURSED)) total -= 5000;
- if ((f3 & TR3_HEAVY_CURSE) && (o_ptr->ident & IDENT_CURSED)) total -= 12500;
- if (f3 & TR3_PERMA_CURSE) total -= 15000;
- if (f3 & TR3_FEATHER) total += 1250;
- if (f4 & TR4_FLY) total += 10000;
- if (f4 & TR4_NEVER_BLOW) total -= 15000;
- if (f4 & TR4_PRECOGNITION) total += 250000;
- if (f4 & TR4_BLACK_BREATH) total -= 12500;
- if (f4 & TR4_DG_CURSE) total -= 25000;
- if (f4 & TR4_CLONE) total -= 10000;
- if (f4 & TR4_LEVELS) total += o_ptr->elevel * 2000;
+ if (flags & TR_AGGRAVATE) total -= 10000;
+ if (flags & TR_BLESSED) total += 750;
+ if ((flags & TR_CURSED) && (o_ptr->ident & IDENT_CURSED)) total -= 5000;
+ if ((flags & TR_HEAVY_CURSE) && (o_ptr->ident & IDENT_CURSED)) total -= 12500;
+ if (flags & TR_PERMA_CURSE) total -= 15000;
+ if (flags & TR_FEATHER) total += 1250;
+ if (flags & TR_FLY) total += 10000;
+ if (flags & TR_NEVER_BLOW) total -= 15000;
+ if (flags & TR_PRECOGNITION) total += 250000;
+ if (flags & TR_BLACK_BREATH) total -= 12500;
+ if (flags & TR_DG_CURSE) total -= 25000;
+ if (flags & TR_CLONE) total -= 10000;
+ if (flags & TR_LEVELS) total += o_ptr->elevel * 2000;
/* Also, give some extra for activatable powers... */
- if ((o_ptr->art_name) && (o_ptr->art_flags3 & (TR3_ACTIVATE)))
+ if ((o_ptr->art_name) && (o_ptr->art_flags & TR_ACTIVATE))
{
int type = o_ptr->xtra2;
@@ -1066,8 +1069,6 @@ s32b object_value_real(object_type const *o_ptr)
{
s32b value;
- u32b f1, f2, f3, f4, f5, esp;
-
object_kind *k_ptr = &k_info[o_ptr->k_idx];
if (o_ptr->tval == TV_RANDART)
@@ -1082,11 +1083,11 @@ s32b object_value_real(object_type const *o_ptr)
value = k_ptr->cost;
/* Extract some flags */
- object_flags(o_ptr, &f1, &f2, &f3, &f4, &f5, &esp);
+ auto const flags = object_flags(o_ptr);
- if (f5 & TR5_TEMPORARY) return (0L);
+ if (flags & TR_TEMPORARY) return (0L);
- if (o_ptr->art_flags1 || o_ptr->art_flags2 || o_ptr->art_flags3)
+ if (o_ptr->art_flags)
{
value += flag_cost (o_ptr, o_ptr->pval);
}
@@ -1126,7 +1127,7 @@ s32b object_value_real(object_type const *o_ptr)
}
/* Pay the spell */
- if (f5 & TR5_SPELL_CONTAIN)
+ if (flags & TR_SPELL_CONTAIN)
{
if (o_ptr->pval2 != -1)
value += 5000 + 500 * spell_type_skill_level(spell_at(o_ptr->pval2));
@@ -1164,28 +1165,28 @@ s32b object_value_real(object_type const *o_ptr)
if (!o_ptr->pval) break;
/* Give credit for stat bonuses */
- if (f1 & (TR1_STR)) value += (o_ptr->pval * 200L);
- if (f1 & (TR1_INT)) value += (o_ptr->pval * 200L);
- if (f1 & (TR1_WIS)) value += (o_ptr->pval * 200L);
- if (f1 & (TR1_DEX)) value += (o_ptr->pval * 200L);
- if (f1 & (TR1_CON)) value += (o_ptr->pval * 200L);
- if (f1 & (TR1_CHR)) value += (o_ptr->pval * 200L);
+ if (flags & TR_STR) value += (o_ptr->pval * 200L);
+ if (flags & TR_INT) value += (o_ptr->pval * 200L);
+ if (flags & TR_WIS) value += (o_ptr->pval * 200L);
+ if (flags & TR_DEX) value += (o_ptr->pval * 200L);
+ if (flags & TR_CON) value += (o_ptr->pval * 200L);
+ if (flags & TR_CHR) value += (o_ptr->pval * 200L);
- if (f5 & (TR5_CRIT)) value += (o_ptr->pval * 500L);
+ if (flags & TR_CRIT) value += (o_ptr->pval * 500L);
/* Give credit for stealth and searching */
- if (f1 & (TR1_STEALTH)) value += (o_ptr->pval * 100L);
- if (f1 & (TR1_SEARCH)) value += (o_ptr->pval * 100L);
+ if (flags & TR_STEALTH) value += (o_ptr->pval * 100L);
+ if (flags & TR_SEARCH) value += (o_ptr->pval * 100L);
/* Give credit for infra-vision and tunneling */
- if (f1 & (TR1_INFRA)) value += (o_ptr->pval * 50L);
- if (f1 & (TR1_TUNNEL)) value += (o_ptr->pval * 50L);
+ if (flags & TR_INFRA) value += (o_ptr->pval * 50L);
+ if (flags & TR_TUNNEL) value += (o_ptr->pval * 50L);
/* Give credit for extra attacks */
- if (f1 & (TR1_BLOWS)) value += (o_ptr->pval * 2000L);
+ if (flags & TR_BLOWS) value += (o_ptr->pval * 2000L);
/* Give credit for speed bonus */
- if (f1 & (TR1_SPEED)) value += (o_ptr->pval * 30000L);
+ if (flags & TR_SPEED) value += (o_ptr->pval * 30000L);
break;
}
@@ -1435,17 +1436,15 @@ s32b object_value(object_type const *o_ptr)
bool_ object_similar(object_type const *o_ptr, object_type const *j_ptr)
{
int total = o_ptr->number + j_ptr->number;
- u32b f1, f2, f3, f4, f5, esp, f11, f12, f13, f14, esp1, f15;
/* Extract the flags */
- object_flags(o_ptr, &f1, &f2, &f3, &f4, &f5, &esp);
- object_flags(j_ptr, &f11, &f12, &f13, &f14, &f15, &esp1);
-
+ auto const o_flags = object_flags(o_ptr);
+ auto const j_flags = object_flags(j_ptr);
/* Require identical object types */
if (o_ptr->k_idx != j_ptr->k_idx) return (0);
- if ((f5 & TR5_SPELL_CONTAIN) || (f15 & TR5_SPELL_CONTAIN))
+ if ((o_flags & TR_SPELL_CONTAIN) || (j_flags & TR_SPELL_CONTAIN))
return FALSE;
/* Analyze the items */
@@ -1549,7 +1548,7 @@ bool_ object_similar(object_type const *o_ptr, object_type const *j_ptr)
if (o_ptr->pval != j_ptr->pval) return (0);
/* Do not combine recharged ones with non recharged ones. */
- if ((f4 & TR4_RECHARGED) != (f14 & TR4_RECHARGED)) return (0);
+ if ((o_flags & TR_RECHARGED) != (j_flags & TR_RECHARGED)) return (0);
/* Do not combine different spells */
if (o_ptr->pval2 != j_ptr->pval2) return (0);
@@ -1584,7 +1583,7 @@ bool_ object_similar(object_type const *o_ptr, object_type const *j_ptr)
if (o_ptr->name1 != j_ptr->name1) return (0);
/* Do not combine recharged ones with non recharged ones. */
- if ((f4 & TR4_RECHARGED) != (f14 & TR4_RECHARGED)) return (0);
+ if ((o_flags & TR_RECHARGED) != (j_flags & TR_RECHARGED)) return (0);
/* Do not combine different spells */
if (o_ptr->pval2 != j_ptr->pval2) return (0);
@@ -1724,10 +1723,10 @@ bool_ object_similar(object_type const *o_ptr, object_type const *j_ptr)
/* Hack -- Identical art_flags! */
- if ((o_ptr->art_flags1 != j_ptr->art_flags1) ||
- (o_ptr->art_flags2 != j_ptr->art_flags2) ||
- (o_ptr->art_flags3 != j_ptr->art_flags3))
+ if (o_ptr->art_flags != j_ptr->art_flags)
+ {
return (0);
+ }
/* Hack -- Require identical "cursed" status */
if ((o_ptr->ident & (IDENT_CURSED)) != (j_ptr->ident & (IDENT_CURSED))) return (0);
@@ -1829,6 +1828,17 @@ void object_copy(object_type *o_ptr, object_type *j_ptr)
/*
+ * Initialize the experience of an object which is a
+ * "sentient" object.
+ */
+static void init_obj_exp(object_type *o_ptr, object_kind const *k_ptr)
+{
+ o_ptr->elevel = (k_ptr->level / 10) + 1;
+ o_ptr->exp = player_exp[o_ptr->elevel - 1];
+}
+
+
+/*
* Prepare an object based on an object kind.
*/
void object_prep(object_type *o_ptr, int k_idx)
@@ -1866,13 +1876,15 @@ void object_prep(object_type *o_ptr, int k_idx)
o_ptr->ds = k_ptr->ds;
/* Hack -- cursed items are always "cursed" */
- if (k_ptr->flags3 & (TR3_CURSED)) o_ptr->ident |= (IDENT_CURSED);
+ if (k_ptr->flags & TR_CURSED)
+ {
+ o_ptr->ident |= (IDENT_CURSED);
+ }
/* Hack give a basic exp/exp level to an object that needs it */
- if (k_ptr->flags4 & TR4_LEVELS)
+ if (k_ptr->flags & TR_LEVELS)
{
- o_ptr->elevel = (k_ptr->level / 10) + 1;
- o_ptr->exp = player_exp[o_ptr->elevel - 1];
+ init_obj_exp(o_ptr, k_ptr);
o_ptr->pval2 = 1; /* Start with one point */
o_ptr->pval3 = 0; /* No flags groups */
}
@@ -2043,45 +2055,41 @@ static void object_mention(object_type *o_ptr)
static void random_artifact_power(object_type *o_ptr)
{
// Shorthand
- auto f2 = &o_ptr->art_flags2;
- auto f3 = &o_ptr->art_flags3;
- auto esp = &o_ptr->art_esp;
+ auto flags = &o_ptr->art_flags;
// Choose ability
- auto try_choose = [&o_ptr, &f2, &f3, &esp](int choice) {
+ auto try_choose = [&o_ptr, &flags](int choice) {
switch (choice)
{
case 0:
- (*f3) |= (TR3_FEATHER);
+ (*flags) |= (TR_FEATHER);
break;
case 1:
- (*f3) |= (TR3_LITE1);
+ (*flags) |= (TR_LITE1);
break;
case 2:
- (*f3) |= (TR3_SEE_INVIS);
+ (*flags) |= (TR_SEE_INVIS);
break;
case 3:
- (*esp) |= (ESP_ALL);
+ (*flags) |= (ESP_ALL);
break;
case 4:
- (*f3) |= (TR3_SLOW_DIGEST);
+ (*flags) |= (TR_SLOW_DIGEST);
break;
case 5:
- (*f3) |= (TR3_REGEN);
+ (*flags) |= (TR_REGEN);
break;
case 6:
- (*f2) |= (TR2_FREE_ACT);
+ (*flags) |= (TR_FREE_ACT);
break;
case 7:
- (*f2) |= (TR2_HOLD_LIFE);
+ (*flags) |= (TR_HOLD_LIFE);
break;
}
};
// Save old values for comparison
- u32b const old_f2 = *f2;
- u32b const old_f3 = *f3;
- u32b const old_esp = *esp;
+ auto const old_flags = *flags;
// Choose an ability; make sure we choose one that isn't already chosen
for (int tries = 0; tries < 1000; tries++)
@@ -2090,8 +2098,8 @@ static void random_artifact_power(object_type *o_ptr)
int choice = rand_int(8);
try_choose(choice);
- // If there's any difference, then we chose a non-overlapping power.
- if ((*f2 != old_f2) || (*f3 != old_f3) || (*esp != old_esp))
+ // If there's any difference, then we've chosen a non-overlapping power.
+ if (*flags != old_flags)
{
break;
}
@@ -2100,12 +2108,12 @@ static void random_artifact_power(object_type *o_ptr)
void random_artifact_resistance(object_type * o_ptr)
{
- auto f5 = a_info[o_ptr->name1].flags5;
+ auto art_flags = a_info[o_ptr->name1].flags;
- // Check flags
- bool give_resistance = (f5 & TR5_RANDOM_RESIST);
- bool give_power = (f5 & TR5_RANDOM_POWER);
- if (f5 & TR5_RANDOM_RES_OR_POWER)
+ // Check flags of the 'protype' artifact
+ auto give_resistance = bool(art_flags & TR_RANDOM_RESIST);
+ auto give_power = bool(art_flags & TR_RANDOM_POWER);
+ if (art_flags & TR_RANDOM_RES_OR_POWER)
{
if (randint(2) == 1)
{
@@ -2127,15 +2135,15 @@ void random_artifact_resistance(object_type * o_ptr)
if (give_resistance)
{
- // Save resistance flags
- u32b const f2 = o_ptr->art_flags2;
+ // Save flags
+ auto const flags = o_ptr->art_flags;
// We'll be a little generous here and make sure that the object
// gets a resistance that it doesn't actually already have.
for (int tries = 0; tries < 1000; tries++)
{
random_resistance(o_ptr, randint(22) + 16);
// Picked up a new resistance?
- if (f2 != o_ptr->art_flags2)
+ if (flags != o_ptr->art_flags)
{
break;
}
@@ -2154,15 +2162,11 @@ void random_artifact_resistance(object_type * o_ptr)
*/
static bool_ make_artifact_special(object_type *o_ptr)
{
- int i;
- int k_idx = 0;
- u32b f1, f2, f3, f4, f5, esp;
-
/* No artifacts in the town */
if (!dun_level) return (FALSE);
/* Check the artifact list (just the "specials") */
- for (i = 0; i < max_a_idx; i++)
+ for (int i = 0; i < max_a_idx; i++)
{
artifact_type *a_ptr = &a_info[i];
@@ -2173,10 +2177,10 @@ static bool_ make_artifact_special(object_type *o_ptr)
if (a_ptr->cur_num) continue;
/* Cannot generate non special ones */
- if (!(a_ptr->flags3 & TR3_INSTA_ART)) continue;
+ if (!(a_ptr->flags & TR_INSTA_ART)) continue;
/* Cannot generate some artifacts because they can only exists in special dungeons/quests/... */
- if ((a_ptr->flags4 & TR4_SPECIAL_GENE) && (!a_allow_special[i])) continue;
+ if ((a_ptr->flags & TR_SPECIAL_GENE) && (!a_allow_special[i])) continue;
/* XXX XXX Enforce minimum "depth" (loosely) */
if (a_ptr->level > dun_level)
@@ -2192,7 +2196,7 @@ static bool_ make_artifact_special(object_type *o_ptr)
if (rand_int(a_ptr->rarity - luck( -(a_ptr->rarity / 2), a_ptr->rarity / 2)) != 0) continue;
/* Find the base object */
- k_idx = lookup_kind(a_ptr->tval, a_ptr->sval);
+ int k_idx = lookup_kind(a_ptr->tval, a_ptr->sval);
/* XXX XXX Enforce minimum "object" level (loosely) */
if (k_info[k_idx].level > object_level)
@@ -2211,13 +2215,12 @@ static bool_ make_artifact_special(object_type *o_ptr)
o_ptr->name1 = i;
/* Extract some flags */
- object_flags(o_ptr, &f1, &f2, &f3, &f4, &f5, &esp);
+ auto const flags = object_flags(o_ptr);
/* Hack give a basic exp/exp level to an object that needs it */
- if (f4 & TR4_LEVELS)
+ if (flags & TR_LEVELS)
{
- o_ptr->elevel = (k_info[k_idx].level / 10) + 1;
- o_ptr->exp = player_exp[o_ptr->elevel - 1];
+ init_obj_exp(o_ptr, &k_info[k_idx]);
}
/* Success */
@@ -2238,10 +2241,6 @@ static bool_ make_artifact_special(object_type *o_ptr)
*/
static bool_ make_artifact(object_type *o_ptr)
{
- int i;
- u32b f1, f2, f3, f4, f5, esp;
- object_kind *k_ptr = &k_info[o_ptr->k_idx];
-
/* No artifacts in the town */
if (!dun_level) return (FALSE);
@@ -2249,7 +2248,7 @@ static bool_ make_artifact(object_type *o_ptr)
if (o_ptr->number != 1) return (FALSE);
/* Check the artifact list (skip the "specials") */
- for (i = 0; i < max_a_idx; i++)
+ for (int i = 0; i < max_a_idx; i++)
{
artifact_type *a_ptr = &a_info[i];
@@ -2260,10 +2259,10 @@ static bool_ make_artifact(object_type *o_ptr)
if (a_ptr->cur_num) continue;
/* Cannot generate special ones */
- if (a_ptr->flags3 & TR3_INSTA_ART) continue;
+ if (a_ptr->flags & TR_INSTA_ART) continue;
/* Cannot generate some artifacts because they can only exists in special dungeons/quests/... */
- if ((a_ptr->flags4 & TR4_SPECIAL_GENE) && (!a_allow_special[i])) continue;
+ if ((a_ptr->flags & TR_SPECIAL_GENE) && (!a_allow_special[i])) continue;
/* Must have the correct fields */
if (a_ptr->tval != o_ptr->tval) continue;
@@ -2289,13 +2288,12 @@ static bool_ make_artifact(object_type *o_ptr)
random_artifact_resistance(o_ptr);
/* Extract some flags */
- object_flags(o_ptr, &f1, &f2, &f3, &f4, &f5, &esp);
+ auto const flags = object_flags(o_ptr);
/* Hack give a basic exp/exp level to an object that needs it */
- if (f4 & TR4_LEVELS)
+ if (flags & TR_LEVELS)
{
- o_ptr->elevel = (k_ptr->level / 10) + 1;
- o_ptr->exp = player_exp[o_ptr->elevel - 1];
+ init_obj_exp(o_ptr, &k_info[o_ptr->k_idx]);
}
/* Success */
@@ -2350,19 +2348,9 @@ static bool_ make_ego_item(object_type *o_ptr, bool_ good)
if ((!good) && e_ptr->cost) continue;
/* Must posses the good flags */
- if (((k_ptr->flags1 & e_ptr->need_flags1) != e_ptr->need_flags1) ||
- ((k_ptr->flags2 & e_ptr->need_flags2) != e_ptr->need_flags2) ||
- ((k_ptr->flags3 & e_ptr->need_flags3) != e_ptr->need_flags3) ||
- ((k_ptr->flags4 & e_ptr->need_flags4) != e_ptr->need_flags4) ||
- ((k_ptr->flags5 & e_ptr->need_flags5) != e_ptr->need_flags5) ||
- ((k_ptr->esp & e_ptr->need_esp) != e_ptr->need_esp))
+ if ((k_ptr->flags & e_ptr->need_flags) != e_ptr->need_flags)
continue;
- if ((k_ptr->flags1 & e_ptr->forbid_flags1) ||
- (k_ptr->flags2 & e_ptr->forbid_flags2) ||
- (k_ptr->flags3 & e_ptr->forbid_flags3) ||
- (k_ptr->flags4 & e_ptr->forbid_flags4) ||
- (k_ptr->flags5 & e_ptr->forbid_flags5) ||
- (k_ptr->esp & e_ptr->forbid_esp))
+ if (k_ptr->flags & e_ptr->forbid_flags)
continue;
/* ok */
@@ -2569,7 +2557,9 @@ static void a_m_aux_1(object_type *o_ptr, int level, int power)
o_ptr->pval2 = randint(70) + (randint(70) << 8);
}
else
- o_ptr->art_flags5 |= (TR5_SPELL_CONTAIN | TR5_WIELD_CAST);
+ {
+ o_ptr->art_flags |= (TR_SPELL_CONTAIN | TR_WIELD_CAST);
+ }
break;
}
case TV_BOLT:
@@ -3085,8 +3075,8 @@ static void a_m_aux_3(object_type *o_ptr, int level, int power)
case SV_AMULET_RESISTANCE:
{
- if (randint(3) == 1) random_resistance(o_ptr, randint(34) + 4);
- if (randint(5) == 1) o_ptr->art_flags2 |= TR2_RES_POIS;
+ if (randint(3) == 1) random_resistance(o_ptr, randint(34) + 4);
+ if (randint(5) == 1) o_ptr->art_flags |= TR_RES_POIS;
}
break;
@@ -3113,7 +3103,7 @@ static void a_m_aux_3(object_type *o_ptr, int level, int power)
{
o_ptr->pval = 1 + m_bonus(3, level);
- if (randint(3) == 1) o_ptr->art_flags3 |= TR3_SLOW_DIGEST;
+ if (randint(3) == 1) o_ptr->art_flags |= TR_SLOW_DIGEST;
/* Boost the rating */
rating += 25;
@@ -3194,7 +3184,6 @@ static int get_stick_max_level(byte tval, int level, int spl)
*/
static void a_m_aux_4(object_type *o_ptr, int level, int power)
{
- u32b f1, f2, f3, f4, f5, esp;
s32b bonus_lvl, max_lvl;
object_kind *k_ptr = &k_info[o_ptr->k_idx];
@@ -3243,12 +3232,15 @@ static void a_m_aux_4(object_type *o_ptr, int level, int power)
case TV_LITE:
{
- object_flags(o_ptr, &f1, &f2, &f3, &f4, &f5, &esp);
+ auto const flags = object_flags(o_ptr);
/* Hack -- random fuel */
- if (f4 & TR4_FUEL_LITE)
+ if (flags & TR_FUEL_LITE)
{
- if (k_info[o_ptr->k_idx].pval2 > 0) o_ptr->timeout = randint(k_info[o_ptr->k_idx].pval2);
+ if (k_info[o_ptr->k_idx].pval2 > 0)
+ {
+ o_ptr->timeout = randint(k_info[o_ptr->k_idx].pval2);
+ }
}
break;
@@ -3471,22 +3463,22 @@ void add_random_ego_flag(object_type *o_ptr, int fego, bool_ *limit_blows)
switch (randint(6))
{
case 1:
- o_ptr->art_flags2 |= TR2_SUST_STR;
+ o_ptr->art_flags |= TR_SUST_STR;
break;
case 2:
- o_ptr->art_flags2 |= TR2_SUST_INT;
+ o_ptr->art_flags |= TR_SUST_INT;
break;
case 3:
- o_ptr->art_flags2 |= TR2_SUST_WIS;
+ o_ptr->art_flags |= TR_SUST_WIS;
break;
case 4:
- o_ptr->art_flags2 |= TR2_SUST_DEX;
+ o_ptr->art_flags |= TR_SUST_DEX;
break;
case 5:
- o_ptr->art_flags2 |= TR2_SUST_CON;
+ o_ptr->art_flags |= TR_SUST_CON;
break;
case 6:
- o_ptr->art_flags2 |= TR2_SUST_CHR;
+ o_ptr->art_flags |= TR_SUST_CHR;
break;
}
}
@@ -3497,37 +3489,37 @@ void add_random_ego_flag(object_type *o_ptr, int fego, bool_ *limit_blows)
switch (randint(11))
{
case 1:
- o_ptr->art_flags2 |= (TR2_RES_BLIND);
+ o_ptr->art_flags |= TR_RES_BLIND;
break;
case 2:
- o_ptr->art_flags2 |= (TR2_RES_CONF);
+ o_ptr->art_flags |= TR_RES_CONF;
break;
case 3:
- o_ptr->art_flags2 |= (TR2_RES_SOUND);
+ o_ptr->art_flags |= TR_RES_SOUND;
break;
case 4:
- o_ptr->art_flags2 |= (TR2_RES_SHARDS);
+ o_ptr->art_flags |= TR_RES_SHARDS;
break;
case 5:
- o_ptr->art_flags2 |= (TR2_RES_NETHER);
+ o_ptr->art_flags |= TR_RES_NETHER;
break;
case 6:
- o_ptr->art_flags2 |= (TR2_RES_NEXUS);
+ o_ptr->art_flags |= TR_RES_NEXUS;
break;
case 7:
- o_ptr->art_flags2 |= (TR2_RES_CHAOS);
+ o_ptr->art_flags |= TR_RES_CHAOS;
break;
case 8:
- o_ptr->art_flags2 |= (TR2_RES_DISEN);
+ o_ptr->art_flags |= TR_RES_DISEN;
break;
case 9:
- o_ptr->art_flags2 |= (TR2_RES_POIS);
+ o_ptr->art_flags |= TR_RES_POIS;
break;
case 10:
- o_ptr->art_flags2 |= (TR2_RES_DARK);
+ o_ptr->art_flags |= TR_RES_DARK;
break;
case 11:
- o_ptr->art_flags2 |= (TR2_RES_LITE);
+ o_ptr->art_flags |= TR_RES_LITE;
break;
}
}
@@ -3538,28 +3530,28 @@ void add_random_ego_flag(object_type *o_ptr, int fego, bool_ *limit_blows)
switch (randint(8))
{
case 1:
- o_ptr->art_flags3 |= (TR3_FEATHER);
+ o_ptr->art_flags |= TR_FEATHER;
break;
case 2:
- o_ptr->art_flags3 |= (TR3_LITE1);
+ o_ptr->art_flags |= TR_LITE1;
break;
case 3:
- o_ptr->art_flags3 |= (TR3_SEE_INVIS);
+ o_ptr->art_flags |= TR_SEE_INVIS;
break;
case 4:
- o_ptr->art_esp |= (ESP_ALL);
+ o_ptr->art_flags |= ESP_ALL;
break;
case 5:
- o_ptr->art_flags3 |= (TR3_SLOW_DIGEST);
+ o_ptr->art_flags |= TR_SLOW_DIGEST;
break;
case 6:
- o_ptr->art_flags3 |= (TR3_REGEN);
+ o_ptr->art_flags |= TR_REGEN;
break;
case 7:
- o_ptr->art_flags2 |= (TR2_FREE_ACT);
+ o_ptr->art_flags |= TR_FREE_ACT;
break;
case 8:
- o_ptr->art_flags2 |= (TR2_HOLD_LIFE);
+ o_ptr->art_flags |= TR_HOLD_LIFE;
break;
}
}
@@ -3613,11 +3605,11 @@ void add_random_ego_flag(object_type *o_ptr, int fego, bool_ *limit_blows)
}
if (randint(5) == 1)
{
- o_ptr->art_flags1 |= TR1_BRAND_POIS;
+ o_ptr->art_flags |= TR_BRAND_POIS;
}
if (o_ptr->tval == TV_SWORD && (randint(3) == 1))
{
- o_ptr->art_flags1 |= TR1_VORPAL;
+ o_ptr->art_flags |= TR_VORPAL;
}
}
@@ -3741,22 +3733,22 @@ void add_random_ego_flag(object_type *o_ptr, int fego, bool_ *limit_blows)
switch (randint(6))
{
case 1:
- o_ptr->art_flags1 |= TR1_STEALTH;
+ o_ptr->art_flags |= TR_STEALTH;
break;
case 2:
- o_ptr->art_flags1 |= TR1_SEARCH;
+ o_ptr->art_flags |= TR_SEARCH;
break;
case 3:
- o_ptr->art_flags1 |= TR1_INFRA;
+ o_ptr->art_flags |= TR_INFRA;
break;
case 4:
- o_ptr->art_flags1 |= TR1_TUNNEL;
+ o_ptr->art_flags |= TR_TUNNEL;
break;
case 5:
- o_ptr->art_flags1 |= TR1_SPEED;
+ o_ptr->art_flags |= TR_SPEED;
break;
case 6:
- o_ptr->art_flags1 |= TR1_BLOWS;
+ o_ptr->art_flags |= TR_BLOWS;
break;
}
}
@@ -3766,22 +3758,22 @@ void add_random_ego_flag(object_type *o_ptr, int fego, bool_ *limit_blows)
switch (randint(6))
{
case 1:
- o_ptr->art_flags1 |= TR1_STR;
+ o_ptr->art_flags |= TR_STR;
break;
case 2:
- o_ptr->art_flags1 |= TR1_INT;
+ o_ptr->art_flags |= TR_INT;
break;
case 3:
- o_ptr->art_flags1 |= TR1_WIS;
+ o_ptr->art_flags |= TR_WIS;
break;
case 4:
- o_ptr->art_flags1 |= TR1_DEX;
+ o_ptr->art_flags |= TR_DEX;
break;
case 5:
- o_ptr->art_flags1 |= TR1_CON;
+ o_ptr->art_flags |= TR_CON;
break;
case 6:
- o_ptr->art_flags1 |= TR1_CHR;
+ o_ptr->art_flags |= TR_CHR;
break;
}
}
@@ -3793,42 +3785,42 @@ void add_random_ego_flag(object_type *o_ptr, int fego, bool_ *limit_blows)
{
case 1:
{
- o_ptr->art_flags1 |= TR1_STR;
- o_ptr->art_flags2 |= TR2_SUST_STR;
+ o_ptr->art_flags |= TR_STR;
+ o_ptr->art_flags |= TR_SUST_STR;
break;
}
case 2:
{
- o_ptr->art_flags1 |= TR1_INT;
- o_ptr->art_flags2 |= TR2_SUST_INT;
+ o_ptr->art_flags |= TR_INT;
+ o_ptr->art_flags |= TR_SUST_INT;
break;
}
case 3:
{
- o_ptr->art_flags1 |= TR1_WIS;
- o_ptr->art_flags2 |= TR2_SUST_WIS;
+ o_ptr->art_flags |= TR_WIS;
+ o_ptr->art_flags |= TR_SUST_WIS;
break;
}
case 4:
{
- o_ptr->art_flags1 |= TR1_DEX;
- o_ptr->art_flags2 |= TR2_SUST_DEX;
+ o_ptr->art_flags |= TR_DEX;
+ o_ptr->art_flags |= TR_SUST_DEX;
break;
}
case 5:
{
- o_ptr->art_flags1 |= TR1_CON;
- o_ptr->art_flags2 |= TR2_SUST_CON;
+ o_ptr->art_flags |= TR_CON;
+ o_ptr->art_flags |= TR_SUST_CON;
break;
}
case 6:
{
- o_ptr->art_flags1 |= TR1_CHR;
- o_ptr->art_flags2 |= TR2_SUST_CHR;
+ o_ptr->art_flags |= TR_CHR;
+ o_ptr->art_flags |= TR_SUST_CHR;
break;
}
}
@@ -3841,26 +3833,26 @@ void add_random_ego_flag(object_type *o_ptr, int fego, bool_ *limit_blows)
{
case 1:
{
- o_ptr->art_flags2 |= TR2_IM_FIRE;
- o_ptr->art_flags3 |= TR3_IGNORE_FIRE;
+ o_ptr->art_flags |= TR_IM_FIRE;
+ o_ptr->art_flags |= TR_IGNORE_FIRE;
break;
}
case 2:
{
- o_ptr->art_flags2 |= TR2_IM_ACID;
- o_ptr->art_flags3 |= TR3_IGNORE_ACID;
+ o_ptr->art_flags |= TR_IM_ACID;
+ o_ptr->art_flags |= TR_IGNORE_ACID;
break;
}
case 3:
{
- o_ptr->art_flags2 |= TR2_IM_ELEC;
- o_ptr->art_flags3 |= TR3_IGNORE_ELEC;
+ o_ptr->art_flags |= TR_IM_ELEC;
+ o_ptr->art_flags |= TR_IGNORE_ELEC;
break;
}
case 4:
{
- o_ptr->art_flags2 |= TR2_IM_COLD;
- o_ptr->art_flags3 |= TR3_IGNORE_COLD;
+ o_ptr->art_flags |= TR_IM_COLD;
+ o_ptr->art_flags |= TR_IGNORE_COLD;
break;
}
}
@@ -3900,30 +3892,25 @@ void add_random_ego_flag(object_type *o_ptr, int fego, bool_ *limit_blows)
*/
void apply_magic(object_type *o_ptr, int lev, bool_ okay, bool_ good, bool_ great, boost::optional<int> force_power)
{
- int i, rolls, f1, f2, power;
+ int i, rolls;
object_kind *k_ptr = &k_info[o_ptr->k_idx];
/* Aply luck */
lev += luck( -7, 7);
- /* Spell in it ? no ! */
- if (k_ptr->flags5 & TR5_SPELL_CONTAIN)
+ /* Spell in it? No! */
+ if (k_ptr->flags & TR_SPELL_CONTAIN)
o_ptr->pval2 = -1;
/* Important to do before all else, be sure to have the basic obvious flags set */
- o_ptr->art_oflags1 = k_ptr->oflags1;
- o_ptr->art_oflags2 = k_ptr->oflags2;
- o_ptr->art_oflags3 = k_ptr->oflags3;
- o_ptr->art_oflags4 = k_ptr->oflags4;
- o_ptr->art_oflags5 = k_ptr->oflags5;
- o_ptr->art_oesp = k_ptr->oesp;
+ o_ptr->art_oflags = k_ptr->oflags;
/* No need to touch normal artifacts */
- if (k_ptr->flags3 & TR3_NORM_ART)
+ if (k_ptr->flags & TR_NORM_ART)
{
/* Ahah! we tried to trick us !! */
if (k_ptr->artifact ||
- ((k_ptr->flags4 & TR4_SPECIAL_GENE) &&
+ ((k_ptr->flags & TR_SPECIAL_GENE) &&
(!k_allow_special[o_ptr->k_idx])))
{
object_prep(o_ptr, lookup_kind(k_ptr->btval, k_ptr->bsval));
@@ -3962,47 +3949,49 @@ void apply_magic(object_type *o_ptr, int lev, bool_ okay, bool_ good, bool_ grea
/* Maximum "level" for various things */
if (lev > MAX_DEPTH - 1) lev = MAX_DEPTH - 1;
+ /* Roll for power */
+ int power = 0;
+ {
+ /* Base chance of being "good" */
+ int f1 = lev + 10 + luck( -15, 15);
- /* Base chance of being "good" */
- f1 = lev + 10 + luck( -15, 15);
-
- /* Maximal chance of being "good" */
- if (f1 > 75) f1 = 75;
-
- /* Base chance of being "great" */
- f2 = f1 / 2;
+ /* Maximal chance of being "good" */
+ if (f1 > 75) f1 = 75;
- /* Maximal chance of being "great" */
- if (f2 > 20) f2 = 20;
+ /* Base chance of being "great" */
+ int f2 = f1 / 2;
+ /* Maximal chance of being "great" */
+ if (f2 > 20) f2 = 20;
- /* Assume normal */
- power = 0;
+ /* Assume normal */
+ power = 0;
- /* Roll for "good" */
- if (good || magik(f1))
- {
- /* Assume "good" */
- power = 1;
+ /* Roll for "good" */
+ if (good || magik(f1))
+ {
+ /* Assume "good" */
+ power = 1;
- /* Roll for "great" */
- if (great || magik(f2)) power = 2;
- }
+ /* Roll for "great" */
+ if (great || magik(f2)) power = 2;
+ }
- /* Roll for "cursed" */
- else if (magik(f1))
- {
- /* Assume "cursed" */
- power = -1;
+ /* Roll for "cursed" */
+ else if (magik(f1))
+ {
+ /* Assume "cursed" */
+ power = -1;
- /* Roll for "broken" */
- if (magik(f2)) power = -2;
- }
+ /* Roll for "broken" */
+ if (magik(f2)) power = -2;
+ }
- /* Override power with parameter? */
- if (auto power_override = force_power)
- {
- power = *power_override;
+ /* Override power with parameter? */
+ if (auto power_override = force_power)
+ {
+ power = *power_override;
+ }
}
/* Assume no rolls */
@@ -4054,7 +4043,7 @@ void apply_magic(object_type *o_ptr, int lev, bool_ okay, bool_ good, bool_ grea
o_ptr->number = 1;
/* Hack -- extract the "cursed" flag */
- if (a_ptr->flags3 & (TR3_CURSED)) o_ptr->ident |= (IDENT_CURSED);
+ if (a_ptr->flags & TR_CURSED) o_ptr->ident |= (IDENT_CURSED);
/* Mega-Hack -- increase the rating */
rating += 10;
@@ -4068,15 +4057,14 @@ void apply_magic(object_type *o_ptr, int lev, bool_ okay, bool_ good, bool_ grea
/* Cheat -- peek at the item */
if ((cheat_peek) || (p_ptr->precognition)) object_mention(o_ptr);
- /* Spell in it ? no ! */
- if (a_ptr->flags5 & TR5_SPELL_CONTAIN)
+ /* Spell in it? No! */
+ if (a_ptr->flags & TR_SPELL_CONTAIN)
o_ptr->pval2 = -1;
/* Give a basic exp/exp level to an artifact that needs it */
- if (a_ptr->flags4 & TR4_LEVELS)
+ if (a_ptr->flags & TR_LEVELS)
{
- o_ptr->elevel = (k_ptr->level / 10) + 1;
- o_ptr->exp = player_exp[o_ptr->elevel - 1];
+ init_obj_exp(o_ptr, k_ptr);
}
/* Done */
@@ -4159,7 +4147,6 @@ void apply_magic(object_type *o_ptr, int lev, bool_ okay, bool_ good, bool_ grea
ego_item_type *e_ptr;
int j;
bool_ limit_blows = FALSE;
- u32b f1, f2, f3, f4, f5, esp;
s16b e_idx;
e_idx = o_ptr->name2;
@@ -4174,35 +4161,23 @@ try_an_other_ego:
/* Rarity check */
if (magik(e_ptr->rar[j]))
{
- o_ptr->art_flags1 |= e_ptr->flags1[j];
- o_ptr->art_flags2 |= e_ptr->flags2[j];
- o_ptr->art_flags3 |= e_ptr->flags3[j];
- o_ptr->art_flags4 |= e_ptr->flags4[j];
- o_ptr->art_flags5 |= e_ptr->flags5[j];
- o_ptr->art_esp |= e_ptr->esp[j];
-
- o_ptr->art_oflags1 |= e_ptr->oflags1[j];
- o_ptr->art_oflags2 |= e_ptr->oflags2[j];
- o_ptr->art_oflags3 |= e_ptr->oflags3[j];
- o_ptr->art_oflags4 |= e_ptr->oflags4[j];
- o_ptr->art_oflags5 |= e_ptr->oflags5[j];
- o_ptr->art_oesp |= e_ptr->oesp[j];
-
+ o_ptr->art_flags |= e_ptr->flags[j];
+ o_ptr->art_oflags |= e_ptr->oflags[j];
add_random_ego_flag(o_ptr, e_ptr->fego[j], &limit_blows);
}
}
/* No insane number of blows */
- if (limit_blows && (o_ptr->art_flags1 & TR1_BLOWS))
+ if (limit_blows && (o_ptr->art_flags & TR_BLOWS))
{
if (o_ptr->pval > 2) o_ptr->pval = randint(2);
}
/* get flags */
- object_flags(o_ptr, &f1, &f2, &f3, &f4, &f5, &esp);
+ auto const flags = object_flags(o_ptr);
/* Hack -- acquire "cursed" flag */
- if (f3 & TR3_CURSED) o_ptr->ident |= (IDENT_CURSED);
+ if (flags & TR_CURSED) o_ptr->ident |= (IDENT_CURSED);
/* Hack -- obtain bonuses */
if (e_ptr->max_to_h > 0) o_ptr->to_h += randint(e_ptr->max_to_h);
@@ -4225,16 +4200,18 @@ try_an_other_ego:
goto try_an_other_ego;
}
- /* Spell in it ? no ! */
- if (f5 & TR5_SPELL_CONTAIN)
+ /* Spell in it ? No! */
+ if (flags & TR_SPELL_CONTAIN)
{
/* Mega hack, mage staves of spell cannot SPELL_CONTAIN */
if (is_ego_p(o_ptr, EGO_MSTAFF_SPELL))
{
- o_ptr->art_flags5 &= ~TR5_SPELL_CONTAIN;
+ o_ptr->art_flags &= ~TR_SPELL_CONTAIN;
}
else
+ {
o_ptr->pval2 = -1;
+ }
}
/* Cheat -- describe the item */
@@ -4245,33 +4222,32 @@ try_an_other_ego:
/* Examine real objects */
if (o_ptr->k_idx)
{
- u32b f1, f2, f3, f4, f5, esp;
-
object_kind *k_ptr = &k_info[o_ptr->k_idx];
/* Hack -- acquire "cursed" flag */
- if (k_ptr->flags3 & (TR3_CURSED)) o_ptr->ident |= (IDENT_CURSED);
+ if (k_ptr->flags & TR_CURSED) o_ptr->ident |= (IDENT_CURSED);
/* Extract some flags */
- object_flags(o_ptr, &f1, &f2, &f3, &f4, &f5, &esp);
+ auto const flags = object_flags(o_ptr);
/* Hack give a basic exp/exp level to an object that needs it */
- if (f4 & TR4_LEVELS)
+ if (flags & TR_LEVELS)
{
- o_ptr->elevel = (k_ptr->level / 10) + 1;
- o_ptr->exp = player_exp[o_ptr->elevel - 1];
+ init_obj_exp(o_ptr, k_ptr);
}
- /* Spell in it ? no ! */
- if (f5 & TR5_SPELL_CONTAIN)
+ /* Spell in it ? No! */
+ if (flags & TR_SPELL_CONTAIN)
{
/* Mega hack, mage staves of spell cannot SPELL_CONTAIN */
if (is_ego_p(o_ptr, EGO_MSTAFF_SPELL))
{
- o_ptr->art_flags5 &= ~TR5_SPELL_CONTAIN;
+ o_ptr->art_flags &= ~TR_SPELL_CONTAIN;
}
else
+ {
o_ptr->pval2 = -1;
+ }
}
/* Hacccccccckkkkk attack ! :) -- To prevent som ugly crashs */
@@ -4284,7 +4260,7 @@ try_an_other_ego:
if (o_ptr->tval == TV_ROD_MAIN)
{
/* Set the max mana and the current mana */
- o_ptr->pval2 = (f4 & TR4_CAPACITY) ? o_ptr->sval * 2 : o_ptr->sval;
+ o_ptr->pval2 = (flags & TR_CAPACITY) ? o_ptr->sval * 2 : o_ptr->sval;
o_ptr->timeout = o_ptr->pval2;
}
@@ -4522,14 +4498,14 @@ bool_ kind_is_legal(int k_idx)
if (!kind_is_theme(match_theme, k_idx)) return FALSE;
- if (k_ptr->flags4 & TR4_SPECIAL_GENE)
+ if (k_ptr->flags & TR_SPECIAL_GENE)
{
if (k_allow_special[k_idx]) return TRUE;
else return FALSE;
}
/* No 2 times the same normal artifact */
- if ((k_ptr->flags3 & TR3_NORM_ART) && (k_ptr->artifact))
+ if ((k_ptr->flags & TR_NORM_ART) && (k_ptr->artifact))
{
return FALSE;
}
@@ -4895,7 +4871,7 @@ void place_object(int y, int x, bool_ good, bool_ great, int where)
{
a_info[q_ptr->name1].cur_num = 0;
}
- else if (k_info[q_ptr->k_idx].flags3 & TR3_NORM_ART)
+ else if (k_info[q_ptr->k_idx].flags & TR_NORM_ART)
{
k_info[q_ptr->k_idx].artifact = 0;
}
@@ -5266,7 +5242,7 @@ s16b drop_near(object_type *j_ptr, int chance, int y, int x)
{
a_info[j_ptr->name1].cur_num = 0;
}
- else if (k_info[j_ptr->k_idx].flags3 & TR3_NORM_ART)
+ else if (k_info[j_ptr->k_idx].flags & TR_NORM_ART)
{
k_info[j_ptr->k_idx].artifact = 0;
}
diff --git a/src/object_filter.cc b/src/object_filter.cc
index 39961146..936eef7d 100644
--- a/src/object_filter.cc
+++ b/src/object_filter.cc
@@ -17,33 +17,10 @@ object_filter_t SVal(byte sval) {
};
}
-object_filter_t HasFlag3(u32b mask) {
+object_filter_t HasFlags(object_flag_set const &mask) {
return [=](object_type const *o_ptr) -> bool {
- // Extract the flags
- u32b f1, f2, f3, f4, f5, esp;
- object_flags(o_ptr, &f1, &f2, &f3, &f4, &f5, &esp);
- // Does the item have the flag?
- return (f3 & mask);
- };
-}
-
-object_filter_t HasFlag4(u32b mask) {
- return [=](object_type const *o_ptr) -> bool {
- // Extract the flags
- u32b f1, f2, f3, f4, f5, esp;
- object_flags(o_ptr, &f1, &f2, &f3, &f4, &f5, &esp);
- // Does the item have the flag?
- return (f4 & mask);
- };
-}
-
-object_filter_t HasFlag5(u32b mask) {
- return [=](object_type const *o_ptr) -> bool {
- // Extract the flags
- u32b f1, f2, f3, f4, f5, esp;
- object_flags(o_ptr, &f1, &f2, &f3, &f4, &f5, &esp);
- // Does the item have the flag?
- return (f5 & mask);
+ auto const flags = object_flags(o_ptr);
+ return bool(flags & mask);
};
}
diff --git a/src/object_filter.hpp b/src/object_filter.hpp
index 9a22090b..d18e13ee 100644
--- a/src/object_filter.hpp
+++ b/src/object_filter.hpp
@@ -1,6 +1,7 @@
#pragma once
#include "h-basic.h"
+#include "object_flag_set.hpp"
#include "object_type_fwd.hpp"
#include <functional>
@@ -21,19 +22,9 @@ object_filter_t TVal(byte tval);
object_filter_t SVal(byte sval);
/**
- * Has given bit mask in flag3 value.
+ * Has given set of flags set.
*/
-object_filter_t HasFlag3(u32b mask);
-
-/**
- * Has given bit mask in flag4 value.
- */
-object_filter_t HasFlag4(u32b mask);
-
-/**
- * Has given bit mask in flag5 value.
- */
-object_filter_t HasFlag5(u32b mask);
+object_filter_t HasFlags(object_flag_set const &);
/**
* Is the object an artifact?
diff --git a/src/object_flag.hpp b/src/object_flag.hpp
new file mode 100644
index 00000000..d5ec2fef
--- /dev/null
+++ b/src/object_flag.hpp
@@ -0,0 +1,12 @@
+#pragma once
+
+#include "object_flag_set.hpp"
+#include <boost/preprocessor/cat.hpp>
+
+//
+// Define flag set for each flag.
+//
+#define TR(tier, index, name, e_name, c_name, c_page, c_col, c_row, c_type, c_prio, is_pval, is_esp) \
+ DECLARE_FLAG(object_flag_set, name, tier, index)
+#include "object_flag_list.hpp"
+#undef TR
diff --git a/src/object_flag_list.hpp b/src/object_flag_list.hpp
new file mode 100644
index 00000000..56cf1b88
--- /dev/null
+++ b/src/object_flag_list.hpp
@@ -0,0 +1,196 @@
+/**
+ * X-macro list of all the object flags.
+ *
+ * Parameters:
+ *
+ * - e_name: name of the flag in the edit files.
+ * - c_name: name of the flag on the character sheet
+ * (10 characters max). If nullptrptr the
+ * flag doesn't appear and the other c_*
+ * values are ignored.
+ * - c_page: page on the character sheet (0-3).
+ * - c_col: column number on the character sheet (0-1).
+ * - c_row: row number on the character sheet (0-15).
+ * - c_type: type of the character sheet; either
+ * NUMERIC, BINARY or TERNARY(n).
+ * - c_prio: priority if the flag overlaps another flag
+ * on the character sheet. 0 is lowes priority.
+ * - is_pval: true iff the flag _description_ depends on PVAL.
+ * - is_esp: true iff the flag affects ESP.
+ */
+
+/* TR(<tier>, <index>, <name>, <e_name>, <c_name>, <c_page>, <c_col>, <c_row>, <c_type>, <c_prio>, <is_pval>, <is_esp>) */
+
+TR(1, 0, TR_STR , STR , "Add Str" , 0, 0, 0, NUMERIC , 0, true , false)
+TR(1, 1, TR_INT , INT , "Add Int" , 0, 0, 1, NUMERIC , 0, true , false)
+TR(1, 2, TR_WIS , WIS , "Add Wis" , 0, 0, 2, NUMERIC , 0, true , false)
+TR(1, 3, TR_DEX , DEX , "Add Dex" , 0, 0, 3, NUMERIC , 0, true , false)
+TR(1, 4, TR_CON , CON , "Add Con" , 0, 0, 4, NUMERIC , 0, true , false)
+TR(1, 5, TR_CHR , CHR , "Add Chr" , 0, 0, 5, NUMERIC , 0, true , false)
+TR(1, 6, TR_MANA , MANA , "Mul Mana" , 0, 0, 6, BINARY , 0, false, false)
+TR(1, 7, TR_SPELL , SPELL , "Mul SPower", 0, 0, 7, BINARY , 0, true , false)
+TR(1, 8, TR_STEALTH , STEALTH , "Add Stea." , 0, 0, 8, NUMERIC , 0, true , false)
+TR(1, 9, TR_SEARCH , SEARCH , "Add Sear." , 0, 0, 9, NUMERIC , 0, true , false)
+TR(1, 10, TR_INFRA , INFRA , "Add Infra" , 0, 0, 10, NUMERIC , 0, true , false)
+TR(1, 11, TR_TUNNEL , TUNNEL , "Add Tun.." , 0, 0, 11, NUMERIC , 0, true , false)
+TR(1, 12, TR_SPEED , SPEED , "Add Speed" , 0, 0, 12, NUMERIC , 0, true , false)
+TR(1, 13, TR_BLOWS , BLOWS , "Add Blows" , 0, 0, 13, NUMERIC , 0, true , false)
+TR(1, 14, TR_CHAOTIC , CHAOTIC , "Chaotic" , 0, 0, 14, BINARY , 0, false, false)
+TR(1, 15, TR_VAMPIRIC , VAMPIRIC , "Vampiric" , 0, 0, 15, BINARY , 0, false, false)
+TR(1, 16, TR_SLAY_ANIMAL , SLAY_ANIMAL , "Slay Anim.", 0, 1, 0, BINARY , 0, false, false)
+TR(1, 17, TR_SLAY_EVIL , SLAY_EVIL , "Slay Evil" , 0, 1, 1, BINARY , 0, false, false)
+TR(1, 18, TR_SLAY_UNDEAD , SLAY_UNDEAD , "Slay Und." , 0, 1, 2, BINARY , 0, false, false)
+TR(1, 19, TR_SLAY_DEMON , SLAY_DEMON , "Slay Demon", 0, 1, 3, BINARY , 0, false, false)
+TR(1, 20, TR_SLAY_ORC , SLAY_ORC , "Slay Orc" , 0, 1, 4, BINARY , 0, false, false)
+TR(1, 21, TR_SLAY_TROLL , SLAY_TROLL , "Slay Troll", 0, 1, 5, BINARY , 0, false, false)
+TR(1, 22, TR_SLAY_GIANT , SLAY_GIANT , "Slay Giant", 0, 1, 6, BINARY , 0, false, false)
+TR(1, 23, TR_SLAY_DRAGON , SLAY_DRAGON , "Slay Drag.", 0, 1, 7, BINARY , 0, false, false)
+TR(1, 24, TR_KILL_DRAGON , KILL_DRAGON , "Kill Drag.", 0, 1, 8, BINARY , 0, false, false)
+TR(1, 25, TR_VORPAL , VORPAL , "Sharpness" , 0, 1, 9, BINARY , 0, false, false)
+TR(1, 26, TR_IMPACT , IMPACT , "Impact" , 0, 1, 10, BINARY , 0, false, false)
+TR(1, 27, TR_BRAND_POIS , BRAND_POIS , "Poison Brd", 0, 1, 11, BINARY , 0, false, false)
+TR(1, 28, TR_BRAND_ACID , BRAND_ACID , "Acid Brand", 0, 1, 12, BINARY , 0, false, false)
+TR(1, 29, TR_BRAND_ELEC , BRAND_ELEC , "Elec Brand", 0, 1, 13, BINARY , 0, false, false)
+TR(1, 30, TR_BRAND_FIRE , BRAND_FIRE , "Fire Brand", 0, 1, 14, BINARY , 0, false, false)
+TR(1, 31, TR_BRAND_COLD , BRAND_COLD , "Cold Brand", 0, 1, 15, BINARY , 0, false, false)
+
+TR(2, 0, TR_SUST_STR , SUST_STR , "Sust Str" , 1, 0, 0, BINARY , 0, false, false)
+TR(2, 1, TR_SUST_INT , SUST_INT , "Sust Int" , 1, 0, 1, BINARY , 0, false, false)
+TR(2, 2, TR_SUST_WIS , SUST_WIS , "Sust Wis" , 1, 0, 2, BINARY , 0, false, false)
+TR(2, 3, TR_SUST_DEX , SUST_DEX , "Sust Dex" , 1, 0, 3, BINARY , 0, false, false)
+TR(2, 4, TR_SUST_CON , SUST_CON , "Sust Con" , 1, 0, 4, BINARY , 0, false, false)
+TR(2, 5, TR_SUST_CHR , SUST_CHR , "Sust Chr" , 1, 0, 5, BINARY , 0, false, false)
+TR(2, 6, TR_INVIS , INVIS , "Invisible" , 1, 0, 6, BINARY , 0, false, false)
+TR(2, 7, TR_LIFE , LIFE , "Mul life" , 1, 0, 7, BINARY , 0, false, false)
+TR(2, 8, TR_IM_ACID , IM_ACID , "Imm Acid" , 1, 1, 0, TERNARY(2), 1, false, false)
+TR(2, 9, TR_IM_ELEC , IM_ELEC , "Imm Elec" , 1, 1, 1, TERNARY(2), 1, false, false)
+TR(2, 10, TR_IM_FIRE , IM_FIRE , "Imm Fire" , 1, 1, 2, TERNARY(2), 1, false, false)
+TR(2, 11, TR_IM_COLD , IM_COLD , "Imm Cold" , 1, 1, 3, TERNARY(2), 1, false, false)
+TR(2, 12, TR_SENS_FIRE , SENS_FIRE , "Sens Fire" , 1, 0, 12, BINARY , 0, false, false)
+TR(2, 13, TR_REFLECT , REFLECT , "Reflect" , 1, 0, 13, BINARY , 0, false, false)
+TR(2, 14, TR_FREE_ACT , FREE_ACT , "Free Act" , 1, 0, 14, BINARY , 0, false, false)
+TR(2, 15, TR_HOLD_LIFE , HOLD_LIFE , "Hold Life" , 1, 0, 15, BINARY , 0, false, false)
+TR(2, 16, TR_RES_ACID , RES_ACID , "Res Acid" , 1, 1, 0, TERNARY(1), 0, false, false)
+TR(2, 17, TR_RES_ELEC , RES_ELEC , "Res Elec" , 1, 1, 1, TERNARY(1), 0, false, false)
+TR(2, 18, TR_RES_FIRE , RES_FIRE , "Res Fire" , 1, 1, 2, TERNARY(1), 0, false, false)
+TR(2, 19, TR_RES_COLD , RES_COLD , "Res Cold" , 1, 1, 3, TERNARY(1), 0, false, false)
+TR(2, 20, TR_RES_POIS , RES_POIS , "Res Pois" , 1, 1, 4, BINARY , 0, false, false)
+TR(2, 21, TR_RES_FEAR , RES_FEAR , "Res Fear" , 1, 1, 5, BINARY , 0, false, false)
+TR(2, 22, TR_RES_LITE , RES_LITE , "Res Light" , 1, 1, 6, BINARY , 0, false, false)
+TR(2, 23, TR_RES_DARK , RES_DARK , "Res Dark" , 1, 1, 7, BINARY , 0, false, false)
+TR(2, 24, TR_RES_BLIND , RES_BLIND , "Res Blind" , 1, 1, 8, BINARY , 0, false, false)
+TR(2, 25, TR_RES_CONF , RES_CONF , "Res Conf" , 1, 1, 9, BINARY , 0, false, false)
+TR(2, 26, TR_RES_SOUND , RES_SOUND , "Res Sound" , 1, 1, 10, BINARY , 0, false, false)
+TR(2, 27, TR_RES_SHARDS , RES_SHARDS , "Res Shard" , 1, 1, 11, BINARY , 0, false, false)
+TR(2, 28, TR_RES_NETHER , RES_NETHER , "Res Neth" , 1, 1, 12, TERNARY(1), 0, false, false)
+TR(2, 29, TR_RES_NEXUS , RES_NEXUS , "Res Nexus" , 1, 1, 13, BINARY , 0, false, false)
+TR(2, 30, TR_RES_CHAOS , RES_CHAOS , "Res Chaos" , 1, 1, 14, BINARY , 0, false, false)
+TR(2, 31, TR_RES_DISEN , RES_DISEN , "Res Disen" , 1, 1, 15, BINARY , 0, false, false)
+
+TR(3, 0, TR_SH_FIRE , SH_FIRE , "Aura Fire" , 2, 0, 0, BINARY , 0, false, false)
+TR(3, 1, TR_SH_ELEC , SH_ELEC , "Aura Elec" , 2, 0, 1, BINARY , 0, false, false)
+TR(3, 2, TR_AUTO_CURSE , AUTO_CURSE , "Auto Curse", 2, 0, 2, BINARY , 0, false, false)
+TR(3, 3, TR_DECAY , DECAY , nullptr , -1, -1, -1, BINARY , 0, false, false)
+TR(3, 4, TR_NO_TELE , NO_TELE , "NoTeleport", 2, 0, 4, BINARY , 0, false, false)
+TR(3, 5, TR_NO_MAGIC , NO_MAGIC , "AntiMagic" , 2, 0, 5, BINARY , 0, false, false)
+TR(3, 6, TR_WRAITH , WRAITH , "WraithForm", 2, 0, 6, BINARY , 0, false, false)
+TR(3, 7, TR_TY_CURSE , TY_CURSE , "EvilCurse" , 2, 0, 7, BINARY , 0, false, false)
+TR(3, 8, TR_EASY_KNOW , EASY_KNOW , nullptr , -1, -1, -1, BINARY , 0, false, false)
+TR(3, 9, TR_HIDE_TYPE , HIDE_TYPE , nullptr , -1, -1, -1, BINARY , 0, false, false)
+TR(3, 10, TR_SHOW_MODS , SHOW_MODS , nullptr , -1, -1, -1, BINARY , 0, false, false)
+TR(3, 11, TR_INSTA_ART , INSTA_ART , nullptr , -1, -1, -1, BINARY , 0, false, false)
+TR(3, 12, TR_FEATHER , FEATHER , "Levitate" , 2, 0, 12, BINARY , 0, false, false)
+TR(3, 13, TR_LITE1 , LITE1 , "Lite" , 2, 0, 13, FIXED(1) , 0, false, false)
+TR(3, 14, TR_SEE_INVIS , SEE_INVIS , "See Invis" , 2, 0, 14, BINARY , 0, false, false)
+TR(3, 15, TR_NORM_ART , NORM_ART , nullptr , -1, -1, -1, BINARY , 0, false, false)
+TR(3, 16, TR_SLOW_DIGEST , SLOW_DIGEST , "Digestion" , 2, 1, 0, BINARY , 0, false, false)
+TR(3, 17, TR_REGEN , REGEN , "Regen" , 2, 1, 1, BINARY , 0, false, false)
+TR(3, 18, TR_XTRA_MIGHT , XTRA_MIGHT , "Xtra Might", 2, 1, 2, BINARY , 0, false, false)
+TR(3, 19, TR_XTRA_SHOTS , XTRA_SHOTS , "Xtra Shots", 2, 1, 3, BINARY , 0, false, false)
+TR(3, 20, TR_IGNORE_ACID , IGNORE_ACID , nullptr , -1, -1, -1, BINARY , 0, false, false)
+TR(3, 21, TR_IGNORE_ELEC , IGNORE_ELEC , nullptr , -1, -1, -1, BINARY , 0, false, false)
+TR(3, 22, TR_IGNORE_FIRE , IGNORE_FIRE , nullptr , -1, -1, -1, BINARY , 0, false, false)
+TR(3, 23, TR_IGNORE_COLD , IGNORE_COLD , nullptr , -1, -1, -1, BINARY , 0, false, false)
+TR(3, 24, TR_ACTIVATE , ACTIVATE , "Activate" , 2, 1, 8, BINARY , 0, false, false)
+TR(3, 25, TR_DRAIN_EXP , DRAIN_EXP , "Drain Exp" , 2, 1, 9, BINARY , 0, false, false)
+TR(3, 26, TR_TELEPORT , TELEPORT , "Teleport" , 2, 1, 10, BINARY , 0, false, false)
+TR(3, 27, TR_AGGRAVATE , AGGRAVATE , "Aggravate" , 2, 1, 11, BINARY , 0, false, false)
+TR(3, 28, TR_BLESSED , BLESSED , "Blessed" , 2, 1, 12, BINARY , 0, false, false)
+TR(3, 29, TR_CURSED , CURSED , "Cursed" , 2, 1, 13, BINARY , 0, false, false)
+TR(3, 30, TR_HEAVY_CURSE , HEAVY_CURSE , "Hvy Curse" , 2, 1, 14, BINARY , 0, false, false)
+TR(3, 31, TR_PERMA_CURSE , PERMA_CURSE , "Prm Curse" , 2, 1, 15, BINARY , 0, false, false)
+
+TR(4, 0, TR_NEVER_BLOW , NEVER_BLOW , "No blows" , 3, 0, 0, BINARY , 0, false, false)
+TR(4, 1, TR_PRECOGNITION , PRECOGNITION , "Precogn." , 3, 0, 1, BINARY , 0, false, false)
+TR(4, 2, TR_BLACK_BREATH , BLACK_BREATH , "B.Breath" , 3, 0, 2, BINARY , 0, false, false)
+TR(4, 3, TR_RECHARGE , RECHARGE , "Recharge" , 3, 0, 3, BINARY , 0, false, false)
+TR(4, 4, TR_FLY , FLY , "Fly" , 3, 0, 4, BINARY , 0, false, false)
+TR(4, 5, TR_DG_CURSE , DG_CURSE , "Mrg.Curse" , 3, 0, 5, BINARY , 0, false, false)
+TR(4, 6, TR_COULD2H , COULD2H , nullptr , -1, -1, -1, BINARY , 0, false, false)
+TR(4, 7, TR_MUST2H , MUST2H , nullptr , -1, -1, -1, BINARY , 0, false, false)
+TR(4, 8, TR_LEVELS , LEVELS , "Sentient" , 3, 0, 8, BINARY , 0, false, false)
+TR(4, 9, TR_CLONE , CLONE , "Clone" , 3, 0, 9, BINARY , 0, false, false)
+TR(4, 10, TR_SPECIAL_GENE , SPECIAL_GENE , nullptr , 3, 0, 10, BINARY , 0, false, false)
+TR(4, 11, TR_CLIMB , CLIMB , "Climb" , 3, 0, 11, BINARY , 0, false, false)
+TR(4, 12, TR_FAST_CAST , FAST_CAST , nullptr , -1, -1, -1, BINARY , 0, false, false)
+TR(4, 13, TR_CAPACITY , CAPACITY , nullptr , -1, -1, -1, BINARY , 0, false, false)
+TR(4, 14, TR_CHARGING , CHARGING , nullptr , -1, -1, -1, BINARY , 0, false, false)
+TR(4, 15, TR_CHEAPNESS , CHEAPNESS , nullptr , -1, -1, -1, BINARY , 0, false, false)
+TR(4, 16, TR_FOUNTAIN , FOUNTAIN , nullptr , -1, -1, -1, BINARY , 0, false, false)
+TR(4, 17, TR_ANTIMAGIC_50 , ANTIMAGIC_50 , nullptr , -1, -1, -1, BINARY , 0, false, false)
+TR(4, 21, TR_EASY_USE , EASY_USE , nullptr , -1, -1, -1, BINARY , 0, false, false)
+TR(4, 22, TR_IM_NETHER , IM_NETHER , "Imm Neth" , 1, 1, 12, TERNARY(2), 1, false, false)
+TR(4, 23, TR_RECHARGED , RECHARGED , nullptr , -1, -1, -1, BINARY , 0, false, false)
+TR(4, 24, TR_ULTIMATE , ULTIMATE , nullptr , -1, -1, -1, BINARY , 0, false, false)
+TR(4, 25, TR_AUTO_ID , AUTO_ID , nullptr , -1, -1, -1, BINARY , 0, false, false)
+TR(4, 26, TR_LITE2 , LITE2 , "Lite" , 2, 0, 13, FIXED(2) , 0, false, false)
+TR(4, 27, TR_LITE3 , LITE3 , "Lite" , 2, 0, 13, FIXED(3) , 0, false, false)
+TR(4, 28, TR_FUEL_LITE , FUEL_LITE , nullptr , -1, -1, -1, BINARY , 0, false, false)
+TR(4, 30, TR_CURSE_NO_DROP , CURSE_NO_DROP , nullptr , -1, -1, -1, BINARY , 0, false, false)
+TR(4, 31, TR_NO_RECHARGE , NO_RECHARGE , nullptr , -1, -1, -1, BINARY , 0, false, false)
+
+TR(5, 0, TR_TEMPORARY , TEMPORARY , nullptr , -1, -1, -1, BINARY , 0, false, false)
+TR(5, 1, TR_DRAIN_MANA , DRAIN_MANA , nullptr , -1, -1, -1, BINARY , 0, false, false)
+TR(5, 2, TR_DRAIN_HP , DRAIN_HP , nullptr , -1, -1, -1, BINARY , 0, false, false)
+TR(5, 3, TR_KILL_DEMON , KILL_DEMON , nullptr , -1, -1, -1, BINARY , 0, false, false)
+TR(5, 4, TR_KILL_UNDEAD , KILL_UNDEAD , nullptr , -1, -1, -1, BINARY , 0, false, false)
+TR(5, 5, TR_CRIT , CRIT , nullptr , -1, -1, -1, BINARY , 0, true , false)
+TR(5, 6, TR_ATTR_MULTI , ATTR_MULTI , nullptr , -1, -1, -1, BINARY , 0, false, false)
+TR(5, 7, TR_WOUNDING , WOUNDING , nullptr , -1, -1, -1, BINARY , 0, false, false)
+TR(5, 8, TR_FULL_NAME , FULL_NAME , nullptr , -1, -1, -1, BINARY , 0, false, false)
+TR(5, 9, TR_LUCK , LUCK , nullptr , -1, -1, -1, BINARY , 0, true , false)
+TR(5, 10, TR_IMMOVABLE , IMMOVABLE , nullptr , -1, -1, -1, BINARY , 0, false, false)
+TR(5, 11, TR_SPELL_CONTAIN , SPELL_CONTAIN , nullptr , -1, -1, -1, BINARY , 0, false, false)
+TR(5, 12, TR_RES_MORGUL , RES_MORGUL , nullptr , -1, -1, -1, BINARY , 0, false, false)
+TR(5, 13, TR_ACTIVATE_NO_WIELD , ACTIVATE_NO_WIELD , nullptr , -1, -1, -1, BINARY , 0, false, false)
+TR(5, 14, TR_MAGIC_BREATH , MAGIC_BREATH , nullptr , -1, -1, -1, BINARY , 0, false, false)
+TR(5, 15, TR_WATER_BREATH , WATER_BREATH , nullptr , -1, -1, -1, BINARY , 0, false, false)
+TR(5, 16, TR_WIELD_CAST , WIELD_CAST , nullptr , -1, -1, -1, BINARY , 0, false, false)
+TR(5, 17, TR_RANDOM_RESIST , RANDOM_RESIST , nullptr , -1, -1, -1, BINARY , 0, false, false)
+TR(5, 18, TR_RANDOM_POWER , RANDOM_POWER , nullptr , -1, -1, -1, BINARY , 0, false, false)
+TR(5, 19, TR_RANDOM_RES_OR_POWER, RANDOM_RES_OR_POWER, nullptr , -1, -1, -1, BINARY , 0, false, false)
+
+TR(6, 0, TR_AUTOMATIC_5 , AUTOMATIC_5 , nullptr , -1, -1, -1, BINARY , 0, false, false)
+TR(6, 1, TR_AUTOMATIC_99 , AUTOMATIC_99 , nullptr , -1, -1, -1, BINARY , 0, false, false)
+TR(6, 2, TR_KILL_GHOST , KILL_GHOST , nullptr , -1, -1, -1, BINARY , 0, false, false)
+TR(6, 3, TR_TELEPORT_TO , TELEPORT_TO , nullptr , -1, -1, -1, BINARY , 0, false, false)
+TR(6, 4, TR_ONLY_DRAGON , ONLY_DRAGON , nullptr , -1, -1, -1, BINARY , 0, false, false)
+TR(6, 5, TR_ONLY_DEMON , ONLY_DEMON , nullptr , -1, -1, -1, BINARY , 0, false, false)
+TR(6, 8, TR_ONLY_ANIMAL , ONLY_ANIMAL , nullptr , -1, -1, -1, BINARY , 0, false, false)
+TR(6, 9, TR_ONLY_UNDEAD , ONLY_UNDEAD , nullptr , -1, -1, -1, BINARY , 0, false, false)
+TR(6, 10, TR_ONLY_EVIL , ONLY_EVIL , nullptr , -1, -1, -1, BINARY , 0, false, false)
+
+TR(7, 0, ESP_ORC , ESP_ORC , "Orc.ESP" , 3, 1, 0, BINARY , 0, false, true )
+TR(7, 1, ESP_TROLL , ESP_TROLL , "Troll.ESP" , 3, 1, 1, BINARY , 0, false, true )
+TR(7, 2, ESP_DRAGON , ESP_DRAGON , "Dragon.ESP", 3, 1, 2, BINARY , 0, false, true )
+TR(7, 3, ESP_GIANT , ESP_GIANT , "Giant.ESP" , 3, 1, 3, BINARY , 0, false, true )
+TR(7, 4, ESP_DEMON , ESP_DEMON , "Demon.ESP" , 3, 1, 4, BINARY , 0, false, true )
+TR(7, 5, ESP_UNDEAD , ESP_UNDEAD , "Undead.ESP", 3, 1, 5, BINARY , 0, false, true )
+TR(7, 6, ESP_EVIL , ESP_EVIL , "Evil.ESP" , 3, 1, 6, BINARY , 0, false, true )
+TR(7, 7, ESP_ANIMAL , ESP_ANIMAL , "Animal.ESP", 3, 1, 7, BINARY , 0, false, true )
+TR(7, 8, ESP_THUNDERLORD , ESP_THUNDERLORD , "TLord.ESP" , 3, 1, 8, BINARY , 0, false, true )
+TR(7, 9, ESP_GOOD , ESP_GOOD , "Good.ESP" , 3, 1, 9, BINARY , 0, false, true )
+TR(7, 10, ESP_NONLIVING , ESP_NONLIVING , "Nlive.ESP" , 3, 1, 10, BINARY , 0, false, true )
+TR(7, 11, ESP_UNIQUE , ESP_UNIQUE , "Unique.ESP", 3, 1, 11, BINARY , 0, false, true )
+TR(7, 12, ESP_SPIDER , ESP_SPIDER , "Spider ESP", 3, 1, 12, BINARY , 0, false, true )
+TR(7, 31, ESP_ALL , ESP_ALL , "Full ESP" , 3, 1, 15, BINARY , 0, false, true )
diff --git a/src/object_flag_meta.cc b/src/object_flag_meta.cc
new file mode 100644
index 00000000..89b91fea
--- /dev/null
+++ b/src/object_flag_meta.cc
@@ -0,0 +1,59 @@
+#include "object_flag_meta.hpp"
+
+#include "object_flag.hpp"
+
+std::vector<object_flag_meta const *> const &object_flags_meta()
+{
+ static std::vector<object_flag_meta const *> instance;
+
+ if (instance.empty())
+ {
+#define NUMERIC 'n'
+#define BINARY 'b'
+#define TERNARY(n) ((n == 1) ? '+' : ((n == 2) ? '*' : '?'))
+#define FIXED(n) ((n == 1) ? '1' : ((n == 2) ? '2' : ((n == 3) ? '3' : '?')))
+#define TR(tier, index, name, e_name, c_name, c_page, c_col, c_row, c_type, c_prio, is_pval, is_esp) \
+ instance.emplace_back(new object_flag_meta { \
+ name, \
+ #name, \
+ #e_name, \
+ c_name, \
+ c_page, \
+ c_col, \
+ c_row, \
+ c_type, \
+ c_prio, \
+ is_pval, \
+ is_esp \
+ });
+#include "object_flag_list.hpp"
+#undef TR
+#undef FIXED
+#undef TERNARY
+#undef BINARY
+#undef NUMERIC
+ };
+
+ return instance;
+}
+
+object_flag_set const &object_flags_esp()
+{
+ static object_flag_set instance;
+ static bool initialized = false;
+
+ if (!initialized)
+ {
+ for (auto const object_flag_meta: object_flags_meta())
+ {
+ if (object_flag_meta->is_esp)
+ {
+ instance |= object_flag_meta->flag_set;
+ }
+ }
+
+ initialized = true;
+ }
+
+ return instance;
+}
diff --git a/src/object_flag_meta.hpp b/src/object_flag_meta.hpp
new file mode 100644
index 00000000..d488c0d5
--- /dev/null
+++ b/src/object_flag_meta.hpp
@@ -0,0 +1,75 @@
+#pragma once
+
+#include "object_flag_set.hpp"
+
+#include <vector>
+
+struct object_flag_meta {
+
+ /**
+ * Flag set representation of the object flag.
+ */
+ const object_flag_set flag_set;
+
+ /**
+ * Name of the object flag.
+ */
+ const char *name;
+
+ /**
+ * Edit file name of the object flag.
+ */
+ const char *e_name;
+
+ /**
+ * Character sheet name of the object flag.
+ */
+ const char *c_name;
+
+ /**
+ * Character sheet page.
+ */
+ const int c_page;
+
+ /**
+ * Character sheet column.
+ */
+ const int c_column;
+
+ /**
+ * Character sheet row.
+ */
+ const int c_row;
+
+ /**
+ * Character sheet type.
+ */
+ char c_type;
+
+ /**
+ * Priority wrt. other flags in the same position
+ * on the character sheet.
+ */
+ int c_priority;
+
+ /**
+ * Is this flag *described* using PVAL?
+ */
+ bool is_pval;
+
+ /**
+ * Is this a flag which affects ESP?
+ */
+ bool is_esp;
+
+};
+
+/**
+ * Get a vector of all the object flags.
+ */
+std::vector<object_flag_meta const *> const &object_flags_meta();
+
+/**
+ * Get a flag representing all ESP flags.
+ */
+object_flag_set const &object_flags_esp();
diff --git a/src/object_flag_set.hpp b/src/object_flag_set.hpp
new file mode 100644
index 00000000..478b6c03
--- /dev/null
+++ b/src/object_flag_set.hpp
@@ -0,0 +1,7 @@
+#pragma once
+
+#include "flag_set.hpp"
+
+constexpr std::size_t TR_MAX_TIERS = 7;
+
+typedef flag_set<TR_MAX_TIERS> object_flag_set;
diff --git a/src/object_kind.hpp b/src/object_kind.hpp
index 767c7e05..2f347f3f 100644
--- a/src/object_kind.hpp
+++ b/src/object_kind.hpp
@@ -1,6 +1,7 @@
#pragma once
#include "h-basic.h"
+#include "object_flag_set.hpp"
/**
* Size of allocation table for objects
@@ -38,17 +39,9 @@ struct object_kind
s32b cost = 0; /* Object "base cost" */
- u32b flags1 = 0; /* Flags, set 1 */
- u32b flags2 = 0; /* Flags, set 2 */
- u32b flags3 = 0; /* Flags, set 3 */
- u32b flags4 = 0; /* Flags, set 4 */
- u32b flags5 = 0; /* Flags, set 5 */
+ object_flag_set flags;
- u32b oflags1 = 0; /* Obvious Flags, set 1 */
- u32b oflags2 = 0; /* Obvious Flags, set 2 */
- u32b oflags3 = 0; /* Obvious Flags, set 3 */
- u32b oflags4 = 0; /* Obvious Flags, set 4 */
- u32b oflags5 = 0; /* Obvious Flags, set 5 */
+ object_flag_set oflags;
byte locale[ALLOCATION_MAX] = { 0 }; /* Allocation level(s) */
byte chance[ALLOCATION_MAX] = { 0 }; /* Allocation chance(s) */
@@ -72,9 +65,6 @@ struct object_kind
bool_ tried = 0; /* The player has "tried" one of the items */
- u32b esp = 0; /* ESP flags */
- u32b oesp = 0; /* Obvious ESP flags */
-
byte btval = 0; /* Become Object type */
byte bsval = 0; /* Become Object sub type */
bool_ artifact = 0; /* Is it a normal artifact(already generated) */
diff --git a/src/object_type.hpp b/src/object_type.hpp
index c0f59547..48d18cf1 100644
--- a/src/object_type.hpp
+++ b/src/object_type.hpp
@@ -1,6 +1,7 @@
#pragma once
#include "h-basic.h"
+#include "object_flag_set.hpp"
/**
* Object information for a specific object.
@@ -77,19 +78,8 @@ struct object_type
u16b note = 0; /* Inscription index */
u16b art_name = 0; /* Artifact name (random artifacts) */
- u32b art_flags1 = 0; /* Flags, set 1 Alas, these were necessary */
- u32b art_flags2 = 0; /* Flags, set 2 for the random artifacts of*/
- u32b art_flags3 = 0; /* Flags, set 3 Zangband */
- u32b art_flags4 = 0; /* Flags, set 4 PernAngband */
- u32b art_flags5 = 0; /* Flags, set 5 PernAngband */
- u32b art_esp = 0; /* Flags, set esp PernAngband */
-
- u32b art_oflags1 = 0; /* Obvious Flags, set 1 */
- u32b art_oflags2 = 0; /* Obvious Flags, set 2 */
- u32b art_oflags3 = 0; /* Obvious Flags, set 3 */
- u32b art_oflags4 = 0; /* Obvious Flags, set 4 */
- u32b art_oflags5 = 0; /* Obvious Flags, set 5 */
- u32b art_oesp = 0; /* Obvious Flags, set esp */
+ object_flag_set art_flags; /* Flags */
+ object_flag_set art_oflags; /* Obvious flags */
s16b held_m_idx = 0; /* Monster holding the object; if any */
diff --git a/src/player_class.hpp b/src/player_class.hpp
index c5fc8916..98414158 100644
--- a/src/player_class.hpp
+++ b/src/player_class.hpp
@@ -2,6 +2,7 @@
#include "body.hpp"
#include "h-basic.h"
+#include "object_flag_set.hpp"
#include "player_defs.hpp"
#include "player_spec.hpp"
@@ -78,12 +79,7 @@ struct player_class
char body_parts[BODY_MAX] { }; /* To help to decide what to use when body changing */
- u32b oflags1[PY_MAX_LEVEL + 1] { };
- u32b oflags2[PY_MAX_LEVEL + 1] { };
- u32b oflags3[PY_MAX_LEVEL + 1] { };
- u32b oflags4[PY_MAX_LEVEL + 1] { };
- u32b oflags5[PY_MAX_LEVEL + 1] { };
- u32b oesp[PY_MAX_LEVEL + 1] { };
+ std::array<object_flag_set, PY_MAX_LEVEL + 1> oflags;
s16b opval[PY_MAX_LEVEL + 1] { };
char skill_basem[MAX_SKILLS] { };
diff --git a/src/player_race.hpp b/src/player_race.hpp
index f1933557..e01034ba 100644
--- a/src/player_race.hpp
+++ b/src/player_race.hpp
@@ -2,6 +2,7 @@
#include "h-basic.h"
#include "body.hpp"
+#include "object_flag_set.hpp"
#include "player_defs.hpp"
#include "player_race_ability_type.hpp"
#include "skills_defs.hpp"
@@ -45,12 +46,7 @@ struct player_race
u32b flags1 = 0;
u32b flags2 = 0;
- u32b oflags1[PY_MAX_LEVEL + 1] { };
- u32b oflags2[PY_MAX_LEVEL + 1] { };
- u32b oflags3[PY_MAX_LEVEL + 1] { };
- u32b oflags4[PY_MAX_LEVEL + 1] { };
- u32b oflags5[PY_MAX_LEVEL + 1] { };
- u32b oesp[PY_MAX_LEVEL + 1] { };
+ std::array<object_flag_set, PY_MAX_LEVEL + 1> oflags;
s16b opval[PY_MAX_LEVEL + 1] { };
char skill_basem[MAX_SKILLS] { };
diff --git a/src/player_race_mod.hpp b/src/player_race_mod.hpp
index 23be55d7..983c3471 100644
--- a/src/player_race_mod.hpp
+++ b/src/player_race_mod.hpp
@@ -2,6 +2,7 @@
#include "body.hpp"
#include "h-basic.h"
+#include "object_flag_set.hpp"
#include "player_defs.hpp"
#include "player_race_ability_type.hpp"
#include "skills_defs.hpp"
@@ -46,12 +47,7 @@ struct player_race_mod
u32b flags1 = 0;
u32b flags2 = 0;
- u32b oflags1[PY_MAX_LEVEL + 1] { };
- u32b oflags2[PY_MAX_LEVEL + 1] { };
- u32b oflags3[PY_MAX_LEVEL + 1] { };
- u32b oflags4[PY_MAX_LEVEL + 1] { };
- u32b oflags5[PY_MAX_LEVEL + 1] { };
- u32b oesp[PY_MAX_LEVEL + 1] { };
+ std::array<object_flag_set, PY_MAX_LEVEL + 1> oflags;
s16b opval[PY_MAX_LEVEL + 1] { };
byte g_attr = 0; /* Overlay graphic attribute */
diff --git a/src/player_type.hpp b/src/player_type.hpp
index 7e615715..0e89605c 100644
--- a/src/player_type.hpp
+++ b/src/player_type.hpp
@@ -275,7 +275,6 @@ struct player_type
bool_ see_inv = FALSE; /* Can see invisible */
bool_ regenerate = FALSE; /* Regenerate hit pts */
bool_ hold_life = FALSE; /* Resist life draining */
- u32b telepathy = 0; /* Telepathy */
bool_ slow_digest = FALSE; /* Slower digestion */
bool_ bless_blade = FALSE; /* Blessed blade */
byte xtra_might = 0; /* Extra might bow */
@@ -356,13 +355,11 @@ struct player_type
bool_ precognition = FALSE; /* Like the cheat mode */
- /*** Extra flags -- used for lua and easying stuff ***/
- u32b xtra_f1 = 0;
- u32b xtra_f2 = 0;
- u32b xtra_f3 = 0;
- u32b xtra_f4 = 0;
- u32b xtra_f5 = 0;
- u32b xtra_esp = 0;
+ /*** Extra flags ***/
+ object_flag_set xtra_flags;
+
+ /** Computed flags based on all worn items, etc. */
+ object_flag_set computed_flags;
/* Corruptions */
bool_ corruptions[CORRUPTIONS_MAX] = { FALSE };
diff --git a/src/q_fireprof.cc b/src/q_fireprof.cc
index 1e75b1b1..777ce690 100644
--- a/src/q_fireprof.cc
+++ b/src/q_fireprof.cc
@@ -8,6 +8,7 @@
#include "lua_bind.hpp"
#include "object1.hpp"
#include "object2.hpp"
+#include "object_flag.hpp"
#include "object_type.hpp"
#include "player_type.hpp"
#include "quark.hpp"
@@ -90,7 +91,7 @@ static object_filter_t const &item_tester_hook_proofable()
TVal(TV_STAFF)),
// Must NOT already be fireproof
Not(
- HasFlag3(TR3_IGNORE_FIRE)));
+ HasFlags(TR_IGNORE_FIRE)));
return instance;
}
diff --git a/src/q_rand.cc b/src/q_rand.cc
index f22675b7..62511dec 100644
--- a/src/q_rand.cc
+++ b/src/q_rand.cc
@@ -21,6 +21,7 @@
#include "monster_type.hpp"
#include "object1.hpp"
#include "object2.hpp"
+#include "object_flag.hpp"
#include "object_kind.hpp"
#include "object_type.hpp"
#include "player_type.hpp"
@@ -266,7 +267,7 @@ static void do_get_new_obj(int y, int x)
{
random_artifacts[o_ptr->sval].generated = FALSE;
}
- else if (k_info[o_ptr->k_idx].flags3 & TR3_NORM_ART)
+ else if (k_info[o_ptr->k_idx].flags & TR_NORM_ART)
{
k_info[o_ptr->k_idx].artifact = FALSE;
}
diff --git a/src/q_ultrag.cc b/src/q_ultrag.cc
index c7c0312b..fcee52a2 100644
--- a/src/q_ultrag.cc
+++ b/src/q_ultrag.cc
@@ -10,6 +10,7 @@
#include "monster_type.hpp"
#include "object1.hpp"
#include "object2.hpp"
+#include "object_flag.hpp"
#include "object_type.hpp"
#include "options.hpp"
#include "player_type.hpp"
@@ -119,15 +120,13 @@ static bool_ quest_ultra_good_stair_hook(void *, void *in_, void *)
/* Now look for an ULTIMATE artifact, that is, one imbued with the flame */
for (i = INVEN_WIELD; i < INVEN_TOTAL; i++)
{
- u32b f1, f2, f3, f4, f5, esp;
object_type *o_ptr = get_object(i);
if (!o_ptr->k_idx) continue;
- /* Examine the gloves */
- object_flags(o_ptr, &f1, &f2, &f3, &f4, &f5, &esp);
+ auto const flags = object_flags(o_ptr);
- if (f4 & TR4_ULTIMATE)
+ if (flags & TR_ULTIMATE)
{
ultimate = TRUE;
break;
diff --git a/src/q_wight.cc b/src/q_wight.cc
index f2cc630c..7d459dee 100644
--- a/src/q_wight.cc
+++ b/src/q_wight.cc
@@ -9,6 +9,7 @@
#include "monster2.hpp"
#include "monster_type.hpp"
#include "object2.hpp"
+#include "object_flag.hpp"
#include "player_type.hpp"
#include "quark.hpp"
#include "tables.hpp"
@@ -76,23 +77,30 @@ static bool_ quest_wight_gen_hook(void *, void *, void *)
q_ptr->art_name = quark_add("of the Wight");
- q_ptr->art_flags1 |= ( TR1_INT | TR1_SEARCH );
- q_ptr->art_flags2 |= ( TR2_RES_BLIND | TR2_SENS_FIRE | TR2_RES_CONF );
- q_ptr->art_flags3 |= ( TR3_IGNORE_ACID | TR3_IGNORE_ELEC |
- TR3_IGNORE_FIRE | TR3_IGNORE_COLD | TR3_SEE_INVIS);
+ q_ptr->art_flags |=
+ TR_INT |
+ TR_SEARCH |
+ TR_RES_BLIND |
+ TR_SENS_FIRE |
+ TR_RES_CONF |
+ TR_IGNORE_ACID |
+ TR_IGNORE_ELEC |
+ TR_IGNORE_FIRE |
+ TR_IGNORE_COLD |
+ TR_SEE_INVIS |
+ TR_CURSED |
+ TR_HEAVY_CURSE;
- /* For game balance... */
- q_ptr->art_flags3 |= (TR3_CURSED | TR3_HEAVY_CURSE);
q_ptr->ident |= IDENT_CURSED;
if (randint(2) == 1)
{
- q_ptr->art_flags1 |= (TR1_SPELL);
+ q_ptr->art_flags |= TR_SPELL;
q_ptr->pval = 6;
}
else
{
- q_ptr->art_flags1 |= (TR1_MANA);
+ q_ptr->art_flags |= TR_MANA;
q_ptr->pval = 2;
}
diff --git a/src/randart.cc b/src/randart.cc
index 5135438a..9528faee 100644
--- a/src/randart.cc
+++ b/src/randart.cc
@@ -10,6 +10,7 @@
#include "mimic.hpp"
#include "object1.hpp"
#include "object2.hpp"
+#include "object_flag.hpp"
#include "object_type.hpp"
#include "options.hpp"
#include "player_type.hpp"
@@ -37,7 +38,6 @@
static bool_ grab_one_power(int *ra_idx, object_type *o_ptr, bool_ good, s16b *max_times)
{
bool_ ret = FALSE;
- u32b f1, f2, f3, f4, f5, esp;
std::vector<size_t> ok_ra;
@@ -71,13 +71,8 @@ static bool_ grab_one_power(int *ra_idx, object_type *o_ptr, bool_ good, s16b *m
if (max_times[i] >= ra_ptr->max) continue;
/* Must NOT have the antagonic flags */
- object_flags(o_ptr, &f1, &f2, &f3, &f4, &f5, &esp);
- if (f1 & ra_ptr->aflags1) continue;
- if (f2 & ra_ptr->aflags2) continue;
- if (f3 & ra_ptr->aflags3) continue;
- if (f4 & ra_ptr->aflags4) continue;
- if (f5 & ra_ptr->aflags5) continue;
- if (esp & ra_ptr->aesp) continue;
+ auto const flags = object_flags(o_ptr);
+ if (flags & ra_ptr->aflags) continue;
/* ok */
ok_ra.push_back(i);
@@ -124,7 +119,7 @@ static bool_ grab_one_power(int *ra_idx, object_type *o_ptr, bool_ good, s16b *m
void give_activation_power (object_type * o_ptr)
{
o_ptr->xtra2 = 0;
- o_ptr->art_flags3 &= ~TR3_ACTIVATE;
+ o_ptr->art_flags &= ~TR_ACTIVATE;
o_ptr->timeout = 0;
}
@@ -268,7 +263,6 @@ bool_ create_artifact(object_type *o_ptr, bool_ a_scroll, bool_ get_name)
int powers = 0, i;
s32b total_flags, total_power = 0;
bool_ a_cursed = FALSE;
- u32b f1, f2, f3, f4, f5, esp;
s16b pval = 0;
bool_ limit_blows = FALSE;
@@ -308,20 +302,15 @@ bool_ create_artifact(object_type *o_ptr, bool_ a_scroll, bool_ get_name)
total_power += ra_ptr->value;
- o_ptr->art_flags1 |= ra_ptr->flags1;
- o_ptr->art_flags2 |= ra_ptr->flags2;
- o_ptr->art_flags3 |= ra_ptr->flags3;
- o_ptr->art_flags4 |= ra_ptr->flags4;
- o_ptr->art_flags5 |= ra_ptr->flags5;
- o_ptr->art_esp |= ra_ptr->esp;
+ o_ptr->art_flags |= ra_ptr->flags;
add_random_ego_flag(o_ptr, ra_ptr->fego, &limit_blows);
/* get flags */
- object_flags(o_ptr, &f1, &f2, &f3, &f4, &f5, &esp);
+ auto const flags = object_flags(o_ptr);
/* Hack -- acquire "cursed" flag */
- if (f3 & TR3_CURSED) o_ptr->ident |= (IDENT_CURSED);
+ if (flags & TR_CURSED) o_ptr->ident |= (IDENT_CURSED);
/* Hack -- obtain bonuses */
if (ra_ptr->max_to_h > 0) o_ptr->to_h += randint(ra_ptr->max_to_h);
@@ -339,23 +328,23 @@ bool_ create_artifact(object_type *o_ptr, bool_ a_scroll, bool_ get_name)
if (pval < 0) o_ptr->pval = randint( -pval);
/* No insane number of blows */
- if (limit_blows && (o_ptr->art_flags1 & TR1_BLOWS))
+ if (limit_blows && (o_ptr->art_flags & TR_BLOWS))
{
if (o_ptr->pval > 2) o_ptr->pval = randint(2);
}
/* Just to be sure */
- o_ptr->art_flags3 |= ( TR3_IGNORE_ACID | TR3_IGNORE_ELEC |
- TR3_IGNORE_FIRE | TR3_IGNORE_COLD);
+ o_ptr->art_flags |=
+ TR_IGNORE_ACID |
+ TR_IGNORE_ELEC |
+ TR_IGNORE_FIRE |
+ TR_IGNORE_COLD;
total_flags = flag_cost(o_ptr, o_ptr->pval);
if (cheat_peek) msg_format("%ld", total_flags);
if (a_cursed) curse_artifact(o_ptr);
- /* Extract the flags */
- object_flags(o_ptr, &f1, &f2, &f3, &f4, &f5, &esp);
-
if (get_name)
{
if (a_scroll)
@@ -393,13 +382,16 @@ bool_ create_artifact(object_type *o_ptr, bool_ a_scroll, bool_ get_name)
/* Window stuff */
p_ptr->window |= (PW_INVEN | PW_EQUIP);
+ /* Extract the flags */
+ auto const flags = object_flags(o_ptr);
+
/* HACKS for ToME */
if (o_ptr->tval == TV_CLOAK && o_ptr->sval == SV_MIMIC_CLOAK)
{
s32b mimic = find_random_mimic_shape(127, TRUE);
o_ptr->pval2 = mimic;
}
- else if (f5 & TR5_SPELL_CONTAIN)
+ else if (flags & TR_SPELL_CONTAIN)
{
o_ptr->pval2 = -1;
}
diff --git a/src/randart_part_type.hpp b/src/randart_part_type.hpp
index c2fa5386..39329a57 100644
--- a/src/randart_part_type.hpp
+++ b/src/randart_part_type.hpp
@@ -1,43 +1,35 @@
#pragma once
#include "h-basic.h"
+#include "object_flag_set.hpp"
/**
* Random artifact part descriptor.
*/
struct randart_part_type
{
- byte tval[20];
- byte min_sval[20];
- byte max_sval[20];
-
- byte level; /* Minimum level */
- byte rarity; /* Object rarity */
- byte mrarity; /* Object rarity */
-
- s16b max_to_h; /* Maximum to-hit bonus */
- s16b max_to_d; /* Maximum to-dam bonus */
- s16b max_to_a; /* Maximum to-ac bonus */
-
- s32b max_pval; /* Maximum pval */
-
- s32b value; /* power value */
- s16b max; /* Number of time it can appear on a single item */
-
- u32b flags1; /* Ego-Item Flags, set 1 */
- u32b flags2; /* Ego-Item Flags, set 2 */
- u32b flags3; /* Ego-Item Flags, set 3 */
- u32b flags4; /* Ego-Item Flags, set 4 */
- u32b flags5; /* Ego-Item Flags, set 5 */
- u32b esp; /* ESP flags */
- u32b fego; /* ego flags */
-
- u32b aflags1; /* Ego-Item Flags, set 1 */
- u32b aflags2; /* Ego-Item Flags, set 2 */
- u32b aflags3; /* Ego-Item Flags, set 3 */
- u32b aflags4; /* Ego-Item Flags, set 4 */
- u32b aflags5; /* Ego-Item Flags, set 5 */
- u32b aesp; /* ESP flags */
-
- s16b power; /* Power granted(if any) */
+ byte tval[20] { };
+ byte min_sval[20] { };
+ byte max_sval[20] { };
+
+ byte level = 0; /* Minimum level */
+ byte rarity = 0; /* Object rarity */
+ byte mrarity = 0; /* Object rarity */
+
+ s16b max_to_h = 0; /* Maximum to-hit bonus */
+ s16b max_to_d = 0; /* Maximum to-dam bonus */
+ s16b max_to_a = 0; /* Maximum to-ac bonus */
+
+ s32b max_pval = 0; /* Maximum pval */
+
+ s32b value = 0; /* power value */
+ s16b max = 0; /* Number of time it can appear on a single item */
+
+ object_flag_set flags; /* Ego item flags */
+
+ u32b fego = 0; /* ego flags */
+
+ object_flag_set aflags; /* Antagonistic ego item flags */
+
+ s16b power = 0; /* Power granted(if any) */
};
diff --git a/src/set_component.hpp b/src/set_component.hpp
index ceb82cbd..18dc4d57 100644
--- a/src/set_component.hpp
+++ b/src/set_component.hpp
@@ -1,6 +1,7 @@
#pragma once
#include "h-basic.h"
+#include "object_flag_set.hpp"
#include <array>
#include <cstdint>
@@ -8,13 +9,8 @@
constexpr std::size_t SET_MAX_SIZE = 6;
struct set_component {
- bool_ present = FALSE; /* Is it actually wore ? */
- s16b a_idx = 0; /* What artifact? */
- std::array<s16b, SET_MAX_SIZE> pval; /* Pval for each combination */
- std::array<u32b, SET_MAX_SIZE> flags1; /* Flags */
- std::array<u32b, SET_MAX_SIZE> flags2; /* Flags */
- std::array<u32b, SET_MAX_SIZE> flags3; /* Flags */
- std::array<u32b, SET_MAX_SIZE> flags4; /* Flags */
- std::array<u32b, SET_MAX_SIZE> flags5; /* Flags */
- std::array<u32b, SET_MAX_SIZE> esp; /* Flags */
+ bool_ present = FALSE; /* Is it being worn? */
+ s16b a_idx = 0; /* What artifact? */
+ std::array<s16b , SET_MAX_SIZE> pval; /* Pval for each combination */
+ std::array<object_flag_set, SET_MAX_SIZE> flags; /* Flags */
};
diff --git a/src/spells1.cc b/src/spells1.cc
index 2b34e98c..bd5f7c99 100644
--- a/src/spells1.cc
+++ b/src/spells1.cc
@@ -27,6 +27,7 @@
#include "monster_type.hpp"
#include "object1.hpp"
#include "object2.hpp"
+#include "object_flag.hpp"
#include "object_kind.hpp"
#include "options.hpp"
#include "player_type.hpp"
@@ -1730,12 +1731,10 @@ static bool_ hates_cold(object_type *o_ptr)
*/
static int set_acid_destroy(object_type *o_ptr)
{
- u32b f1, f2, f3, f4, f5, esp;
-
if (!hates_acid(o_ptr)) return (FALSE);
- object_flags(o_ptr, &f1, &f2, &f3, &f4, &f5, &esp);
- if (f3 & (TR3_IGNORE_ACID)) return (FALSE);
+ auto const f = object_flags(o_ptr);
+ if (f & TR_IGNORE_ACID) return (FALSE);
return (TRUE);
}
@@ -1745,12 +1744,10 @@ static int set_acid_destroy(object_type *o_ptr)
*/
static int set_elec_destroy(object_type *o_ptr)
{
- u32b f1, f2, f3, f4, f5, esp;
-
if (!hates_elec(o_ptr)) return (FALSE);
- object_flags(o_ptr, &f1, &f2, &f3, &f4, &f5, &esp);
- if (f3 & (TR3_IGNORE_ELEC)) return (FALSE);
+ auto const f = object_flags(o_ptr);
+ if (f & TR_IGNORE_ELEC) return (FALSE);
return (TRUE);
}
@@ -1760,12 +1757,10 @@ static int set_elec_destroy(object_type *o_ptr)
*/
static int set_fire_destroy(object_type *o_ptr)
{
- u32b f1, f2, f3, f4, f5, esp;
-
if (!hates_fire(o_ptr)) return (FALSE);
- object_flags(o_ptr, &f1, &f2, &f3, &f4, &f5, &esp);
- if (f3 & (TR3_IGNORE_FIRE)) return (FALSE);
+ auto const f = object_flags(o_ptr);
+ if (f & TR_IGNORE_FIRE) return (FALSE);
return (TRUE);
}
@@ -1775,12 +1770,10 @@ static int set_fire_destroy(object_type *o_ptr)
*/
static int set_cold_destroy(object_type *o_ptr)
{
- u32b f1, f2, f3, f4, f5, esp;
-
if (!hates_cold(o_ptr)) return (FALSE);
- object_flags(o_ptr, &f1, &f2, &f3, &f4, &f5, &esp);
- if (f3 & (TR3_IGNORE_COLD)) return (FALSE);
+ auto const f = object_flags(o_ptr);
+ if (f & (TR_IGNORE_COLD)) return (FALSE);
return (TRUE);
}
@@ -1888,8 +1881,6 @@ static int minus_ac(void)
{
object_type *o_ptr = NULL;
- u32b f1, f2, f3, f4, f5, esp;
-
char o_name[80];
@@ -1927,10 +1918,10 @@ static int minus_ac(void)
object_desc(o_name, o_ptr, FALSE, 0);
/* Extract the flags */
- object_flags(o_ptr, &f1, &f2, &f3, &f4, &f5, &esp);
+ auto const flags = object_flags(o_ptr);
/* Object resists */
- if (f3 & (TR3_IGNORE_ACID))
+ if (flags & TR_IGNORE_ACID)
{
msg_format("Your %s is unaffected!", o_name);
@@ -3839,8 +3830,6 @@ static bool_ project_o(int who, int r, int y, int x, int dam, int typ)
bool_ obvious = FALSE;
- u32b f1, f2, f3, f4, f5, esp;
-
char o_name[80];
int o_sval = 0;
@@ -3873,7 +3862,7 @@ static bool_ project_o(int who, int r, int y, int x, int dam, int typ)
object_type * o_ptr = &o_list[this_o_idx];
/* Extract the flags */
- object_flags(o_ptr, &f1, &f2, &f3, &f4, &f5, &esp);
+ auto const flags = object_flags(o_ptr);
/* Get the "plural"-ness */
if (o_ptr->number > 1) plural = TRUE;
@@ -3917,7 +3906,7 @@ static bool_ project_o(int who, int r, int y, int x, int dam, int typ)
{
do_kill = TRUE;
note_kill = (plural ? " melt!" : " melts!");
- if (f3 & (TR3_IGNORE_ACID)) ignore = TRUE;
+ if (flags & TR_IGNORE_ACID) ignore = TRUE;
}
break;
}
@@ -3929,7 +3918,7 @@ static bool_ project_o(int who, int r, int y, int x, int dam, int typ)
{
do_kill = TRUE;
note_kill = (plural ? " are destroyed!" : " is destroyed!");
- if (f3 & (TR3_IGNORE_ELEC)) ignore = TRUE;
+ if (flags & TR_IGNORE_ELEC) ignore = TRUE;
}
break;
}
@@ -3941,7 +3930,7 @@ static bool_ project_o(int who, int r, int y, int x, int dam, int typ)
{
do_kill = TRUE;
note_kill = (plural ? " burn up!" : " burns up!");
- if (f3 & (TR3_IGNORE_FIRE)) ignore = TRUE;
+ if (flags & TR_IGNORE_FIRE) ignore = TRUE;
}
break;
}
@@ -3953,7 +3942,7 @@ static bool_ project_o(int who, int r, int y, int x, int dam, int typ)
{
note_kill = (plural ? " shatter!" : " shatters!");
do_kill = TRUE;
- if (f3 & (TR3_IGNORE_COLD)) ignore = TRUE;
+ if (flags & TR_IGNORE_COLD) ignore = TRUE;
}
break;
}
@@ -3965,14 +3954,14 @@ static bool_ project_o(int who, int r, int y, int x, int dam, int typ)
{
do_kill = TRUE;
note_kill = (plural ? " burn up!" : " burns up!");
- if (f3 & (TR3_IGNORE_FIRE)) ignore = TRUE;
+ if (flags & TR_IGNORE_FIRE) ignore = TRUE;
}
if (hates_elec(o_ptr))
{
ignore = FALSE;
do_kill = TRUE;
note_kill = (plural ? " are destroyed!" : " is destroyed!");
- if (f3 & (TR3_IGNORE_ELEC)) ignore = TRUE;
+ if (flags & TR_IGNORE_ELEC) ignore = TRUE;
}
break;
}
@@ -3984,14 +3973,14 @@ static bool_ project_o(int who, int r, int y, int x, int dam, int typ)
{
do_kill = TRUE;
note_kill = (plural ? " burn up!" : " burns up!");
- if (f3 & (TR3_IGNORE_FIRE)) ignore = TRUE;
+ if (flags & TR_IGNORE_FIRE) ignore = TRUE;
}
if (hates_cold(o_ptr))
{
ignore = FALSE;
do_kill = TRUE;
note_kill = (plural ? " shatter!" : " shatters!");
- if (f3 & (TR3_IGNORE_COLD)) ignore = TRUE;
+ if (flags & TR_IGNORE_COLD) ignore = TRUE;
}
break;
}
@@ -4029,7 +4018,7 @@ static bool_ project_o(int who, int r, int y, int x, int dam, int typ)
{
do_kill = TRUE;
note_kill = (plural ? " are destroyed!" : " is destroyed!");
- if (f2 & (TR2_RES_CHAOS)) ignore = TRUE;
+ if (flags & TR_RES_CHAOS) ignore = TRUE;
break;
}
diff --git a/src/spells2.cc b/src/spells2.cc
index 010bc424..60aafc16 100644
--- a/src/spells2.cc
+++ b/src/spells2.cc
@@ -28,6 +28,7 @@
#include "notes.hpp"
#include "object1.hpp"
#include "object2.hpp"
+#include "object_flag.hpp"
#include "object_kind.hpp"
#include "object_type.hpp"
#include "options.hpp"
@@ -547,8 +548,6 @@ static int enchant_table[16] =
static bool_ remove_curse_object(object_type *o_ptr, bool_ all)
{
- u32b f1, f2, f3, f4, f5, esp;
-
/* Skip non-objects */
if (!o_ptr->k_idx) return FALSE;
@@ -556,13 +555,13 @@ static bool_ remove_curse_object(object_type *o_ptr, bool_ all)
if (!cursed_p(o_ptr)) return FALSE;
/* Extract the flags */
- object_flags(o_ptr, &f1, &f2, &f3, &f4, &f5, &esp);
+ auto const flags = object_flags(o_ptr);
/* Heavily Cursed Items need a special spell */
- if (!all && (f3 & (TR3_HEAVY_CURSE))) return FALSE;
+ if (!all && (flags & TR_HEAVY_CURSE)) return FALSE;
/* Perma-Cursed Items can NEVER be uncursed */
- if (f3 & (TR3_PERMA_CURSE)) return FALSE;
+ if (flags & TR_PERMA_CURSE) return FALSE;
/* Uncurse it */
o_ptr->ident &= ~(IDENT_CURSED);
@@ -570,11 +569,9 @@ static bool_ remove_curse_object(object_type *o_ptr, bool_ all)
/* Hack -- Assume felt */
o_ptr->ident |= (IDENT_SENSE);
- if (o_ptr->art_flags3 & (TR3_CURSED))
- o_ptr->art_flags3 &= ~(TR3_CURSED);
-
- if (o_ptr->art_flags3 & (TR3_HEAVY_CURSE))
- o_ptr->art_flags3 &= ~(TR3_HEAVY_CURSE);
+ /* Strip curse flags */
+ o_ptr->art_flags &= ~TR_CURSED;
+ o_ptr->art_flags &= ~TR_HEAVY_CURSE;
/* Take note */
o_ptr->sense = SENSE_UNCURSED;
@@ -803,8 +800,6 @@ void self_knowledge(FILE *fff)
{
int i = 0, j, k;
- u32b f1 = 0L, f2 = 0L, f3 = 0L, f4 = 0L, f5 = 0L, esp = 0L;
-
int iter; /* Iterator for a loop */
object_type *o_ptr;
@@ -816,22 +811,16 @@ void self_knowledge(FILE *fff)
strcpy (Dummy, "");
/* Acquire item flags from equipment */
+ auto flags = object_flag_set();
for (k = INVEN_WIELD; k < INVEN_TOTAL; k++)
{
- u32b t1, t2, t3, t4, t5, esp;
-
o_ptr = &p_ptr->inventory[k];
/* Skip non-objects */
if (!o_ptr->k_idx) continue;
/* Extract the flags */
- object_flags(o_ptr, &t1, &t2, &t3, &t4, &t5, &esp);
-
- /* Extract flags */
- f1 |= t1;
- f2 |= t2;
- f3 |= t3;
+ flags |= object_flags(o_ptr);
}
if (death)
@@ -1326,24 +1315,27 @@ void self_knowledge(FILE *fff)
{
info[i++] = "Your appetite is small.";
}
- if (p_ptr->telepathy)
+ // Telepathy
{
- if (p_ptr->telepathy & ESP_ALL) info[i++] = "You have ESP.";
+ if (p_ptr->computed_flags & ESP_ALL)
+ {
+ info[i++] = "You have ESP.";
+ }
else
{
- if (p_ptr->telepathy & ESP_ORC) info[i++] = "You can sense the presence of orcs.";
- if (p_ptr->telepathy & ESP_TROLL) info[i++] = "You can sense the presence of trolls.";
- if (p_ptr->telepathy & ESP_DRAGON) info[i++] = "You can sense the presence of dragons.";
- if (p_ptr->telepathy & ESP_SPIDER) info[i++] = "You can sense the presence of spiders.";
- if (p_ptr->telepathy & ESP_GIANT) info[i++] = "You can sense the presence of giants.";
- if (p_ptr->telepathy & ESP_DEMON) info[i++] = "You can sense the presence of demons.";
- if (p_ptr->telepathy & ESP_UNDEAD) info[i++] = "You can sense presence of undead.";
- if (p_ptr->telepathy & ESP_EVIL) info[i++] = "You can sense the presence of evil beings.";
- if (p_ptr->telepathy & ESP_ANIMAL) info[i++] = "You can sense the presence of animals.";
- if (p_ptr->telepathy & ESP_THUNDERLORD) info[i++] = "You can sense the presence of thunderlords.";
- if (p_ptr->telepathy & ESP_GOOD) info[i++] = "You can sense the presence of good beings.";
- if (p_ptr->telepathy & ESP_NONLIVING) info[i++] = "You can sense the presence of non-living things.";
- if (p_ptr->telepathy & ESP_UNIQUE) info[i++] = "You can sense the presence of unique beings.";
+ if (p_ptr->computed_flags & ESP_ORC) info[i++] = "You can sense the presence of orcs.";
+ if (p_ptr->computed_flags & ESP_TROLL) info[i++] = "You can sense the presence of trolls.";
+ if (p_ptr->computed_flags & ESP_DRAGON) info[i++] = "You can sense the presence of dragons.";
+ if (p_ptr->computed_flags & ESP_SPIDER) info[i++] = "You can sense the presence of spiders.";
+ if (p_ptr->computed_flags & ESP_GIANT) info[i++] = "You can sense the presence of giants.";
+ if (p_ptr->computed_flags & ESP_DEMON) info[i++] = "You can sense the presence of demons.";
+ if (p_ptr->computed_flags & ESP_UNDEAD) info[i++] = "You can sense presence of undead.";
+ if (p_ptr->computed_flags & ESP_EVIL) info[i++] = "You can sense the presence of evil beings.";
+ if (p_ptr->computed_flags & ESP_ANIMAL) info[i++] = "You can sense the presence of animals.";
+ if (p_ptr->computed_flags & ESP_THUNDERLORD) info[i++] = "You can sense the presence of thunderlords.";
+ if (p_ptr->computed_flags & ESP_GOOD) info[i++] = "You can sense the presence of good beings.";
+ if (p_ptr->computed_flags & ESP_NONLIVING) info[i++] = "You can sense the presence of non-living things.";
+ if (p_ptr->computed_flags & ESP_UNIQUE) info[i++] = "You can sense the presence of unique beings.";
}
}
if (!luck( -100, 100))
@@ -1576,56 +1568,56 @@ void self_knowledge(FILE *fff)
info[i++] = "You suffer from Black Breath.";
}
- if (f1 & (TR1_STR))
+ if (flags & TR_STR)
{
info[i++] = "Your strength is affected by your equipment.";
}
- if (f1 & (TR1_INT))
+ if (flags & TR_INT)
{
info[i++] = "Your intelligence is affected by your equipment.";
}
- if (f1 & (TR1_WIS))
+ if (flags & TR_WIS)
{
info[i++] = "Your wisdom is affected by your equipment.";
}
- if (f1 & (TR1_DEX))
+ if (flags & TR_DEX)
{
info[i++] = "Your dexterity is affected by your equipment.";
}
- if (f1 & (TR1_CON))
+ if (flags & TR_CON)
{
info[i++] = "Your constitution is affected by your equipment.";
}
- if (f1 & (TR1_CHR))
+ if (flags & TR_CHR)
{
info[i++] = "Your charisma is affected by your equipment.";
}
- if (f1 & (TR1_STEALTH))
+ if (flags & TR_STEALTH)
{
info[i++] = "Your stealth is affected by your equipment.";
}
- if (f1 & (TR1_SEARCH))
+ if (flags & TR_SEARCH)
{
info[i++] = "Your searching ability is affected by your equipment.";
}
- if (f1 & (TR1_INFRA))
+ if (flags & TR_INFRA)
{
info[i++] = "Your infravision is affected by your equipment.";
}
- if (f1 & (TR1_TUNNEL))
+ if (flags & TR_TUNNEL)
{
info[i++] = "Your digging ability is affected by your equipment.";
}
- if (f1 & (TR1_SPEED))
+ if (flags & TR_SPEED)
{
info[i++] = "Your speed is affected by your equipment.";
}
- if (f1 & (TR1_BLOWS))
+ if (flags & TR_BLOWS)
{
info[i++] = "Your attack speed is affected by your equipment.";
}
- if (f5 & (TR5_CRIT))
+ if (flags & TR_CRIT)
{
info[i++] = "Your ability to score critical hits is affected by your equipment.";
}
@@ -1637,103 +1629,103 @@ void self_knowledge(FILE *fff)
/* Analyze the weapon */
if (o_ptr->k_idx)
{
- object_flags(o_ptr, &f1, &f2, &f3, &f4, &f5, &esp);
+ flags = object_flags(o_ptr);
/* Indicate Blessing */
- if (f3 & (TR3_BLESSED))
+ if (flags & TR_BLESSED)
{
info[i++] = "Your weapon has been blessed by the gods.";
}
- if (f1 & (TR1_CHAOTIC))
+ if (flags & TR_CHAOTIC)
{
info[i++] = "Your weapon is branded with the Sign of Chaos.";
}
/* Hack */
- if (f1 & (TR1_IMPACT))
+ if (flags & TR_IMPACT)
{
info[i++] = "The impact of your weapon can cause earthquakes.";
}
- if (f1 & (TR1_VORPAL))
+ if (flags & TR_VORPAL)
{
info[i++] = "Your weapon is very sharp.";
}
- if (f1 & (TR1_VAMPIRIC))
+ if (flags & TR_VAMPIRIC)
{
info[i++] = "Your weapon drains life from your foes.";
}
/* Special "Attack Bonuses" */
- if (f1 & (TR1_BRAND_ACID))
+ if (flags & TR_BRAND_ACID)
{
info[i++] = "Your weapon melts your foes.";
}
- if (f1 & (TR1_BRAND_ELEC))
+ if (flags & TR_BRAND_ELEC)
{
info[i++] = "Your weapon shocks your foes.";
}
- if (f1 & (TR1_BRAND_FIRE))
+ if (flags & TR_BRAND_FIRE)
{
info[i++] = "Your weapon burns your foes.";
}
- if (f1 & (TR1_BRAND_COLD))
+ if (flags & TR_BRAND_COLD)
{
info[i++] = "Your weapon freezes your foes.";
}
- if (f1 & (TR1_BRAND_POIS))
+ if (flags & TR_BRAND_POIS)
{
info[i++] = "Your weapon poisons your foes.";
}
/* Special "slay" flags */
- if (f1 & (TR1_SLAY_ANIMAL))
+ if (flags & TR_SLAY_ANIMAL)
{
info[i++] = "Your weapon strikes at animals with extra force.";
}
- if (f1 & (TR1_SLAY_EVIL))
+ if (flags & TR_SLAY_EVIL)
{
info[i++] = "Your weapon strikes at evil with extra force.";
}
- if (f1 & (TR1_SLAY_UNDEAD))
+ if (flags & TR_SLAY_UNDEAD)
{
info[i++] = "Your weapon strikes at undead with holy wrath.";
}
- if (f1 & (TR1_SLAY_DEMON))
+ if (flags & TR_SLAY_DEMON)
{
info[i++] = "Your weapon strikes at demons with holy wrath.";
}
- if (f1 & (TR1_SLAY_ORC))
+ if (flags & TR_SLAY_ORC)
{
info[i++] = "Your weapon is especially deadly against orcs.";
}
- if (f1 & (TR1_SLAY_TROLL))
+ if (flags & TR_SLAY_TROLL)
{
info[i++] = "Your weapon is especially deadly against trolls.";
}
- if (f1 & (TR1_SLAY_GIANT))
+ if (flags & TR_SLAY_GIANT)
{
info[i++] = "Your weapon is especially deadly against giants.";
}
- if (f1 & (TR1_SLAY_DRAGON))
+ if (flags & TR_SLAY_DRAGON)
{
info[i++] = "Your weapon is especially deadly against dragons.";
}
/* Special "kill" flags */
- if (f1 & (TR1_KILL_DRAGON))
+ if (flags & TR_KILL_DRAGON)
{
info[i++] = "Your weapon is a great bane of dragons.";
}
/* Special "kill" flags */
- if (f5 & (TR5_KILL_DEMON))
+ if (flags & TR_KILL_DEMON)
{
info[i++] = "Your weapon is a great bane of demons.";
}
/* Special "kill" flags */
- if (f5 & (TR5_KILL_UNDEAD))
+ if (flags & TR_KILL_UNDEAD)
{
info[i++] = "Your weapon is a great bane of undeads.";
}
@@ -2711,11 +2703,10 @@ bool_ enchant(object_type *o_ptr, int n, int eflag)
int i, chance, prob;
bool_ res = FALSE;
bool_ a = (artifact_p(o_ptr) || o_ptr->art_name);
- u32b f1, f2, f3, f4, f5, esp;
/* Extract the flags */
- object_flags(o_ptr, &f1, &f2, &f3, &f4, &f5, &esp);
+ auto const flags = object_flags(o_ptr);
/* Large piles resist enchantment */
prob = o_ptr->number * 100;
@@ -2748,17 +2739,17 @@ bool_ enchant(object_type *o_ptr, int n, int eflag)
/* only when you get it above -1 -CFT */
if (cursed_p(o_ptr) &&
- (!(f3 & (TR3_PERMA_CURSE))) &&
+ (!(flags & TR_PERMA_CURSE)) &&
(o_ptr->to_h >= 0) && (rand_int(100) < 25))
{
msg_print("The curse is broken!");
o_ptr->ident &= ~(IDENT_CURSED);
o_ptr->ident |= (IDENT_SENSE);
- if (o_ptr->art_flags3 & (TR3_CURSED))
- o_ptr->art_flags3 &= ~(TR3_CURSED);
- if (o_ptr->art_flags3 & (TR3_HEAVY_CURSE))
- o_ptr->art_flags3 &= ~(TR3_HEAVY_CURSE);
+ if (o_ptr->art_flags & TR_CURSED)
+ o_ptr->art_flags &= ~TR_CURSED;
+ if (o_ptr->art_flags & TR_HEAVY_CURSE)
+ o_ptr->art_flags &= ~TR_HEAVY_CURSE;
o_ptr->sense = SENSE_UNCURSED;
}
@@ -2779,17 +2770,17 @@ bool_ enchant(object_type *o_ptr, int n, int eflag)
/* only when you get it above -1 -CFT */
if (cursed_p(o_ptr) &&
- (!(f3 & (TR3_PERMA_CURSE))) &&
+ (!(flags & TR_PERMA_CURSE)) &&
(o_ptr->to_d >= 0) && (rand_int(100) < 25))
{
msg_print("The curse is broken!");
o_ptr->ident &= ~(IDENT_CURSED);
o_ptr->ident |= (IDENT_SENSE);
- if (o_ptr->art_flags3 & (TR3_CURSED))
- o_ptr->art_flags3 &= ~(TR3_CURSED);
- if (o_ptr->art_flags3 & (TR3_HEAVY_CURSE))
- o_ptr->art_flags3 &= ~(TR3_HEAVY_CURSE);
+ if (o_ptr->art_flags & TR_CURSED)
+ o_ptr->art_flags &= ~TR_CURSED;
+ if (o_ptr->art_flags & TR_HEAVY_CURSE)
+ o_ptr->art_flags &= ~TR_HEAVY_CURSE;
o_ptr->sense = SENSE_UNCURSED;
}
@@ -2811,17 +2802,17 @@ bool_ enchant(object_type *o_ptr, int n, int eflag)
/* only when you get it above -1 -CFT */
if (cursed_p(o_ptr) &&
- (!(f3 & (TR3_PERMA_CURSE))) &&
+ (!(flags & TR_PERMA_CURSE)) &&
(o_ptr->pval >= 0) && (rand_int(100) < 25))
{
msg_print("The curse is broken!");
o_ptr->ident &= ~(IDENT_CURSED);
o_ptr->ident |= (IDENT_SENSE);
- if (o_ptr->art_flags3 & (TR3_CURSED))
- o_ptr->art_flags3 &= ~(TR3_CURSED);
- if (o_ptr->art_flags3 & (TR3_HEAVY_CURSE))
- o_ptr->art_flags3 &= ~(TR3_HEAVY_CURSE);
+ if (o_ptr->art_flags & TR_CURSED)
+ o_ptr->art_flags &= ~TR_CURSED;
+ if (o_ptr->art_flags & TR_HEAVY_CURSE)
+ o_ptr->art_flags &= ~TR_HEAVY_CURSE;
o_ptr->sense = SENSE_UNCURSED;
}
@@ -2842,17 +2833,17 @@ bool_ enchant(object_type *o_ptr, int n, int eflag)
/* only when you get it above -1 -CFT */
if (cursed_p(o_ptr) &&
- (!(f3 & (TR3_PERMA_CURSE))) &&
+ (!(flags & TR_PERMA_CURSE)) &&
(o_ptr->to_a >= 0) && (rand_int(100) < 25))
{
msg_print("The curse is broken!");
o_ptr->ident &= ~(IDENT_CURSED);
o_ptr->ident |= (IDENT_SENSE);
- if (o_ptr->art_flags3 & (TR3_CURSED))
- o_ptr->art_flags3 &= ~(TR3_CURSED);
- if (o_ptr->art_flags3 & (TR3_HEAVY_CURSE))
- o_ptr->art_flags3 &= ~(TR3_HEAVY_CURSE);
+ if (o_ptr->art_flags & TR_CURSED)
+ o_ptr->art_flags &= ~TR_CURSED;
+ if (o_ptr->art_flags & TR_HEAVY_CURSE)
+ o_ptr->art_flags &= ~TR_HEAVY_CURSE;
o_ptr->sense = SENSE_UNCURSED;
}
@@ -2942,13 +2933,13 @@ void curse_artifact(object_type * o_ptr)
if (o_ptr->to_a) o_ptr->to_a = 0 - ((o_ptr->to_a) + randint(4));
if (o_ptr->to_h) o_ptr->to_h = 0 - ((o_ptr->to_h) + randint(4));
if (o_ptr->to_d) o_ptr->to_d = 0 - ((o_ptr->to_d) + randint(4));
- o_ptr->art_flags3 |= ( TR3_HEAVY_CURSE | TR3_CURSED );
- if (randint(3) == 1) o_ptr-> art_flags3 |= TR3_TY_CURSE;
- if (randint(2) == 1) o_ptr-> art_flags3 |= TR3_AGGRAVATE;
- if (randint(3) == 1) o_ptr-> art_flags3 |= TR3_DRAIN_EXP;
- if (randint(3) == 1) o_ptr-> art_flags4 |= TR4_BLACK_BREATH;
- if (randint(2) == 1) o_ptr-> art_flags3 |= TR3_TELEPORT;
- else if (randint(3) == 1) o_ptr->art_flags3 |= TR3_NO_TELE;
+ o_ptr->art_flags |= TR_HEAVY_CURSE | TR_CURSED;
+ if (randint(3) == 1) o_ptr-> art_flags |= TR_TY_CURSE;
+ if (randint(2) == 1) o_ptr-> art_flags |= TR_AGGRAVATE;
+ if (randint(3) == 1) o_ptr-> art_flags |= TR_DRAIN_EXP;
+ if (randint(3) == 1) o_ptr-> art_flags |= TR_BLACK_BREATH;
+ if (randint(2) == 1) o_ptr-> art_flags |= TR_TELEPORT;
+ else if (randint(3) == 1) o_ptr->art_flags |= TR_NO_TELE;
o_ptr->ident |= IDENT_CURSED;
}
@@ -2961,122 +2952,122 @@ void random_resistance(object_type *o_ptr, int specific)
{
if (artifact_bias == BIAS_ACID)
{
- if (!(o_ptr->art_flags2 & TR2_RES_ACID))
+ if (!(o_ptr->art_flags & TR_RES_ACID))
{
- o_ptr->art_flags2 |= TR2_RES_ACID;
+ o_ptr->art_flags |= TR_RES_ACID;
if (rand_int(2) == 0) return;
}
- if (rand_int(BIAS_LUCK) == 0 && !(o_ptr->art_flags2 & TR2_IM_ACID))
+ if (rand_int(BIAS_LUCK) == 0 && !(o_ptr->art_flags & TR_IM_ACID))
{
- o_ptr->art_flags2 |= TR2_IM_ACID;
+ o_ptr->art_flags |= TR_IM_ACID;
if (rand_int(2) == 0) return;
}
}
else if (artifact_bias == BIAS_ELEC)
{
- if (!(o_ptr->art_flags2 & TR2_RES_ELEC))
+ if (!(o_ptr->art_flags & TR_RES_ELEC))
{
- o_ptr->art_flags2 |= TR2_RES_ELEC;
+ o_ptr->art_flags |= TR_RES_ELEC;
if (rand_int(2) == 0) return;
}
if (o_ptr->tval >= TV_CLOAK && o_ptr->tval <= TV_HARD_ARMOR &&
- !(o_ptr->art_flags3 & TR3_SH_ELEC))
+ !(o_ptr->art_flags & TR_SH_ELEC))
{
- o_ptr->art_flags2 |= TR3_SH_ELEC;
+ o_ptr->art_flags |= TR_SH_ELEC;
if (rand_int(2) == 0) return;
}
- if (rand_int(BIAS_LUCK) == 0 && !(o_ptr->art_flags2 & TR2_IM_ELEC))
+ if (rand_int(BIAS_LUCK) == 0 && !(o_ptr->art_flags & TR_IM_ELEC))
{
- o_ptr->art_flags2 |= TR2_IM_ELEC;
+ o_ptr->art_flags |= TR_IM_ELEC;
if (rand_int(2) == 1) return;
}
}
else if (artifact_bias == BIAS_FIRE)
{
- if (!(o_ptr->art_flags2 & TR2_RES_FIRE))
+ if (!(o_ptr->art_flags & TR_RES_FIRE))
{
- o_ptr->art_flags2 |= TR2_RES_FIRE;
+ o_ptr->art_flags |= TR_RES_FIRE;
if (rand_int(2) == 0) return;
}
if (o_ptr->tval >= TV_CLOAK && o_ptr->tval <= TV_HARD_ARMOR &&
- !(o_ptr->art_flags3 & TR3_SH_FIRE))
+ !(o_ptr->art_flags & TR_SH_FIRE))
{
- o_ptr->art_flags2 |= TR3_SH_FIRE;
+ o_ptr->art_flags |= TR_SH_FIRE;
if (rand_int(2) == 0) return;
}
- if (rand_int(BIAS_LUCK) == 0 && !(o_ptr->art_flags2 & TR2_IM_FIRE))
+ if (rand_int(BIAS_LUCK) == 0 && !(o_ptr->art_flags & TR_IM_FIRE))
{
- o_ptr->art_flags2 |= TR2_IM_FIRE;
+ o_ptr->art_flags |= TR_IM_FIRE;
if (rand_int(2) == 0) return;
}
}
else if (artifact_bias == BIAS_COLD)
{
- if (!(o_ptr->art_flags2 & TR2_RES_COLD))
+ if (!(o_ptr->art_flags & TR_RES_COLD))
{
- o_ptr->art_flags2 |= TR2_RES_COLD;
+ o_ptr->art_flags |= TR_RES_COLD;
if (rand_int(2) == 0) return;
}
- if (rand_int(BIAS_LUCK) == 0 && !(o_ptr->art_flags2 & TR2_IM_COLD))
+ if (rand_int(BIAS_LUCK) == 0 && !(o_ptr->art_flags & TR_IM_COLD))
{
- o_ptr->art_flags2 |= TR2_IM_COLD;
+ o_ptr->art_flags |= TR_IM_COLD;
if (rand_int(2) == 0) return;
}
}
else if (artifact_bias == BIAS_POIS)
{
- if (!(o_ptr->art_flags2 & TR2_RES_POIS))
+ if (!(o_ptr->art_flags & TR_RES_POIS))
{
- o_ptr->art_flags2 |= TR2_RES_POIS;
+ o_ptr->art_flags |= TR_RES_POIS;
if (rand_int(2) == 0) return;
}
}
else if (artifact_bias == BIAS_WARRIOR)
{
- if (rand_int(3) && (!(o_ptr->art_flags2 & TR2_RES_FEAR)))
+ if (rand_int(3) && (!(o_ptr->art_flags & TR_RES_FEAR)))
{
- o_ptr->art_flags2 |= TR2_RES_FEAR;
+ o_ptr->art_flags |= TR_RES_FEAR;
if (rand_int(2) == 0) return;
}
- if ((rand_int(3) == 0) && (!(o_ptr->art_flags3 & TR3_NO_MAGIC)))
+ if ((rand_int(3) == 0) && (!(o_ptr->art_flags & TR_NO_MAGIC)))
{
- o_ptr->art_flags3 |= TR3_NO_MAGIC;
+ o_ptr->art_flags |= TR_NO_MAGIC;
if (rand_int(2) == 0) return;
}
}
else if (artifact_bias == BIAS_NECROMANTIC)
{
- if (!(o_ptr->art_flags2 & TR2_RES_NETHER))
+ if (!(o_ptr->art_flags & TR_RES_NETHER))
{
- o_ptr->art_flags2 |= TR2_RES_NETHER;
+ o_ptr->art_flags |= TR_RES_NETHER;
if (rand_int(2) == 0) return;
}
- if (!(o_ptr->art_flags2 & TR2_RES_POIS))
+ if (!(o_ptr->art_flags & TR_RES_POIS))
{
- o_ptr->art_flags2 |= TR2_RES_POIS;
+ o_ptr->art_flags |= TR_RES_POIS;
if (rand_int(2) == 0) return;
}
- if (!(o_ptr->art_flags2 & TR2_RES_DARK))
+ if (!(o_ptr->art_flags & TR_RES_DARK))
{
- o_ptr->art_flags2 |= TR2_RES_DARK;
+ o_ptr->art_flags |= TR_RES_DARK;
if (rand_int(2) == 0) return;
}
}
else if (artifact_bias == BIAS_CHAOS)
{
- if (!(o_ptr->art_flags2 & TR2_RES_CHAOS))
+ if (!(o_ptr->art_flags & TR_RES_CHAOS))
{
- o_ptr->art_flags2 |= TR2_RES_CHAOS;
+ o_ptr->art_flags |= TR_RES_CHAOS;
if (rand_int(2) == 0) return;
}
- if (!(o_ptr->art_flags2 & TR2_RES_CONF))
+ if (!(o_ptr->art_flags & TR_RES_CONF))
{
- o_ptr->art_flags2 |= TR2_RES_CONF;
+ o_ptr->art_flags |= TR_RES_CONF;
if (rand_int(2) == 0) return;
}
- if (!(o_ptr->art_flags2 & TR2_RES_DISEN))
+ if (!(o_ptr->art_flags & TR_RES_DISEN))
{
- o_ptr->art_flags2 |= TR2_RES_DISEN;
+ o_ptr->art_flags |= TR_RES_DISEN;
if (rand_int(2) == 0) return;
}
}
@@ -3089,7 +3080,7 @@ void random_resistance(object_type *o_ptr, int specific)
random_resistance(o_ptr, specific);
else
{
- o_ptr->art_flags2 |= TR2_IM_ACID;
+ o_ptr->art_flags |= TR_IM_ACID;
/* if (is_scroll) msg_print("It looks totally incorruptible."); */
if (!(artifact_bias))
artifact_bias = BIAS_ACID;
@@ -3100,7 +3091,7 @@ void random_resistance(object_type *o_ptr, int specific)
random_resistance(o_ptr, specific);
else
{
- o_ptr->art_flags2 |= TR2_IM_ELEC;
+ o_ptr->art_flags |= TR_IM_ELEC;
/* if (is_scroll) msg_print("It looks completely grounded."); */
if (!(artifact_bias))
artifact_bias = BIAS_ELEC;
@@ -3111,7 +3102,7 @@ void random_resistance(object_type *o_ptr, int specific)
random_resistance(o_ptr, specific);
else
{
- o_ptr->art_flags2 |= TR2_IM_COLD;
+ o_ptr->art_flags |= TR_IM_COLD;
/* if (is_scroll) msg_print("It feels very warm."); */
if (!(artifact_bias))
artifact_bias = BIAS_COLD;
@@ -3122,7 +3113,7 @@ void random_resistance(object_type *o_ptr, int specific)
random_resistance(o_ptr, specific);
else
{
- o_ptr->art_flags2 |= TR2_IM_FIRE;
+ o_ptr->art_flags |= TR_IM_FIRE;
/* if (is_scroll) msg_print("It feels very cool."); */
if (!(artifact_bias))
artifact_bias = BIAS_FIRE;
@@ -3131,7 +3122,7 @@ void random_resistance(object_type *o_ptr, int specific)
case 5:
case 6:
case 13:
- o_ptr->art_flags2 |= TR2_RES_ACID;
+ o_ptr->art_flags |= TR_RES_ACID;
/* if (is_scroll) msg_print("It makes your stomach rumble."); */
if (!(artifact_bias))
artifact_bias = BIAS_ACID;
@@ -3139,7 +3130,7 @@ void random_resistance(object_type *o_ptr, int specific)
case 7:
case 8:
case 14:
- o_ptr->art_flags2 |= TR2_RES_ELEC;
+ o_ptr->art_flags |= TR_RES_ELEC;
/* if (is_scroll) msg_print("It makes you feel grounded."); */
if (!(artifact_bias))
artifact_bias = BIAS_ELEC;
@@ -3147,7 +3138,7 @@ void random_resistance(object_type *o_ptr, int specific)
case 9:
case 10:
case 15:
- o_ptr->art_flags2 |= TR2_RES_FIRE;
+ o_ptr->art_flags |= TR_RES_FIRE;
/* if (is_scroll) msg_print("It makes you feel cool!");*/
if (!(artifact_bias))
artifact_bias = BIAS_FIRE;
@@ -3155,14 +3146,14 @@ void random_resistance(object_type *o_ptr, int specific)
case 11:
case 12:
case 16:
- o_ptr->art_flags2 |= TR2_RES_COLD;
+ o_ptr->art_flags |= TR_RES_COLD;
/* if (is_scroll) msg_print("It makes you feel full of hot air!");*/
if (!(artifact_bias))
artifact_bias = BIAS_COLD;
break;
case 17:
case 18:
- o_ptr->art_flags2 |= TR2_RES_POIS;
+ o_ptr->art_flags |= TR_RES_POIS;
/* if (is_scroll) msg_print("It makes breathing easier for you."); */
if (!(artifact_bias) && randint(4) != 1)
artifact_bias = BIAS_POIS;
@@ -3173,68 +3164,68 @@ void random_resistance(object_type *o_ptr, int specific)
break;
case 19:
case 20:
- o_ptr->art_flags2 |= TR2_RES_FEAR;
+ o_ptr->art_flags |= TR_RES_FEAR;
/* if (is_scroll) msg_print("It makes you feel brave!"); */
if (!(artifact_bias) && randint(3) == 1)
artifact_bias = BIAS_WARRIOR;
break;
case 21:
- o_ptr->art_flags2 |= TR2_RES_LITE;
+ o_ptr->art_flags |= TR_RES_LITE;
/* if (is_scroll) msg_print("It makes everything look darker.");*/
break;
case 22:
- o_ptr->art_flags2 |= TR2_RES_DARK;
+ o_ptr->art_flags |= TR_RES_DARK;
/* if (is_scroll) msg_print("It makes everything look brigher.");*/
break;
case 23:
case 24:
- o_ptr->art_flags2 |= TR2_RES_BLIND;
+ o_ptr->art_flags |= TR_RES_BLIND;
/* if (is_scroll) msg_print("It makes you feel you are wearing glasses.");*/
break;
case 25:
case 26:
- o_ptr->art_flags2 |= TR2_RES_CONF;
+ o_ptr->art_flags |= TR_RES_CONF;
/* if (is_scroll) msg_print("It makes you feel very determined.");*/
if (!(artifact_bias) && randint(6) == 1)
artifact_bias = BIAS_CHAOS;
break;
case 27:
case 28:
- o_ptr->art_flags2 |= TR2_RES_SOUND;
+ o_ptr->art_flags |= TR_RES_SOUND;
/* if (is_scroll) msg_print("It makes you feel deaf!");*/
break;
case 29:
case 30:
- o_ptr->art_flags2 |= TR2_RES_SHARDS;
+ o_ptr->art_flags |= TR_RES_SHARDS;
/* if (is_scroll) msg_print("It makes your skin feel thicker.");*/
break;
case 31:
case 32:
- o_ptr->art_flags2 |= TR2_RES_NETHER;
+ o_ptr->art_flags |= TR_RES_NETHER;
/* if (is_scroll) msg_print("It makes you feel like visiting a graveyard!");*/
if (!(artifact_bias) && randint(3) == 1)
artifact_bias = BIAS_NECROMANTIC;
break;
case 33:
case 34:
- o_ptr->art_flags2 |= TR2_RES_NEXUS;
+ o_ptr->art_flags |= TR_RES_NEXUS;
/* if (is_scroll) msg_print("It makes you feel normal.");*/
break;
case 35:
case 36:
- o_ptr->art_flags2 |= TR2_RES_CHAOS;
+ o_ptr->art_flags |= TR_RES_CHAOS;
/* if (is_scroll) msg_print("It makes you feel very firm.");*/
if (!(artifact_bias) && randint(2) == 1)
artifact_bias = BIAS_CHAOS;
break;
case 37:
case 38:
- o_ptr->art_flags2 |= TR2_RES_DISEN;
+ o_ptr->art_flags |= TR_RES_DISEN;
/* if (is_scroll) msg_print("It is surrounded by a static feeling.");*/
break;
case 39:
if (o_ptr->tval >= TV_CLOAK && o_ptr->tval <= TV_HARD_ARMOR)
- o_ptr->art_flags3 |= TR3_SH_ELEC;
+ o_ptr->art_flags |= TR_SH_ELEC;
else
random_resistance(o_ptr, specific);
if (!(artifact_bias))
@@ -3242,7 +3233,7 @@ void random_resistance(object_type *o_ptr, int specific)
break;
case 40:
if (o_ptr->tval >= TV_CLOAK && o_ptr->tval <= TV_HARD_ARMOR)
- o_ptr->art_flags3 |= TR3_SH_FIRE;
+ o_ptr->art_flags |= TR_SH_FIRE;
else
random_resistance(o_ptr, specific);
if (!(artifact_bias))
@@ -3251,7 +3242,7 @@ void random_resistance(object_type *o_ptr, int specific)
case 41:
if (o_ptr->tval == TV_SHIELD || o_ptr->tval == TV_CLOAK ||
o_ptr->tval == TV_HELM || o_ptr->tval == TV_HARD_ARMOR)
- o_ptr->art_flags2 |= TR2_REFLECT;
+ o_ptr->art_flags |= TR_REFLECT;
else
random_resistance(o_ptr, specific);
break;
@@ -3460,7 +3451,7 @@ object_filter_t const &item_tester_hook_recharge()
static auto instance =
And(
// Must NOT have NO_RECHARGE flag.
- Not(HasFlag4(TR4_NO_RECHARGE)),
+ Not(HasFlags(TR_NO_RECHARGE)),
// ... and must be a device.
Or(
TVal(TV_STAFF),
@@ -3514,8 +3505,7 @@ bool_ recharge(int power)
object_type *o_ptr = get_object(item);
/* Extract the flags */
- u32b f1, f2, f3, f4, f5, esp;
- object_flags(o_ptr, &f1, &f2, &f3, &f4, &f5, &esp);
+ auto const flags = object_flags(o_ptr);
/* Extract the object "level" */
lev = k_info[o_ptr->k_idx].level;
@@ -3530,7 +3520,7 @@ bool_ recharge(int power)
if (recharge_strength < 0) recharge_strength = 0;
/* Back-fire */
- if ((rand_int(recharge_strength) == 0) && (!(f4 & TR4_RECHARGE)))
+ if ((rand_int(recharge_strength) == 0) && (!(flags & TR_RECHARGE)))
{
/* Activate the failure code. */
fail = TRUE;
@@ -3567,8 +3557,8 @@ bool_ recharge(int power)
/* Back-fire XXX XXX XXX */
- if (((rand_int(recharge_strength) == 0) && (!(f4 & TR4_RECHARGE))) ||
- (f4 & TR4_NO_RECHARGE))
+ if (((rand_int(recharge_strength) == 0) && (!(flags & TR_RECHARGE))) ||
+ (flags & TR_NO_RECHARGE))
{
/* Activate the failure code. */
fail = TRUE;
@@ -3601,7 +3591,7 @@ bool_ recharge(int power)
/* Recharge the wand or staff. */
o_ptr->pval += recharge_amount;
- if (!(f4 & TR4_RECHARGE))
+ if (!(flags & TR_RECHARGE))
{
/* Hack -- we no longer "know" the item */
o_ptr->ident &= ~(IDENT_KNOWN);
@@ -3613,7 +3603,7 @@ bool_ recharge(int power)
}
/* Mark as recharged */
- o_ptr->art_flags4 |= TR4_RECHARGED;
+ o_ptr->art_flags |= TR_RECHARGED;
/* Inflict the penalties for failing a recharge. */
if (fail)
@@ -5799,7 +5789,7 @@ case 27: case 28: case 29:
if (p_ptr->inventory[INVEN_WIELD].k_idx)
{
msg_print("Your weapon now seems useless...");
- p_ptr->inventory[INVEN_WIELD].art_flags4 = TR4_NEVER_BLOW;
+ p_ptr->inventory[INVEN_WIELD].art_flags = TR_NEVER_BLOW;
}
break;
case 25:
diff --git a/src/squelch/rule.cc b/src/squelch/rule.cc
index 1c17d2fd..2bdef61b 100644
--- a/src/squelch/rule.cc
+++ b/src/squelch/rule.cc
@@ -8,6 +8,7 @@
#include "../modules.hpp"
#include "../object1.hpp"
#include "../object2.hpp"
+#include "../object_flag.hpp"
#include "../object_type.hpp"
#include "../quark.hpp"
#include "../tables.hpp"
@@ -250,10 +251,8 @@ bool DestroyRule::do_apply_rule(object_type *o_ptr, int item_idx) const
// Cannot destroy CURSE_NO_DROP objects.
{
- u32b f1, f2, f3, f4, f5, esp;
- object_flags(o_ptr, &f1, &f2, &f3, &f4, &f5, &esp);
-
- if ((f4 & TR4_CURSE_NO_DROP) != 0)
+ auto const f = object_flags(o_ptr);
+ if (f & TR_CURSE_NO_DROP)
{
return false;
}
diff --git a/src/store.cc b/src/store.cc
index 088de82a..972dd096 100644
--- a/src/store.cc
+++ b/src/store.cc
@@ -19,6 +19,7 @@
#include "obj_theme.hpp"
#include "object1.hpp"
#include "object2.hpp"
+#include "object_flag.hpp"
#include "object_kind.hpp"
#include "options.hpp"
#include "owner_type.hpp"
@@ -523,9 +524,7 @@ static bool_ store_object_similar(object_type const *o_ptr, object_type *j_ptr)
if (o_ptr->art_name || j_ptr->art_name) return (0);
/* Hack -- Identical art_flags! */
- if ((o_ptr->art_flags1 != j_ptr->art_flags1) ||
- (o_ptr->art_flags2 != j_ptr->art_flags2) ||
- (o_ptr->art_flags3 != j_ptr->art_flags3))
+ if (o_ptr->art_flags != j_ptr->art_flags)
return (0);
/* Hack -- Never stack "powerful" items */
@@ -622,12 +621,10 @@ static bool_ store_check_num(object_type *o_ptr)
}
-static bool_ is_blessed(object_type const *o_ptr)
+static bool is_blessed(object_type const *o_ptr)
{
- u32b f1, f2, f3, f4, f5, esp;
- object_flags_known(o_ptr, &f1, &f2, &f3, &f4, &f5, &esp);
- if (f3 & TR3_BLESSED) return (TRUE);
- else return (FALSE);
+ auto flags = object_flags_known(o_ptr);
+ return bool(flags & TR_BLESSED);
}
@@ -1173,10 +1170,10 @@ static bool_ kind_is_storeok(int k_idx)
{
object_kind *k_ptr = &k_info[k_idx];
- if (k_info[k_idx].flags3 & TR3_NORM_ART)
+ if (k_info[k_idx].flags & TR_NORM_ART)
return ( FALSE );
- if (k_info[k_idx].flags3 & TR3_INSTA_ART)
+ if (k_info[k_idx].flags & TR_INSTA_ART)
return ( FALSE );
if (!kind_is_legal(k_idx)) return FALSE;
@@ -1288,7 +1285,7 @@ static void store_create(void)
chance = st_info[st_ptr->st_idx].table[item][1];
/* Don't allow k_info artifacts */
- if ((i <= 10000) && (k_info[i].flags3 & TR3_NORM_ART))
+ if ((i <= 10000) && (k_info[i].flags & TR_NORM_ART))
continue;
/* Does it passes the rarity check ? */
@@ -1328,11 +1325,11 @@ static void store_create(void)
if (!obj_all_done)
{
/* Don't allow k_info artifacts */
- if (k_info[i].flags3 & TR3_NORM_ART)
+ if (k_info[i].flags & TR_NORM_ART)
continue;
/* Don't allow artifacts */
- if (k_info[i].flags3 & TR3_INSTA_ART)
+ if (k_info[i].flags & TR_INSTA_ART)
continue;
/* Get local object */
@@ -1347,11 +1344,11 @@ static void store_create(void)
/* Hack -- Charge lite's */
if (q_ptr->tval == TV_LITE)
{
- u32b f1, f2, f3, f4, f5, esp;
-
- object_flags(q_ptr, &f1, &f2, &f3, &f4, &f5, &esp);
-
- if (f4 & TR4_FUEL_LITE) q_ptr->timeout = k_info[q_ptr->k_idx].pval2;
+ auto const flags = object_flags(q_ptr);
+ if (flags & TR_FUEL_LITE)
+ {
+ q_ptr->timeout = k_info[q_ptr->k_idx].pval2;
+ }
}
}
@@ -2401,12 +2398,8 @@ void store_sell(void)
object_type forge;
object_type *q_ptr;
- object_type *o_ptr;
-
char o_name[80];
- u32b f1, f2, f3, f4, f5, esp;
-
bool_ museum = (st_info[st_ptr->st_idx].flags1 & SF1_MUSEUM) ? TRUE : FALSE;
/* Prepare prompt */
@@ -2434,9 +2427,9 @@ void store_sell(void)
}
/* Get the item */
- o_ptr = get_object(item);
+ auto o_ptr = get_object(item);
- object_flags(o_ptr, &f1, &f2, &f3, &f4, &f5, &esp);
+ auto const flags = object_flags(o_ptr);
/* Hack -- Cannot remove cursed items */
if (cursed_p(o_ptr))
@@ -2451,7 +2444,7 @@ void store_sell(void)
}
else
{
- if (f4 & TR4_CURSE_NO_DROP)
+ if (flags & TR_CURSE_NO_DROP)
{
/* Oops */
msg_print("Hmmm, you seem to be unable to drop it.");
diff --git a/src/tables.cc b/src/tables.cc
index debee270..ba86c577 100644
--- a/src/tables.cc
+++ b/src/tables.cc
@@ -12,6 +12,7 @@
#include "modules.hpp"
#include "monster_race_flag.hpp"
#include "monster_spell_flag.hpp"
+#include "object_flag.hpp"
#include "options.hpp"
#include "q_library.hpp"
#include "q_fireprof.hpp"
@@ -2662,121 +2663,92 @@ extern std::vector<flags_group> const &flags_groups()
"Fire",
TERM_L_RED,
1,
- TR1_SLAY_UNDEAD | TR1_BRAND_FIRE,
- TR2_RES_FIRE,
- TR3_SH_FIRE | TR3_LITE1 | TR3_IGNORE_FIRE,
- 0,
- 0,
+ TR_SLAY_UNDEAD | TR_BRAND_FIRE | TR_RES_FIRE |
+ TR_SH_FIRE | TR_LITE1 | TR_IGNORE_FIRE,
},
flags_group {
"Cold",
TERM_WHITE,
1,
- TR1_SLAY_DRAGON | TR1_SLAY_DEMON | TR1_BRAND_COLD,
- TR2_RES_COLD | TR2_INVIS,
- TR3_SLOW_DIGEST | TR3_IGNORE_COLD,
- 0,
- 0,
+ TR_SLAY_DRAGON | TR_SLAY_DEMON | TR_BRAND_COLD | TR_RES_COLD |
+ TR_INVIS | TR_SLOW_DIGEST | TR_IGNORE_COLD,
},
flags_group {
"Acid",
TERM_GREEN,
3,
- TR1_SLAY_ANIMAL | TR1_IMPACT | TR1_TUNNEL | TR1_BRAND_ACID,
- TR2_RES_ACID,
- TR3_IGNORE_ACID,
- 0,
- 0,
+ TR_SLAY_ANIMAL | TR_IMPACT | TR_TUNNEL |
+ TR_BRAND_ACID | TR_RES_ACID | TR_IGNORE_ACID,
},
flags_group {
"Lightning",
TERM_L_BLUE,
1,
- TR1_SLAY_EVIL | TR1_BRAND_ELEC,
- TR2_RES_ELEC,
- TR3_IGNORE_ELEC | TR3_SH_ELEC | TR3_TELEPORT,
- 0,
- 0,
+ TR_SLAY_EVIL | TR_BRAND_ELEC | TR_RES_ELEC |
+ TR_IGNORE_ELEC | TR_SH_ELEC | TR_TELEPORT,
},
flags_group {
"Poison",
TERM_L_GREEN,
2,
- TR1_CHR | TR1_VAMPIRIC | TR1_SLAY_ANIMAL | TR1_BRAND_POIS,
- TR2_SUST_CHR | TR2_RES_POIS,
- TR3_DRAIN_EXP,
- 0,
- ESP_TROLL | ESP_GIANT,
+ TR_CHR | TR_VAMPIRIC | TR_SLAY_ANIMAL | TR_BRAND_POIS |
+ TR_SUST_CHR | TR_RES_POIS | TR_DRAIN_EXP |
+ ESP_TROLL | ESP_GIANT,
},
flags_group {
"Air",
TERM_BLUE,
5,
- TR1_WIS | TR1_STEALTH | TR1_INFRA | TR1_SPEED,
- TR2_RES_LITE | TR2_RES_DARK | TR2_RES_BLIND | TR2_SUST_WIS,
- TR3_FEATHER | TR3_SEE_INVIS | TR3_BLESSED,
- 0,
- ESP_GOOD,
+ TR_WIS | TR_STEALTH | TR_INFRA | TR_SPEED |
+ TR_RES_LITE | TR_RES_DARK | TR_RES_BLIND | TR_SUST_WIS |
+ TR_FEATHER | TR_SEE_INVIS | TR_BLESSED |
+ ESP_GOOD,
},
flags_group {
"Earth",
TERM_L_UMBER,
5,
- TR1_STR | TR1_CON | TR1_TUNNEL | TR1_BLOWS | TR1_SLAY_TROLL | TR1_SLAY_GIANT | TR1_IMPACT,
- TR2_SUST_STR | TR2_SUST_CON | TR2_FREE_ACT | TR2_RES_FEAR | TR2_RES_SHARDS,
- TR3_REGEN,
- 0,
+ TR_STR | TR_CON | TR_TUNNEL | TR_BLOWS | TR_SLAY_TROLL |
+ TR_SLAY_GIANT | TR_IMPACT | TR_SUST_STR | TR_SUST_CON |
+ TR_FREE_ACT | TR_RES_FEAR | TR_RES_SHARDS | TR_REGEN |
ESP_TROLL | ESP_GIANT,
},
flags_group {
"Mind",
TERM_YELLOW,
7,
- TR1_INT | TR1_SEARCH,
- TR2_SUST_INT | TR2_RES_CONF | TR2_RES_FEAR,
- 0,
- 0,
+ TR_INT | TR_SEARCH | TR_SUST_INT | TR_RES_CONF | TR_RES_FEAR |
ESP_ORC | ESP_TROLL | ESP_GIANT | ESP_ANIMAL | ESP_UNIQUE | ESP_SPIDER | ESP_DEMON,
},
flags_group {
"Shield",
TERM_RED,
7,
- TR1_DEX,
- TR2_SUST_DEX | TR2_INVIS | TR2_REFLECT | TR2_HOLD_LIFE | TR2_RES_SOUND | TR2_RES_NEXUS,
- TR3_REGEN,
- 0,
- 0,
+ TR_DEX | TR_SUST_DEX | TR_INVIS | TR_REFLECT |
+ TR_HOLD_LIFE | TR_RES_SOUND | TR_RES_NEXUS |
+ TR_REGEN,
},
flags_group {
"Chaos",
TERM_VIOLET,
7,
- TR1_CHAOTIC | TR1_IMPACT,
- TR2_RES_CHAOS | TR2_RES_DISEN,
- TR3_REGEN,
- 0,
+ TR_CHAOTIC | TR_IMPACT | TR_RES_CHAOS | TR_RES_DISEN | TR_REGEN |
ESP_ALL,
},
flags_group {
"Magic",
TERM_L_BLUE,
10,
- TR1_MANA | TR1_SPELL,
- TR2_RES_CHAOS | TR2_RES_DISEN,
- TR3_WRAITH,
- TR4_PRECOGNITION | TR4_FLY | TR4_CLONE,
- 0,
+ TR_MANA | TR_SPELL | TR_RES_CHAOS | TR_RES_DISEN | TR_WRAITH |
+ TR_PRECOGNITION | TR_FLY | TR_CLONE,
},
flags_group {
"Antimagic",
TERM_L_DARK,
10,
- TR1_VAMPIRIC | TR1_CHAOTIC | TR1_BLOWS | TR1_SPEED,
- TR2_LIFE | TR2_REFLECT | TR2_FREE_ACT | TR2_HOLD_LIFE,
- TR3_NO_MAGIC | TR3_NO_TELE | TR3_SEE_INVIS,
- TR4_ANTIMAGIC_50,
- 0,
+ TR_VAMPIRIC | TR_CHAOTIC | TR_BLOWS | TR_SPEED | TR_LIFE |
+ TR_REFLECT | TR_FREE_ACT | TR_HOLD_LIFE | TR_NO_MAGIC |
+ TR_NO_TELE | TR_SEE_INVIS | TR_ANTIMAGIC_50,
}
};
diff --git a/src/traps.cc b/src/traps.cc
index 8786e858..2f8578d4 100644
--- a/src/traps.cc
+++ b/src/traps.cc
@@ -25,6 +25,7 @@
#include "monster_type.hpp"
#include "object1.hpp"
#include "object2.hpp"
+#include "object_flag.hpp"
#include "object_kind.hpp"
#include "player_race.hpp"
#include "player_race_mod.hpp"
@@ -974,7 +975,6 @@ bool_ player_activate_trap_type(s16b y, s16b x, object_type *i_ptr, s16b item)
{
s16b i, j, slot1, slot2;
object_type *j_ptr, *k_ptr;
- u32b f1, f2, f3, f4, f5, esp;
for (i = INVEN_WIELD; i < INVEN_TOTAL; i++)
{
@@ -983,8 +983,8 @@ bool_ player_activate_trap_type(s16b y, s16b x, object_type *i_ptr, s16b item)
if (!j_ptr->k_idx) continue;
/* Do not allow this trap to touch the One Ring */
- object_flags(j_ptr, &f1, &f2, &f3, &f4, &f5, &esp);
- if(f3 & TR3_PERMA_CURSE) continue;
+ auto const j_flags = object_flags(j_ptr);
+ if(j_flags & TR_PERMA_CURSE) continue;
slot1 = wield_slot(j_ptr);
@@ -995,8 +995,8 @@ bool_ player_activate_trap_type(s16b y, s16b x, object_type *i_ptr, s16b item)
if (!k_ptr->k_idx) continue;
/* Do not allow this trap to touch the One Ring */
- object_flags(k_ptr, &f1, &f2, &f3, &f4, &f5, &esp);
- if(f3 & TR3_PERMA_CURSE) continue;
+ auto const k_flags = object_flags(k_ptr);
+ if(k_flags & TR_PERMA_CURSE) continue;
/* this is a crude hack, but it prevent wielding 6 torches... */
if (k_ptr->number > 1) continue;
@@ -1424,9 +1424,7 @@ bool_ player_activate_trap_type(s16b y, s16b x, object_type *i_ptr, s16b item)
case TRAP_OF_DRAIN_SPEED:
{
- object_type *j_ptr;
s16b j, chance = 75;
- u32b f1, f2, f3, f4, f5, esp;
for (j = 0; j < INVEN_TOTAL; j++)
{
@@ -1435,11 +1433,11 @@ bool_ player_activate_trap_type(s16b y, s16b x, object_type *i_ptr, s16b item)
if (!p_ptr->inventory[j].k_idx) continue;
- j_ptr = &p_ptr->inventory[j];
- object_flags(j_ptr, &f1, &f2, &f3, &f4, &f5, &esp);
+ auto j_ptr = &p_ptr->inventory[j];
+ auto const flags = object_flags(j_ptr);
/* is it a non-artifact speed item? */
- if ((!j_ptr->name1) && (f1 & TR1_SPEED))
+ if ((!j_ptr->name1) && (flags & TR_SPEED))
{
if (randint(100) < chance)
{
@@ -2091,8 +2089,6 @@ void do_cmd_set_trap(void)
object_type object_type_body;
- u32b f1, f2, f3, f4, f5, esp;
-
/* Check some conditions */
if (p_ptr->blind)
{
@@ -2167,11 +2163,11 @@ void do_cmd_set_trap(void)
/* In some cases, take multiple objects to load */
if (o_ptr->sval != SV_TRAPKIT_DEVICE)
{
- object_flags(o_ptr, &f1, &f2, &f3, &f4, &f5, &esp);
+ auto const flags = object_flags(o_ptr);
- if ((f3 & TR3_XTRA_SHOTS) && (o_ptr->pval > 0)) num += o_ptr->pval;
+ if ((flags & TR_XTRA_SHOTS) && (o_ptr->pval > 0)) num += o_ptr->pval;
- if (f2 & (TRAP2_AUTOMATIC_5 | TRAP2_AUTOMATIC_99)) num = 99;
+ if (flags & (TR_AUTOMATIC_5 | TR_AUTOMATIC_99)) num = 99;
if (num > j_ptr->number) num = j_ptr->number;
@@ -2648,8 +2644,6 @@ bool_ mon_hit_trap(int m_idx)
monster_type *m_ptr = &m_list[m_idx];
monster_race *r_ptr = &r_info[m_ptr->r_idx];
- u32b f1, f2, f3, f4, f5, esp;
-
object_type object_type_body;
int mx = m_ptr->fx;
@@ -2680,21 +2674,21 @@ bool_ mon_hit_trap(int m_idx)
auto j_ptr = &object_type_body;
/* Get trap properties */
- object_flags(kit_o_ptr, &f1, &f2, &f3, &f4, &f5, &esp);
+ auto const flags = object_flags(kit_o_ptr);
/* Can set off check */
/* Ghosts only set off Ghost traps */
- if ((r_ptr->flags & RF_PASS_WALL) && !(f2 & TRAP2_KILL_GHOST)) return (FALSE);
+ if ((r_ptr->flags & RF_PASS_WALL) && !(flags & TR_KILL_GHOST)) return (FALSE);
/* Some traps are specialized to some creatures */
- if (f2 & TRAP2_ONLY_MASK)
+ if (flags & (TR_ONLY_DRAGON | TR_ONLY_DEMON | TR_ONLY_ANIMAL | TR_ONLY_UNDEAD | TR_ONLY_EVIL))
{
bool_ affect = FALSE;
- if ((f2 & TRAP2_ONLY_DRAGON) && (r_ptr->flags & RF_DRAGON)) affect = TRUE;
- if ((f2 & TRAP2_ONLY_DEMON) && (r_ptr->flags & RF_DEMON)) affect = TRUE;
- if ((f2 & TRAP2_ONLY_UNDEAD) && (r_ptr->flags & RF_UNDEAD)) affect = TRUE;
- if ((f2 & TRAP2_ONLY_EVIL) && (r_ptr->flags & RF_EVIL)) affect = TRUE;
- if ((f2 & TRAP2_ONLY_ANIMAL) && (r_ptr->flags & RF_ANIMAL)) affect = TRUE;
+ if ((flags & TR_ONLY_DRAGON) && (r_ptr->flags & RF_DRAGON)) affect = TRUE;
+ if ((flags & TR_ONLY_DEMON) && (r_ptr->flags & RF_DEMON)) affect = TRUE;
+ if ((flags & TR_ONLY_UNDEAD) && (r_ptr->flags & RF_UNDEAD)) affect = TRUE;
+ if ((flags & TR_ONLY_EVIL) && (r_ptr->flags & RF_EVIL)) affect = TRUE;
+ if ((flags & TR_ONLY_ANIMAL) && (r_ptr->flags & RF_ANIMAL)) affect = TRUE;
/* Don't set it off if forbidden */
if (!affect) return (FALSE);
@@ -2704,7 +2698,7 @@ bool_ mon_hit_trap(int m_idx)
difficulty = 25;
/* Some traps are well-hidden */
- if (f1 & TR1_STEALTH)
+ if (flags & TR_STEALTH)
{
difficulty += 10 * (kit_o_ptr->pval);
}
@@ -2795,7 +2789,7 @@ bool_ mon_hit_trap(int m_idx)
{
/* Get number of shots */
shots = 1;
- if (f3 & TR3_XTRA_SHOTS) shots += kit_o_ptr->pval;
+ if (flags & TR_XTRA_SHOTS) shots += kit_o_ptr->pval;
if (shots <= 0) shots = 1;
if (shots > load_o_ptr->number) shots = load_o_ptr->number;
@@ -2811,7 +2805,7 @@ bool_ mon_hit_trap(int m_idx)
if (kit_o_ptr->sval == SV_TRAPKIT_BOW) mul = 3;
if (kit_o_ptr->sval == SV_TRAPKIT_XBOW) mul = 4;
if (kit_o_ptr->sval == SV_TRAPKIT_SLING) mul = 2;
- if (f3 & TR3_XTRA_MIGHT) mul += kit_o_ptr->pval;
+ if (flags & TR_XTRA_MIGHT) mul += kit_o_ptr->pval;
if (mul < 0) mul = 0;
/* Multiply damage */
@@ -2932,7 +2926,7 @@ bool_ mon_hit_trap(int m_idx)
{
/* Get number of shots */
shots = 1;
- if (f3 & TR3_XTRA_SHOTS) shots += kit_o_ptr->pval;
+ if (flags & TR_XTRA_SHOTS) shots += kit_o_ptr->pval;
if (shots <= 0) shots = 1;
if (shots > load_o_ptr->number) shots = load_o_ptr->number;
@@ -2973,7 +2967,7 @@ bool_ mon_hit_trap(int m_idx)
{
/* Get number of shots */
shots = 1;
- if (f3 & TR3_XTRA_SHOTS) shots += kit_o_ptr->pval;
+ if (flags & TR_XTRA_SHOTS) shots += kit_o_ptr->pval;
if (shots <= 0) shots = 1;
if (shots > load_o_ptr->number) shots = load_o_ptr->number;
@@ -3015,16 +3009,15 @@ bool_ mon_hit_trap(int m_idx)
if (load_o_ptr->tval == TV_ROD_MAIN)
{
/* Extract mana cost of the rod tip */
- u32b tf1, tf2, tf3, tf4, tf5, tesp;
object_kind *tip_o_ptr = &k_info[lookup_kind(TV_ROD, load_o_ptr->pval)];
- object_flags(load_o_ptr, &tf1, &tf2, &tf3, &tf4, &tf5, &tesp);
- cost = (tf4 & TR4_CHEAPNESS) ? tip_o_ptr->pval / 2 : tip_o_ptr->pval;
+ auto const tflags = object_flags(load_o_ptr);
+ cost = (tflags & TR_CHEAPNESS) ? tip_o_ptr->pval / 2 : tip_o_ptr->pval;
if (cost <= 0) cost = 1;
}
/* Get number of shots */
shots = 1;
- if (f3 & TR3_XTRA_SHOTS) shots += kit_o_ptr->pval;
+ if (flags & TR_XTRA_SHOTS) shots += kit_o_ptr->pval;
if (shots <= 0) shots = 1;
if (load_o_ptr->tval == TV_ROD_MAIN)
@@ -3073,16 +3066,16 @@ bool_ mon_hit_trap(int m_idx)
}
/* Non-automatic traps are removed */
- if (!(f2 & (TRAP2_AUTOMATIC_5 | TRAP2_AUTOMATIC_99)))
+ if (!(flags & (TR_AUTOMATIC_5 | TR_AUTOMATIC_99)))
{
remove = TRUE;
}
- else if (f2 & TRAP2_AUTOMATIC_5) remove = (randint(5) == 1);
+ else if (flags & TR_AUTOMATIC_5) remove = (randint(5) == 1);
}
/* Special trap effect -- teleport to */
- if ((f2 & TRAP2_TELEPORT_TO) && (!disarm) && (!dead))
+ if ((flags & TR_TELEPORT_TO) && (!disarm) && (!dead))
{
teleport_monster_to(m_idx, p_ptr->py, p_ptr->px);
}
diff --git a/src/wizard2.cc b/src/wizard2.cc
index 8685f242..46850be3 100644
--- a/src/wizard2.cc
+++ b/src/wizard2.cc
@@ -21,6 +21,8 @@
#include "monster_type.hpp"
#include "object1.hpp"
#include "object2.hpp"
+#include "object_flag.hpp"
+#include "object_flag_meta.hpp"
#include "object_kind.hpp"
#include "player_type.hpp"
#include "randart.hpp"
@@ -224,32 +226,6 @@ static void do_cmd_summon_horde()
/*
- * Output a long int in binary format.
- */
-static void prt_binary(u32b flags, int row, int col)
-{
- int i;
- u32b bitmask;
-
- /* Scan the flags */
- for (i = bitmask = 1; i <= 32; i++, bitmask *= 2)
- {
- /* Dump set bits */
- if (flags & bitmask)
- {
- Term_putch(col++, row, TERM_BLUE, '*');
- }
-
- /* Dump unset bits */
- else
- {
- Term_putch(col++, row, TERM_WHITE, '-');
- }
- }
-}
-
-
-/*
* Hack -- Teleport to the target
*/
static void do_cmd_wiz_bamf(void)
@@ -442,11 +418,10 @@ static void do_cmd_wiz_change(void)
static void wiz_display_item(object_type *o_ptr)
{
int i, j = 13;
- u32b f1, f2, f3, f4, f5, esp;
char buf[256];
/* Extract the flags */
- object_flags(o_ptr, &f1, &f2, &f3, &f4, &f5, &esp);
+ auto const flags = object_flags(o_ptr);
/* Clear the screen */
for (i = 1; i <= 23; i++) prt("", i, j - 2);
@@ -473,32 +448,27 @@ static void wiz_display_item(object_type *o_ptr)
prt(format("ident = %04x timeout = %-d",
o_ptr->ident, o_ptr->timeout), 8, j);
- prt("+------------FLAGS1------------+", 10, j);
- prt("AFFECT........SLAY........BRAND.", 11, j);
- prt(" cvae xsqpaefc", 12, j);
- prt("siwdcc ssidsahanvudotgddhuoclio", 13, j);
- prt("tnieoh trnipttmiinmrrnrrraiierl", 14, j);
- prt("rtsxna..lcfgdkcpmldncltggpksdced", 15, j);
- prt_binary(f1, 16, j);
-
- prt("+------------FLAGS2------------+", 17, j);
- prt("SUST....IMMUN.RESIST............", 18, j);
- prt(" aefcprpsaefcpfldbc sn ", 19, j);
- prt("siwdcc cliooeatcliooeialoshtncd", 20, j);
- prt("tnieoh ierlifraierliatrnnnrhehi", 21, j);
- prt("rtsxna..dcedslatdcedsrekdfddrxss", 22, j);
- prt_binary(f2, 23, j);
-
- prt("+------------FLAGS3------------+", 10, j + 32);
- prt("fe ehsi st iiiiadta hp", 11, j + 32);
- prt("il n taihnf ee ggggcregb vr", 12, j + 32);
- prt("re nowysdose eld nnnntalrl ym", 13, j + 32);
- prt("ec omrcyewta ieirmsrrrriieaeccc", 14, j + 32);
- prt("aa taauktmatlnpgeihaefcvnpvsuuu", 15, j + 32);
- prt("uu egirnyoahivaeggoclioaeoasrrr", 16, j + 32);
- prt("rr litsopdretitsehtierltxrtesss", 17, j + 32);
- prt("aa echewestreshtntsdcedeptedeee", 18, j + 32);
- prt_binary(f3, 19, j + 32);
+ /* Print all the flags which are set */
+ prt("Flags:", 10, j);
+
+ int const row0 = 11;
+ int row = row0;
+ int col = 0;
+ for (auto const &object_flag_meta: object_flags_meta())
+ {
+ // Is the flag set?
+ if (object_flag_meta->flag_set & flags)
+ {
+ // Advance to next row/column
+ row += 1;
+ if (row >= 23) {
+ row = row0 + 1;
+ col += 1;
+ }
+ // Display
+ prt(object_flag_meta->name, row, j + 1 + 20 * col);
+ }
+ }
}
@@ -622,7 +592,7 @@ static int wiz_create_itemtype(void)
if (k_ptr->tval == tval)
{
/* Hack -- Skip instant artifacts */
- if (k_ptr->flags3 & (TR3_INSTA_ART)) continue;
+ if (k_ptr->flags & TR_INSTA_ART) continue;
/* Acquire the "name" of object "i" */
strip_name(buf, i);
@@ -662,10 +632,9 @@ static void wiz_tweak_item(object_type *o_ptr)
{
cptr p;
char tmp_val[80];
- u32b f1, f2, f3, f4, f5, esp;
/* Extract the flags */
- object_flags(o_ptr, &f1, &f2, &f3, &f4, &f5, &esp);
+ auto const flags = object_flags(o_ptr);
p = "Enter new 'pval' setting: ";
@@ -727,7 +696,7 @@ static void wiz_tweak_item(object_type *o_ptr)
if (!get_string(p, tmp_val, 9)) return;
wiz_display_item(o_ptr);
o_ptr->exp = atoi(tmp_val);
- if (f4 & TR4_LEVELS) check_experience_obj(o_ptr);
+ if (flags & TR_LEVELS) check_experience_obj(o_ptr);
p = "Enter new 'timeout' setting: ";
sprintf(tmp_val, "%d", o_ptr->timeout);
diff --git a/src/xtra1.cc b/src/xtra1.cc
index db057278..1bf2b9a6 100644
--- a/src/xtra1.cc
+++ b/src/xtra1.cc
@@ -30,6 +30,8 @@
#include "monster_type.hpp"
#include "object1.hpp"
#include "object2.hpp"
+#include "object_flag.hpp"
+#include "object_flag_meta.hpp"
#include "object_kind.hpp"
#include "options.hpp"
#include "player_class.hpp"
@@ -1647,9 +1649,6 @@ static void calc_sanity()
static void calc_mana(void)
{
int msp, levels, cur_wgt, max_wgt;
- u32b f1, f2, f3, f4, f5, esp;
-
- object_type *o_ptr;
levels = p_ptr->lev;
@@ -1700,16 +1699,16 @@ static void calc_mana(void)
p_ptr->cumber_glove = FALSE;
/* Get the gloves */
- o_ptr = &p_ptr->inventory[INVEN_HANDS];
+ object_type *o_ptr = &p_ptr->inventory[INVEN_HANDS];
/* Examine the gloves */
- object_flags(o_ptr, &f1, &f2, &f3, &f4, &f5, &esp);
+ auto const flags = object_flags(o_ptr);
/* Normal gloves hurt mage-type spells */
if (o_ptr->k_idx &&
- !(f2 & (TR2_FREE_ACT)) &&
- !((f1 & (TR1_DEX)) && (o_ptr->pval > 0)) &&
- !(f5 & TR5_SPELL_CONTAIN))
+ !(flags & TR_FREE_ACT) &&
+ !((flags & TR_DEX) && (o_ptr->pval > 0)) &&
+ !(flags & TR_SPELL_CONTAIN))
{
/* Encumbered */
p_ptr->cumber_glove = TRUE;
@@ -1953,7 +1952,6 @@ static void calc_torch(void)
{
int i;
object_type *o_ptr;
- u32b f1, f2, f3, f4, f5, esp;
/* Assume no light */
p_ptr->cur_lite = 0;
@@ -1967,14 +1965,14 @@ static void calc_torch(void)
if (!o_ptr->k_idx) continue;
/* Extract the flags */
- object_flags(o_ptr, &f1, &f2, &f3, &f4, &f5, &esp);
+ auto const flags = object_flags(o_ptr);
/* does this item glow? */
- if (((f4 & TR4_FUEL_LITE) && (o_ptr->timeout > 0)) || (!(f4 & TR4_FUEL_LITE)))
+ if (((flags & TR_FUEL_LITE) && (o_ptr->timeout > 0)) || (!(flags & TR_FUEL_LITE)))
{
- if (f3 & TR3_LITE1) p_ptr->cur_lite++;
- if (f4 & TR4_LITE2) p_ptr->cur_lite += 2;
- if (f4 & TR4_LITE3) p_ptr->cur_lite += 3;
+ if (flags & TR_LITE1) p_ptr->cur_lite++;
+ if (flags & TR_LITE2) p_ptr->cur_lite += 2;
+ if (flags & TR_LITE3) p_ptr->cur_lite += 3;
}
}
@@ -2496,13 +2494,13 @@ static void calc_corruptions()
{
if (player_has_corruption(CORRUPT_BALROG_AURA))
{
- p_ptr->xtra_f3 |= TR3_SH_FIRE;
- p_ptr->xtra_f3 |= TR3_LITE1;
+ p_ptr->xtra_flags |= TR_SH_FIRE;
+ p_ptr->xtra_flags |= TR_LITE1;
}
if (player_has_corruption(CORRUPT_BALROG_WINGS))
{
- p_ptr->xtra_f4 |= TR4_FLY;
+ p_ptr->xtra_flags |= TR_FLY;
p_ptr->stat_add[A_CHR] -= 4;
p_ptr->stat_add[A_DEX] -= 2;
}
@@ -2528,7 +2526,7 @@ static void calc_corruptions()
p_ptr->pspeed = p_ptr->pspeed - (p_ptr->lev / 7);
if (p_ptr->lev >= 40)
{
- p_ptr->xtra_f2 |= TR2_IM_FIRE;
+ p_ptr->xtra_flags |= TR_IM_FIRE;
}
}
@@ -2545,7 +2543,7 @@ static void calc_corruptions()
if (player_has_corruption(CORRUPT_RANDOM_TELEPORT))
{
- p_ptr->xtra_f3 |= TR3_TELEPORT;
+ p_ptr->xtra_flags |= TR_TELEPORT;
}
if (player_has_corruption(CORRUPT_ANTI_TELEPORT))
@@ -2558,136 +2556,137 @@ static void calc_corruptions()
if (player_has_corruption(CORRUPT_TROLL_BLOOD))
{
- p_ptr->xtra_f3 |= (TR3_REGEN | TR3_AGGRAVATE);
- p_ptr->xtra_esp |= ESP_TROLL;
+ p_ptr->xtra_flags |= (TR_REGEN | TR_AGGRAVATE | ESP_TROLL);
}
}
/* Apply flags */
static int extra_blows;
static int extra_shots;
-void apply_flags(u32b f1, u32b f2, u32b f3, u32b f4, u32b f5, u32b esp, s16b pval, s16b tval, s16b to_h, s16b to_d, s16b to_a)
+void apply_flags(object_flag_set const &f, s16b pval, s16b tval, s16b to_h, s16b to_d, s16b to_a)
{
s16b antimagic_mod;
+ // Mix into computed flags
+ p_ptr->computed_flags |= f;
+
/* Affect stats */
- if (f1 & (TR1_STR)) p_ptr->stat_add[A_STR] += pval;
- if (f1 & (TR1_INT)) p_ptr->stat_add[A_INT] += pval;
- if (f1 & (TR1_WIS)) p_ptr->stat_add[A_WIS] += pval;
- if (f1 & (TR1_DEX)) p_ptr->stat_add[A_DEX] += pval;
- if (f1 & (TR1_CON)) p_ptr->stat_add[A_CON] += pval;
- if (f1 & (TR1_CHR)) p_ptr->stat_add[A_CHR] += pval;
- if (f5 & (TR5_LUCK)) p_ptr->luck_cur += pval;
+ if (f & TR_STR) p_ptr->stat_add[A_STR] += pval;
+ if (f & TR_INT) p_ptr->stat_add[A_INT] += pval;
+ if (f & TR_WIS) p_ptr->stat_add[A_WIS] += pval;
+ if (f & TR_DEX) p_ptr->stat_add[A_DEX] += pval;
+ if (f & TR_CON) p_ptr->stat_add[A_CON] += pval;
+ if (f & TR_CHR) p_ptr->stat_add[A_CHR] += pval;
+ if (f & TR_LUCK) p_ptr->luck_cur += pval;
/* Affect spell power */
- if (f1 & (TR1_SPELL)) p_ptr->to_s += pval;
+ if (f & TR_SPELL) p_ptr->to_s += pval;
/* Affect mana capacity */
- if (f1 & (TR1_MANA)) p_ptr->to_m += pval;
+ if (f & TR_MANA) p_ptr->to_m += pval;
/* Affect life capacity */
- if (f2 & (TR2_LIFE)) p_ptr->to_l += pval;
+ if (f & TR_LIFE) p_ptr->to_l += pval;
/* Affect stealth */
- if (f1 & (TR1_STEALTH)) p_ptr->skill_stl += pval;
+ if (f & TR_STEALTH) p_ptr->skill_stl += pval;
/* Affect searching ability (factor of five) */
- if (f1 & (TR1_SEARCH)) p_ptr->skill_srh += (pval * 5);
+ if (f & TR_SEARCH) p_ptr->skill_srh += (pval * 5);
/* Affect searching frequency (factor of five) */
- if (f1 & (TR1_SEARCH)) p_ptr->skill_fos += (pval * 5);
+ if (f & TR_SEARCH) p_ptr->skill_fos += (pval * 5);
/* Affect infravision */
- if (f1 & (TR1_INFRA)) p_ptr->see_infra += pval;
+ if (f & TR_INFRA) p_ptr->see_infra += pval;
/* Affect digging (factor of 20) */
- if (f1 & (TR1_TUNNEL)) p_ptr->skill_dig += (pval * 20);
+ if (f & TR_TUNNEL) p_ptr->skill_dig += (pval * 20);
/* Affect speed */
- if (f1 & (TR1_SPEED)) p_ptr->pspeed += pval;
+ if (f & TR_SPEED) p_ptr->pspeed += pval;
/* Affect blows */
- if (f1 & (TR1_BLOWS)) extra_blows += pval;
- if (f5 & (TR5_CRIT)) p_ptr->xtra_crit += pval;
+ if (f & TR_BLOWS) extra_blows += pval;
+ if (f & TR_CRIT) p_ptr->xtra_crit += pval;
/* Hack -- Sensible fire */
- if (f2 & (TR2_SENS_FIRE)) p_ptr->sensible_fire = TRUE;
+ if (f & TR_SENS_FIRE) p_ptr->sensible_fire = TRUE;
/* Hack -- cause earthquakes */
- if (f1 & (TR1_IMPACT)) p_ptr->impact = TRUE;
+ if (f & TR_IMPACT) p_ptr->impact = TRUE;
/* Affect invisibility */
- if (f2 & (TR2_INVIS)) p_ptr->invis += (pval * 10);
+ if (f & TR_INVIS) p_ptr->invis += (pval * 10);
/* Boost shots */
- if (f3 & (TR3_XTRA_SHOTS)) extra_shots++;
+ if (f & TR_XTRA_SHOTS) extra_shots++;
/* Various flags */
- if (f3 & (TR3_AGGRAVATE)) p_ptr->aggravate = TRUE;
- if (f3 & (TR3_TELEPORT)) p_ptr->teleport = TRUE;
- if (f5 & (TR5_DRAIN_MANA)) p_ptr->drain_mana++;
- if (f5 & (TR5_DRAIN_HP)) p_ptr->drain_life++;
- if (f3 & (TR3_DRAIN_EXP)) p_ptr->exp_drain = TRUE;
- if (f3 & (TR3_BLESSED)) p_ptr->bless_blade = TRUE;
- if (f3 & (TR3_XTRA_MIGHT)) p_ptr->xtra_might += pval;
- if (f3 & (TR3_SLOW_DIGEST)) p_ptr->slow_digest = TRUE;
- if (f3 & (TR3_REGEN)) p_ptr->regenerate = TRUE;
- if (esp) p_ptr->telepathy |= esp;
- if ((tval != TV_LITE) && (f3 & (TR3_LITE1))) p_ptr->lite = TRUE;
- if ((tval != TV_LITE) && (f4 & (TR4_LITE2))) p_ptr->lite = TRUE;
- if ((tval != TV_LITE) && (f4 & (TR4_LITE3))) p_ptr->lite = TRUE;
- if (f3 & (TR3_SEE_INVIS)) p_ptr->see_inv = TRUE;
- if (f2 & (TR2_FREE_ACT)) p_ptr->free_act = TRUE;
- if (f2 & (TR2_HOLD_LIFE)) p_ptr->hold_life = TRUE;
- if (f3 & (TR3_WRAITH)) p_ptr->wraith_form = TRUE;
- if (f3 & (TR3_FEATHER)) p_ptr->ffall = TRUE;
- if (f4 & (TR4_FLY)) p_ptr->fly = TRUE;
- if (f4 & (TR4_CLIMB)) p_ptr->climb = TRUE;
+ if (f & TR_AGGRAVATE) p_ptr->aggravate = TRUE;
+ if (f & TR_TELEPORT) p_ptr->teleport = TRUE;
+ if (f & TR_DRAIN_MANA) p_ptr->drain_mana++;
+ if (f & TR_DRAIN_HP) p_ptr->drain_life++;
+ if (f & TR_DRAIN_EXP) p_ptr->exp_drain = TRUE;
+ if (f & TR_BLESSED) p_ptr->bless_blade = TRUE;
+ if (f & TR_XTRA_MIGHT) p_ptr->xtra_might += pval;
+ if (f & TR_SLOW_DIGEST) p_ptr->slow_digest = TRUE;
+ if (f & TR_REGEN) p_ptr->regenerate = TRUE;
+ if ((tval != TV_LITE) && (f & TR_LITE1)) p_ptr->lite = TRUE;
+ if ((tval != TV_LITE) && (f & TR_LITE2)) p_ptr->lite = TRUE;
+ if ((tval != TV_LITE) && (f & TR_LITE3)) p_ptr->lite = TRUE;
+ if (f & TR_SEE_INVIS) p_ptr->see_inv = TRUE;
+ if (f & TR_FREE_ACT) p_ptr->free_act = TRUE;
+ if (f & TR_HOLD_LIFE) p_ptr->hold_life = TRUE;
+ if (f & TR_WRAITH) p_ptr->wraith_form = TRUE;
+ if (f & TR_FEATHER) p_ptr->ffall = TRUE;
+ if (f & TR_FLY) p_ptr->fly = TRUE;
+ if (f & TR_CLIMB) p_ptr->climb = TRUE;
/* Immunity flags */
- if (f2 & (TR2_IM_FIRE)) p_ptr->immune_fire = TRUE;
- if (f2 & (TR2_IM_ACID)) p_ptr->immune_acid = TRUE;
- if (f2 & (TR2_IM_COLD)) p_ptr->immune_cold = TRUE;
- if (f2 & (TR2_IM_ELEC)) p_ptr->immune_elec = TRUE;
+ if (f & TR_IM_FIRE) p_ptr->immune_fire = TRUE;
+ if (f & TR_IM_ACID) p_ptr->immune_acid = TRUE;
+ if (f & TR_IM_COLD) p_ptr->immune_cold = TRUE;
+ if (f & TR_IM_ELEC) p_ptr->immune_elec = TRUE;
/* Resistance flags */
- if (f2 & (TR2_RES_ACID)) p_ptr->resist_acid = TRUE;
- if (f2 & (TR2_RES_ELEC)) p_ptr->resist_elec = TRUE;
- if (f2 & (TR2_RES_FIRE)) p_ptr->resist_fire = TRUE;
- if (f2 & (TR2_RES_COLD)) p_ptr->resist_cold = TRUE;
- if (f2 & (TR2_RES_POIS)) p_ptr->resist_pois = TRUE;
- if (f2 & (TR2_RES_FEAR)) p_ptr->resist_fear = TRUE;
- if (f2 & (TR2_RES_CONF)) p_ptr->resist_conf = TRUE;
- if (f2 & (TR2_RES_SOUND)) p_ptr->resist_sound = TRUE;
- if (f2 & (TR2_RES_LITE)) p_ptr->resist_lite = TRUE;
- if (f2 & (TR2_RES_DARK)) p_ptr->resist_dark = TRUE;
- if (f2 & (TR2_RES_CHAOS)) p_ptr->resist_chaos = TRUE;
- if (f2 & (TR2_RES_DISEN)) p_ptr->resist_disen = TRUE;
- if (f2 & (TR2_RES_SHARDS)) p_ptr->resist_shard = TRUE;
- if (f2 & (TR2_RES_NEXUS)) p_ptr->resist_nexus = TRUE;
- if (f2 & (TR2_RES_BLIND)) p_ptr->resist_blind = TRUE;
- if (f2 & (TR2_RES_NETHER)) p_ptr->resist_neth = TRUE;
- if (f4 & (TR4_IM_NETHER)) p_ptr->immune_neth = TRUE;
-
- if (f2 & (TR2_REFLECT)) p_ptr->reflect = TRUE;
- if (f3 & (TR3_SH_FIRE)) p_ptr->sh_fire = TRUE;
- if (f3 & (TR3_SH_ELEC)) p_ptr->sh_elec = TRUE;
- if (f3 & (TR3_NO_MAGIC)) p_ptr->anti_magic = TRUE;
- if (f3 & (TR3_NO_TELE)) p_ptr->anti_tele = TRUE;
+ if (f & TR_RES_ACID) p_ptr->resist_acid = TRUE;
+ if (f & TR_RES_ELEC) p_ptr->resist_elec = TRUE;
+ if (f & TR_RES_FIRE) p_ptr->resist_fire = TRUE;
+ if (f & TR_RES_COLD) p_ptr->resist_cold = TRUE;
+ if (f & TR_RES_POIS) p_ptr->resist_pois = TRUE;
+ if (f & TR_RES_FEAR) p_ptr->resist_fear = TRUE;
+ if (f & TR_RES_CONF) p_ptr->resist_conf = TRUE;
+ if (f & TR_RES_SOUND) p_ptr->resist_sound = TRUE;
+ if (f & TR_RES_LITE) p_ptr->resist_lite = TRUE;
+ if (f & TR_RES_DARK) p_ptr->resist_dark = TRUE;
+ if (f & TR_RES_CHAOS) p_ptr->resist_chaos = TRUE;
+ if (f & TR_RES_DISEN) p_ptr->resist_disen = TRUE;
+ if (f & TR_RES_SHARDS) p_ptr->resist_shard = TRUE;
+ if (f & TR_RES_NEXUS) p_ptr->resist_nexus = TRUE;
+ if (f & TR_RES_BLIND) p_ptr->resist_blind = TRUE;
+ if (f & TR_RES_NETHER) p_ptr->resist_neth = TRUE;
+ if (f & TR_IM_NETHER) p_ptr->immune_neth = TRUE;
+
+ if (f & TR_REFLECT) p_ptr->reflect = TRUE;
+ if (f & TR_SH_FIRE) p_ptr->sh_fire = TRUE;
+ if (f & TR_SH_ELEC) p_ptr->sh_elec = TRUE;
+ if (f & TR_NO_MAGIC) p_ptr->anti_magic = TRUE;
+ if (f & TR_NO_TELE) p_ptr->anti_tele = TRUE;
/* Sustain flags */
- if (f2 & (TR2_SUST_STR)) p_ptr->sustain_str = TRUE;
- if (f2 & (TR2_SUST_INT)) p_ptr->sustain_int = TRUE;
- if (f2 & (TR2_SUST_WIS)) p_ptr->sustain_wis = TRUE;
- if (f2 & (TR2_SUST_DEX)) p_ptr->sustain_dex = TRUE;
- if (f2 & (TR2_SUST_CON)) p_ptr->sustain_con = TRUE;
- if (f2 & (TR2_SUST_CHR)) p_ptr->sustain_chr = TRUE;
+ if (f & TR_SUST_STR) p_ptr->sustain_str = TRUE;
+ if (f & TR_SUST_INT) p_ptr->sustain_int = TRUE;
+ if (f & TR_SUST_WIS) p_ptr->sustain_wis = TRUE;
+ if (f & TR_SUST_DEX) p_ptr->sustain_dex = TRUE;
+ if (f & TR_SUST_CON) p_ptr->sustain_con = TRUE;
+ if (f & TR_SUST_CHR) p_ptr->sustain_chr = TRUE;
- if (f4 & (TR4_PRECOGNITION)) p_ptr->precognition = TRUE;
+ if (f & TR_PRECOGNITION) p_ptr->precognition = TRUE;
antimagic_mod = to_h + to_d + to_a;
- if (f4 & (TR4_ANTIMAGIC_50))
+ if (f & TR_ANTIMAGIC_50)
{
s32b tmp;
@@ -2698,7 +2697,7 @@ void apply_flags(u32b f1, u32b f2, u32b f3, u32b f4, u32b f5, u32b esp, s16b pva
if (tmp > 0) p_ptr->antimagic_dis += tmp;
}
- if (f4 & (TR4_AUTO_ID))
+ if (f & TR_AUTO_ID)
{
p_ptr->auto_id = TRUE;
}
@@ -2708,13 +2707,17 @@ void apply_flags(u32b f1, u32b f2, u32b f3, u32b f4, u32b f5, u32b esp, s16b pva
* "black_breath". This flag can also be set by a unlucky blow from
* an undead. -LM-
*/
- if (f4 & (TR4_BLACK_BREATH)) p_ptr->black_breath = TRUE;
+ if (f & TR_BLACK_BREATH) p_ptr->black_breath = TRUE;
- if (f5 & (TR5_IMMOVABLE)) p_ptr->immovable = TRUE;
+ if (f & TR_IMMOVABLE) p_ptr->immovable = TRUE;
/* Breaths */
- if (f5 & (TR5_WATER_BREATH)) p_ptr->water_breath = TRUE;
- if (f5 & (TR5_MAGIC_BREATH))
+ if (f & TR_WATER_BREATH)
+ {
+ p_ptr->water_breath = TRUE;
+ }
+
+ if (f & TR_MAGIC_BREATH)
{
p_ptr->magical_breath = TRUE;
p_ptr->water_breath = TRUE;
@@ -2774,20 +2777,20 @@ void calc_bonuses(bool_ silent)
static bool_ monk_notify_aux = FALSE;
int i, j, hold;
int old_speed;
- u32b old_telepathy;
int old_see_inv;
int old_dis_ac;
int old_dis_to_a;
object_type *o_ptr;
- u32b f1, f2, f3, f4, f5, esp;
bool_ monk_armour_aux;
+ /* Save the old computed_flags */
+ auto old_computed_flags = p_ptr->computed_flags;
+
/* Save the old speed */
old_speed = p_ptr->pspeed;
/* Save the old vision stuff */
- old_telepathy = p_ptr->telepathy;
old_see_inv = p_ptr->see_inv;
/* Save the old armor class */
@@ -2855,7 +2858,7 @@ void calc_bonuses(bool_ silent)
p_ptr->climb = FALSE;
p_ptr->ffall = FALSE;
p_ptr->hold_life = FALSE;
- p_ptr->telepathy = 0;
+ p_ptr->computed_flags = object_flag_set();
p_ptr->lite = FALSE;
p_ptr->sustain_str = FALSE;
p_ptr->sustain_int = FALSE;
@@ -2942,12 +2945,7 @@ void calc_bonuses(bool_ silent)
p_ptr->skill_dig = 0;
/* Xtra player flags */
- p_ptr->xtra_f1 = 0;
- p_ptr->xtra_f2 = 0;
- p_ptr->xtra_f3 = 0;
- p_ptr->xtra_f4 = 0;
- p_ptr->xtra_f5 = 0;
- p_ptr->xtra_esp = 0;
+ p_ptr->xtra_flags = object_flag_set();
/* Hide the skills that should auto hide */
for (i = 0; i < max_s_idx; i++)
@@ -2980,7 +2978,7 @@ void calc_bonuses(bool_ silent)
for (i = 1; i <= p_ptr->lev; i++)
{
- apply_flags(cp_ptr->oflags1[i], cp_ptr->oflags2[i], cp_ptr->oflags3[i], cp_ptr->oflags4[i], cp_ptr->oflags5[i], cp_ptr->oesp[i], cp_ptr->opval[i], 0, 0, 0, 0);
+ apply_flags(cp_ptr->oflags[i], cp_ptr->opval[i], 0, 0, 0, 0);
}
if (p_ptr->melee_style == SKILL_HAND)
@@ -3009,7 +3007,10 @@ void calc_bonuses(bool_ silent)
if (get_skill(SKILL_DAEMON) > 20) p_ptr->resist_conf = TRUE;
if (get_skill(SKILL_DAEMON) > 30) p_ptr->resist_fear = TRUE;
- if ( get_skill(SKILL_MINDCRAFT) >= 40 ) p_ptr->telepathy = ESP_ALL;
+ if ( get_skill(SKILL_MINDCRAFT) >= 40 )
+ {
+ p_ptr->computed_flags |= ESP_ALL;
+ }
if (p_ptr->astral)
{
@@ -3023,8 +3024,8 @@ void calc_bonuses(bool_ silent)
for (i = 1; i <= p_ptr->lev; i++)
{
- apply_flags(rp_ptr->oflags1[i], rp_ptr->oflags2[i], rp_ptr->oflags3[i], rp_ptr->oflags4[i], rp_ptr->oflags5[i], rp_ptr->oesp[i], rp_ptr->opval[i], 0, 0, 0, 0);
- apply_flags(rmp_ptr->oflags1[i], rmp_ptr->oflags2[i], rmp_ptr->oflags3[i], rmp_ptr->oflags4[i], rmp_ptr->oflags5[i], rmp_ptr->oesp[i], rmp_ptr->opval[i], 0, 0, 0, 0);
+ apply_flags(rp_ptr->oflags[i], rp_ptr->opval[i], 0, 0, 0, 0);
+ apply_flags(rmp_ptr->oflags[i], rmp_ptr->opval[i], 0, 0, 0, 0);
}
if (race_flags1_p(PR1_HURT_LITE))
@@ -3032,7 +3033,7 @@ void calc_bonuses(bool_ silent)
}
/* The extra flags */
- apply_flags(p_ptr->xtra_f1, p_ptr->xtra_f2, p_ptr->xtra_f3, p_ptr->xtra_f4, p_ptr->xtra_f5, p_ptr->xtra_esp, 0, 0, 0, 0, 0);
+ apply_flags(p_ptr->xtra_flags, 0, 0, 0, 0, 0);
/* Apply the racial modifiers */
for (i = 0; i < 6; i++)
@@ -3052,7 +3053,7 @@ void calc_bonuses(bool_ silent)
/* Extract the item flags */
object_flags_no_set = TRUE;
- object_flags(o_ptr, &f1, &f2, &f3, &f4, &f5, &esp);
+ auto flags = object_flags(o_ptr);
object_flags_no_set = FALSE;
/* MEGA ugly hack -- set spacetime distortion resistance */
@@ -3064,10 +3065,10 @@ void calc_bonuses(bool_ silent)
/* Hack - don't give the Black Breath when merely inspecting a weapon */
if (silent)
{
- f4 &= ~TR4_BLACK_BREATH;
+ flags &= ~TR_BLACK_BREATH;
}
- apply_flags(f1, f2, f3, f4, f5, esp, o_ptr->pval, o_ptr->tval, o_ptr->to_h, o_ptr->to_d, o_ptr->to_a);
+ apply_flags(flags, o_ptr->pval, o_ptr->tval, o_ptr->to_h, o_ptr->to_d, o_ptr->to_a);
if (o_ptr->name1)
{
@@ -3285,7 +3286,7 @@ void calc_bonuses(bool_ silent)
/* Temporary precognition */
if (p_ptr->tim_precognition > 0)
{
- apply_flags(0, 0, 0, TR4_PRECOGNITION, 0, 0, 0, 0, 0, 0, 0);
+ apply_flags(TR_PRECOGNITION, 0, 0, 0, 0, 0);
}
/* Breath */
@@ -3441,7 +3442,7 @@ void calc_bonuses(bool_ silent)
if (p_ptr->tim_esp)
{
- p_ptr->telepathy |= ESP_ALL;
+ p_ptr->computed_flags |= ESP_ALL;
}
/* Temporary see invisible */
@@ -3482,9 +3483,12 @@ void calc_bonuses(bool_ silent)
/* Hack -- Telepathy Change */
- if (p_ptr->telepathy != old_telepathy)
{
- p_ptr->update |= (PU_MONSTERS);
+ auto const &esp_mask = object_flags_esp();
+ if ((p_ptr->computed_flags & esp_mask) != (old_computed_flags & esp_mask))
+ {
+ p_ptr->update |= (PU_MONSTERS);
+ }
}
/* Hack -- See Invis Change */
@@ -3826,10 +3830,8 @@ void calc_bonuses(bool_ silent)
/* 2handed weapon and shield = less damage */
if (p_ptr->inventory[INVEN_WIELD + i].k_idx && p_ptr->inventory[INVEN_ARM + i].k_idx)
{
- /* Extract the item flags */
- object_flags(&p_ptr->inventory[INVEN_WIELD + i], &f1, &f2, &f3, &f4, &f5, &esp);
-
- if (f4 & TR4_COULD2H)
+ auto const flags = object_flags(&p_ptr->inventory[INVEN_WIELD + i]);
+ if (flags & TR_COULD2H)
{
int tmp;
@@ -4376,7 +4378,7 @@ static int get_artifact_idx(int level)
if (a_ptr->level > level) continue;
/* Avoid granting SPECIAL_GENE artifacts */
- if (a_ptr->flags4 & TR4_SPECIAL_GENE) continue;
+ if (a_ptr->flags & TR_SPECIAL_GENE) continue;
return i;
}
@@ -4482,7 +4484,7 @@ void gain_fate(byte fate)
k_ptr = &k_info[fates[i].o_idx];
- if (!(k_ptr->flags3 & TR3_INSTA_ART) && !(k_ptr->flags3 & TR3_NORM_ART)) break;
+ if (!(k_ptr->flags & TR_INSTA_ART) && !(k_ptr->flags & TR_NORM_ART)) break;
}
level = rand_range(max_dlv[dungeon_type] - 20, max_dlv[dungeon_type] + 20);
fates[i].level = (level < 1) ? 1 : (level > 98) ? 98 : level;
@@ -4601,7 +4603,7 @@ std::string fate_desc(int fate)
q_ptr->weight = a_ptr->weight;
/* Hack -- acquire "cursed" flag */
- if (a_ptr->flags3 & (TR3_CURSED)) q_ptr->ident |= (IDENT_CURSED);
+ if (a_ptr->flags & (TR_CURSED)) q_ptr->ident |= (IDENT_CURSED);
random_artifact_resistance(q_ptr);
diff --git a/src/xtra1.hpp b/src/xtra1.hpp
index e2a41b13..3e434828 100644
--- a/src/xtra1.hpp
+++ b/src/xtra1.hpp
@@ -1,11 +1,12 @@
#pragma once
#include "h-basic.h"
+#include "object_flag_set.hpp"
#include <string>
extern void fix_message(void);
-extern void apply_flags(u32b f1, u32b f2, u32b f3, u32b f4, u32b f5, u32b esp, s16b pval, s16b tval, s16b to_h, s16b to_d, s16b to_a);
+extern void apply_flags(object_flag_set const &f, s16b pval, s16b tval, s16b to_h, s16b to_d, s16b to_a);
extern int luck(int min, int max);
extern int weight_limit(void);
extern bool_ calc_powers_silent;
diff --git a/src/xtra2.cc b/src/xtra2.cc
index 5193aa81..4f1536db 100644
--- a/src/xtra2.cc
+++ b/src/xtra2.cc
@@ -32,6 +32,7 @@
#include "notes.hpp"
#include "object1.hpp"
#include "object2.hpp"
+#include "object_flag.hpp"
#include "object_kind.hpp"
#include "options.hpp"
#include "player_class.hpp"
@@ -2572,24 +2573,34 @@ void monster_death(int m_idx)
q_ptr->dd = 6;
q_ptr->pval = 2;
- q_ptr->art_flags1 |= ( TR1_VAMPIRIC | TR1_STR | TR1_CON | TR1_BLOWS );
- q_ptr->art_flags2 |= ( TR2_FREE_ACT | TR2_HOLD_LIFE |
- TR2_RES_NEXUS | TR2_RES_CHAOS | TR2_RES_NETHER |
- TR2_RES_CONF ); /* No longer resist_disen */
- q_ptr->art_flags3 |= ( TR3_IGNORE_ACID | TR3_IGNORE_ELEC |
- TR3_IGNORE_FIRE | TR3_IGNORE_COLD);
- /* Just to be sure */
+ q_ptr->art_flags |=
+ TR_VAMPIRIC |
+ TR_STR |
+ TR_CON |
+ TR_BLOWS |
+ TR_FREE_ACT |
+ TR_HOLD_LIFE |
+ TR_RES_NEXUS |
+ TR_RES_CHAOS |
+ TR_RES_NETHER |
+ TR_RES_CONF |
+ TR_IGNORE_ACID |
+ TR_IGNORE_ELEC |
+ TR_IGNORE_FIRE |
+ TR_IGNORE_COLD |
+ TR_NO_TELE |
+ TR_CURSED |
+ TR_HEAVY_CURSE;
- q_ptr->art_flags3 |= TR3_NO_TELE; /* How's that for a downside? */
-
- /* For game balance... */
- q_ptr->art_flags3 |= (TR3_CURSED | TR3_HEAVY_CURSE);
q_ptr->ident |= IDENT_CURSED;
-
if (randint(2) == 1)
- q_ptr->art_flags3 |= (TR3_DRAIN_EXP);
+ {
+ q_ptr->art_flags |= TR_DRAIN_EXP;
+ }
else
- q_ptr->art_flags3 |= (TR3_AGGRAVATE);
+ {
+ q_ptr->art_flags |= TR_AGGRAVATE;
+ }
q_ptr->found = OBJ_FOUND_MONSTER;
q_ptr->found_aux1 = m_ptr->r_idx;
@@ -2799,7 +2810,7 @@ void monster_death(int m_idx)
q_ptr->weight = a_ptr->weight;
/* Hack -- acquire "cursed" flag */
- if (a_ptr->flags3 & (TR3_CURSED)) q_ptr->ident |= (IDENT_CURSED);
+ if (a_ptr->flags & TR_CURSED) q_ptr->ident |= (IDENT_CURSED);
random_artifact_resistance(q_ptr);
@@ -3145,15 +3156,12 @@ bool_ mon_take_hit(int m_idx, int dam, bool_ *fear, cptr note)
if (!note)
{
- object_type *o_ptr;
- u32b f1, f2, f3, f4, f5, esp;
-
/* Access the weapon */
- o_ptr = &p_ptr->inventory[INVEN_WIELD];
- object_flags(o_ptr, &f1, &f2, &f3, &f4, &f5, &esp);
+ object_type *o_ptr = &p_ptr->inventory[INVEN_WIELD];
+ auto const flags = object_flags(o_ptr);
/* Can the weapon gain levels ? */
- if ((o_ptr->k_idx) && (f4 & TR4_LEVELS))
+ if ((o_ptr->k_idx) && (flags & TR_LEVELS))
{
/* Give some experience for the kill */
const int new_exp = ((long)r_ptr->mexp * m_ptr->level) / (div * 2);
@@ -5061,8 +5069,8 @@ static bool_ test_object_wish(char *name, object_type *o_ptr, object_type *forge
o_ptr = forge;
if (!k_ptr->name) continue;
- if (k_ptr->flags3 & TR3_NORM_ART) continue;
- if (k_ptr->flags3 & TR3_INSTA_ART) continue;
+ if (k_ptr->flags & TR_NORM_ART) continue;
+ if (k_ptr->flags & TR_INSTA_ART) continue;
if (k_ptr->tval == TV_GOLD) continue;
object_prep(o_ptr, i);