Beispiel #1
0
/* Entry point for editing area_data. */
void do_aedit (CHAR_DATA * ch, char *argument)
{
    AREA_DATA *pArea;
    int value;
    char arg[MAX_STRING_LENGTH];

    if (IS_NPC (ch))
        return;

    pArea = ch->in_room->area;

    argument = one_argument (argument, arg);

    if (is_number (arg))
    {
        value = atoi (arg);
        if (!(pArea = get_area_data (value)))
        {
            send_to_char ("That area vnum does not exist.\n\r", ch);
            return;
        }
    }
    else if (!str_cmp (arg, "create"))
    {
        if (ch->pcdata->security < 9)
        {
            send_to_char ("AEdit : Insufficient security to create area.\n\r",
                          ch);
            return;
        }

        aedit_create (ch, "");
        ch->desc->editor = ED_AREA;
        return;
    }

    if (!IS_BUILDER (ch, pArea))
    {
        send_to_char ("Insufficient security to edit areas.\n\r", ch);
        return;
    }

    ch->desc->pEdit = (void *) pArea;
    ch->desc->editor = ED_AREA;
    return;
}
Beispiel #2
0
/*****************************************************************************
 Name:		do_asave
 Purpose:	Entry point for saving area data.
 Called by:	interpreter(interp.c)
 ****************************************************************************/
void do_asave( CHAR_DATA *ch, char *argument )
{
    char arg1 [MAX_INPUT_LENGTH];
    AREA_DATA *pArea;
    int value;

    if ( !ch )                                              /* Do an autosave */
    {
        save_area_list();
        for( pArea = area_first; pArea; pArea = pArea->next )
        {
            save_area( pArea );
            REMOVE_BIT( pArea->area_flags, AREA_CHANGED | AREA_ADDED );
        }
        return;
    }
    if (IS_NPC(ch)) return;

    if (ch->pcdata->security < 1)
    {
        send_to_char("Huh?\n\r", ch );
        return;
    }

    argument = one_argument( argument, arg1 );

    if ( arg1[0] == '\0' )
    {
        send_to_char( "Syntax:\n\r", ch );
        send_to_char( "  asave <vnum>    - saves a particular area\n\r",     ch );
        send_to_char( "  asave list      - saves the area.lst file\n\r",     ch );
        send_to_char( "  asave helps    - saves the help file\n\r", ch );
        send_to_char( "  asave area      - saves the area being edited\n\r", ch );
        send_to_char( "  asave changed   - saves all changed zones\n\r",     ch );
        send_to_char( "  asave world     - saves the world! (db dump)\n\r",  ch );
        send_to_char( "  asave ^ verbose - saves in verbose mode\n\r", ch );
        send_to_char( "\n\r", ch );
        return;
    }

    /* Snarf the value (which need not be numeric). */
    value = atoi( arg1 );

    /* Save the area of given vnum. */
    /* ---------------------------- */

    if ( !( pArea = get_area_data( value ) ) && is_number( arg1 ) )
    {
        send_to_char( "That area does not exist.\n\r", ch );
        return;
    }

    if ( is_number( arg1 ) )
    {
        if ( !IS_BUILDER( ch, pArea ) )
        {
            send_to_char( "You are not a builder for this area.\n\r", ch );
            return;
        }

        save_area_list();
        if ( !str_cmp( "verbose", argument ) )
            SET_BIT( pArea->area_flags, AREA_VERBOSE );
        save_area( pArea );
        REMOVE_BIT( pArea->area_flags, AREA_VERBOSE );
        return;
    }

    /* Save the world, only authorized areas. */
    /* -------------------------------------- */

    if ( !str_cmp( "world", arg1 ) )
    {
        save_area_list();
        for( pArea = area_first; pArea; pArea = pArea->next )
        {
            /* Builder must be assigned this area. */
            if ( !IS_BUILDER( ch, pArea ) )
                continue;

            if ( !str_cmp( "verbose", argument ) )
                SET_BIT( pArea->area_flags, AREA_VERBOSE );
            save_area( pArea );
            REMOVE_BIT( pArea->area_flags, AREA_CHANGED | AREA_ADDED | AREA_VERBOSE );
        }
        send_to_char( "You saved the world.\n\r", ch );
        return;
    }

    if (!str_cmp(arg1, "helps"))
    {

        if (ch->level > 6)
        {
            save_help();
            send_to_char(" Helps saved.\n\r", ch);
        }
        return;
    }

    /* Save changed areas, only authorized areas. */
    /* ------------------------------------------ */

    if ( !str_cmp( "changed", arg1 ) )
    {
        char buf[MAX_INPUT_LENGTH];

        save_area_list();

        send_to_char( "Saved zones:\n\r", ch );
        sprintf( buf, "None.\n\r" );

        for( pArea = area_first; pArea; pArea = pArea->next )
        {
            /* Builder must be assigned this area. */
            if ( !IS_BUILDER( ch, pArea ) )
                continue;

            /* Save changed areas. */
            if ( IS_SET(pArea->area_flags, AREA_CHANGED)
                || IS_SET(pArea->area_flags, AREA_ADDED) )
            {
                if ( !str_cmp( "verbose", argument ) )
                    SET_BIT( pArea->area_flags, AREA_VERBOSE );
                save_area( pArea );
                REMOVE_BIT( pArea->area_flags, AREA_CHANGED | AREA_ADDED | AREA_VERBOSE );
                sprintf( buf, "%24s - '%s'\n\r", pArea->name, pArea->filename );
                send_to_char( buf, ch );
            }
        }
        if ( !str_cmp( buf, "None.\n\r" ) )
            send_to_char( buf, ch );
        return;
    }

    /* Save the area.lst file. */
    /* ----------------------- */
    if ( !str_cmp( arg1, "list" ) )
    {
        save_area_list();
        return;
    }

    /* Save area being edited, if authorized. */
    /* -------------------------------------- */
    if ( !str_cmp( arg1, "area" ) )
    {
        /* Find the area to save. */
        switch (ch->desc->editor)
        {
            case ED_AREA:
                pArea = (AREA_DATA *)ch->desc->pEdit;
                break;
            case ED_ROOM:
                pArea = ch->in_room->area;
                break;
            case ED_OBJECT:
                pArea = ( (OBJ_INDEX_DATA *)ch->desc->pEdit )->area;
                break;
            case ED_MOBILE:
                pArea = ( (MOB_INDEX_DATA *)ch->desc->pEdit )->area;
                break;
            default:
                pArea = ch->in_room->area;
                break;
        }

        if ( !IS_BUILDER( ch, pArea ) )
        {
            send_to_char( "You are not a builder for this area.\n\r", ch );
            return;
        }

        save_area_list();
        if ( !str_cmp( "verbose", argument ) )
            SET_BIT( pArea->area_flags, AREA_VERBOSE );
        save_area( pArea );
        REMOVE_BIT( pArea->area_flags, AREA_CHANGED | AREA_ADDED | AREA_VERBOSE );
        send_to_char( "Area saved.\n\r", ch );
        return;
    }

    /* Show correct syntax. */
    /* -------------------- */
    do_asave( ch, "" );
    return;
}