From 69f08f20b70a819ea308e5226d1576b688ec3367 Mon Sep 17 00:00:00 2001 From: Simon Volpert Date: Thu, 28 Feb 2019 19:40:18 +0200 Subject: [PATCH] Look for addons in both the install dir and user dir --- gui/m_addons.cc | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/gui/m_addons.cc b/gui/m_addons.cc index a04d83a019..c6aa0757ad 100644 --- a/gui/m_addons.cc +++ b/gui/m_addons.cc @@ -81,6 +81,11 @@ bool VFS_AddArchive(const char *filename, bool options_file) filename == fl_filename_name(filename))) { char *new_name = StringPrintf("%s/addons/%s", home_dir, filename); + if (! FileExists(new_name)) + { + StringFree(new_name); + new_name = StringPrintf("%s/addons/%s", install_dir, filename); + } StringFree(filename); filename = new_name; } @@ -180,16 +185,26 @@ void VFS_ScanForAddons() char *dir_name = StringPrintf("%s/addons", home_dir); std::vector list; - int result = ScanDir_MatchingFiles(dir_name, "pk3", list); + int result1 = ScanDir_MatchingFiles(dir_name, "pk3", list); StringFree(dir_name); - if (result < 0) + dir_name = StringPrintf("%s/addons", install_dir); + + std::vector list2; + + int result2 = ScanDir_MatchingFiles(dir_name, "pk3", list2); + + if ((result1 < 0) && (result2 < 0)) { - LogPrintf("FAILED -- missing folder??\n\n"); + LogPrintf("FAILED -- no addon directory found.\n\n"); return; } + list.insert(list.end(), list2.begin(), list2.end()); + + std::vector().swap(list2); + for (unsigned int i = 0 ; i < list.size() ; i++) { addon_info_t info;