Skip to content

Commit

Permalink
Fix addon loading/enumeration
Browse files Browse the repository at this point in the history
  • Loading branch information
dashodanger committed Jun 30, 2024
1 parent a775f54 commit d6a70f0
Showing 1 changed file with 17 additions and 21 deletions.
38 changes: 17 additions & 21 deletions source/m_addons.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,34 +35,22 @@ std::vector<addon_info_t> all_addons;

std::vector<std::string> all_presets;

// Will check install, then home directory (if different)
void VFS_AddFolder(std::string name)
{
std::string path = PathAppend(install_dir, name);
std::string mount = StringFormat("/%s", name.c_str());

if (!PHYSFS_mount(path.c_str(), mount.c_str(), 0))
{
FatalError("Failed to mount '%s' folder in PhysFS:\n%s\n", name.c_str(),
PHYSFS_getErrorByCode(PHYSFS_getLastErrorCode()));
return; /* NOT REACHED */
return; /* NOT REACHED */
}

DebugPrint("mounted folder '%s'\n", name.c_str());
}

// install and home directories if different
void VFS_AddBothFolders(std::string name)
{
std::string path = PathAppend(install_dir, name);
std::string mount = StringFormat("/%s", name.c_str());
if (!PHYSFS_mount(path.c_str(), mount.c_str(), 0))
if (install_dir != home_dir)
{
FatalError("Failed to mount '%s' folder in PhysFS:\n%s\n", name.c_str(),
PHYSFS_getErrorByCode(PHYSFS_getLastErrorCode()));
return; /* NOT REACHED */
path = PathAppend(home_dir, name);
PHYSFS_mount(path.c_str(), mount.c_str(), 0); // this one can fail if not present, that's fine
}
path = PathAppend(home_dir, name);
PHYSFS_mount(path.c_str(), mount.c_str(), 0); // this one can fail if not present, that's fine

DebugPrint("mounted folder '%s'\n", name.c_str());
}
Expand Down Expand Up @@ -113,9 +101,9 @@ void VFS_InitAddons()
VFS_AddFolder("modules");
VFS_AddFolder("data");
VFS_AddFolder("ports");
VFS_AddBothFolders("presets");
VFS_AddBothFolders("addons");
VFS_AddBothFolders("temp");
VFS_AddFolder("presets");
VFS_AddFolder("addons");
VFS_AddFolder("temp");

LogPrint("DONE.\n\n");
}
Expand Down Expand Up @@ -229,7 +217,15 @@ void VFS_ScanForAddons()

for (p = got_names; *p; p++)
{
if (GetExtension(*p) == ".oaf")
PHYSFS_Stat statter;

if (PHYSFS_stat(PathAppend("/addons", *p).c_str(), &statter) == 0)
{
LogPrint("Could not stat %s: %s\n", *p, PHYSFS_getErrorByCode(PHYSFS_getLastErrorCode()));
continue;
}

if (statter.filetype == PHYSFS_FILETYPE_DIRECTORY || (statter.filetype == PHYSFS_FILETYPE_REGULAR && GetExtension(*p) == ".oaf"))
{
addon_info_t info;

Expand Down

0 comments on commit d6a70f0

Please sign in to comment.