Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ SMAUG ➜ SMAUG coding ➜ do_odrop

do_odrop

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Ithildin   USA  (262 posts)  Bio
Date Sat 18 Sep 2004 06:58 AM (UTC)
Message
ok, i'm writing a command like the one from aurura's obj snippet. i've got it compiling nicely, just crashes when used. here's what i have:



 void do_odrop ( CHAR_DATA *ch, char *argument )
 {
    char arg1[MAX_INPUT_LENGTH];
    char arg2[MAX_INPUT_LENGTH];
    char arg3[MAX_INPUT_LENGTH];
    char arg4[MAX_INPUT_LENGTH];
    int count, created, level;
    OBJ_INDEX_DATA *pObjIndex;
    OBJ_DATA *obj;
    CHAR_DATA *rch;
    AREA_DATA *parea;
    ROOM_INDEX_DATA *pRoomIndex;
    bool found = FALSE;

    argument = one_argument(argument, arg1);
    argument = one_argument(argument, arg2);
    argument = one_argument(argument, arg3);
    argument = one_argument(argument, arg4);
    count = atoi( arg2 );
    level = atoi (arg4 );

    rch = get_char (ch);


    if (!authorized (rch, "odrop"))
                 return;
    if (arg1[0] == '\0' || arg2[0] == '\0' || arg3[0] == '\0' )
        {
                send_to_char( "Odrop <area> <# objs> <obj vnum> <level>\n\r", ch );
                return;
        }

    for ( parea = area_first; parea; parea = parea->next )

            if ( !str_cmp(parea->filename, arg1 ) )

    {

            found = TRUE;

            break;

    }

    if ( !found )

    {

            send_to_char("Area not found.\n\r", ch );

            return;

    }



    if (count > 5)

    {

            send_to_char( "You can only drop 5 items or less.\n\r", ch );

            return;


    }



    if ( ( pObjIndex = get_obj_index( atoi(arg2) ) ) == NULL )

    {

            send_to_char("No object has that vnum.\n\r", ch );

    }





    for ( created=0; created < count; created++ )

    {

            if ( (pRoomIndex = get_room_index(number_range(parea->lvnum, parea->uvnum ))) == NULL )



            {

                    --created;

                    continue;

            }

            if (!IS_SET( pRoomIndex->room_flags, ROOM_SAFE))

            {

                    --created;

                    continue;
            }
            obj = create_object( pObjIndex, level);
            obj_to_char(obj, ch);
    }
    send_to_char("You have placed your drop.\n\r", ch);
        return;
 }


it was trying to create obj but making it NULL and crashing.

any thoughts?

Top

Posted by Greven   Canada  (835 posts)  Bio
Date Reply #1 on Sat 18 Sep 2004 01:57 PM (UTC)
Message
Well, from what I can see, you probably what a return here:
    if ( ( pObjIndex = get_obj_index( atoi(arg2) ) ) == NULL )

    {

            send_to_char("No object has that vnum.\n\r", ch );

    }


Its probably sending that message, or queueing it to be sent, and then crashing because its NULL later.

Nobody ever expects the spanish inquisition!

darkwarriors.net:4848
http://darkwarriors.net
Top

Posted by Ithildin   USA  (262 posts)  Bio
Date Reply #2 on Sat 18 Sep 2004 08:13 PM (UTC)
Message
yea, that was the problem. thanks. it was like 4 in the morning when doing that...heh
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


12,957 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.