Um, you might want to put in a quick:

if(tp) {}

check before you do any comparing with tp or tp->next....

It's most likely crashing because tp is somehow getting a NULL....

Also, what does your "TELEPORTER_DATA" struct look like?  is next a
TELEPORTER_DATA* ?

Another item to check is also ensureing that teleporter_list is not null as 
well,
so:

if(!teleporter_list)
        return;

something like that would be adviseable.

just a couple things to check.

-----Original Message-----
From: Oestreich, Charles ICFN [mailto: [EMAIL PROTECTED]
Sent: 1/2/2003 at 1:31 AM
To: "Rom (E-mail)" <[email protected]>
Subject:  teleporter code
Message:

>i code my code working perfect except when someone disactivates or eats a
>teleporter it crashes. i'm not sure how to exactly do the code, but this is
>what i got but if anyone can tell me what i did wrong with it, or if they
>see a problem i'm not seeing any help would be appreciated.
>
>OBJ_DATA *deactivate_teleporter( OBJ_DATA *obj, TELEPORTER_DATA *tp )
>{
>    TELEPORTER_DATA *tp2;
>
>    if ( tp == teleporter_list )
>    {
>       teleporter_list = tp->next;
>    }
>    else
>    {
>       for ( tp2 = teleporter_list; tp2; tp2 = tp2->next )
>       {
>           if ( tp2->next == tp )
>           {
>               tp2->next = tp->next; <-----crashes here
>               break;
>           }
>       }
>    }
>
>    free_teleporter(tp);
>
>    obj->active = FALSE;
>    obj->active_room = 0;
>    return obj;
>}
>
>
>void do_deactivate( CHAR_DATA *ch, char *argument )
>{
>    OBJ_DATA *obj;
>    TELEPORTER_DATA *tp;
>    ROOM_INDEX_DATA *room;
>    char buf[MAX_STRING_LENGTH];
>
>    if ( argument[0] == '\0' )
>    {
>       send_to_char("Deactivate what?\n\r", ch);
>       return;
>    }
>
>    if ( ( obj = get_obj_list(ch, argument, ch->in_room->contents) ) ==
>NULL
>)
>    {
>       send_to_char("You do not see that here.\n\r", ch);
>       return;
>    }
>
>    if ( obj->item_type != ITEM_TELEPORTER )
>    {
>       send_to_char("You can only deactivate teleporters.\n\r", ch);
>       return;
>    }
>
>    if ( !obj->active )
>    {
>       send_to_char("That is not an active teleporter.\n\r", ch);
>       return;
>    }
>
>    for ( tp = teleporter_list; tp; tp = tp->next )
>    {
>       if ( obj->active_room == tp->in_room->vnum )
>           break;
>    }
>
>    if ( tp = NULL )
>    {
>       send_to_char("This teleporter is not assigned to any room.\n\r",
>ch);
>       obj->active = FALSE;
>       obj->active_room = 0;
>       return;
>    }
>
>    room = get_room_index(obj->active_room);
>    obj = deactivate_teleporter(obj, tp);
>    sprintf(buf, "Teleporter for room #%d (%s) has been deactivated.\n\r",
>room->vnum, room->name);
>    send_to_char(buf, ch);
>
>    do_teleport(ch, "");
>    save_teleporters(ch);
>    return;
>}
>
>--
>ROM mailing list
>[email protected]
>http://www.rom.org/cgi-bin/mailman/listinfo/rom





Reply via email to