From 05572b00848b09e98ab23f501a8b68bb647f74b4 Mon Sep 17 00:00:00 2001 From: Deve Date: Sat, 9 Jun 2018 00:38:10 +0200 Subject: [PATCH] Disable addons manager for server-only build. No need to spam with downloading icons for add-ons. --- src/addons/addons_manager.cpp | 3 +++ src/addons/addons_manager.hpp | 5 ++++- src/addons/news_manager.cpp | 4 ++++ src/addons/news_manager.hpp | 4 +++- src/main.cpp | 15 ++++++++++++- src/states_screens/addons_screen.cpp | 9 +++++--- src/states_screens/addons_screen.hpp | 1 - src/states_screens/dialogs/addons_loading.cpp | 21 ++++++++++++++++--- src/states_screens/dialogs/addons_loading.hpp | 2 ++ src/states_screens/dialogs/vote_dialog.cpp | 3 ++- src/states_screens/main_menu_screen.cpp | 8 +++++++ src/states_screens/options_screen_ui.cpp | 3 ++- 12 files changed, 66 insertions(+), 12 deletions(-) diff --git a/src/addons/addons_manager.cpp b/src/addons/addons_manager.cpp index 72ec42e74..b89aa963f 100644 --- a/src/addons/addons_manager.cpp +++ b/src/addons/addons_manager.cpp @@ -18,6 +18,8 @@ \page addons Addons */ +#ifndef SERVER_ONLY + #include "addons/addons_manager.hpp" #include "addons/news_manager.hpp" @@ -614,3 +616,4 @@ void AddonsManager::saveInstalled() xml_installed.close(); } // saveInstalled +#endif diff --git a/src/addons/addons_manager.hpp b/src/addons/addons_manager.hpp index 2aa096e2d..345f2758a 100644 --- a/src/addons/addons_manager.hpp +++ b/src/addons/addons_manager.hpp @@ -19,6 +19,8 @@ #ifndef HEADER_ADDONS_MANAGER_HPP #define HEADER_ADDONS_MANAGER_HPP +#ifndef SERVER_ONLY + #include #include #include @@ -89,5 +91,6 @@ public: }; // class AddonsManager extern AddonsManager *addons_manager; -#endif +#endif +#endif diff --git a/src/addons/news_manager.cpp b/src/addons/news_manager.cpp index 9ca39aab8..78c8a262b 100644 --- a/src/addons/news_manager.cpp +++ b/src/addons/news_manager.cpp @@ -15,6 +15,8 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +#ifndef SERVER_ONLY + #include "addons/news_manager.hpp" #include "config/user_config.hpp" @@ -490,3 +492,5 @@ bool NewsManager::conditionFulfilled(const std::string &cond) } // conditionFulfilled // ---------------------------------------------------------------------------- + +#endif diff --git a/src/addons/news_manager.hpp b/src/addons/news_manager.hpp index e249a83a8..3819cd8df 100644 --- a/src/addons/news_manager.hpp +++ b/src/addons/news_manager.hpp @@ -18,6 +18,8 @@ #ifndef HEADER_NEWS_MANAGER_HPP #define HEADER_NEWS_MANAGER_HPP +#ifndef SERVER_ONLY + #include #include @@ -143,4 +145,4 @@ public: extern NewsManager *news_manager; #endif - +#endif diff --git a/src/main.cpp b/src/main.cpp index 863b66ed2..1a26da448 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1574,7 +1574,9 @@ void initRest() // This only initialises the non-network part of the add-ons manager. The // online section of the add-ons manager will be initialised from a // separate thread running in network HTTP. +#ifndef SERVER_ONLY addons_manager = new AddonsManager(); +#endif Online::ProfileManager::create(); // The request manager will start the login process in case of a saved @@ -1583,7 +1585,9 @@ void initRest() // achievement managers to be created, which can only be created later). PlayerManager::create(); Online::RequestManager::get()->startNetworkThread(); +#ifndef SERVER_ONLY NewsManager::get(); // this will create the news manager +#endif music_manager = new MusicManager(); SFXManager::create(); @@ -1664,8 +1668,10 @@ void askForInternetPermission() Online::RequestManager::IPERM_ALLOWED; UserConfigParams::m_internet_status = Online::RequestManager::IPERM_ALLOWED; +#ifndef SERVER_ONLY if (need_to_start_news_manager) NewsManager::get()->init(false); +#endif GUIEngine::ModalDialog::dismiss(); } // onConfirm // -------------------------------------------------------- @@ -1806,6 +1812,7 @@ int main(int argc, char *argv[] ) //handleCmdLine() needs InitTuxkart() so it can't be called first if(!handleCmdLine()) exit(0); +#ifndef SERVER_ONLY addons_manager->checkInstalledAddons(); // Load addons.xml to get info about add-ons even when not @@ -1827,6 +1834,7 @@ int main(int argc, char *argv[] ) } } } +#endif if(UserConfigParams::m_unit_testing) { @@ -1959,6 +1967,7 @@ int main(int argc, char *argv[] ) StateManager::get()->enterGameState(); } +#ifndef SERVER_ONLY // If an important news message exists it is shown in a popup dialog. const core::stringw important_message = NewsManager::get()->getImportantMessage(); @@ -1968,7 +1977,7 @@ int main(int argc, char *argv[] ) MessageDialog::MESSAGE_DIALOG_OK, NULL, true); } // if important_message - +#endif // Replay a race // ============= @@ -2119,11 +2128,13 @@ static void cleanSuperTuxKart() // was deleted (in cleanUserConfig below), but before STK finishes and // the OS takes all threads down. +#ifndef SERVER_ONLY if(!NewsManager::get()->waitForReadyToDeleted(2.0f)) { Log::info("Thread", "News manager not stopping, exiting anyway."); } NewsManager::deallocate(); +#endif if(!Online::RequestManager::get()->waitForReadyToDeleted(5.0f)) { @@ -2144,7 +2155,9 @@ static void cleanSuperTuxKart() // The add-ons manager might still be called from a currenty running request // in the request manager, so it can not be deleted earlier. +#ifndef SERVER_ONLY if(addons_manager) delete addons_manager; +#endif ServersManager::deallocate(); cleanUserConfig(); diff --git a/src/states_screens/addons_screen.cpp b/src/states_screens/addons_screen.cpp index 4ba06209a..f50f9ec4d 100644 --- a/src/states_screens/addons_screen.cpp +++ b/src/states_screens/addons_screen.cpp @@ -234,7 +234,7 @@ void AddonsScreen::tearDown() */ void AddonsScreen::loadList() { - +#ifndef SERVER_ONLY // Get the filter by words. GUIEngine::TextBoxWidget* w_filter_name = getWidget("filter_name"); @@ -416,6 +416,7 @@ void AddonsScreen::loadList() else getWidget("category")->select("tab_update", PLAYER_ID_GAME_MASTER); +#endif } // loadList // ---------------------------------------------------------------------------- @@ -452,6 +453,7 @@ void AddonsScreen::onColumnClicked(int column_id) void AddonsScreen::eventCallback(GUIEngine::Widget* widget, const std::string& name, const int playerID) { +#ifndef SERVER_ONLY if (name == "back") { StateManager::get()->escapePressed(); @@ -509,7 +511,7 @@ void AddonsScreen::eventCallback(GUIEngine::Widget* widget, { loadList(); } - +#endif } // eventCallback // ---------------------------------------------------------------------------- @@ -534,6 +536,7 @@ void AddonsScreen::setLastSelected() void AddonsScreen::onUpdate(float dt) { +#ifndef SERVER_ONLY if (m_reloading) { if(UserConfigParams::m_internet_status!=RequestManager::IPERM_ALLOWED) @@ -579,5 +582,5 @@ void AddonsScreen::onUpdate(float dt) m_show_tips = false; } } - +#endif } // onUpdate diff --git a/src/states_screens/addons_screen.hpp b/src/states_screens/addons_screen.hpp index 3b12e3254..339ec49c6 100644 --- a/src/states_screens/addons_screen.hpp +++ b/src/states_screens/addons_screen.hpp @@ -46,7 +46,6 @@ class AddonsScreen : public GUIEngine::Screen, friend class GUIEngine::ScreenSingleton; private: AddonsScreen(); - AddonsManager *m_addons; AddonsLoading *m_load; void loadInformations(); /** Icon for installed addon, which can be updated. */ diff --git a/src/states_screens/dialogs/addons_loading.cpp b/src/states_screens/dialogs/addons_loading.cpp index 2dbe92fca..663194b99 100644 --- a/src/states_screens/dialogs/addons_loading.cpp +++ b/src/states_screens/dialogs/addons_loading.cpp @@ -45,8 +45,10 @@ using namespace irr::gui; */ AddonsLoading::AddonsLoading(const std::string &id) - : ModalDialog(0.8f, 0.8f), - m_addon(*(addons_manager->getAddon(id)) ) + : ModalDialog(0.8f, 0.8f) +#ifndef SERVER_ONLY + , m_addon(*(addons_manager->getAddon(id)) ) +#endif { m_icon_shown = false; @@ -82,6 +84,7 @@ AddonsLoading::~AddonsLoading() void AddonsLoading::beforeAddingWidgets() { +#ifndef SERVER_ONLY /* Init the icon here to be able to load a single image*/ m_icon = getWidget ("icon" ); m_progress = getWidget("progress"); @@ -180,6 +183,7 @@ void AddonsLoading::beforeAddingWidgets() unit = _LTR("%s KB", 1); core::stringw size = _("Size: %s", unit.c_str()); getWidget("size")->setText(size, false); +#endif } // AddonsLoading // ---------------------------------------------------------------------------- @@ -205,6 +209,7 @@ bool AddonsLoading::onEscapePressed() GUIEngine::EventPropagation AddonsLoading::processEvent(const std::string& event_source) { +#ifndef SERVER_ONLY GUIEngine::RibbonWidget* actions_ribbon = getWidget("actions"); @@ -252,12 +257,14 @@ GUIEngine::EventPropagation AddonsLoading::processEvent(const std::string& event voteClicked(); return GUIEngine::EVENT_BLOCK; } +#endif return GUIEngine::EVENT_LET; } // processEvent // ---------------------------------------------------------------------------- void AddonsLoading::voteClicked() { +#ifndef SERVER_ONLY if (PlayerManager::isCurrentLoggedIn()) { // We need to keep a copy of the addon id, since dismiss() will @@ -266,11 +273,13 @@ void AddonsLoading::voteClicked() dismiss(); new VoteDialog(addon_id); } +#endif } // voteClicked // ---------------------------------------------------------------------------- void AddonsLoading::onUpdate(float delta) { +#ifndef SERVER_ONLY if(m_progress->isVisible()) { float progress = m_download_request->getProgress(); @@ -308,6 +317,7 @@ void AddonsLoading::onUpdate(float delta) } m_icon_shown = true; } +#endif } // onUpdate // ---------------------------------------------------------------------------- @@ -316,13 +326,14 @@ void AddonsLoading::onUpdate(float delta) **/ void AddonsLoading::startDownload() { +#ifndef SERVER_ONLY std::string save = "tmp/" + StringUtils::getBasename(m_addon.getZipFileName()); m_download_request = new Online::HTTPRequest(save, /*manage mem*/false, /*priority*/5); m_download_request->setURL(m_addon.getZipFileName()); m_download_request->queue(); - +#endif } // startDownload // ---------------------------------------------------------------------------- @@ -353,6 +364,7 @@ void AddonsLoading::stopDownload() */ void AddonsLoading::doInstall() { +#ifndef SERVER_ONLY delete m_download_request; m_download_request = NULL; @@ -383,12 +395,14 @@ void AddonsLoading::doInstall() } track_manager->loadTrackList(); +#endif } // doInstall // ---------------------------------------------------------------------------- void AddonsLoading::doUninstall() { +#ifndef SERVER_ONLY delete m_download_request; m_download_request = NULL; bool error = !addons_manager->uninstall(m_addon); @@ -418,4 +432,5 @@ void AddonsLoading::doUninstall() AddonsScreen::getInstance()->loadList(); dismiss(); } +#endif } // doUninstall diff --git a/src/states_screens/dialogs/addons_loading.hpp b/src/states_screens/dialogs/addons_loading.hpp index cdc91c6e8..1c217641a 100644 --- a/src/states_screens/dialogs/addons_loading.hpp +++ b/src/states_screens/dialogs/addons_loading.hpp @@ -41,7 +41,9 @@ private: GUIEngine::IconButtonWidget *m_icon; /** The addon to load. */ +#ifndef SERVER_ONLY Addon m_addon; +#endif void startDownload(); void stopDownload(); void doInstall(); diff --git a/src/states_screens/dialogs/vote_dialog.cpp b/src/states_screens/dialogs/vote_dialog.cpp index 923f65120..697ea6c16 100644 --- a/src/states_screens/dialogs/vote_dialog.cpp +++ b/src/states_screens/dialogs/vote_dialog.cpp @@ -93,6 +93,7 @@ bool VoteDialog::onEscapePressed() */ void VoteDialog::sendVote() { +#ifndef SERVER_ONLY /** A vote request. The callback will update the addon manager with the * new average. The VoteDialog polls this request till it is finished * to inform the user about the new average. @@ -125,7 +126,7 @@ void VoteDialog::sendVote() m_rating_widget->setActive(false); m_cancel_widget->setActive(false); - +#endif } // sendVote // ----------------------------------------------------------------------------- diff --git a/src/states_screens/main_menu_screen.cpp b/src/states_screens/main_menu_screen.cpp index 0f41e82b2..887d6420a 100644 --- a/src/states_screens/main_menu_screen.cpp +++ b/src/states_screens/main_menu_screen.cpp @@ -140,6 +140,7 @@ void MainMenuScreen::init() // the key bindings for the first player the default again. input_manager->getDeviceManager()->clearLatestUsedDevice(); +#ifndef SERVER_ONLY if (addons_manager->isLoading()) { IconButtonWidget* w = getWidget("addons"); @@ -152,6 +153,7 @@ void MainMenuScreen::init() const core::stringw &news_text = NewsManager::get()->getNextNewsMessage(); w->setText(news_text, true); w->update(0.01f); +#endif RibbonWidget* r = getWidget("menu_bottomrow"); // FIXME: why do I need to do this manually @@ -174,6 +176,7 @@ void MainMenuScreen::init() void MainMenuScreen::onUpdate(float delta) { +#ifndef SERVER_ONLY PlayerProfile *player = PlayerManager::getCurrentPlayer(); if(PlayerManager::getCurrentOnlineState() == PlayerProfile::OS_GUEST || PlayerManager::getCurrentOnlineState() == PlayerProfile::OS_SIGNED_IN) @@ -222,6 +225,7 @@ void MainMenuScreen::onUpdate(float delta) const core::stringw &news_text = NewsManager::get()->getNextNewsMessage(); w->setText(news_text, true); } +#endif } // onUpdate // ---------------------------------------------------------------------------- @@ -229,6 +233,7 @@ void MainMenuScreen::onUpdate(float delta) void MainMenuScreen::eventCallback(Widget* widget, const std::string& name, const int playerID) { +#ifndef SERVER_ONLY if(name=="user-id") { UserScreen::getInstance()->push(); @@ -534,6 +539,7 @@ void MainMenuScreen::eventCallback(Widget* widget, const std::string& name, { OnlineProfileAchievements::getInstance()->push(); } +#endif } // eventCallback // ---------------------------------------------------------------------------- @@ -546,6 +552,7 @@ void MainMenuScreen::tearDown() void MainMenuScreen::onDisabledItemClicked(const std::string& item) { +#ifndef SERVER_ONLY if (item == "addons") { if (UserConfigParams::m_internet_status != RequestManager::IPERM_ALLOWED) @@ -565,4 +572,5 @@ void MainMenuScreen::onDisabledItemClicked(const std::string& item) new MessageDialog( _("Please wait while the add-ons are loading")); } } +#endif } // onDisabledItemClicked diff --git a/src/states_screens/options_screen_ui.cpp b/src/states_screens/options_screen_ui.cpp index 3179d64c1..a0635763d 100644 --- a/src/states_screens/options_screen_ui.cpp +++ b/src/states_screens/options_screen_ui.cpp @@ -239,6 +239,7 @@ void OptionsScreenUI::init() void OptionsScreenUI::eventCallback(Widget* widget, const std::string& name, const int playerID) { +#ifndef SERVER_ONLY if (name == "options_choice") { std::string selection = ((RibbonWidget*)widget)->getSelectionIDString(PLAYER_ID_GAME_MASTER); @@ -387,7 +388,7 @@ void OptionsScreenUI::eventCallback(Widget* widget, const std::string& name, con OptionsScreenUI::getInstance()->push(); } - +#endif } // eventCallback // -----------------------------------------------------------------------------