Optimize and fix autodownload feature
The commit: 1. fixes value of download speed in KB; 2. introduces unique names of progress_callback() functions; 3. removes one unnecessary write_callback() function; 4. removes duplicated code/info in loadmodel().
This commit is contained in:
@@ -1301,6 +1301,7 @@ void clearservers()
|
||||
}
|
||||
|
||||
#define RETRIEVELIMIT 5000
|
||||
extern size_t write_callback(void *ptr, size_t size, size_t nmemb, FILE *stream);
|
||||
extern char *global_name;
|
||||
bool cllock = false, clfail = false;
|
||||
|
||||
@@ -1310,7 +1311,7 @@ struct resolver_data
|
||||
string text;
|
||||
};
|
||||
|
||||
static int progress_callback(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow)
|
||||
int progress_callback_retrieveservers(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow)
|
||||
{
|
||||
resolver_data *rd = (resolver_data *)clientp;
|
||||
rd->timeout = SDL_GetTicks() - rd->starttime;
|
||||
@@ -1323,11 +1324,6 @@ static int progress_callback(void *clientp, double dltotal, double dlnow, double
|
||||
return 0;
|
||||
}
|
||||
|
||||
static size_t write_callback(void *ptr, size_t size, size_t nmemb, FILE *stream)
|
||||
{
|
||||
return fwrite(ptr, size, nmemb, stream);
|
||||
}
|
||||
|
||||
void retrieveservers(vector<char> &data)
|
||||
{
|
||||
if(mastertype == AC_MASTER_HTTP)
|
||||
@@ -1361,7 +1357,7 @@ void retrieveservers(vector<char> &data)
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_callback);
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEDATA, outfile);
|
||||
curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0);
|
||||
curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, progress_callback);
|
||||
curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, progress_callback_retrieveservers);
|
||||
curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, rd);
|
||||
curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, RETRIEVELIMIT/1000);
|
||||
result = curl_easy_perform(curl);
|
||||
|
||||
Reference in New Issue
Block a user