From 216e5654e844d335dae56a67cae3b5c28766b08b Mon Sep 17 00:00:00 2001 From: Redix Date: Sat, 16 Sep 2017 15:19:26 +0200 Subject: [PATCH] Added config variables for server controlled ghost and race recording --- src/engine/shared/config_variables.h | 2 ++ src/game/client/components/ghost.cpp | 9 +++++---- src/game/client/components/race_demo.cpp | 5 +++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/engine/shared/config_variables.h b/src/engine/shared/config_variables.h index d37c553a8..c36a12764 100644 --- a/src/engine/shared/config_variables.h +++ b/src/engine/shared/config_variables.h @@ -308,9 +308,11 @@ MACRO_CONFIG_INT(ConnTimeoutProtection, conn_timeout_protection, 1000, 5, 10000, MACRO_CONFIG_INT(ClShowIDs, cl_show_ids, 0, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Whether to show client ids in scoreboard") MACRO_CONFIG_INT(ClScoreboardOnDeath, cl_scoreboard_on_death, 1, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Whether to show scoreboard after death or not") MACRO_CONFIG_INT(ClAutoRaceRecord, cl_auto_race_record, 1, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Save the best demo of each race") +MACRO_CONFIG_INT(ClRaceRecordServerControl, cl_race_record_server_control, 1, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Let the server start the race recorder") MACRO_CONFIG_INT(ClDemoName, cl_demo_name, 1, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Save the player name within the demo") MACRO_CONFIG_INT(ClDemoAssumeRace, cl_demo_assume_race, 1, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Assume that demos are race demos") MACRO_CONFIG_INT(ClRaceGhost, cl_race_ghost, 1, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Enable ghost") +MACRO_CONFIG_INT(ClRaceGhostServerControl, cl_race_ghost_server_control, 1, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Let the server start the ghost") 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 ") diff --git a/src/game/client/components/ghost.cpp b/src/game/client/components/ghost.cpp index 03497a49d..e4a69f914 100644 --- a/src/game/client/components/ghost.cpp +++ b/src/game/client/components/ghost.cpp @@ -112,12 +112,13 @@ void CGhost::OnRender() if(m_pClient->m_Snap.m_pLocalCharacter && m_pClient->m_Snap.m_pLocalPrevCharacter) { bool RaceFlag = m_pClient->m_Snap.m_pGameInfoObj->m_GameStateFlags&GAMESTATEFLAG_RACETIME; + bool ServerControl = RaceFlag && g_Config.m_ClRaceGhostServerControl; int RaceTick = -m_pClient->m_Snap.m_pGameInfoObj->m_WarmupTimer; static int s_NewRenderTick = -1; int RenderTick = s_NewRenderTick; - if(!RaceFlag && m_pClient->m_NewPredictedTick) + if(!ServerControl && m_pClient->m_NewPredictedTick) { vec2 PrevPos = m_pClient->m_PredictedPrevChar.m_Pos; vec2 Pos = m_pClient->m_PredictedChar.m_Pos; @@ -130,7 +131,7 @@ void CGhost::OnRender() { static int s_LastRaceTick = -1; - if(RaceFlag && s_LastRaceTick != RaceTick) + if(ServerControl && s_LastRaceTick != RaceTick) { if(m_Recording && s_LastRaceTick != -1) m_AllowRestart = true; @@ -142,7 +143,7 @@ void CGhost::OnRender() StartRecord(StartTick); RenderTick = StartTick; } - else if(!RaceFlag) + else if(!ServerControl) { int PrevTick = m_pClient->m_Snap.m_pLocalPrevCharacter->m_Tick; int CurTick = m_pClient->m_Snap.m_pLocalCharacter->m_Tick; @@ -179,7 +180,7 @@ void CGhost::OnRender() s_LastRaceTick = RaceFlag ? RaceTick : -1; } - if((RaceFlag && m_pClient->m_NewTick) || (!RaceFlag && m_pClient->m_NewPredictedTick)) + if((ServerControl && m_pClient->m_NewTick) || (!ServerControl && m_pClient->m_NewPredictedTick)) { // only restart rendering if it did not change since last tick to prevent stuttering if(s_NewRenderTick != -1 && s_NewRenderTick == RenderTick) diff --git a/src/game/client/components/race_demo.cpp b/src/game/client/components/race_demo.cpp index 35581e982..a9ce9a00d 100644 --- a/src/game/client/components/race_demo.cpp +++ b/src/game/client/components/race_demo.cpp @@ -31,17 +31,18 @@ void CRaceDemo::OnRender() static int s_LastRaceTick = -1; bool RaceFlag = m_pClient->m_Snap.m_pGameInfoObj->m_GameStateFlags&GAMESTATEFLAG_RACETIME; + bool ServerControl = RaceFlag && g_Config.m_ClRaceRecordServerControl; int RaceTick = -m_pClient->m_Snap.m_pGameInfoObj->m_WarmupTimer; // start the demo - bool ForceStart = RaceFlag && s_LastRaceTick != RaceTick; + bool ForceStart = ServerControl && s_LastRaceTick != RaceTick; bool AllowRestart = (m_AllowRestart || ForceStart) && m_RaceStartTick + 10 * Client()->GameTickSpeed() < Client()->GameTick(); if(m_RaceState == RACE_IDLE || m_RaceState == RACE_PREPARE || (m_RaceState == RACE_STARTED && AllowRestart)) { vec2 PrevPos = vec2(m_pClient->m_Snap.m_pLocalPrevCharacter->m_X, m_pClient->m_Snap.m_pLocalPrevCharacter->m_Y); vec2 Pos = vec2(m_pClient->m_Snap.m_pLocalCharacter->m_X, m_pClient->m_Snap.m_pLocalCharacter->m_Y); - if(ForceStart || (!RaceFlag && CRaceHelper::IsStart(m_pClient, PrevPos, Pos))) + if(ForceStart || (!ServerControl && CRaceHelper::IsStart(m_pClient, PrevPos, Pos))) { if(m_RaceState == RACE_STARTED) Client()->RaceRecord_Stop();