mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-13 19:48:19 +00:00
Compare commits
8 commits
03aab986fe
...
f3c246f622
Author | SHA1 | Date | |
---|---|---|---|
f3c246f622 | |||
01daa919e8 | |||
790c73bffe | |||
8faba8ee40 | |||
7043a59bc3 | |||
11aba0e38d | |||
722b5f8d11 | |||
4f4284ba2a |
|
@ -657,12 +657,6 @@ bool CGraphics_Threaded::LoadPNG(CImageInfo *pImg, const char *pFilename, int St
|
|||
return true;
|
||||
}
|
||||
|
||||
void CGraphics_Threaded::FreePNG(CImageInfo *pImg)
|
||||
{
|
||||
free(pImg->m_pData);
|
||||
pImg->m_pData = NULL;
|
||||
}
|
||||
|
||||
bool CGraphics_Threaded::CheckImageDivisibility(const char *pFileName, CImageInfo &Img, int DivX, int DivY, bool AllowResize)
|
||||
{
|
||||
dbg_assert(DivX != 0 && DivY != 0, "Passing 0 to this function is not allowed.");
|
||||
|
|
|
@ -983,7 +983,6 @@ public:
|
|||
// simple uncompressed RGBA loaders
|
||||
IGraphics::CTextureHandle LoadTexture(const char *pFilename, int StorageType, int Flags = 0) override;
|
||||
bool LoadPNG(CImageInfo *pImg, const char *pFilename, int StorageType) override;
|
||||
void FreePNG(CImageInfo *pImg) override;
|
||||
|
||||
bool CheckImageDivisibility(const char *pFileName, CImageInfo &Img, int DivX, int DivY, bool AllowResize) override;
|
||||
bool IsImageFormatRGBA(const char *pFileName, CImageInfo &Img) override;
|
||||
|
|
|
@ -225,7 +225,7 @@ void CChooseMaster::CJob::Run()
|
|||
pHead->Wait();
|
||||
if(pHead->State() == EHttpState::ABORTED || State() == IJob::STATE_ABORTED)
|
||||
{
|
||||
log_debug("serverbrowse_http", "master chooser aborted");
|
||||
log_debug("serverbrowser_http", "master chooser aborted");
|
||||
return;
|
||||
}
|
||||
if(pHead->State() != EHttpState::DONE)
|
||||
|
@ -248,7 +248,7 @@ void CChooseMaster::CJob::Run()
|
|||
auto Time = std::chrono::duration_cast<std::chrono::milliseconds>(time_get_nanoseconds() - StartTime);
|
||||
if(pGet->State() == EHttpState::ABORTED || State() == IJob::STATE_ABORTED)
|
||||
{
|
||||
log_debug("serverbrowse_http", "master chooser aborted");
|
||||
log_debug("serverbrowser_http", "master chooser aborted");
|
||||
return;
|
||||
}
|
||||
if(pGet->State() != EHttpState::DONE)
|
||||
|
@ -268,7 +268,7 @@ void CChooseMaster::CJob::Run()
|
|||
continue;
|
||||
}
|
||||
int AgeS = SanitizeAge(pGet->ResultAgeSeconds());
|
||||
log_info("serverbrowse_http", "found master, url='%s' time=%dms age=%ds", pUrl, (int)Time.count(), AgeS);
|
||||
log_info("serverbrowser_http", "found master, url='%s' time=%dms age=%ds", pUrl, (int)Time.count(), AgeS);
|
||||
|
||||
aTimeMs[i] = Time.count();
|
||||
aAgeS[i] = AgeS;
|
||||
|
@ -293,11 +293,11 @@ void CChooseMaster::CJob::Run()
|
|||
}
|
||||
if(BestIndex == -1)
|
||||
{
|
||||
log_error("serverbrowse_http", "WARNING: no usable masters found");
|
||||
log_error("serverbrowser_http", "WARNING: no usable masters found");
|
||||
return;
|
||||
}
|
||||
|
||||
log_info("serverbrowse_http", "determined best master, url='%s' time=%dms age=%ds", m_pData->m_aaUrls[BestIndex], BestTime, BestAge);
|
||||
log_info("serverbrowser_http", "determined best master, url='%s' time=%dms age=%ds", m_pData->m_aaUrls[BestIndex], BestTime, BestAge);
|
||||
m_pData->m_BestIndex.store(BestIndex);
|
||||
}
|
||||
|
||||
|
@ -374,7 +374,7 @@ void CServerBrowserHttp::Update()
|
|||
{
|
||||
if(!m_pChooseMaster->IsRefreshing())
|
||||
{
|
||||
log_error("serverbrowse_http", "no working serverlist URL found");
|
||||
log_error("serverbrowser_http", "no working serverlist URL found");
|
||||
m_State = STATE_NO_MASTER;
|
||||
}
|
||||
return;
|
||||
|
@ -402,7 +402,7 @@ void CServerBrowserHttp::Update()
|
|||
json_value_free(pJson);
|
||||
if(!Success)
|
||||
{
|
||||
log_error("serverbrowse_http", "failed getting serverlist, trying to find best URL");
|
||||
log_error("serverbrowser_http", "failed getting serverlist, trying to find best URL");
|
||||
m_pChooseMaster->Reset();
|
||||
m_pChooseMaster->Refresh();
|
||||
}
|
||||
|
@ -413,7 +413,7 @@ void CServerBrowserHttp::Update()
|
|||
int Age = SanitizeAge(pGetServers->ResultAgeSeconds());
|
||||
if(Age > 300)
|
||||
{
|
||||
log_info("serverbrowse_http", "got stale serverlist, age=%ds, trying to find best URL", Age);
|
||||
log_info("serverbrowser_http", "got stale serverlist, age=%ds, trying to find best URL", Age);
|
||||
m_pChooseMaster->Refresh();
|
||||
}
|
||||
}
|
||||
|
@ -494,7 +494,7 @@ bool CServerBrowserHttp::Parse(json_value *pJson, std::vector<CServerInfo> *pvSe
|
|||
NETADDR ParsedAddr;
|
||||
if(ServerbrowserParseUrl(&ParsedAddr, Addresses[a]))
|
||||
{
|
||||
log_debug("dbg/serverbrowser", "unknown address, i=%d a=%d", i, a);
|
||||
// log_debug("serverbrowser_http", "unknown address, i=%d a=%d", i, a);
|
||||
// Skip unknown addresses.
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -97,6 +97,15 @@ public:
|
|||
*/
|
||||
uint8_t *m_pData = nullptr;
|
||||
|
||||
void Free()
|
||||
{
|
||||
m_Width = 0;
|
||||
m_Height = 0;
|
||||
m_Format = FORMAT_ERROR;
|
||||
free(m_pData);
|
||||
m_pData = nullptr;
|
||||
}
|
||||
|
||||
static size_t PixelSize(EImageFormat Format)
|
||||
{
|
||||
dbg_assert(Format != FORMAT_ERROR, "Format invalid");
|
||||
|
@ -322,7 +331,6 @@ public:
|
|||
virtual const TTwGraphicsGpuList &GetGpus() const = 0;
|
||||
|
||||
virtual bool LoadPNG(CImageInfo *pImg, const char *pFilename, int StorageType) = 0;
|
||||
virtual void FreePNG(CImageInfo *pImg) = 0;
|
||||
|
||||
virtual bool CheckImageDivisibility(const char *pFileName, CImageInfo &Img, int DivX, int DivY, bool AllowResize) = 0;
|
||||
virtual bool IsImageFormatRGBA(const char *pFileName, CImageInfo &Img) = 0;
|
||||
|
|
|
@ -286,8 +286,7 @@ IGraphics::CTextureHandle CMapImages::GetEntities(EMapImageEntityLayerType Entit
|
|||
}
|
||||
|
||||
free(pBuildImgData);
|
||||
|
||||
Graphics()->FreePNG(&ImgInfo);
|
||||
ImgInfo.Free();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2249,7 +2249,7 @@ int CMenus::MenuImageScan(const char *pName, int IsDir, int DirType, void *pUser
|
|||
}
|
||||
if(Info.m_Format != CImageInfo::FORMAT_RGBA)
|
||||
{
|
||||
pSelf->Graphics()->FreePNG(&Info);
|
||||
Info.Free();
|
||||
char aError[IO_MAX_PATH_LENGTH + 64];
|
||||
str_format(aError, sizeof(aError), "Failed to load menu image from '%s': must be an RGBA image", aPath);
|
||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "menus", aError);
|
||||
|
|
|
@ -1944,8 +1944,7 @@ CMenus::CCommunityIconLoadJob::CCommunityIconLoadJob(CMenus *pMenus, const char
|
|||
|
||||
CMenus::CCommunityIconLoadJob::~CCommunityIconLoadJob()
|
||||
{
|
||||
free(m_ImageInfo.m_pData);
|
||||
m_ImageInfo.m_pData = nullptr;
|
||||
m_ImageInfo.Free();
|
||||
}
|
||||
|
||||
int CMenus::CommunityIconScan(const char *pName, int IsDir, int DirType, void *pUser)
|
||||
|
@ -1983,14 +1982,14 @@ bool CMenus::LoadCommunityIconFile(const char *pPath, int DirType, CImageInfo &I
|
|||
}
|
||||
if(Info.m_Format != CImageInfo::FORMAT_RGBA)
|
||||
{
|
||||
Graphics()->FreePNG(&Info);
|
||||
Info.Free();
|
||||
str_format(aError, sizeof(aError), "Failed to load community icon from '%s': must be an RGBA image", pPath);
|
||||
Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "menus/browser", aError);
|
||||
return false;
|
||||
}
|
||||
if(!Storage()->CalculateHashes(pPath, DirType, &Sha256))
|
||||
{
|
||||
Graphics()->FreePNG(&Info);
|
||||
Info.Free();
|
||||
str_format(aError, sizeof(aError), "Failed to load community icon from '%s': could not calculate hash", pPath);
|
||||
Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "menus/browser", aError);
|
||||
return false;
|
||||
|
|
|
@ -293,7 +293,7 @@ const CSkin *CSkins::LoadSkin(const char *pName, CImageInfo &Info)
|
|||
for(int i = 0; i < 6; ++i)
|
||||
Skin.m_ColorableSkin.m_aEyes[i] = Graphics()->LoadSpriteTexture(Info, &g_pData->m_aSprites[SPRITE_TEE_EYE_NORMAL + i]);
|
||||
|
||||
Graphics()->FreePNG(&Info);
|
||||
Info.Free();
|
||||
|
||||
if(g_Config.m_Debug)
|
||||
{
|
||||
|
|
|
@ -3104,8 +3104,7 @@ void CGameClient::LoadGameSkin(const char *pPath, bool AsDir)
|
|||
}
|
||||
|
||||
m_GameSkinLoaded = true;
|
||||
|
||||
Graphics()->FreePNG(&ImgInfo);
|
||||
ImgInfo.Free();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3149,7 +3148,7 @@ void CGameClient::LoadEmoticonsSkin(const char *pPath, bool AsDir)
|
|||
m_EmoticonsSkin.m_aSpriteEmoticons[i] = Graphics()->LoadSpriteTexture(ImgInfo, &g_pData->m_aSprites[SPRITE_OOP + i]);
|
||||
|
||||
m_EmoticonsSkinLoaded = true;
|
||||
Graphics()->FreePNG(&ImgInfo);
|
||||
ImgInfo.Free();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3220,7 +3219,7 @@ void CGameClient::LoadParticlesSkin(const char *pPath, bool AsDir)
|
|||
m_ParticlesSkin.m_aSpriteParticles[9] = m_ParticlesSkin.m_SpriteParticleHit;
|
||||
|
||||
m_ParticlesSkinLoaded = true;
|
||||
free(ImgInfo.m_pData);
|
||||
ImgInfo.Free();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3319,7 +3318,7 @@ void CGameClient::LoadHudSkin(const char *pPath, bool AsDir)
|
|||
m_HudSkin.m_SpriteHudDummyCopy = Graphics()->LoadSpriteTexture(ImgInfo, &g_pData->m_aSprites[SPRITE_HUD_DUMMY_COPY]);
|
||||
|
||||
m_HudSkinLoaded = true;
|
||||
free(ImgInfo.m_pData);
|
||||
ImgInfo.Free();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3364,7 +3363,7 @@ void CGameClient::LoadExtrasSkin(const char *pPath, bool AsDir)
|
|||
m_ExtrasSkin.m_SpriteParticleSnowflake = Graphics()->LoadSpriteTexture(ImgInfo, &g_pData->m_aSprites[SPRITE_PART_SNOWFLAKE]);
|
||||
m_ExtrasSkin.m_aSpriteParticles[0] = m_ExtrasSkin.m_SpriteParticleSnowflake;
|
||||
m_ExtrasSkinLoaded = true;
|
||||
free(ImgInfo.m_pData);
|
||||
ImgInfo.Free();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4369,8 +4369,7 @@ 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));
|
||||
free(pImg->m_pData);
|
||||
pImg->m_pData = nullptr;
|
||||
pImg->Free();
|
||||
*pImg = ImgInfo;
|
||||
str_copy(pImg->m_aName, aBuf);
|
||||
pImg->m_External = IsVanillaImage(pImg->m_aName);
|
||||
|
|
|
@ -2107,8 +2107,7 @@ CUi::EPopupMenuFunctionResult CEditor::PopupEvent(void *pContext, CUIRect View,
|
|||
|
||||
if(pEditor->m_PopupEventType == POPEVENT_PIXELART_BIG_IMAGE || pEditor->m_PopupEventType == POPEVENT_PIXELART_MANY_COLORS)
|
||||
{
|
||||
free(pEditor->m_TileartImageInfo.m_pData);
|
||||
pEditor->m_TileartImageInfo.m_pData = nullptr;
|
||||
pEditor->m_TileartImageInfo.Free();
|
||||
}
|
||||
|
||||
return CUi::POPUP_CLOSE_CURRENT;
|
||||
|
|
|
@ -212,8 +212,7 @@ void CEditor::AddTileart(bool IgnoreHistory)
|
|||
m_EditorHistory.RecordAction(std::make_shared<CEditorActionTileArt>(this, ImageCount, m_aTileartFilename, IndexMap));
|
||||
}
|
||||
|
||||
free(m_TileartImageInfo.m_pData);
|
||||
m_TileartImageInfo.m_pData = nullptr;
|
||||
m_TileartImageInfo.Free();
|
||||
m_Map.OnModify();
|
||||
m_Dialog = DIALOG_NONE;
|
||||
}
|
||||
|
@ -226,8 +225,7 @@ void CEditor::TileartCheckColors()
|
|||
{
|
||||
m_PopupEventType = CEditor::POPEVENT_PIXELART_TOO_MANY_COLORS;
|
||||
m_PopupEventActivated = true;
|
||||
free(m_TileartImageInfo.m_pData);
|
||||
m_TileartImageInfo.m_pData = nullptr;
|
||||
m_TileartImageInfo.Free();
|
||||
}
|
||||
else if(NumColorGroups > 1)
|
||||
{
|
||||
|
|
|
@ -1217,7 +1217,7 @@ void CGameContext::ConSetEyeEmote(IConsole::IResult *pResult,
|
|||
"chatresp",
|
||||
(pPlayer->m_EyeEmoteEnabled) ?
|
||||
"You can now use the preset eye emotes." :
|
||||
"You don't have any eye emotes, remember to bind some. (until you die)");
|
||||
"You don't have any eye emotes, remember to bind some.");
|
||||
return;
|
||||
}
|
||||
else if(str_comp_nocase(pResult->GetString(0), "on") == 0)
|
||||
|
@ -1231,7 +1231,7 @@ void CGameContext::ConSetEyeEmote(IConsole::IResult *pResult,
|
|||
"chatresp",
|
||||
(pPlayer->m_EyeEmoteEnabled) ?
|
||||
"You can now use the preset eye emotes." :
|
||||
"You don't have any eye emotes, remember to bind some. (until you die)");
|
||||
"You don't have any eye emotes, remember to bind some.");
|
||||
}
|
||||
|
||||
void CGameContext::ConEyeEmote(IConsole::IResult *pResult, void *pUserData)
|
||||
|
|
Loading…
Reference in a new issue