Re: [Circle] newbie fighting question

From: Erik (madison@nevada.edu)
Date: 07/30/96


  This really depends on the length of the loop. If there is no call to 
die, hit, damage, etc, thus no way to lose the pointer reference, then it 
is perfectly safe. I use both. The first being quicker by a hair, and 
simpler to follow, I use it if I'm able.

                         Fafhrd of Duris


> > This is not an answer to the question, but a warning 
for a common > > bug....
> > 
> > >     for (i = world[ch->in_room].people; i; i = i->next_in_room)
> >                                                  ^^^^^^^^^^^^^^^
> >                                                         |
> >   This is dangerous. Special since 'i' has a chance for dying.
> > If 'i' die, then 'i->next_in_room' is NULL or something weird, since
> > 'i' is being extracted..
> > 
> >   what to do instead:
> > 
> > Add a struct char_data *next_i;
> > 
> > for (i = world[ch->in_room; i; i = next_i) {
> >   next_i = i->next_in_room;
> > ...etc...
> > 
+-----------------------------------------------------------+
| Ensure that you have read the CircleMUD Mailing List FAQ: |
|   http://cspo.queensu.ca/~fletcher/Circle/list_faq.html   |
+-----------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/07/00 PST