From b3981fb74cc0329c70ed550b908a7b6fc7a31b22 Mon Sep 17 00:00:00 2001 From: oy Date: Sat, 13 Oct 2018 17:12:55 +0200 Subject: [PATCH] fixed game info update --- src/game/server/gamecontext.cpp | 14 ++++++++++++++ src/game/server/gamecontext.h | 1 + src/game/server/gamecontroller.cpp | 27 ++++++++++++++++----------- src/game/server/gamecontroller.h | 1 + 4 files changed, 32 insertions(+), 11 deletions(-) diff --git a/src/game/server/gamecontext.cpp b/src/game/server/gamecontext.cpp index 584d5534b..546977ed8 100644 --- a/src/game/server/gamecontext.cpp +++ b/src/game/server/gamecontext.cpp @@ -1351,6 +1351,16 @@ void CGameContext::ConchainSettingUpdate(IConsole::IResult *pResult, void *pUser } } +void CGameContext::ConchainGameinfoUpdate(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData) +{ + pfnCallback(pResult, pCallbackUserData); + if(pResult->NumArguments()) + { + CGameContext *pSelf = (CGameContext *)pUserData; + pSelf->m_pController->CheckGameInfo(); + } +} + void CGameContext::OnConsoleInit() { m_pServer = Kernel()->RequestInterface(); @@ -1383,6 +1393,10 @@ void CGameContext::OnConsoleInit() Console()->Chain("sv_vote_spectate", ConchainSettingUpdate, this); Console()->Chain("sv_teambalance_time", ConchainSettingUpdate, this); Console()->Chain("sv_spectator_slots", ConchainSettingUpdate, this); + + Console()->Chain("sv_scorelimit", ConchainGameinfoUpdate, this); + Console()->Chain("sv_timelimit", ConchainGameinfoUpdate, this); + Console()->Chain("sv_matches_per_map", ConchainGameinfoUpdate, this); } void CGameContext::OnInit() diff --git a/src/game/server/gamecontext.h b/src/game/server/gamecontext.h index e2d1667b0..1b57c7d07 100644 --- a/src/game/server/gamecontext.h +++ b/src/game/server/gamecontext.h @@ -62,6 +62,7 @@ class CGameContext : public IGameServer static void ConVote(IConsole::IResult *pResult, void *pUserData); static void ConchainSpecialMotdupdate(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData); static void ConchainSettingUpdate(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData); + static void ConchainGameinfoUpdate(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData); CGameContext(int Resetting); void Construct(int Resetting); diff --git a/src/game/server/gamecontroller.cpp b/src/game/server/gamecontroller.cpp index 37ba8d45a..6fc072e44 100644 --- a/src/game/server/gamecontroller.cpp +++ b/src/game/server/gamecontroller.cpp @@ -461,17 +461,7 @@ void IGameController::ResetGame() m_GameStartTick = Server()->Tick(); m_SuddenDeath = 0; - int MatchNum = (str_length(g_Config.m_SvMaprotation) && g_Config.m_SvMatchesPerMap) ? g_Config.m_SvMatchesPerMap : 0; - if(MatchNum == 0) - m_MatchCount = 0; - bool GameInfoChanged = (m_GameInfo.m_MatchCurrent != m_MatchCount+1) || (m_GameInfo.m_MatchNum != MatchNum) || - (m_GameInfo.m_ScoreLimit != g_Config.m_SvScorelimit) || (m_GameInfo.m_TimeLimit != g_Config.m_SvTimelimit); - m_GameInfo.m_MatchCurrent = m_MatchCount+1; - m_GameInfo.m_MatchNum = MatchNum; - m_GameInfo.m_ScoreLimit = g_Config.m_SvScorelimit; - m_GameInfo.m_TimeLimit = g_Config.m_SvTimelimit; - if(GameInfoChanged) - UpdateGameInfo(-1); + CheckGameInfo(); // do team-balancing DoTeamBalance(); @@ -802,6 +792,21 @@ void IGameController::Tick() } // info +void IGameController::CheckGameInfo() +{ + int MatchNum = (str_length(g_Config.m_SvMaprotation) && g_Config.m_SvMatchesPerMap) ? g_Config.m_SvMatchesPerMap : 0; + if(MatchNum == 0) + m_MatchCount = 0; + bool GameInfoChanged = (m_GameInfo.m_MatchCurrent != m_MatchCount + 1) || (m_GameInfo.m_MatchNum != MatchNum) || + (m_GameInfo.m_ScoreLimit != g_Config.m_SvScorelimit) || (m_GameInfo.m_TimeLimit != g_Config.m_SvTimelimit); + m_GameInfo.m_MatchCurrent = m_MatchCount + 1; + m_GameInfo.m_MatchNum = MatchNum; + m_GameInfo.m_ScoreLimit = g_Config.m_SvScorelimit; + m_GameInfo.m_TimeLimit = g_Config.m_SvTimelimit; + if(GameInfoChanged) + UpdateGameInfo(-1); +} + bool IGameController::IsFriendlyFire(int ClientID1, int ClientID2) const { if(ClientID1 == ClientID2) diff --git a/src/game/server/gamecontroller.h b/src/game/server/gamecontroller.h index 835ccdee8..ab4aa5626 100644 --- a/src/game/server/gamecontroller.h +++ b/src/game/server/gamecontroller.h @@ -186,6 +186,7 @@ public: virtual void Tick(); // info + void CheckGameInfo(); bool IsFriendlyFire(int ClientID1, int ClientID2) const; bool IsGamePaused() const { return m_GameState == IGS_GAME_PAUSED || m_GameState == IGS_START_COUNTDOWN; } bool IsGameRunning() const { return m_GameState == IGS_GAME_RUNNING; }