From cbef37bd5bfb938a2303ee3887520c08be85d8e8 Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Tue, 26 Mar 2013 17:10:10 +0100 Subject: Switch almost everything over to C++ --- src/gods.cc | 200 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 200 insertions(+) create mode 100644 src/gods.cc (limited to 'src/gods.cc') diff --git a/src/gods.cc b/src/gods.cc new file mode 100644 index 00000000..f940e21a --- /dev/null +++ b/src/gods.cc @@ -0,0 +1,200 @@ +/* File: gods.c */ + +/* Purpose: Deities code */ + +/* + * Copyright (c) 2002 DarkGod + * + * This software may be copied and distributed for educational, research, and + * not for profit purposes provided that this copyright and statement are + * included in all such copies. + */ + +#include "angband.h" + +/* + * Add amt piety is god is god + */ +void inc_piety(int god, s32b amt) +{ + s32b old = p_ptr->grace; + + if ((god == GOD_ALL) || (god == p_ptr->pgod)) + { + set_grace(p_ptr->grace + amt); + + if(amt > 0 && p_ptr->grace <= old) + set_grace(300000); + + if(amt < 0 && p_ptr->grace >= old) + set_grace(-300000); + } +} + +/* + * Renounce to religion + */ +void abandon_god(int god) +{ + if ((god == GOD_ALL) || (god == p_ptr->pgod)) + { + p_ptr->pgod = GOD_NONE; + set_grace(0); + } +} + +/* + * Check if god may be followed by player + */ +static bool_ may_follow_god(int god) +{ + if (god == GOD_MELKOR) + { + int i; + + /* Check if player has wielded The One Ring */ + for (i = INVEN_WIELD; i < INVEN_TOTAL; i++) + { + if (p_ptr->inventory[i].name1 == ART_POWER) + { + msg_print("The One Ring has corrupted " + "you, and you are rejected."); + return FALSE; + } + } + } + /* Default is to allow */ + return TRUE; +} + +/* + * Get a religion + */ +void follow_god(int god, bool_ silent) +{ + /* Poor unbelievers, i'm so mean ... BOUHAHAHA */ + if (get_skill(SKILL_ANTIMAGIC)) + { + msg_print("Don't be silly; you don't believe in gods."); + return; + } + + /* Are we allowed ? */ + if (!may_follow_god(god)) + return; + + if (p_ptr->pgod == GOD_NONE) + { + p_ptr->pgod = god; + + /* Melkor offer Udun magic */ + GOD(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."); + } + } +} + +/* + * Show religious info. + */ +bool_ show_god_info(bool_ ext) +{ + int pgod = p_ptr->pgod; + + deity_type *d_ptr; + + if (pgod < 0) + { + msg_print("You don't worship anyone."); + msg_print(NULL); + return FALSE; + } + else + { + int i; + + d_ptr = &deity_info[pgod]; + + msg_print(NULL); + + character_icky = TRUE; + Term_save(); + + text_out(format("You worship %s. ", d_ptr->name)); + for (i = 0; (i < 10) && (strcmp(d_ptr->desc[i], "")); i++) + text_out(d_ptr->desc[i]); + text_out("\n"); + + inkey(); + + Term_load(); + character_icky = FALSE; + } + + return TRUE; +} + +/* + * Rescale the wisdom value to a 0 <-> max range + */ +int wisdom_scale(int max) +{ + int i = p_ptr->stat_ind[A_WIS]; + + return (i * max) / 37; +} + +/* + * Get deity info for a given god index. + * Returns NULL for the "atheist" god. + */ +deity_type *god_at(byte god_idx) +{ + assert(god_idx >= 0); + assert(god_idx < MAX_GODS); + + if (god_idx == 0) + { + return NULL; + } + + return &deity_info[god_idx]; +} + +/* + * Check if god is enabled for the current module + */ +bool_ god_enabled(struct deity_type *deity) +{ + int i; + + for (i = 0; deity->modules[i] != -1; i++) + { + if (deity->modules[i] == game_module_idx) + { + return TRUE; + } + } + /* Not enabled */ + return FALSE; +} + +/* Find a god by name */ +int find_god(cptr name) +{ + int i; + + for (i = 0; i < MAX_GODS; i++) + { + /* The name matches and god is "enabled" for the + current module. */ + if (god_enabled(&deity_info[i]) && + streq(deity_info[i].name, name)) + { + return (i); + } + } + return -1; +} -- cgit v1.2.3 From 76d1d3f63fef965ba0a2d5ccea3408ad36e9ce4c Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Thu, 18 Dec 2014 00:00:35 +0100 Subject: Remove all uses of sglib --- src/gods.cc | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/gods.cc') diff --git a/src/gods.cc b/src/gods.cc index f940e21a..9fdbfeb5 100644 --- a/src/gods.cc +++ b/src/gods.cc @@ -12,6 +12,8 @@ #include "angband.h" +#include + /* * Add amt piety is god is god */ -- cgit v1.2.3 From ee2595abc99b86f081acbf5479577f9548baff3b Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Mon, 23 Feb 2015 09:11:59 +0100 Subject: Move gods.cc function declarations to separate header --- src/gods.cc | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'src/gods.cc') diff --git a/src/gods.cc b/src/gods.cc index 9fdbfeb5..92861d79 100644 --- a/src/gods.cc +++ b/src/gods.cc @@ -1,7 +1,3 @@ -/* File: gods.c */ - -/* Purpose: Deities code */ - /* * Copyright (c) 2002 DarkGod * @@ -9,7 +5,7 @@ * not for profit purposes provided that this copyright and statement are * included in all such copies. */ - +#include "gods.hpp" #include "angband.h" #include -- cgit v1.2.3 From dc4b789acb2e6737dd6ed5721b3efbde1a2be14f Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Mon, 23 Feb 2015 09:11:59 +0100 Subject: Move skills.cc function declarations to skills.hpp --- src/gods.cc | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/gods.cc') diff --git a/src/gods.cc b/src/gods.cc index 92861d79..ea23f3fb 100644 --- a/src/gods.cc +++ b/src/gods.cc @@ -6,7 +6,9 @@ * included in all such copies. */ #include "gods.hpp" + #include "angband.h" +#include "skills.hpp" #include -- cgit v1.2.3 From 5ef53fee463b7f93b8b890ed8e6ff0db778bd596 Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Mon, 23 Feb 2015 09:11:59 +0100 Subject: Move xtra2.cc functions to separate header Remove some functions and make others static while we're at it. --- src/gods.cc | 1 + 1 file changed, 1 insertion(+) (limited to 'src/gods.cc') diff --git a/src/gods.cc b/src/gods.cc index ea23f3fb..d810846a 100644 --- a/src/gods.cc +++ b/src/gods.cc @@ -9,6 +9,7 @@ #include "angband.h" #include "skills.hpp" +#include "xtra2.hpp" #include -- cgit v1.2.3 From 4ad730223cc0f2661126b51dd0ac012d48b2b10f Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Mon, 23 Feb 2015 09:11:59 +0100 Subject: Move show_god_info() declaration to its proper location Remove unused parameter while we're at it. --- src/gods.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gods.cc') diff --git a/src/gods.cc b/src/gods.cc index d810846a..0c3297ed 100644 --- a/src/gods.cc +++ b/src/gods.cc @@ -100,7 +100,7 @@ void follow_god(int god, bool_ silent) /* * Show religious info. */ -bool_ show_god_info(bool_ ext) +bool_ show_god_info() { int pgod = p_ptr->pgod; -- cgit v1.2.3 From 37ac44add61e4547507770017dcb85b53c20acb5 Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Mon, 23 Feb 2015 09:12:01 +0100 Subject: Split util.cc function declarations into separate header files We need one .h file and one .hpp since some of the functions are being called from plain C code. --- src/gods.cc | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/gods.cc') diff --git a/src/gods.cc b/src/gods.cc index 0c3297ed..83fd3aae 100644 --- a/src/gods.cc +++ b/src/gods.cc @@ -9,6 +9,8 @@ #include "angband.h" #include "skills.hpp" +#include "util.hpp" +#include "util.h" #include "xtra2.hpp" #include -- cgit v1.2.3 From 6f612c6e6cf9b20c00fd2f515d3694d2b7f7f444 Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Sat, 7 Mar 2015 16:55:42 +0100 Subject: Split variables.cc declarations to separate header files - Can now remove externs.h. Yay! - Put a stray option variable into its rightful place in options.hpp --- src/gods.cc | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/gods.cc') diff --git a/src/gods.cc b/src/gods.cc index 83fd3aae..be877905 100644 --- a/src/gods.cc +++ b/src/gods.cc @@ -11,6 +11,8 @@ #include "skills.hpp" #include "util.hpp" #include "util.h" +#include "variable.h" +#include "variable.hpp" #include "xtra2.hpp" #include -- cgit v1.2.3 From b11197ae79d621c50d89f6a092a3f95f954712f0 Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Sun, 22 Mar 2015 13:05:39 +0100 Subject: Inline various GOD macros --- src/gods.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/gods.cc') 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; +} -- cgit v1.2.3 From c8a270e51dc22f39ed048ab1cc609e6e456df58f Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Sun, 7 Jun 2015 17:49:09 +0200 Subject: Split types.h into separate header for each type --- src/gods.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/gods.cc') diff --git a/src/gods.cc b/src/gods.cc index abb10c13..1163e9b6 100644 --- a/src/gods.cc +++ b/src/gods.cc @@ -7,8 +7,10 @@ */ #include "gods.hpp" -#include "angband.h" +#include "player_type.hpp" #include "skills.hpp" +#include "skill_type.hpp" +#include "stats.hpp" #include "util.hpp" #include "util.h" #include "variable.h" -- cgit v1.2.3 From 0cd5370d552babada63b59003e7629c180d4eeaa Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Sat, 17 Sep 2016 09:58:14 +0200 Subject: Change skill_type struct to use 'bool' --- src/gods.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/gods.cc') diff --git a/src/gods.cc b/src/gods.cc index 1163e9b6..f10209dc 100644 --- a/src/gods.cc +++ b/src/gods.cc @@ -97,8 +97,11 @@ void follow_god(int god, bool_ silent) /* Melkor offer Udun magic */ 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."); + 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."); + } } } } -- cgit v1.2.3 From 4fb8fb773d93efe1cdc812d1046c530c20098455 Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Sat, 17 Sep 2016 09:58:14 +0200 Subject: Remove dead code Fixes a few compiler warnings. --- src/gods.cc | 1 - 1 file changed, 1 deletion(-) (limited to 'src/gods.cc') diff --git a/src/gods.cc b/src/gods.cc index f10209dc..7da62d7a 100644 --- a/src/gods.cc +++ b/src/gods.cc @@ -162,7 +162,6 @@ int wisdom_scale(int max) */ deity_type *god_at(byte god_idx) { - assert(god_idx >= 0); assert(god_idx < MAX_GODS); if (god_idx == 0) -- cgit v1.2.3 From 765e1a3dc7abce3a849b8d1f124ada7a6984154a Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Wed, 5 Oct 2016 18:45:08 +0200 Subject: Move s_{info,descriptors} to Game/GameEdtiData --- src/gods.cc | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/gods.cc') diff --git a/src/gods.cc b/src/gods.cc index 7da62d7a..82d8d300 100644 --- a/src/gods.cc +++ b/src/gods.cc @@ -7,6 +7,7 @@ */ #include "gods.hpp" +#include "game.hpp" #include "player_type.hpp" #include "skills.hpp" #include "skill_type.hpp" @@ -79,6 +80,8 @@ static bool_ may_follow_god(int god) */ void follow_god(int god, bool_ silent) { + auto &s_info = game->s_info; + /* Poor unbelievers, i'm so mean ... BOUHAHAHA */ if (get_skill(SKILL_ANTIMAGIC)) { -- cgit v1.2.3