Level list is empty after selecting "Save & Quit" option from level editor
Polprzewodnikowy opened this issue · comments
Steps to reproduce:
- Run ROM
- Start building new level
- Add some blocks
- Open level settings
- Navigate to system tab
- Select "Save & Quit"
- Message pops up: "No levels currently loaded yet."
Expected outcome:
After save & quit I should see last saved level in the list
Environment:
NTSC N64 console with SummerCart64 flashcart and exFAT file system on the SD card
I've submitted a fix here: #13
Thank you! I'll merge this in a bit. Out of curiosity, why does using chdir cause problems on flashcarts? I'd like to know for future reference.
Main issues seems to be stemming from:
- No error checking. Didn't find the exact function that causes chdir to fail, but
f_opendir
inload_level_files_from_sd_card
function returnsFR_NO_PATH
so somewhere the path is getting desynced. I've tried to usef_getcwd
to look what's going on but it just returned empty string, which should mean root directory. - Incorrect usage of pointers. In many places level directory string was incorrectly passed to the function. Since string already is a pointer, there's no need to add
&
to get the address. Compiler warnings are very clear about that.
As of why this works in the Parallel launcher and not on the real hardware, my assumption is just inaccurate emulation. Maybe there's some place where cache coherency is not taken care of - emulators usually don't implement CPU cache correctly.
If you want to keep f_chdir
then quick fix seems to be to always chdir into absolute path (add /
at the beginning):
But I strongly recommend just sticking to the absolute paths. Doing f_chdir
in random places is error prone and confusing to the uninitiated reader.