LibreSplit icon indicating copy to clipboard operation
LibreSplit copied to clipboard

Saving not working correctly?

Open DevLaTron opened this issue 1 year ago • 1 comments

I've built libresplit on an Ubuntu 24.04, and have had a couple of issues:

  • There seems to be a general error when saving, because json_dump_file returns 0 on success, so I rewrote this (Including debugging output) in src/timer.c

    result = json_dump_file(json, game->path, JSON_PRESERVE_ORDER | JSON_INDENT(2)); if (result != 0) { printf("Error dumping JSON:\n%s\n", json_dumps(json, JSON_PRESERVE_ORDER | JSON_INDENT(2))); printf("Error: '%d'\n", result); printf("Path: %s\n", game->path); } json_decref(json);

    return result;

  • If the split times are "0", they won't be saved, which is probably your start point. Assuming that 0 means "not ran yet" (that's how it looks from the resources provided, I had to add checks for this to work correctly when updating the splits. It for example didn't do the memcpy initially, preventing saving.

  • I stumbled into all sorts of formatting issues between the game construct and the json. As a workaround I changed the serialize function to a simple long long to string conversion, and when loading the json use a strtoll() call to get it back. Of course at that point one could use an int to store that value.

After these adjustments, I finally managed to get it to run.

I'll leave this here for reference, as it's a "it's ugly, but it works for me" kind of hack.

If I find the time, I might clean this up and get it into correct working order with a PR.

DevLaTron avatar Sep 30 '24 08:09 DevLaTron

From what i read and the current code in that part is that you just added a printf telling the user what the error was when saving a json that failed, json_dump_file in the current code is inverted so the logic is really the same This is how it is right now in master

if (!json_dump_file(json, game->path,
            JSON_PRESERVE_ORDER | JSON_INDENT(2))) {
        error = 1;
    }
json_decref(json);

I dont see any problem with adding a printf to the error code, feel free to PR when you feel like it

EXtremeExploit avatar Oct 12 '24 21:10 EXtremeExploit

Can you try now and see if the problem persists or you get new console output?

EXtremeExploit avatar Oct 09 '25 22:10 EXtremeExploit

Project is transfering over https://github.com/LibreSplitDev/LibreSplit, if problem persists open a new issue there

EXtremeExploit avatar Oct 20 '25 14:10 EXtremeExploit