stijnfrishert / libLSDJ

Library for working with the LSDj save file format
MIT License
91 stars 6 forks source link

Writing a sav to file removes songs #82

Closed tommitytom closed 4 years ago

tommitytom commented 4 years ago

If a sav file contains multiple songs, when writing the sav with lsdj_sav_write_to_file or lsdj_sav_write_to_memory, songs are erroneously removed from the written sav.

Test case:

int main() {
    size_t writeCount = 0;
    lsdj_sav_t* sav;
    lsdj_sav_read_from_file("liblsdj-bug.sav", &sav, nullptr);
    lsdj_sav_write_to_file(sav, "liblsdj-bug-out.sav", &writeCount);
    lsdj_sav_free(sav);
    return 0;
}

Test file: https://tommitytom.co.uk/liblsdj-bug.sav

This file contains 4 songs:

  1. SNDTEST1
  2. SNDTEST
  3. SNDTES
  4. SNDTE

After running the above code, the top 3 songs are missing:

  1. SNDTE
stijnfrishert commented 4 years ago

Fixed it! Block allocation table wasn't written out correctly.