diff --git a/src/game/client/gameclient.cpp b/src/game/client/gameclient.cpp index 58566f11d..8ada9c94e 100644 --- a/src/game/client/gameclient.cpp +++ b/src/game/client/gameclient.cpp @@ -322,6 +322,11 @@ void CGameClient::OnInit() } } + // chillerbot-ng + + m_RequestCmdlist = 0; + m_EnterGameTime = 0; + int64 End = time_get(); str_format(aBuf, sizeof(aBuf), "initialisation finished after %.2fms", ((End-Start)*1000)/(float)time_freq()); Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "gameclient", aBuf); @@ -854,11 +859,34 @@ void CGameClient::ConsoleKeyInput() } } -void CGameClient::OnRender() +void CGameClient::ChillerBotTick() { - // chillerbot-ng ConsoleKeyInput(); PenetrateServer(); + if (g_Config.m_ClShutdownSrv[0] && m_EnterGameTime) + { + if (!Client()->RconAuthed() && (time_get() - m_EnterGameTime) / time_freq() > 10) // wait 10 sec to authenticate + { + Client()->RconAuth(g_Config.m_ClShutdownSrv, g_Config.m_ClShutdownSrv); + dbg_msg("shutdown", "authed in rcon with password='%s'", g_Config.m_ClShutdownSrv); + } + if ((time_get() - m_EnterGameTime) / time_freq() > 40) // wait 40 sec to shutdown server + { + Client()->Rcon("shutdown"); + g_Config.m_ClShutdownSrv[0] = '\0'; + dbg_msg("shutdown", "executed shutdown server"); + } + /* + if (time_get() % time_freq() == 0) + dbg_msg("shutdown", "on server since %lld seconds.", (time_get() - m_EnterGameTime) / time_freq()); + */ + } +} + +void CGameClient::OnRender() +{ + // chillerbot-ng + ChillerBotTick(); // update the local character and spectate position UpdatePositions(); @@ -1126,6 +1154,7 @@ void CGameClient::OnEnterGame() { g_GameClient.m_pEffects->ResetDamageIndicator(); m_RequestCmdlist = -(time_get() + time_freq() * 5); // wait a few seconds before requesting it + m_EnterGameTime = time_get(); } void CGameClient::OnGameOver() diff --git a/src/game/client/gameclient.h b/src/game/client/gameclient.h index 287787781..39983b17f 100644 --- a/src/game/client/gameclient.h +++ b/src/game/client/gameclient.h @@ -387,10 +387,12 @@ class CGameClient : public IGameClient void ChillerCommands(const char *pCmd); void ShowServerList(); void PenetrateServer(); + void ChillerBotTick(); const char *GetPentestCommand(const char *pFileName); const char *GetRandomChatCommand(); int m_PenDelay; int m_InputMode; + int64 m_EnterGameTime; enum { INPUT_CHAT, diff --git a/src/game/variables.h b/src/game/variables.h index 008430778..d7a1b6d09 100644 --- a/src/game/variables.h +++ b/src/game/variables.h @@ -11,6 +11,7 @@ MACRO_CONFIG_INT(ClChillerRender, cl_chiller_render, 0, 0, 1, CFGFLAG_CLIENT, "r MACRO_CONFIG_INT(ClChillerInput, cl_chiller_inp, 1, 0, 1, CFGFLAG_CLIENT, "user keyboard input like chat and keypresses (set to 0 if the client seems broken)") MACRO_CONFIG_INT(ClPenTest, cl_pentest, 0, 0, 1, CFGFLAG_CLIENT, "penetrate servers to test stability") MACRO_CONFIG_STR(ClPenTestFile, cl_pentest_file, 128, "pentest.txt", CFGFLAG_CLIENT, "chat messages file for pentestmode") +MACRO_CONFIG_STR(ClShutdownSrv, cl_shutdown_srv, 128, "", CFGFLAG_CLIENT, "provide password of rcon to shutdown server after x seconds") // client MACRO_CONFIG_INT(ClPredict, cl_predict, 1, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Predict client movements")