Cleanup in content_mapblock (#5746)
[oweals/minetest.git] / src / clientmedia.cpp
index 0918e8a3797002d2d262445d7dfe3ffec32b7ce4..9c1e430dfb31f02f460ffd8c75be87f059939a9b 100644 (file)
@@ -26,7 +26,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "log.h"
 #include "porting.h"
 #include "settings.h"
-#include "main.h"
 #include "network/networkprotocol.h"
 #include "util/hex.h"
 #include "util/serialize.h"
@@ -35,7 +34,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 
 static std::string getMediaCacheDir()
 {
-       return porting::path_user + DIR_DELIM + "cache" + DIR_DELIM + "media";
+       return porting::path_cache + DIR_DELIM + "media";
 }
 
 /*
@@ -43,12 +42,12 @@ static std::string getMediaCacheDir()
 */
 
 ClientMediaDownloader::ClientMediaDownloader():
-       m_media_cache(getMediaCacheDir())
+       m_media_cache(getMediaCacheDir()),
+       m_initial_step_done(false),
+       m_uncached_count(0),
+       m_uncached_received_count(0),
+       m_name_bound("")
 {
-       m_initial_step_done = false;
-       m_name_bound = "";  // works because "" is an invalid file name
-       m_uncached_count = 0;
-       m_uncached_received_count = 0;
        m_httpfetch_caller = HTTPFETCH_DISCARD;
        m_httpfetch_active = 0;
        m_httpfetch_active_limit = 0;
@@ -70,7 +69,7 @@ ClientMediaDownloader::~ClientMediaDownloader()
                delete m_remotes[i];
 }
 
-void ClientMediaDownloader::addFile(std::string name, std::string sha1)
+void ClientMediaDownloader::addFile(const std::string &name, const std::string &sha1)
 {
        assert(!m_initial_step_done); // pre-condition
 
@@ -105,7 +104,7 @@ void ClientMediaDownloader::addFile(std::string name, std::string sha1)
        m_files.insert(std::make_pair(name, filestatus));
 }
 
-void ClientMediaDownloader::addRemoteServer(std::string baseurl)
+void ClientMediaDownloader::addRemoteServer(const std::string &baseurl)
 {
        assert(!m_initial_step_done);   // pre-condition
 
@@ -349,7 +348,7 @@ void ClientMediaDownloader::remoteMediaReceived(
 
        std::string name;
        {
-               std::map<unsigned long, std::string>::iterator it =
+               UNORDERED_MAP<unsigned long, std::string>::iterator it =
                        m_remote_file_transfers.find(fetch_result.request_id);
                assert(it != m_remote_file_transfers.end());
                name = it->second;