diff --git a/Source/Project64/UserInterface/ProjectSupport.cpp b/Source/Project64/UserInterface/ProjectSupport.cpp index 5eff9b59f..f93e1a6b0 100644 --- a/Source/Project64/UserInterface/ProjectSupport.cpp +++ b/Source/Project64/UserInterface/ProjectSupport.cpp @@ -1,5 +1,6 @@ #include "stdafx.h" #include +#include #include #include @@ -106,10 +107,29 @@ std::string CProjectSupport::GenerateMachineID(void) void CProjectSupport::IncrementRunCount() { + time_t now = time(nullptr); + if (m_SupportInfo.LastUpdated <= now && ((now - m_SupportInfo.LastUpdated) / 60) < 60) + { + return; + } m_SupportInfo.RunCount += 1; + m_SupportInfo.LastUpdated = now; SaveSupportInfo(); } +bool CProjectSupport::ShowSuppotWindow() +{ + return true; + time_t now = time(nullptr); + if (m_SupportInfo.LastShown <= now && ((now - m_SupportInfo.LastShown) / 60) < 60) + { + return false; + } + m_SupportInfo.LastShown = now; + SaveSupportInfo(); + return true; +} + bool CProjectSupport::PerformRequest(const wchar_t * Url, const std::string & PostData, DWORD & StatusCode, std::vector & Headers) { StatusCode = 0; @@ -259,7 +279,7 @@ void CProjectSupport::LoadSupportInfo(void) } } - if (OutData.size() > 0) + if (OutData.size() == sizeof(SupportInfo) + 32) { SupportInfo * Info = (SupportInfo *)OutData.data(); const char * CurrentHash = (const char *)(OutData.data() + sizeof(SupportInfo)); diff --git a/Source/Project64/UserInterface/ProjectSupport.h b/Source/Project64/UserInterface/ProjectSupport.h index fd99cfe56..fb59ec520 100644 --- a/Source/Project64/UserInterface/ProjectSupport.h +++ b/Source/Project64/UserInterface/ProjectSupport.h @@ -11,6 +11,8 @@ class CProjectSupport char Name[300]; char MachineID[300]; uint32_t RunCount; + time_t LastUpdated; + time_t LastShown; bool Validated; } SupportInfo; @@ -20,6 +22,7 @@ public: bool RequestCode(const char * Email); bool ValidateCode(const char * Code); void IncrementRunCount(); + bool ShowSuppotWindow(); inline uint32_t RunCount() const { return m_SupportInfo.RunCount; } inline const char * MachineID(void) const { return m_SupportInfo.MachineID; } diff --git a/Source/Project64/UserInterface/SupportWindow.cpp b/Source/Project64/UserInterface/SupportWindow.cpp index 02a2acd25..2683146c3 100644 --- a/Source/Project64/UserInterface/SupportWindow.cpp +++ b/Source/Project64/UserInterface/SupportWindow.cpp @@ -33,7 +33,7 @@ void CSupportWindow::Show(HWND hParent, bool Delay) } m_Support.IncrementRunCount(); - if (m_Support.RunCount() < 7) + if (m_Support.RunCount() < 7 || !m_Support.ShowSuppotWindow()) { return; } @@ -116,7 +116,7 @@ LRESULT CSupportWindow::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /* MoveWindow(Left, Top, rcWin.Width(), rcWin.Height(), TRUE); - /*if (m_Delay && m_RunCount >= 10) + if (m_Delay && m_Support.RunCount() >= 15) { CMenuHandle menu = GetSystemMenu(false); menu.RemoveMenu(SC_CLOSE, MF_BYCOMMAND); @@ -127,7 +127,7 @@ LRESULT CSupportWindow::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /* GetDlgItem(IDCANCEL).EnableWindow(false); srand ((uint32_t)time(NULL)); SetTimer(0, 1000, NULL); - }*/ + } return TRUE; }