diff options
-rw-r--r-- | src/externs.h | 5 | ||||
-rw-r--r-- | src/spells4.c | 33 | ||||
-rw-r--r-- | src/types.h | 10 |
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; |