PatcailMemer / Ordinal-Markup

The Github version of Ordinal Markup
MIT License
29 stars 53 forks source link

Lack of save in localStorage breaks new game #21

Open zephyron1237 opened 3 years ago

zephyron1237 commented 3 years ago

I tried to start this game today, and was confused that nothing was working until I noticed a javascript error:

Uncaught SyntaxError: Unexpected token u in JSON at position 0
    at JSON.parse (<anonymous>)
    at load (saveload.js:127)
    at script.js:132

I looked into it and noticed that this line is the issue:

JSON.parse(localStorage[(inPublicTesting()?"ordinalMarkupPublicTestingSave":"ordinalMarkupSave")])

On a fresh device, localStorage["ordinalMarkupSave"] returns undefined, and JSON.parse(undefined) throws the given Exception. Because this exception is thrown, the entire game is broken.

I was able to fix this for myself by running the command localStorage["ordinalMarkupSave"] = "{}" and then reloading, but that's unideal for new players.

In case it's helpful, this was done in Chrome 87.0.4280.66 on Windows.

Ilovetoocode commented 3 years ago

I RAN INTO THIS AS WELL!