![]() |
#51 |
DaJAngband Maintainer
Join Date: Apr 2007
Location: San Antonio, TX
Posts: 1,007
Donated: $10
![]() |
How do I know if it's writing beyond the boundaries of an array?
and How do I know what the boundaries are? When I first started making DaJAngband, I just discovered the txt files in the lib folder (the subfolder was called something other than gamedata at that point), and changed some things and added some new monsters. I posted about making changes in the txt files on here, and someone suggested I make my own variant. I said I can't do that I know only the barest basics of C, but they said something to the effect of Oh it isn't hard, you can probably figure a lot of things out by the comments. So I looked at the code, and the comments were so thorough in saying what the code was doing, that I could figure out how to customize a lot of stuff in the code. I'm a meddler, not a programmer, but I made my own variant before. I can do it again (with the help of the nice people here).
__________________
Will_Asher aka LibraryAdventurer My old variant DaJAngband: http://sites.google.com/site/dajangbandwebsite/home (defunct and so old it's forked from Angband 3.1.0 -I think- but it's probably playable...) |
![]() |
![]() |
![]() |
#52 | |
Adept
Join Date: Aug 2019
Posts: 136
![]() |
Quote:
As for the second question, the boundaries are set when the memory allocation happened - with the size that was passed to the allocator. Besides finding a tool to help detect the source of the memory corruption, manually reviewing your changes, while time-consuming, will likely help. Did the parts you added to the player structure involve dynamic allocation (likely if they are pointers)? If so, check that the size specified for allocation is the right one. Try to identify the lifetime of what was allocated - when is it allocated and when is it released. Are there attempts to access it after it is released (either for reading, writing, or to release it again)? If so, that would be a problem. If you didn't add anything that required dynamic allocation, you would want to check your changes to the savefile loading. Are the loads of the right size and not overflowing the destination memory? |
|
![]() |
![]() |
![]() |
#53 |
DaJAngband Maintainer
Join Date: Apr 2007
Location: San Antonio, TX
Posts: 1,007
Donated: $10
![]() |
here's what I did. I added some things to the player struct in player.h like so
" s16b p_luck; /* Luck */ s16b slimed; /* slime level */ <a few more similar ones, all of them are s16bs> " then I added them to save.c and load.c like so " wr_s16b(player->p_luck); /* luck */ wr_s16b(player->slimed); /* slime */ ... " " rd_s16b(&player->p_luck); rd_s16b(&player->slimed); ... " oh and save.c had this " wr_s16b(0); wr_s16b(0); wr_s16b(0); wr_byte(0); " in that spot before with a corresponding " strip_bytes(7); " in load.c. I figured I didn't need that stuff and cut it out. hmmm... So just now I put those empty s16bs and the strip_bytes() line back in and ...it didn't make any difference. thought it was worth a try. Anyway, that's all I did to the savefiles. EDIT: and I don't know what "dynamic allocation" is. I didn't change anything that looked like it allocated or released anything.
__________________
Will_Asher aka LibraryAdventurer My old variant DaJAngband: http://sites.google.com/site/dajangbandwebsite/home (defunct and so old it's forked from Angband 3.1.0 -I think- but it's probably playable...) Last edited by will_asher; April 14, 2021 at 16:33. |
![]() |
![]() |
![]() |
#54 |
Vanilla maintainer
Join Date: Apr 2007
Location: Canberra, Australia
Age: 55
Posts: 8,760
Donated: $60
![]() |
That doesn't look like it would lead to memory issues in itself, but after the change it probably wouldn't load old savefiles correctly, which could conceivably have led to your problems. Have you tried with a fresh savefile?
__________________
One for the Dark Lord on his dark throne In the Land of Mordor where the Shadows lie. |
![]() |
![]() |
![]() |
#55 | |
DaJAngband Maintainer
Join Date: Apr 2007
Location: San Antonio, TX
Posts: 1,007
Donated: $10
![]() |
Quote:
(Adding a little blah blah because the forum won't let me post a 3-character reply.)
__________________
Will_Asher aka LibraryAdventurer My old variant DaJAngband: http://sites.google.com/site/dajangbandwebsite/home (defunct and so old it's forked from Angband 3.1.0 -I think- but it's probably playable...) |
|
![]() |
![]() |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
can we make identify more common ? | Sky | Vanilla | 16 | September 10, 2017 10:20 |
Make Artistry automatic | bagori nd | Sil | 4 | September 26, 2016 18:22 |
How many variant developers/maintainers have beaten their own variant? | Delver | Variants | 12 | June 5, 2009 09:08 |
Variant writing.. quickstart guide? Also, Hengband variant suggestions? | dzhang | Variants | 34 | April 1, 2009 00:45 |
Trying to make my own variant | bpleshek | Variants | 8 | September 15, 2008 20:42 |