when i type deactivate teleporter, it deactivates it, but it does not remove
it from the list, so when i goto another location and type teleport my mud
crashes because of the list not removing it. wondering if anyone can help
me. here is the code for deactivate.

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; <-- change this
 
                if ( tp->next != NULL )
                    tp2->next = tp->next;
                else tp2->next = NULL;
                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;
}

Reply via email to