diff --git a/src/engine/client/client.cpp b/src/engine/client/client.cpp index 343cd42bb..f5d2c4e85 100644 --- a/src/engine/client/client.cpp +++ b/src/engine/client/client.cpp @@ -59,7 +59,7 @@ #include "friends.h" #include "serverbrowser.h" #include "fetcher.h" -#include "autoupdate.h" +#include "updater.h" #include "client.h" #include @@ -2489,7 +2489,7 @@ void CClient::RegisterInterfaces() Kernel()->RegisterInterface(static_cast(&m_ServerBrowser)); Kernel()->RegisterInterface(static_cast(&m_Fetcher)); #if !defined(CONF_PLATFORM_MACOSX) && !defined(__ANDROID__) - Kernel()->RegisterInterface(static_cast(&m_AutoUpdate)); + Kernel()->RegisterInterface(static_cast(&m_Updater)); #endif Kernel()->RegisterInterface(static_cast(&m_Friends)); } @@ -2507,7 +2507,7 @@ void CClient::InitInterfaces() m_pMasterServer = Kernel()->RequestInterface(); m_pFetcher = Kernel()->RequestInterface(); #if !defined(CONF_PLATFORM_MACOSX) && !defined(__ANDROID__) - m_pAutoUpdate = Kernel()->RequestInterface(); + m_pUpdater = Kernel()->RequestInterface(); #endif m_pStorage = Kernel()->RequestInterface(); @@ -2518,7 +2518,7 @@ void CClient::InitInterfaces() m_Fetcher.Init(); #if !defined(CONF_PLATFORM_MACOSX) && !defined(__ANDROID__) - m_AutoUpdate.Init(); + m_Updater.Init(); #endif m_Friends.Init(); @@ -2656,7 +2656,7 @@ void CClient::Run() if(Input()->Update()) break; // SDL_QUIT #if !defined(CONF_PLATFORM_MACOSX) && !defined(__ANDROID__) - AutoUpdate()->Update(); + Updater()->Update(); #endif // update sound diff --git a/src/engine/client/client.h b/src/engine/client/client.h index c5565a604..f74dc8859 100644 --- a/src/engine/client/client.h +++ b/src/engine/client/client.h @@ -64,7 +64,7 @@ class CClient : public IClient, public CDemoPlayer::IListner IConsole *m_pConsole; IStorage *m_pStorage; IFetcher *m_pFetcher; - IAutoUpdate *m_pAutoUpdate; + IUpdater *m_pUpdater; IEngineMasterServer *m_pMasterServer; enum @@ -79,7 +79,7 @@ class CClient : public IClient, public CDemoPlayer::IListner class CDemoEditor m_DemoEditor; class CServerBrowser m_ServerBrowser; class CFetcher m_Fetcher; - class CAutoUpdate m_AutoUpdate; + class CUpdater m_Updater; class CFriends m_Friends; class CMapChecker m_MapChecker; @@ -204,7 +204,7 @@ public: IEngineMasterServer *MasterServer() { return m_pMasterServer; } IStorage *Storage() { return m_pStorage; } IFetcher *Fetcher() { return m_pFetcher; } - IAutoUpdate *AutoUpdate() { return m_pAutoUpdate; } + IUpdater *Updater() { return m_pUpdater; } CClient(); diff --git a/src/engine/client/autoupdate.cpp b/src/engine/client/updater.cpp similarity index 83% rename from src/engine/client/autoupdate.cpp rename to src/engine/client/updater.cpp index aa701639b..9af78ebf8 100644 --- a/src/engine/client/autoupdate.cpp +++ b/src/engine/client/updater.cpp @@ -1,4 +1,4 @@ -#include "autoupdate.h" +#include "updater.h" #include #include #include @@ -11,7 +11,7 @@ using std::string; using std::vector; -CAutoUpdate::CAutoUpdate() +CUpdater::CUpdater() { m_pClient = NULL; m_pStorage = NULL; @@ -20,7 +20,7 @@ CAutoUpdate::CAutoUpdate() m_Percent = 0; } -void CAutoUpdate::Init() +void CUpdater::Init() { m_pClient = Kernel()->RequestInterface(); m_pStorage = Kernel()->RequestInterface(); @@ -28,16 +28,16 @@ void CAutoUpdate::Init() m_IsWinXP = os_compare_version(5, 1) <= 0; } -void CAutoUpdate::ProgressCallback(CFetchTask *pTask, void *pUser) +void CUpdater::ProgressCallback(CFetchTask *pTask, void *pUser) { - CAutoUpdate *pUpdate = (CAutoUpdate *)pUser; + CUpdater *pUpdate = (CUpdater *)pUser; str_copy(pUpdate->m_Status, pTask->Dest(), sizeof(pUpdate->m_Status)); pUpdate->m_Percent = pTask->Progress(); } -void CAutoUpdate::CompletionCallback(CFetchTask *pTask, void *pUser) +void CUpdater::CompletionCallback(CFetchTask *pTask, void *pUser) { - CAutoUpdate *pUpdate = (CAutoUpdate *)pUser; + CUpdater *pUpdate = (CUpdater *)pUser; if(!str_comp(pTask->Dest(), "update.json")) { if(pTask->State() == CFetchTask::STATE_DONE) @@ -68,17 +68,17 @@ void CAutoUpdate::CompletionCallback(CFetchTask *pTask, void *pUser) delete pTask; } -void CAutoUpdate::FetchFile(const char *pFile, const char *pDestPath) +void CUpdater::FetchFile(const char *pFile, const char *pDestPath) { char aBuf[256]; str_format(aBuf, sizeof(aBuf), "https://%s/%s", g_Config.m_ClDDNetUpdateServer, pFile); if(!pDestPath) pDestPath = pFile; CFetchTask *Task = new CFetchTask; - m_pFetcher->QueueAdd(Task, aBuf, pDestPath, -2, this, &CAutoUpdate::CompletionCallback, &CAutoUpdate::ProgressCallback); + m_pFetcher->QueueAdd(Task, aBuf, pDestPath, -2, this, &CUpdater::CompletionCallback, &CUpdater::ProgressCallback); } -void CAutoUpdate::Update() +void CUpdater::Update() { switch(m_State) { @@ -89,7 +89,7 @@ void CAutoUpdate::Update() } } -void CAutoUpdate::AddNewFile(const char *pFile) +void CUpdater::AddNewFile(const char *pFile) { //Check if already on the download list for(vector::iterator it = m_AddedFiles.begin(); it < m_AddedFiles.end(); ++it) @@ -100,7 +100,7 @@ void CAutoUpdate::AddNewFile(const char *pFile) m_AddedFiles.push_back(string(pFile)); } -void CAutoUpdate::AddRemovedFile(const char *pFile) +void CUpdater::AddRemovedFile(const char *pFile) { //First remove from to be downloaded list for(vector::iterator it = m_AddedFiles.begin(); it < m_AddedFiles.end(); ++it) @@ -113,9 +113,9 @@ void CAutoUpdate::AddRemovedFile(const char *pFile) m_RemovedFiles.push_back(string(pFile)); } -void CAutoUpdate::ReplaceClient() +void CUpdater::ReplaceClient() { - dbg_msg("autoupdate", "Replacing " PLAT_CLIENT_EXEC); + dbg_msg("updater", "Replacing " PLAT_CLIENT_EXEC); //Replace running executable by renaming twice... if(m_IsWinXP) @@ -130,13 +130,13 @@ void CAutoUpdate::ReplaceClient() char aBuf[512]; str_format(aBuf, sizeof aBuf, "chmod +x %s", aPath); if (system(aBuf)) - dbg_msg("autoupdate", "Error setting client executable bit"); + dbg_msg("updater", "Error setting client executable bit"); #endif } -void CAutoUpdate::ReplaceServer() +void CUpdater::ReplaceServer() { - dbg_msg("autoupdate", "Replacing " PLAT_SERVER_EXEC); + dbg_msg("updater", "Replacing " PLAT_SERVER_EXEC); //Replace running executable by renaming twice... m_pStorage->RemoveBinaryFile("DDNet-Server.old"); @@ -148,11 +148,11 @@ void CAutoUpdate::ReplaceServer() char aBuf[512]; str_format(aBuf, sizeof aBuf, "chmod +x %s", aPath); if (system(aBuf)) - dbg_msg("autoupdate", "Error setting server executable bit"); + dbg_msg("updater", "Error setting server executable bit"); #endif } -void CAutoUpdate::ParseUpdate() +void CUpdater::ParseUpdate() { char aPath[512]; IOHANDLE File = m_pStorage->OpenFile(m_pStorage->GetBinaryPath("update.json", aPath, sizeof aPath), IOFLAG_READ, IStorage::TYPE_ALL); @@ -195,16 +195,16 @@ void CAutoUpdate::ParseUpdate() } } -void CAutoUpdate::InitiateUpdate() +void CUpdater::InitiateUpdate() { m_State = GETTING_MANIFEST; FetchFile("update.json"); } -void CAutoUpdate::PerformUpdate() +void CUpdater::PerformUpdate() { m_State = PARSING_UPDATE; - dbg_msg("autoupdate", "Parsing update.json"); + dbg_msg("updater", "Parsing update.json"); ParseUpdate(); m_State = DOWNLOADING; @@ -234,7 +234,7 @@ void CAutoUpdate::PerformUpdate() FetchFile(PLAT_CLIENT_DOWN, "DDNet.tmp"); } -void CAutoUpdate::WinXpRestart() +void CUpdater::WinXpRestart() { char aBuf[512]; IOHANDLE bhFile = io_open(m_pStorage->GetBinaryPath("du.bat", aBuf, sizeof aBuf), IOFLAG_WRITE); diff --git a/src/engine/client/autoupdate.h b/src/engine/client/updater.h similarity index 91% rename from src/engine/client/autoupdate.h rename to src/engine/client/updater.h index 01fab6d97..7748aff6f 100644 --- a/src/engine/client/autoupdate.h +++ b/src/engine/client/updater.h @@ -1,7 +1,7 @@ -#ifndef ENGINE_CLIENT_AUTOUPDATE_H -#define ENGINE_CLIENT_AUTOUPDATE_H +#ifndef ENGINE_CLIENT_UPDATER_H +#define ENGINE_CLIENT_UPDATER_H -#include +#include #include #include #include @@ -32,7 +32,7 @@ #define PLAT_CLIENT_EXEC CLIENT_EXEC PLAT_EXT #define PLAT_SERVER_EXEC SERVER_EXEC PLAT_EXT -class CAutoUpdate : public IAutoUpdate +class CUpdater : public IUpdater { class IClient *m_pClient; class IStorage *m_pStorage; @@ -62,7 +62,7 @@ class CAutoUpdate : public IAutoUpdate void ReplaceServer(); public: - CAutoUpdate(); + CUpdater(); static void ProgressCallback(CFetchTask *pTask, void *pUser); static void CompletionCallback(CFetchTask *pTask, void *pUser); diff --git a/src/engine/autoupdate.h b/src/engine/updater.h similarity index 75% rename from src/engine/autoupdate.h rename to src/engine/updater.h index 857f0c28b..8b474da0f 100644 --- a/src/engine/autoupdate.h +++ b/src/engine/updater.h @@ -1,11 +1,11 @@ -#ifndef ENGINE_AUTOUPDATE_H -#define ENGINE_AUTOUPDATE_H +#ifndef ENGINE_UPDATER_H +#define ENGINE_UPDATER_H #include "kernel.h" -class IAutoUpdate : public IInterface +class IUpdater : public IInterface { - MACRO_INTERFACE("autoupdate", 0) + MACRO_INTERFACE("updater", 0) public: enum { diff --git a/src/game/client/component.h b/src/game/client/component.h index 6a4b1ec7c..b39c2cd05 100644 --- a/src/game/client/component.h +++ b/src/game/client/component.h @@ -28,7 +28,7 @@ protected: class IServerBrowser *ServerBrowser() const { return m_pClient->ServerBrowser(); } class CLayers *Layers() const { return m_pClient->Layers(); } class CCollision *Collision() const { return m_pClient->Collision(); } - class IAutoUpdate *AutoUpdate() const { return m_pClient->AutoUpdate(); } + class IUpdater *Updater() const { return m_pClient->Updater(); } public: virtual ~CComponent() {} class CGameClient *GameClient() const { return m_pClient; } diff --git a/src/game/client/components/menus_browser.cpp b/src/game/client/components/menus_browser.cpp index b88732d37..95afd353f 100644 --- a/src/game/client/components/menus_browser.cpp +++ b/src/game/client/components/menus_browser.cpp @@ -6,7 +6,7 @@ #include #include #include -#include +#include #include #include @@ -1281,23 +1281,23 @@ void CMenus::RenderServerbrowser(CUIRect MainView) #if defined(CONF_FAMILY_WINDOWS) || (defined(CONF_PLATFORM_LINUX) && !defined(__ANDROID__)) StatusBox.HSplitBottom(15.0f, &StatusBox, &Button); char aBuf[64]; - int State = AutoUpdate()->GetCurrentState(); + int State = Updater()->GetCurrentState(); bool NeedUpdate = str_comp(Client()->LatestVersion(), "0"); - if(State == IAutoUpdate::CLEAN && NeedUpdate) + if(State == IUpdater::CLEAN && NeedUpdate) { str_format(aBuf, sizeof(aBuf), "DDNet %s is out!", Client()->LatestVersion()); TextRender()->TextColor(1.0f, 0.4f, 0.4f, 1.0f); } - else if(State == IAutoUpdate::CLEAN) + else if(State == IUpdater::CLEAN) str_format(aBuf, sizeof(aBuf), Localize("Current version: %s"), GAME_VERSION); - else if(State >= IAutoUpdate::GETTING_MANIFEST && State < IAutoUpdate::NEED_RESTART) - str_format(aBuf, sizeof(aBuf), "Downloading %s:", AutoUpdate()->GetCurrentFile()); - else if(State == IAutoUpdate::FAIL) + else if(State >= IUpdater::GETTING_MANIFEST && State < IUpdater::NEED_RESTART) + str_format(aBuf, sizeof(aBuf), "Downloading %s:", Updater()->GetCurrentFile()); + else if(State == IUpdater::FAIL) { str_format(aBuf, sizeof(aBuf), "Failed to download a file! Restart client to retry..."); TextRender()->TextColor(1.0f, 0.4f, 0.4f, 1.0f); } - else if(State == IAutoUpdate::NEED_RESTART) + else if(State == IUpdater::NEED_RESTART) { str_format(aBuf, sizeof(aBuf), "DDNet Client updated!"); TextRender()->TextColor(1.0f, 0.4f, 0.4f, 1.0f); @@ -1307,7 +1307,7 @@ void CMenus::RenderServerbrowser(CUIRect MainView) Button.VSplitLeft(TextRender()->TextWidth(0, 14.0f, aBuf, -1) + 10.0f, &Button, &Part); - if(State == IAutoUpdate::CLEAN && NeedUpdate) + if(State == IUpdater::CLEAN && NeedUpdate) { CUIRect Update; Part.VSplitLeft(100.0f, &Update, NULL); @@ -1315,10 +1315,10 @@ void CMenus::RenderServerbrowser(CUIRect MainView) static int s_ButtonUpdate = 0; if(DoButton_Menu(&s_ButtonUpdate, Localize("Update now"), 0, &Update)) { - AutoUpdate()->InitiateUpdate(); + Updater()->InitiateUpdate(); } } - else if(State == IAutoUpdate::NEED_RESTART) + else if(State == IUpdater::NEED_RESTART) { CUIRect Restart; Part.VSplitLeft(50.0f, &Restart, &Part); @@ -1329,14 +1329,14 @@ void CMenus::RenderServerbrowser(CUIRect MainView) Client()->Restart(); } } - else if(State >= IAutoUpdate::GETTING_MANIFEST && State < IAutoUpdate::NEED_RESTART) + else if(State >= IUpdater::GETTING_MANIFEST && State < IUpdater::NEED_RESTART) { CUIRect ProgressBar, Percent; Part.VSplitLeft(100.0f, &ProgressBar, &Percent); ProgressBar.y += 2.0f; ProgressBar.HMargin(1.0f, &ProgressBar); RenderTools()->DrawUIRect(&ProgressBar, vec4(1.0f, 1.0f, 1.0f, 0.25f), CUI::CORNER_ALL, 5.0f); - ProgressBar.w = clamp((float)AutoUpdate()->GetCurrentPercent(), 10.0f, 100.0f); + ProgressBar.w = clamp((float)Updater()->GetCurrentPercent(), 10.0f, 100.0f); RenderTools()->DrawUIRect(&ProgressBar, vec4(1.0f, 1.0f, 1.0f, 0.5f), CUI::CORNER_ALL, 5.0f); } #else diff --git a/src/game/client/components/menus_settings.cpp b/src/game/client/components/menus_settings.cpp index 6bcfde760..0fa31d663 100644 --- a/src/game/client/components/menus_settings.cpp +++ b/src/game/client/components/menus_settings.cpp @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #include @@ -1798,27 +1798,27 @@ void CMenus::RenderSettingsDDRace(CUIRect MainView) g_Config.m_ClHttpMapDownload ^= 1; } - //AutoUpdate + //Updater #if defined(CONF_FAMILY_WINDOWS) || (defined(CONF_PLATFORM_LINUX) && !defined(__ANDROID__)) { Left.HSplitTop(20.0f, &Label, &Left); bool NeedUpdate = str_comp(Client()->LatestVersion(), "0"); char aBuf[256]; - int State = AutoUpdate()->GetCurrentState(); + int State = Updater()->GetCurrentState(); //Update Button - if(NeedUpdate && State <= IAutoUpdate::CLEAN) + if(NeedUpdate && State <= IUpdater::CLEAN) { str_format(aBuf, sizeof(aBuf), "DDNet %s is available:", Client()->LatestVersion()); Label.VSplitLeft(TextRender()->TextWidth(0, 14.0f, aBuf, -1) + 10.0f, &Label, &Button); Button.VSplitLeft(100.0f, &Button, 0); static int s_ButtonUpdate = 0; if(DoButton_Menu(&s_ButtonUpdate, "Update now", 0, &Button)) - AutoUpdate()->InitiateUpdate(); + Updater()->InitiateUpdate(); } - else if(State >= IAutoUpdate::GETTING_MANIFEST && State < IAutoUpdate::NEED_RESTART) + else if(State >= IUpdater::GETTING_MANIFEST && State < IUpdater::NEED_RESTART) str_format(aBuf, sizeof(aBuf), "Updating..."); - else if(State == IAutoUpdate::NEED_RESTART){ + else if(State == IUpdater::NEED_RESTART){ str_format(aBuf, sizeof(aBuf), "DDNet Client updated!"); m_NeedRestartUpdate = true; } diff --git a/src/game/client/gameclient.cpp b/src/game/client/gameclient.cpp index da28b5f8d..4006fdce8 100644 --- a/src/game/client/gameclient.cpp +++ b/src/game/client/gameclient.cpp @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include #include @@ -125,7 +125,7 @@ void CGameClient::OnConsoleInit() m_pEditor = Kernel()->RequestInterface(); m_pFriends = Kernel()->RequestInterface(); #if defined(CONF_FAMILY_WINDOWS) || (defined(CONF_PLATFORM_LINUX) && !defined(__ANDROID__)) - m_pAutoUpdate = Kernel()->RequestInterface(); + m_pUpdater = Kernel()->RequestInterface(); #endif // setup pointers diff --git a/src/game/client/gameclient.h b/src/game/client/gameclient.h index ad790aad1..5ae4ef994 100644 --- a/src/game/client/gameclient.h +++ b/src/game/client/gameclient.h @@ -95,7 +95,7 @@ class CGameClient : public IGameClient class IServerBrowser *m_pServerBrowser; class IEditor *m_pEditor; class IFriends *m_pFriends; - class IAutoUpdate *m_pAutoUpdate; + class IUpdater *m_pUpdater; CLayers m_Layers; class CCollision m_Collision; @@ -136,7 +136,7 @@ public: class CCollision *Collision() { return &m_Collision; }; class IEditor *Editor() { return m_pEditor; } class IFriends *Friends() { return m_pFriends; } - class IAutoUpdate *AutoUpdate() { return m_pAutoUpdate; } + class IUpdater *Updater() { return m_pUpdater; } int NetobjNumCorrections() { return m_NetObjHandler.NumObjCorrections(); } const char *NetobjCorrectedOn() { return m_NetObjHandler.CorrectedObjOn(); }