mirror of
https://github.com/ddnet/ddnet.git
synced 2024-09-20 01:24:18 +00:00
Send the race time using warmup timer
This commit is contained in:
parent
16f04d8989
commit
4cfe96801b
|
@ -176,6 +176,7 @@ if gen_network_source:
|
||||||
lines += ['']
|
lines += ['']
|
||||||
|
|
||||||
lines += ['static const int max_int = 0x7fffffff;']
|
lines += ['static const int max_int = 0x7fffffff;']
|
||||||
|
lines += ['static const int min_int = 0x80000000;']
|
||||||
|
|
||||||
lines += ['int CNetObjHandler::ClampInt(const char *pErrorMsg, int Value, int Min, int Max)']
|
lines += ['int CNetObjHandler::ClampInt(const char *pErrorMsg, int Value, int Min, int Max)']
|
||||||
lines += ['{']
|
lines += ['{']
|
||||||
|
|
|
@ -3,7 +3,7 @@ from datatypes import *
|
||||||
Emotes = ["NORMAL", "PAIN", "HAPPY", "SURPRISE", "ANGRY", "BLINK"]
|
Emotes = ["NORMAL", "PAIN", "HAPPY", "SURPRISE", "ANGRY", "BLINK"]
|
||||||
PlayerFlags = ["PLAYING", "IN_MENU", "CHATTING", "SCOREBOARD", "AIM"]
|
PlayerFlags = ["PLAYING", "IN_MENU", "CHATTING", "SCOREBOARD", "AIM"]
|
||||||
GameFlags = ["TEAMS", "FLAGS"]
|
GameFlags = ["TEAMS", "FLAGS"]
|
||||||
GameStateFlags = ["GAMEOVER", "SUDDENDEATH", "PAUSED"]
|
GameStateFlags = ["GAMEOVER", "SUDDENDEATH", "PAUSED", "RACETIME"]
|
||||||
|
|
||||||
Emoticons = ["OOP", "EXCLAMATION", "HEARTS", "DROP", "DOTDOT", "MUSIC", "SORRY", "GHOST", "SUSHI", "SPLATTEE", "DEVILTEE", "ZOMG", "ZZZ", "WTF", "EYES", "QUESTION"]
|
Emoticons = ["OOP", "EXCLAMATION", "HEARTS", "DROP", "DOTDOT", "MUSIC", "SORRY", "GHOST", "SUSHI", "SPLATTEE", "DEVILTEE", "ZOMG", "ZZZ", "WTF", "EYES", "QUESTION"]
|
||||||
|
|
||||||
|
@ -106,7 +106,7 @@ Objects = [
|
||||||
NetIntRange("m_GameFlags", 0, 256),
|
NetIntRange("m_GameFlags", 0, 256),
|
||||||
NetIntRange("m_GameStateFlags", 0, 256),
|
NetIntRange("m_GameStateFlags", 0, 256),
|
||||||
NetTick("m_RoundStartTick"),
|
NetTick("m_RoundStartTick"),
|
||||||
NetIntRange("m_WarmupTimer", 0, 'max_int'),
|
NetIntRange("m_WarmupTimer", 'min_int', 'max_int'),
|
||||||
|
|
||||||
NetIntRange("m_ScoreLimit", 0, 'max_int'),
|
NetIntRange("m_ScoreLimit", 0, 'max_int'),
|
||||||
NetIntRange("m_TimeLimit", 0, 'max_int'),
|
NetIntRange("m_TimeLimit", 0, 'max_int'),
|
||||||
|
|
|
@ -108,6 +108,7 @@ enum
|
||||||
VERSION_DDNET_HOOKDURATION_TUNE = 607,
|
VERSION_DDNET_HOOKDURATION_TUNE = 607,
|
||||||
VERSION_DDNET_FIREDELAY_TUNE = 701,
|
VERSION_DDNET_FIREDELAY_TUNE = 701,
|
||||||
VERSION_DDNET_UPDATER_FIXED = 707,
|
VERSION_DDNET_UPDATER_FIXED = 707,
|
||||||
|
VERSION_DDNET_GAMETICK = 10036,
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -47,13 +47,18 @@ void CHud::RenderGameTimer()
|
||||||
{
|
{
|
||||||
char Buf[32];
|
char Buf[32];
|
||||||
int Time = 0;
|
int Time = 0;
|
||||||
if(m_pClient->m_Snap.m_pGameInfoObj->m_TimeLimit && !m_pClient->m_Snap.m_pGameInfoObj->m_WarmupTimer)
|
if(m_pClient->m_Snap.m_pGameInfoObj->m_TimeLimit && (m_pClient->m_Snap.m_pGameInfoObj->m_WarmupTimer <= 0))
|
||||||
{
|
{
|
||||||
Time = m_pClient->m_Snap.m_pGameInfoObj->m_TimeLimit*60 - ((Client()->GameTick()-m_pClient->m_Snap.m_pGameInfoObj->m_RoundStartTick)/Client()->GameTickSpeed());
|
Time = m_pClient->m_Snap.m_pGameInfoObj->m_TimeLimit*60 - ((Client()->GameTick()-m_pClient->m_Snap.m_pGameInfoObj->m_RoundStartTick)/Client()->GameTickSpeed());
|
||||||
|
|
||||||
if(m_pClient->m_Snap.m_pGameInfoObj->m_GameStateFlags&GAMESTATEFLAG_GAMEOVER)
|
if(m_pClient->m_Snap.m_pGameInfoObj->m_GameStateFlags&GAMESTATEFLAG_GAMEOVER)
|
||||||
Time = 0;
|
Time = 0;
|
||||||
}
|
}
|
||||||
|
else if(m_pClient->m_Snap.m_pGameInfoObj->m_GameStateFlags&GAMESTATEFLAG_RACETIME)
|
||||||
|
{
|
||||||
|
//The Warmup timer is negative in this case to make sure that incompatible clients will not see a warmup timer
|
||||||
|
Time = (Client()->GameTick()+m_pClient->m_Snap.m_pGameInfoObj->m_WarmupTimer)/Client()->GameTickSpeed();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
Time = (Client()->GameTick()-m_pClient->m_Snap.m_pGameInfoObj->m_RoundStartTick)/Client()->GameTickSpeed();
|
Time = (Client()->GameTick()-m_pClient->m_Snap.m_pGameInfoObj->m_RoundStartTick)/Client()->GameTickSpeed();
|
||||||
|
|
||||||
|
@ -77,7 +82,7 @@ void CHud::RenderGameTimer()
|
||||||
else
|
else
|
||||||
w = TextRender()->TextWidth(0, 12,"00:00",-1);
|
w = TextRender()->TextWidth(0, 12,"00:00",-1);
|
||||||
// last 60 sec red, last 10 sec blink
|
// last 60 sec red, last 10 sec blink
|
||||||
if(m_pClient->m_Snap.m_pGameInfoObj->m_TimeLimit && Time <= 60 && !m_pClient->m_Snap.m_pGameInfoObj->m_WarmupTimer)
|
if(m_pClient->m_Snap.m_pGameInfoObj->m_TimeLimit && Time <= 60 && (m_pClient->m_Snap.m_pGameInfoObj->m_WarmupTimer <= 0))
|
||||||
{
|
{
|
||||||
float Alpha = Time <= 10 && (2*time_get()/time_freq()) % 2 ? 0.5f : 1.0f;
|
float Alpha = Time <= 10 && (2*time_get()/time_freq()) % 2 ? 0.5f : 1.0f;
|
||||||
TextRender()->TextColor(1.0f, 0.25f, 0.25f, Alpha);
|
TextRender()->TextColor(1.0f, 0.25f, 0.25f, Alpha);
|
||||||
|
@ -283,7 +288,7 @@ void CHud::RenderScoreHud()
|
||||||
void CHud::RenderWarmupTimer()
|
void CHud::RenderWarmupTimer()
|
||||||
{
|
{
|
||||||
// render warmup timer
|
// render warmup timer
|
||||||
if(m_pClient->m_Snap.m_pGameInfoObj->m_WarmupTimer)
|
if(m_pClient->m_Snap.m_pGameInfoObj->m_WarmupTimer > 0 && !(m_pClient->m_Snap.m_pGameInfoObj->m_GameStateFlags&GAMESTATEFLAG_RACETIME))
|
||||||
{
|
{
|
||||||
char Buf[256];
|
char Buf[256];
|
||||||
float FontSize = 20.0f;
|
float FontSize = 20.0f;
|
||||||
|
|
|
@ -1182,30 +1182,58 @@ 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 <= 2 && pPlayer->m_TimerType >= 0)
|
||||||
str_format(aBuf, sizeof(aBuf), "Timer is displayed in", 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 == 3)
|
||||||
str_format(aBuf, sizeof(aBuf), "Timer isn't displayed.");
|
str_format(aBuf, sizeof(aBuf), "Timer isn't displayed.");
|
||||||
|
|
||||||
|
int OldType = pPlayer->m_TimerType;
|
||||||
|
|
||||||
if(pResult->NumArguments() == 0) {
|
if(pResult->NumArguments() == 0) {
|
||||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD,"timer",aBuf);
|
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD,"timer",aBuf);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if(str_comp_nocase(pResult->GetString(0), "gametimer") == 0) {
|
else if(str_comp_nocase(pResult->GetString(0), "gametimer") == 0)
|
||||||
pSelf->SendBroadcast("", pResult->m_ClientID);
|
{
|
||||||
|
if(pPlayer->m_ClientVersion >= VERSION_DDNET_GAMETICK)
|
||||||
pPlayer->m_TimerType = 0;
|
pPlayer->m_TimerType = 0;
|
||||||
|
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)
|
else if(str_comp_nocase(pResult->GetString(0), "broadcast") == 0)
|
||||||
pPlayer->m_TimerType = 1;
|
pPlayer->m_TimerType = 1;
|
||||||
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)
|
||||||
pPlayer->m_TimerType = 2;
|
pPlayer->m_TimerType = 2;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pPlayer->m_TimerType = 1;
|
||||||
|
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 = 3;
|
||||||
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_TimerType < 3)
|
if(pPlayer->m_TimerType < 3)
|
||||||
pPlayer->m_TimerType++;
|
pPlayer->m_TimerType++;
|
||||||
else if(pPlayer->m_TimerType == 3)
|
else if(pPlayer->m_TimerType == 3)
|
||||||
pPlayer->m_TimerType = 0;
|
pPlayer->m_TimerType = 0;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(pPlayer->m_TimerType < 3)
|
||||||
|
pPlayer->m_TimerType = 3;
|
||||||
|
else if(pPlayer->m_TimerType == 3)
|
||||||
|
pPlayer->m_TimerType = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if((OldType == 1 || OldType == 2) && (pPlayer->m_TimerType == 0 || pPlayer->m_TimerType == 3))
|
||||||
|
pSelf->SendBroadcast("", pResult->m_ClientID);
|
||||||
|
|
||||||
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD,"timer",aBuf);
|
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD,"timer",aBuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1562,6 +1562,9 @@ void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID)
|
||||||
else if(pPlayer->m_ClientVersion < Version)
|
else if(pPlayer->m_ClientVersion < Version)
|
||||||
pPlayer->m_ClientVersion = Version;
|
pPlayer->m_ClientVersion = Version;
|
||||||
|
|
||||||
|
if(pPlayer->m_ClientVersion >= VERSION_DDNET_GAMETICK)
|
||||||
|
pPlayer->m_TimerType = g_Config.m_SvDefaultTimerType;
|
||||||
|
|
||||||
dbg_msg("ddnet", "%d using Custom Client %d", ClientID, pPlayer->m_ClientVersion);
|
dbg_msg("ddnet", "%d using Custom Client %d", ClientID, pPlayer->m_ClientVersion);
|
||||||
|
|
||||||
//first update his teams state
|
//first update his teams state
|
||||||
|
|
|
@ -770,18 +770,22 @@ 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))
|
if(pPlayer && (pPlayer->m_TimerType == 0 || pPlayer->m_TimerType == 2) && 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
|
||||||
&& (pPlayer2 = GameServer()->m_apPlayers[pPlayer->m_SpectatorID]))
|
&& (pPlayer2 = GameServer()->m_apPlayers[pPlayer->m_SpectatorID]))
|
||||||
{
|
{
|
||||||
if((pChr = pPlayer2->GetCharacter()))
|
if((pChr = pPlayer2->GetCharacter()) && pChr->m_DDRaceState == DDRACE_STARTED)
|
||||||
pGameInfoObj->m_RoundStartTick = (pChr->m_DDRaceState == DDRACE_STARTED)?pChr->m_StartTime:m_RoundStartTick;
|
|
||||||
}
|
|
||||||
else if((pChr = pPlayer->GetCharacter()))
|
|
||||||
{
|
{
|
||||||
pGameInfoObj->m_RoundStartTick = (pChr->m_DDRaceState == DDRACE_STARTED)?pChr->m_StartTime:m_RoundStartTick;
|
pGameInfoObj->m_WarmupTimer = -pChr->m_StartTime;
|
||||||
|
pGameInfoObj->m_GameStateFlags |= GAMESTATEFLAG_RACETIME;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if((pChr = pPlayer->GetCharacter()) && pChr->m_DDRaceState == DDRACE_STARTED)
|
||||||
|
{
|
||||||
|
pGameInfoObj->m_WarmupTimer = -pChr->m_StartTime;
|
||||||
|
pGameInfoObj->m_GameStateFlags |= GAMESTATEFLAG_RACETIME;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
m_TimerType = (g_Config.m_SvDefaultTimerType == 0 || g_Config.m_SvDefaultTimerType == 2) ? 1 : g_Config.m_SvDefaultTimerType;
|
||||||
m_DefEmote = EMOTE_NORMAL;
|
m_DefEmote = EMOTE_NORMAL;
|
||||||
m_Afk = false;
|
m_Afk = false;
|
||||||
m_LastWhisperTo = -1;
|
m_LastWhisperTo = -1;
|
||||||
|
|
Loading…
Reference in a new issue