Add a new method that return version numbers

This commit is contained in:
smallmodel 2025-03-11 23:31:53 +01:00
parent c87c242098
commit 7a20bb4deb
No known key found for this signature in database
GPG key ID: 9F2D623CEDF08512
2 changed files with 22 additions and 14 deletions

View file

@ -25,13 +25,13 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#ifdef HAS_LIBCURL
#include <curl/curl.h>
# include <curl/curl.h>
//#include <httplib.h>
#include "../qcommon/json.hpp"
# include "../qcommon/json.hpp"
using json = nlohmann::json;
#include <chrono>
# include <chrono>
UpdateChecker updateChecker;
@ -168,6 +168,19 @@ bool UpdateChecker::CheckNewVersion() const
return false;
}
bool UpdateChecker::CheckNewVersion(int& major, int& minor, int& patch) const
{
if (!CheckNewVersion()) {
return false;
}
major = lastMajor;
minor = lastMinor;
patch = lastPatch;
return true;
}
bool UpdateChecker::ParseVersionNumber(const char *value, int& major, int& minor, int& patch) const
{
const char *p = value;
@ -242,7 +255,7 @@ void UpdateChecker::DoRequest()
try {
data = nlohmann::json::parse(responseString);
} catch(const std::exception& e) {
} catch (const std::exception& e) {
return;
}
@ -280,16 +293,10 @@ void UpdateChecker::RequestThread()
#else
void Sys_UpdateChecker_Init()
{
}
void Sys_UpdateChecker_Init() {}
void Sys_UpdateChecker_Process()
{
}
void Sys_UpdateChecker_Process() {}
void Sys_UpdateChecker_Shutdown()
{
}
void Sys_UpdateChecker_Shutdown() {}
#endif

View file

@ -53,6 +53,7 @@ public:
void Shutdown();
bool CheckNewVersion() const;
bool CheckNewVersion(int& major, int& minor, int& patch) const;
private:
void ShutdownClient();