summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBardur Arantsson <bardur@scientician.net>2012-05-30 07:03:38 +0200
committerBardur Arantsson <bardur@scientician.net>2012-05-30 07:06:04 +0200
commitfbc40366c8a50a695fcb913c5f25d717330e9672 (patch)
treeb5b2b8d508ce70c6bb4b0c6ce58bb0be77bf275f /src
parent77fcd7e02c87167002b8294a47c6cc37a0c960b3 (diff)
Lua: Add god_at() for safe indexing of deity_info
Diffstat (limited to 'src')
-rw-r--r--src/externs.h1
-rw-r--r--src/gods.c17
2 files changed, 18 insertions, 0 deletions
diff --git a/src/externs.h b/src/externs.h
index e584b44c..8f55d3d8 100644
--- a/src/externs.h
+++ b/src/externs.h
@@ -2447,3 +2447,4 @@ 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);
+extern deity_type *god_at(byte god_idx);
diff --git a/src/gods.c b/src/gods.c
index 170f56b3..f940e21a 100644
--- a/src/gods.c
+++ b/src/gods.c
@@ -147,6 +147,23 @@ int wisdom_scale(int max)
}
/*
+ * 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)