mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2024-12-22 09:39:43 +01: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:
parent
dd15d67e62
commit
c20db02f15
1 changed files with 19 additions and 0 deletions
|
@ -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)
|
void customlevelclass::getDirectoryData(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -258,6 +275,8 @@ void customlevelclass::getDirectoryData(void)
|
||||||
|
|
||||||
FILESYSTEM_clearLevelDirError();
|
FILESYSTEM_clearLevelDirError();
|
||||||
|
|
||||||
|
unloadZips();
|
||||||
|
|
||||||
loadZips();
|
loadZips();
|
||||||
|
|
||||||
FILESYSTEM_enumerateLevelDirFileNames(levelMetaDataCallback);
|
FILESYSTEM_enumerateLevelDirFileNames(levelMetaDataCallback);
|
||||||
|
|
Loading…
Reference in a new issue