fixed a bit ugly code

This commit is contained in:
heinrich5991 2010-11-07 12:03:26 +01:00
parent dcb0b0ee1d
commit b9875cefd8
2 changed files with 3 additions and 15 deletions

View file

@ -664,11 +664,7 @@ void CCharacter::OnFinish()
if(!g_Config.m_SvHideScore || i == m_pPlayer->GetCID())
{
CNetMsg_Sv_PlayerTime Msg;
char aBuf[16];
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_Time = time * 100.0;
Msg.m_Cid = m_pPlayer->GetCID();
Server()->SendPackMsg(&Msg, MSGFLAG_VITAL, i);
}

View file

@ -986,12 +986,8 @@ void CGameContext::OnMessage(int MsgId, CUnpacker *pUnpacker, int ClientId)
{
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;
Msg.m_Time = TimeToSend;
Msg.m_Time = Score()->PlayerData(i)->m_CurrentTime * 100;
Msg.m_Cid = i;
Server()->SendPackMsg(&Msg, MSGFLAG_VITAL, ClientId);
//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
if(Score()->PlayerData(ClientId)->m_CurrentTime > 0) {
//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;
Msg.m_Time = TimeToSend;
Msg.m_Time = Score()->PlayerData(ClientId)->m_CurrentTime * 100;
Msg.m_Cid = ClientId;
Server()->SendPackMsg(&Msg, MSGFLAG_VITAL, -1);
}