AnonymousHero wrote:Are the spell_level values always wrong immediately after starting? Or only after saving and reloading?
Immediately after starting.
Do you mean "spell_level[realm][spell]" literally, and if so, do both the "realm" and "spell" variables start at 0? Is even spell_level[0][0] corrupted?
Yes, yes, and apparently yes.
Is the spell_level array declared with the appropriate dimensions?
Hmm, looks like it is...
There are several general techniques you can try to find memory corruption problems:
1) Try compiling with "-Wall" and see where warnings pop up. They sometimes point to severe problems, especially if you're looking at .
Okay, though keep in mind T1 is already producing huge numbers of warnings.
2) Try compiling with Clang + "-Wall" and check warnings. Clang sometimes flags things GCC doesn't catch. (Plus it generally has much better error messages.) If you're using Ubuntu (e.g.) installing "Clang" should be as easy as "aptitude install clang".
No easy access to Clang unfortunately.
3) You can try one of the graphical debuggers out there and set a breakpoint somewhere appropriate to inspect values interactively; this is sometimes very helpful for understanding what's going on.
Okay...
4) Try using Valgrind. I haven't really even used it myself, so I'm not really sure how user-friendly it is; YMMV.
I'll check that out too then.
As to the bit about "byte/int16/etc.". These days I think you're probably right and most of that should just be plain "int" or "long"; it's hardly worth saving a byte here and there to risk introducing implicit conversion errors.
Like I said, bytes and 16-bit ints are used all over the place... How, if at all, do you think I should go about replacing them?