From f260a3786aaa1d276c9989188c6c869cad529834 Mon Sep 17 00:00:00 2001 From: saml1er Date: Wed, 14 Oct 2020 12:24:18 +0500 Subject: [PATCH 1/5] Fix 1708: Force people to opt back into Default release type --- Client/core/CMainMenu.cpp | 7 +++++++ Client/core/CVersionUpdater.cpp | 21 +++++++++++++++++++++ Client/core/CVersionUpdater.h | 1 + 3 files changed, 29 insertions(+) diff --git a/Client/core/CMainMenu.cpp b/Client/core/CMainMenu.cpp index 21c3e8cfd15..6515abbfb2c 100644 --- a/Client/core/CMainMenu.cpp +++ b/Client/core/CMainMenu.cpp @@ -450,6 +450,13 @@ void CMainMenu::Update() if (m_bIsFullyVisible) { + static bool versionUpdaterChecked = false; + if (!versionUpdaterChecked) + { + versionUpdaterChecked = true; + GetVersionUpdater()->OnMainMenuFullyVisible(); + } + // Grab our cursor position tagPOINT cursor; GetCursorPos(&cursor); diff --git a/Client/core/CVersionUpdater.cpp b/Client/core/CVersionUpdater.cpp index a37b20b7d59..0cba60300be 100644 --- a/Client/core/CVersionUpdater.cpp +++ b/Client/core/CVersionUpdater.cpp @@ -130,6 +130,7 @@ class CVersionUpdater : public CVersionUpdaterInterface int DoPollDownload(); int DoSendPostToNextServer(); int DoPollPost(); + void OnMainMenuFullyVisible(); static void* StaticThreadProc(void* pContext); void* ThreadProc(); @@ -3377,3 +3378,23 @@ int CVersionUpdater::DoPollPost() } return RES_OK; } + +// Issue: #1708 +// Set the update settings to stable build if the user is on 1.5.8. +// We do this only once, this is why we need to write to registry. +void CVersionUpdater::OnMainMenuFullyVisible() +{ + const SString requiredValue = "discord-rich-presence"; + SString lastSubKey = "version-revert-reason"; + if (GetApplicationSetting(lastSubKey) != requiredValue) + { + SetApplicationSetting(lastSubKey, requiredValue); + // check if the MTA client version is 1.5.8 + if (MTASA_VERSION_MINOR == 5 && MTASA_VERSION_MAINTENANCE == 8) + { + CVARS_SET("update_build_type", 0); + SString strMessage = _("We've reset you back to Default, please go change your settings again if you want Nightly updates.\n"); + g_pCore->ShowMessageBox(_("VERSION UPDATE INFORMATION"), strMessage, MB_BUTTON_OK | MB_ICON_INFO); + } + } +} diff --git a/Client/core/CVersionUpdater.h b/Client/core/CVersionUpdater.h index 94f466bb3a4..09565405dea 100644 --- a/Client/core/CVersionUpdater.h +++ b/Client/core/CVersionUpdater.h @@ -28,6 +28,7 @@ class CVersionUpdaterInterface virtual void GetBrowseVersionMaps(std::map& outBlockedVersionMap, std::map& outAllowedVersionMap) = 0; virtual void GetNewsSettings(SString& strOutOldestPost, uint& uiOutMaxHistoryLength) = 0; virtual const SString& GetDebugFilterString() = 0; + virtual void OnMainMenuFullyVisible() = 0; }; CVersionUpdaterInterface* GetVersionUpdater(); From db1515784fc342bb71234098093754ac0f02196c Mon Sep 17 00:00:00 2001 From: saml1er Date: Wed, 14 Oct 2020 16:12:54 +0500 Subject: [PATCH 2/5] Tweak update settings revert message --- Client/core/CVersionUpdater.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Client/core/CVersionUpdater.cpp b/Client/core/CVersionUpdater.cpp index 0cba60300be..5f2e61fe51d 100644 --- a/Client/core/CVersionUpdater.cpp +++ b/Client/core/CVersionUpdater.cpp @@ -3393,7 +3393,7 @@ void CVersionUpdater::OnMainMenuFullyVisible() if (MTASA_VERSION_MINOR == 5 && MTASA_VERSION_MAINTENANCE == 8) { CVARS_SET("update_build_type", 0); - SString strMessage = _("We've reset you back to Default, please go change your settings again if you want Nightly updates.\n"); + SString strMessage = _("We've reset your update preferences back to Default, please go change your settings again if you want Nightly updates.\n"); g_pCore->ShowMessageBox(_("VERSION UPDATE INFORMATION"), strMessage, MB_BUTTON_OK | MB_ICON_INFO); } } From 56059415dde7eed7165d564383b7b100536689cd Mon Sep 17 00:00:00 2001 From: saml1er Date: Wed, 14 Oct 2020 16:34:46 +0500 Subject: [PATCH 3/5] CVersionUpdater::OnMainMenuFullyVisible improvements --- Client/core/CVersionUpdater.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Client/core/CVersionUpdater.cpp b/Client/core/CVersionUpdater.cpp index 5f2e61fe51d..ae24e4bef6c 100644 --- a/Client/core/CVersionUpdater.cpp +++ b/Client/core/CVersionUpdater.cpp @@ -3385,12 +3385,12 @@ int CVersionUpdater::DoPollPost() void CVersionUpdater::OnMainMenuFullyVisible() { const SString requiredValue = "discord-rich-presence"; - SString lastSubKey = "version-revert-reason"; + const SString lastSubKey = "version-revert-reason"; if (GetApplicationSetting(lastSubKey) != requiredValue) { SetApplicationSetting(lastSubKey, requiredValue); // check if the MTA client version is 1.5.8 - if (MTASA_VERSION_MINOR == 5 && MTASA_VERSION_MAINTENANCE == 8) + if (MTASA_VERSION_MAJOR == 1 && MTASA_VERSION_MINOR == 5 && MTASA_VERSION_MAINTENANCE == 8) { CVARS_SET("update_build_type", 0); SString strMessage = _("We've reset your update preferences back to Default, please go change your settings again if you want Nightly updates.\n"); From f073b3e1ffde6bdac6b7dc21c2b6fd45b4907353 Mon Sep 17 00:00:00 2001 From: saml1er Date: Thu, 15 Oct 2020 16:24:56 +0500 Subject: [PATCH 4/5] Use std::string in CVersionUpdater::OnMainMenuFullyVisible --- Client/core/CVersionUpdater.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Client/core/CVersionUpdater.cpp b/Client/core/CVersionUpdater.cpp index ae24e4bef6c..cff7a89fe9a 100644 --- a/Client/core/CVersionUpdater.cpp +++ b/Client/core/CVersionUpdater.cpp @@ -3384,8 +3384,8 @@ int CVersionUpdater::DoPollPost() // We do this only once, this is why we need to write to registry. void CVersionUpdater::OnMainMenuFullyVisible() { - const SString requiredValue = "discord-rich-presence"; - const SString lastSubKey = "version-revert-reason"; + const std::string requiredValue = "discord-rich-presence"; + const std::string lastSubKey = "version-revert-reason"; if (GetApplicationSetting(lastSubKey) != requiredValue) { SetApplicationSetting(lastSubKey, requiredValue); @@ -3393,8 +3393,8 @@ void CVersionUpdater::OnMainMenuFullyVisible() if (MTASA_VERSION_MAJOR == 1 && MTASA_VERSION_MINOR == 5 && MTASA_VERSION_MAINTENANCE == 8) { CVARS_SET("update_build_type", 0); - SString strMessage = _("We've reset your update preferences back to Default, please go change your settings again if you want Nightly updates.\n"); - g_pCore->ShowMessageBox(_("VERSION UPDATE INFORMATION"), strMessage, MB_BUTTON_OK | MB_ICON_INFO); + std::string message = _("We've reset your update preferences back to Default, please go change your settings again if you want Nightly updates.\n"); + g_pCore->ShowMessageBox(_("VERSION UPDATE INFORMATION"), message.c_str(), MB_BUTTON_OK | MB_ICON_INFO); } } } From 9a129e569e5428329858955178c24be60c4fb351 Mon Sep 17 00:00:00 2001 From: saml1er Date: Thu, 15 Oct 2020 21:00:55 +0500 Subject: [PATCH 5/5] Reset update settings for 20670 build only --- Client/core/CVersionUpdater.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Client/core/CVersionUpdater.cpp b/Client/core/CVersionUpdater.cpp index cff7a89fe9a..fdd7894c3c2 100644 --- a/Client/core/CVersionUpdater.cpp +++ b/Client/core/CVersionUpdater.cpp @@ -3384,6 +3384,8 @@ int CVersionUpdater::DoPollPost() // We do this only once, this is why we need to write to registry. void CVersionUpdater::OnMainMenuFullyVisible() { + if (MTASA_VERSION_BUILD != 20670) // 20670 is the build number with PR #1712 merged. + return; const std::string requiredValue = "discord-rich-presence"; const std::string lastSubKey = "version-revert-reason"; if (GetApplicationSetting(lastSubKey) != requiredValue)