6094: Check if ghost is really used bcs IntsToStr returns weird stuff for 0… r=def- a=Jupeyy

… integers

--- ignore whitespaces

## Checklist

- [x] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [ ] Written a unit test (especially base/) or added coverage to integration test
- [ ] Considered possible null pointers and out of bounds array indexing
- [ ] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


Co-authored-by: Jupeyy <jupjopjap@gmail.com>
This commit is contained in:
bors[bot] 2022-12-05 19:34:43 +00:00 committed by GitHub
commit 2dcef1685b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -672,10 +672,26 @@ void CGhost::RefindSkin()
char aSkinName[64]; char aSkinName[64];
for(auto &Ghost : m_aActiveGhosts) for(auto &Ghost : m_aActiveGhosts)
{ {
IntsToStr(&Ghost.m_Skin.m_Skin0, 6, aSkinName); if(!Ghost.Empty())
{
IntsToStr(&Ghost.m_Skin.m_Skin0, 6, aSkinName);
if(aSkinName[0] != '\0')
{
CTeeRenderInfo *pRenderInfo = &Ghost.m_RenderInfo;
const CSkin *pSkin = m_pClient->m_Skins.Find(aSkinName);
pRenderInfo->m_OriginalRenderSkin = pSkin->m_OriginalSkin;
pRenderInfo->m_ColorableRenderSkin = pSkin->m_ColorableSkin;
pRenderInfo->m_SkinMetrics = pSkin->m_Metrics;
}
}
}
if(!m_CurGhost.Empty())
{
IntsToStr(&m_CurGhost.m_Skin.m_Skin0, 6, aSkinName);
if(aSkinName[0] != '\0') if(aSkinName[0] != '\0')
{ {
CTeeRenderInfo *pRenderInfo = &Ghost.m_RenderInfo; CTeeRenderInfo *pRenderInfo = &m_CurGhost.m_RenderInfo;
const CSkin *pSkin = m_pClient->m_Skins.Find(aSkinName); const CSkin *pSkin = m_pClient->m_Skins.Find(aSkinName);
pRenderInfo->m_OriginalRenderSkin = pSkin->m_OriginalSkin; pRenderInfo->m_OriginalRenderSkin = pSkin->m_OriginalSkin;
@ -683,14 +699,4 @@ void CGhost::RefindSkin()
pRenderInfo->m_SkinMetrics = pSkin->m_Metrics; pRenderInfo->m_SkinMetrics = pSkin->m_Metrics;
} }
} }
IntsToStr(&m_CurGhost.m_Skin.m_Skin0, 6, aSkinName);
if(aSkinName[0] != '\0')
{
CTeeRenderInfo *pRenderInfo = &m_CurGhost.m_RenderInfo;
const CSkin *pSkin = m_pClient->m_Skins.Find(aSkinName);
pRenderInfo->m_OriginalRenderSkin = pSkin->m_OriginalSkin;
pRenderInfo->m_ColorableRenderSkin = pSkin->m_ColorableSkin;
pRenderInfo->m_SkinMetrics = pSkin->m_Metrics;
}
} }