mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Merge #1463
1463: Don't suggest to downgrade, clean up versioning (fixes #1440) r=def- a=def- Co-authored-by: def <dennis@felsin9.de>
This commit is contained in:
commit
35cb7f0b2c
|
@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 2.8)
|
|||
|
||||
file(STRINGS src/game/version.h VERSION_LINE
|
||||
LIMIT_COUNT 1
|
||||
REGEX GAME_RELEASE_VERSION
|
||||
REGEX "^#define GAME_VERSION "
|
||||
)
|
||||
|
||||
if(VERSION_LINE MATCHES "\"([0-9]+)\\.([0-9]+)\\.([0-9]+)\"")
|
||||
|
|
|
@ -2717,6 +2717,17 @@ char str_uppercase(char c)
|
|||
return c;
|
||||
}
|
||||
|
||||
int str_isallnum(const char *str)
|
||||
{
|
||||
while(*str)
|
||||
{
|
||||
if(!(*str >= '0' && *str <= '9'))
|
||||
return 0;
|
||||
str++;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int str_toint(const char *str) { return atoi(str); }
|
||||
int str_toint_base(const char *str, int base) { return strtol(str, NULL, base); }
|
||||
float str_tofloat(const char *str) { return atof(str); }
|
||||
|
|
|
@ -1612,6 +1612,7 @@ int str_toint_base(const char *str, int base);
|
|||
float str_tofloat(const char *str);
|
||||
int str_isspace(char c);
|
||||
char str_uppercase(char c);
|
||||
int str_isallnum(const char *str);
|
||||
unsigned str_quickhash(const char *str);
|
||||
|
||||
struct SKELETON;
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <climits>
|
||||
#include <tuple>
|
||||
|
||||
#include <base/math.h>
|
||||
#include <base/vmath.h>
|
||||
|
@ -2259,6 +2260,29 @@ void CClient::FinishDDNetInfo()
|
|||
LoadDDNetInfo();
|
||||
}
|
||||
|
||||
typedef std::tuple<int, int, int> Version;
|
||||
static const Version InvalidVersion = std::make_tuple(-1, -1, -1);
|
||||
|
||||
Version ToVersion(char *pStr)
|
||||
{
|
||||
int version[3] = {0, 0, 0};
|
||||
const char *p = strtok(pStr, ".");
|
||||
|
||||
for(int i = 0; i < 3 && p; ++i)
|
||||
{
|
||||
if(!str_isallnum(p))
|
||||
return InvalidVersion;
|
||||
|
||||
version[i] = str_toint(p);
|
||||
p = strtok(NULL, ".");
|
||||
}
|
||||
|
||||
if(p)
|
||||
return InvalidVersion;
|
||||
|
||||
return std::make_tuple(version[0], version[1], version[2]);
|
||||
}
|
||||
|
||||
void CClient::LoadDDNetInfo()
|
||||
{
|
||||
const json_value *pDDNetInfo = m_ServerBrowser.LoadDDNetInfo();
|
||||
|
@ -2269,10 +2293,13 @@ void CClient::LoadDDNetInfo()
|
|||
const json_value *pVersion = json_object_get(pDDNetInfo, "version");
|
||||
if(pVersion->type == json_string)
|
||||
{
|
||||
const char *pVersionString = json_string_get(pVersion);
|
||||
if(str_comp(pVersionString, GAME_RELEASE_VERSION))
|
||||
char aNewVersionStr[64];
|
||||
str_copy(aNewVersionStr, json_string_get(pVersion), sizeof(aNewVersionStr));
|
||||
char aCurVersionStr[64];
|
||||
str_copy(aCurVersionStr, GAME_VERSION, sizeof(aCurVersionStr));
|
||||
if(ToVersion(aNewVersionStr) > ToVersion(aCurVersionStr))
|
||||
{
|
||||
str_copy(m_aVersionStr, pVersionString, sizeof(m_aVersionStr));
|
||||
str_copy(m_aVersionStr, json_string_get(pVersion), sizeof(m_aVersionStr));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -122,7 +122,7 @@ void CRequest::Run()
|
|||
curl_easy_setopt(pHandle, CURLOPT_FAILONERROR, 1L);
|
||||
curl_easy_setopt(pHandle, CURLOPT_URL, m_aUrl);
|
||||
curl_easy_setopt(pHandle, CURLOPT_NOSIGNAL, 1L);
|
||||
curl_easy_setopt(pHandle, CURLOPT_USERAGENT, "DDNet " GAME_RELEASE_VERSION " (" CONF_PLATFORM_STRING "; " CONF_ARCH_STRING ")");
|
||||
curl_easy_setopt(pHandle, CURLOPT_USERAGENT, "DDNet " GAME_VERSION " (" CONF_PLATFORM_STRING "; " CONF_ARCH_STRING ")");
|
||||
|
||||
// We only trust our own custom-selected CAs for our own servers.
|
||||
// Other servers can use any CA trusted by the system.
|
||||
|
|
|
@ -233,7 +233,7 @@ void CUpdater::ParseUpdate()
|
|||
{
|
||||
const json_value *pTemp;
|
||||
const json_value *pCurrent = json_array_get(pVersions, i);
|
||||
if(str_comp(json_string_get(json_object_get(pCurrent, "version")), GAME_RELEASE_VERSION))
|
||||
if(str_comp(json_string_get(json_object_get(pCurrent, "version")), GAME_VERSION))
|
||||
{
|
||||
if(json_boolean_get(json_object_get(pCurrent, "client")))
|
||||
m_ClientUpdate = true;
|
||||
|
|
|
@ -229,7 +229,7 @@ void CServerBan::ConBanExt(IConsole::IResult *pResult, void *pUser)
|
|||
int Minutes = pResult->NumArguments()>1 ? clamp(pResult->GetInteger(1), 0, 44640) : 30;
|
||||
const char *pReason = pResult->NumArguments()>2 ? pResult->GetString(2) : "No reason given";
|
||||
|
||||
if(StrAllnum(pStr))
|
||||
if(str_isallnum(pStr))
|
||||
{
|
||||
int ClientID = str_toint(pStr);
|
||||
if(ClientID < 0 || ClientID >= MAX_CLIENTS || pThis->Server()->m_aClients[ClientID].m_State == CServer::CClient::STATE_EMPTY)
|
||||
|
|
|
@ -7,18 +7,6 @@
|
|||
#include "netban.h"
|
||||
|
||||
|
||||
bool CNetBan::StrAllnum(const char *pStr)
|
||||
{
|
||||
while(*pStr)
|
||||
{
|
||||
if(!(*pStr >= '0' && *pStr <= '9'))
|
||||
return false;
|
||||
pStr++;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
CNetBan::CNetHash::CNetHash(const NETADDR *pAddr)
|
||||
{
|
||||
if(pAddr->type==NETTYPE_IPV4)
|
||||
|
@ -478,7 +466,7 @@ void CNetBan::ConUnban(IConsole::IResult *pResult, void *pUser)
|
|||
CNetBan *pThis = static_cast<CNetBan *>(pUser);
|
||||
|
||||
const char *pStr = pResult->GetString(0);
|
||||
if(StrAllnum(pStr))
|
||||
if(str_isallnum(pStr))
|
||||
pThis->UnbanByIndex(str_toint(pStr));
|
||||
else
|
||||
{
|
||||
|
|
|
@ -58,9 +58,6 @@ protected:
|
|||
return pBuffer;
|
||||
}
|
||||
|
||||
// todo: move?
|
||||
static bool StrAllnum(const char *pStr);
|
||||
|
||||
class CNetHash
|
||||
{
|
||||
public:
|
||||
|
|
|
@ -2,9 +2,8 @@
|
|||
/* If you are missing that file, acquire a complete release at teeworlds.com. */
|
||||
#ifndef GAME_VERSION_H
|
||||
#define GAME_VERSION_H
|
||||
#define GAME_VERSION "0.6.4, 11.8"
|
||||
#define GAME_NETVERSION "0.6 626fce9a778df4d4"
|
||||
#define GAME_RELEASE_VERSION "11.8"
|
||||
#define GAME_VERSION "11.8"
|
||||
#define CLIENT_VERSIONNR 11080
|
||||
extern const char *GIT_SHORTREV_HASH;
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue