diff --git a/src/game/server/ddracechat.cpp b/src/game/server/ddracechat.cpp index 6ba910b50..bf99e100b 100644 --- a/src/game/server/ddracechat.cpp +++ b/src/game/server/ddracechat.cpp @@ -1181,9 +1181,9 @@ void CGameContext::ConSetTimerType(IConsole::IResult *pResult, void *pUserData) const char msg[3][128] = {"game/round timer.", "broadcast.", "both game/round timer and broadcast."}; char aBuf[128]; - if(pPlayer->m_TimerType <= 2 && pPlayer->m_TimerType >= 0) + 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]); - else if(pPlayer->m_TimerType == 3) + else if(pPlayer->m_TimerType == CPlayer::TIMERTYPE_NONE) str_format(aBuf, sizeof(aBuf), "Timer isn't displayed."); int OldType = pPlayer->m_TimerType; @@ -1195,46 +1195,46 @@ void CGameContext::ConSetTimerType(IConsole::IResult *pResult, void *pUserData) else if(str_comp_nocase(pResult->GetString(0), "gametimer") == 0) { if(pPlayer->m_ClientVersion >= VERSION_DDNET_GAMETICK) - pPlayer->m_TimerType = 0; + pPlayer->m_TimerType = CPlayer::TIMERTYPE_GAMETIMER; else - pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD,"timer","gametimer is not supported by your client."); + 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 = 1; + 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 = 2; + pPlayer->m_TimerType = CPlayer::TIMERTYPE_GAMETIMER_AND_BROADCAST; else { - pPlayer->m_TimerType = 1; - pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD,"timer","gametimer is not supported by your client."); + 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 = 3; + 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 < 3) + if(pPlayer->m_TimerType < CPlayer::TIMERTYPE_NONE) pPlayer->m_TimerType++; - else if(pPlayer->m_TimerType == 3) - pPlayer->m_TimerType = 0; + else if(pPlayer->m_TimerType == CPlayer::TIMERTYPE_NONE) + pPlayer->m_TimerType = CPlayer::TIMERTYPE_GAMETIMER; } else { - if(pPlayer->m_TimerType < 3) - pPlayer->m_TimerType = 3; - else if(pPlayer->m_TimerType == 3) - pPlayer->m_TimerType = 1; + 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; } } - if((OldType == 1 || OldType == 2) && (pPlayer->m_TimerType == 0 || pPlayer->m_TimerType == 3)) + 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); - pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD,"timer",aBuf); + pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "timer", aBuf); } void CGameContext::ConRescue(IConsole::IResult *pResult, void *pUserData) diff --git a/src/game/server/entities/character.cpp b/src/game/server/entities/character.cpp index aebbf7b63..2281ae359 100644 --- a/src/game/server/entities/character.cpp +++ b/src/game/server/entities/character.cpp @@ -1211,7 +1211,7 @@ void CCharacter::HandleBroadcast() m_CpLastBroadcast = m_CpActive; m_LastBroadcast = Server()->Tick(); } - else if ((m_pPlayer->m_TimerType == 1 || m_pPlayer->m_TimerType == 2) && m_DDRaceState == DDRACE_STARTED && m_LastBroadcast + Server()->TickSpeed() * g_Config.m_SvTimeInBroadcastInterval <= Server()->Tick()) + else if ((m_pPlayer->m_TimerType == CPlayer::TIMERTYPE_BROADCAST || m_pPlayer->m_TimerType == CPlayer::TIMERTYPE_GAMETIMER_AND_BROADCAST) && m_DDRaceState == DDRACE_STARTED && m_LastBroadcast + Server()->TickSpeed() * g_Config.m_SvTimeInBroadcastInterval <= Server()->Tick()) { char aBuftime[64]; int IntTime = (int)((float)(Server()->Tick() - m_StartTime) / ((float)Server()->TickSpeed())); diff --git a/src/game/server/gamecontroller.cpp b/src/game/server/gamecontroller.cpp index 195657618..a28ae196c 100644 --- a/src/game/server/gamecontroller.cpp +++ b/src/game/server/gamecontroller.cpp @@ -770,7 +770,7 @@ void IGameController::Snap(int SnappingClient) CPlayer *pPlayer = SnappingClient > -1 ? GameServer()->m_apPlayers[SnappingClient] : 0; CPlayer *pPlayer2; - if(pPlayer && (pPlayer->m_TimerType == 0 || pPlayer->m_TimerType == 2) && pPlayer->m_ClientVersion >= VERSION_DDNET_GAMETICK) + if(pPlayer && (pPlayer->m_TimerType == CPlayer::TIMERTYPE_GAMETIMER || pPlayer->m_TimerType == CPlayer::TIMERTYPE_GAMETIMER_AND_BROADCAST) && pPlayer->m_ClientVersion >= VERSION_DDNET_GAMETICK) { if((pPlayer->GetTeam() == -1 || pPlayer->m_Paused) && pPlayer->m_SpectatorID != SPEC_FREEVIEW diff --git a/src/game/server/player.cpp b/src/game/server/player.cpp index 66bb51e9b..e31f54ab1 100644 --- a/src/game/server/player.cpp +++ b/src/game/server/player.cpp @@ -64,7 +64,7 @@ void CPlayer::Reset() m_Sent2ndAfkWarning = 0; m_ChatScore = 0; m_EyeEmote = true; - m_TimerType = (g_Config.m_SvDefaultTimerType == 0 || g_Config.m_SvDefaultTimerType == 2) ? 1 : g_Config.m_SvDefaultTimerType; + m_TimerType = (g_Config.m_SvDefaultTimerType == CPlayer::TIMERTYPE_GAMETIMER || g_Config.m_SvDefaultTimerType == CPlayer::TIMERTYPE_GAMETIMER_AND_BROADCAST) ? CPlayer::TIMERTYPE_BROADCAST : g_Config.m_SvDefaultTimerType; m_DefEmote = EMOTE_NORMAL; m_Afk = false; m_LastWhisperTo = -1; diff --git a/src/game/server/player.h b/src/game/server/player.h index ae607fbea..95c4d4505 100644 --- a/src/game/server/player.h +++ b/src/game/server/player.h @@ -139,6 +139,14 @@ public: PAUSED_PAUSED, PAUSED_FORCE }; + + enum + { + TIMERTYPE_GAMETIMER=0, + TIMERTYPE_BROADCAST, + TIMERTYPE_GAMETIMER_AND_BROADCAST, + TIMERTYPE_NONE, + }; int m_Paused; bool m_DND;