From 14011bdc7a86f693409f218a8ce2c32dd8f4fe89 Mon Sep 17 00:00:00 2001 From: rubenwardy Date: Sun, 29 Jul 2018 00:26:03 +0100 Subject: [PATCH] Add protocol_version and supported package types to ContentDB urls --- src/content/packages.cpp | 7 ++++++- src/content/packages.h | 5 +---- src/network/networkprotocol.h | 1 + src/script/lua_api/l_mainmenu.cpp | 5 ++++- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/content/packages.cpp b/src/content/packages.cpp index dd7574d4..2d488eb7 100644 --- a/src/content/packages.cpp +++ b/src/content/packages.cpp @@ -25,6 +25,12 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "content/mods.h" #include "content/subgames.h" +std::string Package::getDownloadURL(const std::string &baseURL) const +{ + return baseURL + "/packages/" + author + "/" + name + "/releases/" + + std::to_string(release) + "/download/"; +} + #if USE_CURL std::vector getPackagesFromURL(const std::string &url) { @@ -60,5 +66,4 @@ std::vector getPackagesFromURL(const std::string &url) return packages; } - #endif diff --git a/src/content/packages.h b/src/content/packages.h index fc60d570..9029475e 100644 --- a/src/content/packages.h +++ b/src/content/packages.h @@ -39,10 +39,7 @@ struct Package type.empty() || release <= 0); } - std::string getDownloadURL(const std::string &baseURL) const - { - return baseURL + "/packages/" + author + "/" + name + "/download/"; - } + std::string getDownloadURL(const std::string &baseURL) const; }; #if USE_CURL diff --git a/src/network/networkprotocol.h b/src/network/networkprotocol.h index 3d682a0a..113b1117 100644 --- a/src/network/networkprotocol.h +++ b/src/network/networkprotocol.h @@ -191,6 +191,7 @@ with this program; if not, write to the Free Software Foundation, Inc., */ #define LATEST_PROTOCOL_VERSION 36 +#define LATEST_PROTOCOL_VERSION_STRING TOSTRING(LATEST_PROTOCOL_VERSION) // Server's supported network protocol range #define SERVER_PROTOCOL_VERSION_MIN 36 diff --git a/src/script/lua_api/l_mainmenu.cpp b/src/script/lua_api/l_mainmenu.cpp index 03b8fe22..c2f0f6e3 100644 --- a/src/script/lua_api/l_mainmenu.cpp +++ b/src/script/lua_api/l_mainmenu.cpp @@ -39,6 +39,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include #include #include "client/renderingengine.h" +#include "network/networkprotocol.h" /******************************************************************************/ @@ -993,7 +994,9 @@ int ModApiMainMenu::l_get_screen_info(lua_State *L) int ModApiMainMenu::l_get_package_list(lua_State *L) { std::string url = g_settings->get("contentdb_url"); - std::vector packages = getPackagesFromURL(url + "/api/packages/"); + std::vector packages = getPackagesFromURL(url + + "/api/packages/?type=mod&type=game&type=txp&protocol_version=" + LATEST_PROTOCOL_VERSION_STRING); // Make table lua_newtable(L);