mirror of
https://github.com/ddnet/ddnet.git
synced 2024-09-19 09:12:19 +00:00
Compare commits
4 commits
c599de5728
...
c0d702bb1a
Author | SHA1 | Date | |
---|---|---|---|
c0d702bb1a | |||
9f278979e5 | |||
32e9240634 | |||
e9a2ffde38 |
|
@ -621,6 +621,18 @@ void CClient::Connect(const char *pAddress, const char *pPassword)
|
|||
else
|
||||
m_aNetClient[CONN_MAIN].Connect(aConnectAddrs, NumConnectAddrs);
|
||||
|
||||
const CServerBrowser::CServerEntry *pEntry = m_ServerBrowser.Find(aConnectAddrs[0]);
|
||||
if(pEntry != nullptr && pEntry->m_GotInfo)
|
||||
{
|
||||
if(str_length(pEntry->m_Info.m_aVerifyUrl))
|
||||
{
|
||||
std::shared_ptr<CHttpRequest> pVerifyGet = HttpGet(pEntry->m_Info.m_aVerifyUrl);
|
||||
pVerifyGet->Timeout(CTimeout{10000, 0, 500, 10});
|
||||
pVerifyGet->IpResolve(aConnectAddrs[0].type == NETTYPE_IPV4 ? IPRESOLVE::V4 : IPRESOLVE::V6);
|
||||
Http()->Run(pVerifyGet);
|
||||
}
|
||||
}
|
||||
|
||||
m_aNetClient[CONN_MAIN].RefreshStun();
|
||||
SetState(IClient::STATE_CONNECTING);
|
||||
|
||||
|
|
|
@ -300,7 +300,7 @@ void CGraphics_Threaded::UnloadTexture(CTextureHandle *pIndex)
|
|||
FreeTextureIndex(pIndex);
|
||||
}
|
||||
|
||||
static bool ConvertToRGBA(uint8_t *pDest, const CImageInfo &SrcImage)
|
||||
bool ConvertToRGBA(uint8_t *pDest, const CImageInfo &SrcImage)
|
||||
{
|
||||
if(SrcImage.m_Format == CImageInfo::FORMAT_RGBA)
|
||||
{
|
||||
|
|
|
@ -124,6 +124,8 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
bool ConvertToRGBA(uint8_t *pDest, const CImageInfo &SrcImage);
|
||||
|
||||
/*
|
||||
Structure: CVideoMode
|
||||
*/
|
||||
|
|
|
@ -2357,6 +2357,10 @@ void CServer::UpdateRegisterServerInfo()
|
|||
JsonWriter.WriteAttribute("requires_login");
|
||||
JsonWriter.WriteBoolValue(false);
|
||||
|
||||
// Client will send a HTTP GET request to the url of sv_verify_url upon connecting
|
||||
JsonWriter.WriteAttribute("verify_url");
|
||||
JsonWriter.WriteStrValue(g_Config.m_SvVerifyUrl);
|
||||
|
||||
JsonWriter.WriteAttribute("clients");
|
||||
JsonWriter.BeginArray();
|
||||
|
||||
|
|
|
@ -118,6 +118,7 @@ public:
|
|||
CClient m_aClients[SERVERINFO_MAX_CLIENTS];
|
||||
int m_NumFilteredPlayers;
|
||||
bool m_RequiresLogin;
|
||||
char m_aVerifyUrl[128];
|
||||
|
||||
static int EstimateLatency(int Loc1, int Loc2);
|
||||
static bool ParseLocation(int *pResult, const char *pString);
|
||||
|
|
|
@ -444,6 +444,7 @@ MACRO_CONFIG_INT(SvDnsblBan, sv_dnsbl_ban, 0, 0, 1, CFGFLAG_SERVER, "Automatical
|
|||
MACRO_CONFIG_STR(SvDnsblBanReason, sv_dnsbl_ban_reason, 128, "VPN detected, try connecting without. Contact admin if mistaken", CFGFLAG_SERVER, "Ban reason for 'sv_dnsbl_ban'")
|
||||
MACRO_CONFIG_INT(SvDnsblChat, sv_dnsbl_chat, 0, 0, 1, CFGFLAG_SERVER, "Don't allow chat from blacklisted addresses")
|
||||
MACRO_CONFIG_INT(SvRconVote, sv_rcon_vote, 0, 0, 1, CFGFLAG_SERVER, "Only allow authed clients to call votes")
|
||||
MACRO_CONFIG_STR(SvVerifyUrl, sv_verify_url, 128, "", CFGFLAG_SERVER, "A URL which the client will send a HTTP GET request to upon connecting")
|
||||
|
||||
MACRO_CONFIG_INT(SvPlayerDemoRecord, sv_player_demo_record, 0, 0, 1, CFGFLAG_SERVER, "Automatically record demos for each player")
|
||||
MACRO_CONFIG_INT(SvDemoChat, sv_demo_chat, 0, 0, 1, CFGFLAG_SERVER, "Record chat for demos")
|
||||
|
|
|
@ -72,6 +72,7 @@ bool CServerInfo2::FromJsonRaw(CServerInfo2 *pOut, const json_value *pJson)
|
|||
const json_value &Version = ServerInfo["version"];
|
||||
const json_value &Clients = ServerInfo["clients"];
|
||||
const json_value &RequiresLogin = ServerInfo["requires_login"];
|
||||
const json_value &VerifyUrl = ServerInfo["verify_url"];
|
||||
|
||||
Error = false;
|
||||
Error = Error || MaxClients.type != json_integer;
|
||||
|
@ -103,6 +104,11 @@ bool CServerInfo2::FromJsonRaw(CServerInfo2 *pOut, const json_value *pJson)
|
|||
{
|
||||
pOut->m_RequiresLogin = RequiresLogin;
|
||||
}
|
||||
str_copy(pOut->m_aVerifyUrl, "");
|
||||
if(VerifyUrl.type == json_string)
|
||||
{
|
||||
str_copy(pOut->m_aVerifyUrl, VerifyUrl);
|
||||
}
|
||||
pOut->m_Passworded = Passworded;
|
||||
str_copy(pOut->m_aGameType, GameType);
|
||||
str_copy(pOut->m_aName, Name);
|
||||
|
@ -239,6 +245,7 @@ CServerInfo2::operator CServerInfo() const
|
|||
str_copy(Result.m_aName, m_aName);
|
||||
str_copy(Result.m_aMap, m_aMapName);
|
||||
str_copy(Result.m_aVersion, m_aVersion);
|
||||
str_copy(Result.m_aVerifyUrl, m_aVerifyUrl);
|
||||
|
||||
for(int i = 0; i < minimum(m_NumClients, (int)SERVERINFO_MAX_CLIENTS); i++)
|
||||
{
|
||||
|
|
|
@ -39,6 +39,7 @@ public:
|
|||
char m_aMapName[MAX_MAP_LENGTH];
|
||||
char m_aVersion[32];
|
||||
bool m_RequiresLogin;
|
||||
char m_aVerifyUrl[128];
|
||||
|
||||
bool operator==(const CServerInfo2 &Other) const;
|
||||
bool operator!=(const CServerInfo2 &Other) const { return !(*this == Other); }
|
||||
|
|
|
@ -4384,7 +4384,7 @@ bool CEditor::ReplaceImage(const char *pFileName, int StorageType, bool CheckDup
|
|||
}
|
||||
}
|
||||
|
||||
CEditorImage ImgInfo(this);
|
||||
CImageInfo ImgInfo;
|
||||
if(!Graphics()->LoadPng(ImgInfo, pFileName, StorageType))
|
||||
{
|
||||
ShowFileDialogError("Failed to load image from file '%s'.", pFileName);
|
||||
|
@ -4394,21 +4394,33 @@ bool CEditor::ReplaceImage(const char *pFileName, int StorageType, bool CheckDup
|
|||
std::shared_ptr<CEditorImage> pImg = m_Map.m_vpImages[m_SelectedImage];
|
||||
Graphics()->UnloadTexture(&(pImg->m_Texture));
|
||||
pImg->Free();
|
||||
*pImg = ImgInfo;
|
||||
pImg->m_Width = ImgInfo.m_Width;
|
||||
pImg->m_Height = ImgInfo.m_Height;
|
||||
pImg->m_Format = ImgInfo.m_Format;
|
||||
pImg->m_pData = ImgInfo.m_pData;
|
||||
str_copy(pImg->m_aName, aBuf);
|
||||
pImg->m_External = IsVanillaImage(pImg->m_aName);
|
||||
|
||||
if(!pImg->m_External && g_Config.m_ClEditorDilate == 1 && pImg->m_Format == CImageInfo::FORMAT_RGBA)
|
||||
if(!pImg->m_External && pImg->m_Format != CImageInfo::FORMAT_RGBA)
|
||||
{
|
||||
DilateImage(ImgInfo.m_pData, ImgInfo.m_Width, ImgInfo.m_Height);
|
||||
uint8_t *pRgbaData = static_cast<uint8_t *>(malloc((size_t)pImg->m_Width * pImg->m_Height * CImageInfo::PixelSize(CImageInfo::FORMAT_RGBA)));
|
||||
ConvertToRGBA(pRgbaData, *pImg);
|
||||
free(pImg->m_pData);
|
||||
pImg->m_pData = pRgbaData;
|
||||
pImg->m_Format = CImageInfo::FORMAT_RGBA;
|
||||
}
|
||||
|
||||
if(!pImg->m_External && g_Config.m_ClEditorDilate == 1)
|
||||
{
|
||||
DilateImage(pImg->m_pData, pImg->m_Width, pImg->m_Height);
|
||||
}
|
||||
|
||||
pImg->m_AutoMapper.Load(pImg->m_aName);
|
||||
int TextureLoadFlag = Graphics()->Uses2DTextureArrays() ? IGraphics::TEXLOAD_TO_2D_ARRAY_TEXTURE : IGraphics::TEXLOAD_TO_3D_TEXTURE;
|
||||
if(ImgInfo.m_Width % 16 != 0 || ImgInfo.m_Height % 16 != 0)
|
||||
if(pImg->m_Width % 16 != 0 || pImg->m_Height % 16 != 0)
|
||||
TextureLoadFlag = 0;
|
||||
pImg->m_Texture = Graphics()->LoadTextureRaw(ImgInfo, TextureLoadFlag, pFileName);
|
||||
ImgInfo.m_pData = nullptr;
|
||||
pImg->m_Texture = Graphics()->LoadTextureRaw(*pImg, TextureLoadFlag, pFileName);
|
||||
|
||||
SortImages();
|
||||
for(size_t i = 0; i < m_Map.m_vpImages.size(); ++i)
|
||||
{
|
||||
|
@ -4447,7 +4459,7 @@ bool CEditor::AddImage(const char *pFileName, int StorageType, void *pUser)
|
|||
return false;
|
||||
}
|
||||
|
||||
CEditorImage ImgInfo(pEditor);
|
||||
CImageInfo ImgInfo;
|
||||
if(!pEditor->Graphics()->LoadPng(ImgInfo, pFileName, StorageType))
|
||||
{
|
||||
pEditor->ShowFileDialogError("Failed to load image from file '%s'.", pFileName);
|
||||
|
@ -4455,19 +4467,30 @@ bool CEditor::AddImage(const char *pFileName, int StorageType, void *pUser)
|
|||
}
|
||||
|
||||
std::shared_ptr<CEditorImage> pImg = std::make_shared<CEditorImage>(pEditor);
|
||||
*pImg = ImgInfo;
|
||||
pImg->m_Width = ImgInfo.m_Width;
|
||||
pImg->m_Height = ImgInfo.m_Height;
|
||||
pImg->m_Format = ImgInfo.m_Format;
|
||||
pImg->m_pData = ImgInfo.m_pData;
|
||||
pImg->m_External = IsVanillaImage(aBuf);
|
||||
|
||||
if(!pImg->m_External && g_Config.m_ClEditorDilate == 1 && pImg->m_Format == CImageInfo::FORMAT_RGBA)
|
||||
if(pImg->m_Format != CImageInfo::FORMAT_RGBA)
|
||||
{
|
||||
DilateImage(ImgInfo.m_pData, ImgInfo.m_Width, ImgInfo.m_Height);
|
||||
uint8_t *pRgbaData = static_cast<uint8_t *>(malloc((size_t)pImg->m_Width * pImg->m_Height * CImageInfo::PixelSize(CImageInfo::FORMAT_RGBA)));
|
||||
ConvertToRGBA(pRgbaData, *pImg);
|
||||
free(pImg->m_pData);
|
||||
pImg->m_pData = pRgbaData;
|
||||
pImg->m_Format = CImageInfo::FORMAT_RGBA;
|
||||
}
|
||||
|
||||
if(!pImg->m_External && g_Config.m_ClEditorDilate == 1)
|
||||
{
|
||||
DilateImage(pImg->m_pData, pImg->m_Width, pImg->m_Height);
|
||||
}
|
||||
|
||||
int TextureLoadFlag = pEditor->Graphics()->Uses2DTextureArrays() ? IGraphics::TEXLOAD_TO_2D_ARRAY_TEXTURE : IGraphics::TEXLOAD_TO_3D_TEXTURE;
|
||||
if(ImgInfo.m_Width % 16 != 0 || ImgInfo.m_Height % 16 != 0)
|
||||
if(pImg->m_Width % 16 != 0 || pImg->m_Height % 16 != 0)
|
||||
TextureLoadFlag = 0;
|
||||
pImg->m_Texture = pEditor->Graphics()->LoadTextureRaw(ImgInfo, TextureLoadFlag, pFileName);
|
||||
ImgInfo.m_pData = nullptr;
|
||||
pImg->m_Texture = pEditor->Graphics()->LoadTextureRaw(*pImg, TextureLoadFlag, pFileName);
|
||||
str_copy(pImg->m_aName, aBuf);
|
||||
pImg->m_AutoMapper.Load(pImg->m_aName);
|
||||
pEditor->m_Map.m_vpImages.push_back(pImg);
|
||||
|
|
|
@ -509,6 +509,15 @@ bool CEditorMap::Load(const char *pFileName, int StorageType, const std::functio
|
|||
pImg->m_Height = ImgInfo.m_Height;
|
||||
pImg->m_Format = ImgInfo.m_Format;
|
||||
pImg->m_pData = ImgInfo.m_pData;
|
||||
if(pImg->m_Format != CImageInfo::FORMAT_RGBA)
|
||||
{
|
||||
uint8_t *pRgbaData = static_cast<uint8_t *>(malloc((size_t)pImg->m_Width * pImg->m_Height * CImageInfo::PixelSize(CImageInfo::FORMAT_RGBA)));
|
||||
ConvertToRGBA(pRgbaData, *pImg);
|
||||
free(pImg->m_pData);
|
||||
pImg->m_pData = pRgbaData;
|
||||
pImg->m_Format = CImageInfo::FORMAT_RGBA;
|
||||
}
|
||||
|
||||
int TextureLoadFlag = m_pEditor->Graphics()->Uses2DTextureArrays() ? IGraphics::TEXLOAD_TO_2D_ARRAY_TEXTURE : IGraphics::TEXLOAD_TO_3D_TEXTURE;
|
||||
if(ImgInfo.m_Width % 16 != 0 || ImgInfo.m_Height % 16 != 0)
|
||||
TextureLoadFlag = 0;
|
||||
|
|
Loading…
Reference in a new issue