1
0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-06-26 14:38:30 +02:00

Unload zips before loading zips

This fixes a minor issue where if you had a zip in the levels list, but
then removed it, it would still show up in the levels list after
reloading it (if you also had a .vvvvvv file named the same as in the
zip) even though it shouldn't.

Thankfully, this didn't lead to a memory leak or duplicate zip mounts or
anything like that, because PhysFS ignores mounting a zip if it's
already mounted.

This also didn't result in a level entry from a zip persisting after
removal after reloading the levels list, because the entry would be gone
due to the .vvvvvv file not being found.
This commit is contained in:
Misa 2024-06-03 13:07:42 -07:00 committed by Misa Elizabeth Kai
parent dd15d67e62
commit c20db02f15

View File

@ -251,6 +251,23 @@ static void levelMetaDataCallback(const char* filename)
}
}
static void unloadZips(void)
{
char** list = PHYSFS_getSearchPath();
if (list == NULL)
{
return;
}
for (char** path = list; *path != NULL; path++)
{
if (SDL_strncmp(*path, "levels/", 7) == 0 && endsWith(*path, ".zip"))
{
PHYSFS_unmount(*path);
}
}
PHYSFS_freeList(list);
}
void customlevelclass::getDirectoryData(void)
{
@ -258,6 +275,8 @@ void customlevelclass::getDirectoryData(void)
FILESYSTEM_clearLevelDirError();
unloadZips();
loadZips();
FILESYSTEM_enumerateLevelDirFileNames(levelMetaDataCallback);