summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/birth.c15
-rw-r--r--src/defines.h6
-rw-r--r--src/externs.h10
-rw-r--r--src/gods.c29
-rw-r--r--src/init2.c26
-rw-r--r--src/lua_bind.c23
-rw-r--r--src/player.pkg63
-rw-r--r--src/tables.c72
-rw-r--r--src/types.h1
-rw-r--r--src/variable.c10
10 files changed, 115 insertions, 140 deletions
diff --git a/src/birth.c b/src/birth.c
index 243f080e..274b50bf 100644
--- a/src/birth.c
+++ b/src/birth.c
@@ -2331,16 +2331,17 @@ static bool_ player_birth_aux_ask()
}
else
{
- int *choice;
+ int choice[MAX_GODS];
int max = 0;
- C_MAKE(choice, max_gods, int);
-
/* Get the list of possible gods */
- for (n = 0; n < max_gods; n++)
+ for (n = 0; n < MAX_GODS; n++)
{
- if ((cp_ptr->gods | spp_ptr->gods) & BIT(n))
+ if (god_enabled(&deity_info[n]) &&
+ ((cp_ptr->gods | spp_ptr->gods) & BIT(n)))
+ {
choice[max++] = n;
+ }
}
if (!max)
@@ -2368,8 +2369,6 @@ static bool_ player_birth_aux_ask()
if (c == 'Q') quit(NULL);
if (c == 'S')
{
- C_FREE(choice, max_gods, int);
-
return (FALSE);
}
if (c == '*')
@@ -2424,8 +2423,6 @@ static bool_ player_birth_aux_ask()
else bell();
}
- C_FREE(choice, max_gods, int);
-
/* Set god */
p_ptr->pgod = k;
p_ptr->grace = 0;
diff --git a/src/defines.h b/src/defines.h
index 92d7fa10..c93abb73 100644
--- a/src/defines.h
+++ b/src/defines.h
@@ -4698,7 +4698,11 @@
#define GOD_TULKAS 3
#define GOD_MELKOR 4
#define GOD_YAVANNA 5
-#define MAX_GODS_INIT 6
+#define GOD_AULE 6
+#define GOD_VARDA 7
+#define GOD_ULMO 8
+#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))
diff --git a/src/externs.h b/src/externs.h
index 6c13aa27..cfb07bbd 100644
--- a/src/externs.h
+++ b/src/externs.h
@@ -60,7 +60,6 @@ extern s16b arena_monsters[MAX_ARENA_MONS];
extern byte extract_energy[300];
extern s32b player_exp[PY_MAX_LEVEL];
extern player_sex sex_info[MAX_SEXES];
-extern deity_type deity_info_init[MAX_GODS_INIT];
extern cptr color_names[16];
extern cptr stat_names[6];
extern cptr stat_names_reduced[6];
@@ -593,12 +592,7 @@ extern s32b DUNGEON_DEATH;
extern s32b DUNGEON_ASTRAL;
extern s32b DUNGEON_ASTRAL_WILD_X;
extern s32b DUNGEON_ASTRAL_WILD_Y;
-extern deity_type *deity_info;
-extern s32b max_gods;
-extern s32b GOD_AULE;
-extern s32b GOD_VARDA;
-extern s32b GOD_ULMO;
-extern s32b GOD_MANDOS;
+extern deity_type deity_info[MAX_GODS];
extern timer_type *gl_timers;
extern s16b tim_precognition;
extern const char *get_version_string();
@@ -1796,7 +1790,6 @@ extern bool_ summon_lua_okay(int r_idx);
extern bool_ lua_summon_monster(int y, int x, int lev, bool_ ffriend, char *fct);
extern s16b add_new_gods(char *name);
-extern void desc_god(int g_idx, int d, char *desc);
extern int get_lua_int(cptr name);
extern bool_ get_com_lua(cptr promtp, int *com);
@@ -1871,3 +1864,4 @@ extern void abandon_god(int god);
extern int wisdom_scale(int max);
extern int find_god(cptr name);
extern void follow_god(int god, bool_ silent);
+extern bool_ god_enabled(struct deity_type *deity);
diff --git a/src/gods.c b/src/gods.c
index b8b8fd3a..56b1380b 100644
--- a/src/gods.c
+++ b/src/gods.c
@@ -125,15 +125,38 @@ int wisdom_scale(int max)
return (i * max) / 37;
}
+/*
+ * 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++)
+ for (i = 0; i < MAX_GODS; i++)
{
- /* The name matches */
- if (streq(deity_info[i].name, name)) return (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;
}
diff --git a/src/init2.c b/src/init2.c
index 1f6e66e6..71e7bc2b 100644
--- a/src/init2.c
+++ b/src/init2.c
@@ -1959,13 +1959,6 @@ static errr init_misc(void)
/* Hack -- No messages yet */
message__tail = MESSAGE_BUF;
- /* Prepare gods */
- deity_info = NULL;
- max_gods = MAX_GODS_INIT;
- reinit_gods(max_gods);
-
- C_COPY(deity_info, deity_info_init, MAX_GODS_INIT, deity_type);
-
/* Prepare schools */
max_spells = 0;
max_schools = 0;
@@ -2066,25 +2059,6 @@ static errr init_wilderness(void)
return 0;
}
-void reinit_gods(s16b new_size)
-{
- deity_type *new_deity;
-
- C_MAKE(new_deity, new_size, deity_type);
-
- /* Reallocate the extra memory */
- if (deity_info)
- {
- C_COPY(new_deity, deity_info, max_gods, deity_type);
-
- C_FREE(deity_info, max_gods, deity_type);
- }
-
- deity_info = new_deity;
-
- max_gods = new_size;
-}
-
void init_spells(s16b new_size)
{
/* allocate the extra memory */
diff --git a/src/lua_bind.c b/src/lua_bind.c
index ff6680be..fd7d9cbb 100644
--- a/src/lua_bind.c
+++ b/src/lua_bind.c
@@ -537,29 +537,6 @@ void lua_display_list(int y, int x, int h, int w, cptr title, list_type* list, i
-/*
- * Gods
- */
-s16b add_new_gods(char *name)
-{
- int i;
-
- /* Increase the size */
- reinit_gods(max_gods + 1);
- deity_info[max_gods - 1].name = string_make(name);
-
- for (i = 0; i < 10; i++)
- strncpy(deity_info[max_gods - 1].desc[i], "", 39);
-
- return (max_gods - 1);
-}
-
-void desc_god(int g_idx, int d, char *desc)
-{
- if (d >= 0 && d < 10)
- strncpy(deity_info[g_idx].desc[d], desc, 79);
-}
-
int get_lua_int(cptr name)
{
return exec_lua(format("return %s", name));
diff --git a/src/player.pkg b/src/player.pkg
index e9649729..459ade67 100644
--- a/src/player.pkg
+++ b/src/player.pkg
@@ -475,21 +475,6 @@ extern s32b player_exp[PY_MAX_LEVEL];
#define PW_BORG_2 0x00008000L
/** @} */
-/** @struct deity_type
- */
-struct deity_type
-{
- /** @structvar name
- * @brief String
- */
- cptr name;
-};
-/** @var deity_info[max_gods]
- * @brief deity_type
- * @note Array of gods.
- */
-extern deity_type deity_info[max_gods];
-
/** @name Body parts
* @{ */
/** @def BODY_WEAPON */
@@ -3098,10 +3083,10 @@ extern s16b dun_level;
#define GOD_YAVANNA 5
/** @} */
-extern s32b GOD_AULE;
-extern s32b GOD_VARDA;
-extern s32b GOD_ULMO;
-extern s32b GOD_MANDOS;
+#define GOD_AULE 6
+#define GOD_VARDA 7
+#define GOD_ULMO 8
+#define GOD_MANDOS 9
/** @fn inc_piety(int god, s32b amt)
@@ -3136,46 +3121,6 @@ extern void abandon_god(int god);
*/
extern int wisdom_scale(int max);
-/** @fn follow_god(int god, bool silent)
- * @brief Player starts to follow god "god".\n
- * @param god Number \n the god
- * @brief God
- * @param silent Boolean \n TRUE if Melkor message is displayed, otherwise
- * FALSE.
- * @brief Show message?
- * @note
- * Unbelievers can not follow a god.
- * @note
- * If the player does not worship a god, they start worshipping "god". If the
- * god is Melkor, the player gains the Udun skill (show a message if silent is
- * FALSE).
- * @note (see file gods.c)
- */
-extern void follow_god(int god, bool silent);
-
-/** @fn add_new_gods(char *name)
- * @brief Add a new god to the deity array.\n
- * @param *name String \n the name of the god
- * @brief God name
- * @return Number \n The index of the new god inthe deity array.
- * @note (see file lua_bind.c)
- */
-extern s16b add_new_gods(char *name);
-
-/** @fn desc_god(int g_idx, int d, char *desc)
- * @brief Return line "d" of the description of god with god index "g_idx".\n
- * @param g_idx Number \n the index of god in the deity array.
- * @brief God index
- * @param d Number \n the line of the description
- * (must be in the range 0 to 9).
- * @brief Line of description
- * @param *desc String
- * @brief Description
- * @return *desc String \n Line "d" of the god description.
- * @note (see file lua_bind.c)
- */
-extern void desc_god(int g_idx, int d, char *desc);
-
/** @name Powers
* @{ */
/** @def PWR_SPIT_ACID
diff --git a/src/tables.c b/src/tables.c
index c5a22204..281395e0 100644
--- a/src/tables.c
+++ b/src/tables.c
@@ -2739,9 +2739,10 @@ cptr deity_standing[11] =
* Only the first four lines are printed at birth.
*/
-deity_type deity_info_init[MAX_GODS_INIT] =
+deity_type deity_info[MAX_GODS] =
{
{
+ { MODULE_TOME, MODULE_THEME, -1, },
"Nobody",
{
"Atheist",
@@ -2757,6 +2758,7 @@ deity_type deity_info_init[MAX_GODS_INIT] =
},
},
{
+ { MODULE_TOME, MODULE_THEME, -1, },
"Eru Iluvatar",
{
"He is the supreme god, he created the world, and most of its inhabitants.",
@@ -2772,6 +2774,7 @@ deity_type deity_info_init[MAX_GODS_INIT] =
},
},
{
+ { MODULE_TOME, MODULE_THEME, -1, },
"Manwe Sulimo",
{
"He is the king of the Valar, most powerful of them after Melkor.",
@@ -2787,6 +2790,7 @@ deity_type deity_info_init[MAX_GODS_INIT] =
},
},
{
+ { MODULE_TOME, MODULE_THEME, -1, },
"Tulkas",
{
"He is the last of the Valar that came to the world, and the fiercest fighter.",
@@ -2802,6 +2806,7 @@ deity_type deity_info_init[MAX_GODS_INIT] =
},
},
{
+ { MODULE_TOME, MODULE_THEME, -1, },
"Melkor Bauglir",
{
"He is the most powerful of the Valar. He became corrupted and he's now ",
@@ -2817,6 +2822,7 @@ deity_type deity_info_init[MAX_GODS_INIT] =
},
},
{
+ { MODULE_TOME, MODULE_THEME, -1, },
"Yavanna Kementari",
{
"She is the Vala of nature, protectress of the great forests of "
@@ -2832,6 +2838,70 @@ deity_type deity_info_init[MAX_GODS_INIT] =
"",
},
},
+ {
+ { MODULE_THEME, -1, },
+ "Aule the Smith",
+ {
+ "Aule is a smith, and the creator of the Dwarves.",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ },
+ },
+ {
+ { MODULE_THEME, -1, },
+ "Varda Elentari",
+ {
+ "The Queen of the Stars. In light is her power and joy.",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ },
+ },
+ {
+ { MODULE_THEME, -1, },
+ "Ulmo",
+ {
+ "Ulmo is called Lord of Waters, he rules all that is water"
+ "on Arda.",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ },
+ },
+ {
+ { MODULE_THEME, -1, },
+ "Mandos",
+ {
+ "The Doomsman of the Valar and keeper of the slain.",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ },
+ },
};
/* jk - to hit, to dam, to ac, to stealth, to disarm, to saving throw */
diff --git a/src/types.h b/src/types.h
index fc4f7356..efefc93a 100644
--- a/src/types.h
+++ b/src/types.h
@@ -1987,6 +1987,7 @@ struct artifact_select_flag {
typedef struct deity_type deity_type;
struct deity_type
{
+ int modules[3]; /* terminated with -1 */
cptr name;
char desc[10][80];
};
diff --git a/src/variable.c b/src/variable.c
index c09d9720..11019a22 100644
--- a/src/variable.c
+++ b/src/variable.c
@@ -1570,16 +1570,6 @@ s32b DUNGEON_ASTRAL_WILD_X = 45;
s32b DUNGEON_ASTRAL_WILD_Y = 19;
/*
- * Gods
- */
-deity_type *deity_info;
-s32b max_gods = MAX_GODS_INIT;
-s32b GOD_AULE = -99;
-s32b GOD_VARDA = -99;
-s32b GOD_ULMO = -99;
-s32b GOD_MANDOS = -99;
-
-/*
* Timers
*/
timer_type *gl_timers = NULL;