Merge pull request #8006 from Robyt3/Client-Ghost-Crash-Fix

Fix client crash if `cl_race_ghost_save_best 1` deletes last ghost
This commit is contained in:
Dennis Felsing 2024-02-22 09:45:59 +00:00 committed by GitHub
commit 808ccd7913
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -985,14 +985,16 @@ void CMenus::UpdateOwnGhost(CGhostItem Item)
if(m_vGhosts[i].m_Own)
Own = i;
if(Own != -1)
if(Own == -1)
{
if(g_Config.m_ClRaceGhostSaveBest)
Item.m_Own = true;
}
else if(g_Config.m_ClRaceGhostSaveBest && (Item.HasFile() || !m_vGhosts[Own].HasFile()))
{
if(Item.HasFile() || !m_vGhosts[Own].HasFile())
Item.m_Own = true;
DeleteGhostItem(Own);
}
if(m_vGhosts[Own].m_Time > Item.m_Time)
else if(m_vGhosts[Own].m_Time > Item.m_Time)
{
Item.m_Own = true;
m_vGhosts[Own].m_Own = false;
@ -1003,11 +1005,6 @@ void CMenus::UpdateOwnGhost(CGhostItem Item)
Item.m_Own = false;
Item.m_Slot = -1;
}
}
else
{
Item.m_Own = true;
}
Item.m_Date = std::time(0);
Item.m_Failed = false;