First problem to boggle me so badly.. hence my first post here. Hi. I decided to add in elemental resistances to the code base I'm toying with, and did it (successfully!) by using one of the int spares in struct special_data_saved as an array resistances[10]. After going through the necessary code to modify spell damage based on its elemental nature, I was convinced everything would work fine when I moved the array over to char_special_data_saved, so both PCs /and/ NPCs could have resistances. So I added an int array resistances[10] to said struct, removed it from its previous struct, and made the necessary change in utils.c. After wiping the pfile (just one player, heh.. me.), I logged on and statted myself to see if all was well. Turned out all my resistance percentages were set to 0, except for resistance[5], which was something like 137198217. *boggle* Attempting to set that particular resistance to any value (via do_set) crashed the mud, but I could set any other resistance. Thinking I might have created the array right on top of some stray data already in memory, I changed the array from type int to sh_int, which is what apply_saving_throw[5] is, right above it in the code. I guess this was my lame attempt to use less memory and hopefully not run across that unaccounted-for data. Compiled, wiped, and logged in again. This time, resistance[6] was at -6732 and resistance[7] was at 2900, but all the other members of the array, including resistance[5], were at 0. Again, trying to set the resistances with wiz commands caused a crash. I even tried to initialize all the values of the array upon character creation in roll_real_abils (which didn't work) and in do_start (which crashed the mud right before advancement to level 1). No cigar. I'm vaguely aware of things called 'malloc' and 'calloc', but don't know if they would solve my problem or how to use them, as I am a semi-newbie to C (but not a /complete/ dumbass ;). Any suggestions? c +------------------------------------------------------------+ | Ensure that you have read the CircleMUD Mailing List FAQ: | | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html | +------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 12/15/00 PST