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

Veteran
Veteran
Joined
Jun 15, 2017
Messages
1,040
Reaction score
2,432
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,784
Reaction score
7,875
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

Veteran
Veteran
Joined
Jun 15, 2017
Messages
1,040
Reaction score
2,432
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,784
Reaction score
7,875
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,020
Reaction score
5,332
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.

Latest Threads

Latest Posts

Latest Profile Posts

Not sure if it's true (and I won't judge or blame anyone if it is, really), but I heard from confident sources that you guys (and girls) really really like to
How is this new year for everyone? Hope you are well. Still deep in Covid in the US. Its like a vampire and refuses to die with even more strains. I need some holy water to kill it with.
in my game, what's known as HeadSpace is combining with the real world...
oh looks like the forums updated while I wasn't looking and we can put a banner now. Neat!
Treating this as a devlog

Forum statistics

Threads
107,664
Messages
1,031,250
Members
139,789
Latest member
tigraroe
Top