hey all, I'm just playing around at this stage and trying to familiarize myself with the code
one thing I figured I'd try to do first is add a new shop
These are the steps I took:
In defines.h
Then in init1.c
Then in edit/store.txt
Then when I compiled and booted, I got an error message during the boot process.
This struck me as odd, since Store 6 was one of the stock stores which I didn't touch. So sure enough I counted and noticed that there were only 28 items listed in the shop. So to deal with this quickly, I made the following change:
So then the program booted, and I made a new character, then when I was finished rolling my character and naming it. I had a crash
From my debugger, I see that st_ptr->table is NULL. So that makes it obvious why the crash is happening.
I'm guessing that this value was initialized to NULL somewhere but wasn't set to a meaningful value along with the other stores like it needs to be.
I'm new to the code, so I was hoping someone could help me discover the solution?
Thanks!
Note: I realize that the store will not appear in town with just these changes.
one thing I figured I'd try to do first is add a new shop
These are the steps I took:
In defines.h
Code:
/* * Total number of stores (see "store.c", etc) */ - #define MAX_STORES 8 + #define MAX_STORES 9 /* * Store index definitions (see "store.c", etc) */ #define STORE_GENERAL 0 #define STORE_ARMOR 1 #define STORE_WEAPON 2 #define STORE_TEMPLE 3 #define STORE_ALCHEMY 4 #define STORE_MAGIC 5 #define STORE_B_MARKET 6 - #define STORE_HOME 8 + #define STORE_KYLE 7 + #define STORE_HOME 8
Code:
} } if (2 != sscanf(buf, "S:%d:%d", &num, &slots)) return PARSE_ERROR_GENERIC; - if (num < 2 || num > 6) + if (num < 2 || num > 7) return PARSE_ERROR_GENERIC; error_idx = num;
Code:
# Magic-user's S:6:29 I:1:ring:Searching I:1:ring:Feather Falling I:1:ring:Protection I:1:amulet:Charisma I:1:amulet:Slow Digestion I:1:amulet:Resist Acid #I:1:rod:Trap Location #I:1:rod:Door/Stair Location #I:2:rod:Treasure Location I:1:wand:Slow Monster I:1:wand:Confuse Monster I:1:wand:Sleep Monster I:1:wand:Magic Missile I:1:wand:Stinking Cloud I:1:wand:Wonder I:2:staff:Teleportation I:2:staff:Identify I:1:staff:Light I:1:staff:Mapping I:1:staff:Detect Invisible I:1:staff:Detect Evil I:3:magic book:[Magic for Beginners] I:2:magic book:[Conjurings and Tricks] I:2:magic book:[Incantations and Illusions] I:1:magic book:[Sorcery and Evocations] + +# Kyle's +S:7:1 +I:1:ring:Searching
Code:
Store 6 has too few entries (read 28, expected 29). -more-
Code:
# Magic-user's S:6:29 -I:1:ring:Searching +I:2:ring:Searching I:1:ring:Feather Falling
Code:
static s16b store_get_choice(int st) { int r; store_type *st_ptr = &store[st]; /* Choose a random entry from the store's table */ r = randint0(st_ptr->table_num); /* Return it */ return st_ptr->table[r]; [b]<----- crash occured on this line[/b] }
From my debugger, I see that st_ptr->table is NULL. So that makes it obvious why the crash is happening.
I'm guessing that this value was initialized to NULL somewhere but wasn't set to a meaningful value along with the other stores like it needs to be.
I'm new to the code, so I was hoping someone could help me discover the solution?
Thanks!
Note: I realize that the store will not appear in town with just these changes.
Comment