mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
fixed a bit ugly code
This commit is contained in:
parent
dcb0b0ee1d
commit
b9875cefd8
|
@ -664,11 +664,7 @@ void CCharacter::OnFinish()
|
||||||
if(!g_Config.m_SvHideScore || i == m_pPlayer->GetCID())
|
if(!g_Config.m_SvHideScore || i == m_pPlayer->GetCID())
|
||||||
{
|
{
|
||||||
CNetMsg_Sv_PlayerTime Msg;
|
CNetMsg_Sv_PlayerTime Msg;
|
||||||
char aBuf[16];
|
Msg.m_Time = time * 100.0;
|
||||||
str_format(aBuf, sizeof(aBuf), "%.0f", time*100.0f); // damn ugly but the only way i know to do it
|
|
||||||
int TimeToSend;
|
|
||||||
sscanf(aBuf, "%d", &TimeToSend);
|
|
||||||
Msg.m_Time = TimeToSend;
|
|
||||||
Msg.m_Cid = m_pPlayer->GetCID();
|
Msg.m_Cid = m_pPlayer->GetCID();
|
||||||
Server()->SendPackMsg(&Msg, MSGFLAG_VITAL, i);
|
Server()->SendPackMsg(&Msg, MSGFLAG_VITAL, i);
|
||||||
}
|
}
|
||||||
|
|
|
@ -986,12 +986,8 @@ void CGameContext::OnMessage(int MsgId, CUnpacker *pUnpacker, int ClientId)
|
||||||
{
|
{
|
||||||
if(m_apPlayers[i] && Score()->PlayerData(i)->m_CurrentTime > 0)
|
if(m_apPlayers[i] && Score()->PlayerData(i)->m_CurrentTime > 0)
|
||||||
{
|
{
|
||||||
char aBuf[16];
|
|
||||||
str_format(aBuf, sizeof(aBuf), "%.0f", Score()->PlayerData(i)->m_CurrentTime*100.0f); // damn ugly but the only way i know to do it
|
|
||||||
int TimeToSend;
|
|
||||||
sscanf(aBuf, "%d", &TimeToSend);
|
|
||||||
CNetMsg_Sv_PlayerTime Msg;
|
CNetMsg_Sv_PlayerTime Msg;
|
||||||
Msg.m_Time = TimeToSend;
|
Msg.m_Time = Score()->PlayerData(i)->m_CurrentTime * 100;
|
||||||
Msg.m_Cid = i;
|
Msg.m_Cid = i;
|
||||||
Server()->SendPackMsg(&Msg, MSGFLAG_VITAL, ClientId);
|
Server()->SendPackMsg(&Msg, MSGFLAG_VITAL, ClientId);
|
||||||
//also send its time to others
|
//also send its time to others
|
||||||
|
@ -1001,12 +997,8 @@ void CGameContext::OnMessage(int MsgId, CUnpacker *pUnpacker, int ClientId)
|
||||||
//also send its time to others
|
//also send its time to others
|
||||||
if(Score()->PlayerData(ClientId)->m_CurrentTime > 0) {
|
if(Score()->PlayerData(ClientId)->m_CurrentTime > 0) {
|
||||||
//TODO: make function for this fucking steps
|
//TODO: make function for this fucking steps
|
||||||
char aBuf[16];
|
|
||||||
str_format(aBuf, sizeof(aBuf), "%.0f", Score()->PlayerData(ClientId)->m_CurrentTime*100.0f); // damn ugly but the only way i know to do it
|
|
||||||
int TimeToSend;
|
|
||||||
sscanf(aBuf, "%d", &TimeToSend);
|
|
||||||
CNetMsg_Sv_PlayerTime Msg;
|
CNetMsg_Sv_PlayerTime Msg;
|
||||||
Msg.m_Time = TimeToSend;
|
Msg.m_Time = Score()->PlayerData(ClientId)->m_CurrentTime * 100;
|
||||||
Msg.m_Cid = ClientId;
|
Msg.m_Cid = ClientId;
|
||||||
Server()->SendPackMsg(&Msg, MSGFLAG_VITAL, -1);
|
Server()->SendPackMsg(&Msg, MSGFLAG_VITAL, -1);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue