aboutsummaryrefslogtreecommitdiff
path: root/games
Commit message (Expand)AuthorAge
* Fix relief mapping issuesRealBadAngel2015-07-16
* Minimal: Remove recently added unnecessary nodesparamat2015-07-14
* Simpler patch for saplings trying to grow on unknown nodesShadowNinja2015-06-16
* Add list-ringsest312015-06-16
* Don't crash when saplings try to grow on unknown nodesy.st2015-06-15
* Minimal: Add snow biome and jungleleaves nodes. Add mapgen aliasesparamat2015-06-12
* Minimal: Edit mapgen aliases. Use blob ore for clay, update other ores. Updat...paramat2015-06-09
* Fix NDT_GLASSLIKE normalsKahrl2015-01-31
* Remove builtin_biome.lua from builtin and add simple biome minimalparamat2015-01-11
* Add lua exception handling test codesapier2014-08-23
* Minimal game: add /dummyball <count> commandKahrl2014-08-23
* Add minetest.swap_nodeNovatux2013-11-30
* Change default value of is_ground_content to truekwolekr2013-11-30
* Fix possible crash with grass ABM.Novatux2013-11-02
* Fix grass adding/removing ABM.Novatux2013-11-02
* Move the sapling growing and grass adding/removing ABMs to LuaNovatux2013-11-02
* Remove mapgen_air alias (#935)0gb.us2013-10-05
* Add mapgen_stair_cobble alias to minimalSfan52013-09-06
* Add support for different drowning damage and allow drowning in other nodetypesBlockMen2013-08-06
* Add drowningPilzAdam2013-06-19
* Compress texturesDavid Gumberg2013-06-18
* Move scriptapi to separate folder (by sapier)sapier2013-05-25
* Use the group "soil" for nodes that saplings grow onShadowNinja2013-05-20
* games/minimal: Add menu/background.png and menu/icon.pngPerttu Ahola2013-05-02
* Add Mapgen V7, reorganize biomeskwolekr2013-04-07
* unkn own block -> unkn own nodekhonkhortisan2013-04-05
* Add different place sound for nodesPilzAdam2013-03-29
* Use minetest.register_ore() in minimalPilzAdam2013-03-24
* Mapgen indev: float islands, larger far biomesproller2013-03-24
* Liquid fine tuningproller2013-03-14
* new adjustable finite liquidproller2013-02-24
* Readded and optimized mapgen V6kwolekr2013-01-21
* Add initial Lua biomedef support, fixed biome selectionkwolekr2013-01-21
* Add the group attached_nodePilzAdam2012-12-01
* Swap out pixel-perfect nyan cat by request of Chris TorresPerttu Ahola2012-11-09
* Add functions to the default mod of minimal game to support old codePilzAdam2012-11-01
* Move falling to builtinPilzAdam2012-10-31
* Fix crash when furnace is full (minimal game)Perttu Ahola2012-08-12
* Deprecate minetest.add_to_creative_inventory and use group not_in_creative_in...Perttu Ahola2012-07-25
* Add notice in the minimal gamePerttu Ahola2012-07-25
* Improve inventory callbacks a bitPerttu Ahola2012-07-25
* Detached inventory callbacks and reworked node metadata callbacksPerttu Ahola2012-07-25
* Detached inventoriesPerttu Ahola2012-07-24
* Add node timer test in minimal/experimentalPerttu Ahola2012-07-24
* Move /give, /giveme, /spawnentity and /pulverize to builtin/chatcommands.luaPerttu Ahola2012-07-23
* Formspec button_exit[] and image_button_exit[]Perttu Ahola2012-07-22
* Add /test1 command to minimal for testing a more complicated player inventory...Perttu Ahola2012-07-22
* Implement formspecdarkrose2012-07-22
* Actually fix facedir-rotated nodes placed using minetest.env:place_node()Perttu Ahola2012-07-21
* Make lava buckets work as fuel in minimal gamedarkrose2012-07-21
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include <vector> #include <iostream> #include <sstream> #include "convert_json.h" #include "mods.h" #include "config.h" #include "log.h" #include "settings.h" #include "httpfetch.h" #include "porting.h" 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; if (extra_headers != NULL) fetch_request.extra_headers = *extra_headers; httpfetch_sync(fetch_request, fetch_result); if (!fetch_result.succeeded) { return Json::Value(); } Json::Value root; Json::Reader reader; std::istringstream stream(fetch_result.data); if (!reader.parse(stream, root)) { errorstream << "URL: " << url << std::endl; errorstream << "Failed to parse json data " << reader.getFormattedErrorMessages(); if (fetch_result.data.size() > 100) { errorstream << "Data (" << fetch_result.data.size() << " bytes) printed to warningstream." << std::endl; warningstream << "data: \"" << fetch_result.data << "\"" << std::endl; } else { errorstream << "data: \"" << fetch_result.data << "\"" << std::endl; } return Json::Value(); } 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; }