Page 1 of 1

External file weirdness

Posted: Tue Aug 28, 2012 11:18 pm
by Ice Cream Jonsey
I have the following happening:

1) A player can create a character.
2) A player can export that character to a file. In this, I am exporting values like the character's name, strength, intelligence, etc.
3) That file can be read successfully
4) The values for the character are populated successfully

So that's RPG stuff, no prob there.

What I think is happening is this: if I declare an array in the game and recompile, suddenly the character info being read contains lots of garbage strings.

So I've got:

- version 0.40 of the game (or whatever) reading and writing characters to disk OK.
- In version 0.41 I declare an array of FatChicks[10] and set it to zero.
- I recompile
- I start the game up, version 0.41
- I can now no longer read the previously-written-to-disk characters.

This seems a little weird to me. But I don't know how it writes those files. I mean, I know what *I* put in them, but is it storing memory addresses as well? Would that explain how things got screwed up?

If I go and create a new character with version 0.41, the newly-created characters import fine.

This isn't a blocker or anything. I anticipated making tens of thousands of characters while developing this game. I am just curious if this seems like reasonable behavior.

Posted: Wed Aug 29, 2012 12:49 am
by Roody_Yogurt
Ok, I'm not sure I'm entirely understanding you. You're saying, you have .40 writing one thing to file, then .41 adding one more thing (even though it's just set to 0) and it's ruining the values of everything?

If so, I've also noticed some inconsistencies in behavior if I have made any changes to what is being written. I think in such cases, you really ought to delete your external files and start anew. Once you get to a point where what is being written doesn't change, you should be fine, though.

I guess Kent should take this one.

Posted: Wed Aug 29, 2012 12:56 am
by Roody_Yogurt
Ok, reading it again, I think I get what you're saying. The mere existence of a new array is messing up the memory map or whatever.

If possible, I'd try declaring all new stuff after the stuff being written to file; maybe that'd help preserve pointer locations over more revisions.