Extra Save Files

Lihinel

Veteran
Veteran
Joined
Nov 9, 2013
Messages
261
Reaction score
321
First Language
German
Primarily Uses
While looking for ways to add my own data to the save file, I noticed, that there is a character limit to save files:
Code:
DataManager.saveGameWithoutRescue = function(savefileId) {
    var json = JsonEx.stringify(this.makeSaveContents());
    if (json.length >= 200000) {
        console.warn('Save data too big!');
    }
    StorageManager.save(savefileId, json);
    this._lastAccessedId = savefileId;
    var globalInfo = this.loadGlobalInfo() || [];
    globalInfo[savefileId] = this.makeSavefileInfo();
    this.saveGlobalInfo(globalInfo);
    return true;
};
After some web searching I only found a few topics on this, one mentioned that this 200000 limit is because of parser issues when files get longer than that. One topic also mentioned reaching this limit on a 101x100 or so map with 100 events.

I don't plan to have that many events on a map, but it made me a bit nervous about just putting my own save data into the regular file.

What I do might have are files that look like this in json:
Code:
[
[ {"x":100,"y":100,"waiting":12000,"busy":120}, {"x":120,"y":120,"waiting":7000,"busy":110} ],
[ {"x":12,"y":200,"waiting":14000,"busy":170} ]
]
They store the minimum amount of information I need if I want to recreate the Townbuilding I have in VXAce in MV.
So a single building is about {"x":100,"y":100,"waiting":12000,"busy":120} which is length 44. Lets be a bit generous and assume 20 buildings for each town and 10 towns each in 7 regions, we are already at ~ 62000 charcters not counting , and [].

From what I have read in the past 2 Threads there are probably 2 ways to save, one for desktop and one for all deployment.

So should I try and create my own save files in addition to the default ones to store that data and edit the DataManager functions based on the existing DataManager functions, or is there again a better way, thats just wasn't picked because it didn't exist in the old version of JS that was used when MV was created?
 

Poryg

Dark Lord of the Castle of Javascreeps
Veteran
Joined
Mar 23, 2017
Messages
4,125
Reaction score
10,640
First Language
Czech
Primarily Uses
RMMV
The reason 200000 is the limit is because some browsers' JSON parsers use memory buffers of this size (or at least they used to in past). I haven't had any problems on Chromium based browsers with larger files, but I did not try to push my luck to what's the max size they can parse without an issue. MV still needs to carry this warning to ensure as much compatibility with various browsers as possible anyway.
Nevertheless, there are always solutions. In fact this problem in particular can be solved simply by separating the file into multiple smaller ones and loading them individually if needed.
So it's not whether you should or should not, it's whether you need or need not. And I assume you can answer this question yourself, since who knows better the length of savefiles in your game than you?
 

Aloe Guvner

Walrus
Veteran
Joined
Sep 28, 2017
Messages
1,628
Reaction score
1,115
First Language
English
Primarily Uses
RMMV
Eh, it's just a warning and 200 000 byte limit is arbitrary. I would not worry about it.

For theoretical purposes, the maximum length of a string in JS is roughly 1GB which is 10 000x larger (4 orders of magnitude larger) than that "limit". Of course I would not recommend something so big because it would require a large amount of RAM.

If you want to see the maximum length of a string, it depends on the environment, but you could test it with something like:
Code:
var str = 'a';
while (true) {
    str += str;
    console.log(str.length);
}
For me it crashed somewhere more than 500MB
 

Lihinel

Veteran
Veteran
Joined
Nov 9, 2013
Messages
261
Reaction score
321
First Language
German
Primarily Uses
Thanks to both of you.
I'll just go with adding new save data to the regular file for now, if I encounter any problems I can change it later on.
 

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

Latest Threads

Latest Profile Posts

Our latest feature is an interview with... me?!

People4_2 (Capelet off and on) added!

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.
Can someone recommend some fun story-heavy RPGs to me? Coming up with good gameplay is a nightmare! I was thinking of making some gameplay platforming-based, but that doesn't work well in RPG form*. I also was thinking of removing battles, but that would be too much like OneShot. I don't even know how to make good puzzles!
one bad plugin combo later and one of my followers is moonwalking off the screen on his own... I didn't even more yet on the new map lol.

Forum statistics

Threads
106,035
Messages
1,018,454
Members
137,821
Latest member
Capterson
Top