Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ SMAUG ➜ SMAUG coding ➜ Need help!

Need help!

It is now over 60 days since the last post. This thread is closed.     Refresh page


Pages: 1  2  3 4  5  

Posted by Greven   Canada  (835 posts)  Bio
Date Reply #30 on Thu 12 Feb 2004 03:52 PM (UTC)
Message
Also, you want to make sure that your setting change somewhere if they don't enter all, cause it might really screw up how much copper they have if they do it manually.

Nobody ever expects the spanish inquisition!

darkwarriors.net:4848
http://darkwarriors.net
Top

Posted by Toy   (206 posts)  Bio
Date Reply #31 on Thu 12 Feb 2004 10:09 PM (UTC)
Message
I know this is gonna probably make me sounds really dumb, but I'm having a problem with gdb. I don't understand how to use it. I tried reading it's help files, and I tried following Nick's post. Can someone gimme some help?

-Toy

It's always good to know how far you are willing to go to be the best...

Karl Mancine
aka
Toy the Dark Puppet
Top

Posted by Nick Gammon   Australia  (23,165 posts)  Bio   Forum Administrator
Date Reply #32 on Thu 12 Feb 2004 10:35 PM (UTC)
Message
It is almost impossible to solve "a problem".

You need to post a screendump of what you see so we can see what is happening.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Toy   (206 posts)  Bio
Date Reply #33 on Fri 13 Feb 2004 12:27 AM (UTC)
Message
*chuckle* I'm sorry, I misworded that. What I ment was I can't figure out how to use gdb at all. I attempted to follow your post on how to use the debugger, but I couldn't even follow that. And until I get an understanding of how to use gdb, I'm pretty much stuck.

-Toy just can't figure anything out today...

It's always good to know how far you are willing to go to be the best...

Karl Mancine
aka
Toy the Dark Puppet
Top

Posted by Nick Gammon   Australia  (23,165 posts)  Bio   Forum Administrator
Date Reply #34 on Fri 13 Feb 2004 03:09 AM (UTC)
Message
I still prefer to point you in the direction of solving the problem for yourself, then you can solve 100 problems in the time it takes to get one done by someone else on the forum.

In what way are you having problems with gdb? Is it not installed? Does it give an error message? If so, what is it?

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Toy   (206 posts)  Bio
Date Reply #35 on Fri 13 Feb 2004 05:31 AM (UTC)
Message
Well, I looked up your post of how to debug with gdb, I read down till the part where it said that you can turn on the program with gdb. so I switched into the src folder and attempted to run smaug like this:

gdb smaug
run

it started to run, hit the area.lst section of the mud's startup and stopped because the files for the area weren't in there. I even went so far as to put the area files into the src directory, the game started up, but then nothing happened. It was like I had simply started the .exe file. I couldn't do any gdb commands.

-Toy

It's always good to know how far you are willing to go to be the best...

Karl Mancine
aka
Toy the Dark Puppet
Top

Posted by Greven   Canada  (835 posts)  Bio
Date Reply #36 on Fri 13 Feb 2004 05:35 AM (UTC)
Message
Ok, heres what you do:

in the area directory, do this:

gdb ../src/smaug
run (port)

This SHOULD boot the mud, and allow you log into the game. Then, inside GDB, hit ctrl+c, and it should pause the game, and give you a prompt. From there you can probably follow Nick's guide to set a breakpoint inside of your function, and go from there.

Hope that help.

Nobody ever expects the spanish inquisition!

darkwarriors.net:4848
http://darkwarriors.net
Top

Posted by Nick Gammon   Australia  (23,165 posts)  Bio   Forum Administrator
Date Reply #37 on Fri 13 Feb 2004 05:39 AM (UTC)
Message
Yes, since you can't normally run SMAUG itself from the src folder you can hardly expect to debug it from there.

Greven is right, however you probably don't need a port number.

Just go to the area directory, and type:

../src/smaug

Set your breakpoints (in your case the problem function) and then type "run".


eg.

break do_change
run



- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Toy   (206 posts)  Bio
Date Reply #38 on Fri 13 Feb 2004 05:53 AM (UTC)
Message
Ok, I did what you said, I logged in and attempting to change silver, and I got this in gdb

Breakpoint 1, do_change (ch=0xa2577e8, argument=0x22f8d7 "2000 silver")
at bank.c:404
404 if ( !( banker = find_banker( ch ) ) )

then I used backtrace and got this:

#0 do_change (ch=0xa2577e8, argument=0x22f8d7 "2000 silver") at bank.c:404
#1 0x004c8c11 in interpret (ch=0xa2577e8, argument=0x22f8d7 "2000 silver")
at interp.c:730
#2 0x0047e8b0 in game_loop () at comm.c:640
#3 0x0047de7f in main (argc=1, argv=0xa041d60) at comm.c:291

