fixed game info update

This commit is contained in:
oy 2018-10-13 17:12:55 +02:00
parent e451a1d28b
commit b3981fb74c
4 changed files with 32 additions and 11 deletions

View file

@ -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() void CGameContext::OnConsoleInit()
{ {
m_pServer = Kernel()->RequestInterface<IServer>(); m_pServer = Kernel()->RequestInterface<IServer>();
@ -1383,6 +1393,10 @@ void CGameContext::OnConsoleInit()
Console()->Chain("sv_vote_spectate", ConchainSettingUpdate, this); Console()->Chain("sv_vote_spectate", ConchainSettingUpdate, this);
Console()->Chain("sv_teambalance_time", ConchainSettingUpdate, this); Console()->Chain("sv_teambalance_time", ConchainSettingUpdate, this);
Console()->Chain("sv_spectator_slots", 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() void CGameContext::OnInit()

View file

@ -62,6 +62,7 @@ class CGameContext : public IGameServer
static void ConVote(IConsole::IResult *pResult, void *pUserData); static void ConVote(IConsole::IResult *pResult, void *pUserData);
static void ConchainSpecialMotdupdate(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData); 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 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); CGameContext(int Resetting);
void Construct(int Resetting); void Construct(int Resetting);

View file

@ -461,17 +461,7 @@ void IGameController::ResetGame()
m_GameStartTick = Server()->Tick(); m_GameStartTick = Server()->Tick();
m_SuddenDeath = 0; m_SuddenDeath = 0;
int MatchNum = (str_length(g_Config.m_SvMaprotation) && g_Config.m_SvMatchesPerMap) ? g_Config.m_SvMatchesPerMap : 0; CheckGameInfo();
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);
// do team-balancing // do team-balancing
DoTeamBalance(); DoTeamBalance();
@ -802,6 +792,21 @@ void IGameController::Tick()
} }
// info // 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 bool IGameController::IsFriendlyFire(int ClientID1, int ClientID2) const
{ {
if(ClientID1 == ClientID2) if(ClientID1 == ClientID2)

View file

@ -186,6 +186,7 @@ public:
virtual void Tick(); virtual void Tick();
// info // info
void CheckGameInfo();
bool IsFriendlyFire(int ClientID1, int ClientID2) const; bool IsFriendlyFire(int ClientID1, int ClientID2) const;
bool IsGamePaused() const { return m_GameState == IGS_GAME_PAUSED || m_GameState == IGS_START_COUNTDOWN; } bool IsGamePaused() const { return m_GameState == IGS_GAME_PAUSED || m_GameState == IGS_START_COUNTDOWN; }
bool IsGameRunning() const { return m_GameState == IGS_GAME_RUNNING; } bool IsGameRunning() const { return m_GameState == IGS_GAME_RUNNING; }