mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-19 14:38:18 +00:00
fixed game info update
This commit is contained in:
parent
e451a1d28b
commit
b3981fb74c
|
@ -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<IServer>();
|
||||
|
@ -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()
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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; }
|
||||
|
|
Loading…
Reference in a new issue