Angband.oook.cz
Angband.oook.cz
AboutVariantsLadderForumCompetitionComicScreenshotsFunniesLinks

Go Back   Angband Forums > Angband > Variants

Reply
 
Thread Tools Display Modes
Old March 3, 2010, 08:25   #1
will_asher
DaJAngband Maintainer
 
will_asher's Avatar
 
Join Date: Apr 2007
Location: San Antonio, TX
Posts: 927
Donated: $10
will_asher is on a distinguished road
code help please

It took me a good bit of trial and error to figure out how to assign a random name to an individual ego item so that it looks like a randart. After a while, I finally got it to work, but now I can't save it in the savefile.
I have the random name saved as:
char o_ptr->randego_name
How can I save that in the savefile with the rest of the o_ptr stuff?
There's wr_byte and wr_s16b, etc. but no wr_char, and I don't know how to make one.

EDIT: If someone could do me a huge favor and write a wr_char function (and probably a rd_char function for load.c) for me, I'd be very grateful. All of the wr_xxxx functions are at the top of save.c.
__________________
Will_Asher

Play DaJAngband:
http://sites.google.com/site/dajangbandwebsite/home

Last edited by will_asher; March 3, 2010 at 09:20.
will_asher is offline   Reply With Quote
Old March 3, 2010, 11:45   #2
takkaria
Veteran
 
takkaria's Avatar
 
Join Date: Apr 2007
Posts: 1,859
Donated: $40
takkaria is on a distinguished road
Quote:
Originally Posted by will_asher View Post
It took me a good bit of trial and error to figure out how to assign a random name to an individual ego item so that it looks like a randart. After a while, I finally got it to work, but now I can't save it in the savefile.
I have the random name saved as:
char o_ptr->randego_name
How can I save that in the savefile with the rest of the o_ptr stuff?
There's wr_byte and wr_s16b, etc. but no wr_char, and I don't know how to make one.

EDIT: If someone could do me a huge favor and write a wr_char function (and probably a rd_char function for load.c) for me, I'd be very grateful. All of the wr_xxxx functions are at the top of save.c.
How about wr_string()?
__________________
"Physician, heal thyself."
takkaria is offline   Reply With Quote
Old March 3, 2010, 20:29   #3
will_asher
DaJAngband Maintainer
 
will_asher's Avatar
 
Join Date: Apr 2007
Location: San Antonio, TX
Posts: 927
Donated: $10
will_asher is on a distinguished road
Quote:
Originally Posted by takkaria View Post
How about wr_string()?
Whatever will allow me to save those random names in the savefile would be awesome.

EDIT: Oh. I just noticed there's already an wr_string() which I hadn't noticed. Would I need to declare o_ptr->randego_name as a cptr instead of a char? I don't know the difference between cptr and char. (The computer with my current DaJAngband stuff is not available at the moment or I'd go ahead and try it).
__________________
Will_Asher

Play DaJAngband:
http://sites.google.com/site/dajangbandwebsite/home
will_asher is offline   Reply With Quote
Old March 3, 2010, 21:01   #4
konijn_
Hellband maintainer
 
konijn_'s Avatar
 
Join Date: Jul 2007
Location: New York, the Big Apple
Age: 41
Posts: 367
Donated: $120
konijn_ is on a distinguished road
Quote:
Originally Posted by will_asher View Post
Whatever will allow me to save those random names in the savefile would be awesome.

EDIT: Oh. I just noticed there's already an wr_string() which I hadn't noticed. Would I need to declare o_ptr->randego_name as a cptr instead of a char? I don't know the difference between cptr and char. (The computer with my current DaJAngband stuff is not available at the moment or I'd go ahead and try it).
Assuming your code works, randego_name is probably char*, it should work.

T.
__________________
* Are you ready for something else ? Hellband 0.8.8 is out! *
konijn_ is offline   Reply With Quote
Old March 4, 2010, 05:20   #5
will_asher
DaJAngband Maintainer
 
will_asher's Avatar
 
Join Date: Apr 2007
Location: San Antonio, TX
Posts: 927
Donated: $10
will_asher is on a distinguished road
How do I find this bug?

Okay, now I have a completely different coding-related problem:

I had a game of DaJAngband on an older computer where I found a crash bug. So I brought the savefile over to the computer with my compiler/debugger on it to look for the bug, and it didn't crash. I tried making sure the old computer had the newest compile and the exact same files. So the two computers were using the exact same .exe file, the exact same files in the lib folder, and the exact same savefile, but it crashed on the older computer and didn't crash on the computer that has my compiler/debugger on it.
I haven't ever knowingly changed anything platform-specific in the code. Both computers are using Windows (although the older one has XP and the newer one has Vista). I don't understand why it would crash on one computer and not the other. How would I go about finding this bug?
__________________
Will_Asher

