Simple question...I think!

Posted by Jmont on Wed 05 Aug 2009 12:19 AM — 8 posts, 29,149 views.

#0
Alright I'm trying to get rid of carrying weight. So I have been getting rid of any instance of can_carry_w like so...


if( char_died( ch )
                   ||ch->carry_number >= can_carry_n( ch )
                   || ch->carry_weight >= can_carry_w( ch ) || ( number && cnt >= number ) )
                   {         
                  if( IS_SET( sysdata.save_flags, SV_GET ) && !char_died( ch ) )
                     save_char_obj( ch );
                  return;


Now when I delete this line

|| ch->carry_weight >= can_carry_w( ch ) || ( number && cnt >= number ) )


I get this error

  Compiling o/act_obj.o....
act_obj.c: In function `void do_get(CHAR_DATA*, const char*)':
act_obj.c:300: error: expected `)' before '{' token
act_obj.c:305: error: expected primary-expression before '}' token
act_obj.c:305: error: expected `;' before '}' token


But I if I add the line back in then everything is all OK. I'm sure I'm missing something simple here but I'm lost for words. If anyone can explain to me whats wrong, or even point me to a tutorial related to my error that would be awesome...I am eager to learn and create.

Thanks everyone!
USA #1
You're deleting too many parenthesis, as the error says.
#2
Hrm but it doesn't look like I need any parenthesis. Unless I'm wrong, which I have to be if I getting errors.


if( char_died( ch )
                   ||ch->carry_number >= can_carry_n( ch )
                   {         
                  if( IS_SET( sysdata.save_flags, SV_GET ) && !char_died( ch ) )
                     save_char_obj( ch );
                  return;
                  }
            }
         }


This is what it looks like when I take that line out. I don't really see what needs a parenthesis though ;_; Also what does the || mean?! It's been awhile since I took any programming classes.

Thanks Zeno
USA #3
The parenthesis before char_died is where you're missing the matching parenthesis.

|| is an or.
#4
Yeah I just noticed the missing parenthesis I didn't know it was one big IF statement. OK one last questions and I should be done with this one, what exactly Is this IF statement saying and doing?

Thanks again Zeno :D
USA #5
IF char has died OR char is carrying equal or greater than their max number of items OR char is carrying equal OR greater than their max weight OR ???, THEN IF the config is on for saving on get AND the char hasn't died, THEN save the char.

I don't know what the ??? is because I don't know what number or cnt is.
Amended on Wed 05 Aug 2009 01:30 AM by Zeno
#6
This might be sound dumb but I thought saving was taken care of somewhere else? Is this just to make sure you don't get an item and lose it?
USA #7
Saving happens in many places. In this case, it is to save your char when you pick up an item.