Bank code errors on compiling

Posted by Gareth on Thu 05 Jun 2003 12:24 AM — 9 posts, 30,245 views.

#0
first a great thank you to everyone helping with code,
i finally got my compile working.. but now.. i cant seem
to get this bank snippet to work, i believe its samsons
bank code

I tried three times, clean... same errors
if you need more details please let me know


bank.c: In function `find_banker':
bank.c:52: parse error before "break"
bank.c: In function `do_balance':
bank.c:207: warning: unused variable `found'
make[1]: *** [bank.o] Error 1
make[1]: Leaving directory `/cygdrive/c/smaug'
make: *** [all] Error 2

USA #1
It's usually safe to assume that on errors that give line numbers, posting what those lines of code are, would be benefitial to your cause.

Due to the nature of your errors I'll see if I can help you out. The first one, in bank.c look at line 51. Is this part of a 'case' statement or an 'if' statement? If it's part of a case/switch block of code then line 51 is likely missing a ; at the end. If it's a line that begins with 'if' it could be a number of things, but check the number of parenthesis there's like a ( or a ) missing in the statement. Considering the error I can assume that if it IS an 'if' statement it's missing a ) at the end. If this doesn't help post lines 50-55.

The second error is a very simple one to "fix". There's an additional variable not being used, 'found', remove it ;-)
#2
Hi, I am more of a writer/designer than a programmer, so you'll have to forgive me, i guess i should turn over all
this to my coder but hes a continent away and i want to do it now ;)

here are the offending lines: break error


for ( banker = ch->in_room->first_person; banker; banker = banker->next_in_room )
if ( IS_NPC( banker ) && xIS_SET( banker->act, ACT_BANKER )
break;

return banker;

and the 'found'

void do_balance( CHAR_DATA *ch, char *argument )
{
CHAR_DATA *banker;
char buf [MAX_STRING_LENGTH];
bool found = FALSE;

the problem is that the bank.c is unmodified by me and im sure samson would not have distributed snippets with code errors in, so i'm assuming the errors are because of other depencies...

thanks again for any advice
USA #3
Quote:
..and im sure samson would not have distributed snippets with code errors in..

Assumptions can get you in sticky situations...

We're all prone to mistakes, and sometimes the more skilled you are, the more 'little' mistakes you make. These errors ARE such, little mistakes.

If you review what I first posted and review what you posted, things tend to fit together.

I said:
Quote:
..look at line 51..

Since you knew how to find the offending line, I know you can determine that this is line 51:
if ( IS_NPC( banker ) && xIS_SET( banker->act, ACT_BANKER )


I then said:
Quote:
If it's a line that begins with 'if' it could be a number of things, but check the number of parenthesis there's like a ( or a ) missing in the statement. Considering the error I can assume that if it IS an 'if' statement it's missing a ) at the end.


Now I admit I didn't flat out say "Add a ) to the end and recompile, but I did hint at it pretty throughly.

Let me correct that problem. On line 51 of the code, add a ) to the end, creating this:
if ( IS_NPC( banker ) && xIS_SET( banker->act, ACT_BANKER ) )

Ok, error #2. I said:
Quote:
The second error is a very simple one to "fix". There's an additional variable not being used, 'found', remove it.

Seems simple enough.. let me clarify.

Remove this line from the code:
bool found = FALSE;


Save. Quit. Recompile.
I'm quite certain Samson posts code on his site contributed by others. He does this as a favor to both the coder and the community. So, this code is not necessarily his. And as I mentioned earlier, even the most skilled coders tend to make simple mistakes ;-)
Amended on Fri 06 Jun 2003 12:06 AM by Boborak
USA #4
Hey Nick, my last post seemed to double any linebreak I added. Kinda strange. I don't remember it doing that before.
Australia Forum Administrator #5
You mean in the code snippets? I haven't changed it, but I noticed a similar problem in the help pages.
USA #6
Yea, it did it in the quote blocks too. I adjusted my post to make it appear normal by cutting out some of the returns.

Just an idea, perhaps something was changed on the server regarding php? Not the webpages, but the server software itself. *shrug*
Amended on Fri 06 Jun 2003 01:50 AM by Boborak
Australia Forum Administrator #7
Yes, that wouldn't surprise me.

I'll have to take a closer look at how I render the code blocks, it is probably something to do with that.
USA #8
Back to the subject of the bank code for a sec, thanks for reporting on that bug guys. Was indeed one of those silly things that just didn't get noticed. What surprises me is that it took so long before someone noticed it. Had been on the page for nearly 6 months like that :P

Also appreciate the kind comments, those are welcome indeed and are all too often missed in the day to day. Thanks :)