mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Better time/score messages
This commit is contained in:
parent
19419617e5
commit
9743b0cb58
|
@ -421,19 +421,17 @@ CServerBrowser::CServerEntry *CServerBrowser::Add(const NETADDR &Addr)
|
|||
void CServerBrowser::Set(const NETADDR &Addr, int Type, int Token, const CServerInfo *pInfo)
|
||||
{
|
||||
static int temp = 0;
|
||||
static int temp2 = 0;
|
||||
CServerEntry *pEntry = 0;
|
||||
if(Type == IServerBrowser::SET_MASTER_ADD)
|
||||
{
|
||||
if(m_ServerlistType != IServerBrowser::TYPE_INTERNET)
|
||||
return;
|
||||
m_LastPacketTick = 0;
|
||||
++temp2;
|
||||
++temp;
|
||||
if(!Find(Addr))
|
||||
{
|
||||
pEntry = Add(Addr);
|
||||
QueueRequest(pEntry);
|
||||
// dbg_msg("Test", "%d, %d", ++temp, temp2);
|
||||
}
|
||||
}
|
||||
else if(Type == IServerBrowser::SET_FAV_ADD)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
|
||||
/* If you are missing that file, acquire a complete release at teeworlds.com. */
|
||||
#include <engine/graphics.h>
|
||||
#include <engine/serverbrowser.h>
|
||||
#include <engine/textrender.h>
|
||||
#include <engine/shared/config.h>
|
||||
|
||||
|
@ -33,8 +34,6 @@ void CHud::OnReset()
|
|||
m_CheckpointTick = 0;
|
||||
m_DDRaceTick = 0;
|
||||
m_FinishTime = false;
|
||||
m_ServerRecord = -1.0f;
|
||||
m_PlayerRecord = -1.0f;
|
||||
m_DDRaceTimeReceived = false;
|
||||
}
|
||||
|
||||
|
@ -201,7 +200,20 @@ void CHud::RenderScoreHud()
|
|||
for(int t = 0; t < 2; ++t)
|
||||
{
|
||||
if(apPlayerInfo[t])
|
||||
str_format(aScore[t], sizeof(aScore)/2, "%d", apPlayerInfo[t]->m_Score);
|
||||
{
|
||||
CServerInfo Info;
|
||||
Client()->GetServerInfo(&Info);
|
||||
bool IsGameTypeRace = str_find_nocase(Info.m_aGameType, "race") || str_find_nocase(Info.m_aGameType, "fastcap");
|
||||
if(IsGameTypeRace && g_Config.m_ClDDRaceScoreBoard)
|
||||
{
|
||||
if (apPlayerInfo[t]->m_Score != -9999)
|
||||
str_format(aScore[t], sizeof(aScore[t]), "%02d:%02d", abs(apPlayerInfo[t]->m_Score)/60, abs(apPlayerInfo[t]->m_Score)%60);
|
||||
else
|
||||
aScore[t][0] = 0;
|
||||
}
|
||||
else
|
||||
str_format(aScore[t], sizeof(aScore)/2, "%d", apPlayerInfo[t]->m_Score);
|
||||
}
|
||||
else
|
||||
aScore[t][0] = 0;
|
||||
}
|
||||
|
@ -490,7 +502,6 @@ void CHud::OnRender()
|
|||
RenderConnectionWarning();
|
||||
RenderTeambalanceWarning();
|
||||
RenderVoting();
|
||||
RenderRecord();
|
||||
}
|
||||
RenderCursor();
|
||||
}
|
||||
|
@ -526,12 +537,6 @@ void CHud::OnMessage(int MsgType, void *pRawMsg)
|
|||
m_DDRaceTime = 0;
|
||||
}
|
||||
}
|
||||
else if(MsgType == NETMSGTYPE_SV_RECORD)
|
||||
{
|
||||
CNetMsg_Sv_Record *pMsg = (CNetMsg_Sv_Record *)pRawMsg;
|
||||
m_ServerRecord = (float)pMsg->m_ServerTimeBest/100;
|
||||
m_PlayerRecord = (float)pMsg->m_PlayerTimeBest/100;
|
||||
}
|
||||
}
|
||||
|
||||
void CHud::RenderDDRaceEffects()
|
||||
|
@ -593,24 +598,3 @@ void CHud::RenderDDRaceEffects()
|
|||
if(m_DDRaceTick >= 100)
|
||||
m_DDRaceTick = 0;
|
||||
}
|
||||
|
||||
void CHud::RenderRecord()
|
||||
{
|
||||
if(m_ServerRecord > 0 )
|
||||
{
|
||||
char aBuf[64];
|
||||
str_format(aBuf, sizeof(aBuf), "Server best:");
|
||||
TextRender()->Text(0, 5, 40, 6, aBuf, -1);
|
||||
str_format(aBuf, sizeof(aBuf), "%02d:%05.2f", (int)m_ServerRecord/60, m_ServerRecord-((int)m_ServerRecord/60*60));
|
||||
TextRender()->Text(0, 53, 40, 6, aBuf, -1);
|
||||
}
|
||||
|
||||
if(m_PlayerRecord > 0 )
|
||||
{
|
||||
char aBuf[64];
|
||||
str_format(aBuf, sizeof(aBuf), "Personal best:");
|
||||
TextRender()->Text(0, 5, 47, 6, aBuf, -1);
|
||||
str_format(aBuf, sizeof(aBuf), "%02d:%05.2f", (int)m_PlayerRecord/60, m_PlayerRecord-((int)m_PlayerRecord/60*60));
|
||||
TextRender()->Text(0, 53, 47, 6, aBuf, -1);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,8 +44,6 @@ private:
|
|||
int m_CheckpointTick;
|
||||
int m_DDRaceTick;
|
||||
bool m_FinishTime;
|
||||
float m_ServerRecord;
|
||||
float m_PlayerRecord;
|
||||
bool m_DDRaceTimeReceived;
|
||||
};
|
||||
|
||||
|
|
|
@ -32,13 +32,14 @@ void CScoreboard::ConKeyScoreboard(IConsole::IResult *pResult, void *pUserData)
|
|||
CServerInfo Info;
|
||||
|
||||
pSelf->Client()->GetServerInfo(&Info);
|
||||
pSelf->m_IsGameTypeRace = str_find_nocase(Info.m_aGameType, "race");
|
||||
pSelf->m_IsGameTypeRace = str_find_nocase(Info.m_aGameType, "race") || str_find_nocase(Info.m_aGameType, "fastcap");
|
||||
pSelf->m_Active = pResult->GetInteger(0) != 0;
|
||||
}
|
||||
|
||||
void CScoreboard::OnReset()
|
||||
{
|
||||
m_Active = false;
|
||||
m_ServerRecord = -1.0f;
|
||||
}
|
||||
|
||||
void CScoreboard::OnRelease()
|
||||
|
@ -46,6 +47,16 @@ void CScoreboard::OnRelease()
|
|||
m_Active = false;
|
||||
}
|
||||
|
||||
void CScoreboard::OnMessage(int MsgType, void *pRawMsg)
|
||||
{
|
||||
if(MsgType == NETMSGTYPE_SV_RECORD)
|
||||
{
|
||||
CNetMsg_Sv_Record *pMsg = (CNetMsg_Sv_Record *)pRawMsg;
|
||||
m_ServerRecord = (float)pMsg->m_ServerTimeBest/100;
|
||||
//m_PlayerRecord = (float)pMsg->m_PlayerTimeBest/100;
|
||||
}
|
||||
}
|
||||
|
||||
void CScoreboard::OnConsoleInit()
|
||||
{
|
||||
Console()->Register("+scoreboard", "", CFGFLAG_CLIENT, ConKeyScoreboard, this, "Show scoreboard");
|
||||
|
@ -203,6 +214,17 @@ void CScoreboard::RenderScoreboard(float x, float y, float w, int Team, const ch
|
|||
str_format(aBuf, sizeof(aBuf), "%d", Score);
|
||||
}
|
||||
}
|
||||
|
||||
if(m_IsGameTypeRace && g_Config.m_ClDDRaceScoreBoard)
|
||||
{
|
||||
if (m_ServerRecord > 0)
|
||||
{
|
||||
str_format(aBuf, sizeof(aBuf), "%02d:%02d", round(m_ServerRecord)/60, round(m_ServerRecord)%60);
|
||||
}
|
||||
else
|
||||
aBuf[0] = 0;
|
||||
}
|
||||
|
||||
float tw = TextRender()->TextWidth(0, TitleFontsize, aBuf, -1);
|
||||
TextRender()->Text(0, x+w-tw-20.0f, y, TitleFontsize, aBuf, -1);
|
||||
|
||||
|
|
|
@ -29,9 +29,12 @@ public:
|
|||
|
||||
// DDRace
|
||||
|
||||
virtual void OnMessage(int MsgType, void *pRawMsg);
|
||||
|
||||
private:
|
||||
|
||||
bool m_IsGameTypeRace;
|
||||
float m_ServerRecord;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue