Add option to always save ghosts, not only personal bests.

This commit is contained in:
furo 2023-10-26 21:02:48 +02:00
parent dc439a804b
commit b90995da06
4 changed files with 32 additions and 7 deletions

View file

@ -323,6 +323,7 @@ MACRO_CONFIG_INT(ClRaceGhostServerControl, cl_race_ghost_server_control, 1, 0, 1
MACRO_CONFIG_INT(ClRaceShowGhost, cl_race_show_ghost, 1, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Show ghost")
MACRO_CONFIG_INT(ClRaceSaveGhost, cl_race_save_ghost, 1, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Save ghost")
MACRO_CONFIG_INT(ClRaceGhostStrictMap, cl_race_ghost_strict_map, 0, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Strict map checking when loading ghosts")
MACRO_CONFIG_INT(ClRaceGhostSaveBest, cl_race_ghost_save_best, 1, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Save only ghosts that are better than the previous record.")
MACRO_CONFIG_INT(ClDDRaceScoreBoard, cl_ddrace_scoreboard, 1, 0, 1, CFGFLAG_SAVE | CFGFLAG_CLIENT, "Enable DDRace Scoreboard")
MACRO_CONFIG_INT(SvResetPickups, sv_reset_pickups, 0, 0, 1, CFGFLAG_SERVER | CFGFLAG_GAME, "Whether the weapons are reset on passing the start tile or not")

View file

@ -133,10 +133,13 @@ void CGhost::GetPath(char *pBuf, int Size, const char *pPlayerName, int Time) co
str_copy(aPlayerName, pPlayerName);
str_sanitize_filename(aPlayerName);
char aTimestamp[32];
str_timestamp_format(aTimestamp, sizeof(aTimestamp), FORMAT_NOSPACE);
if(Time < 0)
str_format(pBuf, Size, "%s/%s_%s_%s_tmp_%d.gho", ms_pGhostDir, pMap, aPlayerName, aSha256, pid());
else
str_format(pBuf, Size, "%s/%s_%s_%d.%03d_%s.gho", ms_pGhostDir, pMap, aPlayerName, Time / 1000, Time % 1000, aSha256);
str_format(pBuf, Size, "%s/%s_%s_%d.%03d_%s_%s.gho", ms_pGhostDir, pMap, aPlayerName, Time / 1000, Time % 1000, aTimestamp, aSha256);
}
void CGhost::AddInfos(const CNetObj_Character *pChar, const CNetObj_DDNetCharacter *pDDnetChar)
@ -427,7 +430,7 @@ void CGhost::StopRecord(int Time)
GhostRecorder()->Stop(m_CurGhost.m_Path.Size(), Time);
CMenus::CGhostItem *pOwnGhost = m_pClient->m_Menus.GetOwnGhost();
if(Time > 0 && (!pOwnGhost || Time < pOwnGhost->m_Time))
if(Time > 0 && (!pOwnGhost || Time < pOwnGhost->m_Time || !g_Config.m_ClRaceGhostSaveBest))
{
if(pOwnGhost && pOwnGhost->Active())
Unload(pOwnGhost->m_Slot);

View file

@ -951,13 +951,28 @@ void CMenus::UpdateOwnGhost(CGhostItem Item)
if(Own != -1)
{
m_vGhosts[Own].m_Slot = -1;
m_vGhosts[Own].m_Own = false;
if(Item.HasFile() || !m_vGhosts[Own].HasFile())
DeleteGhostItem(Own);
if(g_Config.m_ClRaceGhostSaveBest)
{
if(Item.HasFile() || !m_vGhosts[Own].HasFile())
DeleteGhostItem(Own);
}
if(m_vGhosts[Own].m_Time >= Item.m_Time)
{
Item.m_Own = true;
m_vGhosts[Own].m_Own = false;
m_vGhosts[Own].m_Slot = -1;
}
else
{
Item.m_Own = false;
Item.m_Slot = -1;
}
}
else
{
Item.m_Own = true;
}
Item.m_Own = true;
Item.m_Date = std::time(0);
Item.m_Failed = false;
m_vGhosts.insert(std::lower_bound(m_vGhosts.begin(), m_vGhosts.end(), Item), Item);

View file

@ -3051,6 +3051,12 @@ void CMenus::RenderSettingsDDNet(CUIRect MainView)
{
g_Config.m_ClRaceSaveGhost ^= 1;
}
Right.HSplitTop(20.0f, &Button, &Right);
if(DoButton_CheckBox(&g_Config.m_ClRaceGhostSaveBest, Localize("Only save improvements"), g_Config.m_ClRaceGhostSaveBest, &Button))
{
g_Config.m_ClRaceGhostSaveBest ^= 1;
}
}
// gameplay