I'm trying to edit do_put with a for loop that will get the amount of items 
in the current object. After that I want to see if value3 is greater then 
count, and if it is, the player can put an object in it, but if its equal or 
greater then the value, then it returns. This is the first time I tried 
anything like this, even though its small, it crashes when it gets to the if 
statement that compares value and count. I checked the values of count and 
value, and they get the correct ones.
Here is my code:

 if ( IS_SET(container->value[1], CONT_CLOSED) )
    {
        act( "The $d is closed.", ch, NULL, container->name, TO_CHAR );
        return;
    }

/*end of normal do_put*/
/*Start object count*/
    count = 0;
    for ( container = container->contains; container != NULL; container = 
container->next_content)
       {
           count++;
           printf("count %d\n\r", count);
           printf("value 3: %d\n\r", container->value[3]);
       }
     /*End object count, start comparison*/   
    if (container->value[3] <= count)
        {
                stc("Too many items.\n\r", ch);
                return;
        }
        sprintf (buf, "Count is %d\n\r", count);
        stc (buf, ch);
    /*End comparison*/
/*Resume normal do_put*/
if ( str_cmp( arg1, "all" ) && str_prefix( "all.", arg1 ) )
    {
        /* 'put obj container' */
        if ( ( obj = get_obj_carry( ch, arg1, ch ) ) == NULL )
        {
            send_to_char( "You do not have that item.\n\r", ch );
            return;
        }

GDB output:
Tue Apr 30 11:45:49 2002 :: ROM is ready to rock on port 6003.
Tue Apr 30 11:45:52 2002 :: Sock.sinaddr:  66.66.4.192
Tue Apr 30 11:45:54 2002 :: Loading Dayrinni.
Tue Apr 30 11:45:55 2002 :: [EMAIL PROTECTED] has 
connected.
count 1
value 3: 3
count 2    <-----These are correct
value 3: 3     <-----These are correct

Program received signal SIGSEGV, Segmentation fault.
do_put (ch=0x402c8f8c, argument=0x402c7d29 "sword in bag") at act_obj.c:451
451             if (container->value[3] <= count)



Thanks for your help

Reply via email to