LibreSplit icon indicating copy to clipboard operation
LibreSplit copied to clipboard

Saving not working correctly?

Open DevLaTron opened this issue 4 months 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