From 4e0cd853876801033a9bf3255275db4f43d9aff2 Mon Sep 17 00:00:00 2001 From: Ingo Ruhnke Date: Mon, 18 Aug 2014 05:23:16 +0200 Subject: [PATCH] Fixed AddonManager load/save of disabled addon files --- src/addon/addon_manager.cpp | 19 ++++--------------- src/addon/addon_manager.hpp | 14 ++------------ src/supertux/gameconfig.cpp | 16 +++++++--------- src/supertux/gameconfig.hpp | 2 ++ src/supertux/main.cpp | 2 +- src/supertux/menu/addon_menu.cpp | 2 -- 6 files changed, 16 insertions(+), 39 deletions(-) diff --git a/src/addon/addon_manager.cpp b/src/addon/addon_manager.cpp index 70877b58b..5ae64dfa7 100644 --- a/src/addon/addon_manager.cpp +++ b/src/addon/addon_manager.cpp @@ -61,9 +61,9 @@ size_t my_curl_physfs_write(void *ptr, size_t size, size_t nmemb, void *f_p) } #endif -AddonManager::AddonManager() : +AddonManager::AddonManager(std::vector& ignored_addon_filenames_) : addons(), - ignored_addon_filenames() + ignored_addon_filenames(ignored_addon_filenames_) { #ifdef HAVE_LIBCURL curl_global_init(CURL_GLOBAL_ALL); @@ -407,7 +407,8 @@ AddonManager::load_addons() addons.push_back(addon); // check if the Addon is disabled - if (std::find(ignored_addon_filenames.begin(), ignored_addon_filenames.end(), fileName) != ignored_addon_filenames.end()) { + if (std::find(ignored_addon_filenames.begin(), ignored_addon_filenames.end(), fileName) != ignored_addon_filenames.end()) + { unload(addon); } @@ -421,16 +422,4 @@ AddonManager::load_addons() PHYSFS_freeList(rc); } -void -AddonManager::read(const Reader& lisp) -{ - lisp.get("disabled-addons", ignored_addon_filenames); -} - -void -AddonManager::write(lisp::Writer& writer) -{ - writer.write("disabled-addons", ignored_addon_filenames); -} - /* EOF */ diff --git a/src/addon/addon_manager.hpp b/src/addon/addon_manager.hpp index 22a2db19c..9387f4e54 100644 --- a/src/addon/addon_manager.hpp +++ b/src/addon/addon_manager.hpp @@ -32,7 +32,7 @@ class Addon; class AddonManager : public Currenton { public: - AddonManager(); + AddonManager(std::vector& ignored_addon_filenames_); ~AddonManager(); /** @@ -80,19 +80,9 @@ public: */ void load_addons(); - /** - * Write AddonManager configuration to Lisp - */ - void write(Writer& writer); - - /** - * Read AddonManager configuration from Lisp - */ - void read(const Reader& lisp); - private: std::vector addons; - std::vector ignored_addon_filenames; + std::vector& ignored_addon_filenames; }; #endif diff --git a/src/supertux/gameconfig.cpp b/src/supertux/gameconfig.cpp index 5dcb1c72e..0a1a9773c 100644 --- a/src/supertux/gameconfig.cpp +++ b/src/supertux/gameconfig.cpp @@ -46,7 +46,8 @@ Config::Config() : record_demo(), locale(), keyboard_config(), - joystick_config() + joystick_config(), + disabled_addon_filenames() { } @@ -116,9 +117,9 @@ Config::load() } const lisp::Lisp* config_addons_lisp = config_lisp->get_lisp("addons"); - if (config_addons_lisp && AddonManager::current()) + if (config_addons_lisp) { - AddonManager::current()->read(*config_addons_lisp); + config_addons_lisp->get("disabled-addons", disabled_addon_filenames); } } @@ -170,12 +171,9 @@ Config::save() } writer.end_list("control"); - if (AddonManager::current()) - { - writer.start_list("addons"); - AddonManager::current()->write(writer); - writer.end_list("addons"); - } + writer.start_list("addons"); + writer.write("disabled-addons", disabled_addon_filenames); + writer.end_list("addons"); writer.end_list("supertux-config"); } diff --git a/src/supertux/gameconfig.hpp b/src/supertux/gameconfig.hpp index 0bcbf8834..a160e2e0c 100644 --- a/src/supertux/gameconfig.hpp +++ b/src/supertux/gameconfig.hpp @@ -71,6 +71,8 @@ public: KeyboardConfig keyboard_config; JoystickConfig joystick_config; + + std::vector disabled_addon_filenames; }; #endif diff --git a/src/supertux/main.cpp b/src/supertux/main.cpp index 0e3e32bcd..d03c54a86 100644 --- a/src/supertux/main.cpp +++ b/src/supertux/main.cpp @@ -309,7 +309,7 @@ Main::launch_game() Resources resources; timelog("addons"); - AddonManager addon_manager; + AddonManager addon_manager(g_config->disabled_addon_filenames); addon_manager.load_addons(); timelog(0); diff --git a/src/supertux/menu/addon_menu.cpp b/src/supertux/menu/addon_menu.cpp index 8ec3f4bc8..a658a9670 100644 --- a/src/supertux/menu/addon_menu.cpp +++ b/src/supertux/menu/addon_menu.cpp @@ -54,7 +54,6 @@ AddonMenu::refresh() // sort list std::sort(m_addons.begin(), m_addons.end(), generate_addons_menu_sorter); - add_label(_("Add-ons")); add_hl(); @@ -88,7 +87,6 @@ AddonMenu::refresh() kind = _("Level"); } - if(!addon.author.empty()) { text = str(boost::format(_("%s \"%s\" by \"%s\"")) -- 2.11.0