Skip to content

Commit c6f5ae2

Browse files
saml1ercodenulls
saml1er
andauthored
Fix #1708: Force people to opt back into Default release type (#1712)
* Fix 1708: Force people to opt back into Default release type * Tweak update settings revert message * CVersionUpdater::OnMainMenuFullyVisible improvements * Use std::string in CVersionUpdater::OnMainMenuFullyVisible * Reset update settings for 20670 build only Co-authored-by: saml1er <danishroar@gmail.com>
1 parent 89b5620 commit c6f5ae2

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

Client/core/CMainMenu.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,13 @@ void CMainMenu::Update()
450450

451451
if (m_bIsFullyVisible)
452452
{
453+
static bool versionUpdaterChecked = false;
454+
if (!versionUpdaterChecked)
455+
{
456+
versionUpdaterChecked = true;
457+
GetVersionUpdater()->OnMainMenuFullyVisible();
458+
}
459+
453460
// Grab our cursor position
454461
tagPOINT cursor;
455462
GetCursorPos(&cursor);

Client/core/CVersionUpdater.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ class CVersionUpdater : public CVersionUpdaterInterface
130130
int DoPollDownload();
131131
int DoSendPostToNextServer();
132132
int DoPollPost();
133+
void OnMainMenuFullyVisible();
133134

134135
static void* StaticThreadProc(void* pContext);
135136
void* ThreadProc();
@@ -3377,3 +3378,25 @@ int CVersionUpdater::DoPollPost()
33773378
}
33783379
return RES_OK;
33793380
}
3381+
3382+
// Issue: #1708
3383+
// Set the update settings to stable build if the user is on 1.5.8.
3384+
// We do this only once, this is why we need to write to registry.
3385+
void CVersionUpdater::OnMainMenuFullyVisible()
3386+
{
3387+
if (MTASA_VERSION_BUILD != 20670) // 20670 is the build number with PR #1712 merged.
3388+
return;
3389+
const std::string requiredValue = "discord-rich-presence";
3390+
const std::string lastSubKey = "version-revert-reason";
3391+
if (GetApplicationSetting(lastSubKey) != requiredValue)
3392+
{
3393+
SetApplicationSetting(lastSubKey, requiredValue);
3394+
// check if the MTA client version is 1.5.8
3395+
if (MTASA_VERSION_MAJOR == 1 && MTASA_VERSION_MINOR == 5 && MTASA_VERSION_MAINTENANCE == 8)
3396+
{
3397+
CVARS_SET("update_build_type", 0);
3398+
std::string message = _("We've reset your update preferences back to Default, please go change your settings again if you want Nightly updates.\n");
3399+
g_pCore->ShowMessageBox(_("VERSION UPDATE INFORMATION"), message.c_str(), MB_BUTTON_OK | MB_ICON_INFO);
3400+
}
3401+
}
3402+
}

Client/core/CVersionUpdater.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class CVersionUpdaterInterface
2828
virtual void GetBrowseVersionMaps(std::map<SString, int>& outBlockedVersionMap, std::map<SString, int>& outAllowedVersionMap) = 0;
2929
virtual void GetNewsSettings(SString& strOutOldestPost, uint& uiOutMaxHistoryLength) = 0;
3030
virtual const SString& GetDebugFilterString() = 0;
31+
virtual void OnMainMenuFullyVisible() = 0;
3132
};
3233

3334
CVersionUpdaterInterface* GetVersionUpdater();

0 commit comments

Comments
 (0)