I'm trying to code a mob stacking routine that involves a linked list. Here's what I have at the moment: struct list_struct { struct char_data *ch; /* mob data */ struct list_struct *next; /* Next in the list */ int num; /* Number of times this mob occurs */ }; struct list_struct *my_list = NULL, *temp = NULL; for (i = list; i; i = i->next_in_room) { [code here to list mobs that do not match prototype and pcs] /* At this point we have a mob that probably needs to be listed on the same line as several others. */ /* Loop through internal list, find slot and increment count. */ if (!my_list) { my_list->ch = ch; my_list->num = 1; my_list->next = my_list; } else { found = FALSE; for (temp = my_list; temp && !found; temp = temp->next) { if (GET_MOB_VNUM(temp->ch) == GET_MOB_VNUM(i)) { found = TRUE; temp->num++; } } } /* If mobile not found in internal list, add to list */ if (!found) { temp->ch = ch; temp->num = 1; temp->next = my_list; my_list = temp; } } /* Loop through internal list and print them all */ if (my_list) for (temp = my_list; temp; temp = temp->next) list_one_char(temp->ch, ch, temp->num); What happens when you look at a room with a prototypical mob is a crash, but without a core dump, so I have no chance of debugging. :( My experience with creating linked lists is in Pascal and I haven't touched them in years. Could someone please point out where I'm going wrong? Thank you, John Evans <evansj@hi-line.net> -- http://www.hi-line.net/~evansj/ Any sufficiently advanced technology is indistinguishable from magic. --Arthur C. Clarke +------------------------------------------------------------+ | Ensure that you have read the CircleMUD Mailing List FAQ: | | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html | +------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 12/15/00 PST