X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Fclientmedia.h;h=b08b83e4d8c48e851a0678642ca08b995a2dbaca;hb=549cfd9db80c858bdc8d23a237ea57ccf5f68400;hp=5400442394a18fcd6173e963dd0c03fe7f06251f;hpb=0404bbf67196e83d04620180e704916671371ca1;p=dragonfireclient.git diff --git a/src/clientmedia.h b/src/clientmedia.h index 540044239..b08b83e4d 100644 --- a/src/clientmedia.h +++ b/src/clientmedia.h @@ -17,8 +17,7 @@ with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#ifndef CLIENTMEDIA_HEADER -#define CLIENTMEDIA_HEADER +#pragma once #include "irrlichttypes.h" #include "filecache.h" @@ -26,6 +25,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include #include #include +#include class Client; struct HTTPFetchResult; @@ -41,10 +41,10 @@ class ClientMediaDownloader float getProgress() const { if (m_uncached_count >= 1) - return 1.0 * m_uncached_received_count / + return 1.0f * m_uncached_received_count / m_uncached_count; - else - return 0.0; + + return 0.0f; } bool isStarted() const { @@ -58,10 +58,10 @@ class ClientMediaDownloader } // Add a file to the list of required file (but don't fetch it yet) - void addFile(std::string name, std::string sha1); + void addFile(const std::string &name, const std::string &sha1); // Add a remote server to the list; ignored if not built with cURL - void addRemoteServer(std::string baseurl); + void addRemoteServer(const std::string &baseurl); // Steps the media downloader: // - May load media into client by calling client->loadMedia() @@ -96,8 +96,8 @@ class ClientMediaDownloader }; void initialStep(Client *client); - void remoteHashSetReceived(const HTTPFetchResult &fetchresult); - void remoteMediaReceived(const HTTPFetchResult &fetchresult, + void remoteHashSetReceived(const HTTPFetchResult &fetch_result); + void remoteMediaReceived(const HTTPFetchResult &fetch_result, Client *client); s32 selectRemoteServer(FileStatus *filestatus); void startRemoteMediaTransfers(); @@ -122,29 +122,27 @@ class ClientMediaDownloader // Has an attempt been made to load media files from the file cache? // Have hash sets been requested from remote servers? - bool m_initial_step_done; + bool m_initial_step_done = false; // Total number of media files to load - s32 m_uncached_count; + s32 m_uncached_count = 0; // Number of media files that have been received - s32 m_uncached_received_count; + s32 m_uncached_received_count = 0; // Status of remote transfers unsigned long m_httpfetch_caller; - unsigned long m_httpfetch_next_id; - long m_httpfetch_timeout; - s32 m_httpfetch_active; - s32 m_httpfetch_active_limit; - s32 m_outstanding_hash_sets; - std::map m_remote_file_transfers; + unsigned long m_httpfetch_next_id = 0; + long m_httpfetch_timeout = 0; + s32 m_httpfetch_active = 0; + s32 m_httpfetch_active_limit = 0; + s32 m_outstanding_hash_sets = 0; + std::unordered_map m_remote_file_transfers; // All files up to this name have either been received from a // remote server or failed on all remote servers, so those files // don't need to be looked at again // (use m_files.upper_bound(m_name_bound) to get an iterator) - std::string m_name_bound; + std::string m_name_bound = ""; }; - -#endif // !CLIENTMEDIA_HEADER