diff options
| author | Choupom <andycootlapin@hotmail.fr> | 2011-04-12 18:59:08 +0200 |
|---|---|---|
| committer | oy <Tom_Adams@web.de> | 2011-04-12 19:29:06 +0200 |
| commit | ffe40db053b50bebc1743a2b96e8c76a8af79b12 (patch) | |
| tree | da2705187fa2791f62c073445cde54bf7b0a751b /src/game/client | |
| parent | b5070bac70beb39a45c1340ced3e0a7740997638 (diff) | |
| download | zcatch-ffe40db053b50bebc1743a2b96e8c76a8af79b12.tar.gz zcatch-ffe40db053b50bebc1743a2b96e8c76a8af79b12.zip | |
fixed map download speed and remaining time
Diffstat (limited to 'src/game/client')
| -rw-r--r-- | src/game/client/components/menus.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/game/client/components/menus.cpp b/src/game/client/components/menus.cpp index 568b3a6e..8bed34c1 100644 --- a/src/game/client/components/menus.cpp +++ b/src/game/client/components/menus.cpp @@ -1038,20 +1038,24 @@ int CMenus::Render() } // update download speed - float Diff = (Client()->MapDownloadAmount()-m_DownloadLastCheckSize)/1024.0f; - m_DownloadSpeed = absolute((m_DownloadSpeed*(1.0f-(1.0f/m_DownloadSpeed))) + (Diff*(1.0f/m_DownloadSpeed))); + float Diff = Client()->MapDownloadAmount()-m_DownloadLastCheckSize; + float StartDiff = m_DownloadLastCheckSize-0.0f; + if(StartDiff+Diff > 0.0f) + m_DownloadSpeed = (Diff/(StartDiff+Diff))*(Diff/1.0f) + (StartDiff/(Diff+StartDiff))*m_DownloadSpeed; + else + m_DownloadSpeed = 0.0f; m_DownloadLastCheckTime = Now; m_DownloadLastCheckSize = Client()->MapDownloadAmount(); } Box.HSplitTop(64.f, 0, &Box); Box.HSplitTop(24.f, &Part, &Box); - str_format(aBuf, sizeof(aBuf), "%d/%d KiB (%.1f KiB/s)", Client()->MapDownloadAmount()/1024, Client()->MapDownloadTotalsize()/1024, m_DownloadSpeed); + str_format(aBuf, sizeof(aBuf), "%d/%d KiB (%.1f KiB/s)", Client()->MapDownloadAmount()/1024, Client()->MapDownloadTotalsize()/1024, m_DownloadSpeed/1024.0f); UI()->DoLabel(&Part, aBuf, 20.f, 0, -1); // time left const char *pTimeLeftString; - int TimeLeft = (Client()->MapDownloadTotalsize()-Client()->MapDownloadAmount())/(m_DownloadSpeed*1024)+1; + int TimeLeft = m_DownloadSpeed > 0.0f ? (Client()->MapDownloadTotalsize()-Client()->MapDownloadAmount())/m_DownloadSpeed : 0.0f; if(TimeLeft >= 60) { TimeLeft /= 60; @@ -1346,7 +1350,7 @@ void CMenus::OnStateChange(int NewState, int OldState) m_Popup = POPUP_CONNECTING; m_DownloadLastCheckTime = time_get(); m_DownloadLastCheckSize = 0; - m_DownloadSpeed = 1.0f; + m_DownloadSpeed = 0.0f; //client_serverinfo_request(); } else if(NewState == IClient::STATE_CONNECTING) |