summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBardur Arantsson <bardur@scientician.net>2015-03-22 13:05:39 +0100
committerBardur Arantsson <bardur@scientician.net>2015-03-22 13:05:39 +0100
commitb11197ae79d621c50d89f6a092a3f95f954712f0 (patch)
tree44b20f31bc6b4f946d2f4fb6c19afdce558a34f2
parentfb2a78c52a32026a57fd9cc7763a783456199dd7 (diff)
Inline various GOD macros
-rw-r--r--src/cmd1.cc6
-rw-r--r--src/cmd2.cc8
-rw-r--r--src/cmd6.cc2
-rw-r--r--src/defines.h4
-rw-r--r--src/dungeon.cc59
-rw-r--r--src/files.cc18
-rw-r--r--src/gods.cc7
-rw-r--r--src/gods.hpp1
-rw-r--r--src/melee1.cc3
-rw-r--r--src/q_one.cc10
-rw-r--r--src/q_spider.cc2
-rw-r--r--src/skills.cc2
-rw-r--r--src/spells1.cc2
-rw-r--r--src/xtra1.cc24
-rw-r--r--src/xtra2.cc29
15 files changed, 98 insertions, 79 deletions
diff --git a/src/cmd1.cc b/src/cmd1.cc
index 96cb3826..2b1b6ea1 100644
--- a/src/cmd1.cc
+++ b/src/cmd1.cc
@@ -2465,7 +2465,7 @@ void py_attack(int y, int x, int max_blow)
while (randint(4) == 1);
}
- PRAY_GOD(GOD_TULKAS)
+ if (praying_to(GOD_TULKAS))
{
if (magik(wisdom_scale(130) - m_ptr->level) && (p_ptr->grace > 1000))
{
@@ -2492,7 +2492,7 @@ void py_attack(int y, int x, int max_blow)
}
/* Melkor can cast curse for you*/
- PRAY_GOD(GOD_MELKOR)
+ if (praying_to(GOD_MELKOR))
{
int lv = get_level(MELKOR_CURSE, 100, 1);
@@ -2928,7 +2928,7 @@ bool_ player_can_enter(byte feature)
pass_wall ||
(has_ability(AB_TREE_WALK)) ||
(p_ptr->mimic_form == resolve_mimic_name("Ent")) ||
- ((p_ptr->grace >= 9000) && (p_ptr->praying) && (p_ptr->pgod == GOD_YAVANNA)))
+ ((p_ptr->grace >= 9000) && praying_to(GOD_YAVANNA)))
return (TRUE);
}
diff --git a/src/cmd2.cc b/src/cmd2.cc
index 4354773b..ac6cbf1e 100644
--- a/src/cmd2.cc
+++ b/src/cmd2.cc
@@ -4464,7 +4464,7 @@ void do_cmd_immovable_special(void)
/* Can we sacrifice it ? */
static bool_ item_tester_hook_sacrifiable(object_type *o_ptr)
{
- GOD(GOD_MELKOR)
+ if (p_ptr->pgod == GOD_MELKOR)
{
/* Corpses are */
if (o_ptr->tval == TV_CORPSE && o_ptr->sval == SV_CORPSE_CORPSE)
@@ -4537,7 +4537,7 @@ void do_cmd_sacrifice(void)
int agod = on_what - FEAT_ALTAR_HEAD + 1;
/* Not worshipping a god ? ahhhh! */
- GOD(GOD_NONE)
+ if (p_ptr->pgod == GOD_NONE)
{
int i;
@@ -4555,7 +4555,7 @@ void do_cmd_sacrifice(void)
}
else if (p_ptr->pgod == agod)
{
- GOD(GOD_MELKOR)
+ if (p_ptr->pgod == GOD_MELKOR)
{
/* One can sacrifice some HP for piety or damage */
if ((p_ptr->mhp > 10) && (p_ptr->chp > 10) && get_check("Do you want to sacrifice a part of yourself? "))
@@ -4612,7 +4612,7 @@ void do_cmd_sacrifice(void)
}
}
- GOD(GOD_AULE)
+ if (p_ptr->pgod == GOD_AULE)
{
do_cmd_sacrifice_aule();
}
diff --git a/src/cmd6.cc b/src/cmd6.cc
index f0fa7f10..6d3dcf56 100644
--- a/src/cmd6.cc
+++ b/src/cmd6.cc
@@ -2365,7 +2365,7 @@ static bool_ quaff_potion(int tval, int sval, int pval, int pval2)
potions of corruption. */
if (game_module_idx == MODULE_THEME)
{
- GOD(GOD_MELKOR)
+ if (p_ptr->pgod == GOD_MELKOR)
{
msg_print("Your quaffing of this potion pleases Melkor!");
set_grace(p_ptr->grace + 2);
diff --git a/src/defines.h b/src/defines.h
index 564eeceb..a352e562 100644
--- a/src/defines.h
+++ b/src/defines.h
@@ -4133,10 +4133,6 @@
#define GOD_MANDOS 9
#define MAX_GODS 10
-#define GOD(g) if (p_ptr->pgod == (g))
-#define PRAY_GOD(g) if ((p_ptr->pgod == (g)) && (p_ptr->praying))
-#define NOT_PRAY_GOD(g) if ((p_ptr->pgod == (g)) && (!p_ptr->praying))
-
/*
* Command numbers for do_cmd_cli().
*
diff --git a/src/dungeon.cc b/src/dungeon.cc
index f75d13a6..68ccef82 100644
--- a/src/dungeon.cc
+++ b/src/dungeon.cc
@@ -266,7 +266,7 @@ static byte value_check_aux2_magic(object_type *o_ptr)
*/
static bool_ granted_resurrection(void)
{
- PRAY_GOD(GOD_ERU)
+ if (praying_to(GOD_ERU))
{
if (p_ptr->grace > 100000)
{
@@ -1005,7 +1005,7 @@ static void process_world_gods()
const char *race_name = rp_ptr->title;
const char *subrace_name = rmp_ptr->title;
- GOD(GOD_VARDA)
+ if (p_ptr->pgod == GOD_VARDA)
{
if (grace_delay_trigger())
{
@@ -1035,7 +1035,7 @@ static void process_world_gods()
}
}
- GOD(GOD_ULMO)
+ if (p_ptr->pgod == GOD_ULMO)
{
if (grace_delay_trigger())
{
@@ -1077,7 +1077,7 @@ static void process_world_gods()
}
}
- GOD(GOD_AULE)
+ if (p_ptr->pgod == GOD_AULE)
{
if (grace_delay_trigger())
{
@@ -1159,7 +1159,7 @@ static void process_world_gods()
}
}
- GOD(GOD_MANDOS)
+ if (p_ptr->pgod == GOD_MANDOS)
{
if (grace_delay_trigger())
{
@@ -1699,7 +1699,7 @@ static void process_world(void)
/* Eru piety incraese with time */
if (((turn % 100) == 0) && (!p_ptr->did_nothing) && (!p_ptr->wild_mode))
{
- NOT_PRAY_GOD(GOD_ERU)
+ if ((p_ptr->pgod == GOD_ERU) && !p_ptr->praying)
{
int inc = wisdom_scale(10);
@@ -1711,40 +1711,55 @@ static void process_world(void)
/* Most gods piety decrease with time */
if (((turn % 300) == 0) && (!p_ptr->did_nothing) && (!p_ptr->wild_mode) && (dun_level))
{
- GOD(GOD_MANWE)
+ if (p_ptr->pgod == GOD_MANWE)
{
int dec = 4 - wisdom_scale(3);
- PRAY_GOD(GOD_MANWE)
- dec++;
+ if (p_ptr->praying)
+ {
+ dec++;
+ }
+
if (race_flags1_p(PR1_ELF))
+ {
dec -= wisdom_scale(2);
- if (dec < 1) dec = 1;
+ }
+
+ dec = std::max(1, dec);
+
inc_piety(GOD_MANWE, -dec);
}
- GOD(GOD_MELKOR)
+
+ if (p_ptr->pgod == GOD_MELKOR)
{
int dec = 8 - wisdom_scale(6);
- PRAY_GOD(GOD_MELKOR)
- dec++;
+ if (p_ptr->praying)
+ {
+ dec++;
+ }
+
if (race_flags1_p(PR1_ELF))
+ {
dec += 5 - wisdom_scale(4);
- if (dec < 1) dec = 1;
+ }
+
+ dec = std::max(1, dec);
+
inc_piety(GOD_MELKOR, -dec);
}
- PRAY_GOD(GOD_TULKAS)
+
+ if (praying_to(GOD_TULKAS))
{
- int dec = 4 - wisdom_scale(3);
+ int dec = std::max(1, 4 - wisdom_scale(3));
- if (dec < 1) dec = 1;
inc_piety(GOD_TULKAS, -dec);
}
}
/* Yavanna piety decrease with time */
if (((turn % 400) == 0) && (!p_ptr->did_nothing) && (!p_ptr->wild_mode) && (dun_level))
{
- GOD(GOD_YAVANNA)
+ if (p_ptr->pgod == GOD_YAVANNA)
{
int dec = 5 - wisdom_scale(3);
@@ -1753,10 +1768,8 @@ static void process_world(void)
{
dec -= wisdom_scale(2);
}
- if (dec < 1)
- {
- dec = 1;
- }
+
+ dec = std::max(1, dec);
inc_piety(GOD_YAVANNA, -dec);
}
}
@@ -1773,7 +1786,7 @@ static void process_world(void)
if (cave_no_regen) regen_amount = 0;
/* Being over grass allows Yavanna to regen you */
- PRAY_GOD(GOD_YAVANNA)
+ if (praying_to(GOD_YAVANNA))
{
if (cave[p_ptr->py][p_ptr->px].feat == FEAT_GRASS)
{
diff --git a/src/files.cc b/src/files.cc
index 9585a249..78784938 100644
--- a/src/files.cc
+++ b/src/files.cc
@@ -1589,28 +1589,28 @@ void player_flags(u32b *f1, u32b *f2, u32b *f3, u32b *f4, u32b *f5, u32b *esp)
if (get_skill(SKILL_WATER) >= 30) (*f5) |= TR5_WATER_BREATH;
/* Gods */
- GOD(GOD_ERU)
+ 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;
}
- GOD(GOD_MELKOR)
+ 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);
- PRAY_GOD(GOD_MELKOR)
+ if (p_ptr->praying)
{
if (p_ptr->grace > 5000) (*f2) |= TR2_INVIS;
if (p_ptr->grace > 15000) (*f2) |= TR2_IM_FIRE;
}
}
- GOD(GOD_MANWE)
+ if (p_ptr->pgod == GOD_MANWE)
{
if (p_ptr->grace >= 2000) (*f3) |= TR3_FEATHER;
- PRAY_GOD(GOD_MANWE)
+ if (p_ptr->praying)
{
if (p_ptr->grace >= 7000) (*f2) |= TR2_FREE_ACT;
if (p_ptr->grace >= 15000) (*f4) |= TR4_FLY;
@@ -1618,13 +1618,13 @@ void player_flags(u32b *f1, u32b *f2, u32b *f3, u32b *f4, u32b *f5, u32b *esp)
}
}
- GOD(GOD_TULKAS)
+ if (p_ptr->pgod == GOD_TULKAS)
{
if (p_ptr->grace > 5000) (*f1) |= TR1_CON;
if (p_ptr->grace > 10000) (*f1) |= TR1_STR;
}
- GOD(GOD_AULE)
+ if (p_ptr->pgod == GOD_AULE)
{
if (p_ptr->grace > 5000)
{
@@ -1632,7 +1632,7 @@ void player_flags(u32b *f1, u32b *f2, u32b *f3, u32b *f4, u32b *f5, u32b *esp)
}
}
- GOD(GOD_MANDOS)
+ if (p_ptr->pgod == GOD_MANDOS)
{
(*f2) |= TR2_RES_NETHER;
@@ -1649,7 +1649,7 @@ void player_flags(u32b *f1, u32b *f2, u32b *f3, u32b *f4, u32b *f5, u32b *esp)
}
}
- GOD(GOD_ULMO)
+ if (p_ptr->pgod == GOD_ULMO)
{
(*f5) |= TR5_WATER_BREATH;
diff --git a/src/gods.cc b/src/gods.cc
index be877905..abb10c13 100644
--- a/src/gods.cc
+++ b/src/gods.cc
@@ -93,7 +93,7 @@ void follow_god(int god, bool_ silent)
p_ptr->pgod = god;
/* Melkor offer Udun magic */
- GOD(GOD_MELKOR)
+ if (p_ptr->pgod == GOD_MELKOR)
{
s_info[SKILL_UDUN].hidden = FALSE;
if (!silent) msg_print("You feel the dark powers of Melkor in you. You can now use the Udun skill.");
@@ -203,3 +203,8 @@ int find_god(cptr name)
}
return -1;
}
+
+bool praying_to(int god)
+{
+ return (p_ptr->pgod == god) && p_ptr->praying;
+}
diff --git a/src/gods.hpp b/src/gods.hpp
index 7fcf55cc..a7d60822 100644
--- a/src/gods.hpp
+++ b/src/gods.hpp
@@ -10,3 +10,4 @@ extern void follow_god(int god, bool_ silent);
extern bool_ god_enabled(struct deity_type *deity);
extern deity_type *god_at(byte god_idx);
extern bool_ show_god_info();
+extern bool praying_to(int god);
diff --git a/src/melee1.cc b/src/melee1.cc
index 58f41903..5e3dba82 100644
--- a/src/melee1.cc
+++ b/src/melee1.cc
@@ -11,6 +11,7 @@
#include "angband.h"
#include "cave.hpp"
#include "cmd5.hpp"
+#include "gods.hpp"
#include "mimic.hpp"
#include "monster2.hpp"
#include "monster3.hpp"
@@ -1552,7 +1553,7 @@ bool_ make_attack_normal(int m_idx, byte divis)
}
/* Eru can help you */
- PRAY_GOD(GOD_ERU)
+ if (praying_to(GOD_ERU))
{
s32b chance = p_ptr->grace;
diff --git a/src/q_one.cc b/src/q_one.cc
index da016ce1..8f1d16bf 100644
--- a/src/q_one.cc
+++ b/src/q_one.cc
@@ -34,22 +34,22 @@ static bool_ quest_one_move_hook(void *, void *in_, void *)
cmsg_print(TERM_YELLOW, "'and destroy it. I know it will tempt you, but *NEVER* use it'");
cmsg_print(TERM_YELLOW, "'or it will corrupt you forever.'");
- GOD(GOD_ERU)
+ if (p_ptr->pgod == GOD_ERU)
{
cmsg_print(TERM_YELLOW, "'Also, Eru will abandon you if you wear it.'");
}
- GOD(GOD_MANWE)
+ if (p_ptr->pgod == GOD_MANWE)
{
cmsg_print(TERM_YELLOW, "'Also, Manwe will abandon you if you wear it.'");
}
- GOD(GOD_TULKAS)
+ if (p_ptr->pgod == GOD_TULKAS)
{
cmsg_print(TERM_YELLOW, "'Also, Tulkas will abandon you if you wear it.'");
}
- GOD(GOD_YAVANNA)
+ if (p_ptr->pgod == GOD_YAVANNA)
{
cmsg_print(TERM_YELLOW, "'Also, Yavanna will abandon you if you wear it.'");
}
@@ -61,7 +61,7 @@ static bool_ quest_one_move_hook(void *, void *in_, void *)
cmsg_print(TERM_YELLOW, "'are other people that might know.'");
cmsg_print(TERM_YELLOW, "'Do not forget: the Ring must be cast back into the fires of Mount Doom!'");
- GOD(GOD_MELKOR)
+ if (p_ptr->pgod == GOD_MELKOR)
{
cmsg_print(TERM_YELLOW, "'Melkor will abandon you when you do, but you must do it anyway!'");
}
diff --git a/src/q_spider.cc b/src/q_spider.cc
index e838414d..0571ebc6 100644
--- a/src/q_spider.cc
+++ b/src/q_spider.cc
@@ -64,7 +64,7 @@ static bool_ quest_spider_death_hook(void *, void *, void *)
cmsg_print(TERM_YELLOW, "The forest is now safer, thanks to you.");
/* Yavanna LOVES saving forests */
- GOD(GOD_YAVANNA)
+ if (p_ptr->pgod == GOD_YAVANNA)
{
cmsg_print(TERM_L_GREEN, "You feel the gentle touch of Yavanna, as she smiles at you.");
inc_piety(GOD_YAVANNA, 6000);
diff --git a/src/skills.cc b/src/skills.cc
index c6d609c0..5b93ce2e 100644
--- a/src/skills.cc
+++ b/src/skills.cc
@@ -1170,7 +1170,7 @@ bool_ forbid_gloves()
/* Which gods forbid edged weapons */
bool_ forbid_non_blessed()
{
- GOD(GOD_ERU) return (TRUE);
+ if (p_ptr->pgod == GOD_ERU) return (TRUE);
return (FALSE);
}
diff --git a/src/spells1.cc b/src/spells1.cc
index dbbf4e24..084fd6bf 100644
--- a/src/spells1.cc
+++ b/src/spells1.cc
@@ -1524,7 +1524,7 @@ void take_hit(int damage, cptr hit_from)
/* Melkor acn summon to help you */
if (percent < 25)
{
- PRAY_GOD(GOD_MELKOR)
+ if (praying_to(GOD_MELKOR))
{
int chance = p_ptr->grace / 500; /* * 100 / 50000; */
diff --git a/src/xtra1.cc b/src/xtra1.cc
index 80638d9e..1dfa0566 100644
--- a/src/xtra1.cc
+++ b/src/xtra1.cc
@@ -1664,7 +1664,7 @@ static void calc_mana(void)
msp += msp * cp_ptr->mana / 100;
/* Apply Eru mana */
- GOD(GOD_ERU)
+ if (p_ptr->pgod == GOD_ERU)
{
s32b tmp = p_ptr->grace;
@@ -1831,7 +1831,7 @@ void calc_hitpoints(void)
}
/* Factor in the melkor hp modifications */
- GOD(GOD_MELKOR)
+ if (p_ptr->pgod == GOD_MELKOR)
{
mhp -= (p_ptr->melkor_sacrifice * 10);
if (mhp < 1) mhp = 1;
@@ -2322,7 +2322,7 @@ int get_archery_skill()
static void calc_gods()
{
/* Boost WIS if the player follows Eru */
- GOD(GOD_ERU)
+ if (p_ptr->pgod == GOD_ERU)
{
if (p_ptr->grace > 10000) p_ptr->stat_add[A_WIS] += 1;
if (p_ptr->grace > 20000) p_ptr->stat_add[A_WIS] += 1;
@@ -2330,7 +2330,7 @@ static void calc_gods()
}
/* Boost str, con, chr and reduce int, wis if the player follows Melkor */
- GOD(GOD_MELKOR)
+ if (p_ptr->pgod == GOD_MELKOR)
{
if (p_ptr->grace > 10000) p_ptr->stat_add[A_STR] += 1;
if (p_ptr->grace > 20000) p_ptr->stat_add[A_STR] += 1;
@@ -2352,7 +2352,7 @@ static void calc_gods()
if (p_ptr->grace > 20000) p_ptr->stat_add[A_WIS] -= 1;
if (p_ptr->grace > 30000) p_ptr->stat_add[A_WIS] -= 1;
- PRAY_GOD(GOD_MELKOR)
+ if (praying_to(GOD_MELKOR))
{
if (p_ptr->grace > 5000) p_ptr->invis += 30;
if (p_ptr->grace > 15000) p_ptr->immune_fire = TRUE;
@@ -2361,7 +2361,7 @@ static void calc_gods()
}
/* Gifts of Manwe if the player is praying to Manwe */
- PRAY_GOD(GOD_MANWE)
+ if (praying_to(GOD_MANWE))
{
s32b add = p_ptr->grace;
@@ -2376,13 +2376,13 @@ static void calc_gods()
}
/* Manwe bonus not requiring the praying status */
- GOD(GOD_MANWE)
+ if (p_ptr->pgod == GOD_MANWE)
{
if (p_ptr->grace >= 2000) p_ptr->ffall = TRUE;
}
/* Boost Str and Con if the player is following Tulkas */
- GOD(GOD_TULKAS)
+ if (p_ptr->pgod == GOD_TULKAS)
{
if (p_ptr->grace > 5000) p_ptr->stat_add[A_CON] += 1;
if (p_ptr->grace > 10000) p_ptr->stat_add[A_CON] += 1;
@@ -2394,7 +2394,7 @@ static void calc_gods()
}
/* Aule provides to-hit/damage bonuses and fire resistance */
- GOD(GOD_AULE)
+ if (p_ptr->pgod == GOD_AULE)
{
if (p_ptr->grace > 0)
{
@@ -2420,7 +2420,7 @@ static void calc_gods()
/* Mandos provides nether resistance and, while praying,
nether immunity and prevents teleportation. */
- GOD(GOD_MANDOS)
+ if (p_ptr->pgod == GOD_MANDOS)
{
p_ptr->resist_neth = TRUE;
@@ -2439,7 +2439,7 @@ static void calc_gods()
/* Ulmo provides water breath and, while praying can
provide poison resistance and magic breath. */
- GOD(GOD_ULMO)
+ if (p_ptr->pgod == GOD_ULMO)
{
p_ptr->water_breath = TRUE;
@@ -3243,7 +3243,7 @@ void calc_bonuses(bool_ silent)
}
/* Provide the damage we get from sacrifice */
- GOD(GOD_MELKOR)
+ if (p_ptr->pgod == GOD_MELKOR)
{
int x = wisdom_scale(4);
if (x < 1) x = 1;
diff --git a/src/xtra2.cc b/src/xtra2.cc
index 07747a32..80179045 100644
--- a/src/xtra2.cc
+++ b/src/xtra2.cc
@@ -3254,35 +3254,38 @@ bool_ mon_take_hit(int m_idx, int dam, bool_ *fear, cptr note)
/* Manwe appreciate evil monster death */
if (r_ptr->flags3 & RF3_EVIL)
{
- int inc = m_ptr->level / 2;
+ int inc = std::max(1, m_ptr->level / 2);
- if (!inc) inc = 1;
- PRAY_GOD(GOD_MANWE) inc_piety(GOD_MANWE, inc);
+ if (praying_to(GOD_MANWE))
+ {
+ inc_piety(GOD_MANWE, inc);
+ }
+
+ inc = std::max(2, inc);
- if (inc < 2) inc = 2;
inc_piety(GOD_TULKAS, inc / 2);
- PRAY_GOD(GOD_TULKAS)
+
+ if (praying_to(GOD_TULKAS))
{
inc_piety(GOD_TULKAS, inc / 2);
- if (r_ptr->flags3 & RF3_DEMON) inc_piety(GOD_TULKAS, inc);
+ if (r_ptr->flags3 & RF3_DEMON)
+ {
+ inc_piety(GOD_TULKAS, inc);
+ }
}
}
/* Yavanna likes when corruption is destroyed */
if ((r_ptr->flags3 & RF3_NONLIVING) || (r_ptr->flags3 & RF3_DEMON) || (r_ptr->flags3 & RF3_UNDEAD))
{
- int inc = m_ptr->level / 2;
-
- if (!inc) inc = 1;
+ int inc = std::max(1, m_ptr->level / 2);
inc_piety(GOD_YAVANNA, inc);
}
/* Yavanna doesnt like any killing in her name */
- PRAY_GOD(GOD_YAVANNA)
+ if (praying_to(GOD_YAVANNA))
{
- int inc = m_ptr->level / 2;
-
- if (!inc) inc = 1;
+ int inc = std::max(1, m_ptr->level / 2);
inc_piety(GOD_YAVANNA, -inc);
/* Killing animals in her name is a VERY bad idea */