summaryrefslogtreecommitdiff
path: root/src/spells4.c
diff options
context:
space:
mode:
authorBardur Arantsson <bardur@scientician.net>2012-05-28 06:38:12 +0200
committerBardur Arantsson <bardur@scientician.net>2012-05-29 05:38:15 +0200
commite272282c1451329d16fd16efbfccc234395cba6e (patch)
tree9fc6c55bbd318ce8f78ef702e0bb82d5e08a9eb7 /src/spells4.c
parent7d052a1a4b8ff944a649c4afdd277aeb30b42cb0 (diff)
Lua: Add "school_idx" type to hold list of spell schools
Diffstat (limited to 'src/spells4.c')
-rw-r--r--src/spells4.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/spells4.c b/src/spells4.c
index e270c464..900121fc 100644
--- a/src/spells4.c
+++ b/src/spells4.c
@@ -37,6 +37,39 @@ static int compare_spell_idx(spell_idx_list *a, spell_idx_list *b)
SGLIB_DEFINE_LIST_FUNCTIONS(spell_idx_list, compare_spell_idx, next);
+static int compare_school_idx(school_idx *a, school_idx *b)
+{
+ return SGLIB_NUMERIC_COMPARATOR(a->i, b->i);
+}
+
+SGLIB_DEFINE_LIST_FUNCTIONS(school_idx, compare_school_idx, next);
+
+void school_idx_init(school_idx *e, s32b i)
+{
+ assert(e != NULL);
+
+ e->i = i;
+ e->next = NULL;
+}
+
+school_idx *school_idx_new(s32b i)
+{
+ school_idx *e = malloc(sizeof(school_idx));
+ assert(e != NULL);
+
+ school_idx_init(e, i);
+
+ return e;
+}
+
+void school_idx_add_new(school_idx **list, s32b i)
+{
+ school_idx *e = school_idx_new(i);
+ assert(e != NULL);
+
+ sglib_school_idx_add(list, e);
+}
+
static bool_ uses_piety_to_cast(int s)
{
char buf[128];