diff --git a/include/libtorrent/stat.hpp b/include/libtorrent/stat.hpp index 3fab1456b..a301f37ec 100644 --- a/include/libtorrent/stat.hpp +++ b/include/libtorrent/stat.hpp @@ -82,7 +82,7 @@ namespace libtorrent // should be called once every second void second_tick(int tick_interval_ms); - int rate() const { return m_rate_sum / history; } + int rate() const { return int(m_rate_sum / history); } size_type rate_sum() const { return m_rate_sum; } size_type total() const { return m_total_counter; } @@ -94,7 +94,7 @@ namespace libtorrent TORRENT_ASSERT(m_total_counter >= 0); } - size_type counter() const { return m_counter; } + int counter() const { return m_counter; } void clear() { @@ -225,20 +225,20 @@ namespace libtorrent int upload_rate() const { - return (m_stat[upload_payload].rate_sum() + return int((m_stat[upload_payload].rate_sum() + m_stat[upload_protocol].rate_sum() + m_stat[upload_ip_protocol].rate_sum() + m_stat[upload_dht_protocol].rate_sum()) - / stat_channel::history; + / stat_channel::history); } int download_rate() const { - return (m_stat[download_payload].rate_sum() + return int((m_stat[download_payload].rate_sum() + m_stat[download_protocol].rate_sum() + m_stat[download_ip_protocol].rate_sum() + m_stat[download_dht_protocol].rate_sum()) - / stat_channel::history; + / stat_channel::history); } size_type total_upload() const @@ -288,13 +288,13 @@ namespace libtorrent m_stat[upload_payload].offset(uploaded); } - size_type last_payload_downloaded() const + int last_payload_downloaded() const { return m_stat[download_payload].counter(); } - size_type last_payload_uploaded() const + int last_payload_uploaded() const { return m_stat[upload_payload].counter(); } - size_type last_protocol_downloaded() const + int last_protocol_downloaded() const { return m_stat[download_protocol].counter(); } - size_type last_protocol_uploaded() const + int last_protocol_uploaded() const { return m_stat[upload_protocol].counter(); } // these are the channels we keep stats for diff --git a/src/stat.cpp b/src/stat.cpp index 2f824d8fa..6c2c9c5ff 100644 --- a/src/stat.cpp +++ b/src/stat.cpp @@ -55,7 +55,7 @@ void stat_channel::second_tick(int tick_interval_ms) for (int i = history - 2; i >= 0; --i) m_rate_history[i + 1] = m_rate_history[i]; - m_rate_history[0] = size_type(m_counter) * 1000 / tick_interval_ms; + m_rate_history[0] = int(size_type(m_counter) * 1000 / tick_interval_ms); TORRENT_ASSERT(m_rate_history[0] >= 0); m_rate_sum += m_rate_history[0]; m_counter = 0;