Disable addons manager for server-only build.

No need to spam with downloading icons for add-ons.
This commit is contained in:
Deve 2018-06-09 00:38:10 +02:00
parent 68f8d524df
commit 05572b0084
12 changed files with 66 additions and 12 deletions

View File

@ -18,6 +18,8 @@
\page addons Addons \page addons Addons
*/ */
#ifndef SERVER_ONLY
#include "addons/addons_manager.hpp" #include "addons/addons_manager.hpp"
#include "addons/news_manager.hpp" #include "addons/news_manager.hpp"
@ -614,3 +616,4 @@ void AddonsManager::saveInstalled()
xml_installed.close(); xml_installed.close();
} // saveInstalled } // saveInstalled
#endif

View File

@ -19,6 +19,8 @@
#ifndef HEADER_ADDONS_MANAGER_HPP #ifndef HEADER_ADDONS_MANAGER_HPP
#define HEADER_ADDONS_MANAGER_HPP #define HEADER_ADDONS_MANAGER_HPP
#ifndef SERVER_ONLY
#include <string> #include <string>
#include <map> #include <map>
#include <vector> #include <vector>
@ -89,5 +91,6 @@ public:
}; // class AddonsManager }; // class AddonsManager
extern AddonsManager *addons_manager; extern AddonsManager *addons_manager;
#endif
#endif
#endif

View File

@ -15,6 +15,8 @@
// along with this program; if not, write to the Free Software // along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef SERVER_ONLY
#include "addons/news_manager.hpp" #include "addons/news_manager.hpp"
#include "config/user_config.hpp" #include "config/user_config.hpp"
@ -490,3 +492,5 @@ bool NewsManager::conditionFulfilled(const std::string &cond)
} // conditionFulfilled } // conditionFulfilled
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#endif

View File

@ -18,6 +18,8 @@
#ifndef HEADER_NEWS_MANAGER_HPP #ifndef HEADER_NEWS_MANAGER_HPP
#define HEADER_NEWS_MANAGER_HPP #define HEADER_NEWS_MANAGER_HPP
#ifndef SERVER_ONLY
#include <string> #include <string>
#include <vector> #include <vector>
@ -143,4 +145,4 @@ public:
extern NewsManager *news_manager; extern NewsManager *news_manager;
#endif #endif
#endif

View File

