Bank commands...

Posted by Bryn on Sun 05 Jan 2003 08:08 AM — 16 posts, 67,029 views.

#0
I was adding a bank snippet today, and i got to the part where i add balance, withdraw and deposit to tables.c, but all the readme said was "Make the appropriate additions to tables.c for do_balance, do_withdraw, and do_deposit." Can anyone please tell me just what to add to tables.c?


Bryn
USA #1
all you have to do is find...
if ( !str_cmp( name, "do_*" )) return do_*;

where * is the name off ythe function you want to add... that section its important to put the if statement alphabetically according to the name of the command... search for case 'w': and put the if statement for withdraw in there and then search for case 'b': and add balance and search for case 'd' and add deposit...
then search for
char *skill_name( DO_FUN *skill )
and add
if ( skill == do_* ) return "do_*";
for each of the three commands anywhere after the

if ( skill == NULL ) return "reserved";

you should be all set :)
-typhon
#2
i added those into tables.c, and the file compiled just fine, but after it created the .o files it gave me two errors for each command that said(this is only one example)
"tables.o(.text+0x61bf):/home/Bryn/smaug/dist/src/tables.c:853 undefined refrence to '_do_balance'

what did i do wrong?
USA #3
"do_balance" rather than "_do_balance"
Australia Forum Administrator #4
I think the compiler adds the underscore.

Check the new file (with do_balance in it) is linked into the executable. eg. look in the makefile to make sure that the file name (eg. banking.o) is in the list of object files.
USA #5
To bring an old subject up...

i tried installing Samsons' bank code from his site. everything compiled fine, but when i go to put the commands in the game, it won't let me.

Log: Ithildin: cedit balance create do_balance
Command added.
Code do_balance not found. Set to no code.

what can i do?
USA #6
did you add the commands to tables.c and the DECLARE_DO_FUN to mud.h?
USA #7
yep. i added everything. i even looked up another command to make sure i had it in all the places that it needed to be. i know i'm just doing one simple thing wrong, but i can't find it anywhere. i tried puttin in rafermands bank snippet, but i had the same problem so i just figured it didn't work, so i switched to this one and now i can't do it either. the code is in bank.c, for some reason it might not be reading bank.c correctly. it's in my project, i'm using windows right now. i even put it in the makefile. it compiles it when it recompiles. this is buggin me. heh. i know it's something stupid.
Australia Forum Administrator #8
Make sure the "do_balance" command is in the "b" part of tables.c. Just with other commands is not enough, it has to be in the "b" section.
USA #9
i did that at the beginning. i'm still not sure what's going on.
USA #10
here's what i have so far. but it just won't let me cedit it in the mud. can't find do_balance or any of the others.


case 'b':
	if ( !str_cmp( name, "do_backstab" ))		return do_backstab;
	if ( !str_cmp( name, "do_balzhur" ))		return do_balzhur;
	if ( !str_cmp( name, "do_balance" ))		return do_balance;

and here:

if ( skill == do_backstab )		return "do_backstab";
	if ( skill == do_balance )		return "do_balance";
    if ( skill == do_balzhur )		return "do_balzhur";


that's where my do balance is. it's also the same with withdraw and deposit. they are in alphabetical order. my declares are in there as well.

would it have to do with the fact that bank.c and bank.h aren't compiling correctly even though it shows them compiling?
Canada #11
Its possible, like if you've got multiple declaration calls and such, but it would be more important if your getting errors from table.c about it. What are th errors? If we can see them, we might be able to show you how to correct them.
Australia Forum Administrator #12
Well, the only place that message appears is in act_wiz.c, here:


        command->do_fun = skill_function( arg2 );
        add_command( command );
        send_to_char( "Command added.\n\r", ch );
        if ( command->do_fun == skill_notfound )
            ch_printf( ch, "Code %s not found.  Set to no code.\n\r", arg2 );


If you get no compiler errors or warnings, and you cannot see what is the problem, put a breakpoint on the first line, above, step into skill_function, and see what happens when it tries to find your function name.
USA #13
hey nick, i'm not really understanding what your trying to say. this may sound stupid, but what do you mean by breakpoint? Greven, i'm not getting any errors. i'm not really sure what's going on. i'm going to have a hard look into it here in a second. i haven't had much time to look at it much.

THanks for all the help

here's the help file i used.

Quote:

1. To install this code:

Copy bank.c and bank.h to your src directory. Add bank.c, bank.h
and bank.o to the appropriate sections in your Makefile.

2. In mud.h, find the pc_data structure, and add the following to it:

int balance;

Find the following:

#define LEVEL_HIGOD LEVEL_GOD

and after it add: #include "bank.h"

find the ACT flags for mobiles, and define
ACT_BANKER using an available slot.

3. In save.c, function fwrite_char, find the following line:

fprintf( fp, "Favor %d\n", ch->pcdata->favor );

Add the following line below it:

fprintf( fp, "Balance %d\n", ch->pcdata->balance );

Locate function load_char_obj, find the following line:

ch->pcdata->wizinvis = 0;

Add the following line below it:

ch->pcdata->balance = 0;

Locate function fread_char, find the following line:
KEY( "Bamfin", ch->pcdata->bamfin, fread_string_nohash( fp ) );

Add the following line above it:

KEY( "Balance", ch->pcdata->balance, fread_number( fp ) );

4. In build.c, find the act_flags for mobs, and add "banker" in the
spot corresponding to the new ACT_BANKER flag you defined in mud.h.

5. Make the appropriate additions to tables.c for
do_balance, do_withdraw, and do_deposit.

6. Add the text from bank.help to your help.are file.

7. Make clean, then recompile.

8. Create commands for balance, deposit, and withdraw.

9. Set the banker flag on a mob of your choice.
Amended on Tue 02 Mar 2004 04:58 AM by Ithildin
Australia Forum Administrator #14
See this post:

http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=3653

If you have followed the instructions, and done a make, and are using the new version, then you probably need to use gdb to find exactly what is wrong.
USA #15
hrm..well, i just added this snippet to smaugfuss and it worked. i did exactly the same thing as i did on my windows smaug. oh well, thanks for helping out here. i think i'm going to switch everything over to smaugfuss. it seems to be a lot more stable anyways.