Conversation
8398f66 to
a943ad1
Compare
|
Not sure how this got marked as a draft. I've been using this branch as my daily driver for some weeks now, and haven't encountered any more odd behavior. The only real head-scratcher is when leaving the floor into the mezzanine/perk shrine -- it feels like the save code generator is being called twice, but I haven't yet worked out how. Backup all your save codes before messing with this! |
ed8f0c9 to
351ab3a
Compare
c2c4f95 to
df89f00
Compare
9d2acef to
8cdf474
Compare
7762b2a to
eb29208
Compare
ba0d6df to
3519a71
Compare
cc38b3d to
d50559f
Compare
646af88 to
6e041d6
Compare
72ac5c4 to
03306d1
Compare
1ab8a1b to
bac8293
Compare
|
Im personally not a fan of making core functions async |
|
Perhaps a better solution would be to use something similar to the "Generating Map" screen, but intercepting mouse clicks instead of overriding the screen |
I'm not, either. Unfortunately, the compression facility is advertised as async-only, rather like the IndexedDB facility (which created a series of It may also be worth pointing out that I compressed not only game saves, but also outfits, so my PR touches more things. I will be reading @Zarniwoops' PR #247 with interest. |
|
I tried to keep my changes as minimal as I could. Which meant just the bulk save, and not the rest of the smaller save codes. Async is unavoidable, but the key here is that you can switch the main render screen to a "please wait / loading / saving", and let async come back in it's own time. If there's any interest, I can update the PR to be a clean merge... otherwise, I'll leave it as-is just for reference. |
Some brief experiments with CyberChef showed that changing from LZString to gzip CompressionStreams would not only be faster, but also result in smaller save codes. New save codes are `data:` URLs, base64-encoded. The MIME types are: - `application/vnd.straightlaced.kinkydungeon.save.game+gzip;version=2` - `application/vnd.straightlaced.kinkydungeon.save.outfit+gzip;version=2` - `application/vnd.straightlaced.kinkydungeon.save.wardrobe+gzip;version=2` (The 'wardrobe` variant is not used yet.) Save codes without a `data:` leader are assumed to be legacy LZString codes, and may still be loaded from browser storage or pasted in to the load dialog. The intention, however, is for all new saves to be in the new format. This initial checkin gets the core code in place, but forces saves in legacy format. This will be removed when the new codes are proved reliable, and I'm convinced we're not accidentally destroying data. (async/Promises are a real pain...)
There are a bunch of places where wardrobe outfit codes are loaded and stored, and I had to update all of them. Tried to be judicious about where to place `async` blocks, but there's a good chance there are synchronization errors. Initial tests promising, however; hence this checkin. Save codes still forced to legacy LZStrings.
Locate and update all remaining calls to `compressToBase64()`,
`decompressFromBase64()`, and `DecompressB64()`. Also supply SaveType
arguments at all `KinkyDungeon{,De}CompressSave()` call sites.
Newly generated save codes will be in the new format.
Re-design save codes. Re-write all sites where codes are compressed to use the new functions.
Because
CompressionStreams require async code, save codes are now "trapped" inside the async/Promise space, and can only be accessed if the code accessing them is also inside that space. A lot ofasynckeywords have been sprinkled haphazardly throughout the code to get it to compile and sort of work. However, there are almost certainly race conditions where "mainline" code needs to wait for async tasks to complete and fill out shared variables before proceeding. There is no way to do this without making the calling functions async as well.The result is that bits of the program are now flaky, notably the wardrobe editor. Not sure how to address this without a major rewrite of everything.
Best reviewed using
diff -bto ignore whitespace/indentation changes.Backup all your save codes before messing with this!