Re: [ Code ] Again... I still ahev problems with free() and NULL pointers

From: Rasdan (rasdan@PEAK.ORG)
Date: 08/04/97


>
> void check_fall(void)
> {
>   int fall_dmg;
>   struct char_data *ch, *next_ch;
>   for (ch = character_list; ch; ch = next_ch) {
>     next_ch = ch->next;
>
>   if (ROOM_AFFECTED(IN_ROOM(ch), RAFF_ACID_RAIN))
>     gen_damage(ch, GET_MAX_HIT(ch) * 10 / 100, SPELL_ACID_RAIN);
>
>     if (ch && ((SECT(IN_ROOM(ch)) == SECT_FLYING)) && (!AFF_FLAGGED(ch, AFF_FLY
>         !(IS_NPC(ch) && MOB_FLAGGED(ch, MOB_WINGS)) &&
>         !(IS_NPC(ch) && MOB_FLAGGED(ch, MOB_NOACT)) &&
>         !(GET_LEVEL(ch) > LVL_IMMORT)) {
>
> ... etc etc etc ...
>
Looks like you are also damaging mobs in this way, is that what you want
to do?

if not, use descriptor_list not character_list

Also, why not make gen_damage return a value type int and if the char is
freed return 0 like:

   if (ROOM_AFFECTED(IN_ROOM(ch), RAFF_ACID_RAIN))
     if (!gen_damage(ch, GET_MAX_HIT(ch) * 10 / 100, SPELL_ACID_RAIN))
       return;          /* Exit out, don't bother with the next step if
                         * char is gone!
                         */
> (gdb) print ch
> $4 = (struct char_data *) 0x829bc08

Well, this is right because you are printint the address of ch, not the
value.

>
> *blink*
>
> (gdb) print ch->player.name
> $6 = 0x81ff3b8 "Puff dragon fractal"

Again, you are acting on mobs too, if you don't want to do that stop that
and use descriptor_list.

>
> *blink*
>
> (gdb) print *ch
> ... snip snip snip ...
> *blink*

This prints everything in the char structure.

Try print ch->in_room.

Rasdan

=--=--=--=--=--=--=--=--=--=--=
  I have done so much,
  with so little,                         James C. Thomas Jr.
  for so long,                                 Rasdan
  That I can do anything                Head Coder of Finality!
  with nothing.
=--=--=--=--=--=--=--=--=--=--=
Finality is based upon CircleMUD 3.0, check us out:
                   finality.mudservices.com 5555


     +------------------------------------------------------------+
     | 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/08/00 PST