From 3578e1d4a711a32e2e768dcc6ff207ffc1bccbad Mon Sep 17 00:00:00 2001 From: Ilya Zhuravlev Date: Fri, 14 Dec 2012 15:30:17 +0400 Subject: Added ability to fetch media from remote server (using cURL library) --- src/client.h | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) (limited to 'src/client.h') diff --git a/src/client.h b/src/client.h index f85e8ac7b..c6858f549 100644 --- a/src/client.h +++ b/src/client.h @@ -33,6 +33,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "filesys.h" #include "filecache.h" #include "localplayer.h" +#include "server.h" #include "util/pointedthing.h" struct MeshMakeData; @@ -129,6 +130,24 @@ public: IGameDef *m_gamedef; }; +class MediaFetchThread : public SimpleThread +{ +public: + + MediaFetchThread(IGameDef *gamedef): + m_gamedef(gamedef) + { + } + + void * Thread(); + + core::list m_file_requests; + MutexedQueue > m_file_data; + core::list m_failed; + std::string m_remote_url; + IGameDef *m_gamedef; +}; + enum ClientEventType { CE_NONE, @@ -289,10 +308,13 @@ public: { return m_access_denied_reason; } float mediaReceiveProgress() - { return m_media_receive_progress; } + { + if (!m_media_receive_started) return 0; + return 1.0 * m_media_received_count / m_media_count; + } bool texturesReceived() - { return m_media_received; } + { return m_media_receive_started && m_media_received_count == m_media_count; } bool itemdefReceived() { return m_itemdef_received; } bool nodedefReceived() @@ -318,7 +340,9 @@ private: // Insert a media file appropriately into the appropriate manager bool loadMedia(const std::string &data, const std::string &filename); - + + void request_media(const core::list &file_requests); + // Virtual methods from con::PeerHandler void peerAdded(con::Peer *peer); void deletingPeer(con::Peer *peer, bool timeout); @@ -347,6 +371,7 @@ private: MtEventManager *m_event; MeshUpdateThread m_mesh_update_thread; + core::list m_media_fetch_threads; ClientEnvironment m_env; con::Connection m_con; IrrlichtDevice *m_device; @@ -375,8 +400,9 @@ private: FileCache m_media_cache; // Mapping from media file name to SHA1 checksum core::map m_media_name_sha1_map; - float m_media_receive_progress; - bool m_media_received; + bool m_media_receive_started; + u32 m_media_count; + u32 m_media_received_count; bool m_itemdef_received; bool m_nodedef_received; friend class FarMesh; -- cgit v1.2.3