From: Ingo Ruhnke Date: Sat, 23 Aug 2014 18:37:11 +0000 (+0200) Subject: Added check for MD5 and version number to Addon online check X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=f72cd83161ea9d9d394294b718ca8dc58f5c2d63;p=supertux.git Added check for MD5 and version number to Addon online check --- diff --git a/src/addon/addon.hpp b/src/addon/addon.hpp index e7a3c9f94..81cf34909 100644 --- a/src/addon/addon.hpp +++ b/src/addon/addon.hpp @@ -54,6 +54,7 @@ private: public: std::string get_id() const { return m_id; } + int get_version() const { return m_version; } Type get_type() const { return m_type; } std::string get_title() const { return m_title; } diff --git a/src/supertux/menu/addon_menu.cpp b/src/supertux/menu/addon_menu.cpp index 615305d7d..d2e6c5bc5 100644 --- a/src/supertux/menu/addon_menu.cpp +++ b/src/supertux/menu/addon_menu.cpp @@ -138,9 +138,29 @@ AddonMenu::rebuild_menu() for (const auto& addon_id : m_repository_addons) { const Addon& addon = m_addon_manager.get_repository_addon(addon_id); - std::string text = generate_menu_item_text(addon); - add_entry(MAKE_REPOSITORY_MENU_ID(idx), "Install " + text); - idx += 1; + try + { + // addon is already installed, so check if they are the same + Addon& installed_addon = m_addon_manager.get_installed_addon(addon_id); + if (installed_addon.get_md5() == addon.get_md5() || + installed_addon.get_version() > addon.get_version()) + { + // addon alredy present, ignore it + } + else + { + std::string text = generate_menu_item_text(addon); + add_entry(MAKE_REPOSITORY_MENU_ID(idx), "Install " + text + "*NEW*"); + idx += 1; + } + } + catch(const std::exception& err) + { + // addon is not installed + std::string text = generate_menu_item_text(addon); + add_entry(MAKE_REPOSITORY_MENU_ID(idx), "Install " + text); + idx += 1; + } } }