Re: fighting list

From: Hades (tourach@servtech.com)
Date: 06/26/96


> 
> >     for (k = combat_list; k; k = temp)
> >     {
> >        temp = k->next_fighting;
> >        if (FIGHTING(k) == ch)
> >          stop_fighting(k);
> >     }
> 
> also, you can just do:
> for (k=combat_list;k;k=k->next_fighting){
>   if (FIGHTING(k)==vict)
>     stop_fighting(k);
> }
> 

Cant... k = k->next-fighting wont work. stop_fighting pulls 'k' from the
linked lsit... so if the list were:
bob -> mark -> steve -> joe -> tim

would work like this:
for(k = bob; k; k = k->next_fighting) {
  if(fighting(bob) == vict)
  remove_bob_from_list;
}

Now bob is no longer in the list, which sets bo->next_fighting = NULL; so,
when k = k->next fighting, k will = NULL, and the loop will end as !k is
true.
 Did that make any sense at all?



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