From 05e7c284ea40b8ab45f44a8783ab28ec5bdbebcd Mon Sep 17 00:00:00 2001 From: furo Date: Mon, 30 Oct 2023 00:53:00 +0100 Subject: [PATCH] Fix incorrect ghost being loaded with `cl_race_ghost_save_best` --- src/game/client/components/ghost.cpp | 8 ++++---- src/game/client/components/menus_ingame.cpp | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/game/client/components/ghost.cpp b/src/game/client/components/ghost.cpp index 350ff6391..f8b71ee80 100644 --- a/src/game/client/components/ghost.cpp +++ b/src/game/client/components/ghost.cpp @@ -432,14 +432,14 @@ void CGhost::StopRecord(int Time) CMenus::CGhostItem *pOwnGhost = m_pClient->m_Menus.GetOwnGhost(); if(Time > 0 && (!pOwnGhost || Time < pOwnGhost->m_Time || !g_Config.m_ClRaceGhostSaveBest)) { - if(pOwnGhost && pOwnGhost->Active()) - Unload(pOwnGhost->m_Slot); - // add to active ghosts int Slot = GetSlot(); - if(Slot != -1) + if(Slot != -1 && (!pOwnGhost || Time < pOwnGhost->m_Time)) m_aActiveGhosts[Slot] = std::move(m_CurGhost); + if(pOwnGhost && pOwnGhost->Active() && Time < pOwnGhost->m_Time) + Unload(pOwnGhost->m_Slot); + // create ghost item CMenus::CGhostItem Item; if(RecordingToFile) diff --git a/src/game/client/components/menus_ingame.cpp b/src/game/client/components/menus_ingame.cpp index 09220203a..3e55dd0e0 100644 --- a/src/game/client/components/menus_ingame.cpp +++ b/src/game/client/components/menus_ingame.cpp @@ -956,7 +956,7 @@ void CMenus::UpdateOwnGhost(CGhostItem Item) if(Item.HasFile() || !m_vGhosts[Own].HasFile()) DeleteGhostItem(Own); } - if(m_vGhosts[Own].m_Time >= Item.m_Time) + if(m_vGhosts[Own].m_Time > Item.m_Time) { Item.m_Own = true; m_vGhosts[Own].m_Own = false;