]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - src/clientmedia.cpp
Mgvalleys: Correct spawn problems
[dragonfireclient.git] / src / clientmedia.cpp
index 7eb505314b0b5116a232cef88a86b88893ed2794..bca3f67c28fd721c80fead554074f9c41ac1680d 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";
 }
 
 /*
@@ -72,7 +71,7 @@ ClientMediaDownloader::~ClientMediaDownloader()
 
 void ClientMediaDownloader::addFile(std::string name, std::string sha1)
 {
-       assert(!m_initial_step_done);
+       assert(!m_initial_step_done); // pre-condition
 
        // if name was already announced, ignore the new announcement
        if (m_files.count(name) != 0) {
@@ -107,7 +106,7 @@ void ClientMediaDownloader::addFile(std::string name, std::string sha1)
 
 void ClientMediaDownloader::addRemoteServer(std::string baseurl)
 {
-       assert(!m_initial_step_done);
+       assert(!m_initial_step_done);   // pre-condition
 
        #ifdef USE_CURL
 
@@ -356,11 +355,11 @@ void ClientMediaDownloader::remoteMediaReceived(
                m_remote_file_transfers.erase(it);
        }
 
-       assert(m_files.count(name) != 0);
+       sanity_check(m_files.count(name) != 0);
 
        FileStatus *filestatus = m_files[name];
-       assert(!filestatus->received);
-       assert(filestatus->current_remote >= 0);
+       sanity_check(!filestatus->received);
+       sanity_check(filestatus->current_remote >= 0);
 
        RemoteServerStatus *remote = m_remotes[filestatus->current_remote];
 
@@ -382,6 +381,7 @@ void ClientMediaDownloader::remoteMediaReceived(
 
 s32 ClientMediaDownloader::selectRemoteServer(FileStatus *filestatus)
 {
+       // Pre-conditions
        assert(filestatus != NULL);
        assert(!filestatus->received);
        assert(filestatus->current_remote < 0);
@@ -483,12 +483,12 @@ void ClientMediaDownloader::startRemoteMediaTransfers()
 
 void ClientMediaDownloader::startConventionalTransfers(Client *client)
 {
-       assert(m_httpfetch_active == 0);
+       assert(m_httpfetch_active == 0);        // pre-condition
 
        if (m_uncached_received_count != m_uncached_count) {
                // Some media files have not been received yet, use the
                // conventional slow method (minetest protocol) to get them
-               std::list<std::string> file_requests;
+               std::vector<std::string> file_requests;
                for (std::map<std::string, FileStatus*>::iterator
                                it = m_files.begin();
                                it != m_files.end(); ++it) {
@@ -616,7 +616,7 @@ std::string ClientMediaDownloader::serializeRequiredHashSet()
                        it = m_files.begin();
                        it != m_files.end(); ++it) {
                if (!it->second->received) {
-                       assert(it->second->sha1.size() == 20);
+                       FATAL_ERROR_IF(it->second->sha1.size() != 20, "Invalid SHA1 size");
                        os << it->second->sha1;
                }
        }