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).
Help me make my new variant! (please!)
Collapse
X
-
Eeek! The stack is the program's active memory-- when you subroutine gets called, it takes more space on the stack. Its memory is released when the routine exits. It also means the current set of subroutines that are active.
The heap is the program's long-term memory. It gets created and released in arbitrary order with malloc() (memory allocate) and free(). Each allocation has a fixed size, and if you write beyond it, your program eventually gets borked. There are two ways this commonly happens: writing beyond the boundaries of an array, and writing too long a string.Leave a comment:
-
Heap corruption means you borked the memory allocator, either with a write to freed memory, or with a buffer overrun. That particular error message suggests the debug allocator detected a buffer overrun, where you allocated insufficient space for a data structure. What does the stack look like at the time?
(I know what borked means at least. I definitely borked something.)Leave a comment:
-
Heap corruption means you borked the memory allocator, either with a write to freed memory, or with a buffer overrun. That particular error message suggests the debug allocator detected a buffer overrun, where you allocated insufficient space for a data structure. What does the stack look like at the time?Leave a comment:
-
thank you.
well.
I found almost that exact problem with the ampersands. So I fixed it, recompiled, and I'm still getting the same error popup...
(except the "at 0x..." number is different)Last edited by will_asher; April 13, 2021, 13:55.Leave a comment:
-
Code:rd_byte(tmp8u)
Code:rd_byte(&tmp8u)
Leave a comment:
-
I broke something somehow.
I went to open the game and test something, it compiles, it starts to run, then after character creation, I get this popup error window:
"Debug error
HEAP CORRUPTION DETECTED: after normal block (#213273) at 0x054BB1B8.
CRT detected that the application wrote to memory after end of heap buffer."
What does this mean? It sounds bad.
I added a couple things to savefiles in the player struct, but I thought I did it right...Leave a comment:
-
I guess the original idea was that other blow effects are more about the effect than the damage. Clearly that principal is not universal any more - as you say, CONFUSE blows often do a lot of damage, as do some high level DISENCHANT blows.Leave a comment:
-
Finding some kind of interesting things in the code I didn't know about before...
At the top of blow_effects.txt, it says:
"# eval - used for power evaluation in eval_blow_effect()"
But there is no eval_blow_effect(), and the eval appears to be unused.
Also, in mon-blows.c, I noticed armor reduces damage only for attacks that HURT, SHATTER, and partially for elemental attacks, but not any other blow effect.
Why is this?
(Also, is this why several high-level giants and such HIT to CONFUSE instead of HURT?)Last edited by will_asher; April 12, 2021, 15:25.Leave a comment:
-
Okay then. I can live with it. It just makes things a little harder for me.Leave a comment:
-
Will--
Putting data in configuration files is standard software practice. The types of spells (ball, beam, status effect, etc) are coded, but the spells themselves are not. This gets rid of enormous case blocks, which are not actually easy to read, and cut-and-paste programming, which is also a no-no. (Among other issues, it's a pain to test.)Leave a comment:
-
I want to add that changing some things, like adding new types monster spells, seems a lot more complicated now (at least for someone like me who isn't fluent in C) than it used to be before more things were put in the gamedata txt files.
EDIT: Also, I'm having a really hard time figuring out how to make pCONF a partial resist instead of completely immunity (only against CHAOS and a stronger confusion effect, won't be partial against the normal CONF spell or attack).Last edited by will_asher; April 10, 2021, 19:42.Leave a comment:
-
-
If you wanted to do this, you could mimic the way the code does it for shapes - add a modifiers entry to struct player_race, parse as in parse_shape_values(), copy the way calc_shapechange() handles modifiers into calc_bonuses(), probably add something in ui-entry.c for character sheet display. Or you could add it as another skill, like searching and digging.Leave a comment:
-
the explanation at the top of p_race says:
# 'values' is for object modifiers which take a value that races possess
# innately.
But the code only reads "RES_" values, so if you want to make a player race with innate extra speed, you have to do it another way. ppfffflt.Leave a comment:
Leave a comment: