diff options
author | sapier <Sapier at GMX dot net> | 2013-07-13 01:36:58 +0200 |
---|---|---|
committer | PilzAdam <pilzadam@minetest.net> | 2013-07-22 18:09:59 +0200 |
commit | 5c7ecdb7c583c98cbe6bdf54ae7a07e6a6a61007 (patch) | |
tree | 3f169f5908df7afd7a20331f3bb96d37d3e81212 /src | |
parent | 80a2acaa86de99356879f3c79adb63fea47d00ee (diff) | |
download | minetest-5c7ecdb7c583c98cbe6bdf54ae7a07e6a6a61007.tar.gz minetest-5c7ecdb7c583c98cbe6bdf54ae7a07e6a6a61007.tar.bz2 minetest-5c7ecdb7c583c98cbe6bdf54ae7a07e6a6a61007.zip |
Add support for modstore screenshots
Add error output on invalid mmdb entries
Diffstat (limited to 'src')
-rw-r--r-- | src/convert_json.cpp | 50 | ||||
-rw-r--r-- | src/guiLuaApi.cpp | 4 | ||||
-rw-r--r-- | src/mods.h | 8 |
3 files changed, 62 insertions, 0 deletions
diff --git a/src/convert_json.cpp b/src/convert_json.cpp index 9b704aca6..71cba0695 100644 --- a/src/convert_json.cpp +++ b/src/convert_json.cpp @@ -111,6 +111,7 @@ std::vector<ModStoreMod> readModStoreList(Json::Value& modlist) { } } else { + errorstream << "readModStoreList: missing id" << std::endl; toadd.valid = false; } @@ -119,6 +120,7 @@ std::vector<ModStoreMod> readModStoreList(Json::Value& modlist) { toadd.title = modlist[i]["title"].asString(); } else { + errorstream << "readModStoreList: missing title" << std::endl; toadd.valid = false; } @@ -127,6 +129,7 @@ std::vector<ModStoreMod> readModStoreList(Json::Value& modlist) { toadd.basename = modlist[i]["basename"].asString(); } else { + errorstream << "readModStoreList: missing basename" << std::endl; toadd.valid = false; } @@ -166,6 +169,7 @@ ModStoreModDetails readModStoreModDetails(Json::Value& details) { } } else { + errorstream << "readModStoreModDetails: missing version_set id" << std::endl; retval.valid = false; } @@ -179,6 +183,7 @@ ModStoreModDetails readModStoreModDetails(Json::Value& details) { toadd.file = details["version_set"][i]["file"].asString(); } else { + errorstream << "readModStoreModDetails: missing version_set file" << std::endl; retval.valid = false; } @@ -196,6 +201,7 @@ ModStoreModDetails readModStoreModDetails(Json::Value& details) { } if (retval.versions.size() < 1) { + errorstream << "readModStoreModDetails: not a single version specified!" << std::endl; retval.valid = false; } @@ -215,12 +221,14 @@ ModStoreModDetails readModStoreModDetails(Json::Value& details) { } } 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; } @@ -245,10 +253,12 @@ ModStoreModDetails readModStoreModDetails(Json::Value& details) { 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; } @@ -256,10 +266,12 @@ ModStoreModDetails readModStoreModDetails(Json::Value& details) { 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; } @@ -276,6 +288,7 @@ ModStoreModDetails readModStoreModDetails(Json::Value& details) { } } else { + errorstream << "readModStoreModDetails: missing license id" << std::endl; retval.valid = false; } @@ -283,6 +296,7 @@ ModStoreModDetails readModStoreModDetails(Json::Value& details) { retval.license.shortinfo = details["license"]["short"].asString(); } else { + errorstream << "readModStoreModDetails: missing license short" << std::endl; retval.valid = false; } @@ -292,6 +306,39 @@ ModStoreModDetails readModStoreModDetails(Json::Value& details) { } + //titlepic + if (details["titlepic"].isObject()) { + if (details["titlepic"]["id"].asString().size()) { + + const char* id_raw = details["titlepic"]["id"].asString().c_str(); + char* endptr = 0; + int numbervalue = strtol(id_raw,&endptr,10); + + if ((*id_raw != 0) && (*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()) { + + const char* mod_raw = details["titlepic"]["mod"].asString().c_str(); + char* endptr = 0; + int numbervalue = strtol(mod_raw,&endptr,10); + + if ((*mod_raw != 0) && (*endptr == 0)) { + retval.titlepic.mod = numbervalue; + } + } + } + //id if (details["id"].asString().size()) { @@ -304,6 +351,7 @@ ModStoreModDetails readModStoreModDetails(Json::Value& details) { } } else { + errorstream << "readModStoreModDetails: missing id" << std::endl; retval.valid = false; } @@ -312,6 +360,7 @@ ModStoreModDetails readModStoreModDetails(Json::Value& details) { retval.title = details["title"].asString(); } else { + errorstream << "readModStoreModDetails: missing title" << std::endl; retval.valid = false; } @@ -320,6 +369,7 @@ ModStoreModDetails readModStoreModDetails(Json::Value& details) { retval.basename = details["basename"].asString(); } else { + errorstream << "readModStoreModDetails: missing basename" << std::endl; retval.valid = false; } diff --git a/src/guiLuaApi.cpp b/src/guiLuaApi.cpp index 4ed5cb24c..6bf8df607 100644 --- a/src/guiLuaApi.cpp +++ b/src/guiLuaApi.cpp @@ -430,6 +430,10 @@ int guiLuaApi::l_get_modstore_details(lua_State *L) lua_pushstring(L,current_mod.versions[0].file.c_str()); 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); diff --git a/src/mods.h b/src/mods.h index eb453bf6a..e10d49324 100644 --- a/src/mods.h +++ b/src/mods.h @@ -202,11 +202,19 @@ struct ModStoreVersionEntry { 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; |