[Home] [Downloads] [Search] [Help/forum]

Gammon Software Solutions forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  SMAUG
. -> [Folder]  SMAUG coding
. . -> [Subject]  do_odrop

Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

do_odrop

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page


Posted by Ithildin   USA  (262 posts)  [Biography] bio
Date Sat 18 Sep 2004 06:58 AM (UTC)  quote  ]
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?

[Go to top] top

Posted by Greven   Canada  (835 posts)  [Biography] bio
Date Reply #1 on Sat 18 Sep 2004 01:57 PM (UTC)  quote  ]
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
[Go to top] top

Posted by Ithildin   USA  (262 posts)  [Biography] bio
Date Reply #2 on Sat 18 Sep 2004 08:13 PM (UTC)  quote  ]
Message
yea, that was the problem. thanks. it was like 4 in the morning when doing that...heh
[Go to top] 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.


2,069 views.

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

[Home]

Written by Nick Gammon - 5K

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Internet Contents Rating Association (ICRA) - 2K]    [Web site powered by FutureQuest.Net]