diff options
author | Bardur Arantsson <bardur@scientician.net> | 2012-05-28 06:38:12 +0200 |
---|---|---|
committer | Bardur Arantsson <bardur@scientician.net> | 2012-05-29 05:38:15 +0200 |
commit | e272282c1451329d16fd16efbfccc234395cba6e (patch) | |
tree | 9fc6c55bbd318ce8f78ef702e0bb82d5e08a9eb7 /src/spells4.c | |
parent | 7d052a1a4b8ff944a649c4afdd277aeb30b42cb0 (diff) |
Lua: Add "school_idx" type to hold list of spell schools
Diffstat (limited to 'src/spells4.c')
-rw-r--r-- | src/spells4.c | 33 |
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]; |