Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incompatible with Alpha v0.21 Saves #5

Open
ckabalan opened this issue Aug 13, 2021 · 2 comments
Open

Incompatible with Alpha v0.21 Saves #5

ckabalan opened this issue Aug 13, 2021 · 2 comments

Comments

@ckabalan
Copy link
Owner

There was a SIGNIFICANT re-write in how saving works in Melvor Idle with Alpha v0.21. Old saves were just gzipped JSON files. New saves are smaller serialized objects which require significant portions of the game code to read.

I will work on this "soon" but after playing with it for a few hours this looks to be a bigger task.

If anyone knows of an open source project that is working with these saves outside of the Melvor game code please post here.

Pull requests also welcome!

@cdd1
Copy link

cdd1 commented Aug 13, 2021

Hi, since I really enjoy using your tool, I had a quick look at it. I could get it working for my savefile with some very minimalistic changes, although them being not clean.

The saved data is stored as arrays now:

  • item stats: saveJSON['ns'][3][0]
  • monster stats: saveJSON['s'][21]
  • pet stats: saveJSON['s'][22]

By reassigning them to the original saveJSON, it almost worked (not sure whether these safety checks are of any use):

saveJSON['itemStats'] = (saveJSON['ns'] && saveJSON['ns'][3] && saveJSON['ns'][3][0]) ?? [];
saveJSON['monsterStats'] = (saveJSON['s'] && saveJSON['s'][21]) ?? [];
saveJSON['petUnlocked'] = (saveJSON['s'] && saveJSON['s'][22]) ?? [];

The data for pets is the same, but the array for items and monsters contain more data. So I updated the functions to check the right column. For items this is the first column of 3. For monsters, it's the third column of 10.

    function getMissingItemIDs(itemStats) {
        var missingIDs = []
        itemStats.forEach(function(item, index) {
            if (item == 0 && index%3 == 0) {
                missingIDs.push((index/3).toString())
            }
        });
        return missingIDs;
    }
    function getMissingMonsterIDs(monsterStats) {
        var missingIDs = Object.keys(melvorData['monsters']);
        var missingIDs = []
        monsterStats.forEach(function(monster, index) {
            if (index%10 == 2 && monster == 0) {
                missingIDs.push(((index - index%10)/10).toString())
            }
        });
        return missingIDs;
    }

With these minimal changes, it worked for me. But it's very fragile. The column order is found in https://melvoridle.com/assets/js/game/serializeSave.js?989. This might change in the future as it's decided by the game version (currently 3) which decides the order of fields: serialVars[currentSaveVersion]

I did not check where it's decided how many subtables there are. Since it's potentially dynamic, it could break quite easily, even with patch updates. For items, the second and third column are respectively quantity sold and GP gained.

@ckabalan
Copy link
Owner Author

ckabalan commented Aug 14, 2021

@cdd1 I cannot overstate how awesome this feedback is. I've updated the site with your fix (53a506d). You're right this is likely is fragile, but I wanted to get it up and running immediately. I am going to leave this open for some improvements. I believe I can use the "tooling" side of the repo to bring in the serialVars to make it more reliable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants