From 1b1d8f79644f822726d9d7a3708cbc258912434f Mon Sep 17 00:00:00 2001 From: def Date: Fri, 25 Sep 2020 15:18:28 +0200 Subject: [PATCH 1/2] Don't show wrong decisecs in game time in HUD --- src/engine/shared/config_variables.h | 1 - src/game/client/components/hud.cpp | 29 ++-------------------------- 2 files changed, 2 insertions(+), 28 deletions(-) diff --git a/src/engine/shared/config_variables.h b/src/engine/shared/config_variables.h index c6da0e19c..9e44dc516 100644 --- a/src/engine/shared/config_variables.h +++ b/src/engine/shared/config_variables.h @@ -288,7 +288,6 @@ 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(ClDDRaceScoreBoard, cl_ddrace_scoreboard, 1, 0, 1, CFGFLAG_SAVE | CFGFLAG_CLIENT, "Enable DDRace Scoreboard") -MACRO_CONFIG_INT(ClShowDecisecs, cl_show_decisecs, 1, 0, 1, CFGFLAG_SAVE | CFGFLAG_CLIENT, "Show deciseconds in game time") 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") MACRO_CONFIG_INT(ClShowOthers, cl_show_others, 0, 0, 2, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Show players in other teams (2 to show own team only)") MACRO_CONFIG_INT(ClShowOthersAlpha, cl_show_others_alpha, 40, 0, 100, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Show players in other teams (alpha value, 0 invisible, 100 fully visible)") diff --git a/src/game/client/components/hud.cpp b/src/game/client/components/hud.cpp index 4e0c4b146..ea75fb97b 100644 --- a/src/game/client/components/hud.cpp +++ b/src/game/client/components/hud.cpp @@ -70,7 +70,6 @@ void CHud::OnReset() m_DDRaceTime = 0; m_LastReceivedTimeTick = 0; m_CheckpointTick = 0; - m_DDRaceTick = 0; m_FinishTime = false; m_DDRaceTimeReceived = false; m_ServerRecord = -1.0f; @@ -122,20 +121,13 @@ void CHud::RenderGameTimer() else Time = (Client()->GameTick(g_Config.m_ClDummy) - m_pClient->m_Snap.m_pGameInfoObj->m_RoundStartTick) / Client()->GameTickSpeed(); - if(Time <= 0 && g_Config.m_ClShowDecisecs) - str_format(aBuf, sizeof(aBuf), "00:00.0"); - else if(Time <= 0) + if(Time <= 0) str_format(aBuf, sizeof(aBuf), "00:00"); - else if(g_Config.m_ClShowDecisecs) - str_format(aBuf, sizeof(aBuf), "%02d:%02d.%d", Time / 60, Time % 60, m_DDRaceTick / 10); else str_format(aBuf, sizeof(aBuf), "%02d:%02d", Time / 60, Time % 60); float FontSize = 10.0f; float w; - if(g_Config.m_ClShowDecisecs) - w = TextRender()->TextWidth(0, 12, "00:00.0", -1, -1.0f); - else - w = TextRender()->TextWidth(0, 12, "00:00", -1, -1.0f); + w = TextRender()->TextWidth(0, 12, "00:00", -1, -1.0f); // last 60 sec red, last 10 sec blink if(m_pClient->m_Snap.m_pGameInfoObj->m_TimeLimit && Time <= 60 && (m_pClient->m_Snap.m_pGameInfoObj->m_WarmupTimer <= 0)) { @@ -804,16 +796,6 @@ void CHud::OnRender() RenderRecord(); } RenderCursor(); - - static int LastChangeTick = 0; - if(LastChangeTick != Client()->PredGameTick(g_Config.m_ClDummy)) - { - m_DDRaceTick += 100 / Client()->GameTickSpeed(); - LastChangeTick = Client()->PredGameTick(g_Config.m_ClDummy); - } - - if(m_DDRaceTick >= 100) - m_DDRaceTick = 0; } void CHud::OnMessage(int MsgType, void *pRawMsg) @@ -825,7 +807,6 @@ void CHud::OnMessage(int MsgType, void *pRawMsg) CNetMsg_Sv_DDRaceTime *pMsg = (CNetMsg_Sv_DDRaceTime *)pRawMsg; m_DDRaceTime = pMsg->m_Time; - m_DDRaceTick = 0; m_LastReceivedTimeTick = Client()->GameTick(g_Config.m_ClDummy); @@ -856,7 +837,6 @@ void CHud::OnMessage(int MsgType, void *pRawMsg) m_DDRaceTimeReceived = true; m_DDRaceTime = pMsg->m_ServerTimeBest; // First value: m_Time - m_DDRaceTick = 0; m_LastReceivedTimeTick = Client()->GameTick(g_Config.m_ClDummy); @@ -915,11 +895,6 @@ void CHud::RenderDDRaceEffects() TextRender()->TextColor(1, 1, 1, 1); } } - /*else if(m_DDRaceTimeReceived) - { - str_format(aBuf, sizeof(aBuf), "%02d:%02d.%d", m_DDRaceTime/60, m_DDRaceTime%60, m_DDRaceTick/10); - TextRender()->Text(0, 150*Graphics()->ScreenAspect()-TextRender()->TextWidth(0, 12, "00:00.0", -1, -1.0f)/2, 20, 12, aBuf, -1.0f); // use fixed value for text width so its not shaky - }*/ } void CHud::RenderRecord() From 973a4caf4b51b7a34d8d4f86bf542e563aa53bd0 Mon Sep 17 00:00:00 2001 From: def Date: Fri, 25 Sep 2020 15:25:05 +0200 Subject: [PATCH 2/2] Show days and hours in game time --- src/game/client/components/hud.cpp | 11 ++++++++++- src/game/client/components/hud.h | 1 - 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/game/client/components/hud.cpp b/src/game/client/components/hud.cpp index ea75fb97b..599265e00 100644 --- a/src/game/client/components/hud.cpp +++ b/src/game/client/components/hud.cpp @@ -123,11 +123,20 @@ void CHud::RenderGameTimer() if(Time <= 0) str_format(aBuf, sizeof(aBuf), "00:00"); + else if(Time >= 3600 * 24) + str_format(aBuf, sizeof(aBuf), "%dd %02d:%02d:%02d", Time / (3600 * 24), (Time % (3600 * 24)) / 3600, (Time % 3600) / 60, Time % 60); + else if(Time >= 3600) + str_format(aBuf, sizeof(aBuf), "%02d:%02d:%02d", Time / 3600, (Time % 3600) / 60, Time % 60); else str_format(aBuf, sizeof(aBuf), "%02d:%02d", Time / 60, Time % 60); float FontSize = 10.0f; float w; - w = TextRender()->TextWidth(0, 12, "00:00", -1, -1.0f); + if(Time >= 3600 * 24) + w = TextRender()->TextWidth(0, 12, "00d 00:00:00", -1, -1.0f); + else if(Time >= 3600) + w = TextRender()->TextWidth(0, 12, "00:00:00", -1, -1.0f); + else + w = TextRender()->TextWidth(0, 12, "00:00", -1, -1.0f); // last 60 sec red, last 10 sec blink if(m_pClient->m_Snap.m_pGameInfoObj->m_TimeLimit && Time <= 60 && (m_pClient->m_Snap.m_pGameInfoObj->m_WarmupTimer <= 0)) { diff --git a/src/game/client/components/hud.h b/src/game/client/components/hud.h index e3f75df5c..46f8e411a 100644 --- a/src/game/client/components/hud.h +++ b/src/game/client/components/hud.h @@ -84,7 +84,6 @@ private: int m_DDRaceTime; int m_LastReceivedTimeTick; int m_CheckpointTick; - int m_DDRaceTick; bool m_FinishTime; bool m_DDRaceTimeReceived; };