2 * nazghul - an old-school RPG engine
3 * Copyright (C) 2007 Gordon McNutt
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the Free
7 * Software Foundation; either version 2 of the License, or (at your option)
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 * You should have received a copy of the GNU General Public License along with
16 * this program; if not, write to the Free Foundation, Inc., 59 Temple Place,
17 * Suite 330, Boston, MA 02111-1307 USA
20 * gmcnutt@users.sourceforge.net
23 #include "skill_set.h"
24 #include "skill_set_entry.h"
34 static void skill_set_del(struct skill_set *skset)
38 assert(!skset->refcount);
44 list = skset->skills.next;
45 while (list != &skset->skills) {
46 struct skill_set_entry *ssent;
48 ssent = list_entry(list, struct skill_set_entry, list);
50 list_remove(&ssent->list);
51 skill_set_entry_unref(ssent);
57 struct skill_set *skill_set_new(void)
59 struct skill_set *skset = (struct skill_set*)calloc(1, sizeof(*skset));
61 list_init(&skset->list);
62 list_init(&skset->skills);
67 void skill_set_set_name(struct skill_set *skset, char *val)
73 skset->name = strdup(val);
77 void skill_set_ref(struct skill_set *skset)
82 void skill_set_unref(struct skill_set *skset)
84 assert(skset->refcount > 0);
86 if (!skset->refcount) {
91 void skill_set_add_skill(struct skill_set *skset, struct skill *skill,
94 struct skill_set_entry *ssent = skill_set_entry_new(skill, level);
96 list_add_tail(&skset->skills, &ssent->list);