Re: Question concerning linked lists

From: Jason Beeland (jbeeland@speedfactory.net)
Date: 12/14/99


Ok, this is my case for open in do_doorcmd in act.movement.c
now, the problem is that the code which removes the entry in spec_door_list
seems to crash the mud.  even when i used the code which Dak suggested,
which i agree is better.  I'm really at a loss here.  Any help is
appreciated.
The goal is to make it so that if a door is affected by EX_FIRETRAP and if
the person opening the door is not the caster of the spell (*owner) then do
the
damage, and remove the affect.  Removing the affect also entails removing
the
spec_door entry for that door in the spec_door_list linked list.

Hope this clairifys things a bit, and thanks in advance.

-Veritus

case SCMD_OPEN:
    if(obj) {
      if(IS_OBJ_STAT(obj, ITEM_FIRETRAP) && !is_firetrap_owner(obj, door,
ch)) {
        REMOVE_BIT(obj->obj_flags.extra_flags, ITEM_FIRETRAP);
        damage(ch, ch, dice(2, 600), SKILL_EXPLOSIVE, DAMAGE_HEAT);
      }
    }
    else {
      if(IS_SET(EXITN(ch->in_room, door)->exit_info, EX_FIRETRAP) &&
!is_firetrap_owner(obj, door, ch)) {
        send_to_room("A glowing sigil appears in the air, and then bursts
into flames!\r\n", ch->in_room);
        damage(ch, ch, dice(2, 600), SKILL_EXPLOSIVE, DAMAGE_HEAT);
        REMOVE_BIT(EXITN(ch->in_room, door)->exit_info, EX_FIRETRAP);
        for (kPrev = NULL, k = spec_door_list; k; kPrev = k, k = k->next)
          if (k->door == EXITN(ch->in_room, door))
            break;
        if (k) {
          if (kPrev) {
            kPrev->next = k->next;
          } else {
            spec_door_list = spec_door_list->next;
          }
        }
        free(k);
        if(back) {
          send_to_room("You hear a small explosion!\r\n", other_room);
          REMOVE_BIT(back->exit_info, EX_FIRETRAP);
         for (kPrev = NULL, kk = spec_door_list; kk; kPrev = kk, kk =
kk->next)
          if (k->door == EXITN(ch->in_room, door))
            break;
        if (kk) {
          if (kPrev) {
            kPrev->next = kk->next;
          } else {
            spec_door_list = spec_door_list->next;
          }
        }
        free(kk);
        }
      }
    }


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     |  http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html  |
     +------------------------------------------------------------+



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