summaryrefslogtreecommitdiff
path: root/src/client.h
diff options
context:
space:
mode:
authorIlya Zhuravlev <zhuravlevilya@ya.ru>2012-12-14 15:30:17 +0400
committerIlya Zhuravlev <zhuravlevilya@ya.ru>2012-12-16 15:20:18 +0400
commit3578e1d4a711a32e2e768dcc6ff207ffc1bccbad (patch)
tree9215740fb64bbb89ce9b9ba89f8ebf0db709ee35 /src/client.h
parentaa46e5c5e7285a8ac5c9e096a55c3fa02b90280e (diff)
downloadminetest-3578e1d4a711a32e2e768dcc6ff207ffc1bccbad.tar.gz
minetest-3578e1d4a711a32e2e768dcc6ff207ffc1bccbad.tar.bz2
minetest-3578e1d4a711a32e2e768dcc6ff207ffc1bccbad.zip
Added ability to fetch media from remote server (using cURL library)
Diffstat (limited to 'src/client.h')
-rw-r--r--src/client.h36
1 files changed, 31 insertions, 5 deletions
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<MediaRequest> m_file_requests;
+ MutexedQueue<std::pair<std::string, std::string> > m_file_data;
+ core::list<MediaRequest> 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<MediaRequest> &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<MediaFetchThread> 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<std::string, std::string> 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;