mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
Change os_compare_version
to os_is_winxp_or_lower
This stops leaking OS details in non-`system.c` files.
This commit is contained in:
parent
27722633a3
commit
f0c647dba5
|
@ -2760,21 +2760,19 @@ void shell_execute(const char *file)
|
|||
#endif
|
||||
}
|
||||
|
||||
int os_compare_version(unsigned int major, unsigned int minor)
|
||||
int os_is_winxp_or_lower(unsigned int major, unsigned int minor)
|
||||
{
|
||||
#if defined(CONF_FAMILY_WINDOWS)
|
||||
static const DWORD WINXP_MAJOR = 5;
|
||||
static const DWORD WINXP_MINOR = 1;
|
||||
OSVERSIONINFO ver;
|
||||
mem_zero(&ver, sizeof(OSVERSIONINFO));
|
||||
ver.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
|
||||
GetVersionEx(&ver);
|
||||
if(ver.dwMajorVersion > major || (ver.dwMajorVersion == major && ver.dwMinorVersion > minor))
|
||||
return 1;
|
||||
else if(ver.dwMajorVersion == major && ver.dwMinorVersion == minor)
|
||||
return 0;
|
||||
else
|
||||
return -1;
|
||||
return ver.dwMajorVersion < WINXP_MAJOR
|
||||
|| (ver.dwMajorVersion == WINXP_MAJOR && ver.dwMinorVersion <= WINXP_MINOR);
|
||||
#else
|
||||
return 0; // unimplemented
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -1512,19 +1512,14 @@ int pid();
|
|||
void shell_execute(const char *file);
|
||||
|
||||
/*
|
||||
Function: os_compare_version
|
||||
Compares the OS version to a given major and minor.
|
||||
|
||||
Parameters:
|
||||
major - Major version to compare to.
|
||||
minor - Minor version to compare to.
|
||||
Function: os_is_winxp_or_lower
|
||||
Checks whether the program runs on Windows XP or lower.
|
||||
|
||||
Returns:
|
||||
1 - OS version higher.
|
||||
0 - OS version same.
|
||||
-1 - OS version lower.
|
||||
1 - Windows XP or lower.
|
||||
0 - Higher Windows version, Linux, macOS, etc.
|
||||
*/
|
||||
int os_compare_version(unsigned int major, unsigned int minor);
|
||||
int os_is_winxp_or_lower();
|
||||
|
||||
/*
|
||||
Function: generate_password
|
||||
|
|
|
@ -3623,11 +3623,7 @@ bool CClient::RaceRecord_IsRecording()
|
|||
void CClient::RequestDDNetInfo()
|
||||
{
|
||||
char aUrl[256];
|
||||
#if defined(CONF_FAMILY_WINDOWS)
|
||||
static bool s_IsWinXP = os_compare_version(5U, 1U) <= 0;
|
||||
#else
|
||||
static bool s_IsWinXP = false;
|
||||
#endif
|
||||
static bool s_IsWinXP = os_is_winxp_or_lower();
|
||||
if(s_IsWinXP)
|
||||
str_copy(aUrl, "http://info.ddnet.tw/info", sizeof(aUrl));
|
||||
else
|
||||
|
|
|
@ -25,11 +25,7 @@ void CUpdater::Init()
|
|||
m_pClient = Kernel()->RequestInterface<IClient>();
|
||||
m_pStorage = Kernel()->RequestInterface<IStorage>();
|
||||
m_pFetcher = Kernel()->RequestInterface<IFetcher>();
|
||||
#if defined(CONF_FAMILY_WINDOWS)
|
||||
m_IsWinXP = os_compare_version(5U, 1U) <= 0;
|
||||
#else
|
||||
m_IsWinXP = false;
|
||||
#endif
|
||||
m_IsWinXP = os_is_winxp_or_lower();
|
||||
}
|
||||
|
||||
void CUpdater::ProgressCallback(IFetchTask *pTask, void *pUser)
|
||||
|
@ -117,7 +113,7 @@ void CUpdater::ReplaceClient()
|
|||
{
|
||||
dbg_msg("updater", "replacing " PLAT_CLIENT_EXEC);
|
||||
|
||||
//Replace running executable by renaming twice...
|
||||
// Replace running executable by renaming twice...
|
||||
if(!m_IsWinXP)
|
||||
{
|
||||
m_pStorage->RemoveBinaryFile("DDNet.old");
|
||||
|
|
Loading…
Reference in a new issue