@ -1574,7 +1574,9 @@ void initRest()
// This only initialises the non-network part of the add-ons manager. The // 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 // online section of the add-ons manager will be initialised from a
// separate thread running in network HTTP. // separate thread running in network HTTP.
#ifndef SERVER_ONLY
addons_manager = new AddonsManager(); addons_manager = new AddonsManager();
#endif
Online::ProfileManager::create(); Online::ProfileManager::create();
// The request manager will start the login process in case of a saved // 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). // achievement managers to be created, which can only be created later).
PlayerManager::create(); PlayerManager::create();
Online::RequestManager::get()->startNetworkThread(); Online::RequestManager::get()->startNetworkThread();
#ifndef SERVER_ONLY
NewsManager::get(); // this will create the news manager NewsManager::get(); // this will create the news manager
#endif
music_manager = new MusicManager(); music_manager = new MusicManager();
SFXManager::create(); SFXManager::create();
@ -1664,8 +1668,10 @@ void askForInternetPermission()
Online::RequestManager::IPERM_ALLOWED; Online::RequestManager::IPERM_ALLOWED;
UserConfigParams::m_internet_status = UserConfigParams::m_internet_status =
Online::RequestManager::IPERM_ALLOWED; Online::RequestManager::IPERM_ALLOWED;
#ifndef SERVER_ONLY
if (need_to_start_news_manager) if (need_to_start_news_manager)
NewsManager::get()->init(false); NewsManager::get()->init(false);
#endif
GUIEngine::ModalDialog::dismiss(); GUIEngine::ModalDialog::dismiss();
} // onConfirm } // onConfirm
// -------------------------------------------------------- // --------------------------------------------------------
@ -1806,6 +1812,7 @@ int main(int argc, char *argv[] )
//handleCmdLine() needs InitTuxkart() so it can't be called first //handleCmdLine() needs InitTuxkart() so it can't be called first
if(!handleCmdLine()) exit(0); if(!handleCmdLine()) exit(0);
#ifndef SERVER_ONLY
addons_manager->checkInstalledAddons(); addons_manager->checkInstalledAddons();
// Load addons.xml to get info about add-ons even when not // 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) if(UserConfigParams::m_unit_testing)
{ {
@ -1959,6 +1967,7 @@ int main(int argc, char *argv[] )
StateManager::get()->enterGameState(); StateManager::get()->enterGameState();
} }
#ifndef SERVER_ONLY
// If an important news message exists it is shown in a popup dialog. // If an important news message exists it is shown in a popup dialog.
const core::stringw important_message = const core::stringw important_message =
NewsManager::get()->getImportantMessage(); NewsManager::get()->getImportantMessage();
@ -1968,7 +1977,7 @@ int main(int argc, char *argv[] )
MessageDialog::MESSAGE_DIALOG_OK, MessageDialog::MESSAGE_DIALOG_OK,
NULL, true); NULL, true);
} // if important_message } // if important_message
#endif
// Replay a race // Replay a race
// ============= // =============
@ -2119,11 +2128,13 @@ static void cleanSuperTuxKart()
// was deleted (in cleanUserConfig below), but before STK finishes and // was deleted (in cleanUserConfig below), but before STK finishes and
// the OS takes all threads down. // the OS takes all threads down.
#ifndef SERVER_ONLY
if(!NewsManager::get()->waitForReadyToDeleted(2.0f)) if(!NewsManager::get()->waitForReadyToDeleted(2.0f))
{ {
Log::info("Thread", "News manager not stopping, exiting anyway."); Log::info("Thread", "News manager not stopping, exiting anyway.");
} }
NewsManager::deallocate(); NewsManager::deallocate();
#endif
if(!Online::RequestManager::get()->waitForReadyToDeleted(5.0f)) 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 // The add-ons manager might still be called from a currenty running request
// in the request manager, so it can not be deleted earlier. // in the request manager, so it can not be deleted earlier.
#ifndef SERVER_ONLY
if(addons_manager) delete addons_manager; if(addons_manager) delete addons_manager;
#endif
ServersManager::deallocate(); ServersManager::deallocate();
cleanUserConfig(); cleanUserConfig();

View File

