TerryCavanagh / VVVVVV

The source code to VVVVVV! http://thelettervsixtim.es/
Other
7.01k stars 560 forks source link

Emscripten support - Save data not working #1212

Open Buggem opened 2 days ago

Buggem commented 2 days ago

When compiling with emscripten, save data does not persist. I noticed that there are handlings for this to save it but they are not working properly.

leo60228 commented 2 days ago

Are you configuring persistent data storage as described in Emscripten documentation?

Buggem commented 2 days ago

@leo60228 Yes I have, this is my rundown code



int main() {
    EM_ASM(
        // Make a save directory
        FS.mkdir('/home/web_user/.local/share/VVVVVV/saves');
        FS.chmod('/home/web_user/.local/share/VVVVVV/saves', 777); // with or without, makes no difference, just emulating what the original VVVVVV C++ handling looked like (yes I am aware of bad permissions but this is WASM virtual machinery so I'm fine)
        // Then mount with IDBFS type
        FS.mount(IDBFS, {}, '/home/web_user/.local/share/VVVVVV/saves');

        // Then sync
        FS.syncfs(true, function (err) {
            // Error
        });
    );

    // open and save game
    int off_file = fopen("/home/web_user/.local/share/VVVVVV/saves/qsave1.vvv");
    ...

    // sync to make sure it is stored to IndexedDB
    EM_ASM(
        FS.syncfs(function (err) {
            // Error
        });
    );
}```
leo60228 commented 2 days ago

I can't reproduce this issue.