um.. so as 'm not very familiar with this, I'm guessing there is errors in bank.c, interp.c, and comm.c when I do_change?

-Toy

It's always good to know how far you are willing to go to be the best...

Karl Mancine
aka
Toy the Dark Puppet
Top

Posted by Greven   Canada  (835 posts)  Bio
Date Reply #39 on Fri 13 Feb 2004 06:15 AM (UTC)
Message
no, backtrace just gives you where the command came from: the game was started in comm.c, your command went through the intererate function in interp.c, and that called do_change.

From here, you want to type n or next to go to the next executable line. It will pause here, lets say it displays:
Quote:
change = silver%10000;
You can type "print silver" and "print change" to see that the variables are right. If they are, follow the next step, and keep checking that everything is right. This should show you how/why its not working when it doesn't go to the place you think it should.

Nobody ever expects the spanish inquisition!

darkwarriors.net:4848
http://darkwarriors.net
Top

Posted by Nick Gammon   Australia  (23,165 posts)  Bio   Forum Administrator
Date Reply #40 on Fri 13 Feb 2004 06:29 AM (UTC)
Message
Exactly!

You might want to display your important fields:

p ch->silver
p ch->gold
p arg1

And so on, and checking that each is what you expect. If so, keep stepping through the function (type "next" or "n") until you get to a place where one should change (eg. "amount") but doesn't, or doesn't change the way you thought it would. Then look very carefully at the line in question.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Toy   (206 posts)  Bio
Date Reply #41 on Fri 13 Feb 2004 06:41 AM (UTC)
Message
OK, I think I'm doing this right, lemme post what I've gotten:

Breakpoint 1, do_change (ch=0xa2577e8, argument=0x22f8d7 "all silver")
at bank.c:404
404 if ( !( banker = find_banker( ch ) ) )
(gdb) n
410 if ( IS_NPC( ch ) )
(gdb) n
417 if ( argument[0] == '\0' )
(gdb) n
423 argument = one_argument( argument, arg1 );
(gdb) n
424 argument = one_argument( argument, arg2 );
(gdb) n
435 if ( !str_cmp( arg2, "silver" ) )
(gdb) n
437 if ( str_cmp(arg1, "all") && !is_number( arg1 ) )
(gdb) n
444 if ( !str_cmp( arg1, "all" ) )
(gdb) n
446 amount = ch->silver/100;
(gdb) print amount
$1 = 2281472
(gdb) n
447 change = ch->silver%100;
(gdb) print change
$2 = 2280356
(gdb) n
453 if ( amount > ch->silver )
(gdb) print silver
$3 = silver
(gdb) n
461 ch->gold += amount;
(gdb) print amount
$4 = 20
(gdb) n
462 ch->silver = change;
(gdb) print change
$5 = 0
(gdb)

Now, if I'm reading correctly if I used change all silver, it looks like it works correctly, but these lines confuse me:

446 amount = ch->silver/100;
(gdb) print amount
$1 = 2281472
(gdb) n
447 change = ch->silver%100;
(gdb) print change
$2 = 2280356

can you explain those to me?

-Toy

It's always good to know how far you are willing to go to be the best...

Karl Mancine
aka
Toy the Dark Puppet
Top

Posted by Toy   (206 posts)  Bio
Date Reply #42 on Fri 13 Feb 2004 06:43 AM (UTC)
Message
Quick side note: I logged into the game outaide the debugger and used "change all silver" on 2000 silver. On the character's file it changed to 20 gold and no silver, which is fine, but it gave me this message:

You change 0 silver into 2295260 gold coins.

-Toy

It's always good to know how far you are willing to go to be the best...

Karl Mancine
aka
Toy the Dark Puppet
Top

Posted by Nick Gammon   Australia  (23,165 posts)  Bio   Forum Administrator
Date Reply #43 on Fri 13 Feb 2004 06:55 AM (UTC)
Message
Quote:

446 amount = ch->silver/100;
(gdb) print amount
$1 = 2281472


I'm pretty sure it does the line you are seeing *after* you press "next" - that is, this is the line that is about to be executed.

Thus, you need to display "amount" *after* that line (press n one more time) - the figure you see there is just the uninitialized variable before the statement is executed.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Nick Gammon   Australia  (23,165 posts)  Bio   Forum Administrator
Date Reply #44 on Fri 13 Feb 2004 06:56 AM (UTC)
Message
You are going well, you almost have it solved.

Just make sure you print the correct variables. Looks like you should be typing:

p ch->silver

not

p silver

- Nick Gammon

www.gammon.com.au, www.mushclient.com
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.


156,259 views.

This is page 3, subject is 5 pages long:  [Previous page]  1  2  3 4  5  [Next page]

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.