summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBardur Arantsson <bardur@scientician.net>2016-06-22 07:42:43 +0200
committerBardur Arantsson <bardur@scientician.net>2016-06-22 07:42:43 +0200
commit3941b7834f0a038ed544e6ee96b9920d43db4c32 (patch)
tree4c0cb0d2a37105eb40b88608c9c9e18fc0d1dd5b /src
parent3966bfb2f6836d13c1a93bfab1e9fa61ec4fff35 (diff)
Rework PR{1,2}_* flags to flag_set<>
Since there's no need for two tiers we also reduce the flag set to 1 tier. (Breaks savefile compatbility.)
Diffstat (limited to 'src')
-rw-r--r--src/birth.cc31
-rw-r--r--src/bldg.cc3
-rw-r--r--src/cmd1.cc3
-rw-r--r--src/cmd2.cc3
-rw-r--r--src/cmd6.cc7
-rw-r--r--src/corrupt.cc13
-rw-r--r--src/defines.h38
-rw-r--r--src/dungeon.cc13
-rw-r--r--src/files.cc3
-rw-r--r--src/init1.cc106
-rw-r--r--src/loadsave.cc3
-rw-r--r--src/monster2.cc3
-rw-r--r--src/player_class.hpp4
-rw-r--r--src/player_race.hpp4
-rw-r--r--src/player_race_flag.hpp12
-rw-r--r--src/player_race_flag_list.hpp26
-rw-r--r--src/player_race_flag_set.hpp7
-rw-r--r--src/player_race_mod.hpp4
-rw-r--r--src/player_spec.hpp4
-rw-r--r--src/spells2.cc3
-rw-r--r--src/xtra1.cc20
-rw-r--r--src/xtra1.hpp4
-rw-r--r--src/xtra2.cc9
23 files changed, 132 insertions, 191 deletions
diff --git a/src/birth.cc b/src/birth.cc
index 6ce86c5a..bd59161f 100644
--- a/src/birth.cc
+++ b/src/birth.cc
@@ -35,6 +35,7 @@
#include "options.hpp"
#include "player_class.hpp"
#include "player_race.hpp"
+#include "player_race_flag.hpp"
#include "player_race_mod.hpp"
#include "player_type.hpp"
#include "q_rand.hpp"
@@ -1204,7 +1205,7 @@ int dump_classes(s16b *classes, int sel, u32b *restrictions)
std::string desc;
desc += cp_ptr->desc;
- if (cp_ptr->flags1 & PR1_EXPERIMENTAL)
+ if (cp_ptr->flags & PR_EXPERIMENTAL)
{
desc += "\nEXPERIMENTAL";
}
@@ -1212,7 +1213,7 @@ int dump_classes(s16b *classes, int sel, u32b *restrictions)
print_desc(desc.c_str());
if (!(restrictions[classes[n] / 32] & BIT(classes[n])) ||
- cp_ptr->flags1 & PR1_EXPERIMENTAL)
+ (cp_ptr->flags & PR_EXPERIMENTAL))
c_put_str(TERM_BLUE, buf, 18 + (n / 4), 1 + 20 * (n % 4));
else
c_put_str(TERM_L_BLUE, buf, 18 + (n / 4), 1 + 20 * (n % 4));
@@ -1220,7 +1221,7 @@ int dump_classes(s16b *classes, int sel, u32b *restrictions)
else
{
if (!(restrictions[classes[n] / 32] & BIT(classes[n])) ||
- cp_ptr->flags1 & PR1_EXPERIMENTAL)
+ (cp_ptr->flags & PR_EXPERIMENTAL))
c_put_str(TERM_SLATE, buf, 18 + (n / 4), 1 + 20 * (n % 4));
else
put_str(buf, 18 + (n / 4), 1 + 20 * (n % 4));
@@ -1266,21 +1267,21 @@ int dump_specs(int sel)
std::string desc;
desc += spp_ptr->desc;
- if (spp_ptr->flags1 & PR1_EXPERIMENTAL)
+ if (spp_ptr->flags & PR_EXPERIMENTAL)
{
desc += "\nEXPERIMENTAL";
}
print_desc(desc.c_str());
- if (spp_ptr->flags1 & PR1_EXPERIMENTAL)
+ if (spp_ptr->flags & PR_EXPERIMENTAL)
c_put_str(TERM_BLUE, buf, 18 + (n / 4), 1 + 20 * (n % 4));
else
c_put_str(TERM_L_BLUE, buf, 18 + (n / 4), 1 + 20 * (n % 4));
}
else
{
- if (spp_ptr->flags1 & PR1_EXPERIMENTAL)
+ if (spp_ptr->flags & PR_EXPERIMENTAL)
c_put_str(TERM_SLATE, buf, 18 + (n / 4), 1 + 20 * (n % 4));
else
put_str(buf, 18 + (n / 4), 1 + 20 * (n % 4));
@@ -1322,21 +1323,21 @@ int dump_races(int sel)
std::string desc;
desc += rp_ptr->desc;
- if (rp_ptr->flags1 & PR1_EXPERIMENTAL)
+ if (rp_ptr->flags & PR_EXPERIMENTAL)
{
desc += "\nEXPERIMENTAL";
}
print_desc(desc.c_str());
- if (rp_ptr->flags1 & PR1_EXPERIMENTAL)
+ if (rp_ptr->flags & PR_EXPERIMENTAL)
c_put_str(TERM_BLUE, buf, 18 + (n / 5), 1 + 15 * (n % 5));
else
c_put_str(TERM_L_BLUE, buf, 18 + (n / 5), 1 + 15 * (n % 5));
}
else
{
- if (rp_ptr->flags1 & PR1_EXPERIMENTAL)
+ if (rp_ptr->flags & PR_EXPERIMENTAL)
c_put_str(TERM_SLATE, buf, 18 + (n / 5), 1 + 15 * (n % 5));
else
put_str(buf, 18 + (n / 5), 1 + 15 * (n % 5));
@@ -1383,21 +1384,21 @@ int dump_rmods(int sel, int *racem, int max)
std::string desc;
desc += rmp_ptr->desc;
- if (rmp_ptr->flags1 & PR1_EXPERIMENTAL)
+ if (rmp_ptr->flags & PR_EXPERIMENTAL)
{
desc += "\nEXPERIMENTAL";
}
print_desc(desc.c_str());
- if (rmp_ptr->flags1 & PR1_EXPERIMENTAL)
+ if (rmp_ptr->flags & PR_EXPERIMENTAL)
c_put_str(TERM_BLUE, buf, 18 + (n / 5), 1 + 15 * (n % 5));
else
c_put_str(TERM_L_BLUE, buf, 18 + (n / 5), 1 + 15 * (n % 5));
}
else
{
- if (rmp_ptr->flags1 & PR1_EXPERIMENTAL)
+ if (rmp_ptr->flags & PR_EXPERIMENTAL)
c_put_str(TERM_SLATE, buf, 18 + (n / 5), 1 + 15 * (n % 5));
else
put_str(buf, 18 + (n / 5), 1 + 15 * (n % 5));
@@ -1998,7 +1999,7 @@ static bool_ player_birth_aux_ask()
p_ptr->pgod = k;
set_grace(previous_char.grace);
}
- else if (race_flags1_p(PR1_NO_GOD))
+ else if (race_flags_p(PR_NO_GOD))
{
p_ptr->pgod = GOD_NONE;
}
@@ -2105,7 +2106,7 @@ static bool_ player_birth_aux_ask()
}
/* A god that like us ? more grace ! */
- if (race_flags1_p(PR1_GOD_FRIEND))
+ if (race_flags_p(PR_GOD_FRIEND))
{
set_grace(200);
}
@@ -2135,7 +2136,7 @@ static bool_ player_birth_aux_ask()
/* Set birth options: maximize, preserve, sepcial levels and astral */
p_ptr->preserve = preserve;
p_ptr->special = special_lvls;
- p_ptr->astral = (race_flags2_p(PR2_ASTRAL)) ? TRUE : FALSE;
+ p_ptr->astral = (race_flags_p(PR_ASTRAL)) ? TRUE : FALSE;
/*
* A note by pelpel. (remove this please)
diff --git a/src/bldg.cc b/src/bldg.cc
index 4f1747db..34a4576c 100644
--- a/src/bldg.cc
+++ b/src/bldg.cc
@@ -25,6 +25,7 @@
#include "object2.hpp"
#include "object_flag.hpp"
#include "owner_type.hpp"
+#include "player_race_flag.hpp"
#include "player_type.hpp"
#include "q_library.hpp"
#include "q_fireprof.hpp"
@@ -542,7 +543,7 @@ static bool_ inn_comm(int cmd)
/* Extract race info */
- vampire = ((race_flags1_p(PR1_VAMPIRE)) || (p_ptr->mimic_form == resolve_mimic_name("Vampire")));
+ vampire = ((race_flags_p(PR_VAMPIRE)) || (p_ptr->mimic_form == resolve_mimic_name("Vampire")));
switch (cmd)
{
diff --git a/src/cmd1.cc b/src/cmd1.cc
index 55b1954e..ab3f29d9 100644
--- a/src/cmd1.cc
+++ b/src/cmd1.cc
@@ -33,6 +33,7 @@
#include "object1.hpp"
#include "object2.hpp"
#include "options.hpp"
+#include "player_race_flag.hpp"
#include "player_type.hpp"
#include "quark.hpp"
#include "skills.hpp"
@@ -2560,7 +2561,7 @@ bool_ player_can_enter(byte feature)
/* Player can not walk through "walls" unless in Shadow Form */
- if (p_ptr->wraith_form || (race_flags1_p(PR1_SEMI_WRAITH)))
+ if (p_ptr->wraith_form || (race_flags_p(PR_SEMI_WRAITH)))
pass_wall = TRUE;
else
pass_wall = FALSE;
diff --git a/src/cmd2.cc b/src/cmd2.cc
index f4e85847..059170d4 100644
--- a/src/cmd2.cc
+++ b/src/cmd2.cc
@@ -35,6 +35,7 @@
#include "object_flag.hpp"
#include "object_kind.hpp"
#include "options.hpp"
+#include "player_race_flag.hpp"
#include "player_type.hpp"
#include "skills.hpp"
#include "spells1.hpp"
@@ -4886,7 +4887,7 @@ void do_cmd_steal()
m_ptr->hold_o_idxs.erase(m_ptr->hold_o_idxs.begin() + k);
/* Rogues gain some xp */
- if (race_flags1_p(PR1_EASE_STEAL))
+ if (race_flags_p(PR_EASE_STEAL))
{
s32b max_point;
diff --git a/src/cmd6.cc b/src/cmd6.cc
index 0c0fb63d..661a950c 100644
--- a/src/cmd6.cc
+++ b/src/cmd6.cc
@@ -34,6 +34,7 @@
#include "object_kind.hpp"
#include "object_type.hpp"
#include "options.hpp"
+#include "player_race_flag.hpp"
#include "player_type.hpp"
#include "randart.hpp"
#include "skills.hpp"
@@ -1495,7 +1496,7 @@ void do_cmd_eat_food(void)
/* Food can feed the player, in a different ways */
/* Vampires */
- if ((race_flags1_p(PR1_VAMPIRE)) || (p_ptr->mimic_form == resolve_mimic_name("Vampire")))
+ if ((race_flags_p(PR_VAMPIRE)) || (p_ptr->mimic_form == resolve_mimic_name("Vampire")))
{
/* Reduced nutritional benefit */
/* (void)set_food(p_ptr->food + (fval / 10)); -- No more */
@@ -1508,9 +1509,9 @@ void do_cmd_eat_food(void)
}
}
- else if (race_flags1_p(PR1_NO_FOOD))
+ else if (race_flags_p(PR_NO_FOOD))
{
- if (race_flags1_p(PR1_UNDEAD))
+ if (race_flags_p(PR_UNDEAD))
{
msg_print("The food of mortals is poor sustenance for you.");
}
diff --git a/src/corrupt.cc b/src/corrupt.cc
index 8d5670c6..64569264 100644
--- a/src/corrupt.cc
+++ b/src/corrupt.cc
@@ -3,6 +3,7 @@
#include "init1.hpp"
#include "object_flag.hpp"
#include "player_race.hpp"
+#include "player_race_flag.hpp"
#include "player_race_mod.hpp"
#include "player_type.hpp"
#include "stats.hpp"
@@ -60,10 +61,10 @@ static void player_gain_vampire_teeth()
rmp_ptr = &race_mod_info[SUBRACE_SAVE];
subrace_add_power(rmp_ptr, PWR_VAMPIRISM);
- rmp_ptr->flags1 = rmp_ptr->flags1
- | PR1_VAMPIRE
- | PR1_UNDEAD
- | PR1_NO_SUBRACE_CHANGE;
+ rmp_ptr->flags = rmp_ptr->flags
+ | PR_VAMPIRE
+ | PR_UNDEAD
+ | PR_NO_SUBRACE_CHANGE;
}
static void player_gain_vampire_strength()
@@ -105,7 +106,7 @@ static void player_gain_vampire()
}
/* Bonus/and .. not bonus :) */
- rmp_ptr->flags1 = rmp_ptr->flags1 | PR1_HURT_LITE;
+ rmp_ptr->flags = rmp_ptr->flags | PR_HURT_LITE;
rmp_ptr->oflags[2] = rmp_ptr->oflags[2]
| TR_RES_POIS
| TR_RES_NETHER
@@ -766,7 +767,7 @@ static bool_ player_allow_corruption(int corruption_idx)
/* Vampire teeth is special */
if (corruption_idx == CORRUPT_VAMPIRE_TEETH)
{
- if (race_flags1_p(PR1_NO_SUBRACE_CHANGE))
+ if (race_flags_p(PR_NO_SUBRACE_CHANGE))
{
return TRUE;
}
diff --git a/src/defines.h b/src/defines.h
index 7243eb9c..d69247ce 100644
--- a/src/defines.h
+++ b/src/defines.h
@@ -383,44 +383,6 @@
#define MAX_STACK_SIZE 100
-/* Race flags */
-#define PR1_EXPERIMENTAL 0x00000001L /* Is still under developemnt */
-/* XXX */
-#define PR1_RESIST_BLACK_BREATH 0x00000004L /* Resist black breath */
-#define PR1_NO_STUN 0x00000008L /* Never stunned */
-#define PR1_XTRA_MIGHT_BOW 0x00000010L /* Xtra might with bows */
-#define PR1_XTRA_MIGHT_XBOW 0x00000020L /* Xtra might with xbows */
-#define PR1_XTRA_MIGHT_SLING 0x00000040L /* Xtra might with slings */
-#define PR1_AC_LEVEL 0x00000080L /* More AC with levels */
-#define PR1_HURT_LITE 0x00000100L /* Hurt by light */
-#define PR1_VAMPIRE 0x00000200L /* Vampire */
-#define PR1_UNDEAD 0x00000400L /* Undead */
-#define PR1_NO_CUT 0x00000800L /* no cuts */
-#define PR1_CORRUPT 0x00001000L /* hack-- corrupted */
-#define PR1_NO_FOOD 0x00002000L /* little gain from food */
-#define PR1_NO_GOD 0x00004000L /* cannot worship */
-/* XXX */
-#define PR1_ELF 0x00010000L /* Is an elf */
-#define PR1_SEMI_WRAITH 0x00020000L /* Takes damage when going in walls */
-#define PR1_NO_SUBRACE_CHANGE 0x00040000L /* Impossible to change subrace */
-/* XXX */
-#define PR1_ANTIMAGIC 0x00100000L /* antimagic ... hack */
-#define PR1_MOLD_FRIEND 0x00200000L /* Not attacked by molds wielded */
-#define PR1_GOD_FRIEND 0x00400000L /* Better grace */
-/* XXX */
-#define PR1_INNATE_SPELLS 0x01000000L /* KNown all spells, only need books */
-/* XXX */
-/* XXX */
-#define PR1_EASE_STEAL 0x08000000L /* Gain xp by stealing */
-/* XXX */
-/* XXX */
-/* XXX */
-/* XXX */
-
-/* XXX */
-#define PR2_ASTRAL 0x00000002L /* Is it an astral being coming from th halls of mandos ? */
-/* XXX */
-
/* XXX */
#define MKEY_MINDCRAFT 2
#define MKEY_ANTIMAGIC 3
diff --git a/src/dungeon.cc b/src/dungeon.cc
index bbb60aa5..2e71278e 100644
--- a/src/dungeon.cc
+++ b/src/dungeon.cc
@@ -52,6 +52,7 @@
#include "object_type.hpp"
#include "options.hpp"
#include "player_race.hpp"
+#include "player_race_flag.hpp"
#include "player_race_mod.hpp"
#include "player_spec.hpp"
#include "player_type.hpp"
@@ -1494,7 +1495,7 @@ static void process_world(void)
{
/* Do nothing */
}
- else if (race_flags1_p(PR1_SEMI_WRAITH) && (!p_ptr->wraith_form) && (f_info[cave[p_ptr->py][p_ptr->px].feat].flags & FF_CAN_PASS))
+ else if (race_flags_p(PR_SEMI_WRAITH) && (!p_ptr->wraith_form) && (f_info[cave[p_ptr->py][p_ptr->px].feat].flags & FF_CAN_PASS))
{
int amt = 1 + ((p_ptr->lev) / 5);
@@ -1719,7 +1720,7 @@ static void process_world(void)
dec++;
}
- if (race_flags1_p(PR1_ELF))
+ if (race_flags_p(PR_ELF))
{
dec -= wisdom_scale(2);
}
@@ -1738,7 +1739,7 @@ static void process_world(void)
dec++;
}
- if (race_flags1_p(PR1_ELF))
+ if (race_flags_p(PR_ELF))
{
dec += 5 - wisdom_scale(4);
}
@@ -2663,7 +2664,7 @@ static void process_world(void)
byte chance = 0;
int plev = p_ptr->lev;
- if (race_flags1_p(PR1_RESIST_BLACK_BREATH)) chance = 2;
+ if (race_flags_p(PR_RESIST_BLACK_BREATH)) chance = 2;
else chance = 5;
if ((rand_int(100) < chance) && (p_ptr->exp > 0))
@@ -3908,7 +3909,7 @@ static void process_command(void)
if (p_ptr->control) break;
if (p_ptr->wild_mode) break;
- if (race_flags1_p(PR1_NO_GOD))
+ if (race_flags_p(PR_NO_GOD))
{
msg_print("You cannot worship gods.");
}
@@ -5223,7 +5224,7 @@ void play_game()
/* Hack -- enter the world */
/* Mega-hack Vampires and Spectres start at midnight */
- if (race_flags1_p(PR1_UNDEAD))
+ if (race_flags_p(PR_UNDEAD))
{
turn = (10L * DAY / 2) + 1;
}
diff --git a/src/files.cc b/src/files.cc
index 9ebc18ab..4cd95447 100644
--- a/src/files.cc
+++ b/src/files.cc
@@ -39,6 +39,7 @@
#include "options.hpp"
#include "player_class.hpp"
#include "player_race.hpp"
+#include "player_race_flag.hpp"
#include "player_race_mod.hpp"
#include "player_spec.hpp"
#include "player_type.hpp"
@@ -2698,7 +2699,7 @@ errr file_character(cptr name, bool_ full)
if (noscore)
fprintf(fff, "\n You have done something illegal.");
- if (race_flags1_p(PR1_EXPERIMENTAL))
+ if (race_flags_p(PR_EXPERIMENTAL))
fprintf(fff, "\n You have done something experimental.");
{
diff --git a/src/init1.cc b/src/init1.cc
index ec12ad34..53e9d851 100644
--- a/src/init1.cc
+++ b/src/init1.cc
@@ -28,6 +28,7 @@
#include "owner_type.hpp"
#include "player_class.hpp"
#include "player_race.hpp"
+#include "player_race_flag.hpp"
#include "player_race_mod.hpp"
#include "player_type.hpp"
#include "randart_gen_type.hpp"
@@ -272,84 +273,6 @@ static cptr st_info_flags1[] =
"XXX1"
};
-/*
- * Race flags
- */
-static cptr rp_info_flags1[] =
-{
- "EXPERIMENTAL",
- "XXX",
- "RESIST_BLACK_BREATH",
- "NO_STUN",
- "XTRA_MIGHT_BOW",
- "XTRA_MIGHT_XBOW",
- "XTRA_MIGHT_SLING",
- "AC_LEVEL",
- "HURT_LITE",
- "VAMPIRE",
- "UNDEAD",
- "NO_CUT",
- "CORRUPT",
- "NO_FOOD",
- "NO_GOD",
- "XXX",
- "ELF",
- "SEMI_WRAITH",
- "NO_SUBRACE_CHANGE",
- "XXX",
- "XXX",
- "MOLD_FRIEND",
- "GOD_FRIEND",
- "XXX",
- "INNATE_SPELLS",
- "XXX",
- "XXX",
- "EASE_STEAL",
- "XXX",
- "XXX",
- "XXX",
- "XXX"
-};
-
-/*
- * Race flags
- */
-static cptr rp_info_flags2[] =
-{
- "XXX",
- "ASTRAL",
- "XXX",
- "XXX1",
- "XXX1",
- "XXX1",
- "XXX1",
- "XXX1",
- "XXX1",
- "XXX1",
- "XXX1",
- "XXX1",
- "XXX1",
- "XXX1",
- "XXX1",
- "XXX1",
- "XXX1",
- "XXX1",
- "XXX1",
- "XXX1",
- "XXX1",
- "XXX1",
- "XXX1",
- "XXX1",
- "XXX1",
- "XXX1",
- "XXX1",
- "XXX1",
- "XXX1",
- "XXX1",
- "XXX1",
- "XXX1"
-};
-
/* Skill flags */
static cptr s_info_flags1[] =
{
@@ -922,14 +845,16 @@ static errr grab_one_skill_flag(u32b *f1, cptr what)
/*
* Grab one flag from a textual string
*/
-static errr grab_one_player_race_flag(u32b *f1, u32b *f2, cptr what)
+static errr grab_one_player_race_flag(player_race_flag_set *flags, cptr what)
{
- if (lookup_flags(what,
- flag_tie(f1, rp_info_flags1),
- flag_tie(f2, rp_info_flags2)))
- {
- return 0;
- }
+#define PR(tier, index, name) \
+ if (streq(what, #name)) \
+ { \
+ *flags |= BOOST_PP_CAT(PR_,name); \
+ return 0; \
+ };
+#include "player_race_flag_list.hpp"
+#undef PR
/* Oops */
msg_format("(2)Unknown race flag '%s'.", what);
@@ -1310,7 +1235,7 @@ errr init_player_info_txt(FILE *fp)
/* Process 'G' for "Player flags" (multiple lines) */
if ((buf[0] == 'R') && (buf[2] == 'G'))
{
- if (0 != grab_one_player_race_flag(&rp_ptr->flags1, &rp_ptr->flags2, buf + 4))
+ if (0 != grab_one_player_race_flag(&rp_ptr->flags, buf + 4))
{
return (5);
}
@@ -1606,7 +1531,7 @@ errr init_player_info_txt(FILE *fp)
/* Process 'G' for "Player flags" (multiple lines) */
if ((buf[0] == 'S') && (buf[2] == 'G'))
{
- if (0 != grab_one_player_race_flag(&rmp_ptr->flags1, &rmp_ptr->flags2, buf + 4))
+ if (0 != grab_one_player_race_flag(&rmp_ptr->flags, buf + 4))
{
return (5);
}
@@ -2046,7 +1971,7 @@ errr init_player_info_txt(FILE *fp)
/* Process 'G' for "Player flags" (multiple lines) */
if ((buf[0] == 'C') && (buf[2] == 'G'))
{
- if (0 != grab_one_player_race_flag(&c_ptr->flags1, &c_ptr->flags2, buf + 4))
+ if (0 != grab_one_player_race_flag(&c_ptr->flags, buf + 4))
{
return (5);
}
@@ -2244,7 +2169,10 @@ errr init_player_info_txt(FILE *fp)
}
/* Parse this entry */
- if (0 != grab_one_player_race_flag(&s_ptr->flags1, &s_ptr->flags2, s)) return (5);
+ if (0 != grab_one_player_race_flag(&s_ptr->flags, s))
+ {
+ return (5);
+ }
/* Start the next entry */
s = t;
diff --git a/src/loadsave.cc b/src/loadsave.cc
index 93f2679c..5c257518 100644
--- a/src/loadsave.cc
+++ b/src/loadsave.cc
@@ -353,8 +353,7 @@ static void do_subrace(ls_flag_t flag)
for (i = 0; i < BODY_MAX; i++)
do_byte((byte*)&sr_ptr->body_parts[i], flag);
- do_u32b(&sr_ptr->flags1, flag);
- do_u32b(&sr_ptr->flags2, flag);
+ do_flag_set(&sr_ptr->flags, flag);
for (i = 0; i < PY_MAX_LEVEL + 1; i++)
{
diff --git a/src/monster2.cc b/src/monster2.cc
index e5957770..7c05f9f6 100644
--- a/src/monster2.cc
+++ b/src/monster2.cc
@@ -31,6 +31,7 @@
#include "object_kind.hpp"
#include "object_type.hpp"
#include "options.hpp"
+#include "player_race_flag.hpp"
#include "player_type.hpp"
#include "randart.hpp"
#include "spells1.hpp"
@@ -1470,7 +1471,7 @@ static void sanity_blast(monster_type * m_ptr, bool_ necro)
}
/* Undead characters are 50% likely to be unaffected */
- if ((race_flags1_p(PR1_UNDEAD)) || (p_ptr->mimic_form == resolve_mimic_name("Vampire")))
+ if ((race_flags_p(PR_UNDEAD)) || (p_ptr->mimic_form == resolve_mimic_name("Vampire")))
{
if (randint(100) < (25 + (p_ptr->lev))) return;
}
diff --git a/src/player_class.hpp b/src/player_class.hpp
index 98414158..236a3007 100644
--- a/src/player_class.hpp
+++ b/src/player_class.hpp
@@ -4,6 +4,7 @@
#include "h-basic.h"
#include "object_flag_set.hpp"
#include "player_defs.hpp"
+#include "player_race_flag_set.hpp"
#include "player_spec.hpp"
/**
@@ -55,8 +56,7 @@ struct player_class
byte max_spell_level = 0; /* Maximun spell level */
byte magic_max_spell = 0; /* Maximun numbner of spells one can learn by natural means */
- u32b flags1 = 0;
- u32b flags2 = 0;
+ player_race_flag_set flags;
s16b mana = 0;
s16b blow_num = 0;
diff --git a/src/player_race.hpp b/src/player_race.hpp
index e01034ba..9af977aa 100644
--- a/src/player_race.hpp
+++ b/src/player_race.hpp
@@ -5,6 +5,7 @@
#include "object_flag_set.hpp"
#include "player_defs.hpp"
#include "player_race_ability_type.hpp"
+#include "player_race_flag_set.hpp"
#include "skills_defs.hpp"
#include <array>
@@ -43,8 +44,7 @@ struct player_race
s16b chart = 0; /* Chart history */
- u32b flags1 = 0;
- u32b flags2 = 0;
+ player_race_flag_set flags;
std::array<object_flag_set, PY_MAX_LEVEL + 1> oflags;
s16b opval[PY_MAX_LEVEL + 1] { };
diff --git a/src/player_race_flag.hpp b/src/player_race_flag.hpp
new file mode 100644
index 00000000..1268c3c0
--- /dev/null
+++ b/src/player_race_flag.hpp
@@ -0,0 +1,12 @@
+#pragma once
+
+#include "player_race_flag_set.hpp"
+#include <boost/preprocessor/cat.hpp>
+
+//
+// Define flag set for each flag.
+//
+#define PR(tier, index, name) \
+ DECLARE_FLAG(player_race_flag_set, BOOST_PP_CAT(PR_,name), tier, index)
+#include "player_race_flag_list.hpp"
+#undef PR
diff --git a/src/player_race_flag_list.hpp b/src/player_race_flag_list.hpp
new file mode 100644
index 00000000..5116ad87
--- /dev/null
+++ b/src/player_race_flag_list.hpp
@@ -0,0 +1,26 @@
+/**
+ * X-macro list of all the player race flags
+ */
+
+/* PR(<tier>, <index>, <name>) */
+
+PR(1, 0, EXPERIMENTAL) /* Experimental */
+PR(1, 1, RESIST_BLACK_BREATH) /* Resists black breath */
+PR(1, 2, NO_STUN) /* Cannot be stunned */
+PR(1, 3, XTRA_MIGHT_BOW) /* Xtra might with bows */
+PR(1, 4, XTRA_MIGHT_XBOW) /* Xtra might with x-bows */
+PR(1, 5, XTRA_MIGHT_SLING) /* Xtra might with slings */
+PR(1, 6, AC_LEVEL) /* AC increases with levels */
+PR(1, 7, HURT_LITE) /* Hurt by light */
+PR(1, 8, VAMPIRE) /* Vampire */
+PR(1, 9, UNDEAD) /* Undead */
+PR(1, 10, NO_CUT) /* No cuts */
+PR(1, 11, CORRUPT) /* Corrupted; automatically gains corruptions */
+PR(1, 12, NO_FOOD) /* Little gain from food */
+PR(1, 13, NO_GOD) /* Cannot worship any gods */
+PR(1, 14, ELF) /* Is an elf */
+PR(1, 15, SEMI_WRAITH) /* Allows walking through walls; taking damage */
+PR(1, 16, NO_SUBRACE_CHANGE) /* Impossible to change subrace */
+PR(1, 17, GOD_FRIEND) /* Better grace */
+PR(1, 18, EASE_STEAL) /* Gain XP by stealing */
+PR(1, 19, ASTRAL) /* Astral being from the halls of Mandos */
diff --git a/src/player_race_flag_set.hpp b/src/player_race_flag_set.hpp
new file mode 100644
index 00000000..4dd8dd9f
--- /dev/null
+++ b/src/player_race_flag_set.hpp
@@ -0,0 +1,7 @@
+#pragma once
+
+#include "flag_set.hpp"
+
+constexpr std::size_t PR_MAX_TIERS = 1;
+
+typedef flag_set<PR_MAX_TIERS> player_race_flag_set;
diff --git a/src/player_race_mod.hpp b/src/player_race_mod.hpp
index 983c3471..756da347 100644
--- a/src/player_race_mod.hpp
+++ b/src/player_race_mod.hpp
@@ -5,6 +5,7 @@
#include "object_flag_set.hpp"
#include "player_defs.hpp"
#include "player_race_ability_type.hpp"
+#include "player_race_flag_set.hpp"
#include "skills_defs.hpp"
#include <array>
@@ -44,8 +45,7 @@ struct player_race_mod
char body_parts[BODY_MAX] { }; /* To help to decide what to use when body changing */
- u32b flags1 = 0;
- u32b flags2 = 0;
+ player_race_flag_set flags;
std::array<object_flag_set, PY_MAX_LEVEL + 1> oflags;
s16b opval[PY_MAX_LEVEL + 1] { };
diff --git a/src/player_spec.hpp b/src/player_spec.hpp
index 5105df31..5fcec7cd 100644
--- a/src/player_spec.hpp
+++ b/src/player_spec.hpp
@@ -2,6 +2,7 @@
#include "h-basic.h"
#include "player_race_ability_type.hpp"
+#include "player_race_flag_set.hpp"
#include "skills_defs.hpp"
#include <array>
@@ -30,8 +31,7 @@ struct player_spec
u32b gods = 0;
- u32b flags1 = 0;
- u32b flags2 = 0;
+ player_race_flag_set flags;
std::array<player_race_ability_type, 10> abilities; /* Abilities to be gained by level(doesnt take prereqs in account) */
};
diff --git a/src/spells2.cc b/src/spells2.cc
index 7b7c3b7b..15df2f37 100644
--- a/src/spells2.cc
+++ b/src/spells2.cc
@@ -33,6 +33,7 @@
#include "object_kind.hpp"
#include "object_type.hpp"
#include "options.hpp"
+#include "player_race_flag.hpp"
#include "player_type.hpp"
#include "skills.hpp"
#include "spells1.hpp"
@@ -4492,7 +4493,7 @@ void earthquake(int cy, int cx, int r)
map[16 + p_ptr->py - cy][16 + p_ptr->px - cx] = FALSE;
/* Semi-wraiths have to be hurt *some*, says DG */
- if (race_flags1_p(PR1_SEMI_WRAITH))
+ if (race_flags_p(PR_SEMI_WRAITH))
damage /= 4;
/* Take some damage */
diff --git a/src/xtra1.cc b/src/xtra1.cc
index 1bf2b9a6..6fbbfdf0 100644
--- a/src/xtra1.cc
+++ b/src/xtra1.cc
@@ -36,6 +36,7 @@
#include "options.hpp"
#include "player_class.hpp"
#include "player_race.hpp"
+#include "player_race_flag.hpp"
#include "player_race_mod.hpp"
#include "player_type.hpp"
#include "skill_type.hpp"
@@ -3028,7 +3029,7 @@ void calc_bonuses(bool_ silent)
apply_flags(rmp_ptr->oflags[i], rmp_ptr->opval[i], 0, 0, 0, 0);
}
- if (race_flags1_p(PR1_HURT_LITE))
+ if (race_flags_p(PR_HURT_LITE))
p_ptr->sensible_lite = TRUE;
}
@@ -3146,7 +3147,7 @@ void calc_bonuses(bool_ silent)
/* Hack -- aura of fire also provides light */
if (p_ptr->sh_fire) p_ptr->lite = TRUE;
- if (race_flags1_p(PR1_AC_LEVEL))
+ if (race_flags_p(PR_AC_LEVEL))
{
p_ptr->to_a += 20 + (p_ptr->lev / 5);
p_ptr->dis_to_a += 20 + (p_ptr->lev / 5);
@@ -3617,13 +3618,13 @@ void calc_bonuses(bool_ silent)
if (p_ptr->num_fire < 1) p_ptr->num_fire = 1;
}
- if (race_flags1_p(PR1_XTRA_MIGHT_BOW) && p_ptr->tval_ammo == TV_ARROW)
+ if (race_flags_p(PR_XTRA_MIGHT_BOW) && p_ptr->tval_ammo == TV_ARROW)
p_ptr->xtra_might += 1;
- if (race_flags1_p(PR1_XTRA_MIGHT_SLING) && p_ptr->tval_ammo == TV_SHOT)
+ if (race_flags_p(PR_XTRA_MIGHT_SLING) && p_ptr->tval_ammo == TV_SHOT)
p_ptr->xtra_might += 1;
- if (race_flags1_p(PR1_XTRA_MIGHT_XBOW) && p_ptr->tval_ammo == TV_BOLT)
+ if (race_flags_p(PR_XTRA_MIGHT_XBOW) && p_ptr->tval_ammo == TV_BOLT)
p_ptr->xtra_might += 1;
/* Examine the "current tool" */
@@ -4679,12 +4680,7 @@ int luck(int min, int max)
return (luck + min);
}
-bool race_flags1_p(u32b flags1_mask)
+bool race_flags_p(player_race_flag_set const &flags_mask)
{
- return (rp_ptr->flags1 | rmp_ptr->flags1 | cp_ptr->flags1 | spp_ptr->flags1) & flags1_mask;
-}
-
-bool race_flags2_p(u32b flags2_mask)
-{
- return (rp_ptr->flags2 | rmp_ptr->flags2 | cp_ptr->flags2 | spp_ptr->flags2) & flags2_mask;
+ return bool((rp_ptr->flags | rmp_ptr->flags | cp_ptr->flags | spp_ptr->flags) & flags_mask);
}
diff --git a/src/xtra1.hpp b/src/xtra1.hpp
index 3e434828..0c1b93bf 100644
--- a/src/xtra1.hpp
+++ b/src/xtra1.hpp
@@ -2,6 +2,7 @@
#include "h-basic.h"
#include "object_flag_set.hpp"
+#include "player_race_flag_set.hpp"
#include <string>
@@ -23,5 +24,4 @@ extern void calc_bonuses(bool_ silent);
extern void gain_fate(byte fate);
extern std::string fate_desc(int fate);
extern std::string dump_fates();
-extern bool race_flags1_p(u32b flags1_mask);
-extern bool race_flags2_p(u32b flags2_mask);
+extern bool race_flags_p(player_race_flag_set const &flags_mask);
diff --git a/src/xtra2.cc b/src/xtra2.cc
index 3665ee5b..93a0603b 100644
--- a/src/xtra2.cc
+++ b/src/xtra2.cc
@@ -38,6 +38,7 @@
#include "options.hpp"
#include "player_class.hpp"
#include "player_race.hpp"
+#include "player_race_flag.hpp"
#include "player_race_mod.hpp"
#include "player_type.hpp"
#include "point.hpp"
@@ -1362,7 +1363,7 @@ bool_ set_stun(int v)
/* Hack -- Force good values */
v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
- if (race_flags1_p(PR1_NO_STUN)) v = 0;
+ if (race_flags_p(PR_NO_STUN)) v = 0;
/* Knocked out */
if (p_ptr->stun > 100)
@@ -1523,7 +1524,7 @@ bool_ set_cut(int v)
/* Hack -- Force good values */
v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
- if (race_flags1_p(PR1_NO_CUT)) v = 0;
+ if (race_flags_p(PR_NO_CUT)) v = 0;
/* Mortal wound */
if (p_ptr->cut > 1000)
@@ -1998,7 +1999,7 @@ void check_experience(void)
if (p_ptr->lev > p_ptr->max_plv)
{
p_ptr->max_plv = p_ptr->lev;
- if ((race_flags1_p(PR1_CORRUPT)) &&
+ if ((race_flags_p(PR_CORRUPT)) &&
(randint(3) == 1))
{
level_corruption = TRUE;
@@ -2093,7 +2094,7 @@ void check_experience_obj(object_type *o_ptr)
*/
void gain_exp(s32b amount)
{
- if ((p_ptr->max_exp > 0) && (race_flags1_p(PR1_CORRUPT)))
+ if ((p_ptr->max_exp > 0) && (race_flags_p(PR_CORRUPT)))
{
if ((randint(p_ptr->max_exp) < amount) || (randint(12000000) < amount))
{