@ -234,7 +234,7 @@ void AddonsScreen::tearDown()
*/ */
void AddonsScreen::loadList() void AddonsScreen::loadList()
{ {
#ifndef SERVER_ONLY
// Get the filter by words. // Get the filter by words.
GUIEngine::TextBoxWidget* w_filter_name = GUIEngine::TextBoxWidget* w_filter_name =
getWidget<GUIEngine::TextBoxWidget>("filter_name"); getWidget<GUIEngine::TextBoxWidget>("filter_name");
@ -416,6 +416,7 @@ void AddonsScreen::loadList()
else else
getWidget<GUIEngine::RibbonWidget>("category")->select("tab_update", getWidget<GUIEngine::RibbonWidget>("category")->select("tab_update",
PLAYER_ID_GAME_MASTER); PLAYER_ID_GAME_MASTER);
#endif
} // loadList } // loadList
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -452,6 +453,7 @@ void AddonsScreen::onColumnClicked(int column_id)
void AddonsScreen::eventCallback(GUIEngine::Widget* widget, void AddonsScreen::eventCallback(GUIEngine::Widget* widget,
const std::string& name, const int playerID) const std::string& name, const int playerID)
{ {
#ifndef SERVER_ONLY
if (name == "back") if (name == "back")
{ {
StateManager::get()->escapePressed(); StateManager::get()->escapePressed();
@ -509,7 +511,7 @@ void AddonsScreen::eventCallback(GUIEngine::Widget* widget,
{ {
loadList(); loadList();
} }
#endif
} // eventCallback } // eventCallback
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -534,6 +536,7 @@ void AddonsScreen::setLastSelected()
void AddonsScreen::onUpdate(float dt) void AddonsScreen::onUpdate(float dt)
{ {
#ifndef SERVER_ONLY
if (m_reloading) if (m_reloading)
{ {
if(UserConfigParams::m_internet_status!=RequestManager::IPERM_ALLOWED) if(UserConfigParams::m_internet_status!=RequestManager::IPERM_ALLOWED)
@ -579,5 +582,5 @@ void AddonsScreen::onUpdate(float dt)
m_show_tips = false; m_show_tips = false;
} }
} }
#endif
} // onUpdate } // onUpdate

View File

@ -46,7 +46,6 @@ class AddonsScreen : public GUIEngine::Screen,
friend class GUIEngine::ScreenSingleton<AddonsScreen>; friend class GUIEngine::ScreenSingleton<AddonsScreen>;
private: private:
AddonsScreen(); AddonsScreen();
AddonsManager *m_addons;
AddonsLoading *m_load; AddonsLoading *m_load;
void loadInformations(); void loadInformations();
/** Icon for installed addon, which can be updated. */ /** Icon for installed addon, which can be updated. */

View File

@ -45,8 +45,10 @@ using namespace irr::gui;
*/ */
AddonsLoading::AddonsLoading(const std::string &id) AddonsLoading::AddonsLoading(const std::string &id)
: ModalDialog(0.8f, 0.8f), : ModalDialog(0.8f, 0.8f)
m_addon(*(addons_manager->getAddon(id)) ) #ifndef SERVER_ONLY
, m_addon(*(addons_manager->getAddon(id)) )
#endif
{ {
m_icon_shown = false; m_icon_shown = false;
@ -82,6 +84,7 @@ AddonsLoading::~AddonsLoading()
void AddonsLoading::beforeAddingWidgets() void AddonsLoading::beforeAddingWidgets()
{ {
#ifndef SERVER_ONLY
/* Init the icon here to be able to load a single image*/ /* Init the icon here to be able to load a single image*/
m_icon = getWidget<IconButtonWidget> ("icon" ); m_icon = getWidget<IconButtonWidget> ("icon" );
m_progress = getWidget<ProgressBarWidget>("progress"); m_progress = getWidget<ProgressBarWidget>("progress");
@ -180,6 +183,7 @@ void AddonsLoading::beforeAddingWidgets()
unit = _LTR("%s KB", 1); unit = _LTR("%s KB", 1);
core::stringw size = _("Size: %s", unit.c_str()); core::stringw size = _("Size: %s", unit.c_str());
getWidget<LabelWidget>("size")->setText(size, false); getWidget<LabelWidget>("size")->setText(size, false);
#endif
} // AddonsLoading } // AddonsLoading
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -205,6 +209,7 @@ bool AddonsLoading::onEscapePressed()
GUIEngine::EventPropagation AddonsLoading::processEvent(const std::string& event_source) GUIEngine::EventPropagation AddonsLoading::processEvent(const std::string& event_source)
{ {
#ifndef SERVER_ONLY
GUIEngine::RibbonWidget* actions_ribbon = GUIEngine::RibbonWidget* actions_ribbon =
getWidget<GUIEngine::RibbonWidget>("actions"); getWidget<GUIEngine::RibbonWidget>("actions");
@ -252,12 +257,14 @@ GUIEngine::EventPropagation AddonsLoading::processEvent(const std::string& event
voteClicked(); voteClicked();
return GUIEngine::EVENT_BLOCK; return GUIEngine::EVENT_BLOCK;
} }
#endif
return GUIEngine::EVENT_LET; return GUIEngine::EVENT_LET;
} // processEvent } // processEvent
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
void AddonsLoading::voteClicked() void AddonsLoading::voteClicked()
{ {
#ifndef SERVER_ONLY
if (PlayerManager::isCurrentLoggedIn()) if (PlayerManager::isCurrentLoggedIn())
{ {
// We need to keep a copy of the addon id, since dismiss() will // We need to keep a copy of the addon id, since dismiss() will
@ -266,11 +273,13 @@ void AddonsLoading::voteClicked()
dismiss(); dismiss();
new VoteDialog(addon_id); new VoteDialog(addon_id);
} }
#endif
} // voteClicked } // voteClicked
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
void AddonsLoading::onUpdate(float delta) void AddonsLoading::onUpdate(float delta)
{ {
#ifndef SERVER_ONLY
if(m_progress->isVisible()) if(m_progress->isVisible())
{ {
float progress = m_download_request->getProgress(); float progress = m_download_request->getProgress();
@ -308,6 +317,7 @@ void AddonsLoading::onUpdate(float delta)
} }
m_icon_shown = true; m_icon_shown = true;
} }
#endif
} // onUpdate } // onUpdate
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -316,13 +326,14 @@ void AddonsLoading::onUpdate(float delta)
**/ **/
void AddonsLoading::startDownload() void AddonsLoading::startDownload()
{ {
#ifndef SERVER_ONLY
std::string save = "tmp/" std::string save = "tmp/"
+ StringUtils::getBasename(m_addon.getZipFileName()); + StringUtils::getBasename(m_addon.getZipFileName());
m_download_request = new Online::HTTPRequest(save, /*manage mem*/false, m_download_request = new Online::HTTPRequest(save, /*manage mem*/false,
/*priority*/5); /*priority*/5);
m_download_request->setURL(m_addon.getZipFileName()); m_download_request->setURL(m_addon.getZipFileName());
m_download_request->queue(); m_download_request->queue();
#endif
} // startDownload } // startDownload
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -353,6 +364,7 @@ void AddonsLoading::stopDownload()
*/ */
void AddonsLoading::doInstall() void AddonsLoading::doInstall()
{ {
#ifndef SERVER_ONLY
delete m_download_request; delete m_download_request;
m_download_request = NULL; m_download_request = NULL;
@ -383,12 +395,14 @@ void AddonsLoading::doInstall()
} }
track_manager->loadTrackList(); track_manager->loadTrackList();
#endif
} // doInstall } // doInstall
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
void AddonsLoading::doUninstall() void AddonsLoading::doUninstall()
{ {
#ifndef SERVER_ONLY
delete m_download_request; delete m_download_request;
m_download_request = NULL; m_download_request = NULL;
bool error = !addons_manager->uninstall(m_addon); bool error = !addons_manager->uninstall(m_addon);
@ -418,4 +432,5 @@ void AddonsLoading::doUninstall()
AddonsScreen::getInstance()->loadList(); AddonsScreen::getInstance()->loadList();
dismiss(); dismiss();
} }
#endif
} // doUninstall } // doUninstall

View File

@ -41,7 +41,9 @@ private:
GUIEngine::IconButtonWidget *m_icon; GUIEngine::IconButtonWidget *m_icon;
/** The addon to load. */ /** The addon to load. */
#ifndef SERVER_ONLY
Addon m_addon; Addon m_addon;
#endif
void startDownload(); void startDownload();
void stopDownload(); void stopDownload();
void doInstall(); void doInstall();

View File

@ -93,6 +93,7 @@ bool VoteDialog::onEscapePressed()
*/ */
void VoteDialog::sendVote() void VoteDialog::sendVote()
{ {
#ifndef SERVER_ONLY
/** A vote request. The callback will update the addon manager with the /** A vote request. The callback will update the addon manager with the
* new average. The VoteDialog polls this request till it is finished * new average. The VoteDialog polls this request till it is finished
* to inform the user about the new average. * to inform the user about the new average.
@ -125,7 +126,7 @@ void VoteDialog::sendVote()
m_rating_widget->setActive(false); m_rating_widget->setActive(false);
m_cancel_widget->setActive(false); m_cancel_widget->setActive(false);
#endif
} // sendVote } // sendVote
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------

View File

@ -140,6 +140,7 @@ void MainMenuScreen::init()
// the key bindings for the first player the default again. // the key bindings for the first player the default again.
input_manager->getDeviceManager()->clearLatestUsedDevice(); input_manager->getDeviceManager()->clearLatestUsedDevice();
#ifndef SERVER_ONLY
if (addons_manager->isLoading()) if (addons_manager->isLoading())
{ {
IconButtonWidget* w = getWidget<IconButtonWidget>("addons"); IconButtonWidget* w = getWidget<IconButtonWidget>("addons");
@ -152,6 +153,7 @@ void MainMenuScreen::init()
const core::stringw &news_text = NewsManager::get()->getNextNewsMessage(); const core::stringw &news_text = NewsManager::get()->getNextNewsMessage();
w->setText(news_text, true); w->setText(news_text, true);
w->update(0.01f); w->update(0.01f);
#endif
RibbonWidget* r = getWidget<RibbonWidget>("menu_bottomrow"); RibbonWidget* r = getWidget<RibbonWidget>("menu_bottomrow");
// FIXME: why do I need to do this manually // FIXME: why do I need to do this manually
@ -174,6 +176,7 @@ void MainMenuScreen::init()
void MainMenuScreen::onUpdate(float delta) void MainMenuScreen::onUpdate(float delta)
{ {
#ifndef SERVER_ONLY
PlayerProfile *player = PlayerManager::getCurrentPlayer(); PlayerProfile *player = PlayerManager::getCurrentPlayer();
if(PlayerManager::getCurrentOnlineState() == PlayerProfile::OS_GUEST || if(PlayerManager::getCurrentOnlineState() == PlayerProfile::OS_GUEST ||
PlayerManager::getCurrentOnlineState() == PlayerProfile::OS_SIGNED_IN) PlayerManager::getCurrentOnlineState() == PlayerProfile::OS_SIGNED_IN)
@ -222,6 +225,7 @@ void MainMenuScreen::onUpdate(float delta)
const core::stringw &news_text = NewsManager::get()->getNextNewsMessage(); const core::stringw &news_text = NewsManager::get()->getNextNewsMessage();
w->setText(news_text, true); w->setText(news_text, true);
} }
#endif
} // onUpdate } // onUpdate
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -229,6 +233,7 @@ void MainMenuScreen::onUpdate(float delta)
void MainMenuScreen::eventCallback(Widget* widget, const std::string& name, void MainMenuScreen::eventCallback(Widget* widget, const std::string& name,
const int playerID) const int playerID)
{ {
#ifndef SERVER_ONLY
if(name=="user-id") if(name=="user-id")
{ {
UserScreen::getInstance()->push(); UserScreen::getInstance()->push();
@ -534,6 +539,7 @@ void MainMenuScreen::eventCallback(Widget* widget, const std::string& name,
{ {
OnlineProfileAchievements::getInstance()->push(); OnlineProfileAchievements::getInstance()->push();
} }
#endif
} // eventCallback } // eventCallback
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -546,6 +552,7 @@ void MainMenuScreen::tearDown()
void MainMenuScreen::onDisabledItemClicked(const std::string& item) void MainMenuScreen::onDisabledItemClicked(const std::string& item)
{ {
#ifndef SERVER_ONLY
if (item == "addons") if (item == "addons")
{ {
if (UserConfigParams::m_internet_status != RequestManager::IPERM_ALLOWED) 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")); new MessageDialog( _("Please wait while the add-ons are loading"));
} }
} }
#endif
} // onDisabledItemClicked } // onDisabledItemClicked

View File

@ -239,6 +239,7 @@ void OptionsScreenUI::init()
void OptionsScreenUI::eventCallback(Widget* widget, const std::string& name, const int playerID) void OptionsScreenUI::eventCallback(Widget* widget, const std::string& name, const int playerID)
{ {
#ifndef SERVER_ONLY
if (name == "options_choice") if (name == "options_choice")
{ {
std::string selection = ((RibbonWidget*)widget)->getSelectionIDString(PLAYER_ID_GAME_MASTER); 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(); OptionsScreenUI::getInstance()->push();
} }
#endif
} // eventCallback } // eventCallback
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------