Fix wrong code convension, add enum for timer display type

This commit is contained in:
necropotame 2017-02-27 23:10:19 +01:00
parent 4cfe96801b
commit b6548aa8cf
5 changed files with 29 additions and 21 deletions

View file

@ -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)

View file

@ -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()));

View file

@ -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

View file

@ -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;

View file

@ -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;