]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - src/convert_json.cpp
Remove unused variable Client::m_active_blocks
[dragonfireclient.git] / src / convert_json.cpp
index a6107aa64a7fec1790e9d133c9fabb6c95a2178b..e03508e21fe2d0a77a76013d3f3a79a3168c9a0c 100644 (file)
@@ -25,55 +25,38 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "mods.h"
 #include "config.h"
 #include "log.h"
-#include "main.h" // for g_settings
 #include "settings.h"
-#include "version.h"
 #include "httpfetch.h"
 #include "porting.h"
 
-Json::Value                 fetchJsonValue(const std::string &url,
-               struct curl_slist *chunk) {
+Json::Value fetchJsonValue(const std::string &url,
+               std::vector<std::string> *extra_headers)
+{
+       HTTPFetchRequest fetch_request;
+       HTTPFetchResult fetch_result;
+       fetch_request.url = url;
+       fetch_request.caller = HTTPFETCH_SYNC;
 
-       HTTPFetchRequest fetchrequest;
-       HTTPFetchResult fetchresult;
-       fetchrequest.url = url;
-       fetchrequest.caller = HTTPFETCH_SYNC;
+       if (extra_headers != NULL)
+               fetch_request.extra_headers = *extra_headers;
 
-#if USE_CURL
-       struct curl_slist* runptr = chunk;
-       while(runptr) {
-               fetchrequest.extra_headers.push_back(runptr->data);
-               runptr = runptr->next;
-       }
-#endif
-       httpfetch_sync(fetchrequest,fetchresult);
+       httpfetch_sync(fetch_request, fetch_result);
 
-       if (!fetchresult.succeeded) {
+       if (!fetch_result.succeeded) {
                return Json::Value();
        }
        Json::Value root;
        Json::Reader reader;
-       std::istringstream stream(fetchresult.data);
+       std::istringstream stream(fetch_result.data);
 
-       if (!reader.parse( stream, root ) )
-       {
+       if (!reader.parse(stream, root)) {
                errorstream << "URL: " << url << std::endl;
                errorstream << "Failed to parse json data " << reader.getFormattedErrorMessages();
-               errorstream << "data: \"" << fetchresult.data << "\"" << std::endl;
+               errorstream << "data: \"" << fetch_result.data << "\"" << std::endl;
                return Json::Value();
        }
 
-       if (root.isArray()) {
-               return root;
-       }
-       if ((root["list"].isArray())) {
-               return root["list"];
-       }
-       else {
-               return root;
-       }
-
-       return Json::Value();
+       return root;
 }
 
 std::vector<ModStoreMod>    readModStoreList(Json::Value& modlist) {
@@ -373,18 +356,10 @@ ModStoreModDetails          readModStoreModDetails(Json::Value& details) {
        }
 
        //value
-       if (details["rating"].asString().size()) {
-
-               std::string id_raw = details["rating"].asString();
-               char* endptr = 0;
-               float numbervalue = strtof(id_raw.c_str(),&endptr);
-
-               if ((id_raw != "") && (*endptr == 0)) {
-                       retval.rating = numbervalue;
-               }
-       }
-       else {
-               retval.rating = 0.0;
+       if (details["value"].isInt()) {
+               retval.rating = details["value"].asInt();
+       } else {
+               retval.rating = 0;
        }
 
        //depends