some time ago when races were added to xml, the global familiarrace-list was broken. fixed.

This commit is contained in:
Enno Rehling 2006-02-10 21:15:08 +00:00
parent a66e90c25b
commit af9a86efa7
3 changed files with 20 additions and 5 deletions

View File

@ -59,7 +59,24 @@
/** external variables **/ /** external variables **/
race * races; race * races;
race_list * familiarraces;
race_list *
get_familiarraces(void)
{
static int init = 0;
static race_list * familiarraces;
if (!init) {
race * rc = races;
for (;rc!=NULL;rc=rc->next) {
if (rc->init_familiar!=NULL) {
racelist_insert(&familiarraces, rc);
}
}
init = false;
}
return familiarraces;
}
void void
racelist_clear(struct race_list **rl) racelist_clear(struct race_list **rl)
@ -110,9 +127,6 @@ race *
rc_add(race * rc) rc_add(race * rc)
{ {
rc->next = races; rc->next = races;
if (rc->init_familiar!=NULL) {
racelist_insert(&familiarraces, rc);
}
return races = rc; return races = rc;
} }

View File

@ -102,7 +102,7 @@ typedef struct race_list {
extern void racelist_clear(struct race_list **rl); extern void racelist_clear(struct race_list **rl);
extern void racelist_insert(struct race_list **rl, const struct race *r); extern void racelist_insert(struct race_list **rl, const struct race *r);
extern struct race_list * familiarraces; extern struct race_list * get_familiarraces(void);
extern struct race * races; extern struct race * races;
extern struct race * rc_find(const char *); extern struct race * rc_find(const char *);

View File

@ -521,6 +521,7 @@ select_familiar(const race * magerace, magic_t magiegebiet)
assert(magerace->familiars[0]); assert(magerace->familiars[0]);
if (rnd < 3) { if (rnd < 3) {
race_list * familiarraces = get_familiarraces();
unsigned int maxlen = listlen(familiarraces); unsigned int maxlen = listlen(familiarraces);
if (maxlen>0) { if (maxlen>0) {
race_list * rclist = familiarraces; race_list * rclist = familiarraces;