mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Fix wrong code convension, add enum for timer display type
This commit is contained in:
parent
4cfe96801b
commit
b6548aa8cf
|
@ -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."};
|
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 <= 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]);
|
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.");
|
str_format(aBuf, sizeof(aBuf), "Timer isn't displayed.");
|
||||||
|
|
||||||
int OldType = pPlayer->m_TimerType;
|
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)
|
else if(str_comp_nocase(pResult->GetString(0), "gametimer") == 0)
|
||||||
{
|
{
|
||||||
if(pPlayer->m_ClientVersion >= VERSION_DDNET_GAMETICK)
|
if(pPlayer->m_ClientVersion >= VERSION_DDNET_GAMETICK)
|
||||||
pPlayer->m_TimerType = 0;
|
pPlayer->m_TimerType = CPlayer::TIMERTYPE_GAMETIMER;
|
||||||
else
|
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)
|
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)
|
else if(str_comp_nocase(pResult->GetString(0), "both") == 0)
|
||||||
{
|
{
|
||||||
if(pPlayer->m_ClientVersion >= VERSION_DDNET_GAMETICK)
|
if(pPlayer->m_ClientVersion >= VERSION_DDNET_GAMETICK)
|
||||||
pPlayer->m_TimerType = 2;
|
pPlayer->m_TimerType = CPlayer::TIMERTYPE_GAMETIMER_AND_BROADCAST;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pPlayer->m_TimerType = 1;
|
pPlayer->m_TimerType = CPlayer::TIMERTYPE_BROADCAST;
|
||||||
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), "none") == 0)
|
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)
|
else if(str_comp_nocase(pResult->GetString(0), "cycle") == 0)
|
||||||
{
|
{
|
||||||
if(pPlayer->m_ClientVersion >= VERSION_DDNET_GAMETICK)
|
if(pPlayer->m_ClientVersion >= VERSION_DDNET_GAMETICK)
|
||||||
{
|
{
|
||||||
if(pPlayer->m_TimerType < 3)
|
if(pPlayer->m_TimerType < CPlayer::TIMERTYPE_NONE)
|
||||||
pPlayer->m_TimerType++;
|
pPlayer->m_TimerType++;
|
||||||
else if(pPlayer->m_TimerType == 3)
|
else if(pPlayer->m_TimerType == CPlayer::TIMERTYPE_NONE)
|
||||||
pPlayer->m_TimerType = 0;
|
pPlayer->m_TimerType = CPlayer::TIMERTYPE_GAMETIMER;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(pPlayer->m_TimerType < 3)
|
if(pPlayer->m_TimerType < CPlayer::TIMERTYPE_NONE)
|
||||||
pPlayer->m_TimerType = 3;
|
pPlayer->m_TimerType = CPlayer::TIMERTYPE_NONE;
|
||||||
else if(pPlayer->m_TimerType == 3)
|
else if(pPlayer->m_TimerType == CPlayer::TIMERTYPE_NONE)
|
||||||
pPlayer->m_TimerType = 1;
|
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->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)
|
void CGameContext::ConRescue(IConsole::IResult *pResult, void *pUserData)
|
||||||
|
|
|
@ -1211,7 +1211,7 @@ void CCharacter::HandleBroadcast()
|
||||||
m_CpLastBroadcast = m_CpActive;
|
m_CpLastBroadcast = m_CpActive;
|
||||||
m_LastBroadcast = Server()->Tick();
|
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];
|
char aBuftime[64];
|
||||||
int IntTime = (int)((float)(Server()->Tick() - m_StartTime) / ((float)Server()->TickSpeed()));
|
int IntTime = (int)((float)(Server()->Tick() - m_StartTime) / ((float)Server()->TickSpeed()));
|
||||||
|
|
|
@ -770,7 +770,7 @@ void IGameController::Snap(int SnappingClient)
|
||||||
CPlayer *pPlayer = SnappingClient > -1 ? GameServer()->m_apPlayers[SnappingClient] : 0;
|
CPlayer *pPlayer = SnappingClient > -1 ? GameServer()->m_apPlayers[SnappingClient] : 0;
|
||||||
CPlayer *pPlayer2;
|
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)
|
if((pPlayer->GetTeam() == -1 || pPlayer->m_Paused)
|
||||||
&& pPlayer->m_SpectatorID != SPEC_FREEVIEW
|
&& pPlayer->m_SpectatorID != SPEC_FREEVIEW
|
||||||
|
|
|
@ -64,7 +64,7 @@ void CPlayer::Reset()
|
||||||
m_Sent2ndAfkWarning = 0;
|
m_Sent2ndAfkWarning = 0;
|
||||||
m_ChatScore = 0;
|
m_ChatScore = 0;
|
||||||
m_EyeEmote = true;
|
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_DefEmote = EMOTE_NORMAL;
|
||||||
m_Afk = false;
|
m_Afk = false;
|
||||||
m_LastWhisperTo = -1;
|
m_LastWhisperTo = -1;
|
||||||
|
|
|
@ -139,6 +139,14 @@ public:
|
||||||
PAUSED_PAUSED,
|
PAUSED_PAUSED,
|
||||||
PAUSED_FORCE
|
PAUSED_FORCE
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
TIMERTYPE_GAMETIMER=0,
|
||||||
|
TIMERTYPE_BROADCAST,
|
||||||
|
TIMERTYPE_GAMETIMER_AND_BROADCAST,
|
||||||
|
TIMERTYPE_NONE,
|
||||||
|
};
|
||||||
|
|
||||||
int m_Paused;
|
int m_Paused;
|
||||||
bool m_DND;
|
bool m_DND;
|
||||||
|
|
Loading…
Reference in a new issue