diff options
author | Elijah Duffy <enduffy2014@outlook.com> | 2017-07-14 11:37:58 -0700 |
---|---|---|
committer | Loïc Blot <nerzhul@users.noreply.github.com> | 2017-07-14 20:37:58 +0200 |
commit | dc3ca09e0e0e25f40cccae12c73830b0334ffb60 (patch) | |
tree | 25ce565ec4db341868754b004fe167c452950b50 /src | |
parent | 32b68de65a303f0e063cb0d61a79ff7b4837ad7f (diff) | |
download | minetest-dc3ca09e0e0e25f40cccae12c73830b0334ffb60.tar.gz minetest-dc3ca09e0e0e25f40cccae12c73830b0334ffb60.tar.bz2 minetest-dc3ca09e0e0e25f40cccae12c73830b0334ffb60.zip |
Remove remaining modstore code (#6120)
Diffstat (limited to 'src')
-rw-r--r-- | src/convert_json.cpp | 321 | ||||
-rw-r--r-- | src/convert_json.h | 6 | ||||
-rw-r--r-- | src/defaultsettings.cpp | 3 | ||||
-rw-r--r-- | src/mods.cpp | 19 | ||||
-rw-r--r-- | src/mods.h | 60 | ||||
-rw-r--r-- | src/script/lua_api/l_mainmenu.cpp | 145 | ||||
-rw-r--r-- | src/script/lua_api/l_mainmenu.h | 4 | ||||
-rw-r--r-- | src/settings_translation_file.cpp | 3 |
8 files changed, 0 insertions, 561 deletions
diff --git a/src/convert_json.cpp b/src/convert_json.cpp index e548c45f5..1343903b4 100644 --- a/src/convert_json.cpp +++ b/src/convert_json.cpp @@ -64,324 +64,3 @@ Json::Value fetchJsonValue(const std::string &url, return root; } - -std::vector<ModStoreMod> readModStoreList(Json::Value& modlist) { - std::vector<ModStoreMod> retval; - - if (modlist.isArray()) { - for (unsigned int i = 0; i < modlist.size(); i++) - { - ModStoreMod toadd; - toadd.valid = true; - - //id - if (modlist[i]["id"].asString().size()) { - std::string id_raw = modlist[i]["id"].asString(); - char* endptr = 0; - int numbervalue = strtol(id_raw.c_str(),&endptr,10); - - if ((id_raw != "") && (*endptr == 0)) { - toadd.id = numbervalue; - } - else { - errorstream << "readModStoreList: missing id" << std::endl; - toadd.valid = false; - } - } - else { - errorstream << "readModStoreList: missing id" << std::endl; - toadd.valid = false; - } - - //title - if (modlist[i]["title"].asString().size()) { - toadd.title = modlist[i]["title"].asString(); - } - else { - errorstream << "readModStoreList: missing title" << std::endl; - toadd.valid = false; - } - - //basename - if (modlist[i]["basename"].asString().size()) { - toadd.basename = modlist[i]["basename"].asString(); - } - else { - errorstream << "readModStoreList: missing basename" << std::endl; - toadd.valid = false; - } - - //author - - //rating - - //version - - if (toadd.valid) { - retval.push_back(toadd); - } - } - } - return retval; -} - -ModStoreModDetails readModStoreModDetails(Json::Value& details) { - - ModStoreModDetails retval; - - retval.valid = true; - - //version set - if (details["version_set"].isArray()) { - for (unsigned int i = 0; i < details["version_set"].size(); i++) - { - ModStoreVersionEntry toadd; - - if (details["version_set"][i]["id"].asString().size()) { - std::string id_raw = details["version_set"][i]["id"].asString(); - char* endptr = 0; - int numbervalue = strtol(id_raw.c_str(),&endptr,10); - - if ((id_raw != "") && (*endptr == 0)) { - toadd.id = numbervalue; - } - } - else { - errorstream << "readModStoreModDetails: missing version_set id" << std::endl; - retval.valid = false; - } - - //date - if (details["version_set"][i]["date"].asString().size()) { - toadd.date = details["version_set"][i]["date"].asString(); - } - - //file - if (details["version_set"][i]["file"].asString().size()) { - toadd.file = details["version_set"][i]["file"].asString(); - } - else { - errorstream << "readModStoreModDetails: missing version_set file" << std::endl; - retval.valid = false; - } - - //approved - - //mtversion - - if( retval.valid ) { - retval.versions.push_back(toadd); - } - else { - break; - } - } - } - - if (retval.versions.size() < 1) { - infostream << "readModStoreModDetails: not a single version specified!" << std::endl; - retval.valid = false; - } - - //categories - if (details["categories"].isObject()) { - for (unsigned int i = 0; i < details["categories"].size(); i++) { - ModStoreCategoryInfo toadd; - - if (details["categories"][i]["id"].asString().size()) { - - std::string id_raw = details["categories"][i]["id"].asString(); - char* endptr = 0; - int numbervalue = strtol(id_raw.c_str(),&endptr,10); - - if ((id_raw != "") && (*endptr == 0)) { - toadd.id = numbervalue; - } - } - else { - errorstream << "readModStoreModDetails: missing categories id" << std::endl; - retval.valid = false; - } - if (details["categories"][i]["title"].asString().size()) { - toadd.name = details["categories"][i]["title"].asString(); - } - else { - errorstream << "readModStoreModDetails: missing categories title" << std::endl; - retval.valid = false; - } - - if( retval.valid ) { - retval.categories.push_back(toadd); - } - else { - break; - } - } - } - - //author - if (details["author"].isObject()) { - if (details["author"]["id"].asString().size()) { - - std::string id_raw = details["author"]["id"].asString(); - char* endptr = 0; - int numbervalue = strtol(id_raw.c_str(),&endptr,10); - - if ((id_raw != "") && (*endptr == 0)) { - retval.author.id = numbervalue; - } - else { - errorstream << "readModStoreModDetails: missing author id (convert)" << std::endl; - retval.valid = false; - } - } - else { - errorstream << "readModStoreModDetails: missing author id" << std::endl; - retval.valid = false; - } - - if (details["author"]["username"].asString().size()) { - retval.author.username = details["author"]["username"].asString(); - } - else { - errorstream << "readModStoreModDetails: missing author username" << std::endl; - retval.valid = false; - } - } - else { - errorstream << "readModStoreModDetails: missing author" << std::endl; - retval.valid = false; - } - - //license - if (details["license"].isObject()) { - if (details["license"]["id"].asString().size()) { - - std::string id_raw = details["license"]["id"].asString(); - char* endptr = 0; - int numbervalue = strtol(id_raw.c_str(),&endptr,10); - - if ((id_raw != "") && (*endptr == 0)) { - retval.license.id = numbervalue; - } - } - else { - errorstream << "readModStoreModDetails: missing license id" << std::endl; - retval.valid = false; - } - - if (details["license"]["short"].asString().size()) { - retval.license.shortinfo = details["license"]["short"].asString(); - } - else { - errorstream << "readModStoreModDetails: missing license short" << std::endl; - retval.valid = false; - } - - if (details["license"]["link"].asString().size()) { - retval.license.url = details["license"]["link"].asString(); - } - - } - - //titlepic - if (details["titlepic"].isObject()) { - if (details["titlepic"]["id"].asString().size()) { - - std::string id_raw = details["titlepic"]["id"].asString(); - char* endptr = 0; - int numbervalue = strtol(id_raw.c_str(),&endptr,10); - - if ((id_raw != "") && (*endptr == 0)) { - retval.titlepic.id = numbervalue; - } - } - - if (details["titlepic"]["file"].asString().size()) { - retval.titlepic.file = details["titlepic"]["file"].asString(); - } - - if (details["titlepic"]["desc"].asString().size()) { - retval.titlepic.description = details["titlepic"]["desc"].asString(); - } - - if (details["titlepic"]["mod"].asString().size()) { - - std::string mod_raw = details["titlepic"]["mod"].asString(); - char* endptr = 0; - int numbervalue = strtol(mod_raw.c_str(),&endptr,10); - - if ((mod_raw != "") && (*endptr == 0)) { - retval.titlepic.mod = numbervalue; - } - } - } - - //id - if (details["id"].asString().size()) { - - std::string id_raw = details["id"].asString(); - char* endptr = 0; - int numbervalue = strtol(id_raw.c_str(),&endptr,10); - - if ((id_raw != "") && (*endptr == 0)) { - retval.id = numbervalue; - } - } - else { - errorstream << "readModStoreModDetails: missing id" << std::endl; - retval.valid = false; - } - - //title - if (details["title"].asString().size()) { - retval.title = details["title"].asString(); - } - else { - errorstream << "readModStoreModDetails: missing title" << std::endl; - retval.valid = false; - } - - //basename - if (details["basename"].asString().size()) { - retval.basename = details["basename"].asString(); - } - else { - errorstream << "readModStoreModDetails: missing basename" << std::endl; - retval.valid = false; - } - - //description - if (details["desc"].asString().size()) { - retval.description = details["desc"].asString(); - } - - //repository - if (details["replink"].asString().size()) { - retval.repository = details["replink"].asString(); - } - - //value - if (details["value"].isInt()) { - retval.rating = details["value"].asInt(); - } else { - retval.rating = 0; - } - - //depends - if (details["depends"].isArray()) { - //TODO - } - - //softdepends - if (details["softdep"].isArray()) { - //TODO - } - - //screenshot url - if (details["screenshot_url"].asString().size()) { - retval.screenshot_url = details["screenshot_url"].asString(); - } - - return retval; -} diff --git a/src/convert_json.h b/src/convert_json.h index 55321af5f..b5831884f 100644 --- a/src/convert_json.h +++ b/src/convert_json.h @@ -22,12 +22,6 @@ with this program; if not, write to the Free Software Foundation, Inc., #include <json/json.h> -struct ModStoreMod; -struct ModStoreModDetails; - -std::vector<ModStoreMod> readModStoreList(Json::Value& modlist); -ModStoreModDetails readModStoreModDetails(Json::Value& details); - Json::Value fetchJsonValue(const std::string &url, std::vector<std::string> *extra_headers); diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp index fe3a4d275..707f2c3aa 100644 --- a/src/defaultsettings.cpp +++ b/src/defaultsettings.cpp @@ -221,9 +221,6 @@ void set_default_settings(Settings *settings) settings->setDefault("main_menu_path", ""); settings->setDefault("main_menu_mod_mgr", "1"); settings->setDefault("main_menu_game_mgr", "0"); - settings->setDefault("modstore_download_url", "https://forum.minetest.net/media/"); - settings->setDefault("modstore_listmods_url", "https://forum.minetest.net/mmdb/mods/"); - settings->setDefault("modstore_details_url", "https://forum.minetest.net/mmdb/mod/*/"); settings->setDefault("serverlist_file", "favoriteservers.txt"); #if USE_FREETYPE diff --git a/src/mods.cpp b/src/mods.cpp index a555a5b13..7e2d83944 100644 --- a/src/mods.cpp +++ b/src/mods.cpp @@ -365,25 +365,6 @@ ClientModConfiguration::ClientModConfiguration(const std::string &path): } #endif -#if USE_CURL -Json::Value getModstoreUrl(const std::string &url) -{ - std::vector<std::string> extra_headers; - - bool special_http_header = true; - - try { - special_http_header = g_settings->getBool("modstore_disable_special_http_header"); - } catch (SettingNotFoundException) {} - - if (special_http_header) { - extra_headers.push_back("Accept: application/vnd.minetest.mmdb-v1+json"); - } - return fetchJsonValue(url, special_http_header ? &extra_headers : NULL); -} - -#endif - ModMetadata::ModMetadata(const std::string &mod_name): m_mod_name(mod_name) { diff --git a/src/mods.h b/src/mods.h index 1a5c32692..697fed38b 100644 --- a/src/mods.h +++ b/src/mods.h @@ -141,15 +141,6 @@ public: }; #endif -#if USE_CURL -Json::Value getModstoreUrl(const std::string &url); -#else -inline Json::Value getModstoreUrl(const std::string &url) -{ - return Json::Value(); -} -#endif - struct ModLicenseInfo { int id; std::string shortinfo; @@ -161,57 +152,6 @@ struct ModAuthorInfo { std::string username; }; -struct ModStoreMod { - int id; - std::string title; - std::string basename; - ModAuthorInfo author; - float rating; - bool valid; -}; - -struct ModStoreCategoryInfo { - int id; - std::string name; -}; - -struct ModStoreVersionEntry { - int id; - std::string date; - std::string file; - bool approved; - //ugly version number - int mtversion; -}; - -struct ModStoreTitlePic { - int id; - std::string file; - std::string description; - int mod; -}; - -struct ModStoreModDetails { - /* version_set?? */ - std::vector<ModStoreCategoryInfo> categories; - ModAuthorInfo author; - ModLicenseInfo license; - ModStoreTitlePic titlepic; - int id; - std::string title; - std::string basename; - std::string description; - std::string repository; - float rating; - std::vector<std::string> depends; - std::vector<std::string> softdeps; - - std::string download_url; - std::string screenshot_url; - std::vector<ModStoreVersionEntry> versions; - bool valid; -}; - class ModMetadata: public Metadata { public: diff --git a/src/script/lua_api/l_mainmenu.cpp b/src/script/lua_api/l_mainmenu.cpp index 917fea134..b0ce6b740 100644 --- a/src/script/lua_api/l_mainmenu.cpp +++ b/src/script/lua_api/l_mainmenu.cpp @@ -311,147 +311,6 @@ int ModApiMainMenu::l_get_games(lua_State *L) return 1; } /******************************************************************************/ -int ModApiMainMenu::l_get_modstore_details(lua_State *L) -{ - const char *modid = luaL_checkstring(L, 1); - - if (modid != 0) { - Json::Value details; - std::string url = ""; - try{ - url = g_settings->get("modstore_details_url"); - } - catch(SettingNotFoundException &e) { - lua_pushnil(L); - return 1; - } - - size_t idpos = url.find("*"); - url.erase(idpos,1); - url.insert(idpos,modid); - - details = getModstoreUrl(url); - - ModStoreModDetails current_mod = readModStoreModDetails(details); - - if ( current_mod.valid) { - lua_newtable(L); - int top = lua_gettop(L); - - lua_pushstring(L,"id"); - lua_pushnumber(L,current_mod.id); - lua_settable(L, top); - - lua_pushstring(L,"title"); - lua_pushstring(L,current_mod.title.c_str()); - lua_settable(L, top); - - lua_pushstring(L,"basename"); - lua_pushstring(L,current_mod.basename.c_str()); - lua_settable(L, top); - - lua_pushstring(L,"description"); - lua_pushstring(L,current_mod.description.c_str()); - lua_settable(L, top); - - lua_pushstring(L,"author"); - lua_pushstring(L,current_mod.author.username.c_str()); - lua_settable(L, top); - - lua_pushstring(L,"download_url"); - lua_pushstring(L,current_mod.versions[0].file.c_str()); - lua_settable(L, top); - - lua_pushstring(L,"versions"); - lua_newtable(L); - int versionstop = lua_gettop(L); - for (unsigned int i=0;i < current_mod.versions.size(); i++) { - lua_pushnumber(L,i+1); - lua_newtable(L); - int current_element = lua_gettop(L); - - lua_pushstring(L,"date"); - lua_pushstring(L,current_mod.versions[i].date.c_str()); - lua_settable(L,current_element); - - lua_pushstring(L,"download_url"); - lua_pushstring(L,current_mod.versions[i].file.c_str()); - lua_settable(L,current_element); - - lua_settable(L,versionstop); - } - lua_settable(L, top); - - lua_pushstring(L,"screenshot_url"); - lua_pushstring(L,current_mod.titlepic.file.c_str()); - lua_settable(L, top); - - lua_pushstring(L,"license"); - lua_pushstring(L,current_mod.license.shortinfo.c_str()); - lua_settable(L, top); - - lua_pushstring(L,"rating"); - lua_pushnumber(L,current_mod.rating); - lua_settable(L, top); - - //TODO depends - - //TODO softdepends - return 1; - } - } - return 0; -} - -/******************************************************************************/ -int ModApiMainMenu::l_get_modstore_list(lua_State *L) -{ - Json::Value mods; - std::string url = ""; - try{ - url = g_settings->get("modstore_listmods_url"); - } - catch(SettingNotFoundException &e) { - lua_pushnil(L); - return 1; - } - - mods = getModstoreUrl(url); - - std::vector<ModStoreMod> moddata = readModStoreList(mods); - - lua_newtable(L); - int top = lua_gettop(L); - unsigned int index = 1; - - for (unsigned int i = 0; i < moddata.size(); i++) - { - if (moddata[i].valid) { - lua_pushnumber(L,index); - lua_newtable(L); - - int top_lvl2 = lua_gettop(L); - - lua_pushstring(L,"id"); - lua_pushnumber(L,moddata[i].id); - lua_settable(L, top_lvl2); - - lua_pushstring(L,"title"); - lua_pushstring(L,moddata[i].title.c_str()); - lua_settable(L, top_lvl2); - - lua_pushstring(L,"basename"); - lua_pushstring(L,moddata[i].basename.c_str()); - lua_settable(L, top_lvl2); - - lua_settable(L, top); - index++; - } - } - return 1; -} - -/******************************************************************************/ int ModApiMainMenu::l_get_favorites(lua_State *L) { std::string listtype = "local"; @@ -1137,8 +996,6 @@ void ModApiMainMenu::Initialize(lua_State *L, int top) API_FCT(get_mainmenu_path); API_FCT(show_path_select_dialog); API_FCT(download_file); - API_FCT(get_modstore_details); - API_FCT(get_modstore_list); API_FCT(gettext); API_FCT(get_video_drivers); API_FCT(get_video_modes); @@ -1166,7 +1023,5 @@ void ModApiMainMenu::InitializeAsync(lua_State *L, int top) API_FCT(copy_dir); //API_FCT(extract_zip); //TODO remove dependency to GuiEngine API_FCT(download_file); - API_FCT(get_modstore_details); - API_FCT(get_modstore_list); //API_FCT(gettext); (gettext lib isn't threadsafe) } diff --git a/src/script/lua_api/l_mainmenu.h b/src/script/lua_api/l_mainmenu.h index 1d3e931e1..4be07576c 100644 --- a/src/script/lua_api/l_mainmenu.h +++ b/src/script/lua_api/l_mainmenu.h @@ -124,10 +124,6 @@ private: static int l_extract_zip(lua_State *L); - static int l_get_modstore_details(lua_State *L); - - static int l_get_modstore_list(lua_State *L); - static int l_download_file(lua_State *L); static int l_get_video_drivers(lua_State *L); diff --git a/src/settings_translation_file.cpp b/src/settings_translation_file.cpp index 3cd0755a6..d472852b8 100644 --- a/src/settings_translation_file.cpp +++ b/src/settings_translation_file.cpp @@ -769,9 +769,6 @@ fake_function() { gettext("Replaces the default main menu with a custom one."); gettext("Main menu game manager"); gettext("Main menu mod manager"); - gettext("Modstore download URL"); - gettext("Modstore mods list URL"); - gettext("Modstore details URL"); gettext("Engine profiling data print interval"); gettext("Print the engine's profiling data in regular intervals (in seconds). 0 = disable. Useful for developers."); } |