Play DaJAngband:
http://sites.google.com/site/dajangbandwebsite/home
will_asher is offline   Reply With Quote
Old March 4, 2010, 05:59   #6
Pete Mack
Prophet
 
Join Date: Apr 2007
Location: Seattle, WA
Posts: 5,010
Donated: $40
Pete Mack is on a distinguished road
If you have a working debugger, you can just track down where it crashes and see what caused the crash. If you don't (can't get gdb to work, etc), you may need to install Visual Studio Express and debug with that. It takes a while to get set up, but learning to debug with VS is a lot easer than with gdb.

Oh yeah, and if you do get it to work, please make the project file available for Angband. Things would be easier on windows if VS were officially supported.
Pete Mack is offline   Reply With Quote
Old March 4, 2010, 06:46   #7
will_asher
DaJAngband Maintainer
 
will_asher's Avatar
 
Join Date: Apr 2007
Location: San Antonio, TX
Posts: 927
Donated: $10
will_asher is on a distinguished road
Quote:
Originally Posted by Pete Mack View Post
If you have a working debugger, you can just track down where it crashes and see what caused the crash. If you don't (can't get gdb to work, etc), you may need to install Visual Studio Express and debug with that. It takes a while to get set up, but learning to debug with VS is a lot easer than with gdb.
My problem here is that it doesn't crash on the computer that has the debugger, so how do I track down where it crashes? It would be a lot of trouble to get the debugger onto the old computer because it isn't connected to the internet.

Quote:
Originally Posted by Pete Mack View Post
Oh yeah, and if you do get it to work, please make the project file available for Angband. Things would be easier on windows if VS were officially supported.
I had been using VS on (yet) another computer, but that computer kindof died, and I had problems installing VS on the computer I'm using now so I went back to using Dev C++. Its debugger isn't as good, but it does have one.
__________________
Will_Asher

Play DaJAngband:
http://sites.google.com/site/dajangbandwebsite/home
will_asher is offline   Reply With Quote
Old March 4, 2010, 08:43   #8
PowerDiver
Prophet
 
Join Date: Mar 2008
Posts: 2,712
PowerDiver is on a distinguished road
Quote:
Originally Posted by will_asher View Post
I don't understand why it would crash on one computer and not the other. How would I go about finding this bug?
The recent OS-related crash differences that I have read about here have been due to accessing bad pointers. If you read from a bad pointer, should that cause a crash or simply return an arbitrary result? Different OSes treat this differently. Whether that difference is true of Vista vs XP is beyond my knowledge.

You might try to track down recent fixes to V that fix these kinds of bugs. Perhaps someone with a better memory can list some of them for you. Unfortunately that won't help if you introduced the bug yourself.
PowerDiver is offline   Reply With Quote
Old March 4, 2010, 08:54   #9
Pete Mack
Prophet
 
Join Date: Apr 2007
Location: Seattle, WA
Posts: 5,010
Donated: $40
Pete Mack is on a distinguished road
I no longer have an XP box, so I can't help there.
MS does distribute an ISO you can burn, if you really get desperate, but it may not crash in a version recompiled in VS.

Otherwise, you can try valgrind if you have access to a linux account. It's very good at tracking down bad pointer use.
Pete Mack is offline   Reply With Quote
Old March 4, 2010, 14:58   #10
konijn_
Hellband maintainer
 
konijn_'s Avatar
 
Join Date: Jul 2007
Location: New York, the Big Apple
Age: 41
Posts: 367
Donated: $120
konijn_ is on a distinguished road
Quote:
Originally Posted by will_asher View Post
Okay, now I have a completely different coding-related problem:

I had a game of DaJAngband on an older computer where I found a crash bug. So I brought the savefile over to the computer with my compiler/debugger on it to look for the bug, and it didn't crash. <snip more stuff>
Greetings,

I would compile the game once more in Visual Studio and build a Debug version and try the debug version on your old machine. When it crashes, the Debug version should tell you at least in which file / line the crash happens.

T.
__________________
* Are you ready for something else ? Hellband 0.8.8 is out! *
konijn_ is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Code: Notes live where? camlost Vanilla 4 February 20, 2009 22:11
fun with the code (and a big thank you) will_asher Idle chatter 0 March 3, 2008 05:24
Screensaver needs to rewrite some code APWhite Vanilla 0 October 16, 2007 22:19
Looking through the code K.I.L.E.R Vanilla 5 July 11, 2007 09:01
The safe_setuid code CJNyfalt Vanilla 11 June 26, 2007 04:25


All times are GMT +1. The time now is 11:39.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2018, vBulletin Solutions Inc.