mirror of
https://github.com/luanti-org/luanti.git
synced 2025-07-02 16:38:41 +00:00
Added ability to fetch media from remote server (using cURL library)
This commit is contained in:
parent
aa46e5c5e7
commit
3578e1d4a7
12 changed files with 278 additions and 49 deletions
36
src/client.h
36
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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue