Fix null pointer access in maplayers when the snapshot has no game info

```
src/game/client/components/maplayers.cpp:98:112: runtime error: member access within null pointer of type 'const struct CNetObj_GameInfo'
    #0 0x55d84eea9e1e in CMapLayers::EnvelopeEval(int, int, ColorRGBA&, void*) src/game/client/components/maplayers.cpp:98
    #1 0x55d84f518082 in CRenderTools::ForceRenderQuads(CQuad*, int, int, void (*)(int, int, ColorRGBA&, void*), void*, float) src/game/client/render_map.cpp:112
    #2 0x55d84f517ac7 in CRenderTools::RenderQuads(CQuad*, int, int, void (*)(int, int, ColorRGBA&, void*), void*) src/game/client/render_map.cpp:98
    #3 0x55d84eee10b0 in CMapLayers::OnRender() src/game/client/components/maplayers.cpp:1839
    #4 0x55d84f34b915 in CGameClient::OnRender() src/game/client/gameclient.cpp:640
    #5 0x55d84e8d44c2 in CClient::Render() src/engine/client/client.cpp:1222
    #6 0x55d84e92d1a0 in CClient::Run() src/engine/client/client.cpp:3370
    #7 0x55d84e99964f in main src/engine/client/client.cpp:4761
```
This commit is contained in:
Robert Müller 2022-07-21 15:28:31 +02:00
parent a93dac5156
commit b4eee122dd

View file

@ -94,15 +94,18 @@ void CMapLayers::EnvelopeEval(int TimeOffsetMillis, int Env, ColorRGBA &Channels
}
if(pItem->m_Version < 2 || pItem->m_Synchronized)
{
// get the lerp of the current tick and prev
int MinTick = pThis->Client()->PrevGameTick(g_Config.m_ClDummy) - pThis->m_pClient->m_Snap.m_pGameInfoObj->m_RoundStartTick;
int CurTick = pThis->Client()->GameTick(g_Config.m_ClDummy) - pThis->m_pClient->m_Snap.m_pGameInfoObj->m_RoundStartTick;
s_Time = std::chrono::nanoseconds((int64_t)(mix<double>(
0,
(CurTick - MinTick),
(double)pThis->Client()->IntraGameTick(g_Config.m_ClDummy)) *
TickToNanoSeconds.count())) +
MinTick * TickToNanoSeconds;
if(pThis->m_pClient->m_Snap.m_pGameInfoObj)
{
// get the lerp of the current tick and prev
int MinTick = pThis->Client()->PrevGameTick(g_Config.m_ClDummy) - pThis->m_pClient->m_Snap.m_pGameInfoObj->m_RoundStartTick;
int CurTick = pThis->Client()->GameTick(g_Config.m_ClDummy) - pThis->m_pClient->m_Snap.m_pGameInfoObj->m_RoundStartTick;
s_Time = std::chrono::nanoseconds((int64_t)(mix<double>(
0,
(CurTick - MinTick),
(double)pThis->Client()->IntraGameTick(g_Config.m_ClDummy)) *
TickToNanoSeconds.count())) +
MinTick * TickToNanoSeconds;
}
}
else
{