Add support for zlib-compressed levels in URLs

This commit is contained in:
Eevee (Evelyn Woods) 2021-01-01 22:09:49 -07:00
parent e277a1363e
commit 29df283f80
2 changed files with 6 additions and 1 deletions

View File

@ -2631,7 +2631,7 @@ export class Editor extends PrimaryView {
}, 60 * 1000);
});
_make_button("Share", ev => {
let data = util.b64encode(c2g.synthesize_level(this.stored_level));
let data = util.b64encode(fflate.zlibSync(new Uint8Array(c2g.synthesize_level(this.stored_level))));
let url = new URL(location);
url.searchParams.delete('level');
url.searchParams.delete('setpath');

View File

@ -3263,6 +3263,11 @@ async function main() {
else if (b64level) {
// TODO all the more important to show errors!!
let buf = util.b64decode(b64level);
let u8array = new Uint8Array(buf);
if (u8array[0] === 0x78) {
// zlib compressed
buf = fflate.unzlibSync(u8array).buffer;
}
await conductor.parse_and_load_game(buf, null, 'shared.c2m', null, "Shared level");
}
}