summaryrefslogtreecommitdiff
path: root/src
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
parent7d052a1a4b8ff944a649c4afdd277aeb30b42cb0 (diff)
Lua: Add "school_idx" type to hold list of spell schools
Diffstat (limited to 'src')
-rw-r--r--src/externs.h5
-rw-r--r--src/spells4.c33
-rw-r--r--src/types.h10
3 files changed, 48 insertions, 0 deletions
diff --git a/src/externs.h b/src/externs.h
index f3e5bc02..d2805f0c 100644
--- a/src/externs.h
+++ b/src/externs.h
@@ -1906,6 +1906,7 @@ char *varda_star_kindler_info();
/* spells4.c */
SGLIB_DEFINE_LIST_PROTOTYPES(spell_idx_list, compare_spell_idx, next);
+SGLIB_DEFINE_LIST_PROTOTYPES(school_idx, compare_school_idx, next);
extern s32b SCHOOL_AIR;
extern s32b SCHOOL_AULE;
@@ -1933,6 +1934,10 @@ extern s32b SCHOOL_VARDA;
extern s32b SCHOOL_WATER;
extern s32b SCHOOL_YAVANNA;
+void school_idx_init(school_idx *e, s32b i);
+school_idx *school_idx_new(s32b i);
+void school_idx_add_new(school_idx **list, s32b i);
+
void print_spell_desc(int s, int y);
void init_school_books();
school_book_type *school_books_at(int sval);
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];
diff --git a/src/types.h b/src/types.h
index 3c028d3a..fbf049ae 100644
--- a/src/types.h
+++ b/src/types.h
@@ -2504,6 +2504,16 @@ struct skill_type
/*
+ * School index list.
+ */
+typedef struct school_idx school_idx;
+struct school_idx {
+ s32b i; /* School index */
+ school_idx *next; /* for list */
+};
+
+
+/*
* Casting type
*/
typedef enum { USE_SPELL_POINTS, USE_PIETY } casting_type;