mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-13 03:28:19 +00:00
Merge pull request #678 from necropotame/pr-i662-timer
Fix #662 (timer command displays the wrong state)
This commit is contained in:
commit
afce3c9d3d
|
@ -1272,6 +1272,8 @@ void CGameContext::ConTime(IConsole::IResult *pResult, void *pUserData)
|
||||||
pSelf->SendBroadcast(aBuftime, pResult->m_ClientID);
|
pSelf->SendBroadcast(aBuftime, pResult->m_ClientID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const char s_aaMsg[3][128] = {"game/round timer.", "broadcast.", "both game/round timer and broadcast."};
|
||||||
|
|
||||||
void CGameContext::ConSetTimerType(IConsole::IResult *pResult, void *pUserData)
|
void CGameContext::ConSetTimerType(IConsole::IResult *pResult, void *pUserData)
|
||||||
{
|
{
|
||||||
CGameContext *pSelf = (CGameContext *) pUserData;
|
CGameContext *pSelf = (CGameContext *) pUserData;
|
||||||
|
@ -1283,60 +1285,65 @@ void CGameContext::ConSetTimerType(IConsole::IResult *pResult, void *pUserData)
|
||||||
if (!pPlayer)
|
if (!pPlayer)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const char msg[3][128] = {"game/round timer.", "broadcast.", "both game/round timer and broadcast."};
|
|
||||||
char aBuf[128];
|
char aBuf[128];
|
||||||
if(pPlayer->m_TimerType <= CPlayer::TIMERTYPE_GAMETIMER_AND_BROADCAST && pPlayer->m_TimerType >= CPlayer::TIMERTYPE_GAMETIMER)
|
|
||||||
str_format(aBuf, sizeof(aBuf), "Timer is displayed in %s", msg[pPlayer->m_TimerType]);
|
if(pResult->NumArguments() > 0)
|
||||||
else if(pPlayer->m_TimerType == CPlayer::TIMERTYPE_NONE)
|
|
||||||
str_format(aBuf, sizeof(aBuf), "Timer isn't displayed.");
|
|
||||||
|
|
||||||
int OldType = pPlayer->m_TimerType;
|
|
||||||
|
|
||||||
if(pResult->NumArguments() == 0) {
|
|
||||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD,"timer",aBuf);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else if(str_comp_nocase(pResult->GetString(0), "gametimer") == 0)
|
|
||||||
{
|
{
|
||||||
if(pPlayer->m_ClientVersion >= VERSION_DDNET_GAMETICK)
|
int OldType = pPlayer->m_TimerType;
|
||||||
pPlayer->m_TimerType = CPlayer::TIMERTYPE_GAMETIMER;
|
|
||||||
else
|
if(str_comp_nocase(pResult->GetString(0), "gametimer") == 0)
|
||||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "timer", "gametimer is not supported by your client.");
|
|
||||||
}
|
|
||||||
else if(str_comp_nocase(pResult->GetString(0), "broadcast") == 0)
|
|
||||||
pPlayer->m_TimerType = CPlayer::TIMERTYPE_BROADCAST;
|
|
||||||
else if(str_comp_nocase(pResult->GetString(0), "both") == 0)
|
|
||||||
{
|
|
||||||
if(pPlayer->m_ClientVersion >= VERSION_DDNET_GAMETICK)
|
|
||||||
pPlayer->m_TimerType = CPlayer::TIMERTYPE_GAMETIMER_AND_BROADCAST;
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
pPlayer->m_TimerType = CPlayer::TIMERTYPE_BROADCAST;
|
if(pPlayer->m_ClientVersion >= VERSION_DDNET_GAMETICK)
|
||||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "timer", "gametimer is not supported by your client.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(str_comp_nocase(pResult->GetString(0), "none") == 0)
|
|
||||||
pPlayer->m_TimerType = CPlayer::TIMERTYPE_NONE;
|
|
||||||
else if(str_comp_nocase(pResult->GetString(0), "cycle") == 0)
|
|
||||||
{
|
|
||||||
if(pPlayer->m_ClientVersion >= VERSION_DDNET_GAMETICK)
|
|
||||||
{
|
|
||||||
if(pPlayer->m_TimerType < CPlayer::TIMERTYPE_NONE)
|
|
||||||
pPlayer->m_TimerType++;
|
|
||||||
else if(pPlayer->m_TimerType == CPlayer::TIMERTYPE_NONE)
|
|
||||||
pPlayer->m_TimerType = CPlayer::TIMERTYPE_GAMETIMER;
|
pPlayer->m_TimerType = CPlayer::TIMERTYPE_GAMETIMER;
|
||||||
|
else
|
||||||
|
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "timer", "gametimer is not supported by your client.");
|
||||||
|
}
|
||||||
|
else if(str_comp_nocase(pResult->GetString(0), "broadcast") == 0)
|
||||||
|
pPlayer->m_TimerType = CPlayer::TIMERTYPE_BROADCAST;
|
||||||
|
else if(str_comp_nocase(pResult->GetString(0), "both") == 0)
|
||||||
|
{
|
||||||
|
if(pPlayer->m_ClientVersion >= VERSION_DDNET_GAMETICK)
|
||||||
|
pPlayer->m_TimerType = CPlayer::TIMERTYPE_GAMETIMER_AND_BROADCAST;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pPlayer->m_TimerType = CPlayer::TIMERTYPE_BROADCAST;
|
||||||
|
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "timer", "gametimer is not supported by your client.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(str_comp_nocase(pResult->GetString(0), "none") == 0)
|
||||||
|
pPlayer->m_TimerType = CPlayer::TIMERTYPE_NONE;
|
||||||
|
else if(str_comp_nocase(pResult->GetString(0), "cycle") == 0)
|
||||||
|
{
|
||||||
|
if(pPlayer->m_ClientVersion >= VERSION_DDNET_GAMETICK)
|
||||||
|
{
|
||||||
|
if(pPlayer->m_TimerType < CPlayer::TIMERTYPE_NONE)
|
||||||
|
pPlayer->m_TimerType++;
|
||||||
|
else if(pPlayer->m_TimerType == CPlayer::TIMERTYPE_NONE)
|
||||||
|
pPlayer->m_TimerType = CPlayer::TIMERTYPE_GAMETIMER;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(pPlayer->m_TimerType < CPlayer::TIMERTYPE_NONE)
|
||||||
|
pPlayer->m_TimerType = CPlayer::TIMERTYPE_NONE;
|
||||||
|
else if(pPlayer->m_TimerType == CPlayer::TIMERTYPE_NONE)
|
||||||
|
pPlayer->m_TimerType = CPlayer::TIMERTYPE_BROADCAST;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(pPlayer->m_TimerType < CPlayer::TIMERTYPE_NONE)
|
str_format(aBuf, sizeof(aBuf), "Unknown \"%s\" parameter. Accepted values: gametimer, broadcast, both, none, cycle", pResult->GetString(0));
|
||||||
pPlayer->m_TimerType = CPlayer::TIMERTYPE_NONE;
|
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "timer", aBuf);
|
||||||
else if(pPlayer->m_TimerType == CPlayer::TIMERTYPE_NONE)
|
return;
|
||||||
pPlayer->m_TimerType = CPlayer::TIMERTYPE_BROADCAST;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if((OldType == CPlayer::TIMERTYPE_BROADCAST || OldType == CPlayer::TIMERTYPE_GAMETIMER_AND_BROADCAST) && (pPlayer->m_TimerType == CPlayer::TIMERTYPE_GAMETIMER || pPlayer->m_TimerType == CPlayer::TIMERTYPE_NONE))
|
||||||
|
pSelf->SendBroadcast("", pResult->m_ClientID);
|
||||||
}
|
}
|
||||||
|
|
||||||
if((OldType == CPlayer::TIMERTYPE_BROADCAST || OldType == CPlayer::TIMERTYPE_GAMETIMER_AND_BROADCAST) && (pPlayer->m_TimerType == CPlayer::TIMERTYPE_GAMETIMER || pPlayer->m_TimerType == CPlayer::TIMERTYPE_NONE))
|
if(pPlayer->m_TimerType <= CPlayer::TIMERTYPE_GAMETIMER_AND_BROADCAST && pPlayer->m_TimerType >= CPlayer::TIMERTYPE_GAMETIMER)
|
||||||
pSelf->SendBroadcast("", pResult->m_ClientID);
|
str_format(aBuf, sizeof(aBuf), "Timer is displayed in %s", s_aaMsg[pPlayer->m_TimerType]);
|
||||||
|
else if(pPlayer->m_TimerType == CPlayer::TIMERTYPE_NONE)
|
||||||
|
str_format(aBuf, sizeof(aBuf), "Timer isn't displayed.");
|
||||||
|
|
||||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "timer", aBuf);
|
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "timer", aBuf);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue