Save Data Corruption

Status
Not open for further replies.

Capitán

kind of a big deal
Veteran
Joined
Jul 9, 2013
Messages
572
Reaction score
145
First Language
Engilsh
Primarily Uses
RMMV
Before I get into this I would like to preface by saying this is not a save editing question I am working on a system for my game and it needs a bit of save data manipulation,

When I open a .rpgsave file it is filled with letters that mean nothing to me, when I copy the contents of that file and then delete it, I start my game and my game creates a new a file with those exact contents the save file becomes corrupted, and I get an error that looks something like this

1604391358355.png

Why is this happening?
 

Hyouryuu-Na

Sapphire Sodium- Probably the laziest dev here
Veteran
Joined
Jun 15, 2017
Messages
1,034
Reaction score
2,422
First Language
Not English
Primarily Uses
RMMV
How exactly are you writing the file? Can you share the events/scripts?
 

Capitán

kind of a big deal
Veteran
Joined
Jul 9, 2013
Messages
572
Reaction score
145
First Language
Engilsh
Primarily Uses
RMMV
For testing purposes I am writing the file using the node module fs

like so
fs.writeFileSync('./save/file1.rpgsave', saveData)
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,756
Reaction score
7,862
First Language
German
Primarily Uses
RMMV
when a savefile is created, a lot of data goes into it. Not only what you see in the default, but also what is added there by plugins.
Unfortunately most of the plugin programmers take the easy way to handle saving their data by adding it to objects that are automatically saved, and not installing their own saveguards for data security.
that basically means that ANY change in the plugin manager - including adding, removing and reordering plugins - has a very high chance of making the savefile incompatible, creating similar errors to what you displayed.

which basically means that you can't even be sure the error is caused by what you assume it was caused.
If you changed anything else in the plugin manager before writing that savefile (like adding a plugin that handles your save-modifications) then that already makes your old data incompatible.

your only chance to get on with this would be to have all the other plugins you need installed and working, then add a placeholder with most of the data for the plugin that you want to use to modify savegames, and only after that start to analyse the savedata inside the savefiles.
Because any analysis you make will become incompatible as soon as you add another plugin or do something similar.
 

Hyouryuu-Na

Sapphire Sodium- Probably the laziest dev here
Veteran
Joined
Jun 15, 2017
Messages
1,034
Reaction score
2,422
First Language
Not English
Primarily Uses
RMMV
I've done similar things before where I had to overwrite save files and this never happened to me so the method you're going for should be working. I guess there must be something wrong with the contents of the saveData variable. You said you're manipulating the save data. Maybe that messed it up.
you can try doing what Andar suggested. Maybe it will help.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,756
Reaction score
7,862
First Language
German
Primarily Uses
RMMV
there is something else I just thought of that might have messed with the data - especially if you're using a text editor to get that.

Data is often stored as bytes - one of which can be a number between 0 and 255.
There are tables on the computer that assigns some letters to most of those numbers, but not all - which results in several different numbers to be displayed as "unidenfitief letter" (the box) when opening it with a text editor.
Additionally, there are several different tables for that assignment - ANSI, UTF-8, UTF-16 and more. You can select that codetable when saving a text in the editor at the bottom of the file window.

Now if the letters are saved in a different coding that the browser assumed them to be, you suddenly got the numbers messed up and corrupted.

That is also something you should look at when trying to find the cause of the error.
 

Capitán

kind of a big deal
Veteran
Joined
Jul 9, 2013
Messages
572
Reaction score
145
First Language
Engilsh
Primarily Uses
RMMV
It seems @Andar 's first diagnosis was correct, these save files are extremely volatile and the slightest change within the scripts causes corruption. I couldn't start the game because there is no new game option on my title screen only loading that one save file and the only way to get past that was for me to enable a script that skips my title screen, thus breaking the save file.
 

Capitán

kind of a big deal
Veteran
Joined
Jul 9, 2013
Messages
572
Reaction score
145
First Language
Engilsh
Primarily Uses
RMMV
Sorry for the double post but I just wanted to say that I lied and a combination of @Andar 's second diagnosis and @Hyouryuu-Na 's insight was actually the problem, so a simple console log of the saveData variable showed me that the save data was actually being saved as a Buffer object as opposed to text using saveData.toString('utf8') I was able to load my save file flawlessly!

Thank you for the help!
 

slimmmeiske2

Little Red Riding Hood
Global Mod
Joined
Sep 6, 2012
Messages
8,011
Reaction score
5,325
First Language
Dutch
Primarily Uses
RMXP

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

 
Status
Not open for further replies.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

The second draft of my script is almost done, and I don't think I'm going to write a third draft. I'll make changes to dialogue here and there, but I'm happy with the series of events the way they are.
How you feel about font and dialogue box changing for every main character while the minor cast and regular npc get their own styles? Too much?
Just found an obviously custom effect (i.e. edited by me) in my resources>sounds folder called "rip jaw off". Dear Lord what is wrong with me as a person that at some point I needed a sound *specifically* for THAT??
(...rhetorical question.)
so like with the whole 'familiarity breeds contempt thingy', how are you supposed to tell if your title screen/battle music gets really tedious after a few dozen plays or if you're just personally hella sick of it?

Forum statistics

Threads
107,520
Messages
1,030,237
Members
139,646
Latest member
JesuProYT
Top